Skip to content

Instantly share code, notes, and snippets.

Created October 26, 2014 19:02
Show Gist options
  • Save anonymous/06d14073d6d5afb7be76 to your computer and use it in GitHub Desktop.
Save anonymous/06d14073d6d5afb7be76 to your computer and use it in GitHub Desktop.
BR Main
choice: .block 2
num: .block 2
ans: .block 2
msg: .ascii "A - ADD \x00"
msg2: .ascii "\nS - SUB \x00"
msg3: .ascii "\nN - NEG \x00"
msg4: .ascii "\nQ - Quit \x00"
ansmsg: .ascii "Answer = \x00"
inputmsg:.ascii "\nInput Option: \x00"
inputnum:.ascii "Input number: \x00"
Main: LDA 0,i
STA ans,d
STRO msg,d
STRO msg2,d
STRO msg3,d
STRO msg4,d
do: STRO inputmsg,d
CHARI choice,d
LDBYTEA choice,d
CPA 'A',i
BRNE elseif1
STRO inputnum,d
DECI num,d
LDA ans,d
ADDA num,d
STA ans,d
STRO ansmsg,d
DECO ans,d
BR do
elseif1: CPA 'S',i
BRNE elseif2
STRO inputnum,d
DECI num,d
LDA ans,d
SUBA num,d
STA ans,d
STRO ansmsg,d
DECO ans,d
BR do
elseif2: CPA 'N',i
BRNE while
LDA ans,d
NEGA
STA ans,d
STRO ansmsg,d
DECO ans,d
BR do
while: CPA 'Q',i
STOP
.end
@cheery
Copy link

cheery commented Nov 1, 2014

Interesting. Downloaded the simulator to try this and traced through the code. You should btw. do that too if you haven't done.

It took me some serious analysis to exclude away possible choices. I didn't have a manual so I did tests to verify the CHARI isn't affected by Accumulator or any of the status flags.

Figured out the CHARI only blocks when run after DECI. If I press N + enter, CHARI runs after CHARI, the second time will happily seem to go all the way down to QUIT.

Then I proceed to put CHARI -instructions one after another. When I keep typing characters pressing enter between them, every another CHARI doesn't wait for input. Next I made a program that prints out what CHARI received as a number.

Then I figured out what was the problem and fixed the program.

Later found the manual too..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment