mirror of
https://github.com/zellyn/a2audit.git
synced 2024-11-21 22:32:23 +00:00
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:
parent
ad621d9f93
commit
c65d7b9ee2
@ -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 {
|
||||
|
BIN
audit/audit.dsk
BIN
audit/audit.dsk
Binary file not shown.
@ -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=*
|
||||
|
Loading…
Reference in New Issue
Block a user