⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 x86_64.inc

📁 一个用纯汇编 写的操作系统 源代码 是用 TASM 编译器写的
💻 INC
📖 第 1 页 / 共 5 页
字号:
enter_instruction:
	lods	byte [esi]
	call	get_size_operator
	cmp	ah,2
	je	enter_imm16_size_ok
	or	ah,ah
	jnz	invalid_operand_size
      enter_imm16_size_ok:
	cmp	al,'('
	jne	invalid_operand
	call	get_word_value
	cmp	[next_pass_needed],0
	jne	enter_imm16_ok
	cmp	[value_type],0
	jne	invalid_use_of_symbol
      enter_imm16_ok:
	push	eax
	mov	[operand_size],0
	lods	byte [esi]
	cmp	al,','
	jne	invalid_operand
	lods	byte [esi]
	call	get_size_operator
	cmp	ah,1
	je	enter_imm8_size_ok
	or	ah,ah
	jnz	invalid_operand_size
      enter_imm8_size_ok:
	cmp	al,'('
	jne	invalid_operand
	call	get_byte_value
	mov	dl,al
	pop	ebx
	mov	al,0C8h
	stos	byte [edi]
	mov	ax,bx
	stos	word [edi]
	mov	al,dl
	stos	byte [edi]
	jmp	instruction_assembled
ret_instruction_only64:
	cmp	[code_type],64
	jne	illegal_instruction
	jmp	ret_instruction
ret_instruction_32bit_except64:
	cmp	[code_type],64
	je	illegal_instruction
ret_instruction_32bit:
	call	operand_32bit
	jmp	ret_instruction
ret_instruction_16bit:
	call	operand_16bit
	jmp	ret_instruction
retf_instruction:
	cmp	[code_type],64
	jne	ret_instruction
ret_instruction_64bit:
	call	operand_64bit
ret_instruction:
	mov	[base_code],al
	lods	byte [esi]
	dec	esi
	or	al,al
	jz	simple_ret
	cmp	al,0Fh
	je	simple_ret
	lods	byte [esi]
	call	get_size_operator
	or	ah,ah
	jz	ret_imm
	cmp	ah,2
	je	ret_imm
	jmp	invalid_operand_size
      ret_imm:
	cmp	al,'('
	jne	invalid_operand
	call	get_word_value
	cmp	[next_pass_needed],0
	jne	ret_imm_ok
	cmp	[value_type],0
	jne	invalid_use_of_symbol
      ret_imm_ok:
	cmp	[size_declared],0
	jne	ret_imm_store
	or	ax,ax
	jz	simple_ret
      ret_imm_store:
	mov	dx,ax
	call	store_instruction_code
	mov	ax,dx
	stos	word [edi]
	jmp	instruction_assembled
      simple_ret:
	inc	[base_code]
	call	store_instruction_code
	jmp	instruction_assembled
lea_instruction:
	mov	[base_code],8Dh
	lods	byte [esi]
	call	get_size_operator
	cmp	al,10h
	jne	invalid_operand
	lods	byte [esi]
	call	convert_register
	mov	[postbyte_register],al
	lods	byte [esi]
	cmp	al,','
	jne	invalid_operand
	xor	al,al
	xchg	al,[operand_size]
	push	eax
	lods	byte [esi]
	call	get_size_operator
	cmp	al,'['
	jne	invalid_operand
	mov	[size_override],-1
	call	get_address
	pop	eax
	mov	[operand_size],al
	call	operand_autodetect
	call	store_instruction
	jmp	instruction_assembled
ls_instruction:
	or	al,al
	jz	les_instruction
	cmp	al,3
	jz	lds_instruction
	add	al,0B0h
	mov	[extended_code],al
	mov	[base_code],0Fh
	jmp	ls_code_ok
      les_instruction:
	mov	[base_code],0C4h
	jmp	ls_short_code
      lds_instruction:
	mov	[base_code],0C5h
      ls_short_code:
	cmp	[code_type],64
	je	illegal_instruction
      ls_code_ok:
	lods	byte [esi]
	call	get_size_operator
	cmp	al,10h
	jne	invalid_operand
	lods	byte [esi]
	call	convert_register
	mov	[postbyte_register],al
	lods	byte [esi]
	cmp	al,','
	jne	invalid_operand
	add	[operand_size],2
	lods	byte [esi]
	call	get_size_operator
	cmp	al,'['
	jne	invalid_operand
	call	get_address
	mov	al,[operand_size]
	cmp	al,4
	je	ls_16bit
	cmp	al,6
	je	ls_32bit
	cmp	al,10
	je	ls_64bit
	jmp	invalid_operand_size
      ls_16bit:
	call	operand_16bit
	call	store_instruction
	jmp	instruction_assembled
      ls_32bit:
	call	operand_32bit
	call	store_instruction
	jmp	instruction_assembled
      ls_64bit:
	call	operand_64bit
	call	store_instruction
	jmp	instruction_assembled
