0% found this document useful (0 votes)
200 views6 pages

Little Minion Computer Notes (Student Copy)

The document describes the Little Minion Computer, a conceptual model of a CPU introduced by Dr. Stuart Madnick. The model uses a minion, calculator, mailboxes, and trays to illustrate how a CPU works. It captures important features like the fetch-execute cycle in an accessible way. Various instructions like LOAD, ADD, SUBTRACT, and INPUT/OUTPUT are defined. Examples show the minion carrying out programs by executing the instructions stored in the mailboxes. The model helps explain concepts like stored program computing.

Uploaded by

jscansino
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)
200 views6 pages

Little Minion Computer Notes (Student Copy)

The document describes the Little Minion Computer, a conceptual model of a CPU introduced by Dr. Stuart Madnick. The model uses a minion, calculator, mailboxes, and trays to illustrate how a CPU works. It captures important features like the fetch-execute cycle in an accessible way. Various instructions like LOAD, ADD, SUBTRACT, and INPUT/OUTPUT are defined. Examples show the minion carrying out programs by executing the instructions stored in the mailboxes. The model helps explain concepts like stored program computing.

Uploaded by

jscansino
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/ 6

School of Engineering

and Computing Sciences


Little Minion Computer
The Little Minion Computer is a conceptual model of a simple CPU, introduced by Dr. Stuart
Madnick of M.I.T. in 1965. Although it seems simplistic, in fact the model captures many important
features of a real CPU and illustrates these in an accessible way.

The Little Minion Computer


The conceit is that inside the CPU is a tiny person or minion that runs around organising data and
performing the calculations. Inside the box of the CPU are:

• 100 numbered mailboxes


• A calculator
• A 2-digit counter
• An in-tray
• An out-tray

Calculator

Little Minion

In-tray
Mailboxes
Out-tray

Counter
The mailboxes each have a 2-digit address, so 100 mailboxes is the limit, counting from 00 to 99.
Each mailbox contains a slip of paper with 3 digits on it, and can only ever contain a single slip of
paper at a time.
The calculator that can only display 3 digits on the screen, and has buttons for numbers 0-9 and +
and - . It also has an LED that lights up when a larger number is subtracted from a smaller number.
This LED is known as the negative flag.
The 2-digit counter has two buttons: the first button increments the counter by 1, the second
(external) button resets the counter to 00.
The input and output trays can each contain stack of slips of paper, each of which has 3-digits
on. The user can put slips of paper with 3 digits on in the input tray, to be read when the little
minion next looks at the in tray. Likewise the little minion can write 3-digit notes and put them in the
out tray, to be read by the user.
The Fetch-Execute cycle

Or what the little minion does…

1. The little minion starts by looking at the counter for number, which is a mailbox number.
2. The minion increments the counter, so that next time the minion comes it will be one larger.
3. The minion goes to the mailbox with the number the minion read on the counter, and reads
what is written on the slip of paper in the mailbox, i.e. 3 digits.
4. The minion takes the appropriate action depending on those digits
5. The minion then starts again…

Steps 1-3 are the fetch: the little minion is fetching an instruction. Step 4 is the execute: the little
minion does the indicated instruction.

The instructions:
The little minion will read a 3-digit message in the mailbox the minion is sent to, e.g. 5 8 4, which is
the minion's instruction. The first digit of the instruction is the operation: 5. The second and third
digits give another mailbox number: 84. The operation part is also known as an “operation code”
or “op code”, the other two numbers are an address. Op code 5 is load: the little minion goes to
the mailbox indicated by the address, copies what is on the slip of paper in the mailbox, then goes
to the calculator and enters that number. E.g. if mailbox 84 contained 1 2 3, then when the little
minion reads instruction 584, the minion goes to mailbox 84, copies down 123, then goes to the
calculator and enters 123.

Let’s define some more op codes and give the little minion a task.

