Appendix A Flashcards
Instruction set architectures classification
By internal storage:
- accumulator architecture - operands are implicitly in accumulator
- stack architecture - operands are implicitly on top of the stack
- general-purpose register architecture - only explicit operands
By accessing memory and registers:
- register-memory architecture - any instruction can access memory
- load-store architecture - load and store instructions to access memory
- memory-memory architecture - not used anymore, all operands in memory
One special type is also extended accumulator or special-purpose register computers - more registers than just accumulator
Currently mostly used are general purpose register architectures - registers are faster than memories.
How many registers are sufficient?
Depends on the effectivity of the compiler, some compilers allocate GP registers for different purposes such as expression evaluation (e.g. x86 stores the result of the 8-bit division in AL and modulus in AH).
Types of GPR architectures
By number of operands:
- 2 operand format - one operand is both source and destination of the operation
- 3 operand format - one result operand, two src operands
By number of memory operands:
- multiple different amounts - from all three to none
Memory access types
byte - 8 bits
half word -16 bits
words - 32 bits
double words - 64 bits
Byte ordering
Big Endian - highest bits are in the end - 0,1,2,3,4,5,6,7
Little Endian - lowest bits are in the end - 7,6,5,4,3,2,1,0
Memory alignment
Used for accesses higher than byte - memory is then aligned by the module operation where address if address mod access size => s = 0 (e.g. for word access address 0 and 4 is aligned and address such as 2, or 6 is misaligned access
Addrsessing modes
Acutal address is called effective address
Modes:
- register - value is in register
- immidiate - constants, operand is actual value
- displacement - memory[constant + regValue]
- register indirect - memory[regValue]
- indexed - memory[reg1Value + reg2Value]
- direct/absolute - memory[constant]
- memory indirect - memory[memory[regValue]]
- autoincrement/autodecrement - memory[regValue = regValue + d/regValue = regValue - d]
- scaled - memory[constant + reg1Value + reg2Value*d]
regValue - value in register
reg1Value, reg2Value - multiple registers value
d - displacement
constant - constant value
Types of operands
character - 8 bits
half word - 16 bits
word - 32 bits
single-precision floating-point - 32 bits
double-precision floating-point - 64 bits
Decimal operands
- packed and binary coded decimals - 4 bits encode 0 - 9 and 2 digits are packed in each byte
- numeric character strings - unpacked decimals
- used to precisely repersent decimals which are difficult to represent in binary (e.g. 0.1)
Operations in instruction sets
- Arithmetic and logic operations - e.g. add, subtract, multiply, divide, or, and
- Data transfer - load-store
- Control - branch, jump, etc.
- System - operating system call, virtual memory management
- Floating point - floating point operations - add, subtract, multiply, divide…
- Decimal - decimal add, decimal multiply, decimal to character conversions
- String - string move, string compare
- Graphics - pixel and vertex operations
Control flow instructions types
conditional branches
jumps
procedure calls
procedure returns
Adddressing modes for control flow
- PC-relative - adding displacement to program counter (PC)
- position independent
- instructions don`t need to be fully loaded
- usually smaller jumps
Register indirect jumps - when jump address is unknown at compilation time - case or switch statements
- virtual functions or methods
- higher-order functions or function pointers
- dynamically shared libraries
They all usually load jump address from memory
Condition branch options
- Condition code - tests special bits set by ALU operations, possibly under program control
- Condition register/limited comparison - tests arbitrary register with the result of a simple comparison
- Compare and branch - Compare is part of the branch
Procedure invocation - saving processor state
Storing the whole processor state in other registers (older architectures). Using load and store operations to store processor`s state (newer architectures).
Caller saving vs. Callee saving
In caller saving calling procedure is responsible to save the state of the processor.
In callee saving called procedure is responsible for saving the state of the processor.
Encoding instructions - considerations
- desire to have as many registers and addressing modes as possible
- impact of the register and addressing modes on the average instruction size and average program size
- instructions encoded into lengths that are easy to handle in a pipelined implementation.