ARMv8-A Architecture Flashcards

1
Q

Which type of Architecture is ARMv8? (RISC or CISC)

A

RISC

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

Is the ARMv8 a Load/Store Machine?

A

Yes

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

How many registers does the Register file contain?

A

Register file contains 31 64-bit registers

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

Which data is manipulated by most instructions in the registers?

A

32-bit or 64-bit data

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

What are the 2 execution states of ARMv8 architecture?

A

AArch64 and AArch32

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

What does the AArch64 execution state use?

A

Uses the A64 Instruction set and 64-bit registers

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

What does the AArch32 execution state use?

A

Uses the A32 or T32 Instruction sets (provides computability with older ARM and THUMB instruction sets using 32-bit registers)

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

What are the ARMv8’s 4 exception levels

A

EL0 - for normal user apps with limited privileges EL1 - for the OS kernel EL2 - for a Hypervisor EL3 - Low-Level firmware

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

EL0

A
  • Restricted access to a limited set of instructions and registers - Most programs work at this level
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

EL1

A
  • Privileged access to instructions, registers and memory - Accessed indirectly by user programs using system calls - Lots of System registers accessible only in EL1 and used in OS kernel code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

EL2

A
  • Support virtualization, where the computer hosts multiple guest OSs, each on its own virtual machine
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

EL3

A
  • Include the Secure Monitor
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How many General-purpose registers does AArch64 have? What are they numbered as? When using all 64 bits, use? When using only the lower-order 32 bits, use?

A

31 64-bit wide general-purpose registers Numbered from 0 to 30 x or X (eXtended) w or W (Word)

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

Register uses: x0-x7 x8 x9-x15 x16-x17

A

x0 - x7: to pass args into a procedure and return results x8: indirect result location register x9 - x15: temp registers x16 - x17: intra-procedure-call temp registers (IP0, IP1)

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

Register uses: x18 x19-x28 x29 x30

A

x18: platform register x19 - x28: callee-savee registers (value is preserved by any function you call) x29: frame pointer (FP) register x30: procedure link register (LR)

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

Special-Purpose Registers: (Use/Types)

A

Stack Pointer - Points to top of run-time stack SP: 64-bit WSP: 32-bit Zero Register - Gives 0 value when read from and discards value when written to XZR: 64-bit WZR: 32-bit Program Counter - Holds address of currently executing instruction / Can’t be accessed directly as a named register / Is changed indirectly by branch and other instructions / Is used implicitly by PC-relative load/stores PC: 64-bit

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

How many floating-point registers are there?

A

32 128-bit wide floating-point registers

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

What is an immediate value and how can it be used?

A

An immediate value (a constant) may be used as final source operand or some instructions

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

Which symbol is optional when using gcc?

A

A # symbol can prefix the immediate, but is optional when using gcc

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

How many constants are allowed

A

It depends on the particular instruction and how many bits are available within the machine instruction

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

Prefixes to prevent immediates to be assumed as decimals

A

Hexadecimal: 0x Octal: 0 Binary: 0b

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

Why use aliases?

A

mov x29, sp is alias for add x29, sp, 0 provided for readability and programmer convenience

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

Commonly used instructions

A
  • Move immediate mov Wd, #imm32 [-(2^31) to +(2^32) - 1] mov Xd, #imm64 [-(2^63) to +(2^64) - 1] - Move register mov Wd, Wm [alias for orr Wd, wzr, Wm] mov Xd, Xm [alias for orr Xd, xzr, Xm]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What is Branch and Link instruction used for? In what are args and return value?

A

To call a function (library or your own) Arguments put into x0-x7 before call Return value is in x0

