0% found this document useful (0 votes)
7 views

Lecture Note 05

The document describes the components and operation of the Little Man Computer (LMC). The LMC uses mailboxes numbered 00-99 to store instructions and data, and a calculator to perform arithmetic. A Little Man executes programs by following the instructions stored in the mailboxes. He communicates with the outside world via an input and output basket. The LMC has a simple instruction set that allows it to perform operations like loading data, storing results, and branching based on calculator values.

Uploaded by

ShyamkantVasekar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Lecture Note 05

The document describes the components and operation of the Little Man Computer (LMC). The LMC uses mailboxes numbered 00-99 to store instructions and data, and a calculator to perform arithmetic. A Little Man executes programs by following the instructions stored in the mailboxes. He communicates with the outside world via an input and output basket. The LMC has a simple instruction set that allows it to perform operations like loading data, storing results, and branching based on calculator values.

Uploaded by

ShyamkantVasekar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

The Little Man Computer: Components & Physical Layout

J 100 mailboxes
J address 00 - 99
J Each holds 3-digit decimal
number
J Calculator
J Enter number
The Little Man Computer J Temporarily hold number
J Add and Subtraction
J Display 3 digits
J Hand counter
J Reset button
J Instruction counter
J Little Man
J In/Out Basket

School of Computer Science G51CSA School of Computer Science G51CSA

1 2

The Little Man Computer: Components & Physical Layout The Little Man Computer: Components & Physical Layout

J Start Button: J Calculator:

The operator of the LMC (not the Little Man) presses the Performs simple arithmetic (addition and subtraction only)
START BUTTON to zero the Instruction Counter and ring a Used for temporary storage of a single three digit number. The display is
bell which wakes up the Little Man so he can start executing limited to three digits.
the program which has previously been stored in the The calculator has ten numerical keys (0-9) and two operation keys (+ and -).
mailboxes The calculator also has two lights which can be seen by the Little Man.
J Instruction Counter: One of these lights turns on whenever the number being displayed is exactly
zero.
This display contains the number of the mailbox in which the
The other light turns on whenever the number being displayed is positive ( the
NEXT instruction is stored. The Little Man can change the
number ZERO is considered a positive number). Thus when ZERO is
number in the instruction counter (usually by incrementing but displayed on the calculator, both lights will be on.
sometimes by replacement), and the user of the LMC can reset
These lights are sometimes referred to as flags
the Instruction Counter to 00 using the start button

School of Computer Science G51CSA School of Computer Science G51CSA

3 4

The Little Man Computer: Components & Physical Layout The Little Man Computer: Communication with outside World

J Mailboxes: J A user outside the mailroom


Mailboxes are identified using two-digit numbers (00 99) and communicate with the little man by
each can hold a single slip of paper containing a single three digit
number. J Putting a 3-digit into the in
basket
J Retrieving a 3-digit from the out
basket

J Apart from the reset button, all


communication between the LMC
and the outside world takes place
using 3-digit numbers

School of Computer Science G51CSA School of Computer Science G51CSA

5 6

1
The Little Man Computer: Operation The Little Man Computer: Instruction Set

J A small group of instructions, each consists of a single digit


FORMAT MNEMONIC MEANING
J The first digit of a 3-digit number is used to tell the Little
Man which operation to perform. 3xx STO xx Stores the calculator value into mailbox
J In some cases, the Little Man is required to use a particular xx.
mailbox to store or retrieve data
4xx STA xx Stores the address portion of the
J The 3 digits can be used to give instructions to the Little calculator value (last 2 digits) into the
Man according to address portion of the instruction in
mailbox xx.
Operation Code (Op-Code)

5xx LOAD xx Loads the contents of mailbox xx into


3 25 the calculator.
Instruction mailbox address

School of Computer Science G51CSA School of Computer Science G51CSA

7 8

The Little Man Computer: Instruction Set The Little Man Computer: Instruction Set

FORMAT MNEMONIC MEANING


FORMAT MNEMONIC MEANING
000 STOP Stops the Computer - the Little Man rests.

1xx ADD xx Adds the contents of mailbox xx to the 6xx B xx This instruction sets the instruction counter to the
number xx, thus effectively branching to mailbox xx
calculator display.

