📄 w.asm
字号:
mov errflags,1
jmp ret0
exit:
mov esi,edx
cmp byte ptr [esi],'+'
jne ret0
call _Deleteminius
ret0:
pop edx
pop eax
ret
TO endp
_Addminius proc
push edi
push esi
push eax
mov edi,esi
call _Strlen1
add esi,ecx
inc ecx
add edi,ecx
@1: mov al,byte ptr [esi]
mov byte ptr [edi],al
dec edi
dec esi
loop @1
mov byte ptr [edi],'-'
pop eax
pop esi
pop edi
ret
_Addminius endp
_Quit proc
invoke DestroyWindow,hWinMain
invoke PostQuitMessage,NULL
ret
_Quit endp
_Strlen PROC
push eax
push esi
xor ecx,ecx
cmp emptyflags,0
jz @2
cmp emptyflags,2
jz @2
@1:
inc ecx
inc esi
mov al,byte ptr [esi]
cmp al,0
jnz @1
@2: pop esi
pop eax
ret
_Strlen endp
_Strlen1 proc
push eax
push esi
xor ecx,ecx
mov al,byte ptr [esi]
@91: cmp al,0
jz @90
inc ecx
inc esi
mov al,byte ptr [esi]
jmp @91
@90: pop esi
pop eax
ret
_Strlen1 endp
_Strcat proc
push edi
push eax
call _Strlen
add edi,ecx
mov al,keychar
mov byte ptr [edi],al
inc edi
mov byte ptr [edi],0
pop eax
pop edi
ret
_Strcat endp
_Deleteminius proc
push eax
push edi
push esi
mov edi,esi
call _Strlen1
;dec ecx
inc edi
@1: mov al,byte ptr [edi]
mov byte ptr [esi],al
inc edi
inc esi
loop @1
pop esi
pop edi
pop eax
ret
_Deleteminius endp
_Move proc
push eax
push edi
push esi
call _Strlen1
inc ecx
@601: mov al,byte ptr [esi]
mov byte ptr [edi],al
inc edi
inc esi
loop @601
pop esi
pop edi
pop eax
ret
_Move endp
_Atod proc
push esi
call real2
addr2 equ this word
real2: pop esi
sub esi,offset addr2
push eax
mov byte ptr status[esi],0
push ebx
mov al,byte ptr [ebx]
cmp al,cr
jz zero
call sign0
call get_num
jc error
cmp al,cr
jz ok
and byte ptr status[esi],0fdh
call sign0
call get_num
jc error
fild ten[esi]
call _XexpY
fmulp st(1),st
ok: clc
exit: pop ebx
pop eax
pop esi
ret
zero: fldz
jmp ok
error: stc
finit
jmp exit
sign0: mov al,[ebx]
fld1
cmp al,'-'
jz sign_m
cmp al,'+'
jz sign_p
ret
sign_m: fchs
sign_p: inc ebx
ret
check: cmp al,9
jb num
sub al,'0'
jb non_n
cmp al,'9'
ja non_n
num: clc
ret
non_n: stc
ret
get_num:
fldz
n0: cbw
mov al,byte ptr [ebx]
cmp al,cr
jz n2
cmp al,'E'
je n1
cmp al,'e'
je n1
cmp al,'.'
je n6
call check
jnc n7
jmp short n5
n1: test status[esi],1
jnz n5
or status[esi],1
n2: test status[esi],0fh
jz na
test status[esi],2
jz n3
fcomp st(1)
n3: test status[esi],4
jnz short n4
fcomp st
fld1
n4: fmulp st(1),st
inc ebx
clc
ret
n5: stc
ret
n6: test status[esi],2
jnz n5
or status[esi],6
fld1
fidiv ten[esi]
jmp short n9
n7: mov x[esi],ax
or status[esi],4
test status[esi],2
jnz n8
fimul ten[esi]
fild x[esi]
faddp st(1),st
jmp short n9
n8: fld st
fimul x[esi]
faddp st(2),st
fidiv ten[esi]
n9: inc ebx
jmp n0
na: fcomp st
fldz
jmp n4
_Atod endp
_2exp proc
fstcw cw
fwait
push cw
and cw,0f3ffh
or cw,00400h
fldcw cw
fld st
frndint
pop cw
fldcw cw
fsub st(1),st
fxch
f2xm1
fld1
faddp st(1),st
fscale
fstp st(1)
ret
_2exp endp
_XexpY proc
ftst
push eax
fstsw sw
fwait
mov ax,sw
sahf
jz zero
jc err1
fyl2x
call _2exp
exit: clc
pop eax
ret
zero: fcomp
ftst
fstsw sw
mov ax,sw
sahf
jz err2
fcomp
fldz
jmp exit
err1: fcomp
err2: fcomp
stc
pop eax
ret
_XexpY endp
_Dtoa proc
push esi
call realad
addrad equ this word
realad: pop esi
sub esi,offset addrad
ftst
push eax
fstsw sw1[esi]
fwait
mov ax,sw1[esi]
sahf
fld st
jne non_z
fbstp exp[esi]
fld st
jmp short ok_z
non_z: fabs
fld1
fxch st(1)
fyl2x
fldl2t
fdivp st(1),st
fstcw cw1[esi]
fwait
push cw1[esi]
and cw1[esi],not 0c00h
or cw1[esi],0400h
fldcw cw1[esi]
frndint
pop cw1[esi]
fldcw cw1[esi]
fld st
fbstp exp[esi]
fchs
fild ten[esi]
call _XexpY
fmul st,st(1)
fmul ten17[esi]
ok_z:
fbstp mans[esi]
cld
push edi
push ebx
mov edi,ebx
mov ebx,offset mans+9
add ebx,esi
mov al,byte ptr [ebx]
call set_sign
dec ebx
mov al,byte ptr [ebx]
mov ah,al
and al,0f0h
shr al,4
call set_nibble
mov al,'.'
stosb
mov al,ah
call set_nibble
push ecx
dec ebx
mov ecx,8
agin0: call set_byte
loop agin0
mov al,'e'
stosb
mov ebx,offset exp+9
add ebx,esi
mov al,byte ptr [ebx]
call set_sign
mov ecx,2
sub ebx,8
agin1: call set_byte
loop agin1
pop ecx
pop ebx
pop edi
pop eax
pop esi
ret
set_sign: or al,al
mov al,'+'
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -