TCB1043
COMPUTER ORGANISATION
Basic Microprocessor System
Saipunidzam Mahamad @ Computer Organization
Learning Topics
Little Man Computer
The Fetch-Executed Cycle
The LMC instruction Set
The LMC and the von Newmann architecture
Computer Buses: 1s and 0s continuously on
the move
Saipunidzam Mahamad @ Computer Organization
The Little Man Computer - LMC
What it is?
Created by Dr. Stuart
Madnick 1965 of MIT.
An almost accurate
representation of the
working of a computer.
Even after 35 years of
Computer Innovation
and Creation. The LMC
architecture is at the
heart of todays
computer design.
View of LMC
Saipunidzam Mahamad @ Computer Organization
The Little Man Computer - LMC
What are its component?
A post room (not too dusty)
A little man (physically fit!!)
A mailbox with many (100) pigeon holes
numbered from 00 to 99
A calculator (for simple arithmetic operations)
A counter
An input booth (to interact with the outside world)
An output booth (to interact with the outside
world)
Saipunidzam Mahamad @ Computer Organization
The Little Man Computer - LMC
What does the little man do?
Transfer or move information from one part of the
post room to another.
Interpret (or decode) and Carry out instructions that
involve movement of information or data.
Continuously on the lookout for new instructions.
The little man must be very fit to do all
this running about !!!
Saipunidzam Mahamad @ Computer Organization
The Little Man Computer - LMC
What are the pigeon holes of the mailbox used
for?
A pigeon hole contains NOT letters, but instruction slips.
Each pigeon hole contains one and only one instruction
slip at a time.
Some pigeon holes may contain data (i.e. simple
numbers) that does not represent instructions.
Each Pigeon hole has a unique label (called an address)
that is a number from 00 to 99.
Address Content
Saipunidzam Mahamad @ Computer Organization
The Little Man Computer - LMC
What does calculator do?
Some instructions involve arithmetic calculations like addition,
subtraction and division.
The little can execute instructions that involve movement of data.
BUT The little man does not perform any calculations.
Thus were using a calculator
What is the counter used for?
The little man needs to remember the address (or label of the next
pigeon) to check for any instructions.
The little man remembers the current value of the counter and then
updates the counter (by incrementing it) before he goes to get
another instruction.
Saipunidzam Mahamad @ Computer Organization
The Little Man Computer - LMC
Input and Output Trays
Some instructions or data may be obtained from
outside the post room through the input tray.
The little man sometimes stores data in a pigeonhole
in the mailbox. Some other times, he may have to
deliver data outside the post room through the
output tray.
The little man interacts with the world outside the
post room through the use the input tray and the
output tray.
Saipunidzam Mahamad @ Computer Organization
The LMC Instruction Set
What are the instruction?
3-decimal coded instructions.
The first digit represent the instruction code.
The last two digits represent an address of a pigeon hole in
the mailbox, or one of the input or output trays.
The instruction code is also called the Operation Code or
Op code.
The last two digits are also called the Operand.
Address
Saipunidzam Mahamad @ Computer Organization
Content
Op code
Operand
The LMC Instruction Set
Instruction Structure
Arithmetic
1xx
ADD
Data Movement
2xx
3xx
SUB
STORE
5xx
LOAD
901
902
000
INPUT
Output
STOP
COB
Input/Output
Machine Control
(coffee break)
Saipunidzam Mahamad @ Computer Organization
Input/Output
Move data between calculator and in/out
baskets
Content
Op Code
Operand
(address)
IN (input)
01
OUT (output)
02
Saipunidzam Mahamad @ Computer Organization
LMC Input/Output
IN
OUT
Saipunidzam Mahamad @ Computer Organization
Internal Data Movement
Between mailbox and calculator
Content
Op Code
Operand
(address)
STO (store)
xx
LDA (load)
xx
Saipunidzam Mahamad @ Computer Organization
LMC Internal Data
LDA
STO
Saipunidzam Mahamad @ Computer Organization
Data storage location
Physically identical to instruction mailbox
Not located in instruction sequence
Identified by DAT mnemonic
Saipunidzam Mahamad @ Computer Organization
Arithmetic Instructions
Read mailbox
Perform operation in the calculator
Content
Op Code
Operand
(address)
ADD
xx
SUB
xx
Saipunidzam Mahamad @ Computer Organization
LMC Arithmetic Instructions
ADD
SUB
Saipunidzam Mahamad @ Computer Organization
Program Control
Branching (executing an instruction out of
sequence)
Changes the address in the counter
Halt
Content
Op Code
Operand
(address)
BR (Jump)
xx
BRZ (Branch on 0)
xx
BRP (Branch on +)
xx
COB (stop)
(ignore)
Saipunidzam Mahamad @ Computer Organization
Instruction Set
Arithmetic
1xx
ADD
2xx
SUB
3xx
STORE
5xx
LOAD
BR
6xx
JUMP
BRZ
7xx
BRANC ON 0
BRP
8xx
BRANCH ON +
Input/Output
901
INPUT
902
OUTPUT
000
HALT
COB
Data Movement
Machine Control
(coffee break)
Saipunidzam Mahamad @ Computer Organization
The LMC Instruction Set
Summary
Instruction can be expresses using Op Codes
or as literal abbreviations call Mnemonics
Mnemoni
cs
LDA
STO/STD
ADD
Op
Code
5xx
3xx
1xx
Description
SUB
2xx
IN
OUT
COB or
HLT
BRZ
BRP
BR
DAT
901
902
000
;Load the content of location/pigeon-hole xx into the calculator
;Store the content of calculator into location/pigeon-hole xx
;Add content of location/pigeon-hole xx to the current content of the
calculator
;Subtract content of location/pigeon-hole xx from the current content
of calculator
;Obtain the data from the Input Tray and put it in the calculator
; Send to the current data in the calculator to the Output Tray.
;Coffee Break or Halt (i.e. Stop execution)
7xx
8xx
6xx
yyy
;Jump to location/pigeon-hole xx if the content of the calculator is 0
;Jump to location/pigeon-hole xx if the content of the calculator is >=0
;Jump to location/pigeon-hole xx without any conditions
;Data Storage Location
Saipunidzam Mahamad @ Computer Organization
Simple Program: Add 2 Numbers
Input a #
Assume data is stored
in mailboxes with
addresses >90
Write instructions
Store the #
Input a #
Add
Output the
number
Saipunidzam Mahamad @ Computer Organization
Program to Add 2 Numbers:
Using Mnemonics
Mailbox Mnemonic Instruction Description
00
IN
;input 1st Number
01
02
STO 99
IN
;store data
;input 2nd Number
03
ADD 99
;add 1st # to 2nd #
04
OUT
;output result
05
COB
;stop
99
DAT 00
;data
Saipunidzam Mahamad @ Computer Organization
Program to Add 2 Numbers
Mailbox Code Instruction Description
00
01
02
03
04
05
99
901
399
901
199
902
000
000
;input 1st Number
;store data
;input 2nd Number
;add 1st # to 2nd #
;output result
;stop
;data
Saipunidzam Mahamad @ Computer Organization
The LMC Instruction Set
Sample LMC program to calculate N2-N1:
Saipunidzam Mahamad @ Computer Organization
Find Positive Difference of 2 Numbers
00
IN
901
01
STO 10
310
02
IN
901
03
STO 11
311
04
SUB 10
210
05
BRP 08
808
;test
06
LDA 10
510
;if negative, reverse order
07
SUB 11
211
08
OUT
902
;print result and
09
COB
000
;stop
10
DAT 00
000
;used for data
11
DAT 00
000
;used for data
Saipunidzam Mahamad @ Computer Organization
The Fetch-Execute Cycle
The Fetch-cycle: go and look for the
next instruction and find out what the
instruction means
Before the little man can carry out an
instruction, he needs to find out which
instruction he has to carry out.
He does this by first getting the value from
the counter, and then fetching the value
from the corresponding pigeon hole in
mailbox.
The little identifies what the instruction is.
Saipunidzam Mahamad @ Computer Organization
The Fetch-Execute Cycle
The Execute-cycle: execute the instruction
Once the little man knows which instruction he is going to
perform, he has to start executing it. This is the 'Execute' phase
of the fetch - execute cycle.
For each instruction, the little man will perform a series of tasks.
For instance, for an input instruction, the little man will go to the
input tray, take the value he finds there, and go and put it into
the calculator. For an add instruction, he will take a value from
the mailbox, and add it to the value presently in the calculator
Once the execute phase is complete, the little man will start the
cycle again, and go to the counter to get the address of the next
pigeon hole containing the next instruction he has to fetch.
Saipunidzam Mahamad @ Computer Organization
The Fetch-Execute Cycle
The Fetch-Execute cycles: general path
START
Fetch Cycle
Execute Cycle
Fetch Next
Instruction
Execute
Instruction
Saipunidzam Mahamad @ Computer Organization
HALT
(1)The Little Man reads the
address from the location counter
(2)walks over the mailbox that
corresponds to the location counter
Figure 6.5a The fetch of the
instruction cycle
Saipunidzam Mahamad @ Computer Organization
(3)and reads the number on the
slip of paper. (He then puts the slips
of paper back, in case he should need
to read it again later
Figure 6.5a The fetch of the
instruction cycle
Saipunidzam Mahamad @ Computer Organization
Figure 6.5b
The execute portion of the instruction cycle
(LOAD instruction)
Saipunidzam Mahamad @ Computer Organization
Figure 6.5b
The execute portion of the instruction cycle
(LOAD instruction)
Saipunidzam Mahamad @ Computer Organization
Exercise
Convert the following LMC:
a. Machine code Mnemonic code
00
01
02
03
04
05
06
07
08
901
399
901
199
399
901
299
902
000
Saipunidzam Mahamad @ Computer Organization
a. Mnemonic code Machine code
00 IN
01 STD
02 IN
03 ADD
04 STD
05 IN
06 STD
07 LDA
08 SUB
09 OUT
10 COB
11 DAT
99
99
99
98
99
98
01
The von Neumann architecture
Characteristics of the von Newman
Architecture
Memory holds both program instructions and
program data. This is known as the stored program
concept.
Memory is addressed linearly. In other words, all
memory locations are unique and have numerical
sequential addresses.
Every memory cell is uniquely addressed by its
location number regardless of information is stored
inside it.
Saipunidzam Mahamad @ Computer Organization
The LMC and the von Newmann
architecture
The concept of the CPU Registers
The Register is a single storage location within the CPU.
There are usually many registers within the CPU.
For example, the calculator and the counter used in the LMC
would be implemented inside the CPU using two separate
registers.
Registers are addressed by their names not by a location
number. That is why they different from ordinary memory
cells.
Saipunidzam Mahamad @ Computer Organization
The von Neumann architecture
The CPU (Central Processing Unit)
The CPU and memory are intimately related.
Any discussion of one of must include a discussion
of the other.
In the same that the Little Man cannot work without
his mailbox inside the post-room.
The CPU (Central
Processing Unit)
Component
Saipunidzam Mahamad @ Computer Organization
The von Neumann architecture
Similarities between the LMC and the CPU
CPU
Description
Components
Control unit (CU) Interpreting and managing the execution of
instruction includes a program counter PC
ALU (arithmetic Calculation and temporary storage
logic unit)
I/O Interface
Communication with external devices
Memory
Program and data storage
Program counter
Part of the CU used to store the location of the
next instruction to execute
Saipunidzam Mahamad @ Computer Organization
The von Newmann architecture
Similarities between LMC and the CPU
LMC
CPU
The post-room
The little man
The calculator
The input tray
The output tray
Mailbox
Pigeon hole
The location counter
Saipunidzam Mahamad @ Computer Organization
inside the CPU
control unit (CU)
ALU (arithmetic logic unit)
I/O interface
I/O interface
Memory
Memory cells
Program counter (PC
The LMC and the von Newmann
architecture
Is the LMC a von Newman-based
Computer?
If we now think of the mailbox inside the LMC as
Memory and the pigeon holes as distinct linear
memory cells that are used to store both instructions
and data then
Yes! The LMC is definitely a good example of the
von Newman architecture.
Saipunidzam Mahamad @ Computer Organization
Summary
The working of the computer can be simulated by a simple
model - The Little Man Computer Model
The LMC meets all qualification of von Neumann
computer architecture
The exact steps performed by the LMC are important
because they reflect closely the steps performed in real
CPU in executing an instruction
Reading: Textbook - Chapter 6 & 7
Saipunidzam Mahamad @ Computer Organization