Grade 12 Please join Google Classroom : yoho9gv
Fetch - Decode - Execute - Store Cycle
Link to Little Man Computer Click Here
Type in these example instructions to that will add 2 numbers: INP, STA 99, INP, ADD 99, OUT, HLT
The instructions are held in RAM / Memory
The instruction register holds the instruction code example 3 to store the address register holds the address to store what is held in the accumulator.
First of all, type in the following code in the LMC as shown in the animation in order to see how it works
INP
STA 20
OUT
HLT
Where is the input stored?
Where are the program instructions stored?
The same can be achieved the following way too - specifying a variable - A in this case - without specifying a particular memory cell.
INP
STA A
OUT
HLT
A DAT
Here is the code to subtract 2 numbers , try it out
INP
STA A
INP
STA B
LDA A
SUB B
OUT
HLT
A DAT
B DAT
Activity Challenge - I will be marking Question 1 below Only , please answer using google classroom
- 1accept 3 numbers as input and output the sum
- 2Accept 2 numbers ( assume first number is > than second number input , output the difference
Little Man Computer references
Numeric code | Mnemonic code | Instruction | Description |
1xx | ADD | ADD | Add the value stored in mailbox xx to whatever value is currently on the accumulator (calculator). Note: the contents of the mailbox are not changed, and the actions of the accumulator (calculator) are not defined for add instructions that cause sums larger than 3 digits. |
2xx | SUB | SUBTRACT | Subtract the value stored in mailbox xx from whatever value is currently on the accumulator (calculator). Note: the contents of the mailbox are not changed, and the actions of the accumulator are not defined for subtract instructions that cause negative results - however, a negative flag will be set so that 8xx (BRP) can be used properly. |
3xx | STA | STORE | Store the contents of the accumulator in mailbox xx (destructive). Note: the contents of the accumulator (calculator) are not changed (non-destructive), but contents of mailbox are replaced regardless of what was in there (destructive) |
5xx | LDA | LOAD | Load the value from mailbox xx (non-destructive) and enter it in the accumulator (destructive). |
6xx | BRA | BRANCH(unconditional) | Set the program counter to the given address (value xx). That is, value xx will be the next instruction executed. |
7xx | BRZ | BRANCH IF ZERO (conditional) | If the accumulator (calculator) contains the value 000, set the program counter to the value xx. Otherwise, do nothing. Note: since the program is stored in memory, data and program instructions all have the same address/location format. |
8xx | BRP | BRANCH IF POSITIVE (conditional) | If the accumulator (calculator) is 0 or positive, set the program counter to the value xx. Otherwise, do nothing. Note: since the program is stored in memory, data and program instructions all have the same address/location format. |
901 | INP | INPUT | Go to the INBOX, fetch the value from the user, and put it in the accumulator (calculator) Note: this will overwrite whatever value was in the accumulator (destructive) |
902 | OUT | OUTPUT | Copy the value from the accumulator (calculator) to the OUTBOX. Note: the contents of the accumulator are not changed (non-destructive). |
0 | HLT | HALT | Stop working. |
DAT | DATA | This is an assembler instruction which simply loads the value into the next available mailbox. DAT can also be used in conjunction with labels to declare variables. For example, DAT 984 will store the value 984 into a mailbox. |
Collection of activities and exercises
Pseudo code problem solving click here
Pseudo code problem solving advanced click here
Pseudo code Collections click here
Pseudo code Collections exercise ( teacher cities ) click here
Pseudo code advanced teacher votes print out requirement click here
Analyse program presented as a flow chart click here
Program efficiency click here
Activities Find the error in the code and BIG O efficiency in loops click here
Logic Gates Half Adder click here
Logic Gates applying to PHP and create code based on log conditions click here
Working with 2D arrays click here
(4.2.9) Iterations and absolute value click here
Nested Loops and PHP click here
Instruction cycle with exercise click here
architecture of the central processing unit click here
2D arrays advanced click here
Searching with video click here
Sorting click here
Web Science Activities
Online interaction crowd funding. wiki google maps alternatives click here
Internet Future Quest Click here