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
Q

Main routine of a program structure

A
26
Q

What does .global main do?

A

Makes the label “main” visible to the linker

The main() routine is where execution always starts

27
Q

What does … [sp, -16] do?

A

Allocates 16 bytes in stack memory (in RAM)

Does this by pre-incrementing the SP register by 16

28
Q

What does stp x29, x30, … do?

A

Stores the contents of the pair of registers to the stack

Saves the state of the registers used by calling code

29
Q

What does SP do after stp?

A

SP points to the location in RAM where we write to

30
Q

What does mov x29, sp do?

What is the FP used as?

A

Updates FP to the current SP

FP may be used as a base address in the routine

31
Q

What does ldp x29, x30, … do?

A

Loa_d_s the _p_airs of registers from RAM

Restores the state of the FP and LR registers

32
Q

What does the SP do after ldp?

A

SP points to the location in RAM where we read from

33
Q

What does …, [sp], 16 do?

A

Deallocates 16 bytes of stack memory

Does so by post-incrementing SP by +16

34
Q

What does ret do?

A

Returns control to calling code (in OS)

Uses the address in LR

35
Q

Addition registers/operands

A

1 DR, 2SO

36
Q

Subtraction registers/operands

A

1 DR, 2SO

37
Q

Multiplication registers/operands/immediates

Aliases

A

1 DR, 2 or 3 SR

No immediates allowed

mul Wd, Wn, Wm
Alias for
madd, Wd, Wn, Wm, wzr

38
Q

Multiply-add registers/operands

A

madd Wd, Wn, Wm, Wa

39
Q

Multiply-subtract registers/operands

A

msub Wd, Wn, Wm, Wa

Calculates: Wd = Wa – (Wn * Wm)

40
Q

Multiply-negate registers/operands

A

mneg Wd, Wn, Wm, Wa

Calculates -(Wm * Wa)

41
Q

Division registers/operands/immediates

Forms

A

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
Q

To get remainder or Modulus, do?

A

numerator - (quotient * denominator)

Use msub

43
Q

What does dividing by 0 do?

A

Does not generate an exception but instead writes 0 to DR

44
Q

Printing to Standard Output

A

printf()

Invoked with 1 or more args

First is the format string (usually literal)

Rest corresponds to placeholders in the string

45
Q

What does a branch instruction do?

What happens to PC?

A

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
Q

What are condition flags used for?

SIze?

What does 0 and 1 mean?

A

To store information about the result of an instruction

Are single bits in the CPU

0 = false, 1 = true

47
Q

What are the 4 condition flags and when are they true?

A
  • Z: true if result is zero
  • N: true if result is a negative
  • V: true if result overflows
  • C: true if result generates a carry out
48
Q

How are condition flags set?

A

Condition flags are set by instructions that end in “s” (set flags)

e.g. subs, adds

49
Q

What is cmp an Alias for?

A

Form (64-bit): cmp Xn, Xm
Is an alias for: subs wzr, Xn, Xm

50
Q

What are Conditional branch instructions used for?

A

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
Q

Diagram for signed integers

b.cc where cc is the condition code

A

Condition codes for signed integers are

52
Q

How are loops formed?

A

By branching from the bottom of the loop to the top

53
Q

What type of loop is a do loop and its format

A

A do loop is a post-test loop (loop body executed at least once)

54
Q

How can you optimize code for a pre-test loop?

A

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
Q

How can a for loop be formed?

A

Convert it to a while loop

56
Q

How can you make the If construct

A

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
Q

If-else construct

A
58
Q

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

A

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
Q
A