Download presentation
Presentation is loading. Please wait.
1
Little Man Computer
2
Components Memory (100 cells numbered 0 to 99) Program Counter
Holds machine language instructions and data Program Counter Holds the address of the next instruction to be executed Accumulator Holds the result of the most recent ADD / SUB instruction In box Where the computer gets its input Out box Where the computer sends its ouput
3
Instructions OpCode Mnemonic Description HLT Halt execution 1 ADD
HLT Halt execution 1 ADD Add memory cell to accumulator 2 SUB Subtract memory cell from accumulator 3 STA Store accumulator to memory cell 4 LDA Load memory cell to accumulator 5 BRA Set program counter to operand 6 BRZ Set program counter to operand only if accumulator is zero 7 INP Load in box to accumulator 8 OUT Write accumulator to out box
4
LMC Machine Language Each machine language instruction is a 3-digit number 3 1 9 The opcode specifies which instruction to execute The operand specifies additional information needed by the instruction
5
3 1 9 LMC Assembly Language STA 19
An assembly language instruction is a decoded machine language instruction 3 1 9 STA 19
6
Execution Cycle Fetch => Decode => Execute
7
Example – Add 2 Numbers Get a number from input into calc
Copy that number to an unused mailbox (mailbox 99) Get another number from input into calc Add the number we put into a mailbox 99 to calc Copy calc to the output Halt
8
Example – Add 2 Numbers Address Machine Language Assembly 700 INP 1
700 INP 1 399 STA 99 2 3 199 ADD 99 4 800 OUT 5 000 HLT
9
Example – Count Down to Zero
Address Machine Language Assembly 700 INP 1 605 BRZ 5 2 800 OUT 3 206 SUB 6 4 501 BRA 1 5 000 HLT 6 001 DAT 1
10
Example – Read / Write Two Numbers But Swap Them
Get a number from input into calc Copy the number to an unused mailbox (mailbox 99) Copy the number to an unused mailbox (mailbox 98) Copy the value from mailbox 98 to calc Copy the value in calc to output Copy the value from mailbox 99 to calc
11
Example – Read / Write Two Numbers But Swap Them
INP (700) STA 99 (399) STA 98 (398) LDA 98 (598) OUT (800) LDA 99 (599)
12
Example – Multiply by 3 if Positive
INP (700) STA 99 (399) STA 98 (398) STA 97 (397) LDA 98 (498) ADD 13 (113) BRZ 13 (613) LDA 97 (497) SUB 13 (213) BRZ 17 (617) BRA 04 (504) 1 (this is data, not an instruction) LDA 99 (399) OUT (800) HLT (000) ADD 99 (199)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.