From 0bd18d930c2bc88eb4a4b31d19772c74fc4af06f Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Mon, 22 Feb 2016 19:00:53 -0500 Subject: save 12 more bytes, 7368 free, document the hell out of console.s --- console.s | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'console.s') diff --git a/console.s b/console.s index 7837ce1..1930303 100644 --- a/console.s +++ b/console.s @@ -138,7 +138,32 @@ _rvs_off: ; ...or 5 bytes each. we have 5 of them, so 25 bytes. using fall-thru ; and the BIT trick, they condense down to 17 bytes. ; if you're not familiar with the "BIT trick" to skip a 2-byte instruction, - ; the stuff below looks like gibberish, sorry. + ; the stuff below looks like gibberish... here's a mini-tutorial: + + ;store1: + ; lda #1 + ; .byte $2c ; this is the opcode for BIT absolute + ;store2: + ; lda #2 + ; sta $0600 + ; rts + + ; if entered via "jsr store1", the above code fragment executes these + ; instructions: + ; lda #1 + ; bit $02A9 ; $A9 is the LDA immediate opcode, 02 is the #2 + ; sta $0600 + ; rts + + ; if entered via "jsr store2", it's + ; lda #2 + ; sta $0600 + ; rts + + ; the "bit $02a9' doesn't affect any registers other than the flags, + ; and the "sta $0600 : rts" part doesn't depend on any of the flags, + ; so the BIT is effectively a no-op that "masks" the 2-byte LDA #2 + ; instruction "hidden" as its operand. ; ", Taipan? " ; using fall-thru here saves 3 bytes (normally the last instruction -- cgit v1.2.3