|
This is basically the same as the last problem
except that this time we want to keep track of which square we're up to.
As before, let's store the square number in S
and the bit we add on in A - it will have to be increased by TWO each time.
|
INP N LDA #1 STA C STA S LDA #3 STA A LOOP: LDA C SUB N BEQ END INC C LDA S ADD A STA S INC A INC A JMP LOOP END: OUT S HLT |
INP N
LDA #1
STA C
STA S
LDA #3
STA A
LOOP: LDA C
SUB N
BEQ END
INC C
LDA S
ADD A
STA S
INC A
INC A
JMP LOOP
END: OUT S
HLT