printi8.asm 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include once <printnum.asm>
  2. #include once <div8.asm>
  3. ;
  4. __PRINTI8: ; Prints an 8 bits number in Accumulator (A)
  5. ; Converts 8 to 32 bits
  6. ora z80_a ;- or a
  7. ;- jp p, __PRINTU8
  8. pha ;- push af
  9. php
  10. jsr __PRINT_MINUS ;- call __PRINT_MINUS
  11. plp ;- pop af
  12. pha
  13. ;- neg
  14. __PRINTU8:
  15. ;- PROC
  16. ;- LOCAL __PRINTU_LOOP
  17. lda %0 ;- ld b,0 ; Counter
  18. sta z80_b
  19. __PRINTU_LOOP:
  20. ora z80_a ;- or a
  21. jeq __PRINTU_START ;- jp z, __PRINTU_START
  22. lda z80_c ;- push bc
  23. pha
  24. lda z80_b
  25. pha
  26. ;- ld h,10
  27. jsr __DIVU8_FAST ;- call __DIVU8_FAST ; Divides by 10. D'E'H'L' contains modulo (L' since < 10)
  28. pla ;- pop bc
  29. sta z80_b
  30. pla
  31. sta z80_c
  32. lda z80_l ;- ld a,l
  33. sta z80_a
  34. ;- or '0' ; Stores ASCII digit (must be print in reversed order)
  35. pha ;- push af
  36. php
  37. lda z80_h ;- ld a,h
  38. sta z80_a
  39. inc z80_b ;- inc b
  40. jmp __PRINTU_LOOP ;- jp __PRINTU_LOOP ; Uses JP in loops
  41. ;- ENDP