A poorly written OS for the x86 arch. (WIP)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
eOS/bootloader/bios/convert.asm

42 lines
876 B

HEX_OUT: db "0x0000", ASCII_END
; SR to convert hex values into ASCII strings
; This SR is going to mess up some registers
; since it fills the register with the desired
; pointer toward the string.
4 years ago
hex_to_ascii:
mov cx, 0 ; incrementor
hexloop:
cmp cx, 4 ; check if we reached the end
je hexreturn ; if so just return our new ASCII string
mov ax, dx
; mask the hex value in ax so that we get the last "char"
and ax, 0x000f
; convert ax into ASCII (numeric)
add al, ASCII_OFFSET_NUM ; add 0x30
4 years ago
cmp al, 0x39 ; if al (char) > "9"
jle hexloop2
4 years ago
add al, 7 ; 7 distance from "A"
4 years ago
hexloop2:
; Write the char into the HEX_OUT string
4 years ago
mov bx, HEX_OUT + 5
sub bx, cx
4 years ago
mov [bx], al ; write the char into the string
ror dx, 4 ; "rotate" the string
inc cx ; increment and go onto next char
jmp hexloop
hexreturn:
mov bx, HEX_OUT
ret