7xx BZ xx IF the calculator value is zero, THEN set the


2xx SUB xx Subtracts the contents of mailbox xx instruction counter to the number xx, thus effectively
from the calculator display. branching to mailbox xx.

8xx BP xx IF the calculator value is positive, THEN set the


instruction counter to the number xx, thus effectively
branching to mailbox xx. NOTE: zero is considered
positive.

School of Computer Science G51CSA School of Computer Science G51CSA

9 10

The Little Man Computer: Instruction Set The Little Man Computer: Execute Program

To actually run an LMC program we must carry out the following steps.

FORMAT MNEMONIC MEANING J Load the instructions into the mailboxes, starting with mailbox 00.
J Place the data to be used by the program in the IN basket, in the order in
901 INPUT Read a number from the IN basket which the program will use these data.
and key it into the calculator.
J Press the RESET BUTTON to set the Instruction Counter to 00 and to
also wakeup the Little Man. Then
902 OUTPUT Copy the number in the calculator
onto a slip of paper and place it 1. The Little Man looks into the Instruction Counter
into the OUT basket. 2. The Little Man find the mailbox whose address has the value in the
Instruction Counter and fetches the 3-digit number from the mailbox.
3. The Little Man executes the instruction found in the mailbox
4. The Little Man go over to increase the instruction counter by 1
5. The Little Man repeat the by going to 1

School of Computer Science G51CSA School of Computer Science G51CSA

11 12

2
The Little Man Computer: Program Example The Little Man Computer: Program Example

Mail Box Map Write a LMC program which adds two numbers together
Mail Box Division: (Memory Map)

00 Mailbox Code Instruction Description


Both Program and data are
Instructions
00 901 INPUT
stored in the mail box 29
01 399 STORE DATA (to mailbox no 99)
Not Used 02 901 INPUT
Which is data, which is program?
03 199 ADD the 1st number to 2nd number
70 04 902 OUTPUT RESULT
Data 05 000 The Little Man rest

99
99 Data

School of Computer Science G51CSA School of Computer Science G51CSA

13 14

The Little Man Computer: Program Example The Little Man Computer: The Instruction Cycle

Write a LMC program to find the positive (absolute) difference of two numbers
Mailbox Mnemonic Code
00 IN 901
01 STO 10 310
02 IN 901
03 STO 11 311
04 SUB 10 210
05 BP 08 808
06 LOAD 10 510
07 SUB 11 211
08 OUT 902 The fetch portion of the instruction cycle
09 HALT 000 (LOAD Instruction)
10 DAT 00 000
11 DAT00 000

School of Computer Science G51CSA School of Computer Science G51CSA

15 16

The Little Man Computer: The Instruction Cycle The Little Man Computer: The Instruction Cycle

The execute portion of the instruction cycle


The execute portion of the instruction cycle
(LOAD instruction)
(LOAD instruction)
School of Computer Science G51CSA School of Computer Science G51CSA

17 18

3
Some Observations Regarding Computer Architecture The Little Man CPU
Buffer

J Between 1945 and 1951, von Neumann architecture


J Other experimental architectures have been developed and built
J von Neumann architecture continues to be the standard architecture for PC 000 MAR
MM
computer
J No other architecture has had any commercial success so far +1
Out
J It is significant that in a field where technological changes happens almost
overnight, the architecture of computers is virtually unchanged since 1951 Accu.
MDR
J Key concepts of von Neumann architecture include In
J Stored program concept Ctrl
J Memory is addressed linearly
ALU
J Memory addressed by the location number without regard to the contents
IR Buffer Buffer
J Instructions executed in sequence unless an instruction or outside events
cause branch

School of Computer Science G51CSA School of Computer Science G51CSA

19 20

Programming Languages

Divided into two broad categories


– Low-level (close to hardware)
Assembly Languages
– High-level (abstracted away from hardware)
And
Programming Paradigm

School of Computer Science G51CSA School of Computer Science G51CSA

21 22

Characteristics Of High-Level Language Characteristics Of Low-Level Language

