hex2ascii.asm 403 B

12345678910111213141516171819
  1. ;-----------------------------------------------
  2. ; HEX TO ASCII
  3. ;-----------------------------------------------
  4. ;I think, this was the smallest (only 10 words).
  5. ;input: R16 = 8 bit value 0 ... 255
  6. ;output: R18, R17, R16 = digits
  7. ;bytes: 20
  8. Hex2Ascii: LDI r18,-1+'0'
  9. _bcd1: INC r18
  10. SUBI r16,100
  11. BRCC _bcd1
  12. LDI r17,10+'0'
  13. _bcd2: DEC r17
  14. SUBI r16,-10
  15. BRCS _bcd2
  16. SBCI r16,-'0'
  17. RET