我有个汇编的程序代码,谁可以帮我讲解一下什么意思!
题目是图片,代码如下!stacksegmentstackdw512dup(?)stackendsdatasegmentdaxdw0daydw0bufferdb10db0d...
题目是图片,代码如下!
stack segment stack
dw 512 dup(?)
stack ends
data segment
dax dw 0
day dw 0
buffer db 10
db 0
db 10 dup(0)
string db 0dh,0ah,'$'
data ends
code segment 'code'
assume cs:code, ds:data, ss:stack
main proc far
mov ax,data
mov ds,ax
call InputX
call CalY
lea dx,string
mov ah,9
int 21h
call Print
mov ax,4c00h
int 21h
main endp
InputX proc near
mov ah,0ah
mov dx,offset buffer
int 21h
lea si,buffer
inc si
mov ch,0
mov cl,[si]
inc si
again:
mov ax,dax
mov bx,10
imul bx
mov dax,ax
mov ax,0
mov al,[si]
sub al,30h
add dax, ax
inc si
loop again
ret
InputX endp
CalY proc near
cmp dax,0
jne next1
mov ax,dax
add ax,1000
mov day,ax
jmp exitCalY
next1:
cmp dax,1
jne next2
mov ax,dax
mov bx,5
imul bx
sub ax,2
mov day,ax
jmp exitCalY
next2:
mov ax,dax
mov day,ax
cmp day,0
jg exitCalY
mov ax,0
sub ax,day
mov day,ax
exitCalY:
ret
CalY endp
Print proc near
mov ah,02h
cmp day,0
jne next3
mov dl,'0'
jmp exitPrint
next3:
cmp day,0
jg next4
mov dl,'-'
jmp exitPrint
next4:
mov dl,'+'
exitPrint:
int 21h
ret
Print endp
code ends
end main 展开
stack segment stack
dw 512 dup(?)
stack ends
data segment
dax dw 0
day dw 0
buffer db 10
db 0
db 10 dup(0)
string db 0dh,0ah,'$'
data ends
code segment 'code'
assume cs:code, ds:data, ss:stack
main proc far
mov ax,data
mov ds,ax
call InputX
call CalY
lea dx,string
mov ah,9
int 21h
call Print
mov ax,4c00h
int 21h
main endp
InputX proc near
mov ah,0ah
mov dx,offset buffer
int 21h
lea si,buffer
inc si
mov ch,0
mov cl,[si]
inc si
again:
mov ax,dax
mov bx,10
imul bx
mov dax,ax
mov ax,0
mov al,[si]
sub al,30h
add dax, ax
inc si
loop again
ret
InputX endp
CalY proc near
cmp dax,0
jne next1
mov ax,dax
add ax,1000
mov day,ax
jmp exitCalY
next1:
cmp dax,1
jne next2
mov ax,dax
mov bx,5
imul bx
sub ax,2
mov day,ax
jmp exitCalY
next2:
mov ax,dax
mov day,ax
cmp day,0
jg exitCalY
mov ax,0
sub ax,day
mov day,ax
exitCalY:
ret
CalY endp
Print proc near
mov ah,02h
cmp day,0
jne next3
mov dl,'0'
jmp exitPrint
next3:
cmp day,0
jg next4
mov dl,'-'
jmp exitPrint
next4:
mov dl,'+'
exitPrint:
int 21h
ret
Print endp
code ends
end main 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询