ADD – op code 1
go to the mailbox address specified, read the 3-digit number at that address, then go to the
calculator and add the number to the number already on the calculator.
SUBTRACT – op code 2
go to the mailbox address specified, read the 3-digit number at that address, then go to the
calculator and subtract the number from the number already on the calculator.
Note: the mailboxes will still contain the same 3-digit messages as before, but the calculator
will have changed. If the subtracted number is larger than the value already in the calculator
(i.e. the subtraction ends with a negative value), then the negative flag is set/activated and
the value in the calculator cannot be trusted to be right.
STORE – op code 3
go to the calculator and note the 3-digit number displayed, then go to mailbox address
specified and enter that number on a new slip of paper.
Note: the calculator will still contain the same 3-digits as before, but the mailbox will have
whatever was there before discarded.
LOAD – op code 5
go to the mailbox address specified, read the 3-digit number at that address, then go to the
calculator and enter that number in.
INPUT/OUTPUT – op code 9
INPUT or READ op code 9 address 01
go to the IN tray, read the 3-digit number there, then go to the calculator and enter the
number in.
Note: The slip of paper in the IN tray with the 3-digits is removed. If there are several slips in
the IN tray, the little minion takes the first one that was put there only, the others remain for
future visits.
OUTPUT or PRINT op code 9 address 02
go to the calculator, read the 3-digit number there, then go to the OUT tray and leave a slip of
paper with that number on it.
BREAK – op code 0
The little minion stops and has a rest.
A program

When the Little Minion Computer is started, the counter is reset to Mailbox Contents
00, and the mailboxes will already contain some values, so the little
minion starts by visiting mailbox 00 and executing the instruction 00 901
there. What the minion does after that depends on the instructions! 01 306
02 901
Look at the initial mailbox contents given to the right. What will the
little minion do? What does this achieve? 03 106
04 902
• The minion first gets an input and puts it in the calculator 05 000
• Then the minion stores that in mailbox 06
• The minion gets another input (into the calculator) 06 000
• Then adds the contents of mailbox 06 to the value in the 07 000
calculator
08 000
• Next the minion takes the calculator value and copies it to the
output tray 09 000
• Finally (instruction in mailbox 05), the minion halts.
The total effect of this is to take two numbers from input and
output the addition of those two numbers.

Mailbox 06 is used there as a temporary storage for a value, since it is empty and unused by the
program. Why didn’t we use mailbox 05, the first 000 value mailbox?

• Although mailbox 05 looks empty, it is in fact the instruction 000, i.e. HALT. If we used mailbox
05 to store the temporary value, then whatever we stored would be read as an instruction once
the little minion finished with the instruction in 04.
• Change the program to have 305 in mailbox 01 and 105 in mailbox 03, then see what happens
(e.g. on inputs 300 and 301).
• So the LMC does not distinguish between data and program instructions! This is central to the
concept of stored program computing.

Exercises

Enter values in the mailboxes so that when the Little Minion starts (with counter at 00)
• The minion takes 3 inputs values and then outputs the sum of all of them
• The minion takes two input values, a and b, and outputs the difference, a - b.
• What happens if you subtract something large from something small? E.g. 350 from 100

Mailbox Contents Mailbox Contents


00 901 00 901
01 309 01 306
02 901 02 901
03 109 03 206
04 309 04 902
05 901 05 000
06 109 06 000
07 902 07 000
08 000 08 000
09 000 09 000

If you subtract something large from something small then the negative flag is activated
and the value outputted is wrong.
More instructions

The instructions so far can be grouped into categories as follows:

Data movement:
LOAD – op code 5
STORE – op code 3

Arithmetic:
ADD – op code 1
SUBTRACT – op code 2

Input/Output:
INPUT – op code 901
OUTPUT – op code 902

Machine control:
BREAK – op code 0

To get the Little Minion to do more powerful calculations, we need to have more control over the
machine and in particular the flow of the program - i.e. which instructions the minion does when.
We do this with branch instructions.

BRANCH – op code 6
set the counter to the 2-digits specified in the address.
Note: The next instruction the minion reads is the one in the mailbox address specified.

To have even greater control we allow two more complex branch instructions: conditional branch
instructions.

BRANCH on ZERO – op code 7


go to the calculator and read the 3-digit number. If it is zero, set the counter to the 2-digits
specified in the address, otherwise do nothing.

BRANCH on POSITIVE – op code 8


