Created
October 6, 2020 15:43
-
-
Save Fighter19/03f06d6e1219a65bd88ec8b3b4ed797a to your computer and use it in GitHub Desktop.
Prints 16-bit register to COM1
This file contains hidden or 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
.macro put_hex shift_by | |
sar $\shift_by, %ax | |
and $0xf, %ax | |
cmp $0x9, %ax | |
jg 1f | |
/* If smaller or equal to 9 add 0x30 ('1' to '9', else 0x37 (small 'a')*/ | |
add $0x30, %ax | |
jmp 2f | |
1: | |
add $0x37, %ax | |
2: | |
out %al,(%dx) | |
mov %cx, %ax | |
.endm | |
printHexShort: | |
mov $0x3f8, %dx | |
mov %ax, %cx | |
put_hex 12 | |
put_hex 8 | |
put_hex 4 | |
put_hex 0 /* Not optimal */ | |
ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment