📄 unasm.inc
字号:
call insert_op_size
call get_register
stosw
pop ax
ret
;=============================================================================
; get_register
;-----------------------------------------------------------------------------
get_register:
push bx
mov bl,[cs:word_flag]
xor bl,1
xor bh,bh
shl bx,1
shl bx,1
shl bx,1
shl bx,1
add bx,ax
mov ax,[cs:registers+bx]
inc bx
pop bx
ret
;=============================================================================
;
;-----------------------------------------------------------------------------
insert_op_size:
cmp byte [cs:op_size_flag],0
je @@ret
cmp byte [cs:word_flag],0
je @@ret
push ax
mov al,'e'
stosb
pop ax
@@ret:
ret
;=============================================================================
; analyze_rm_seg
;-----------------------------------------------------------------------------
analyze_rm_seg:
push ax
and al,00111000b
cmp byte [cs:cpu_type],a386
jae @@3
cmp al,00011000b
jbe @@1
@@bad_seg_reg:
mov byte [cs:db_flag],1
pop ax
ret
@@3:
cmp al,00101000b
ja @@bad_seg_reg
@@1:
shr al,1
shr al,1
cbw
mov bx,ax
mov ax,[cs:seg_regs+bx]
stosw
pop ax
ret
;=============================================================================
; get_disp
;-----------------------------------------------------------------------------
get_disp:
call print_ptr
and al,00000111b
cbw
mov [cs:mem_disp_type],al
shl ax,1
mov bx,ax
mov bx,[cs:disp_adrs+bx]
jmp fill_csbx
;=============================================================================
disp_adrs:
dw of000
dw of001
dw of010
dw of011
dw of100
dw of101
dw of110
dw of111
of000 db '[bx+si',0
of001 db '[bx+di',0
of010 db '[bp+si',0
of011 db '[bp+di',0
of100 db '[si',0
of101 db '[di',0
of110 db '[bp',0
of111 db '[bx',0
;=============================================================================
; get_32_disp
;-----------------------------------------------------------------------------
get_32_disp:
cmp byte [cs:op_size_flag],0
je @@1
mov byte [dword_flag],1
@@1:
call print_ptr
cbw
mov bx,ax
add bx,bx
mov ax,'[e'
stosw
mov ax,[cs:registers+bx]
stosw
ret
;=============================================================================
; get_scale
;-----------------------------------------------------------------------------
get_scale:
mov al,ch
and al,00111000b
cmp al,00100000b
je no_scale
shr al,1
shr al,1
cbw
mov bx,ax
mov ax,'+e'
stosw
mov ax,[cs:registers+bx]
stosw
mov al,'*'
stosb
mov al,ch
and al,11000000b
rol al,1
rol al,1
cbw
mov bx,ax
mov al,[cs:scaler+bx]
stosb
no_scale:
ret
scaler db '1248'
pt_byte db 'byte ',0
pt_dword db 'd'
pt_word db 'word ',0
pt_ptr db 'ptr ',0
;=============================================================================
; print_ptr
;-----------------------------------------------------------------------------
print_ptr:
push ax
push si
cmp byte [cs:print_flag],0
je @@quit
mov si,pt_byte
cmp byte [cs:word_flag],0
je @@byte
mov si,pt_word
;[1245 - 1.01]
cmp byte [cs:op_size_flag],0
je @@check_dword
mov byte [cs:dword_flag],1
; mov cs:memory_flag,3
@@check_dword:
;[1245 - 1.01]
cmp byte [cs:dword_flag],0
je @@byte
dec si
@@byte:
call unasm_fill_str
mov si,pt_ptr
call unasm_fill_str
@@quit:
cmp word [cs:cur_prefix],0
je @@exit
mov si,[cs:cur_prefix]
mov [cs:mem_prefix],si
call unasm_fill_str
@@exit:
mov word [cs:cur_prefix],0
pop si
pop ax
ret
;=============================================================================
; unasm_fill_str
;-----------------------------------------------------------------------------
unasm_fill_str:
push ds
push cs
pop ds
@@next:
lodsb
or al,al
jz @@quit
stosb
jmp @@next
@@quit:
pop ds
ret
;=============================================================================
; fill_csbx
;-----------------------------------------------------------------------------
fill_csbx:
@@next:
mov al,[cs:bx]
or al,al
jz @@quit
stosb
inc bx
jmp @@next
@@quit:
ret
;=============================================================================
; delimit
;-----------------------------------------------------------------------------
delimit:
push ax
mov al,','
stosb
pop ax
ret
;=============================================================================
; fill_addr
;-----------------------------------------------------------------------------
fill_addr:
mov ax,[cs:unasm_cur_ip]
jmp fill_word_str
;=============================================================================
; fill_codes
;-----------------------------------------------------------------------------
fill_codes:
push si
mov si,[cs:unasm_cur_ip]
@@next_byte:
cmp di,CMD_X-1
jae @@trunc
lodsb
call fill_byte_str
loop @@next_byte
@@quit:
pop si
ret
@@trunc:
mov al,'+'
stosb
jmp @@quit
;=============================================================================
; fill_wb
;-----------------------------------------------------------------------------
fill_wb:
cmp byte [cs:word_flag],1
je @@out_word
lodsb
jmp fill_byte_str
@@out_word:
lodsw
jmp fill_word_str
;-------------------------------------------------------------------------------
; Print_Command proc near
; push si
; mov ax,0A0Dh
; stosw
; mov cx,di
; mov dx,offset Buffer
; sub cx,dx
; mov ah,40h
; mov bx,1
; int 21h
; pop si
; ret
; Print_Command endp
;=============================================================================
; clear_buffer
;-----------------------------------------------------------------------------
clear_buffer:
mov di,buffer
push di
mov al,' '
mov cx,BUF_SIZE
rep stosb
pop di
ret
;=============================================================================
registers db 'axcxdxbxspbpsidi'
db 'alcldlblahchdhbh'
seg_regs db 'escsssdsfsgs'
commands:
cadd db 'add',0
cor db 'or',0
cadc db 'adc',0
csbb db 'sbb',0
cand db 'and',0
csub db 'sub',0
cxor db 'xor',0
ccmp db 'cmp',0
cinc db 'inc',0
cdec db 'dec',0
cpush db 'push',0
cpop db 'pop',0
cmov db 'mov',0
cxchg db 'xchg',0
cshl db 'shl',0
cshr db 'shr',0
crcl db 'rcl',0
crcr db 'rcr',0
csar db 'sar',0
crol db 'rol',0
cror db 'ror',0
ctest db 'test',0
cnot db 'not',0
cneg db 'neg',0
cmul db 'mul',0
cimul db 'imul',0
cdiv db 'div',0
cidiv db 'idiv',0
ccbw db 'cbw',0
ccwd db 'cwd',0
caaa db 'aaa',0
caad db 'aad',0
caam db 'aam',0
caas db 'aas',0
cdaa db 'daa',0
cdas db 'das',0
cmovsb db 'movsb',0
cmovsw db 'movsw',0
cstosb db 'stosb',0
cstosw db 'stosw',0
clodsb db 'lodsb',0
clodsw db 'lodsw',0
ccmpsb db 'cmpsb',0
ccmpsw db 'cmpsw',0
cscasb db 'scasb',0
cscasw db 'scasw',0
ccall db 'call',0
cjmp db 'jmp',0
cret db 'ret',0
cretf db 'retf',0
cloop db 'loop',0
cloope db 'loope',0
cloopne db 'loopne',0
cint db 'int',0
cinto db 'into',0
cint3 db 'int3',0
ciret db 'iret',0
cpushf db 'pushf',0
cpopf db 'popf',0
csahf db 'sahf',0
clahf db 'lahf',0
cclc db 'clc',0
ccmc db 'cmc',0
cstc db 'stc',0
ccld db 'cld',0
cstd db 'std',0
ccli db 'cli',0
csti db 'sti',0
chlt db 'hlt',0
cnop db 'nop',0
clea db 'lea',0
cles db 'les',0
clds db 'lds',0
cxlat db 'xlat',0
cjcxz db 'jcxz',0
cin db 'in',0
cout db 'out',0
cesc db 'esc',0
cwait db 'wait',0
cjo db 'jo',0
cjno db 'jno',0
cjb db 'jb',0
cjnb db 'jnb',0
cjz db 'jz',0
cjnz db 'jnz',0
cjbe db 'jbe',0
cja db 'ja',0
cjs db 'js',0
cjns db 'jns',0
cjp db 'jp',0
cjnp db 'jnp',0
cjl db 'jl',0
cjge db 'jge',0
cjle db 'jle',0
cjg db 'jg',0
; 286 instructions
cpusha db 'pusha',0
cpopa db 'popa',0
cbound db 'bound',0
cinsb db 'insb',0
coutsb db 'outsb',0
cinsw db 'insw',0
coutsw db 'outsw',0
center db 'enter',0
cleave db 'leave',0
; 286 Protected Mode instructions
clgdt db 'lgdt',0
csgdt db 'sgdt',0
clidt db 'lidt',0
csidt db 'sidt',0
clldt db 'lldt',0
csldt db 'sldt',0
clmsw db 'lmsw',0
csmsw db 'smsw',0
cltr db 'ltr',0
cstr db 'str',0
clar db 'lar',0
clsl db 'lsl',0
carpl db 'arpl',0
cverr db 'verr',0
cverw db 'verw',0
cclts db 'clts',0
cloadall db 'loadall',0
; c db '',0
; 386 instructions
cmovsx db 'movsx',0
cmovzx db 'movzx',0
clfs db 'lfs',0
clgs db 'lgs',0
clss db 'lss',0
ccwde db 'cwde',0
ccdq db 'cdq',0
cshld db 'shld',0
cshrd db 'shrd',0
cbt db 'bt',0
cbts db 'bts',0
cbtr db 'btr',0
cbtc db 'btc',0
cbsf db 'bsf',0
cbsr db 'bsr',0
clodsd db 'lodsd',0
cstosd db 'stosd',0
cinsd db 'insd',0
coutsd db 'outsd',0
cmovsd db 'movsd',0
ccmpsd db 'cmpsd',0
cscasd db 'scasd',0
cseta db 'seta',0
csetae db 'setae',0
csetb db 'setb',0
csetbe db 'setbe',0
csete db 'sete',0
csetne db 'setne',0
csetp db 'setp',0
csetnp db 'setnp',0
csetg db 'setg',0
csetge db 'setge',0
csetl db 'setl',0
csetle db 'setle',0
csets db 'sets',0
csetns db 'setns',0
cseto db 'seto',0
csetno db 'setno',0
cjecxz db 'jecxz',0
ciretd db 'iretd',0
cpushad db 'pushad',0
cpopad db 'popad',0
cpushfd db 'pushfd',0
cpopfd db 'popfd',0
; 486 instructions
cinvd db 'invd',0
cwbinvd db 'wbinvd',0
cinvlpg db 'invlpg',0
ccmpxchg db 'cmpxchg',0
cxadd db 'xadd',0
cbswap db 'bswap',0
; c db '',0
;~comment #
;~
;~ Cfld db 'fld',0
;~ cfst db 'fst',0
;~ cfstp db 'fstp',0
;~ cfxch db 'fxch',0
;~ cfcom db 'fcom',0
;~ cfcomp db 'fcomp',0
;~ cfcompp db 'fcompp',0
;~ cftst db 'ftst',0
;~ cfxam db 'fxam',0
;~ cfadd db 'fadd',0
;~ cfsub db 'fsub',0
;~ cfmul db 'fmul',0
;~ cfdiv db 'fdiv',0
;~ cfsqrt db 'fsqrt',0
;~ cfscale db 'fscale',0
;~ cfprem db 'fprem',0
;~ cfrndint db 'frndint',0
;~ cfxtract db 'fxtract',0
;~ cfabs db 'fabs',0
;~ cfchs db 'fchs',0
;~ cfptan db 'fptan',0
;~ cfpatan db 'fpatan',0
;~ cf2xm1 db 'f2xm1',0
;~ cfyl2x db 'fyl2x',0
;~ cfyl2xp1 db 'fyl2xp1',0
;~ cfldz db 'fldz',0
;~ cfld1 db 'fld1',0
;~ cfldpi db 'fldpi',0
;~ cfldl2t db 'fldl2t',0
;~ cfldl2e db 'fldl2e',0
;~ cfldlg2 db 'fldlg2',0
;~ cfldln2 db 'fldln2',0
;~ cfinit db 'finit',0
;~ cfeni db 'feni',0
;~ cfdisi db 'fdisi',0
;~ cfldcw db 'fldcw',0
;~ cfstcw db 'fstcw',0
;~ cfldsw db 'fldsw',0
;~ cfstsw db 'fstsw',0
;~ cfclex db 'fclex',0
;~ cfstenv db 'fstenv',0
;~ cfldenv db 'fldenv',0
;~ cfsave db 'fsave',0
;~ cfrstor db 'frstor',0
;~ cfincstp db 'fincstp',0
;~ cfdecstp db 'fdecstp',0
;~ cffree db 'ffree',0
;~ cffnop db 'fnop',0
;~#
cdb db 'db',0
qqq db '???',0
prefixes:
plock db 'lock',0
unasm_rep_prefixes:
prep db 'rep ',0
prepe db 'repe ',0
prepne db 'repne ',0
seg_prefixes:
pcs db 'cs:',0
pds db 'ds:',0
pes db 'es:',0
pss db 'ss:',0
pfs db 'fs:',0
pgs db 'gs:',0
size_prefixes:
op_size db 0
AddrSize db 0
; db '',0
ArOp1 equ 0
ArOp2 equ 1
ShiftOp equ 2
grp_1 equ 3
Grp2 equ 4
Grp3 equ 5
MovGrp equ 6
bt_grp equ 6
cmd_addrs:
dw cadd ; 0
dw cadd
dw cadd
dw cadd
dw cadd
dw cadd
dw cpush
dw cpop
dw cor
dw cor
dw cor
dw cor
dw cor
dw cor
dw cpush
dw cdb
dw cadc ; 1
dw cadc
dw cadc
dw cadc
dw cadc
dw cadc
dw cpush
dw cpop
dw csbb
dw csbb
dw csbb
dw csbb
dw csbb
dw csbb
dw cpush
dw cpop
dw cand ; 2
dw cand
dw cand
dw cand
dw cand
dw cand
dw pes
dw cdaa
dw csub
dw csub
dw csub
dw csub
dw csub
dw csub
dw pcs
dw cdas
dw cxor ; 3
dw cxor
dw cxor
dw cxor
dw cxor
dw cxor
dw pss
dw caaa
dw ccmp
dw ccmp
dw ccmp
dw ccmp
dw ccmp
dw ccmp
dw pds
dw caas
dw cinc ; 4
dw cinc
dw cinc
dw cinc
dw cinc
dw cinc
dw cinc
dw cinc
dw cdec
dw cdec
dw cdec
dw cdec
dw cdec
dw cdec
dw cdec
dw cdec
dw cpush ; 5
dw cpush
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -