write.s 615 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. .define Mwrite
  2. .sect .text
  3. .sect .rom
  4. .sect .data
  5. .sect .bss
  6. .sect .text
  7. ! This subroutine performs the monitor call write.
  8. ! Writing is always done to standardoutput.
  9. ! A zero is returned on exit.
  10. ! The subroutine WRCH is a special routine of the BBC
  11. ! microcomputer.
  12. Mwrite:
  13. jsr Pop ! get fildes
  14. jsr Pop ! get address of characterbuffer
  15. stx ADDR ! bufferaddress (lowbyte)
  16. sta ADDR+1 ! bufferaddress (highbyte)
  17. jsr Pop ! number of characters to be writen.
  18. ldy #0
  19. 1: lda (ADDR),y
  20. cmp #10
  21. bne 2f
  22. pha
  23. lda #13
  24. jsr WRCH
  25. pla
  26. 2: jsr WRCH
  27. iny
  28. dex
  29. bne 1b
  30. tya
  31. tax
  32. lda #0
  33. jsr Push
  34. tax
  35. rts