Question: Write a machine-language program to input two one-digit numbers, add them, and output the one-digit sum. Write it in a format suitable for the loader
Write a machine-language program to input two one-digit numbers, add them, and output the one-digit sum. Write it in a format suitable for the loader and execute it on the Pep/8 simulator.
My solution was: 49 00 60 49 00 61 D1 00 60 71 00 61 90 00 0F A0 00 30 F1 00 62 51 00 62 00 zz
Using the example of (23), I would get incorrect output. Searching for help, I found that changing 71 00 61 to 71 00 60, helped. Here's what I can't understand:
49 00 60: Input first character, store at mem[0060] 49 00 61: Input second character, store at mem[0061] D1 00 60: Load byte mem[0060] to register 0 (Accumulator) 71 00 6*: Here's my problem step. With mem[0060] store in the Accumulator, I think that the next step here is to add the two characters. Therefore, I would add the value from mem[0061]. This is incorrect for some reason. But if I add the value from mem[0060], which is the same value in the accumulator, the output is correct.
What am I missing?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
