Computer Architecture Example |
CSE 410 Fall 98 |
Memory
There is a memory of 1000 locations, numbered from 0 to 999. Each location is capable of holding a
number. Since instructions are numbers, each location is also capable of holding an instruction.
Processor Registers
The processor contains the following special locations, called registers.
- The accumulator, where all arithmetic operations take place.
- The program counter, (also called the PC), which contains the location number of the next
instruction to be executed.
- The instructor register, which contains the instruction being currently executed.
Instructions
Each instruction consists of a 1-digit opcode followed by a three-digit location number, also called the
address. There are 9 opcodes, listed below.
Opcode | Mnemonic | Description | Notes |
0 | halt | Halt the computer | (address is ignored) |
1 | load | Load from location | accum<-location |
2 | store | Store to location | location<-accum |
3 | add | Add | accum<-accum+location |
4 | sub | Substract | accum<-accum-location |
5 | mul | Multiply | accum<-accum*location |
6 | div | Divide | accum<-accum/location |
7 | br | Branch to address | pc<-address |
8 | brpos | Branch if accum>0 | if (accum>0) pc<-address |
Example: compute y=x*x+4*x-5
10: 1100 accum <- x
11: 5100 accum <- x*x
12: 2019 temporary <- x*x
13: 1100 accum <- x
14: 5020 accum <- 4*x
15: 4021 accum <- 4*x-5
16: 3019 accum <- x*x+4*x-5
17: 2101 y <- accum
18: 0000 halt
19: 0000 (temporary location)
20: 0004 (constant 4)
21: 0005 (constant 5)