Title: The Little Man Computer
1The Little Man Computer
- LMC was created by Dr. Stuart Madnick at MIT 1965
2Layout of the LMC
- LMC consists of a walled mailroom
- There are 100 mailboxes addressed from 00 to 99
- A mailbox can hold a signal slip of paper which
is written three-digit decimal number - Calculator can add, subtract and hold 3-digit
temporarily number - Hand counter is for little man to see which
mailbox he has to get reset button is for people
outside mailroom to press - Basket in and Basket out are for little
communicate with outside world
3Figure 6.1 The Little Man Computer
4Operation of the LMC
- 3 digits mean following
- 1 digits for instruction (op code)
- The rest for mailbox address (address)
3 25
5Operation of the LMC cont.
- Load instruction op code 5
- Store instruction op code 3
- Add instruction op code 1
- Subtract instruction op code 2
- Input instruction op code 9, address 01
- 901
- Output instruction op code 9, address 02
- 902
- Coffee break instruction (Halt) op code 0
6Load
Walk to mailbox address
Little Man
Read 3-digit number in that mailbox
Walk to calculator and put these numbers to the
calculator
The numbers in the mailbox are left unchanged
7Store
Walk to calculator and read 3-digit number on
calculator
Little Man
Write 3-digit number in a blank paper
Walk to mailbox address and put this paper to the
mailbox
The numbers in the calculator are left unchanged
8Add
Walk to mailbox address
Little Man
Read 3-digit number in that mailbox
Walk to calculator and add these numbers to the
calculator
The numbers in the mailbox are left unchanged
9Subtract
Walk to mailbox address
Little Man
Read 3-digit number in that mailbox
Walk to the calculator and subtract value on
calculator from mailbox value
The numbers in the mailbox are left unchanged
10Input
Walk basket in
Little Man
Read 3-digit number in that basket
Walk to the calculator and put these numbers on
11Output
Walk to the calculator
Little Man
Read 3-digit number from the calculator write
down in a paper
Walk to the basket out and put this paper in
12Coffee break (halt)
Little Man
- Summary of instructions
- Move data
- Load, store
- Simple arithmetic
- Add, subtract
- Input and output
- Input, output
- Control machine
- Coffee break
Stop doing anything Just relax and take a glass
of coffee
13A simple program
- We need to find the place for store the program
- We assume that the program is stored at mail box
address 00 - When LM completes the instruction, he walks to
the counter to increase its value 1 more - We can reset LM to execute program by pressing
the reset button
14Add two numbers
- User places two numbers in the in basket
- Result will be returned in the out basket
- Input 901
- Store 99 399
- Input 901
- Add 99 199
- Output 902
- Coffee break 000
In class Do add 3 number
15An extended instruction set
- Branch unconditionally instruction (Jump) op
code 6 - Branch on zero instruction op code 7
- Branch on positive instruction op code 8
16Branch unconditionally
Walk to counter
Little Man
Change counter to specific number
Execute the instruction where counter shows
17Branch on zero
Walk to calculator
Little Man
The number on calculator is zero?
Yes, change value in counter to mailbox address
No, dont care
continue executing next instruction
18Branch on positive
Walk to calculator
Little Man
The number on calculator is gt 0?
Yes, change value in counter to mailbox address
No, dont care
continue executing next instruction
19Example of branch program
- While (i0)
- do something
-
- 45 LDA 90 590 90 contains i
- 46 BRZ 48 748 branch on zero
- 47 BR 60 660
- do something
- 59 BR 45 645
- 60 COB stop
Look at table 6.3 for mnemonic instruction page
155
90 000
90 100
20Another example of branch
- Find the positive difference between two numbers
? a b where a, b gt 0 - 00 IN 901
- 01 STO 10 310 store a
- 02 IN 901
- 03 STO 11 311 store b
- 04 SUB 10 210 b-a
- 05 BRP 08 808 gt0?
- 06 LDA 10 510
- 07 SUB 11 211
- 08 OUT 902 print output
- 09 COB 000
- 10 DAT 000 a
- 11 DAT 000 b
In high level language if (b-agt0) print
(b-a) else print (a-b)
21The Instruction Cycle
- Fetch
- Execute
- Von Neumann architecture
- Stored program concept
- Sequential numeric address executing
22Fetch
23Execute
24More example
- Write a Little Man program that accepts three
values as input and produces the largest of the
three as output - Write a Little Man program that prints out the
odd numbers from 1 to 99. No input is required
25Addressing mode
- Immediate
- Direct
- Indirect
- Register
- Register Indirect
- Indexed Addressing
Why do we need to have other methods of
addressing techniques in stead of only absolute
addressing?
26Immediate addressing
- Data is in the instruction
- No memory reference to fetch data
- Fast
- Limited range
27Direct Addressing
- Address field contains address of operand
- e.g. ADD A
- Add contents of cell A to accumulator
- Look in memory at address A for operand
- Single memory reference to access data
- No additional calculations to work out effective
address - Limited address space
28Direct Addressing Diagram
29Indirect Addressing Diagram
- Memory cell pointed to by address field contains
the address of (pointer to) the operand
30Indirect Addressing
- Large address space
- 2n where n word length
- Multiple memory accesses to find operand
- Often used in branch instructions
- Often used in access table
- Could have multiple levels of indirection
- Like pointer in C or Pascal
- Hence slower
31Little Man indirect addressing(1)
32Little Man indirect addressing(2)
33Register Addressing (1)
- Very fast performance
- Example, move r1, r2
34Register Addressing (2)
- Operand is held in register named in address
filed - Limited number of registers
- Very small address field needed
- Shorter instructions
- Faster instruction fetch
- No memory access
- Very fast execution
- Very limited address space
- Multiple registers helps performance
- Requires good assembly programming or compiler
writing
35Register Addressing Diagram
36Register Indirect Addressing
- Operand is in memory cell pointed to by contents
of register R - Large address space (2n)
- n is number of bits in the register
- One fewer memory access than indirect addressing
- Can use Auto incrementing or auto decrementing
for table access
37Register Indirect Addressing Diagram
38Indexed Addressing (1)
Modifying an address with an index register
39Indexed Addressing (2)
Indexing a base offset address