-
-
Save anonymous/8acab8cb8240c0bed0d4c7961f45511d to your computer and use it in GitHub Desktop.
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
Convert int to string | |
; Pass in value in BX | |
Console_Write_Int: | |
mov si, IntBuffer + 4 ; Get last digit of intbuffer | |
mov ax, bx ; Move BX into AX | |
GetDigit: | |
xor dx, dx ; Clear DX | |
mov cx, 10 ; Counter to 10 | |
div cx ; Divide by 10 | |
add dl, 48 ; Convert to ASCII (add 48 to remainder) | |
mov [si], dl ; Store converted number to si | |
dec si | |
cmp ax, 0 | |
jne GetDigit | |
inc si | |
call Console_Write_16 | |
ret | |
IntBuffer db ' ', 0 | |
; Convert value in BX as 4 digit hexadecimal number | |
; Pass in value in BX | |
Console_Write_Hex: | |
mov cx, 4 | |
HexLoop: | |
rol bx, 4 | |
mov si, bx | |
and si, 000Fh | |
mov al, byte [si + HexChars] | |
mov ah, 0Eh | |
int 10h | |
loop HexLoop | |
ret | |
HexChars db '0123456789ABCDEF' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment