0% found this document useful (0 votes)
79 views4 pages

Chapter 6 - The Little Man Computer

Chapter 6 introduces the Little Man Computer (LMC), a simplified model used to explain computer architecture, covering its layout, operations, programming, and instruction cycle. LMC consists of a main computing engine, a calculator, mailboxes for instruction and data storage, and a defined instruction set for various operations. The chapter also discusses program execution principles, flow control, and includes examples of LMC programs and an emulator for testing them.

Uploaded by

Sangdup Tamang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views4 pages

Chapter 6 - The Little Man Computer

Chapter 6 introduces the Little Man Computer (LMC), a simplified model used to explain computer architecture, covering its layout, operations, programming, and instruction cycle. LMC consists of a main computing engine, a calculator, mailboxes for instruction and data storage, and a defined instruction set for various operations. The chapter also discusses program execution principles, flow control, and includes examples of LMC programs and an emulator for testing them.

Uploaded by

Sangdup Tamang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Chapter 6 – The Little Man Computer

· This chapter starts the coverage of the hardware component of the computer system architecture
· The following main topics will be covered:
o Layout of the Little Man Computer (LMC)
o Operations of LMC
o Programming in LMC
o The instruction cycle

Layout of LMC

· This chapter discusses a classical computer model, called the Little Man Computer (LMC)
· LMC is a simplified computer prototype to help explain the computer hardware architecture
· LMC was originally developed in 1965
· In 1979, LMC was slightly modified
· 37 years after its introduction, LMC still provide an accurate representation of the real computer
design and operation
· The following fundamental computer architecture concepts will be outlined through the LMC
discussion:
o Organization and physical layout of a typical computer system
o Role of CPU
o Role of memory
o Role of Input/Output devices
o The instruction set
o How the LMC execute instructions (i.e. fetch-execute cycle)
o How simple instructions can be used to write software programs
o The stored program concept

· Figure 6.1 in page 148, describes the physical layout of LMC


o Little Man main computing engine to coordinate and control instruction execution
o Calculator arithmetic unit (add, subtract), store and display 3-digit decimal number
o Mailboxes 100 mailboxes to store 3-digit decimal numbers (instructions and data)
o Program counter stores the program counter address during program execution
o Reset button external button to restart program execution (i.e. reset the program
counter)
o In basket accept user input
o Out basket pass output to users

Operations of LMC

· LMC defines an instruction set


· The instruction set defines the basic operations that LMC is capable of performing
· Each instruction consists of:
o 3-digits number
o Left digit defines the type of operation (op code)
o Right 2 digits specifies the mailbox address or the type of I/O operation (Input or Output)

· LMC defines fixed length instruction set (3 decimal digits)


· LMC defines 3 different formats for its instruction set:
o Op code only format (e.g. 0?? – halt/stop execution - memory address is not
used)
o Memory address format (e.g. 150 – add content of mailbox 50 to calculator)
o I/O address format (e.g. 901 – read from I/O address 01 or input)

· The following is the LMC instruction set


1. Op Code Only Format instructions
1. 0 HALT stop execution

2. Memory Address Format instructions


2. 1 ADD calculator = number in calculator + specific mailbox content
3. 2 SUBTRACT calculator = number in calculator - specific mailbox content
4. 3 STORE store the number from the calculator into a specified mailbox
5. 5 LOAD load the content of the specified mailbox into the calculator
6. 6 BR Branch to the specified address (unconditional branch)
7. 7 BRZ Branch to specified address if calculator content is 0
8. 8 BRP Branch to specified address if calculator content is positive

3. I/O Address Format instructions


9. 901 INPUT accept number from the in basket and store into the calculator
10. 902 OUTPUT pass number from the calculator to the out basket

· Note: Op code 4 is not defined (may be used for future expansion of the instruction set)
· The instructions in the LMC instruction set can be divided into 5 categories
o Data movement (LOAD, STORE)
o Arithmetic calculations (ADD, SUBTRACT)
o I/O operations (INPUT, OUTPUT)
o Control operations (HALT)
o Flow control (BR, BRZ, BRP)

Program Execution Principles


