diff --git a/Programs/CosmOS/Apps/Fib-8.asm b/Programs/CosmOS/Apps/Fib-8.asm index 2377d05..76afb10 100644 --- a/Programs/CosmOS/Apps/Fib-8.asm +++ b/Programs/CosmOS/Apps/Fib-8.asm @@ -8,7 +8,7 @@ start: ; Load our initial values into A and B. - INIA 0x00 + RSTA CALL printByteDecimal CALL blankSpace ; Move the value into B. @@ -25,8 +25,7 @@ start: PSHA POPB ; Copy Q into A - PSHQ - POPA + MVQA ; Print A. CALL printByteDecimal CALL blankSpace diff --git a/Programs/CosmOS/Assembler/classify.asm b/Programs/CosmOS/Assembler/classify.asm index 1a23eb1..0d641bd 100644 --- a/Programs/CosmOS/Assembler/classify.asm +++ b/Programs/CosmOS/Assembler/classify.asm @@ -33,7 +33,7 @@ clsToken: INIB 0x23 ; '#' XOR BNQ clsTryInstruction - INIA 0d0 + RSTA SETD.0 ClsType STA.0 BRI clsYes diff --git a/Programs/CosmOS/README.md b/Programs/CosmOS/README.md index 20f6149..a942d5f 100644 --- a/Programs/CosmOS/README.md +++ b/Programs/CosmOS/README.md @@ -462,7 +462,7 @@ Typed in as bytes, checked by disassembling it back, and run. It ends with `SWI `Edit` is the first program on this machine that makes a file a person typed - every byte on every disk before it was put there by the host tool. It is line oriented in the manner of `ed`: `l` lists, `a` adds at the end, `i` and `c` and `d` take a line number, `w` writes and `q` stops. -It includes nothing but `services.asm` and `text.asm`: the filesystem and the console are the system's, asked for rather than carried. That is what took it from 4,941 bytes to 1,996 without a line of its own logic changing - and the way that was checked is worth knowing, because the recorded output of the `cosmosEdit` test did not move by a single byte across the rewrite. +It includes nothing but `services.asm` and `text.asm`: the filesystem and the console are the system's, asked for rather than carried. That is what brought `Edit` down from 4,941 bytes to 1,995 bytes without a line of its own logic changing - and the way that was checked is worth knowing, because the recorded output of the `cosmosEdit` test did not move by a single byte across the rewrite. It keeps the document as a **linked list of lines** rather than one buffer with newlines in it. Each line says where the next one is, how long it is, and then its bytes. Inserting is two pointers changed and nothing moved; with a flat buffer it would mean shifting every byte after the edit, on a machine whose only block move is a device asked politely. The price is that deleted lines are not reused, so a heavy session uses more room than the document needs and writing it out is what tidies up. diff --git a/Programs/CosmOS/Source/text.asm b/Programs/CosmOS/Source/text.asm index 5c77767..7fdda6f 100644 --- a/Programs/CosmOS/Source/text.asm +++ b/Programs/CosmOS/Source/text.asm @@ -94,8 +94,7 @@ textHexWord: textHexLoop: LDA.0 CALL textHexDigit - PSHQ - POPA + MVQA INIB 0xFF CCF SUB diff --git a/Programs/Examples/Fibonacci/8bitFibonacci.asm b/Programs/Examples/Fibonacci/8bitFibonacci.asm index 3f6571b..e85ed0e 100644 --- a/Programs/Examples/Fibonacci/8bitFibonacci.asm +++ b/Programs/Examples/Fibonacci/8bitFibonacci.asm @@ -5,7 +5,7 @@ #Program start: ; Load our initial values into A and B. - INIA 0x00 + RSTA CALL printByteDecimal CALL blankSpace ; Move the value into B. @@ -22,8 +22,7 @@ start: PSHA POPB ; Copy Q into A - PSHQ - POPA + MVQA ; Print A. CALL printByteDecimal CALL blankSpace diff --git a/Programs/Examples/gameOfLife/16x16Life.asm b/Programs/Examples/gameOfLife/16x16Life.asm index 2ad4429..f3e9003 100644 --- a/Programs/Examples/gameOfLife/16x16Life.asm +++ b/Programs/Examples/gameOfLife/16x16Life.asm @@ -193,50 +193,43 @@ countNeighbors: LDB CCF ADD - PSHQ - POPA + MVQA DPUP 0d02 LDB CCF ADD - PSHQ - POPA + MVQA DPUP 0d02 LDB CCF ADD - PSHQ - POPA + MVQA DPUP 0d32 LDB CCF ADD - PSHQ - POPA + MVQA DPUP 0d04 LDB CCF ADD - PSHQ - POPA + MVQA DPUP 0d32 LDB CCF ADD - PSHQ - POPA + MVQA DPUP 0d02 LDB CCF ADD - PSHQ - POPA + MVQA DPUP 0d02 LDB diff --git a/Programs/Examples/inputTest.asm b/Programs/Examples/inputTest.asm index 2e1bc5e..0695680 100644 --- a/Programs/Examples/inputTest.asm +++ b/Programs/Examples/inputTest.asm @@ -20,7 +20,7 @@ start: INCD ; Increment to the next spot in the buffer. BRI inputLoop ; Loop again to grab more string. inputEnd: - INIA 0x00 ; Set A to 0. + RSTA ; Set A to 0. STA ; Store it in the buffer. SETD Buffer ; Set the Data Pointer to the start of the buffer again. CALL printString ; Print it out. diff --git a/Programs/Examples/replCalculator.asm b/Programs/Examples/replCalculator.asm index dbc4e71..68e846e 100644 --- a/Programs/Examples/replCalculator.asm +++ b/Programs/Examples/replCalculator.asm @@ -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 diff --git a/Programs/Libraries/int8.asm b/Programs/Libraries/int8.asm index e84125d..9d781c7 100644 --- a/Programs/Libraries/int8.asm +++ b/Programs/Libraries/int8.asm @@ -25,8 +25,7 @@ int8mult: DECA ; Subtract one from the multiplier. BRA int8multDone ; If the multiplier becomes zero, we're done. PSHA ; Push the multiplier back to the stack. - PSHQ ; Push the running total to the stack. - POPA ; Pop the running total into A. + MVQA ; Push the running total to the stack. Pop the running total into A. BRI int8multLoop return0: RSTA @@ -58,8 +57,7 @@ int8div: POPA ; Pop the quotient counter from the stack. INCA ; Increment it. PSHA ; Push it back onto the stack. - PSHQ ; Push the running total onto the stack. - POPA ; Pop the runing total into A. + MVQA ; Push the running total onto the stack. Pop the runing total into A. BRI int8divLoop ; Branch back to the loop. int8divDone: CCF ; Clear the Carry Flag. @@ -76,13 +74,11 @@ int8mod: int8modLoop: SUB ; Subtract B from A. BRC int8modDone - PSHQ - POPA + MVQA BRI int8modLoop int8modDone: ; Add the divisor to Q to get the remainder. CCF - PSHQ - POPA + MVQA ADD RET diff --git a/Programs/Libraries/print.asm b/Programs/Libraries/print.asm index 47587b3..2eb912f 100644 --- a/Programs/Libraries/print.asm +++ b/Programs/Libraries/print.asm @@ -97,10 +97,10 @@ printByteDecimal: ; Expects A to contain the byte you want to print as a hexadecimal value. printByteHex: - INIB 0x00 ; Set B to 0. + RSTB ; Set B to 0. SHR SHR SHR SHR ; Shift Right four times to move the high nybble into the lower half of A. CALL printHexDigit ; Print the nybble. - INIA 0x00 ; Set A to 0. + RSTA ; Set A to 0. SHL SHL SHL SHL ; Shift left four times to move the low nybble back into the lower half of A. CALL printHexDigit ; Print the nybble. RET ; Return to the caller. diff --git a/Programs/testPrograms/inputTest.asm b/Programs/testPrograms/inputTest.asm index 2e1bc5e..0695680 100644 --- a/Programs/testPrograms/inputTest.asm +++ b/Programs/testPrograms/inputTest.asm @@ -20,7 +20,7 @@ start: INCD ; Increment to the next spot in the buffer. BRI inputLoop ; Loop again to grab more string. inputEnd: - INIA 0x00 ; Set A to 0. + RSTA ; Set A to 0. STA ; Store it in the buffer. SETD Buffer ; Set the Data Pointer to the start of the buffer again. CALL printString ; Print it out. diff --git a/Programs/testPrograms/printTest.asm b/Programs/testPrograms/printTest.asm index dff6f94..34c8b17 100644 --- a/Programs/testPrograms/printTest.asm +++ b/Programs/testPrograms/printTest.asm @@ -8,8 +8,8 @@ #Program clearRegisters: - INIA 0x00; - INIB 0x00; + RSTA + RSTB ADD RET diff --git a/Programs/testPrograms/rawCallAndOffsets.asm b/Programs/testPrograms/rawCallAndOffsets.asm index c880296..61fc909 100644 --- a/Programs/testPrograms/rawCallAndOffsets.asm +++ b/Programs/testPrograms/rawCallAndOffsets.asm @@ -36,12 +36,12 @@ start: ; ---- Offsetting by a whole sixteen bit value ---- SETD.1 Text - INIA 0x00 + RSTA INIB 0d13 DPUW.1 LDA.1 OUTA 0x00 - INIA 0x00 + RSTA INIB 0d13 DPDW.1 LDA.1 diff --git a/Programs/testPrograms/registryTest.asm b/Programs/testPrograms/registryTest.asm index f7b5eda..fe112cd 100644 --- a/Programs/testPrograms/registryTest.asm +++ b/Programs/testPrograms/registryTest.asm @@ -21,7 +21,7 @@ #Program start: - INIA 0x00 + RSTA CALL reportPort INIA 0x10 CALL reportPort diff --git a/Tests/expected/16x16Life.out b/Tests/expected/16x16Life.out index 7e11637..b9bc7e1 100644 --- a/Tests/expected/16x16Life.out +++ b/Tests/expected/16x16Life.out @@ -457,5 +457,10 @@ # ### - Execution stopped. (cycle limit reached) + + + + + +Execution stopped. (cycle limit reached) [exit 0] diff --git a/Tests/expected/cosmosMonitor.out b/Tests/expected/cosmosMonitor.out index e870c94..83fb026 100644 --- a/Tests/expected/cosmosMonitor.out +++ b/Tests/expected/cosmosMonitor.out @@ -62,7 +62,7 @@ finished finished * > greet.sbx 210 hello.sbx 52 -Life.sbx 1411 +Life.sbx 1409 Snake.sbx 2175 Keys.sbx 663 Say.sbx 155 diff --git a/Tests/expected/cosmosRun.out b/Tests/expected/cosmosRun.out index 8fbbfd9..c471318 100644 --- a/Tests/expected/cosmosRun.out +++ b/Tests/expected/cosmosRun.out @@ -2,7 +2,7 @@ CosmOS > nothing is loaded > greet.sbx 210 hello.sbx 52 -Life.sbx 1411 +Life.sbx 1409 Snake.sbx 2175 Keys.sbx 663 Say.sbx 155 diff --git a/Tests/expected/cosmosSlowDisk.out b/Tests/expected/cosmosSlowDisk.out index fd0fe38..153bdcc 100644 --- a/Tests/expected/cosmosSlowDisk.out +++ b/Tests/expected/cosmosSlowDisk.out @@ -1,7 +1,7 @@ CosmOS > greet.sbx 210 hello.sbx 52 -Life.sbx 1411 +Life.sbx 1409 Snake.sbx 2175 Keys.sbx 663 Say.sbx 155 diff --git a/Tests/expected/cosmosTreeWrite.out b/Tests/expected/cosmosTreeWrite.out index 43c42ef..561e2a3 100644 --- a/Tests/expected/cosmosTreeWrite.out +++ b/Tests/expected/cosmosTreeWrite.out @@ -1,13 +1,13 @@ CosmOS > Folder