# Computing - Little Man Computer

> Source: https://ollybritton.com/notes/a-level/computing/topics/lmc/ · Updated: 2020-09-24 · Tags: computing, school, safe-to-post-online

### Input and storing
##### What does `INP` mean in LMC??
Input.
^inp-mnemonic

##### What does the `INP` instruction do in LMC??
Allow the user to input data.
^inp-behaviour

##### Where is the input from `INP` stored in LMC??
In the accumulator.
^inp-stores-in-accumulator

##### What does `STA` mean in LMC??
Store address.
^sta-mnemonic

### Instruction format
##### What is the instruction register for instruction `901` in LMC??
`9`.
^opcode-of-901

##### What is the address register for instruction `901` in LMC??
`01`.
^operand-of-901

### Store
##### What does `STA` do in LMC??
Store the value in the accumulator at the given address.
^sta-behaviour

##### What is the operand for `STA`??
The address.
^sta-operand

### Arithmetic instructions
##### What does `ADD` mean in LMC??
Add.
^add-mnemonic

##### What does the `ADD` instruction do in LMC??
Add what is in the address given to the accumulator.
^add-behaviour

##### What does `ADD 59` do in LMC??
Add what is in address `59` to the accumulator.
^add-59-example

##### What does `SUB` mean in LMC??
Subtract.
^sub-mnemonic

##### What does the `SUB` instruction do in LMC??
Subtract what is in the address from the accumulator.
^sub-behaviour

##### What does `SUB 59` do in LMC??
Subtract what is in address `59` from the accumulator.
^sub-59-example

### Output and halting
##### What does `OUT` mean in LMC??
Output.
^out-mnemonic

##### What does `OUT` do in LMC??
Output/print what is in the accumulator.
^out-behaviour

##### What does `HLT` mean in LMC??
Halt/end.
^hlt-mnemonic

##### What does `HLT` do in LMC??
Stops the execution of the program.
^hlt-behaviour

### Branching instructions
##### What does `BRZ` mean in LMC??
Branch if zero.
^brz-mnemonic

##### What does `BRZ` do in LMC??
If the contents of the accumulator is 0, set the program counter to the given address.
^brz-behaviour

##### What does `BRP` mean in LMC??
Branch if positive/zero.
^brp-mnemonic

##### What does `BRP` do in LMC??
If the contents of the accumulator is 0 or positive, set the program counter to the given address.
^brp-behaviour

##### What does `BRA` mean in LMC??
Branch always.
^bra-mnemonic

##### What does `BRA` do in LMC??
Set the contents of the program counter to the given address.
^bra-behaviour

### Data and addressing
##### What does `DAT` mean in LMC??
Data.
^dat-mnemonic

##### What does `DAT` do in LMC??
Instead of storing the instruction in RAM, store the operand given where that operation would be.
^dat-behaviour

##### What is the program counter in LMC??
It holds the address of the next instruction the little man has to carry out.
^program-counter-definition-little-man-computer
##### What is direct addressing??
Where an operand is specified as a memory address holding the value to be used.
^direct-addressing-definition

##### What is immediate addressing??
Where the operand is specified as the actual value explicitly.
^immediate-addressing-definition

##### Why is it called Little Man Computer??
Because it's like a little man running about, grabbing instructions and doing all the operations in a computer.
^little-man-computer-name-reason

---
Olly Britton — https://ollybritton.com. Machine-readable index: https://ollybritton.com/llms.txt
