请求大神给点指导
这是一个三位数的汇编程序,只需要16的寄存器,如何改写成八位数的汇编的程序。assume cs:code
data segment
num db 0,0,0
data ends
code segment
;将百位数ax的值百位存到num[0],十位num[1],个位num[2]
init:
push ax
push bx
push cx
push dx
push bp
mov bp,10
lea bx,num
add bx,2
mov cx,3
init1:
xor dx,dx
div bp
mov ds:[bx],dl
dec bx
loop init1
pop bp
pop dx
pop cx
pop bx
pop ax
ret
;将num[]的三个数输出
print:
push ax
push cx
push dx
lea bx,num
mov cx,3
print1:
mov dl,ds:[bx]
add dl,30h
mov ah,2
int 21h
inc bx
loop print1
mov ah,2
mov dx,10
int 21h
pop dx
pop cx
pop ax
ret
;将num[3]的每个数的3次方相加保存到ax
calc:
push bx
push cx
push dx
push si
push bp
xor si,si
mov cx,3
lea bx,num
calc1:
mov al,ds:[bx]
mov ah,0
mov bp,ax
mul bp
mul bp
add si,ax
inc bx
loop calc1
mov ax,si
pop bp
pop si
pop dx
pop cx
pop bx
ret
start:
mov ax,data
mov ds,ax
mov cx,99
s:
inc cx
cmp cx,999
ja exit
mov ax,cx
call init
call calc
cmp ax,cx
jne s
call print
jmp s
exit:
mov ah,4ch
int 21h
code ends
end start