Download presentation
1
LMC Little Moron Computer
Chapter 6 LMC Little Moron Computer
2
von Neumann Principles (revisited)
Stored program concept - Memory & Data Memory is addressed linearly Memory is addressed without regard to content1 John von Neumann, 1945
3
LMC Mailboxes Calculator LM Counter 00 01 02 03 04 05 06 07 96 97 98
99 LM Counter
4
LMC Organization
5
CPU Components
6
LMC - CPU
7
LMC Instructions OPCODE OPERAND Source OPERAND OPCODE Mailbox Address
8
Address vs. Contents G Addresses are consecutive
G Contents may be data or instructions
9
The CPU - The Instruction Cycle
START Fetch Next Instruction & Decode Fetch Cycle Execute Instruction Execute Cycle HALT
10
Fetch an Instruction
11
Fetch an Instruction (continued)
12
Execute an Instruction
13
Execute an Instruction (continued)
14
LMC Instruction Set 1 xx ADD Arithmetic 2 xx SUB
3 xx STO Data Movement 5 xx LDA 6 xx BR Program Control 7 xx BRZ 8 xx BRP IN Input/Output OUT HLT DAT Data Storage Location
15
LDA INSTRUCTION 5 xx Go to mailbox with address xx
Read 3-digit number on paper in mailbox (leave paper there) Enter 3-digit number into calculator Advance location counter NOTE: Accumulator changes in value. Contents of memory location xx does not change.
16
STO INSTRUCTION 3 xx Retrieve value from calculator
Go to mailbox at address xx and replace 3-digit number on paper in mailbox with value from calculator Advance location counter NOTE: Accumulator does not change in value. Contents of memory location xx does change.
17
ADD INSTRUCTION 1 xx Go to mailbox with address xx
Read 3-digit number on paper in mailbox (leave paper there) Add 3-digit number to number stored in calculator Advance location counter NOTE: Accumulator changes in value.
18
SUB INSTRUCTION 2 xx Go to mailbox with address xx
Read 3-digit number on paper in mailbox (leave paper there) Subtract 3-digit number from number stored in calculator Advance location counter NOTE: Accumulator changes in value.
19
IN INSTRUCTION 9 01 Wait for paper slip to be placed in IN Basket.
Remove paper from IN Basket, and read 3-digit number on it Enter number into calculator Advance location counter NOTE: Accumulator changes in value.
20
OUT INSTRUCTION 9 02 Copy number from calculator onto paper
Place paper into OUT Basket Advance location counter NOTE: Accumulator does not change in value.
21
BRANCH INSTRUCTION 6 xx Set value of location counter to xx
22
BRZ INSTRUCTION 7 xx Observe value stored in calculator
If value is 0, set value of location counter to xx
23
BRP INSTRUCTION 8 xx Observe value stored in calculator
If value is not negative, set value of location counter to xx NOTE: 0 value is considered positive.
24
HLT INSTRUCTION 0 00 LMC takes a break.
NOTE: Make no assumptions about contents of memory or calculator.
25
ADD TWO INPUT NUMBERS 00 IN 9 01 01 STO 99 3 99 02 IN 9 01
04 OUT 05 HLT 99 DAT
26
FIND POSITIVE DIFFERENCE OF TWO INPUT NUMBERS
01 STO 02 IN 9 01 03 STO 04 SUB 05 BRP 06 LDA 07 SUB 08 OUT 9 02 09 HLT 0 00 10 DAT 11 DAT
27
Problem 6.6: Find largest of 3 numbers
Part 1: Find larger of two numbers and store its value in memory cell. 00 IN ;input three numbers and save 01 STO 02 IN 9 01 03 STO 04 IN 05 STO 06 SUB ;subtract number in 98 from that in 97 07 BRP ;number in 97 larger 08 LDA ;number in 98 larger-restore 98 09 BR 10 LDA ;restore 97 11 STO ;store larger of (97, 98) in 96
28
Problem 6.6 (continued) 12 SUB ;subtract number in 99 from larger 13 BRP ;number in 96 larger 14 LDA ;number in 99 larger--restore 99 15 BR 16 LDA ;restore 96 17 OUT 18 HLT 0 00 96 DAT 97 DAT 98 DAT 99 DAT
29
Problem 6.7 - Find Largest of N Numbers
01 STO ;store the first number in 99 02 IN 03 BRZ ;completion flag 04 STO ;store new value temporarily 05 SUB 06 BRP ;new value larger--store it in 99 07 BR ;old value in 99 is larger--get next number 08 LDA 09 STO 10 BR 11 LDA 12 OUT 13 HLT 0 00 98 DAT 99 DAT ;contains largest number currently input
30
Problem 6.14: Program Loader
00 BR ;Jump to location 86 … 86 LDA ;initialize the STORE instruction at location 92 87 STO 88 INP ;input a value 89 SUB ;subtract 999 90 BRZ ;done loading--jump to 01 for execution 91 ADD ;restore input value 92 DAT ;store value. This will contain 3XX, with XX indexed ;each time 93 LDA ;load the STORE instruction in 92 94 ADD ;increment it 95 STO ;and resave it 96 BR ;continue with the next input [NOTE: No test for exceeding ;memory] 97 DAT ;value 999 for testing 98 DAT ;initial STORE 01 instruction as a data value 99 DAT ;value 1 for indexing
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.