//---------------------------------------------------------------- // eax2hex.s // // This assembly language procedure converts the value found // in register EAX into its representation as a digit-string // of hexadecimal numerals that starts at the memory-address // found in the EDI register. The contents of cpu registers // are preserved across calls to this this procedure. // // programmer: ALLAN CRUSE // written on: 08 FEB 2005 //---------------------------------------------------------------- .data hexlist: .ascii "0123456789ABCDEF" # digit look-up table .text eax2hex: pushal # preserve registers leal hexlist, %ebx # setup for 'xlat' movl %eax, %edx # copy argument to EDX movl $8, %ecx # generate 8 numerals nxnyb: roll $4, %edx # hi-nybble into DL movb %dl, %al # copy nybble to AL andb $0xF, %al # isolate the nybble xlat # lookup its numeral movb %al, (%edi) incl %edi loop nxnyb popal # restore registers ret # go back to caller .global eax2hex # public entry-point .end # assembly ends here