📄 operands.asm
字号:
mov al,REG_EAX
call SetReg
sub ax,ax
ret
op23 ENDP
;/* op 24 acc, absolute */
op24 PROC
sub cx,cx
mov al,REG_EAX
call SetReg
mov di,bx
mov [di+OPERAND.CODE],OM_ABSOLUTE
bt [di+OPERAND.OEFLAGS],OMF_ADR32
jnc short op24word
inc cl
inc cl
LONG si+1
jmp short op24done
op24word:
UINT si+1
op24done:
mov [di+OPERAND.ADDRESS],eax
mov ax,cx
ret
op24 ENDP
;/* op 25 - immediate byte or word */
op25 PROC
mov [reqsPtrSizeOvride],false
bts [di+OPERAND.OEFLAGS],OMF_BYTE
bt DWORD PTR fs:[si],1
jc short op25fin
btr [di+OPERAND.OEFLAGS],OMF_BYTE
op25fin:
push si
inc si
call Immediate
pop si
ret
op25 ENDP
;/* op 26, immediate 2byte,byte */
op26 PROC
mov [reqsPtrSizeOvride],false
btr [di+OPERAND.OEFLAGS],OMF_BYTE
btr [di+OPERAND.OEFLAGS],OMF_OP32
push si
inc si
call Immediate
mov di,bx
bts [di+OPERAND.OEFLAGS],OMF_BYTE
btr [di+OPERAND.OEFLAGS],OMF_OP32
inc si
inc si
call Immediate
pop si
sub ax,ax
ret
op26 ENDP
;/* op 27 - string */
op27 PROC
mov al,'d'
bt [di+OPERAND.OEFLAGS],OMF_OP32
jc short op27pc
mov al,'w'
op27pc:
call MnemonicChar
sub ax,ax
ret
op27 ENDP
;/* op 28 - source = REG, dest = RM */
op28 PROC
xchg di,bx
jmp op7
op28 ENDP
;/* op 29 - rm, size don't care */
op29 PROC
btr [di+OPERAND.OEFLAGS],OMF_OP32
mov [reqsPtrSizeOvride],false
call ReadRM
ret
op29 ENDP
;/* op30 - RM, shift with B3 of stream selecting COUNT or CL*/
op30 PROC
call ReadRM
mov cx,ax
mov di,bx
mov [di+OPERAND.CODE],OM_SHIFT
bt DWORD PTR fs:[si],3
jnc op30cl
movzx esi,si
movzx ecx,cx
movzx eax,byte ptr [esi+ecx+2]
mov [di+OPERAND.ADDRESS],eax
inc cx
jmp short op30done
op30cl:
bts [di+OPERAND.OEFLAGS],OMF_CL
op30done:
mov ax,cx
ret
op30 ENDP
;/* op 31- reg, rm, count where B1 of opcode = byte/word */
op31 PROC
call copyextra
REG si
call SetReg
mov di,bx
call ReadRM
mov cx,ax
mov di,offset extraoperand
bts [di+OPERAND.OEFLAGS],OMF_BYTE
bt DWORD PTR fs:[si],1
jc short op31byte
btr [di+OPERAND.OEFLAGS],OMF_BYTE
op31byte:
push si
inc si
inc si
call Immediate
pop si
add ax,cx
ret
op31 ENDP
;/* op32 - 386 special regs */
op32 PROC
mov cx,WORD PTR fs:[si]
and cx,0c005h
cmp cx,0c000h
mov al,OM_CRX
jz short op32gotype
cmp cx,0c001h
mov al,OM_DRX
jz short op32gotype
cmp cx,0c004h
mov al,OM_TRX
jz short op32gotype
mov al,OM_SUD
op32gotype:
btr [di+OPERAND.OEFLAGS],OMF_BYTE
btr [bx+OPERAND.OEFLAGS],OMF_BYTE
bts [di+OPERAND.OEFLAGS],OMF_OP32
bts [bx+OPERAND.OEFLAGS],OMF_OP32
bt DWORD PTR fs:[si],1
jc op32noswap
xchg bx,di
op32noswap:
mov [di+OPERAND.CODE],al
REG si
mov [di+OPERAND.THEREG],al
mov di,bx
RM si
call SetReg
sub ax,ax
ret
op32 ENDP
;/* op33 - reg,rm,shiftcnt where B3 = reg source, b0 = shift cl */
op33 PROC
btr [di+OPERAND.OEFLAGS],OMF_BYTE
btr [bx+OPERAND.OEFLAGS],OMF_BYTE
call CopyExtra
call ReadRM
mov cx,ax
REG si
mov di,bx
call SetReg
mov di,offset extraoperand
mov [di+OPERAND.CODE],OM_SHIFT
bt DWORD PTR fs:[si],0
jnc short getofs
bts [di+OPERAND.OEFLAGS],OMF_CL
jmp short op33done
getofs:
movzx ecx,cx
movzx esi,si
movzx eax,BYTE PTR fs:[esi+ecx+2]
mov [di+OPERAND.ADDRESS],eax
op33done:
mov ax,cx
ret
op33 ENDP
;/* op 34 - push & pop word, also no reqsPtrSizeOvride single args */
op34 PROC
call ReadRM
ret
op34 ENDP
;/* op 35 -floating RM */
op35 PROC
mov [reqsPtrSizeOvride],FALSE
MODX si
cmp al,3
jnz short op35fsttab
bts [di+OPERAND.OEFLAGS],OMF_FST
call ReadRM
ret
op35 endp
op35fsttab proc
bts [di+OPERAND.OEFLAGS],OMF_FSTTAB
movzx eax,BYTE PTR fs:[si]
B12
shl eax, OM_FTAB
or [di+OPERAND.OEFLAGS],ax
call ReadRM
ret
op35fsttab endp
;/* op 36 - floating math & pop */
op36 PROC
mov [reqsPtrSizeOvride],FALSE
mov al,fs:[si+1]
and al,0c7h
cmp al,0c1h
jz op36noarg
bts [di+OPERAND.OEFLAGS],OMF_FST
and al,7
call setreg
sub al,al
xchg bx,di
bts [di+OPERAND.OEFLAGS],OMF_FST
call setreg
op36noarg:
sub ax,ax
ret
op36 ENDP
;/* OP 37 - floating MATH */
op37 PROC
mov [reqsPtrSizeOvride],FALSE
MODX si
cmp al,3
jc op35fsttab
test byte ptr fs:[si],4
jnz op37noflop
xchg di,bx
op37noflop:
bts [di+OPERAND.OEFLAGS],OMF_FST
RM si
call setreg
sub al,al
xchg bx,di
bts [di+OPERAND.OEFLAGS],OMF_FST
call setreg
sub ax,ax
ret
op37 ENDP
;/* op38 - FAR RM */
op38 PROC
mov [reqsPtrSizeOvride],FALSE
bts [di+OPERAND.OEFLAGS],OMF_FSTTAB
call ReadRM
ret
op38 ENDP
;/* OP39 - word regrm with reg source */
op39 PROC
btr [di+OPERAND.OEFLAGS],OMF_BYTE
btr [bx+OPERAND.OEFLAGS],OMF_BYTE
call op40
ret
op39 ENDP
;/* op 40 regrm with reg source */
op40 PROC
mov [dest2],bx
mov [source2],di
call RegRM
ret
op40 ENDP
;/* op 41 reg, bitnum */
op41 PROC
btr [di+OPERAND.OEFLAGS],OMF_BYTE
call ReadRM
mov cx,ax
mov di,bx
bts [di+OPERAND.OEFLAGS],OMF_BYTE
push si
add si,cx
add si,2
call Immediate
pop si
mov ax,cx
ret
op41 ENDP
;/* op 42 mixed regrm with reg dest & reqsPtrSizeOvrideness enforced */
op42 PROC
mov [dest2],di
mov [source2],bx
btr [di+OPERAND.OEFLAGS],OMF_BYTE
btr [bx+OPERAND.OEFLAGS],OMF_OP32
call RegRM
mov [reqsPtrSizeOvride],TRUE
ret
op42 ENDP
;/* op 43 CWDE
op43 PROC
bt [di+OPERAND.OEFLAGS],OMF_OP32
jnc short op43nochng
push si
mov si,offset nmmnemonic+1
mov eax,"wde"
call put3
mov BYTE PTR [si],0
pop si
sub ax,ax
op43nochng:
ret
op43 ENDP
;/* op 44 BSWAP
op44 PROC
btr [di+OPERAND.OEFLAGS],OMF_BYTE
mov al,fs:[si]
and al,7
call SetReg
sub ax,ax
ret
op44 ENDP
;/* OP45 - any regrm with reg source */
op45 PROC
bt word ptr fs:[si-1],0
jc op45nb
btr [di+OPERAND.OEFLAGS],OMF_BYTE
btr [bx+OPERAND.OEFLAGS],OMF_BYTE
op45nb:
XCHG BX,DI
REG si
call SetReg
XCHG bx,di
call ReadRM
ret
op45 ENDP
;/* op 46 - floating R/M, pointers to mem */
op46 PROC
jmp op29
op46 ENDP
;/* op47 - AX */
op47 PROC
btr [di+OPERAND.OEFLAGS],OMF_OP32
btr [di+OPERAND.OEFLAGS],OMF_BYTE
sub al,al
call SetReg
sub ax,ax
ret
op47 ENDP
;/* op48 - 32-bit reg to r02, no prefix (bswap) */
op48 PROC
bts [di+OPERAND.OEFLAGS],OMF_OP32
btr [di+OPERAND.OEFLAGS],OMF_BYTE
mov al,fs:[si]
B02
call SetReg
sub ax,ax
ret
op48 ENDP
;/* op 49, FST */
op49 PROC
mov [reqsPtrSizeOvride],FALSE
MODX si
cmp al,3
jnz op49noreg
bts [di+OPERAND.OEFLAGS],OMF_FST
jmp short op49fin
op49noreg:
bts [di+OPERAND.OEFLAGS],OMF_FSTTAB
movzx eax,BYTE PTR fs:[si]
and al,6
jz op49nxor
xor al,6
op49nxor:
shl eax, OM_FTAB
or [di+OPERAND.OEFLAGS],ax
op49fin:
call ReadRM
ret
op49 ENDP
;/* op 50, FLD & FSTP */
op50 PROC
jmp op49
op50 ENDP
;/* op 51, FBLD/FBSTP */
op51 PROC
mov [reqsPtrSizeOvride],FALSE
bts [di+OPERAND.OEFLAGS],OMF_FSTTAB
or [di+OPERAND.OEFLAGS],4 SHL OM_FTAB
call readrm
ret
op51 ENDP
;/* op 52, FILD & FISTP */
op52 PROC
mov [reqsPtrSizeOvride],FALSE
mov ah,1 ; assume dword
mov al,fs:[si]
cmp al,0dfh
jnz op52dw
mov ah,2 ; assume qword
test byte ptr fs:[si+1],20h
jnz op52dw
mov ah,3
op52dw:
mov al,ah
sub ah,ah
bts [di+OPERAND.OEFLAGS],OMF_FSTTAB
shl ax,OM_FTAB
or [di+OPERAND.OEFLAGS],ax
call readrm
ret
op52 ENDP
;/* op 53, FIST & FISTP */
op53 PROC
jmp op52
op53 ENDP
;/* op 54, FREG */
op54 PROC
mov [reqsPtrSizeOvride],0
bts [di+OPERAND.OEFLAGS],OMF_FST
call ReadRM
ret
op54 ENDP
;/* op 55, FREG if not one */
op55 PROC
mov al,fs:[si+1]
and al,7
cmp al,1
jnz op54
sub ax,ax
ret
op55 ENDP
;/* op 56, FIMATH */
op56 PROC
mov [reqsPtrSizeOvride],false
mov ax,1
test byte ptr fs:[si],4
jz op56go
mov al,3
op56go:
bts [di+OPERAND.OEFLAGS],OMF_FSTTAB
shl ax,OM_FTAB
or [di+OPERAND.OEFLAGS],ax
call readrm
ret
op56 ENDP
ReadOverrides PROC
ro_lp:
sub ax,ax
lods BYTE PTR fs:[si]
test [Disassemble32Bit],1
jz testseg
cmp al,64h
jc short testseg
cmp al,68h
jnc short testseg
sub al,64h
mov bx,SG_FS
ro_found:
mov cl,al
shl bx,cl
or [segs],bx
jmp short ro_lp
testseg:
push ax
and al,0e7h
cmp al,026h
pop ax
jnz testrep
mov bx,1
shr ax,3
and al,3
jmp ro_found
testrep:
sub al,0f2h
cmp al,2
jnc ro_done
mov bx,SG_REPNZ
jmp short ro_found
ro_done:
dec si
ret
ReadOverrides ENDP
DispatchOperands PROC
mov dx,ax
push bx
mov di,offset nmmnemonic
push si
mov si,[bx+OPCODE.MNEMONIC]
call strcpy
pop si
mov [reqsPtrSizeOvride],TRUE
movzx ax,[bx+OPCODE.OPERANDS]
push ax
mov di,offset dest
mov bx,offset source
test [x86pfx],1
jz short notwobyte
or [segs],SG_TWOBYTEOP
notwobyte:
mov ax,offset extraoperand
movzx eax,ax
mov [eax+OPERAND.CODE],0
mov [di+OPERAND.CODE],0
mov [bx+OPERAND.CODE],0
mov [di+OPERAND.OEFLAGS],0
mov [bx+OPERAND.OEFLAGS],0
bt DWORD PTR fs:[si],0
jc notbyte
bts [di+OPERAND.OEFLAGS],OMF_BYTE
bts [bx+OPERAND.OEFLAGS],OMF_BYTE
notbyte:
or dx,dx
jz short xadr16
bts [di+OPERAND.OEFLAGS],OMF_ADR32
bts [bx+OPERAND.OEFLAGS],OMF_ADR32
bts [di+OPERAND.OEFLAGS],OMF_OP32
bts [bx+OPERAND.OEFLAGS],OMF_OP32
xadr16:
test [segs],SG_ADRSIZ
jz do_word1
btc [di+OPERAND.OEFLAGS],OMF_ADR32
btc [bx+OPERAND.OEFLAGS],OMF_ADR32
do_word1:
test [segs],SG_OPSIZ
jz do_word2
btc [di+OPERAND.OEFLAGS],OMF_OP32
btc [bx+OPERAND.OEFLAGS],OMF_OP32
do_word2:
pop ax
or ax,ax
jz nodispatch
dec al
push 0
call TableDispatch
dw 55
dw OP1, OP2, OP3, OP4, OP5, OP6, OP7, OP8, OP9, OP10
dw OP11, OP12, OP13, OP14, OP15, OP16, OP17, OP18, OP19, OP20
dw OP21, OP22, OP23, OP24, OP25, OP26, OP27, OP28, OP29, OP30
dw OP31, OP32, OP33, OP34, OP35, OP36, OP37, OP38, OP39, OP40
dw OP41, OP42, OP43, OP44, OP45, OP46, OP47, OP48, OP49, OP50
dw OP51, OP52, OP53, OP54, OP55, OP56
movzx ax,al
add si,ax
nodispatch:
pop bx
movzx ax,[bx+OPCODE.OCLENGTH]
add si,ax
ret
DispatchOperands ENDP
doreqsPtrSizeOvride PROC
push di
push si
test [reqsPtrSizeOvride],-1
jz short floatreqsPtrSizeOvride
bt [di+OPERAND.OEFLAGS],OMF_BYTE
jnc chkdwptr
mov di,si
mov si,offset byptr
jmp short reqsPtrSizeOvrideend
chkdwptr:
bt [di+OPERAND.OEFLAGS],OMF_OP32
mov di,si
jnc mkwordptr
mov si,offset dwptr
jmp short reqsPtrSizeOvrideend
mkwordptr:
mov si,offset woptr
jmp short reqsPtrSizeOvrideend
floatreqsPtrSizeOvride:
bt [di+OPERAND.OEFLAGS],OMF_FSTTAB
jnc reqsPtrSizeOvridedone
mov ax,[di+OPERAND.OEFLAGS]
shr ax,OM_FTAB
and ax,7
mov di,si
push di
mov si,offset sts
movzx esi,si
movzx eax,ax
mov si,[esi+eax * 2]
call strcat
mov si,offset theptr
pop di
reqsPtrSizeOvrideend:
call strcat
reqsPtrSizeOvridedone:
pop si
call strlen
add si,ax
pop di
ret
DoreqsPtrSizeOvride ENDP
;Tab over to the next location on the display
; INPUT: AL contains the number of positions to move
; SI points to a buffer aparently containing display strings?
; If the buffer contains a string whose length exceeds the passed tab
; position, we just add the requested tab position to SI, which now points
; into the middle of that string somewhere. Otherwise, we stuff spaces into
; the buffer up to the requested tab position.
TabTo PROC
movzx eax,al ;convert length to dword
mov cx,ax ;put into loop counter
call strlen ;find length of string, returned in AX
xchg ax,cx ;tab length now in AX, string length in CX
sub ax,cx ;subtract string length from tab length
jnc tt_noover ;if NC, tab length was longer than string
add ax,cx ;else get tab length back into AX
add si,ax ;and add that to buffer pointer
jmp short tt_done ;return new buffer position in SI
;We got here if the string in the buffer was shorter than the distance to
;the tab position. In this case, AX is tab-string, and cx=stringlen.
tt_noover:
add si,cx ;add string length to SI
mov cx,ax ;put tab-string into cx
or cx,cx ;were they the same?
jnz tabtlp ;if not, OK
inc cx ;else stash one space anyway
tabtlp:
mov BYTE PTR [si],' ' ;space
inc si ;bump pointer into buffer
loop tabtlp ;for the remaining positions
tt_done:
mov BYTE PTR [si],0 ;put a 0 in the buffer following the spaces
ret
TabTo ENDP
GetST PROC
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -