printf.asm 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #include once <printstr.asm>
  2. #include once <stackf.asm>
  3. #include once <const.asm>
  4. ;
  5. __PRINTF: ; Prints a Fixed point Number stored in C ED LH
  6. PROC
  7. LOCAL RECLAIM2
  8. LOCAL STK_END
  9. STK_END EQU 5C65h
  10. ;- ld hl, (ATTR_T)
  11. lda z80_l ;- push hl ; Saves ATTR_T since BUG ROM changes it
  12. pha
  13. lda z80_h
  14. pha
  15. ;- ld hl, (STK_END)
  16. lda z80_l ;- push hl ; Stores STK_END
  17. pha
  18. lda z80_h
  19. pha
  20. jsr __FPSTACK_PUSH ;- call __FPSTACK_PUSH ; Push number into stack
  21. ;- rst 28h ; # Rom Calculator
  22. ;- defb 2Eh ; # STR$(x)
  23. ;- defb 38h ; # END CALC
  24. jsr __FPSTACK_POP ;- call __FPSTACK_POP ; Recovers string parameters to A ED CB
  25. pla ;- pop hl
  26. sta z80_h
  27. pla
  28. sta z80_l
  29. ;- ld (STK_END),hl ; Balance STK_END to avoid STR$ bug
  30. pla ;- pop hl
  31. sta z80_h
  32. pla
  33. sta z80_l
  34. ;- ld (ATTR_T),hl ; Restores ATTR_T
  35. lda z80_e ;- ex de,hl ; String position now in HL
  36. ldx z80_l
  37. stx z80_e
  38. sta z80_l
  39. lda z80_d
  40. ldx z80_h
  41. stx z80_d
  42. sta z80_h
  43. lda z80_c ;- push bc
  44. pha
  45. lda z80_b
  46. pha
  47. eor z80_a ;- xor a ; Avoid the str to be FREED from heap
  48. jsr __PRINT_STR ;- call __PRINT_STR
  49. pla ;- pop bc
  50. sta z80_b
  51. pla
  52. sta z80_c
  53. inc z80_c ;- inc bc
  54. bne *+4
  55. inc z80_b
  56. jmp RECLAIM2 ;- jp RECLAIM2 ; Frees TMP Memory
  57. ;- RECLAIM2 EQU 19E8h
  58. ;- ENDP