Created
April 5, 2015 19:27
-
-
Save shemul/42499ec986b014b61be1 to your computer and use it in GitHub Desktop.
1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://www.dreamincode.net/forums/topic/365881-Convert-ASCII-To-Binary/ | |
org 100h | |
include 'emu8086.inc' | |
.model small | |
.stack | |
.data | |
MSG1 DB 'Enter a ASCII character : $' | |
MSG2 DB 'The ASCII code of the character : $' | |
size equ 2d | |
buffer db size dup ('x') | |
.code | |
MOV AX,@DATA | |
MOV DS,AX | |
entry: ; Do the character entry | |
LEA DX , MSG1 | |
MOV AH , 9 | |
INT 21H | |
call GET_STRING | |
putc 13 | |
putc 10 | |
LEA DX , MSG2 | |
MOV AH , 9 | |
INT 21H | |
mov ax, [di] | |
mov ah, 10000000b ; mask for a binary value test | |
mov cx, 8 ; definition of the 8 bits counter | |
write_bit: ; Routine of the binary value presentation | |
test al, ah ; verify if the AL interrupt didn't have been modified | |
jz write_0 ; if the bit test be 0, write it as 0 | |
putc '1' ; if not, write 1 | |
jmp next_bit ; get the next bit of the sequence | |
write_0: | |
putc '0' ; write zero | |
next_bit: | |
shr ah, 01h ; move one bit from the mask to the right | |
loop write_bit | |
exit: | |
hlt | |
DEFINE_GET_STRING | |
DEFINE_PRINT_STRING | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment