2021-05-30 16:12:19 +00:00
|
|
|
;Converts a byte in ah to a hex string at di.
|
|
|
|
|
2021-06-06 16:56:54 +00:00
|
|
|
byte2hex:
|
2021-05-30 16:12:19 +00:00
|
|
|
|
2021-06-06 08:18:15 +00:00
|
|
|
;Store the initial registers in the stack
|
|
|
|
pusha
|
|
|
|
|
2021-05-30 16:12:19 +00:00
|
|
|
;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
|
|
|
|
|
2021-06-06 08:18:15 +00:00
|
|
|
;Load the initial registers from the stack
|
|
|
|
popa
|
|
|
|
|
2021-05-30 16:12:19 +00:00
|
|
|
ret
|
|
|
|
|
|
|
|
.key:
|
|
|
|
db "0123456789abcdef"
|