Systems Architecture Flashcards
Does ARM assembly support a RISC or CISC instruction set?
RISC
What is the purpose of the CPSR?
To record anomalous arithmetic outputs
What are the flags for the CPSR?
N bit for negatives
Z bit for zero results
C bit for a carry
V bit for negatives
Which registers can the programmers us?
R0-R7
Which register should contain the output of a function?
R0
What is an unaligned transfer?
Reading 4 bytes across more than one 4 byte region
What does the stack store?
Variables and function arguments
What does the heap store?
Data allocation during runtime
What does the global data area store?
Global variables
What does BSS store?
Uninitliased global variables
What does the text segment store?
Machine code instructions
Define pipelining
A method to improve efficiency where multiple fetch-decode-execute cycles are run at the same time with each using a different component
Define program relative addressing
An addressing mode where an isntruction specifies an address relative to the current program counter
What is the effective address?
The PC + an offset
What does a compare instruction do?
Updates and evaluates the value of the bits in the CPSR and then discards them
What should we always ensure when returning from a function?
LEAVE NO TRACE
What is the first convention for writing good functions?
We should only use r0-r3 to pass parameters to functions
What do you do if you have more than 4 parameters to pass to a function?
Allocate memory from the heap to a pointer and then store those pointers in r0-r3
What does the link register store?
The return address
What should we do to the stack pointer when we call a function to ensure we have enough memory?
Decrement the value of the stack pointer so that the stack grows into the unused memory space
What is the second convention for writing good functions?
We must preserve the contents of registers
What does it mean to preserve registers?
Registers must be restored after a procedure call and if we avoid using these regsiters than we avoid register spilling
What is register spilling?
The contents of registers spilling into main memory
What is the third convention for writing good functions?
Push contents of registers to the stack before your function and pop them afterwards to restore them
How do we ensure that assembly instructions stay in place during compilation?
Compiling with no optimisation
Which command allows inline assembly and for assembly code to be embedded into c?
asm
What is a clobbered register?
A CPU register that is overwritten by the assembly code but not used as an explicit output operand in the GCC inline assembly syntax
Why are clobbered register important?
We need to explicitly tell the compiler that the contents of the register has changed otherwise it may assume the value remains the same and use it as such
What does the preprocessor do?
Deal with macros such as directives and replaces macros throughout the program
Outputs what is known as pure C code
What does the compiler do?
Transforms C into assembly code
Dependent on machine architecture
What does the assembler do?
Outputs machine code
What does the linker do?
Combines several object files together
What is the difference between dynamic and static linking?
Static linking embeds the additional functions into your program where as dynamic linking links your program with the file containing the other functions whilst keeping the two files separate
What is an exception?
Any unexpected change in the flow control
What is a synchronous exception?
Caused by an instruction in the running program and includes things like arithmetic exceptions, invalid memory addresses
What is an asynchronous exception?
Caused by an IO device requesting the CPU and is known as a hardware interrupt
What does the CPU do when it receives an interrupt?
It will create an exception interrupt which is a special function called by the CPU. It will save the current state of the CPU and then change the code execution to the exception handler to deal with the interrupt. It does this by using a vector table that contains a branch instruction to the exception handler