Drukowanie wartości szesnastkowych w zespole x86

Muszę wykonać procedurę, która przekształci adres pamięci w ciąg bajtów. Ten ciąg znaków byłby wtedy wejściem dla funkcji, która drukuje łańcuchy zakończone znakiem null (co już mogłem zrobić). Na przykład, jeśli mam adres 0x1bf9, muszę wydrukować tekst „1bf9” na ekranie. Książka nie przeszła jeszcze do trybu 32-bitowego, ale sugerowała, że ​​do tego będziemy jej potrzebować. Oto, co mam do tej pory:

TABLE:
db "0123456789ABCDEF", 0

STRING:
db 0

hex_to_char:
    lea bx, TABLE
    mov ax, dx

    mov ah, al ;make al and ah equal so we can isolate each half of the byte
    shr ah, 4 ;ah now has the high nibble
    and al, 0x0F ;al now has the low nibble
    xlat ;lookup al's contents in our table
    xchg ah, al ;flip around the bytes so now we can get the higher nibble 
    xlat ;look up what we just flipped
    inc STRING
    mov [STRING], ah ;append the new character to a string of bytes
    inc STRING
    mov [STRING], al ;append the new character to the string of bytes

    ret

questionAnswers(2)

yourAnswerToTheQuestion