主题:[原创]汇编挑战者进也!(1)
有兴趣的run这个程序:
stack segment stack
dw 20h dup(0)
stack ends
datarea segment
;在次定义变量
message1 db 'N=?',0ah,0dh,'$'
message2 db 'what is the name of spindle X ?'
db 0ah,0dh,'$'
message3 db 'what is the name of spindle Y ?'
db 0ah,0dh,'$'
message4 db 'what is the name of spindle z ?'
db 0ah,0dh,'$'
flag dw 0
constant dw 10000,1000,100,10,1
datarea ends
prognam segment
assume cs:prognam,ds:datarea,ss:stack
main proc far
push ds
mov ax,0
push ax
mov ax,datarea
mov ds,ax
;在此输入指令
lea dx,message1
mov ah,09h
int 21h
call decibin
call crlf
cmp bx,0
jz exit
lea dx,message2
mov ah,09h
int 21h
mov ah,01h
int 21h
mov ah,0
mov cx,ax
call crlf
lea dx,message3
mov ah,09h
int 21h
mov ah,01h
int 21h
mov ah,0
mov si,ax
call crlf
lea dx,message4
mov ah,09h
int 21h
mov ah,01h
int 21h
mov ah,0
mov di,ax
call crlf
call hanoi
exit: ret
main endp
hanoi proc near
cmp bx,1
je basis
call save
dec bx
xchg si,di
call hanoi
call restor
call print
dec bx
xchg cx,si
call hanoi
jmp return
basis: call print
return: ret
hanoi endp
print proc near
mov dx,cx
mov ah,02h
int 21h
call binidec
mov dx,di
mov ah,02h
int 21h
call crlf
print endp
save proc near
pop bp
push bx
push cx
push si
push di
push bp
ret
save endp
restor proc near
pop bp
pop di
pop si
pop cx
pop bx
push bp
ret
restor endp
stack segment stack
dw 20h dup(0)
stack ends
datarea segment
;在次定义变量
message1 db 'N=?',0ah,0dh,'$'
message2 db 'what is the name of spindle X ?'
db 0ah,0dh,'$'
message3 db 'what is the name of spindle Y ?'
db 0ah,0dh,'$'
message4 db 'what is the name of spindle z ?'
db 0ah,0dh,'$'
flag dw 0
constant dw 10000,1000,100,10,1
datarea ends
prognam segment
assume cs:prognam,ds:datarea,ss:stack
main proc far
push ds
mov ax,0
push ax
mov ax,datarea
mov ds,ax
;在此输入指令
lea dx,message1
mov ah,09h
int 21h
call decibin
call crlf
cmp bx,0
jz exit
lea dx,message2
mov ah,09h
int 21h
mov ah,01h
int 21h
mov ah,0
mov cx,ax
call crlf
lea dx,message3
mov ah,09h
int 21h
mov ah,01h
int 21h
mov ah,0
mov si,ax
call crlf
lea dx,message4
mov ah,09h
int 21h
mov ah,01h
int 21h
mov ah,0
mov di,ax
call crlf
call hanoi
exit: ret
main endp
hanoi proc near
cmp bx,1
je basis
call save
dec bx
xchg si,di
call hanoi
call restor
call print
dec bx
xchg cx,si
call hanoi
jmp return
basis: call print
return: ret
hanoi endp
print proc near
mov dx,cx
mov ah,02h
int 21h
call binidec
mov dx,di
mov ah,02h
int 21h
call crlf
print endp
save proc near
pop bp
push bx
push cx
push si
push di
push bp
ret
save endp
restor proc near
pop bp
pop di
pop si
pop cx
pop bx
push bp
ret
restor endp