📄 unasm.inc
字号:
db arm8, ano
db arm8, ano
db afs, ano
db afs,ano
db arm16r, aemp
db arm16r, aim8
db arm16r, acl
db ags, ano
db ags, ano
db arm16r, aemp
db arm16r, aim8
db arm16r, acl
db ar16rm, aemp
db ar16rm, aemp
db arm16r, aemp
db ar16rm, aemp
db ar16rm, aemp
db ar8_16, aemp
db ar16_32, aemp
db arm16, aim8
db arm16r, aemp
db ar16rm, aemp
db ar16rm, aemp
db ar8_16, aemp
db ar16_32, aemp
;=============================================================================
param_486:
db ano, ano
db ano, ano
db arm8r, aemp
db arm16r, aemp
db arm8r, aemp
db arm16r, aemp
db aax, ano
db acx, ano
db adx, ano
db abx, ano
db asp, ano
db abp, ano
db asi, ano
db adi, ano
;Coprocessor:
; and al,111b
; mov bl,al
; mov bh,0
; lodsb
; and al,00111000b
; or bl,al
; add bx,bx
; mov si,cs:CoprocCmd[bx]
; jmp @@Quit
;~ endp
;=============================================================================
; analyze_param
;-----------------------------------------------------------------------------
analyze_param:
mov byte [cs:word_flag],0
mov byte [cs:dword_flag],0
test al,80h
jz @@byte
inc byte [cs:word_flag]
@@byte:
and al,7fh
cmp al,40h
jae immed_reg
mov bx,sub_table
next_param:
mov ah,[cs:bx]
cmp al,ah
je execute
add bx,3
or ah,ah
jnz next_param
ret
execute:
jmp [cs:bx+1]
;-----------------------------------------------------------------------------
sub_table:
db aim8
dw immed_value
db a1
dw immed_1
db amem8
dw memory
db asht
dw jump_short
db anear
dw jump_near
db afar
dw jump_far
db arm8
dw reg_mem
db arm8r
dw reg_mem_reg
db ar8rm
dw reg_reg_mem
db arm_seg
dw reg_mem_seg
db aseg_rm
dw seg_reg_mem
db aesc
dw esc_param
db aim8_16
dw im8_to_16
db ar8_16
dw reg8_to_16
db ar16_32
dw reg16_to_32
db r_cr
dw cr_to_reg
db cr_r
dw reg_to_cr
db r_dr
dw dr_to_reg
db dr_r
dw reg_to_dr
db r_tr
dw tr_to_reg
db tr_r
dw reg_to_tr
db astr
dw str_param
db astrn
dw str_nparam
db 0
;=============================================================================
; immed_reg
;-----------------------------------------------------------------------------
immed_reg:
cmp al,aal
jae @@byte_reg
mov byte [cs:word_flag],1
@@byte_reg:
xor bx,bx
mov bl,al
sub bl,40h
shl bx,1
call insert_op_size
mov ax,[cs:registers+bx]
stosw
ret
;=============================================================================
; immed_value
;-----------------------------------------------------------------------------
immed_value:
cmp byte [cs:word_flag],0
je im8
cmp byte [cs:op_size_flag],1
je im32
im8:
jmp fill_wb
im32:
jmp fill_dword_str
;=============================================================================
; im8_to_16
;-----------------------------------------------------------------------------
im8_to_16:
lodsb
cbw
cmp byte [cs:op_size_flag],1
jne im816
cwd
xchg ax,dx
call fill_word_str
xchg ax,dx
im816:
jmp fill_word_str
immed_1:
mov al,'1'
stosb
ret
;=============================================================================
; memory
;-----------------------------------------------------------------------------
memory:
call print_ptr
mov al,'['
stosb
cmp byte [cs:addr_size_flag],0
je @@1
call fill_dword_str
jmp @@2
@@1:
lodsw
mov [cs:mem_disp_offs],ax
mov byte [cs:mem_disp_type],8
mov ch,[cs:word_flag]
inc ch
mov [cs:memory_flag],ch
call fill_word_str
@@2:
mov al,']'
stosb
ret
;=============================================================================
; reg8_to_16
;-----------------------------------------------------------------------------
reg8_to_16:
lodsb
mov byte [cs:word_flag],1
call analyze_rm_reg
call delimit
mov byte [cs:word_flag],0
;[1245 - 1.01]
mov byte [cs:op_size_flag],0
mov byte [cs:print_flag],1
;[1245 - 1.01]
jmp analyze_rm_disp
;=============================================================================
; reg16_to_32
;-----------------------------------------------------------------------------
reg16_to_32:
lodsb
mov byte [cs:op_size_flag],1
mov byte [cs:word_flag],1
call analyze_rm_reg
call delimit
mov byte [cs:op_size_flag],0
mov byte [cs:print_flag],1
jmp analyze_rm_disp
;=============================================================================
; str_param
;-----------------------------------------------------------------------------
str_param:
cmp word [cs:cur_prefix],0
je str_nparam
mov bx,[cs:cur_prefix]
mov word [cs:cur_prefix],0
call fill_csbx
str_nparam:
mov byte [cs:str_flag],1
ret
;=============================================================================
; jump_short
;-----------------------------------------------------------------------------
jump_short:
cmp byte [cs:cur_cmd],0ebh
jne not_print
mov bx,short_str
call fill_csbx
not_print:
lodsb
cbw
..@print_jump:
call check$
jc @@ret1
add ax,si
call fill_word_str
@@ret1:
ret
check$:
or ax,ax
jz @@$p
mov bx,[cs:unasm_cur_ip]
sub bx,si
cmp ax,bx
je @@$
clc
ret
@@$:
mov al,'$'
stosb
stc
ret
@@$p:
mov ax,'$+'
stosw
mov ax,si
sub ax,[cs:unasm_cur_ip]
add al,'0'
stosb
stc
ret
short_str db 'short ',0
;near_str db 'near ',0
far_str db 'far ',0
;=============================================================================
; jump_near
;-----------------------------------------------------------------------------
jump_near:
; call Fill_CS_BX
cmp byte [cs:addr_size_flag],1
je near_far
lodsw
jmp ..@print_jump
near_far:
lodsw
mov bx,ax
lodsw
add bx,si
adc ax,0
call fill_word_str
mov ax,bx
jmp fill_word_str
;=============================================================================
; jump_far
;-----------------------------------------------------------------------------
jump_far:
mov bx,far_str
call fill_csbx
cmp byte [cs:addr_size_flag],1
je far_far
lodsw
xchg ax,bx
lodsw
call fill_word_str
mov al,':'
stosb
xchg ax,bx
jmp fill_word_str
far_far:
lodsw
mov bx,ax
lodsw
mov cx,ax
lodsw
call fill_word_str
mov al,':'
stosb
mov ax,cx
call fill_word_str
mov ax,bx
jmp fill_word_str
reg_mem:
lodsb
cmp byte [cs:cur_cmd],0feh
jae @@jumps
@@reg_mem:
jmp analyze_rm_disp
@@jumps:
push ax
and al,00111000b
cmp al,00011000b
jne @@ch_jump
mov byte [cs:dword_flag],1
jmp @@ret
@@ch_jump:
cmp al,00101000b
jne @@ret
mov byte [cs:dword_flag],1
@@ret:
pop ax
jmp @@reg_mem
;=============================================================================
; reg_mem_reg
;-----------------------------------------------------------------------------
reg_mem_reg:
lodsb
call analyze_rm_disp
call delimit
jmp analyze_rm_reg
;=============================================================================
; reg_reg_mem
;-----------------------------------------------------------------------------
reg_reg_mem:
lodsb
call analyze_rm_reg
call delimit
jmp analyze_rm_disp
;=============================================================================
; reg_mem_seg
;-----------------------------------------------------------------------------
reg_mem_seg:
lodsb
mov byte [cs:word_flag],1
call analyze_rm_disp
call delimit
jmp analyze_rm_seg
;=============================================================================
; seg_reg_mem
;-----------------------------------------------------------------------------
seg_reg_mem:
lodsb
mov byte [cs:word_flag],1
call analyze_rm_seg
call delimit
jmp analyze_rm_disp
;=============================================================================
; esc_param
;-----------------------------------------------------------------------------
esc_param:
dec si
lodsb
and al,00000111b
mov ah,al
lodsb
push ax
and al,00111000b
or al,ah
call fill_byte_str
pop ax
call delimit
jmp analyze_rm_disp
;=============================================================================
; cr_to_reg
;-----------------------------------------------------------------------------
cr_to_reg:
lodsb
call get_cr_reg
mov ah,'c'
jmp ..@get_cr_num
dr_to_reg:
lodsb
call get_cr_reg
mov ah,'d'
jmp ..@get_cr_num
tr_to_reg:
lodsb
call get_cr_reg
mov ah,'t'
..@get_cr_num:
call delimit
jmp get_cr_num
reg_to_cr:
lodsb
mov ah,'c'
jmp ..@get_cr_reg
reg_to_dr:
lodsb
mov ah,'d'
jmp ..@get_cr_reg
reg_to_tr:
lodsb
mov ah,'t'
..@get_cr_reg:
call get_cr_num
call delimit
jmp get_cr_reg
get_cr_reg:
push ax
and al,00000111b
shl al,1
cbw
mov bx,ax
mov al,'e'
stosb
mov ax,[cs:registers+bx]
stosw
pop ax
ret
get_cr_num:
push ax
and al,00111000b
shr al,1
shr al,1
shr al,1
add al,'0'
xchg al,ah
stosb
mov al,'r'
stosw
pop ax
ret
;=============================================================================
; analyze_rm_disp
;-----------------------------------------------------------------------------
analyze_rm_disp:
push ax
mov ch,[cs:word_flag]
inc ch
add ch,[cs:dword_flag]
mov [cs:memory_flag],ch
cmp byte [cs:addr_size_flag],1
je disp_32_bit
mov ch,al
and al,11000000b
cmp al,00000000b
je no_offs
cmp al,01000000b
je byte_offs
cmp al,10000000b
je word_offs
reg_2:
mov byte [cs:memory_flag],0
mov al,ch ; r/m = Register
and al,00000111b
shl al,1
cbw
call insert_op_size
call get_register
stosw
jmp ..@exit_00
word_offs:
mov al,ch
call get_disp
mov al,'+'
stosb
lodsw
jmp ..@fill_word
byte_offs:
mov al,ch
call get_disp
lodsb
cbw
mov [cs:mem_disp_offs],ax
mov ah,'+'
test al,80h
jz plus_8
mov ah,'-'
neg al
plus_8:
mov [es:di],ah
inc di
call fill_byte_str
jmp ..@quit_01
no_offs:
mov word [cs:mem_disp_offs],0
mov al,ch
and al,00000111b
cmp al,00000110b
jne read_disp
call print_ptr
mov al,'['
stosb
lodsw
mov byte [cs:mem_disp_type],8
..@fill_word:
mov [cs:mem_disp_offs],ax
call fill_word_str
jmp ..@quit_01
read_disp:
call get_disp
..@quit_01:
mov al,']'
stosb
..@exit_00:
pop ax
ret
disp_32_bit:
mov ch,al
and al,11000000b
cmp al,11000000b
je reg_2
mov cl,al
mov al,ch
and al,00000111b
cmp al,00000100b
je analyze_sib
xchg al,cl
cmp al,00000000b
je no_ofs_32
cmp al,10000000b
je ofs_32
ofs_8:
mov al,cl
call get_32_disp
mov al,'+'
stosb
lodsb
call fill_byte_str
jmp ..@quit_01
ofs_32:
mov al,cl
call get_32_disp
mov al,'+'
stosb
call fill_dword_str
jmp ..@quit_01
;;
no_ofs_32:
cmp cl,00000101b
jne no_disp_32
mov al,'['
stosb
call fill_dword_str
jmp ..@quit_01
no_disp_32:
mov al,cl
call get_32_disp
jmp ..@quit_01
analyze_sib:
lodsb
mov ch,al
cmp cl,00000000b
je sib_no_ofs
cmp cl,01000000b
je sib_ofs_8
sib_ofs_32:
and al,00000111b
call get_32_disp
call get_scale
mov al,'+'
stosb
call fill_dword_str
jmp ..@quit_01
sib_no_ofs:
and al,00000111b
cmp al,00000101b
jne get_sib_disp
call print_ptr
mov al,'['
stosb
call fill_dword_str
jmp ..@get_scale
get_sib_disp:
call get_32_disp
..@get_scale:
call get_scale
jmp ..@quit_01
sib_ofs_8:
and al,00000111b
call get_32_disp
call get_scale
mov al,'+'
stosb
lodsb
call fill_byte_str
jmp ..@quit_01
;=============================================================================
; analyze_rm_reg
;-----------------------------------------------------------------------------
analyze_rm_reg:
push ax
and al,00111000b
shr al,1
shr al,1
cbw
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -