Guest User

[CC] [CHIPER] print.asm

a guest
Mar 29th, 2017
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. ; refresh screen
  2. ld I, $FFF
  3. ld (I), #1
  4. ; ---------------------
  5.  
  6. ; set screen text color to black
  7. ld I, $FFD
  8. ld (I), $F
  9. ; ---------------------
  10.  
  11. ; set screen X pos to 0
  12. ld I, $FFA
  13. ld (I), #0
  14. ; ---------------------
  15.  
  16. ld X, text ; set register X to memory location of the text
  17. call print ; call print
  18.  
  19. ; refresh screen
  20. ld I, $FFF
  21. ld (I), #1
  22. ; ---------------------
  23.  
  24. .loop jmp loop ; infinite loop
  25.  
  26. .print ; zero terminated print function
  27.  
  28. ld X, I ; load X value to I
  29. ld A, (I) ; load the char
  30. eql A, #0 ; check if its not 0
  31. jmp printEnd ; if its 0 goto END
  32.  
  33. ; put char on screen
  34. ld I, $FFE
  35. ld (I), A
  36. ; ---------------------
  37.  
  38. sub X, #1 ; move to the next char
  39.  
  40. ; update screen X pos
  41. ld I, $FFA
  42. ld A, (I)
  43. add A, #1
  44. ld (I), A
  45. ; ---------------------
  46.  
  47. jmp print ; loop until zero
  48.  
  49. .printEnd
  50.  
  51. ; fix the double chars at the end of the string
  52. ; simply replaces the end char with a space
  53. ld A, $20
  54. ld I, $FFE
  55. ld (I), A
  56.  
  57. ret ; get back from function
  58.  
  59. .text db "Hello, world!"
Advertisement
Add Comment
Please, Sign In to add comment