go to the calculator and check the negative flag. If it is not activated, set the counter to the 2-
digits specified in the address, otherwise do nothing.

Now we can construct simple loops:


Mailbox
Mailbox code
code Description
Description
value = INPUT 00 901
901 INPUT
INPUTvalue
value
do while value >=0 01 902 OUTPUT
902 OUTPUT
print value
value -- 02
02 299
209 SUBTRACT
SUBTRACT11
next 03
03 705
705 BRZ
BRZ
end 04
04 601
601 BRANCH
BRANCH
05
05 902
902 OUTPUT
OUTPUT
06
06 000
000 STOP
STOP
07 000
07 000
08 000
08 000
09 001 DATA - 1
09 001 DATA - 1
And we can test conditions. What does this program do?

Mailbox Contents
• The program takes two inputs and stores them in boxes 11 and 00 901
12. 01 311
• It then subtracts.
• If the subtraction gives something positive, the program 02 901
branches to 08, where it loads the first number and outputs it. 03 312
• If the subtraction triggers the negative flag, the program does not 04 211
branch, so it loads the second number and outputs it.
05 808
• The effect is to output the smaller of the two inputted numbers.
06 512
07 609
08 511
09 902
10 000

Exercise

Enter values in the mailboxes so that when the Little Minion starts (with counter at 00)
• The minion takes 2 inputs values, a and b, and then outputs all integers between the
two inputs.
• First assume a < b. Then try and get it to work for inputs either way round.

Mailbox Contents Mailbox Contents


00 901 10 215
01 314 11 713
02 901 12 606
03 315 13 000
04 514 14 000
05 902 15 000
06 514 16 001
07 116 17 000
08 902 18 000
09 314 19 000

Inputs either way round left as an exercise!

Machine code and assembly language


This style of coding is called machine code, since we are programming directly in the code the
Little Minion understands. The first step towards making things easier for the programmer is to use
assembly language - human readable mnemonics for the machine code. Since we are now going
to write our code as a list of mnemonics without reference to specific mailboxes, we shall also label
lines of code that we might want to branch to. So each line of our assembly code will have:
• a label (possibly blank),
• an operation given as a mnemonic, and
• an address, given as a label (possibly blank)
Here is an example of assembly code for the program to add two numbers and output the result:

IN
STO A
IN
ADD A
OUT
HLT
A DAT

Note that each line starts with a label or a tab, then has a mnemonic, then if the interaction needs
an address, has another tab and an address label. We give this text to a special program called a
compiler that will turn it into machine code and fill suitable mailboxes with the result. There is a
compiler in the Little Minion Simulator.

Mnemonic op code Description


ADD 1xx Add
SUB 2xx Subtract
STO 3xx Store
LDA 5xx Load
BR 6xx Branch
BRZ 7xx Branch on zero
BRP 8xx Branch on positive
IN 901 Input
OUT 902 Output
HLT 000 Halt or Stop
DAT Data storage location

Further Exercises
1. Give assembly code for your earlier programs, e.g. the one to output all numbers between two
input values.
2. Create a Little Minion Computer program to output the Fibonacci numbers. Look up Fibonacci
numbers online if you are not familiar with them.
3. Create a Little Minion Computer program to output the first ‘n’ Fibonacci numbers. Your
program should take the input n and then output the first n elements of the sequence. I.e. 1, 1,
2, 3, 5…
4. Create a Little Minion Computer program to take two inputs a, b and compute a × b.
5. Create a Little Minion Computer program to an input a and compute a divided by 2.
6. Create a Little Minion Computer program to take two inputs a, b and compute a divided by b.
7. Create a Little Minion Computer program to take inputs until an input of 0 is received, then
output the sum of the inputs.
8. Create a Little Minion Computer program to take inputs until an input of 0 is received, then
output the smallest of the inputs.
9. Create a Little Minion Computer program to take two inputs and output the highest common
factor (look up Euclid's algorithm).

These notes are based on the description of the Little Man Computer found in the book: The
Architecture of Computer Hardware and System Software: An Information Technology Approach,
3rd edition, by Irv Englander.

You might also like