sh_instruction:
	mov	[postbyte_register],al
	lods	byte [esi]
	call	get_size_operator
	cmp	al,10h
	je	sh_reg
	cmp	al,'['
	jne	invalid_operand
      sh_mem:
	call	get_address
	push	edx ebx ecx
	mov	al,[operand_size]
	push	eax
	mov	[operand_size],0
	lods	byte [esi]
	cmp	al,','
	jne	invalid_operand
	lods	byte [esi]
	call	get_size_operator
	cmp	al,'('
	je	sh_mem_imm
	cmp	al,10h
	jne	invalid_operand
      sh_mem_reg:
	lods	byte [esi]
	cmp	al,11h
	jne	invalid_operand
	pop	eax ecx ebx edx
	cmp	al,1
	je	sh_mem_cl_8bit
	jb	sh_mem_cl_nosize
	call	operand_autodetect
	mov	[base_code],0D3h
	call	store_instruction
	jmp	instruction_assembled
      sh_mem_cl_nosize:
	cmp	[error_line],0
	jne	sh_mem_cl_8bit
	mov	eax,[current_line]
	mov	[error_line],eax
	mov	[error],operand_size_not_specified
      sh_mem_cl_8bit:
	mov	[base_code],0D2h
	call	store_instruction
	jmp	instruction_assembled
      sh_mem_imm:
	mov	al,[operand_size]
	or	al,al
	jz	sh_mem_imm_size_ok
	cmp	al,1
	jne	invalid_operand_size
      sh_mem_imm_size_ok:
	call	get_byte_value
	mov	byte [value],al
	pop	eax ecx ebx edx
	cmp	al,1
	je	sh_mem_imm_8bit
	jb	sh_mem_imm_nosize
	call	operand_autodetect
	cmp	byte [value],1
	je	sh_mem_1
	mov	[base_code],0C1h
	call	store_instruction_with_imm8
	jmp	instruction_assembled
      sh_mem_1:
	mov	[base_code],0D1h
	call	store_instruction
	jmp	instruction_assembled
      sh_mem_imm_nosize:
	cmp	[error_line],0
	jne	sh_mem_imm_8bit
	mov	eax,[current_line]
	mov	[error_line],eax
	mov	[error],operand_size_not_specified
      sh_mem_imm_8bit:
	cmp	byte [value],1
	je	sh_mem_1_8bit
	mov	[base_code],0C0h
	call	store_instruction_with_imm8
	jmp	instruction_assembled
      sh_mem_1_8bit:
	mov	[base_code],0D0h
	call	store_instruction
	jmp	instruction_assembled
      sh_reg:
	lods	byte [esi]
	call	convert_register
	mov	bx,ax
	mov	[operand_size],0
	lods	byte [esi]
	cmp	al,','
	jne	invalid_operand
	lods	byte [esi]
	call	get_size_operator
	cmp	al,'('
	je	sh_reg_imm
	cmp	al,10h
	jne	invalid_operand
      sh_reg_reg:
	lods	byte [esi]
	cmp	al,11h
	jne	invalid_operand
	mov	al,bh
	cmp	al,1
	je	sh_reg_cl_8bit
	call	operand_autodetect
	mov	[base_code],0D3h
	call	store_nomem_instruction
	jmp	instruction_assembled
      sh_reg_cl_8bit:
	mov	[base_code],0D2h
	call	store_nomem_instruction
	jmp	instruction_assembled
      sh_reg_imm:
	mov	al,[operand_size]
	or	al,al
	jz	sh_reg_imm_size_ok
	cmp	al,1
	jne	invalid_operand_size
      sh_reg_imm_size_ok:
	push	ebx
	call	get_byte_value
	mov	dl,al
	pop	ebx
	mov	al,bh
	cmp	al,1
	je	sh_reg_imm_8bit
	call	operand_autodetect
	cmp	dl,1
	je	sh_reg_1
	mov	[base_code],0C1h
	call	store_nomem_instruction
	mov	al,dl
	stos	byte [edi]
	jmp	instruction_assembled
      sh_reg_1:
	mov	[base_code],0D1h
	call	store_nomem_instruction
	jmp	instruction_assembled
      sh_reg_imm_8bit:
	cmp	dl,1
	je	sh_reg_1_8bit
	mov	[base_code],0C0h
	call	store_nomem_instruction
	mov	al,dl
	stos	byte [edi]
	jmp	instruction_assembled
      sh_reg_1_8bit:
	mov	[base_code],0D0h
	call	store_nomem_instruction
	jmp	instruction_assembled
