39 lines
484 B
PHP
39 lines
484 B
PHP
;Converts a byte in ah to a hex string at di.
|
|
|
|
byte2hexstr:
|
|
|
|
;Store the initial registers in the stack
|
|
pusha
|
|
|
|
;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
|
|
|
|
;Load the initial registers from the stack
|
|
popa
|
|
|
|
ret
|
|
|
|
.key:
|
|
db "0123456789abcdef"
|