;Input a 2 digit decimal number, convert to binary ;NO Error checking on input ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; .model small .586 .stack 100h ;Set maximum stack size to 256 bytes ;; declare externally used subroutines extrn Writestring:proc, Crlf:proc, Clrscr:proc, Writeint:proc extrn Random_range:proc, Randomize:proc, Readint:proc .data msg1 db "Enter decimal number (0 - 99): ", 0h msg2 db "Decimal Value: ",0h msg3 db "Hex Value : ",0h msg4 db "Binary Value : ",0h buf db 3,0,3 dup (?) .code START: mov ax, @data ;ax <-- data segment start address mov ds, ax ;ds <-- initialize data segment register call clrscr ; clear screen mov dx, offset msg1 call Writestring ;prompt for number ;DOS interrupt 21h, function 0Ah mov ah,0ah mov dx, offset buf int 21h mov bx, offset buf+2 ; point at start of string xor cl, cl ; cl = 0, will be converted value mov al, buf+1 ; get actual number of bytes entered cmp al, 1 je onechar ; if only one character, skip multiply mov al,[bx] ; get most significant digit sub al,30h ; get value of digit mov ah,10 mul ah ; multiply by 10 mov cl,al ; save in cl inc bx ; point at next char onechar: mov al,[bx] ; get next char sub al,30h ; subtract 30h to get digit value add al,cl ; add in mult*10 value xor ah,ah ; zero ah ;; AX has value to be printed call Crlf ; print CRLF mov dx, offset msg2 call Writestring ; print msg mov bx, 10 ; print number as decimal number call Writeint call Crlf mov dx, offset msg3 call Writestring ; print msg mov bx, 16 ; print number as hex number call Writeint call Crlf mov dx, offset msg4 call Writestring ; print msg mov bx, 2 ; print number as hex number call Writeint call Crlf EXIT: mov ax, 4c00h ;ax <-- 4c DOS 21h program halt function int 21h ;DOS service interrupt END START