· Program must be loaded into memory before it can start execution (i.e. stored program concept)
· Automatic loading is assumed
· Program is loaded starting at mailbox 00
· Data must be stored after program instructions (i.e. cannot mix instructions and data)
· Data can be stored at any mailbox after the code
· Negative numbers, as a result of a subtract operation, is handled through an internal flag
· Negative numbers can be tested but cannot be displayed or stored
· LMC executes programs using the following process:
o Little Man execute instructions one instruction at a time
o In normal execution, instructions are executed sequentially
§ Program counter is incremented to point to the next mailbox address
o In Flow Control execution, instructions can be executed arbitrary (i.e. none sequential)
§ Program counter is set to a specified mailbox address
o The HALT instruction is used to indicate end of program execution (i.e. exit program)
§ Can be placed anywhere in the program (flow control execution)
§ Should have a HALT instruction at the end of the program (i.e. last instruction)
o User can restart program execution by pressing the external reset button
Programming in the Little Man Computer
· An LMC program consists of set of instructions, from the instruction set, that are combined to
perform a certain task
· The following programming layout must be used when writing an LMC program

Mailbox Address Machine Code Assembly Code Operands Comment


00 150 ADD 50 add calculator to content of
mailbox 50
01 000 HALT stop execution

Flow Control Execution


· Instructions (BR, BRZ, BRP) make it possible to break from the default sequential execution
· Instructions of this type are used to perform conditional and loop execution in programming
· Conditional and looping are essential for writing complex programs
· Example of implementing a while loop in the LMC instruction set: WHILE value == 0 DO
00 590 LOAD 90 load content of mailbox 90 (assume it contain value to test the
loop)
01 703 BRZ 03 continue the loop if calculator content is zero
02 605 BR 05 exit loop
03 . statements inside the loop
04 600 BR 00 loop back
05 . statements after the loop

Program 1: add 2 numbers and write the result to the out basket
00 901 INPUT read 1st number from in basket and store into calculator
01 399 STORE 99 store number in calculator into mailbox 99
02 901 INPUT read 2nd number from in basket and store it into calculator
03 199 ADD 99 calculator = (calculator content + content of mailbox 99)
04 902 OUTPUT write content of calculator and put it in the out basket
05 000 HALT end execution
99 DATA mailbox contain data (1st number)

Program 2: find positive difference of 2 numbers and write the result to the out basket
· Note: this program uses mnemonics instead of full instruction name
00 901 IN read 1st number from in basket and store it into calculator
01 310 STO 10 store content of calculator (1st number) into mailbox 10
02 901 IN read 2nd number from in basket and store it into calculator
03 311 STO 11 store content of calculator (2nd number) into mailbox 11
04 210 SUB 10 calculator = calculator - number in mailbox 10 (2nd – 1st number)
05 808 BRP 08 if result is positive, already got the positive difference, so just
output
06 510 LDA 10 load content of mailbox 10 into calculator (1st number)
07 211 SUB 11 calculator = calculator - number in mailbox 11 (1st – 2nd number)
08 902 OUT write content of calculator and put it in the out basket (difference)
09 000 HLT end execution
10 DAT mailbox contain data (first number)
11 DAT mailbox contain data (second number)

The Instruction Cycle


· The instruction cycle refers to the steps taken by the Little Man to complete the execution of an
instruction
· LMC instruction cycle consists of 2 phases that must be performed sequentially
o Fetch which involves, see Figure 6.5a in page 157
§ Read program counter to identify the mailbox that contain the instruction to be executed
§ Retrieve the instruction from the mailbox
§ Decode the instruction to figure out what work to perform
o Execute which involves
§ Perform operation specified by the instruction
§ Adjust the program counter to point to the next instruction to be executed
· The fetch behavior is identical in every instruction
· The execute behavior, however, varies between the different instructions
· See Figure 6.5b in page 158 for an illustration of the execute portion of the LOAD instruction
o Little Man goes to the mailbox specified by the instruction
o Little Man retrieve number inside the specified mailbox
o Little Man type the number into the calculator
o Little Man advance Program Counter by 1
· Obviously the LOAD instruction consists of 7 steps (i.e. 3 fetch + 4 execution steps)

· The HALT instruction consists of 3 steps (i.e. 3 fetch + 0 execution steps)


o Read program counter to identify the mailbox that contain the instruction to be executed
o Retrieve the instruction from the mailbox
o Decode the instruction to figure out what work to perform
o Little Man goes to sleep
· The BR instruction consists of 4 steps (i.e. 3 fetch + 1 execution steps)
o Read program counter to identify the mailbox that contain the instruction to be executed
o Retrieve the instruction from the mailbox
o Decode the instruction to figure out what work to perform
o Little Man sets Program Counter to specified mailbox address

The LMC Emulator

· The LMC emulator is Windows based software application to emulates the LMC
· It provides capabilities for interactive and visual writing and execution of LMC programs
· In assignment 3 you will be asked to use the emulator to test your LMC programs
· Live demo…

You might also like