SWI osExit takes a status in A, and the shell keeps it. Fifty eight exits across twenty three programs now say deliberately whether they worked: 25 did what they were asked, 24 did not, 9 were asked wrongly. Compare is the exception and says so - one there means the files differ, which is a result rather than a failure, the way diff has always had it. IN A RATHER THAN Q, which is not a departure from the rule that a service answers in Q. This one takes an ARGUMENT, the way osPrintNumber takes A and B, and it never returns to answer anything. A is free precisely because a return would have put it back - and Q is the ALU's output, so a small number costs four instructions there against one in A. The shell does not print it. A program that failed has already said so in words and a number beside that is noise, so osLastStatus hands it back and Status is the program that shows it. That indirection is the point: the number exists for the thing that cannot read words. MARKING THE EXITS FOUND A DEFECT ON THE FIRST RUN. Type and More printed why they had failed and then fell through into the success exit, reporting that all was well. Nobody had noticed, because while the only reader was a person, the person could see both the complaint and the claim. Two smaller things. Snake sets the console to line mode and then exits with zero, and the linter flagged the second RSTA as redundant - an exit status and a console mode, equal by accident, which is the class that must never be collapsed. And the README still taught answering by writing into the frame, three months of habit that SRET replaced yesterday; that section is gone and the one describing SRET stands in its place.
86 lines
1.3 KiB
NASM
86 lines
1.3 KiB
NASM
; A Fibonacci number generating program that uses two bytes to store the value.
|
|
|
|
#Include services.asm
|
|
|
|
#Program
|
|
|
|
#Base 0x4000
|
|
|
|
start:
|
|
; Swap ValueB and ValueA.
|
|
; First, store ValueA on the stack.
|
|
SETD ValueA
|
|
LDA
|
|
PSHA
|
|
INCD
|
|
LDA
|
|
PSHA
|
|
; Now copy ValueB into AB.
|
|
SETD ValueB
|
|
LDA ; High byte
|
|
INCD
|
|
LDB ; Low byte
|
|
; Now save it back to ValueA
|
|
SETD ValueA
|
|
STA ; High byte
|
|
INCD
|
|
STB ; Low byte.
|
|
; Now retrieve value A from the stack and store it in ValueB.
|
|
POPB
|
|
POPA
|
|
SETD ValueB
|
|
STA
|
|
INCD
|
|
STB
|
|
; Print ValueA.
|
|
SETD ValueA
|
|
LDA
|
|
CALL printByteHex
|
|
INCD
|
|
LDA
|
|
CALL printByteHex
|
|
CALL blankSpace
|
|
; Now add ValueA and ValueB, and store the result in ValueA.
|
|
; Add the low bytes of ValueA and ValueB
|
|
SETD ValueB
|
|
INCD
|
|
LDA
|
|
SETD ValueA
|
|
INCD
|
|
LDB
|
|
CCF
|
|
ADD
|
|
; Store the result in ValueA.
|
|
STQ
|
|
; Now add the high bytes of ValueA and ValueB.
|
|
DECD
|
|
LDB
|
|
SETD ValueB
|
|
LDA
|
|
ADD
|
|
; If this addition overflows, we're done.
|
|
BRC end
|
|
; Otherwise, store the result in ValueA.
|
|
SETD ValueA
|
|
STQ
|
|
; And branch back to the beginning of the loop.
|
|
BRI start
|
|
end:
|
|
CALL lineFeed
|
|
RSTA
|
|
SWI osExit
|
|
|
|
#Data
|
|
|
|
#Base 0x2000
|
|
|
|
ValueA:
|
|
; Low byte, high byte.
|
|
0x00 0x01
|
|
|
|
ValueB:
|
|
; Low byte, high byte.
|
|
0x00 0x00
|
|
|
|
#Include print.asm
|