shd_instruction:
	mov	[base_code],0Fh
	mov	[extended_code],al
	lods	byte [esi]
	call	get_size_operator
	cmp	al,10h
	je	shd_reg
	cmp	al,'['
	jne	invalid_operand
      shd_mem:
	call	get_address
	push	edx ebx ecx
	lods	byte [esi]
	cmp	al,','
	jne	invalid_operand
	lods	byte [esi]
	call	get_size_operator
	cmp	al,10h
	jne	invalid_operand
	lods	byte [esi]
	call	convert_register
	mov	[postbyte_register],al
	lods	byte [esi]
	cmp	al,','
	jne	invalid_operand
	mov	al,ah
	mov	[operand_size],0
	push	eax
	lods	byte [esi]
	call	get_size_operator
	cmp	al,'('
	je	shd_mem_reg_imm
	cmp	al,10h
	jne	invalid_operand
	lods	byte [esi]
	cmp	al,11h
	jne	invalid_operand
	pop	eax ecx ebx edx
	call	operand_autodetect
	inc	[extended_code]
	call	store_instruction
	jmp	instruction_assembled
      shd_mem_reg_imm:
	mov	al,[operand_size]
	or	al,al
	jz	shd_mem_reg_imm_size_ok
	cmp	al,1
	jne	invalid_operand_size
      shd_mem_reg_imm_size_ok:
	call	get_byte_value
	mov	byte [value],al
	pop	eax ecx ebx edx
	call	operand_autodetect
	call	store_instruction_with_imm8
	jmp	instruction_assembled
      shd_reg:
	lods	byte [esi]
	call	convert_register
	mov	[postbyte_register],al
	lods	byte [esi]
	cmp	al,','
	jne	invalid_operand
	lods	byte [esi]
	call	get_size_operator
	cmp	al,10h
	jne	invalid_operand
	lods	byte [esi]
	call	convert_register
	mov	bl,[postbyte_register]
	mov	[postbyte_register],al
	mov	al,ah
	push	eax ebx
	lods	byte [esi]
	cmp	al,','
	jne	invalid_operand
	mov	[operand_size],0
	lods	byte [esi]
	call	get_size_operator
	cmp	al,'('
	je	shd_reg_reg_imm
	cmp	al,10h
	jne	invalid_operand
	lods	byte [esi]
	cmp	al,11h
	jne	invalid_operand
	pop	ebx eax
	call	operand_autodetect
	inc	[extended_code]
	call	store_nomem_instruction
	jmp	instruction_assembled
      shd_reg_reg_imm:
	mov	al,[operand_size]
	or	al,al
	jz	shd_reg_reg_imm_size_ok
	cmp	al,1
	jne	invalid_operand_size
      shd_reg_reg_imm_size_ok:
	call	get_byte_value
	mov	dl,al
	pop	ebx eax
	call	operand_autodetect
	call	store_nomem_instruction
	mov	al,dl
	stos	byte [edi]
	jmp	instruction_assembled
movx_instruction:
	mov	[base_code],0Fh
	mov	[extended_code],al
	lods	byte [esi]
	call	get_size_operator
	cmp	al,10h
	jne	invalid_operand
	lods	byte [esi]
	call	convert_register
	mov	[postbyte_register],al
	mov	al,ah
	push	eax
	lods	byte [esi]
	cmp	al,','
	jne	invalid_operand
	mov	[operand_size],0
	lods	byte [esi]
	call	get_size_operator
	cmp	al,10h
	je	movx_reg
	cmp	al,'['
	jne	invalid_operand
	call	get_address
	pop	eax
	mov	ah,[operand_size]
	or	ah,ah
	jz	movx_unknown_size
	cmp	ah,al
	jae	invalid_operand_size
	cmp	ah,1
	je	movx_mem_8bit
	cmp	ah,2
	jne	invalid_operand_size
      movx_mem_16bit:
	inc	[extended_code]
	call	operand_autodetect
	call	store_instruction
	jmp	instruction_assembled
      movx_unknown_size:
	cmp	[error_line],0
	jne	movx_mem_8bit
	mov	eax,[current_line]
	mov	[error_line],eax
	mov	[error],operand_size_not_specified
      movx_mem_8bit:
	call	operand_autodetect
	call	store_instruction
	jmp	instruction_assembled
      movx_reg:
	lods	byte [esi]
	call	convert_register
	pop	ebx
	xchg	bl,al
	cmp	ah,al
	jae	invalid_operand_size
	cmp	ah,1
	je	movx_reg_8bit
	cmp	ah,2
	je	movx_reg_16bit
	jmp	invalid_operand_size
      movx_reg_8bit:
	call	operand_autodetect
	call	store_nomem_instruction
	jmp	instruction_assembled
      movx_reg_16bit:
	call	operand_autodetect
	inc	[extended_code]
	call	store_nomem_instruction
	jmp	instruction_assembled
