Lecture 2 - ARM Assembly and Input/Output Flashcards

1
Q

What is an immediate value?

A

A value that is not stored anywhere, but rather a part of the instruction itself

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why can immediate values only be 8 bits?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does the ARM Assembly function bl do?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

In ARM Assembly, what happens when you need to return from a function

A

Need to move LR to PC,LR remembers where the function was called from.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

In ARM Assembly, what are callee registers?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

In ARM Assembly language, what are caller saved registers?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How does the stack operate?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is CISC?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the two categories of ISAs?

A

CISC and RISC

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is RISC

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Name four properties of I/O devices?

A

Device (Mouse, keyboard, network)

Behaviour (Input, output, both, storage)

Partner (human, machine)

Data rate (Mbit / sec)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is an IO controller?

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does the data register in the IO controller contain

A

For input devices: Holds data read from device

For output devices: Holds data that needs to be written to the device

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does the status register in the IO controller contain

A

status of read/write operation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How is IO devices addressed?

A

Memory mapped I/O
Isolated I/O space

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is memory mapped I/O?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is isolated I/O space?

A

I/O devices are in a completely seperate memory space.

One memory address can both belong to a space in memory and an I/O device

Because of this, seperate instructions are used to communicate with these addresses to differentiate when you are communicating with memory or when you are communicating with I/O

18
Q

What are the methods the CPU uses to determine if an I/O device is ready for data transfer?

A

Polling (busy-wait I/O)
Interrupt

19
Q

What is polling (busy-wait I/O)?

A

CPU monitors I/O continuously to see if it’s ready.

This wastes CPU time, but makes CPU react fast when ready

20
Q

What are interrupts?

A

The I/O controller sends an interrupt signal to the CPU when the device is ready

Slow response from CPU as CPU must finish what it was doing before it can handle the interrupt

Better CPU utilization as CPU resources are not wasted

21
Q

What happens on an interrupt?

A

I/O controller sends an interrupt signal to the CPU

The CPU saves the address of the current instruction (saves state to be able to continue later on)

Jump to interrupt handler

Handle interrupt (service the I/O device, preserve registers)

Return to foregroung program. There is a special instruction to return from interrupt handler.

22
Q

How do you connect more I/O devices to an CPU than there are ports on the CPU?

A

Connect I/O devices together through OR-gates.
When doing this, the CPU must poll each device to see where an interrupt signal came from.

Can use an interrupt controller that arbitrates CPU access amoung devices

23
Q

What are the 2 methods of finding the correct interrupt handler?

A

1: Jump to predefined address. Use cause of interrupt (device id) to specify the right handler

2: Vector interrupts: Directly branch to a specific handler based on device.

24
Q

What is an vector interrupt table

A

A table that contains information of where the interrupt handler is for each possible interrupt

25
Q

What happens when multiple interrupts come at the same time?

A

Interrupts have a priority. A high priority is handled before a low one. If an interrupt is being handled when a new one comes, it will continue with the current interrupt if the new one has lower priority. If the new one has higher priority it will interrupt the handler and start handling the new one. When finished, the old one is continued.

26
Q

What does a priority registry store?

A

The priority of the interrupt currently being executed

27
Q

What does it mean when the CPU masks an interrupt?

A

When the CPU is doing something important, the CPU won’t be informed that an interrupt has occured of lower priority

28
Q

What are NMIs and what do they do?

A

NMI’s, or non-maskable interrupts are interrupts that are used when accessing important resources from the CPU

29
Q

Name everything that happens when an interrupt is raised

A

I/O: raises interrupt

CPU: Checks pending interrupts every cycle. Acknowledges the highest priority interrupt

I/O device: Sends its interrupt vector number to the CPU on receiving acknowledgement

CPU: Saves state (PC, registers), jumps to handler

Software: Performs required I/O operation, might need to save additional CPU state

CPU: Restores state and PC and returns to previous execution

30
Q

Compare exceptions and interrupts

A

Similar:
- cause CPU to break out of execution
- Handled the same way as interrupts
- Vectored and prioritized

Differences:
- Raised by internal error during program execution
- Caused by invalid condition, illegal memory access, …

31
Q

What are traps

A

Traps are explicitly generated and requested by programmer.
Generated by special instructions.
Not raised because of errors, as exceptions are.

Used to request OS services

32
Q

What is a Bus?

A

Collection of wires running between components

It is also the protocol that determine how two devices communicate

33
Q

Name 3 bus signals

A

Address bus: n wires that specifies an address, often unidirectional going from the CPU to memory.

Data bus: n wires that carry data, bidirectional

Control bus: wires to implement bus protocol (read/write, interrupts). Often bidirectional but most individual wires (control signals within the bus) are unidirectional.

34
Q

How does communication happen over a bus? (4 stage handshake protocol)

A

When two devices communicate, one will send a request and the other answers with an ack.

Device 1 raises an enquiry signal.
Device 2 sends the 2 when ready to listen
Data transfer happens.
When the data transfer is finished, one device lowers its signal.
The other terminates operation.

35
Q

What is an asynchronous bus?

A

Events can happen at any time

36
Q

How does read and write happen on a synchronous bus?

A

Events are synchronized with a clock signal.
Events can only happen on the rising or the lower edge of the clock.

37
Q

What are wait states?

A

When devices are not able to provide data at the next clock cycle, there are cycles where there are no activity.These are wait states.

38
Q

What are burst transfers?

A

When more data is provided than can be transported in one cycle on the bus.
When this happens one request is sent, and the data is transfered during the next cycles until all data has been transferred.

39
Q

What is direct memory access?

A

When data is transferred directly to memory without involving the CPU.

A component named the DMA controller, which is much simpler than the CPU,
will instead handle this data transfer.

During this, the memory bus won’t be accessible to the CPU which in the meantime only can do computations on data in registers and caches. If the CPU is dependent on memory that is not in caches, it waits for the memory bus to be available.

40
Q

How can we reduce CPU wait cycles when memory bus is taken by the DMA?

A

Limit data (just a few words) in the DMA transaction before giving control back to the CPU that checks if it need any memory.
The DMA will request the bus back using the Bus request signal. CPU gives DMA access by enabling bus grant signal.