CS2002 Flashcards
Fetch-Execute Cycle
- Load data from the IP 2. Set the ip to the next instruction 3. Control unit decodes the instruction 4. ALU executes the instruction 5. Some instr may change the pointer to something else
ISA
Set of instructions understood by a CPU -
- Their encoding into bits
- Their meaning
imulq $86, (%rax), %rcx
- imul: signed integer multiplication
- imulq: qword or quadword= 64 bit
- $86: Constant 86
- %rax, %rcx : registers
- anything inside brackets, is basically just derefencing
- Compiler
- Interpreter
- Assembler
- Linker
- Loader
- Compiler: converts high level instructions to low level instructions which the CPU can understand
- Interpreter: Program that reads high level programmes and carries it out
- Assembler: Converts assembly language to object code, think of it as compilers for lower level languages.
- Linker: Combines object code files to create an executable file that can run by including different library object code files and determining memory offsets for functions in different files.
- Loader: Loads all the libraries into memory and prepares them for execution
List the different kinds of registers
- GP registers: Stores one word and are used in integer operations, typically a small number, e.g. x86 which has 16 registers
- Floating point registers:
- Special registers: IP a.k.a program counters
Orthogonality of ISAs
When ISA doesn’t distinguish between different registers. What can be done with one register can be done with any other registers. Each instruction performs a unique task that doesn’t overlap with another instruction.
ARM is orthogonal
Uses of Conventions
They help structure writing assembly code
- Not writing values immediately to registers
ISA Design decisions for where arguments can be loaded and stored
- Register-memory: Atleast one argument can come straight from memory
- More expensive.
- Load store: All arguments are directly from the memory, register - register
- Memory is accessed only to load data into the registers
- Separation of memory and arithmetic operations make design easier.
Word Addressed
One address for one word and there is extra info to refer to the bytes inside the word
Byte Addressed
One address per octet ( 8 bits ) and the lowest address in a word represents the address of the word.
How does ISA allow memory access or what are the different memory addressing modes?
- Immediate mode
- Direct mode
- Indirect mode
- Index mode
- Immediate Memory Access Modes
- Direct Mode
Immediate Mode: The value is specified in the instruction itself, used for constants.
Direct Mode: The value is stored at a fixed address. Used for global variables.
- Indirect Memory access Mode
- Index mode
Indirect mode: The value is stored in a fixed address which is specified inside a register. Extra power(check)
Index Mode: The value is at a fixed address specified by register but is offset by an index.
Register Naming
Stackframes
The stack frame is the collection of all data on the stack associated with the function call like the arguments to the function and the return address