📄 asmops.asm
字号:
test al,2
mov eax,dword ptr [bx +asmop.addrx]
jnz aop31sb1
test [PrefixBitmapWord],AS_OPSIZE
jz aop31szw
stosd
clc
ret
aop31szw:
stosw
clc
ret
aop31sb1:
stosb
clc
ret
aop31sb PROC
mov ecx,[bx+asmop.addrx]
test ecx,NOT 7fh
jnz aop31sbx
cmp ecx,-80h
jl aop31sbx
cmp [bx+asmop.asize],BYTESIZE
je aop31sbx
or al,2
aop31sbx:
ret
aop31sb ENDP
AOP31 ENDP
;
; move to/from a special register
; bit 1 = set if spc reg is the dest
; bit 0 & 2 define the special reg
;
AOP32 PROC
call noarg3
call intsize
mov bx,offset arg1
mov cx,offset arg2
mov ax,[si+OPCODE.COMPARE]
cmp [arg1.asize],DWORDSIZE
jne aop32bad
cmp [arg1.mode],am_reg
je aop32crsource
or al,2
xchg bx,cx
aop32crsource:
sub dl,dl
cmp [ecx+asmop.mode],AM_CR
je aop32c
mov dl,1
cmp [ecx+asmop.mode],AM_DR
je aop32c
mov dl,4
cmp [ecx+asmop.mode],AM_TR
jne aop32bad
aop32c:
or al,dl
stosb
call chkreg
movzx ecx,cx
mov al,[ecx+asmop.areg1]
shl al,3
or al,[bx +asmop.areg1]
or al,ah ; actually is a MOD/RM which is restricted
; to regs
stosb
and [PrefixBitmapWord],NOT AS_OPSIZE ; don't need opsize for this
; and there will be no clash
; if we got this far
ret
aop32bad:
stc
ret
AOP32 ENDP
;
; rm,reg,count (shld/shrd)
; bit 0 = set if using CL for count
;
;
aop33 PROC
mov bx,offset arg2
call chkreg
cmp [bx+asmop.asize],BYTESIZE
je aop33bad
mov ah,[bx+asmop.areg1]
mov al,byte ptr [si+OPCODE.compare]
mov bx,offset arg3
cmp [bx+asmop.areg1],isECX
je aop33cl
call chkimm
stosb
xchg al,ah
mov bx,offset arg1
call asmrm
mov al,byte ptr [arg3.addrx]
stosb
ret
aop33cl:
cmp [bx+asmop.mode],AM_REG
jne aop33bad
or al,1h
stosb
xchg al,ah
mov bx,offset arg1
call asmrm
ret
aop33bad:
stc
ret
AOP33 ENDP
;
; push & pop rm
;
AOP34 PROC
call noarg2
call intsize
mov bx,offset arg1
cmp [bx+asmop.asize],BYTESIZE
je aop34bad
mov ax,[si+OPCODE.compare]
stosb
xchg al,ah
call asmrm2
ret
aop34bad:
stc
ret
AOP34 ENDP
;
; floating R/M
; bit two of opcode set if size is qword
; bit 3 of mod/rm set if last ch = 'p'
;
AOP35 PROC
call noarg2
mov ax,[si+OPCODE.COMPARE]
and ax,010d8h
cmp [arg1.mode],AM_FPREG
je aop35fin
cmp [arg1.asize],QWORDSIZE
jne aop35fin
or al,4
aop35fin:
cmp [lastbyte],'p'
jne aop35fin2
or ah,8
aop35fin2:
stosb
xchg al,ah
mov bx,offset arg1
call asmfrm
ret
AOP35 ENDP
;
; fmathp
; sti),st(0) or nothing
;
AOP36 PROC
cmp [arg3.mode],AM_NONE
jne aop36errx
mov ax,100h
cmp [arg2.mode],AM_NONE
jne aop362arg
call noarg1
jmp aop36fin
aop362arg:
cmp [arg1.mode],AM_FPREG
jne aop36errx
cmp [arg2.mode],AM_FPREG
jne aop36errx
cmp [arg2.areg1],isEAX
jne aop36errx
mov ah,[arg1.areg1]
aop36fin:
or ax,[si+OPCODE.COMPARE]
stosw
ret
aop36errx:
stc
ret
AOP36 ENDP
;
; fmath
; st(i),st(0) ; st(0), st(i), mem
; bit two of opcode set for i dest or qword mem
; bit 3 of mod/rm gets flipped if reg & al &6 & bit 5 of mod/rm set
;
;
AOP37 PROC
cmp [arg3.mode],AM_NONE
jne aop37errx
mov ax,[si+OPCODE.COMPARE]
and al,NOT 4
cmp [arg2.mode], AM_NONE
je aop37mem
cmp [arg1.mode],AM_FPREG
jne AOP37mem
cmp [arg2.mode],AM_FPREG
jne AOP37errx
mov bl,[arg2.areg1]
mov bh,[arg1.areg1]
cmp bh,0
je aop37isrc
cmp bl,0
jne aop37errx
xchg bl,bh
or al,4
aop37isrc:
test al,6
jz aop371
test ah,20h
jz aop371
xor ah,8
aop371:
or ah,bl
or ah,0c0h
stosw
ret
aop37mem:
cmp [arg2.mode],AM_NONE
jne aop37errx
cmp [arg1.asize],QWORDSIZE
jne aop37memnq
or al,4
aop37memnq:
stosb
xchg al,ah
mov bx,offset [arg1]
call asmfrm
ret
aop37errx:
stc
ret
AOP37 ENDP
;
; far RM
;
AOP38 PROC
call noarg2
cmp [arg1.asize],DWORDSIZE
jne aop38errx
cmp [arg1.mode],AM_REG
je aop38errx
mov ax,[si+opcode.compare]
stosb
xchg al,ah
mov bx,offset arg1
call asmrm2
ret
aop38errx:
stc
ret
AOP38 ENDP
;
; word regrm with reg source
; bug: lets arpl [bx],eax through
;
AOP39 PROC
cmp [arg2.asize],BYTESIZE
jne AOP40
stc
ret
AOP39 ENDP
;
; regrm with reg source
; bit 0 = size
AOP40 PROC
call noarg3
call intsize
mov bx,offset arg2
call chkreg
mov al,byte ptr [si+opcode.compare]
call sizeb0
stosb
mov al,[arg2.areg1]
mov bx,offset arg1
call asmrm
ret
AOP40 ENDP
;
; rm,immediate
;
AOP41 PROC
call noarg3
call intsize
mov bx,offset arg2
call chkimm
cmp [arg1.asize],BYTESIZE
je aop41errx
mov ax,[si+OPCODE.COMPARE]
stosb
xchg al,ah
mov bx,offset arg1
call asmrm2
mov al,byte ptr [arg2.addrx]
stosb
ret
aop41errx:
stc
ret
AOP41 ENDP
;
; regrm with reg dest & forced strictness (MOVZX & MOVSX)
; bit 0 of opcode set if size is word
;
AOP42 PROC
call noarg3
call intsize
mov bx,offset arg1
call chkreg
cmp [arg1.asize],BYTESIZE
je aop42errx
cmp [arg2.asize],NOSIZE
je aop42errx
mov bx,offset arg2
mov ax,[si+OPCODE.COMPARE]
call sizeb0
stosb
xchg al,ah
call asmrm2
cmp [arg1.asize],DWORDSIZE ; another func for which
; auto extend to dword doesn't work
jne aop42x
or [PrefixBitmapWord],AS_OPSIZE
aop42x:
clc
ret
aop42errx:
stc
ret
AOP42 ENDP
;
; not needed in assembler, same as no args
;
AOP43 PROC
jmp aop0
AOP43 ENDP
;
; unused
;
AOP44 PROC
call noarg2
call intsize
mov bx,offset arg1
call chkreg
cmp [bx+asmop.asize],DWORDSIZE
jne aop44errx
or [PrefixBitmapWord],AS_OPSIZE
mov al,byte ptr [si+OPCODE.COMPARE]
or al,[bx+asmop.areg1]
stosb
ret
aop44errx:
stc
ret
AOP44 ENDP
;
; any regrm with reg source
; same as aop40
;
AOP45 PROC
jmp aop40
AOP45 ENDP
;
; rm , size don't care, but no regs
;
AOP46 PROC
cmp [arg1.mode],AM_FPREG
je aop46err
cmp [arg1.mode],AM_REG
jne aop29
aop46err:
stc
ret
AOP46 ENDP
;
; ax reg only
;
AOP47 PROC
call noarg2
mov bx,offset arg1
call chkaxw
mov ax,[si+OPCODE.COMPARE]
stosw
clc
ret
AOP47 ENDP
;
; bswap, 32-bit reg to bits 0-3 of opcode
;
AOP48 PROC
call noarg2
call intsize
mov bx,offset arg1
call chkreg
cmp [bx+asmop.asize],DWORDSIZE
jne aop48errx
or [PrefixBitmapWord],AS_OPSIZE
mov al,byte ptr [si+OPCODE.COMPARE]
or al,[bx+asmop.areg1]
stosb
ret
aop48errx:
stc
ret
AOP48 ENDP
;
; fst
; same as next but no tbyte
;
AOP49 PROC
cmp [arg1.asize],TBYTESIZE
jb aop50
stc
ret
AOP49 ENDP
;
; fld/fstp
; freg
; dword,qword,tybe
; bit 1 of opcode set for tbyte
; bit 2 of opcode set for qword or store
; bit 5 of modrm set if tbyte
; bit 3 of modrm gets cleared if not tbyte && bit 4 set
;
AOP50 PROC
call noarg2
mov ax,[si+OPCODE.COMPARE]
AND ax,NOT 0e006h
cmp [arg1.mode],AM_FPREG
je aop50reg
cmp [arg1.asize],DWORDSIZE
jb aop50errx
aop502:
cmp [arg1.asize],TBYTESIZE
jne aop503
or ax,2802h
jmp aop505
aop503:
cmp [arg1.asize],QWORDSIZE
jne aop504
or al,4
aop504:
test ah,10h
jnz aop505
and ah,NOT 8
aop505:
stosb
xchg al,ah
mov bx,offset arg1
call asmfrm
ret
aop50reg:
test ah,10h
jnz aop506
and ah,NOT 8
jmp aop507
aop506:
or al,4
aop507:
or ah,0c0h
or ah,[arg1.areg1]
stosw
ret
aop50errx:
stc
ret
AOP50 ENDP
;
;
; fbld/fbstp
; tbyte ptr mem
;
AOP51 PROC
call noarg2
cmp [arg1.mode],AM_FPREG
je aop51errx
cmp [arg1.asize],NOSIZE
je aop51c
cmp [arg1.asize],TBYTESIZE
jne aop51errx
aop51c:
mov ax,[si+OPCODE.COMPARE]
stosb
xchg al,ah
mov bx,offset arg1
call asmfrm
ret
aop51errx:
stc
ret
AOP51 ENDP
;
; fild/fistp
; word,dword,qword mem
; bit 2 of opcode set if word or qword
; bit 3 of modrm gets cleared if not qword & bit 4 is set
; bit 5 or modrm set if qword
;
AOP52 PROC
call noarg2
mov ax,[si+OPCODE.COMPARE]
and ax,NOT 2004h
cmp [arg1.mode],AM_FPREG
je aop52errx
cmp [arg1.asize],DWORDSIZE
je aop522
or al,4
aop522:
cmp [arg1.asize],QWORDSIZE
ja aop52errx
jne aop523
or ah,20h
jmp aop524
aop523:
test ah,10h
jnz aop524
and ah, NOT 8
aop524:
stosb
xchg al,ah
mov bx,offset arg1
call asmfrm
ret
aop52errx:
stc
ret
AOP52 ENDP
;
; fist
; same as above but no qword mode
;
AOP53 PROC
cmp [arg1.asize],QWORDSIZE
jb aop52
stc
ret
AOP53 ENDP
;
; freg
; reg put in mod/rm byte
;
AOP54 PROC
call noarg2
cmp [arg1.mode],AM_FPREG
jne aop54errx
mov ax,[si+OPCODE.COMPARE]
or ah,[arg1.areg1]
stosw
ret
aop54errx:
stc
ret
AOP54 ENDP
;
; same as above, deault to reg 1 if no args
AOP55 PROC
cmp [arg3.mode],AM_NONE
jne aop55errx
cmp [arg2.mode],AM_NONE
jne aop55errx
call noarg2
mov ax,[si+OPCODE.COMPARE]
cmp [arg1.mode],AM_FPREG
jne aop55chknone
or ah,[arg1.areg1]
stosw
ret
aop55chknone:
cmp [arg1.mode],AM_NONE
jne aop55errx
or ah,1
stosw
ret
aop55errx:
stc
ret
AOP55 ENDP
;
; fimath
; word or dword arg
; bit two gets set if word
;
AOP56 PROC
call noarg2
call intsize
cmp [arg1.asize],BYTESIZE
je aop56errx
cmp [arg1.mode],AM_FPREG
je aop56errx
mov ax,[si+OPCODE.COMPARE]
cmp [arg1.asize],WORDSIZE
jne aop56c
or al,4
aop56c:
stosb
xchg al,ah
mov bx,offset arg1
call asmfrm
ret
aop56errx:
ret
AOP56 ENDP
;
; addrsize prefix on one-byte
;
AOP57 PROC
or [PrefixBitmapWord],AS_ADDRSIZE
jmp aop0
AOP57 ENDP
;
; opsize prefix on one-byte
;
AOP58 PROC
or [PrefixBitmapWord],AS_OPSIZE
jmp aop0
AOP58 ENDP
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -