From this code, what does this particular part mean?
Two, Dec 2
X, Dec 10
Y, Dec 10
It declares 3 variables Two
, X
, Y
and set their initial values to 2, 10, 10 respectively. The Dec
means that the numbers specified are in Decimal (base 10). These variables can be used anywhere in the program.
And how do I input a new value to Y?
If you want to change the initial value of Y to 50, simply change the number after Dec
on this line:
Y, Dec 50
If you want to input the value of Y during execution of program, you must use the Input
and Store
commands at the start of the program:
ORG 200
Input /take user input
Store Y /store in Y
/ rest of program, including declarations, are unchanged
/ ...
Also, what does first load instruction mean?
Load X
means load the value stored in variable X to accumulator. If X contains 10, the value 10 is loaded to accumulator.
For future reference, use the official MARIE instruction set:
Mnemonic | Hex | Description
-----------+-----+-----------------------------------------------
Add X | 3 | Add the contents of address X to AC
AddI X | B | Add indirect: Use the value at X as the actual
| | address of the data operand to add to AC
Clear | A | Put all zeros in AC
Input | 5 | Input a value from the keyboard into AC
Halt | 7 | Terminate program
Jump X | 9 | Load the value of X into PC
JumpI X | C | Use the value at X as the address to jump to
JnS X | 0 | Store the PC at address X and jump to X+1
Load X | 1 | Load contents of address X into AC
LoadI X | D | Load indirect: Use the value at X as the
| | address of the value to load.
Output | 6 | Output the value in AC to the display
Skipcond X | 8 | Skip next instruction on condition
| | (See note below.)
Store X | 2 | Store the contents of AC at address X
StoreI X | E | Store indirect: Use X the value at X as the
| | address of where to store the value.
Subt X | 4 | Subtract the contents of address X from AC
-----------------------------------------------------------------
Note regarding use of SKIPCOND:
The two address bits closest to the opcode field, bits 10 and
11 specify the condition to be tested. If the two address bits
are 00, this translates to "skip if the AC is negative". If the
two address bits are 01, this translates to "skip if the AC is
equal to 0". Finally, if the two address bits are 10 (or 2),
this translates to "skip if the AC is greater than 0".
Example: the instruction Skipcond 800 will skip the
instruction that follows if the AC is
greater than 0.
-----------------------------------------------------------------