主题:[原创]改一个十进制转八进制加分
帮忙改这个程序,10进制转八进制
data segment
message db 'please put into:$'
data ends
stack segment stack
db 100 dup (0)
stack ends
code segment
assume cs:code,ds:data,ss:stack
main proc far
start:mov ax,data
mov ds,ax
mov ax,stack
mov ss,ax
mov bx,0
loop1:lea dx,message
mov ah,09h
int 21h
mov ah,01h
int 21h
cbw
sub ax,30h
cmp ax,0h
jl exit
cmp ax,09h
jg exit
cmp al,'*'
jz continue
xchg ax,bx
mov dx,10
mul dx
add ax,bx
xchg ax,bx
jmp loop1
continue: call binoctal
exit: mov ah,4ch
int 21h
main endp
binoctal proc near
mov cx,5
loop2:mov cl,3
rol bx,cl
mov ax,bx
and al,07h
mov dl,al
mov ah,02h
int 21h
loop loop2
rol bx,1
mov ax,bx
and al,07h
mov dl,al
mov ah,02h
int 21h
ret
binoctal endp
code ends
end start
data segment
message db 'please put into:$'
data ends
stack segment stack
db 100 dup (0)
stack ends
code segment
assume cs:code,ds:data,ss:stack
main proc far
start:mov ax,data
mov ds,ax
mov ax,stack
mov ss,ax
mov bx,0
loop1:lea dx,message
mov ah,09h
int 21h
mov ah,01h
int 21h
cbw
sub ax,30h
cmp ax,0h
jl exit
cmp ax,09h
jg exit
cmp al,'*'
jz continue
xchg ax,bx
mov dx,10
mul dx
add ax,bx
xchg ax,bx
jmp loop1
continue: call binoctal
exit: mov ah,4ch
int 21h
main endp
binoctal proc near
mov cx,5
loop2:mov cl,3
rol bx,cl
mov ax,bx
and al,07h
mov dl,al
mov ah,02h
int 21h
loop loop2
rol bx,1
mov ax,bx
and al,07h
mov dl,al
mov ah,02h
int 21h
ret
binoctal endp
code ends
end start