25
Main routine of a program structure
26
What does .global main do?
Makes the label "main" visible to the linker The main() routine is where execution always starts
27
What does ... [sp, -16] do?
Allocates 16 bytes in stack memory (in RAM) Does this by pre-incrementing the SP register by 16
28
What does stp x29, x30, ... do?
**_St_**ores the contents of the **_p_**air of registers to the stack Saves the state of the registers used by calling code
29
What does SP do after stp?
SP points to the location in RAM where we write to
30
What does mov x29, sp do? What is the FP used as?
Updates FP to the current SP FP may be used as a base address in the routine
31
What does ldp x29, x30, ... do?
**_L_**oa**_d**_s the _**p_**airs of registers from RAM Restores the state of the FP and LR registers
32
What does the SP do after ldp?
SP points to the location in RAM where we read from
33
What does ..., [sp], 16 do?
Deallocates 16 bytes of stack memory Does so by post-incrementing SP by +16
34
What does ret do?
Returns control to calling code (in OS) Uses the address in LR
35
Addition registers/operands
1 DR, 2SO
36
Subtraction registers/operands
1 DR, 2SO
37
Multiplication registers/operands/immediates Aliases
1 DR, 2 or 3 SR No immediates allowed mul Wd, Wn, Wm Alias for madd, Wd, Wn, Wm, wzr
38
Multiply-add registers/operands
madd Wd, Wn, Wm, Wa
39
Multiply-subtract registers/operands
msub Wd, Wn, Wm, Wa Calculates: Wd = Wa – (Wn \* Wm)
40
Multiply-negate registers/operands
mneg Wd, Wn, Wm, Wa Calculates -(Wm \* Wa)
41
Division registers/operands/immediates Forms
1DR, 2SR Does **integer** division No immediates allowed Signed-form sdiv Wd, Wn, Wm Operands are signed integers Unsigned-form udiv Wd, Wn, Wm Operands are unsigned integers
42
To get remainder or Modulus, do?
numerator - (quotient \* denominator) Use msub
43
What does dividing by 0 do?
Does not generate an exception but instead writes 0 to DR
44
Printing to Standard Output
printf() Invoked with 1 or more args First is the format string (usually literal) Rest corresponds to placeholders in the string
45
What does a branch instruction do? What happens to PC?
A branch instruction transfers control to another part of the program PC is not incremented as usual but is set ot th ecomputed address of an instruction (corresponds to the value of its label) b *label* is an unconditional branch that's always taken
46
What are condition flags used for? SIze? What does 0 and 1 mean?
To store information about the result of an instruction Are single bits in the CPU 0 = false, 1 = true
47
What are the 4 condition flags and when are they true?
* Z: true if result is **_z_**ero * N: true if result is a **_n_**egative * V: true if result o**_v_**erflows * C: true if result generates a **_c_**arry out
48
How are condition flags set?
Condition flags are set by instructions that end in "s" (**_s_**et flags) e.g. sub**_s_**, add**_s_**
49
What is cmp an Alias for?
Form (64-bit): cmp Xn, Xm Is an alias for: subs wzr, Xn, Xm
50
What are *Conditional branch* instructions used for?
Conditional branch instructions use the condition flags to make a decision e.g b.eq If Z is true, branches Otherwise drops through to the following instruction
51
Diagram for signed integers b.cc where cc is the condition code
Condition codes for signed integers are
52
How are loops formed?
By branching from the bottom of the loop to the top
53
What type of loop is a do loop and its format
A do loop is a post-test loop (loop body executed at least once)
54
How can you optimize code for a pre-test loop?
Move the test to the end of the loop It reduces the loop by one instruction Branch does not use complemented logic (idk) Must branch to the test the first time though
55
How can a for loop be formed?
Convert it to a while loop
56
How can you make the If construct
Is formed by branching over the statement body if the condition is not true Uses logical complement b. lt \<-\> b.ge b. le \<-\> b.gt b. eq \<-\> b.ne
57
If-else construct
58
Using gdb debugger Start a program under debugger control Set breakpoint Run program Continue to next breakpoint Single Step ni display/i $pc p$reg q
gdb myprogram b *label* * r* * c* * si* * ni* (also executes next instruction but if a function call, proceeds until the function returns) shows current instruction when single stepping (do before running program) prints contents of register (Can append a *format* character: Signed decimal: p/d Hexadecimal: p/x Binary: p/t) q
59