From c65d7b9ee2bcf922d52a2de4b2fbc330857420d3 Mon Sep 17 00:00:00 2001 From: Zellyn Hunter Date: Thu, 15 Dec 2016 22:20:54 -0500 Subject: [PATCH] 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. --- audit/audit.asm | 18 +++++++++++------- audit/audit.dsk | Bin 143360 -> 143360 bytes audit/macros.asm | 8 +++----- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/audit/audit.asm b/audit/audit.asm index 93a662c..cd58ec5 100644 --- a/audit/audit.asm +++ b/audit/audit.asm @@ -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 { diff --git a/audit/audit.dsk b/audit/audit.dsk index 7138489090e852be1b1c404c677df1358424afc9..7ab72e6da5a2c7cb2f693b8379a3079633cfe5de 100644 GIT binary patch delta 1320 zcmZvaPi)&%9LMc=aYMyWvbHSHiM-QP+8)wXLlFnG6WXKzhpB1@XvBFbR77HSxFC8+ zHdH8Lo+2zEjSHq@2v-=TV}hMx{iwSL_7 zu}|G%BW#w%o%&l4`?ak6I;8iGhLN9iBc24&G0epmlZeCbY0>y#Qp?Ggpw4Vq35dfw zgDnB#pw2i}65@c)Jg^`nG53%jLU?+D_$SFd@Gx@m!{|ZCb#WB!(^GJY*TLVj$AWbMfOzy0<5C)EC|fEJdkES9#-2c>OZ$+xh-7Ecy!U%JnfHEY9?v zAHE=bQ!30C7SyJ_YFF26b!pu(WdARU8=U)}0t$e8 z+zasCEaeQ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644 --- a/audit/macros.asm +++ b/audit/macros.asm @@ -2,14 +2,12 @@ ;;; Copyright © 2016 Zellyn Hunter !macro print { - lda #LASTSTRING - sta getch2+2 - jsr print2 + jsr LASTSTRING !set TEMP = * * = LASTSTRING + jsr print } + !macro printed { !byte 0 !set LASTSTRING=*