Impresión de valores hexadecimales en ensamblaje x86
Necesito hacer una rutina que convierta una dirección de memoria en una cadena de bytes. Esa cadena sería entonces la entrada para una función que imprime cadenas terminadas en nulo (que ya pude hacer). Por ejemplo, si tengo una dirección 0x1bf9 necesito imprimir el texto "1bf9" en la pantalla. El libro aún no ha entrado en el modo de 32 bits, pero sugirió que también lo necesitaríamos para eso. Esto es lo que tengo hasta ahora:
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