386fpemu.inc
来自「开放源码的编译器open watcom 1.6.0版的源代码」· INC 代码 · 共 1,702 行 · 第 1/5 页
INC
1,702 行
dosib: mov bl,[esi] ; get sib byte in bl ssiiibbb
inc esi ; bump over sib byte
push ebx ; save sib byte
and bl,7 ; isolate base 00000bbb
mov bh,ah ; get modrm in bh mmRRRrrr
shr bh,3 ; mod field in position 000mmRRR
and bh,18H ; isolate mod field 000mm000
or bl,bh ; glue it to get mod:base 000mmbbb
mov bh,0 ; zero top byte
ifdef SEGMENTED
call dword ptr cs:sib[ebx*4] ; calcuate base + displacement
else
call dword ptr sib[ebx*4] ; calcuate base + displacement
endif
pop edx ; sib in edx again ssiiibbb
push ecx ; save segment
mov ecx,edx ; get sib
and dl,038H ; isolate index 00iii000
cmp dl,020H ; if no index 00100000
_if ne ; - then
shr edx,1 ; - get 00iii000 / 2 000iii00
neg edx ; - negate for index into stack
mov edx,S_EAX[ebp+edx] ; - fish the right register off stack
shr cl,6 ; - get scale factor in cl 000000ss
shl edx,cl ; - scale the index
add ebx,edx ; - add it into effective address
_endif ; endif
pop ecx ; restore segment
ret ; return to caller
xref __FLDA
xref __FLDS
xref __FLDM
xref __FLDD
xref __FLDC
xref __I4LD
xref __U4LD
xref __LDI4
xref __LDU4
xref __EmuFSLD
xref __EmuLDFS
xref __EmuFDLD
xref __EmuLDFD
xref __sqrt
xref __fprem
xref __sin
xref __cos
xref __tan
xref __fpatan
xref __fyl2x
xref __f2xm1
xref __frndint ; 24-mar-90
ifdef _DEBUG
badop proc near
if _OS eq _PLDT
lea edx,illopmsg
mov ah,9H
int 21H
ret
else
lea eax,illopmsg
jmp puts_
endif
badop endp
endif
illop macro
ifdef _DEBUG
call badop
endif
endm
ifdef _DEBUG
prtnyi proc near
if _OS eq _PLDT
mov ah,9H
int 21H
lea edx,nyimsg
mov ah,9H
int 21H
ret
else
mov eax,edx
call puts_
lea eax,nyimsg
jmp puts_
endif
prtnyi endp
nyi macro string
local msg
startdata
msg db '&string',NC
enddata
lea edx,msg
call prtnyi
endm
else
nyi macro string
endm
endif
_lea macro reg,what
IFIDN <what>,<st>
lea reg,[edi+ebp].fpstack
ELSE
IFIDN <what>,<st(i)>
lea reg,[esi+ebp].fpstack
ELSE
.ERRDIF <what>,<temp>
lea reg,[ebp].fptemp
ENDIF
ENDIF
endm
_add macro a,b,c
_lea EAX,a
_lea EDX,b
_lea EBX,c
call __FLDA
endm
_sub macro a,b,c
_lea EAX,a
_lea EDX,b
_lea EBX,c
call __FLDS
endm
_mul macro a,b,c
_lea EAX,a
_lea EDX,b
_lea EBX,c
call __FLDM
endm
_div macro a,b,c
_lea EAX,a
_lea EDX,b
_lea EBX,c
call __FLDD
endm
_neg macro a
_lea EAX,a
xor byte ptr 9[EAX],80h
endm
_abs macro a
_lea EAX,st
and byte ptr 9[EAX],7Fh ; turn off sign bit
endm
_cmp macro a,b
_lea EAX,a
_lea EDX,b
call __FLDC
endm
_xchg macro a,b
_lea EBX,a
_lea ESI,b
mov eax,[esi]
xchg eax,[ebx]
mov [esi],eax
mov eax,4[esi]
xchg eax,4[ebx]
mov 4[esi],eax
mov ax,8[esi]
xchg ax,8[ebx]
mov 8[esi],ax
endm
st_top macro rtn
_lea EAX,st
call __&rtn
endm
st_top2 macro rtn
_lea EAX,st
popstk
_lea EDX,st
call __&rtn
endm
real10x struc
bytes1to4 dd 0
bytes5to8 dd 0
bytes9n10 dw 0
real10x ends
ifdef SEGMENTED
mov10 macro src_seg,src_off,dst_seg,dst_off
mov eax,src_seg:src_off.bytes1to4
mov dst_seg:dst_off.bytes1to4,eax
mov eax,src_seg:src_off.bytes5to8
mov dst_seg:dst_off.bytes5to8,eax
mov ax,src_seg:src_off.bytes9n10
mov dst_seg:dst_off.bytes9n10,ax
endm
else
mov10 macro src_seg,src_off,dst_seg,dst_off
mov eax, src_off.bytes1to4
mov dst_off.bytes1to4,eax
mov eax, src_off.bytes5to8
mov dst_off.bytes5to8,eax
mov ax, src_off.bytes9n10
mov dst_off.bytes9n10,ax
endm
endif
putword macro what,where
ifdef SEGMENTED
mov ds:[ebp].&where,what
else
mov [ebp].&where,what
endif
endm
getword macro what,where
ifdef SEGMENTED
mov what,ds:[ebp].&where
else
mov what, [ebp].&where
endif
endm
loadword macro what
ifdef SEGMENTED
mov what,es:[esi]
else
mov what, [esi]
endif
endm
saveword macro what
ifdef SEGMENTED
mov es:[esi],what
else
mov [esi],what
endif
endm
save_st macro
_lea ebx,st
push [ebx]
push 4[ebx]
push 6[ebx]
endm
restore_st macro
_lea ebx,st
pop 6[ebx]
pop 4[ebx]
pop [ebx]
endm
rndint macro
_lea eax,st
getword dx,control
and dx,CW_RC
call __frndint
endm
ldcons macro cons
mov10 cs,cons,ds,[ebp].fptemp
endm
stcons macro w1,w2,w3,w4,w5
pushstk ; push stack pointer
_lea esi,st
if ((w4 shl 16) + w5) eq 0
sub eax,eax
mov [esi],eax
else
mov dword ptr [esi],(w4 shl 16) + w5
endif
if ((w2 shl 16) + w3) eq 0
mov 4[esi],eax
else
mov dword ptr 4[esi],(w2 shl 16) + w3
endif
if w1 eq 0
mov 8[esi],ax
else
mov word ptr 8[esi],w1
endif
endm
setp_extended macro
lea edx,p_extended
ifdef __WIN387__
mov precrtn, edx
else
putword edx,precrtn
endif
endm
setp_double macro
lea edx,p_double
ifdef __WIN387__
mov precrtn, edx
else
putword edx,precrtn
endif
endm
setp_single macro
lea edx,p_single
ifdef __WIN387__
mov precrtn,edx
else
putword edx,precrtn
endif
endm
_fclex macro
ifdef SEGMENTED
and word ptr ds:[ebp].status, 07f00H
else
and word ptr [ebp].status, 07f00H
endif
endm
_finit macro
putword CW_INIT,control
putword SW_INIT,status
putword TAG_INIT,tags
setp_extended
sub edi,edi ; set top of stack pointer to 0
putword edi,stktop
endm
save87 macro size ; put the 87 into user memory
mov ecx,ENV_SIZE / 4 ; set up size reg
mov ebx,edi ; save top of stack pointer
mov edi,esi ; destination is user memory
mov esi,ebp ; source is the '8087'
rep movsd ; stash it in users memory
IFDIF <size>,<ENV_SIZE>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?