; ; - Input character a from the keyboard ; - Type " = " after the character entered (on the same line) ; - Follow this with an 8-Bit Binary representation of the character ; - Go to a new line and loop back for another character ; ; - Exit back to DOS when the user types an Escape ; ; Sample Session: ; ; C:> BinTyp ; A = 01000001 ; B = 01000010 ; 0 = 00110000 ; ; C:> ; Data Segment Equal_A DB " = $" New_Line DB 0DH, 0AH, "$" Data Ends Working_Storage Segment Stack DW 100H DUP(?) Working_Storage Ends Code Segment Assume CS:Code,DS:Data,SS:Working_Storage Start: Mov AX,Data Mov DS,AX M_Loop: Mov AH, 1H ; Have DOS get a Character Int 21H ; from the keyboard Cmp AL, 27D ; See if they entered an JE Done ; YES - All done.... ; NO - Type it as Binary Mov BL, AL ; Save AL in BL Mov DX, Offset Equal_A ; Have DOS Mov AH, 9 ; type " = " Int 21H ; screen Mov BH, 8 ; Loop for 8 bytes B_Loop: SHL BL, 1 ; Shift AL byte left 1 bit ; (Left most bit goes to Carry Flag) JNC A_Zero ; No Carry, go type Zero Mov DL, "1" ; Move "1" into position Jmp No_Zero ; Hop over the Zero thing... A_Zero: Mov DL, "0" ; Move "0" into position No_Zero: Mov AH, 2 ; Output Char to Screen function Int 21H ; Now have DOS type it... Sub BH, 1 ; Decrement bit counter JA B_Loop ; Go get next bit (if any left) ; Else Mov DX, Offset New_Line ; Have DOS place cursor at beginning Mov AH, 9 ; of next line on the Int 21H ; screen Jmp M_Loop ; Go get another character... ;Return to DOS Done: Mov AX,4C00H Int 21H Code Ends End Start