Lecture 2 - ARM Assembly and Input/Output Flashcards
What is an immediate value?
A value that is not stored anywhere, but rather a part of the instruction itself
Why can immediate values only be 8 bits?
When looking at the instruction format, the operand 2 field contains bits for immediate value. However, these are only 8 bits and therefor sets the constraint
What does the ARM Assembly function bl do?
First sets Link Register (r14) to PC + 4.
PC is the address of the current instruction, in this case the bl instruction itself.
PC+ 4 corresponds to the sequentially next instructions, as each instructions are 32 bits.
Then the bl instruction sets the PC to the label provided with the bl instruction.
In ARM Assembly, what happens when you need to return from a function
Need to move LR to PC,LR remembers where the function was called from.
In ARM Assembly, what are callee registers?
r4 - r12 are defined as callee saved registers.
If a called function needs to write to any of these registers, it first needs to save these values. And before it returns to the callee function, it needs to restore the values to these registers.
In ARM Assembly language, what are caller saved registers?
r0-r3 are defined as caller registers.
parameters are passed in r0-r3.
return values are stored in r0 and r1.
If the caller wants to preserve the values of these registers after a function call, it needs to save these values before the fundtion call, and restore them afterwards.
How does the stack operate?
Last-in-First-out
Stack pointer (r13, SP) always points to the last occupied position in the stack
Stack grows downwards.
Push and pop are special instructions to operate on the stack. SP moves automatically with these
pop from stack does not remove values, just moves the stack pointer upwards
Content of stack, growing downwards:
- parameters
- caller context
- return address
- local vars
What is CISC?
Complex Instruction Set Computer.
Also known as register-memory architectures
appeared in early computers (i.e. x86)
Computers mostly programmed in assembly - assembly instructions close to what HLL now provide
Few registers - operands in memory, instructions were allowed to operate directly in memory
memory was limited, instructions were of variable length because of this
What are the two categories of ISAs?
CISC and RISC
What is RISC
Reduced Instruction Set Architecture.
load-store architectures
Appeared in the 80’s
HLL and compilers were already well developed. Because of this the instructions could remain simple
More registers and memory, faster clock.
Because of this fixed length/format instructions were implemented for easy and fast decoding
Name four properties of I/O devices?
Device (Mouse, keyboard, network)
Behaviour (Input, output, both, storage)
Partner (human, machine)
Data rate (Mbit / sec)
What is an IO controller?
Connects the I/Odevice and the CPU
contains a data- and a status registers.
Different IO devices connects to different IO controllers through different interfaces (video, USB, PCIe)
What does the data register in the IO controller contain
For input devices: Holds data read from device
For output devices: Holds data that needs to be written to the device
What does the status register in the IO controller contain
status of read/write operation
How is IO devices addressed?
Memory mapped I/O
Isolated I/O space
What is memory mapped I/O?
I/O controller registers are mapped to dedicated portion of memory
Upside: can use regular load/store ops for this
Downside: eats up memory space