Two mechanical fixes SplitLint found: MVQA, and RSTA for zero
Twenty four places moved Q into A or B by pushing it and popping it back. That is four bus cycles and two bytes to do what MVQA does in one of each, and several of them are inside loops - Life, the calculator, int8. Nineteen more loaded zero with INIA 0d0 where RSTA says the same thing in one byte. Both are equivalent at the CPU rather than by assertion: RSTA and INIA both leave Status alone, and PSHQ followed by POPA nets to A = Q with the Stack Pointer where it started. The one difference is that the pair leaves a copy of Q in memory just below the Stack Pointer and MVQA does not, which nothing here reads. Five recorded outputs moved and every one of them says the change worked: - 16x16Life fits five more generations into the same cycle budget, the first 457 lines identical, because the loop got cheaper. - Life.sbx is 1409 bytes rather than 1411, in three tests that list it. - Edit.sbx is 1995 rather than 1996. That last one broke a check I added this morning, and the hole is worth recording: the CosmOS README's claim about Edit's size did not have the word "Edit" on the same line as the number, because the subject was in the sentence before, so the check that measures quoted sizes skipped it silently. The sentence now names what it is talking about, which makes it both checkable and clearer, and the check fails on a wrong number there. Comments on either half of a replaced pair are carried onto the instruction that replaces them, so nothing anybody wrote was lost.
This commit is contained in:
@@ -18,8 +18,7 @@ repl:
|
||||
CALL printString
|
||||
|
||||
CALL readNonSpace
|
||||
PSHQ
|
||||
POPA
|
||||
MVQA
|
||||
|
||||
; Q, q, or end-of-file exits.
|
||||
INIB 0xFF
|
||||
@@ -39,14 +38,12 @@ repl:
|
||||
BRQ inputError
|
||||
|
||||
CALL readNonSpace
|
||||
PSHQ
|
||||
POPA
|
||||
MVQA
|
||||
SETD Operator
|
||||
STA
|
||||
|
||||
CALL readNonSpace
|
||||
PSHQ
|
||||
POPA
|
||||
MVQA
|
||||
CALL readHexByteFirst
|
||||
SETD RightOperand
|
||||
STQ
|
||||
@@ -98,7 +95,7 @@ readNonSpaceLoop:
|
||||
INIB 0x0D
|
||||
XOR
|
||||
BRQ readNonSpaceLoop
|
||||
INIB 0x00
|
||||
RSTB
|
||||
CCF
|
||||
ADD
|
||||
RET
|
||||
@@ -108,12 +105,11 @@ readNonSpaceLoop:
|
||||
readHexByteFirst:
|
||||
CALL clearParseStatus
|
||||
CALL hexNibble
|
||||
PSHQ
|
||||
POPA
|
||||
MVQA
|
||||
INIB 0xFF
|
||||
XOR
|
||||
BRQ invalidByte
|
||||
INIB 0x00
|
||||
RSTB
|
||||
SHL
|
||||
SHL
|
||||
SHL
|
||||
@@ -121,11 +117,9 @@ readHexByteFirst:
|
||||
PSHA
|
||||
|
||||
CALL readNonSpace
|
||||
PSHQ
|
||||
POPA
|
||||
MVQA
|
||||
CALL hexNibble
|
||||
PSHQ
|
||||
POPA
|
||||
MVQA
|
||||
INIB 0xFF
|
||||
XOR
|
||||
BRQ invalidLowNibble
|
||||
@@ -142,7 +136,7 @@ invalidByte:
|
||||
STA
|
||||
POPD
|
||||
INIA 0xFF
|
||||
INIB 0x00
|
||||
RSTB
|
||||
CCF
|
||||
ADD
|
||||
RET
|
||||
@@ -157,8 +151,7 @@ hexNibble:
|
||||
CCF
|
||||
SUB
|
||||
BRC tryUpperHex
|
||||
PSHQ
|
||||
POPA
|
||||
MVQA
|
||||
INIB 0d10
|
||||
CCF
|
||||
SUB
|
||||
@@ -171,8 +164,7 @@ tryUpperHex:
|
||||
CCF
|
||||
SUB
|
||||
BRC tryLowerHex
|
||||
PSHQ
|
||||
POPA
|
||||
MVQA
|
||||
INIB 0d06
|
||||
CCF
|
||||
SUB
|
||||
@@ -185,8 +177,7 @@ tryLowerHex:
|
||||
CCF
|
||||
SUB
|
||||
BRC badNibble
|
||||
PSHQ
|
||||
POPA
|
||||
MVQA
|
||||
INIB 0d06
|
||||
CCF
|
||||
SUB
|
||||
@@ -195,14 +186,14 @@ tryLowerHex:
|
||||
badNibble:
|
||||
POPA
|
||||
INIA 0xFF
|
||||
INIB 0x00
|
||||
RSTB
|
||||
CCF
|
||||
ADD
|
||||
RET
|
||||
|
||||
decimalNibble:
|
||||
POPB
|
||||
INIB 0x00
|
||||
RSTB
|
||||
CCF
|
||||
ADD
|
||||
RET
|
||||
@@ -223,8 +214,7 @@ lowerNibble:
|
||||
|
||||
; Return Q=0 if Q was 0xFF, otherwise return a nonzero value.
|
||||
resultIsInvalid:
|
||||
PSHQ
|
||||
POPA
|
||||
MVQA
|
||||
INIB 0xFF
|
||||
XOR
|
||||
RET
|
||||
@@ -288,7 +278,7 @@ evaluate:
|
||||
INIA 0x01
|
||||
STA
|
||||
RSTA
|
||||
INIB 0x00
|
||||
RSTB
|
||||
CCF
|
||||
ADD
|
||||
RET
|
||||
@@ -360,7 +350,7 @@ multiplyLoop:
|
||||
multiplyDone:
|
||||
SETD Product
|
||||
LDA
|
||||
INIB 0x00
|
||||
RSTB
|
||||
CCF
|
||||
ADD
|
||||
RET
|
||||
|
||||
Reference in New Issue
Block a user