One-to-one translation
Many-to-one translation
Hardware dependence
Hardware independence
Application orientation Systems programming
orientation
General-purpose
Special-purpose
Powerful abstractions
Few abstractions

School of Computer Science G51CSA School of Computer Science G51CSA

23 24

4
Terminology An Important Concept

Assembly language
Because an assembly language is a low-level language
– Refers to a type of low-level language that incorporates specific characteristics of a
– Specific to given processor processor, such as the instruction set, operand
addressing, and registers, many assembly languages
Assembler exist.

– Refers to software that translates assembly


language into binary code
– Analogous to compiler

School of Computer Science G51CSA School of Computer Science G51CSA

25 26

Assembly Languages Assembly Statement Format

Share same general structure General format is:


Programmer who understands one label: opcode operand1, operand2, ...
assembly language can learn another
quickly Label is optional
Opcode and operands are processor specific

School of Computer Science G51CSA School of Computer Science G51CSA

27 28

Comment Syntax An LMC Assembly Program


LMC Assembly Program to find the positive (absolute) difference of two numbers
Typically
IN #input 1st number
– Character reserved to start a comment STO dat1 #store first number in location dat11
IN #input 2nd number
– Comment extends to end of line
STO dat2 #store in location dat2
SUB dat1 #A = A – (dat1)
BP Label1 #If A>=0, jump to Label1
Examples of comment characters LOAD dat1 #load content from location dat1
SUB dat2 #A – A – (dat2)
– Pound sign (#) Label1 OUT #output content in A
HALT #Halt the program
– Semicolon (;) dat1 DAT 00 #Location reserved for 1st number
dat2 DAT00 #Location reserve for 2nd number

School of Computer Science G51CSA School of Computer Science G51CSA

29 30

5
Assembly Language For Conditional Execution In Practice
if (condition) {
body
Because writing application programs in
}
assembly language is difficult, assembly
next statement language is reserved for situations where a
code to test condition and high-level language has insufficient
set condition code functionality or results in poor performance.
branch not true to label
code to perform body
label: code for next statement

School of Computer Science G51CSA School of Computer Science G51CSA

31 32

Assembler Difference Between Assembler And Compiler

v Software component Although both a compiler and an assembler translate a


source program into equivalent binary code, a compiler
v Accepts assembly language program as has more freedom to choose which values are kept in
input registers, the instructions used to implement each
statement, and the allocation of variables to memory. An
v Produces binary form of program as output assembler merely provides a one-to-one translation of
each statement in the source program to the equivalent
v Uses two-pass algorithm binary form.

School of Computer Science G51CSA School of Computer Science G51CSA

33 34

What An Assembler Provides Summary

v Assembly language is low-level and incorporates details of a specific


processor
v Statements are 1-1 with instructions v Many assembly languages exist, one per processor

v Assembler v Each assembly language statement corresponds to one machine


instruction
v – Computes relative location for each label v Same basic programming paradigm used in most assembly languages

v – Fills in branch offsets automatically v Programmers must code assembly language equivalents of abstractions
such as
v Consequence: can insert or delete statements v – Conditional execution
without recomputing offsets manually v – Definite and indefinite iteration
v – Procedure call

School of Computer Science G51CSA School of Computer Science G51CSA

35 36

6
Beginning, Program & Data in Memory
Summary Reset counter, the Machine in a random state …. 234

MAR 00 901
v Assembler translates assembly language program into binary code 01 310

88
PC 00
v Assembler uses two-pass processing 02 901
v – First pass assigns relative locations +1 03 311
Out Acc. 04 210
v – Second pass generates code 222 05 808
777 06 510
In MDR 07 211
Ctrl
08 902
ALU 09 000
444 444 333 10 000
11 000

School of Computer Science G51CSA School of Computer Science G51CSA

37 38

Instruction Fetch ... 234 Instruction execution ... 234


MAR MAR
00 901 00 901
01 310 01 310
00

00
PC 00 PC 01
02 901 02 901
+1 03 311 +1 03 311
Out Acc. Out Acc.
04 210 04 210
222 05 808 102 05 808
901 06 510 901 06 510
In MDR 07 211 In MDR 07 211
Ctrl 102 Ctrl 304
304 08 902 123 08 902
…. 09 000 …. 09 000
IR ALU IR ALU
901 444 333 10 000 901 444 333 10 000
11 000 11 000

School of Computer Science G51CSA School of Computer Science G51CSA

39 40

Instruction Fetch ... 234 Instruction Execution ... 102


MAR MAR
00 901 00 901
01 310 01 310
0 1

1 0

PC 01 PC 02
02 901 02 901
+1 03 311 +1 03 311
Out Acc. Out Acc.
04 210 04 210
102 05 808 102 05 808
310 06 510 310 06 510
In MDR 07 211 In MDR 07 211
Ctrl 304 Ctrl 304
123 08 902 123 08 902
…. 09 000 …. 09 000
IR ALU IR ALU
310 444 333 10 000 310 444 333 10 102
11 000 11 000

School of Computer Science G51CSA School of Computer Science G51CSA

41 42

7
Instruction Fetch ... 102 Instruction Execution ... 102
MAR MAR
00 901 00 901
01 310 01 310

0 2

0 2
PC 02 PC 03
02 901 02 901
+1 03 311 +1 03 311
Out Acc. Out Acc.
04 210 04 210
102 05 808 304 05 808
901 06 510 901 06 510
In MDR 07 211 In MDR 07 211
Ctrl 304 Ctrl 123
123 08 902 100 08 902
…. 09 000 …. 09 000
IR ALU IR ALU
901 444 333 10 102 901 444 333 10 102
11 000 11 000

School of Computer Science G51CSA School of Computer Science G51CSA

43 44

Instruction Fetch ... 102 Instruction Execution ... 304


MAR MAR
00 901 00 901
01 310 01 310
0 3

11
PC 03 PC 04
02 901 02 901
+1 03 311 +1 03 311
Out Acc. Out Acc.
04 210 04 210
304 05 808 304 05 808
311 06 510 311 06 510
In MDR 07 211 In MDR 07 211
Ctrl 123 Ctrl 123
100 08 902 100 08 902
…. 09 000 …. 09 000
IR ALU IR ALU
311 444 333 10 102 311 444 333 10 102
11 000 11 304

School of Computer Science G51CSA School of Computer Science G51CSA

45 46

Instruction Fetch ... 304 Instruction Execution ... 304


MAR MAR
00 901 00 901
01 310 01 310
04

10

PC 04 PC 05
02 901 02 901
+1 03 311 +1 03 311
Out Acc. Out Acc.
04 210 04 210
304 05 808 202 05 808
210 06 510 102 06 510
In MDR 07 211 In MDR 07 211
Ctrl 123 Ctrl 123
100 08 902 100 08 902
…. 09 000 …. 09 000
IR ALU IR ALU
210 444 333 10 102 210 304 102 10 102
11 304 11 304

School of Computer Science G51CSA School of Computer Science G51CSA

47 48

8
Instruction Fetch ... 304 Instruction Execution ... 304
MAR MAR
00 901 00 901
01 310 01 310

05

05
PC 05 PC 08
02 901 02 901
+1 03 311 +1 03 311
Out Acc. Out Acc.
04 210 04 210
202 05 808 202 05 808
808 06 510 808 06 510
In MDR 07 211 In MDR 07 211
Ctrl 123 Ctrl 123
100 08 902 100 08 902
…. 09 000 …. 09 000
IR ALU IR ALU
808 304 102 10 102 808 304 102 10 102
11 304 11 304

School of Computer Science G51CSA School of Computer Science G51CSA

49 50

Instruction Fetch ... 304 Instruction Execution ... 304


MAR MAR
00 901 00 901
01 310 01 310
08

08
PC 08 PC 09
02 901 02 901
+1 03 311 +1 03 311
Out Acc. Out Acc.
04 210 04 210
202
202 05 808 202 05 808
902 06 510 …. 902 06 510
In MDR 07 211 In MDR 07 211
Ctrl 123 Ctrl 123
100 08 902 100 08 902
…. 09 000 …. 09 000
IR ALU IR ALU
902 304 102 10 102 902 304 102 10 102
11 304 11 304

School of Computer Science G51CSA School of Computer Science G51CSA

51 52

Instruction Fetch ... 304 Instruction Execution ... 304


MAR MAR
00 901 00 901
01 310 01 310
09

09

PC 09 PC 09
02 901 02 901
+1 03 311 +1 03 311
Out Acc. Out Acc.
04 210 04 210
202 202
202 05 808 202 05 808
…. 000 06 510 …. 000 06 510
In MDR 07 211 In MDR 07 211
Ctrl 123 Ctrl 123
100 08 902 100 08 902
…. 09 000 …. 09 000
IR ALU IR ALU
000 304 102 10 102 000 304 102 10 102
11 304 11 304

School of Computer Science G51CSA School of Computer Science G51CSA

53 54

9
Instruction Fetch ... 102
MAR
If the first number is bigger than the first number 00 901
01 310

05
PC 05
………., e.g, the input basket looks like this 02 901
+1 03 311
304 Out Acc.
102
04 210
…. - 202 05 808
808 06 510
not this
In MDR 07 211
Ctrl 123
102 100 08 902
304 ….
…. IR ALU 09 000
808 102 304 10 304
11 102

School of Computer Science G51CSA School of Computer Science G51CSA

55 56

Instruction Execution ... 102 Instruction Fetch ... 102


MAR MAR
00 901 00 901
01 310 01 310

06
05

PC 06 PC 06
02 901 02 901
+1 03 311 +1 03 311
Out Acc. Out Acc.
04 210 04 210
-202 05 808 -202 05 808
808 06 510 510 06 510
In MDR 07 211 In MDR 07 211
Ctrl 123 Ctrl 123
100 08 902 100 08 902
…. 09 000 …. 09 000
IR ALU IR ALU
808 102 304 10 304 510 102 304 10 304
11 102 11 102

School of Computer Science G51CSA School of Computer Science G51CSA

57 58

Instruction Execution ... 102 Instruction Fetch ... 102


MAR MAR
00 901 00 901
01 310 01 310
10

07

PC 07 PC 07
02 901 02 901
+1 03 311 +1 03 311
Out Acc. Out Acc.
04 210 04 210
304 05 808 304 05 808
304 06 510 211 06 510
In MDR 07 211 In MDR 07 211
Ctrl 123 Ctrl 123
100 08 902 100 08 902
…. 09 000 …. 09 000
IR ALU IR ALU
510 102 304 10 304 211 102 304 10 304
11 102 11 102

School of Computer Science G51CSA School of Computer Science G51CSA

59 60

10
Instruction Execution ... 102 Instruction Fetch ... 102
MAR MAR
00 901 00 901
01 310 01 310

08
11
PC 08 PC 08
02 901 02 901
+1 03 311 +1 03 311
Out Acc. Out Acc.
04 210 04 210
202 05 808 202 05 808
102 06 510 902 06 510
In MDR 07 211 In MDR 07 211
Ctrl 123 Ctrl 123
100 08 902 100 08 902
…. 09 000 …. 09 000
IR ALU IR ALU
211 304 102 10 304 902 304 102 10 304
11 102 11 102

School of Computer Science G51CSA School of Computer Science G51CSA

61 62

Instruction Execution ... 102 Instruction Fetch ... 102


MAR MAR
00 901 00 901
01 310 01 310
08

09
PC 09 PC 09
02 901 02 901
+1 03 311 +1 03 311
Out Acc. Out Acc.
04 210 04 210
202 202
202 05 808 202 05 808
…. 902 06 510 …. 000 06 510
In MDR 07 211 In MDR 07 211
Ctrl 123 Ctrl 123
100 08 902 100 08 902
…. 09 000 …. 09 000
IR ALU IR ALU
902 304 102 10 304 000 304 102 10 304
11 102 11 102

School of Computer Science G51CSA School of Computer Science G51CSA

63 64

Instruction Execution ... 102


MAR
00 901
01 310
09

PC 09
02 901
+1 03 311
Out Acc. 04 210
202 202 05 808
…. 000 06 510
In MDR 07 211
Ctrl 123
100 08 902
…. 09 000
IR ALU
000 304 102 10 102
11 304

School of Computer Science G51CSA

65

11

You might also like