;輸入不超過65535的10進位制數,將其以16位的形式顯示
code segment
assume cs:code
org 100h
start:
jmp bbb
x dw 0
msg1 db 10,13,"please input a number:","$"
msg2 db 10,13," ","$"
bbb:
push cs
pop ds
lea dx,msg1
mov ah,9
int 21h
lea bx,x
mov ax,0
push ax
again1:
mov ah,1
cmp al,13
je line0
sub al,30h
mov ah,0
mov si,ax
pop ax
mov cl,10
mov ch,0
mul cx
add ax,si
jmp again1
line0:
mov word ptr[x],ax
lea di,msg2
inc di
mov cx,4
again2:
mov ax,word ptr[x]
rol ax,1
; rol ax,4
and ax,000Fh
cmp al,9
jg line1
add al,30h
mov byte ptr[di],al
jmp line2
line1:
add al,37h
line2:
loop again2
lea dx,msg2
mov ah,8
mov ah,4ch
code ends
end start
;輸入不超過65535的10進位制數,將其以16位的形式顯示
code segment
assume cs:code
org 100h
start:
jmp bbb
x dw 0
msg1 db 10,13,"please input a number:","$"
msg2 db 10,13," ","$"
bbb:
push cs
pop ds
lea dx,msg1
mov ah,9
int 21h
lea bx,x
mov ax,0
push ax
again1:
mov ah,1
int 21h
cmp al,13
je line0
sub al,30h
mov ah,0
mov si,ax
pop ax
mov cl,10
mov ch,0
mul cx
add ax,si
push ax
jmp again1
line0:
pop ax
mov word ptr[x],ax
lea di,msg2
inc di
inc di
mov cx,4
again2:
mov ax,word ptr[x]
rol ax,1
rol ax,1
rol ax,1
rol ax,1
; rol ax,4
mov word ptr[x],ax
and ax,000Fh
cmp al,9
jg line1
add al,30h
mov byte ptr[di],al
jmp line2
line1:
add al,37h
mov byte ptr[di],al
line2:
inc di
loop again2
lea dx,msg2
mov ah,9
int 21h
mov ah,8
int 21h
mov ah,4ch
int 21h
code ends
end start