assume cs:code,ds:data start:mov ax,data mov ds,ax mov al,0 mov ah,01h int 21h mov bh,al mov ah,01h int 21h mov bl,al mov ax,0 sub bh,30h mov al,bh mov cl,0ah mul cl sub bl,30h add al,bl mov dl,al
mov bl,10h mov cl,al mov dl,0 l1:cmp cl,bl jnae l2 inc dl sub cl,bl jmp l1
l2:add dl,30h mov ah,02h int 21h
cmp cl,0ah jae l3 mov dl,cl add dl,30h mov ah,02h int 21h jmp e
l3: mov dl,cl add dl,37h mov ah,02h int 21h
e: mov ah,4ch int 21h code ends
end start
2. 10转2 data segment
output1 db 'input the decimal number:$' output2 db 'the binary number is:$' data ends
code segment
assume cs:code,ds:data main proc far start:
mov ax,data mov ds,ax
mov dx,offset output1 mov ah,09h int 21h call crlf input: mov ah,01h int 21h cmp al,30h jb input cmp al,39h
jae input mov bl,al
lea dx,output2 mov ah,09h int 21h call crlf mov cx,4 m1: test bl,8h jnz m2 mov dl,'0' mov ah,02h int 21h
jmp m3 m2: mov dl,'1' mov ah,02h int 21h m3: shl bx,1 loop m1
mov ah,4ch int 21h ret main endp
crlf proc near
mov dl,0dh mov ah,02h int 21h mov dl,0ah mov ah,02h int 21h ret crlf endp
code ends
end start
因篇幅问题不能全部显示,请点此查看更多更全内容