home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / program / compiler / nasm20b / nasm_src / lib / src / utoh.s65 < prev   
Text File  |  1993-01-19  |  785b  |  45 lines

  1.    .zext _string1
  2.    .zext _value
  3.    
  4. ; --------------------------------------------------------------
  5. ; convert unsigned word to hex ascii
  6. ; value in _VALUE
  7. ; return in _STRING1
  8. ; --------------------------------------------------------------
  9. utoh:
  10.    lda   _value+1
  11.    jsr   utob
  12.    ldy   #2
  13.    lda   _value
  14.    .byte $2C            ;; makes a BIT
  15.  
  16. ; --------------------------------------------------------------
  17. ; convert unsigned byte to hex ascii
  18. ; value in A
  19. ; return in _STRING1
  20. ; --------------------------------------------------------------
  21. utob
  22.    ldy   #0
  23. :utob:
  24.    pha
  25.    iny
  26.    jsr   :cnv
  27.    dey
  28.    pla
  29.    lsr   a
  30.    lsr   a
  31.    lsr   a
  32.    lsr   a
  33. :cnv
  34.    and   #$F
  35.    tax
  36.    clc
  37.    lda   _hextable,x
  38.    sta   (_string1),y
  39.    rts
  40.  
  41.  
  42. _hextable:
  43.    .byte "0123456789ABCDEF"
  44.  
  45.