;Print the binary value of a character ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; .model small .586 .stack 100h ;Set maximum stack size to 256 bytes .data msg db "Enter Character:", "$" pcrlf db 0ah, 0dh, "$" .code START: mov ax, @data ;ax <-- data segment start address mov ds, ax ;ds <-- initialize data segment register mov dx, offset msg mov ah, 09h int 21h ; print message to screen mov ah,1 int 21h ; get character from screen push ax ; save on stack mov dx, offset pcrlf mov ah, 09h int 21h ; print CRLF ; start to print out the binary pop ax ; get character back mov cx,8 LP1: test al, 80h ; test upper bit jnz pone push ax ; save character mov ah,2 mov dl,30h ; get a '0' jmp skip pone: push ax mov ah,2 mov dl,31h ; get a '1' skip: int 21h pop ax ; get ax back shl al,1 ; shift left loop LP1 EXIT: mov ax, 4c00h ;ax <-- 4c DOS 21h program halt function int 21h ;DOS service interrupt END START