用汇编语言设计一个将0-9十个数累加的程序,并将每一步计算步骤显示
assume cs:cseg
cseg segment
start:
mov cx, 9
mov bx, 0 ; sum 0-9
mov al, 0
mov dl, 1
$0:
call printdec
push ax
mov al, '+'
call printAl
mov ah, 0
mov al, dl
call printDec
mov al, '='
call printAl
pop ax
add al,dl
call printDec
push ax
mov al,0dh
call printAl
mov al,0ah
call printAl
pop ax
inc dl
loop $0
;exit to dos
mov ah,4ch
int 21h
printDec proc near
push ax
push bx
push cx
push dx
mov bx, 10
xor cx, cx
Q0:
xor dx, dx
div bx
xor dx, 0e30h
push dx
inc cx
cmp ax, 0
jnz Q0
Q1:
pop ax
int 10h
loop Q1
pop dx
pop cx
pop bx
pop ax
ret
printDec endp
printAl proc near
mov ah,0eh
int 10h
ret
printAl endp
cseg ends
end start
温馨提示:答案为网友推荐,仅供参考
相似回答