audit: combine two print mechanisms: smaller code

The first old way was to JSR and get the value from the stack, with
string directly following. The second old way was to put strings in
their own area, and explicitly load the address of each string. The
new way combines the two: put the strings in their own area, and JSR
to a three-byte prefix of each string that just JSR's to the print
routine. The print routine pulls the string address from the stack,
and pushes nothing back, so the final JSR returns to the code that
wanted to print.
This commit is contained in:
Zellyn Hunter 2016-12-15 22:20:54 -05:00
parent ad621d9f93
commit c65d7b9ee2
3 changed files with 14 additions and 12 deletions

View File

@ -29,18 +29,22 @@ main:
end: jmp *
print2
print
lda $C081
lda $C081
getch2 lda $FEED
pla
sta getch+1
pla
sta getch+2
- inc getch+1
bne getch
inc getch+2
getch lda $FEED ; FEED gets modified
beq +
jsr COUT
inc getch2+1
bne getch2
inc getch2+2
jmp getch2
jmp -
+ rts
!src "technote2.asm"
; !if * != STRINGS {

Binary file not shown.

View File

@ -2,14 +2,12 @@
;;; Copyright © 2016 Zellyn Hunter <zellyn@gmail.com>
!macro print {
lda #<LASTSTRING
sta getch2+1
lda #>LASTSTRING
sta getch2+2
jsr print2
jsr LASTSTRING
!set TEMP = *
* = LASTSTRING
jsr print
}
!macro printed {
!byte 0
!set LASTSTRING=*