EttinOS/source/byte2hexstr.inc

33 lines
386 B
PHP

;Converts a byte in ah to a hex string at di.
byte2hexstr:
;Set a key for the hex digits
mov si, .key
;Set a counter for the two characters of the hex string
mov cx, 0x2
.loop:
;Read the byte
rol ax, 0x4
mov bx, ax
;Convert the byte to a hex digit
and bx, 0xf
mov bl, [si + bx]
;Store the hex digit
mov [di], bl
;Repeat
inc di
dec cx
jnz .loop
ret
.key:
db "0123456789abcdef"