21,496
社区成员




.386
.MODEL FLAT
ExitProcess PROTO NEAR32 stdcall,dwExitCode:DWORD
include io.h
cr equ 0dh
Lf equ 0ah
.STACK 4096
.DATA
prompt BYTE cr,Lf,'How many disks? ',0
number BYTE 16 DUP(?)
message BYTE cr,Lf,'Move disk from spindle '
source BYTE ?,' to spindle '
dest BYTE ?,'.',0
.CODE
Move PROC NEAR32
push ebp
mov ebp,esp
push eax
push ebx
cmp WORD PTR [ebp+14],1
jne elseMore
mov bx,[ebp+12]
mov source,bl
mov bx,[ebp+10]
mov dest,bl
output message
jmp endIfOne
elseMore:
mov ax,[ebp+14]
dec ax
push ax
pushw [ebp+12]
pushw [ebp+8]
pushw [ebp+10]
call Move
add esp,8
pushw 1
pushw [ebp+12]
pushw [ebp+10]
pushw [ebp+8]
call Move
add esp,8
push ax
pushw [ebp+8]
pushw [ebp+10]
pushw [ebp+12]
call Move
add esp,8
endIfOne:
pop ebx
pop eax
pop ebp
ret
Move ENDP
_start:
output prompt
input number,16
atoi number
push ax
mov al,'A'
push ax
mov al,'B'
push ax
mov al,'C'
push ax
call Move
add esp,8
INVOKE ExitProcess,0
PUBLIC _start
END
.386
.MODEL FLAT
ExitProcess PROTO NEAR32 stdcall,dwExitCode:DWORD
include io.h
cr EQU 0dh
Lf EQU 0ah
.STACK 4096
.DATA
prompt BYTE "Enter a 16's number:",0
number BYTE 20 DUP(?)
result BYTE "The octal representation is:"
octOut BYTE 6 DUP(?),cr,Lf,0
.CODE
ToOctal PROC NEAR32
push ebp
mov ebp,esp
pushad
pushf
quit:
popf
popad
pop ebp
ret 8
ToOctal ENDP
_start:
output prompt
input number,20
atod number
push eax
lea eax,octOut
push eax
call ToOctal
output result
INVOKE ExitProcess,0
PUBLIC _start
END