movsxd_instruction:
	mov	[base_code],al
	lods	byte [esi]
	call	get_size_operator
	cmp	al,10h
	jne	invalid_operand
	lods	byte [esi]
	call	convert_register
	mov	[postbyte_register],al
	cmp	ah,8
	jne	invalid_operand_size
	lods	byte [esi]
	cmp	al,','
	jne	invalid_operand
	mov	[operand_size],0
	lods	byte [esi]
	call	get_size_operator
	cmp	al,10h
	je	movsxd_reg
	cmp	al,'['
	jne	invalid_operand
	call	get_address
	cmp	[operand_size],4
	je	movsxd_mem_store
	cmp	[operand_size],0
	jne	invalid_operand_size
      movsxd_mem_store:
	call	operand_64bit
	call	store_instruction
	jmp	instruction_assembled
      movsxd_reg:
	lods	byte [esi]
	call	convert_register
	cmp	ah,4
	jne	invalid_operand_size
	mov	bl,al
	call	operand_64bit
	call	store_nomem_instruction
	jmp	instruction_assembled
bt_instruction:
	mov	[postbyte_register],al
	shl	al,3
	add	al,83h
	mov	[extended_code],al
	mov	[base_code],0Fh
	lods	byte [esi]
	call	get_size_operator
	cmp	al,10h
	je	bt_reg
	cmp	al,'['
	jne	invalid_operand
	call	get_address
	push	eax ebx ecx
	lods	byte [esi]
	cmp	al,','
	jne	invalid_operand
	cmp	byte [esi],'('
	je	bt_mem_imm
	cmp	byte [esi],11h
	jne	bt_mem_reg
	cmp	byte [esi+2],'('
	je	bt_mem_imm
      bt_mem_reg:
	lods	byte [esi]
	call	get_size_operator
	cmp	al,10h
	jne	invalid_operand
	lods	byte [esi]
	call	convert_register
	mov	[postbyte_register],al
	pop	ecx ebx edx
	mov	al,ah
	call	operand_autodetect
	call	store_instruction
	jmp	instruction_assembled
      bt_mem_imm:
	xor	al,al
	xchg	al,[operand_size]
	push	eax
	lods	byte [esi]
	call	get_size_operator
	cmp	al,'('
	jne	invalid_operand
	mov	al,[operand_size]
	or	al,al
	jz	bt_mem_imm_size_ok
	cmp	al,1
	jne	invalid_operand_size
      bt_mem_imm_size_ok:
	call	get_byte_value
	mov	byte [value],al
	pop	eax
	or	al,al
	jz	bt_mem_imm_nosize
	call	operand_autodetect
      bt_mem_imm_store:
	pop	ecx ebx edx
	mov	[extended_code],0BAh
	call	store_instruction_with_imm8
	jmp	instruction_assembled
      bt_mem_imm_nosize:
	cmp	[error_line],0
	jne	bt_mem_imm_store
	mov	eax,[current_line]
	mov	[error_line],eax
	mov	[error],operand_size_not_specified
	jmp	bt_mem_imm_store
      bt_reg:
	lods	byte [esi]
	call	convert_register
	mov	bl,al
	lods	byte [esi]
	cmp	al,','
	jne	invalid_operand
	cmp	byte [esi],'('
	je	bt_reg_imm
	cmp	byte [esi],11h
	jne	bt_reg_reg
	cmp	byte [esi+2],'('
	je	bt_reg_imm
      bt_reg_reg:
	lods	byte [esi]
	call	get_size_operator
	cmp	al,10h

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -