computer architecture pt2 Flashcards
FDE cycle
CPU sends value of PC to be copied to MAR
PC increments
get instruction identified by MAR and copy into MDR
move instruction from MDR to IR
move instruction from IR to CU for decoding:
-sends operation to ALU
-put address of data to be operated on in a register
-send address of data from register to MAR
-read data and place in MDR
-move data from MDR to an accumulator in the ALU
-complete operation and store result in an accumulator in the ALU
uses of alternative addressing modes
- addressing large amount of memory with few bits
- use indexes to loop or examine a table or array
- address registers (bc faster than addressing memory)
- relocate data or programs in memory
direct addressing
the address used is the address holding the data to be operated on
immediate addressing
the address read in the instruction is the data to be used (e.g. for constants like 1)
indirect addressing *
the address used is the address of the memory location holding the address of the data item to be operated on
register indirect addressing
the address read in the instruction is the address of the register holding the data item to be operated on
indexed addressing @
the address in the instruction has an index (stored in a register) which is added to obtain the address of the data
impure code
when instructions are changed during execution
changed instructions have to be reset before being run again else program will run differently
full instruction structure
opcode + addressing mode + address 1 + address 2
absolute addressing
the address read is the address that should be gone to
relative addressing
the address read in the instruction is an offset to the current instruction address (i.e. program counter value)
base offset addressing
the address read in the instruction is offset by the current value in a special base register
type of instructions
Single operand manipulation: negating, inc/decrementing, setting reg = 0
Arithmetic: floating point, add/sub/div/multiplication
Program control: branching, call, jumps, return
Boolean logic: shift/rotate, bit manipulation- allowing the design of own flags so controlling program flow. inc set/test instructions
Data movement: between registers, reg+memory + memory locations
Stack: pop/push in a LIFO structure
Multiple data, single instruction: multimedia- single instruction on a large amount of date e.g. pixels
MIPS principles
- simplicity favours regularity
- makes the common case faster
- smaller is faster
- good design demands good compromises
1.simplicity favours regularity
consistent instruction format with same number of operands- 2 sources + 1 destination- : easier to encode + handle in hardware
- makes common case faster
only includes simple, commonly used instructions
for complex operations, use more instructions
results in simpler, smaller, faster hardware
(RISC)
- smaller is faster
few registers used
- good design demands good compromises
more instruction formats = more flexibility
number of instruction formats kept small to adhere to principle 1 + 3
other formats may appear in assembler but transformed in machine code to fit format
3 instruction formats
- R type: register operands
- I type: immediate operand
- J type: jumping
r-type instruction formats
opcode (6 bits, 0 for r-type), rs, rt (source registers, 5 bits), rd (destination register, 5 bits), shamt (shift amount, 5 bits, 0 if not shift operation), func (function, operation to be done, 6 bits)
register field values: shift bits in register 17 left 5 places and put in in register 16
opcode = 0 rs = 0 rt = 17 rd = 16 shamt = 5 func = 0
i-type instruction formats
opcode (6 bits), rs, rt (source registers, 5 bits), imm (16 bit twos complement immediate)
rt is used as a destination for some instructions e.g. addi
addi $s0, $s1, 5
(immediate type) add the value in register 17, and the number 5, and place in register 16
lw $t2, 32($0)
load word at address 32+ contents of register 0, and store in register 10
sw $s1, 4($t1)
store word in register 17 at address 4+ contents of register 9
li $s0, 5
aka ori $s0, $0, 5
(immediate type) load immediate 5 and store in register 16
in machine code, swap round $0 and $s0