2_Memory ARM and program generation

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/115

encourage image

There's no tags or description

Looks like no tags are added yet.

116 Terms

1
New cards

What is von Neumann (Princeton) memory architecture?

Instructions and data use a shared memory system/path.

2
New cards

What is a main drawback of von Neumann architecture?

Instruction fetch and data access can compete for the same path.

3
New cards

What is Harvard memory architecture?

Separate instruction and data memory paths.

4
New cards

Why can Harvard architecture improve throughput?

Instruction fetch and data access can occur simultaneously.

5
New cards

What is the distinction between memory contents and paths?

Data/instructions are contents; buses/access paths determine simultaneous access.

6
New cards

How many visible general registers are listed for ARM Cortex-M?

R0 through R15: 16 registers, each 32 bits wide.

7
New cards

What do R0–R7 represent?

Low general-purpose registers.

8
New cards

What do R8–R12 represent?

High general-purpose registers.

9
New cards

What is R13?

Stack pointer (SP).

10
New cards

What does the stack pointer indicate?

The current top-of-stack location in memory.

11
New cards

What is R14?

Link register (LR), holding return information for calls.

12
New cards

What is R15?

Program counter (PC), used to track instruction execution.

13
New cards

What are the main ARM instruction categories in the notes?

Data processing, memory operations, control flow, and other/system instructions.

14
New cards

Name arithmetic operations mentioned.

ADD, ADC, SUB, MUL, and DIV.

15
New cards

What does ADD do?

Adds operands.

16
New cards

What does ADC do in ARM?

Adds operands together with the carry flag.

17
New cards

What does SUB do?

Subtracts one operand from another.

18
New cards

What do MUL and DIV do?

Multiply and divide operands.

19
New cards

What do shift instructions do?

Shift bits left or right.

20
New cards

Name ARM shift types in the notes.

LSL, LSR, ASR, and rotate.

21
New cards

How does LSL work?

Logical left shift; bits shift left and zeros fill the right.

22
New cards

How does LSR work?

Logical right shift; zeros fill the left.

23
New cards

How does ASR work?

Arithmetic right shift; sign bit is replicated.

24
New cards

What is a rotate operation?

Bits shifted out on one end reenter at the other.

25
New cards

Name bitwise Boolean instructions.

AND, ORR, EOR, BIC, and NOT/MVN.

26
New cards

What does AND do?

Sets a result bit only if both corresponding input bits are 1.

27
New cards

What does ORR do?

Sets a result bit if either input bit is 1.

28
New cards

What does EOR do?

Exclusive OR; result bit is 1 when the input bits differ.

29
New cards

What does BIC do?

Clears selected bits using a bitwise AND with an inverted mask.

30
New cards

What does CMP do?

Compares operands by subtraction and updates flags without storing the result.

31
New cards

What does CMN do?

Compares via addition and updates flags.

32
New cards

What does TST do?

Bitwise AND test that updates flags without storing a result.

33
New cards

What byte manipulation operations are mentioned?

Byte reversal (REV/REV16) and sign/zero extension.

34
New cards

What do SXTB and SXTH do?

Sign-extend a byte or halfword into a register.

35
New cards

What do UXTB and UXTH do?

Zero-extend a byte or halfword into a register.

36
New cards

What is an opcode?

The instruction field specifying the operation.

37
New cards

What is an operand?

A value, register, or location used by an instruction.

38
New cards

What is an immediate operand?

A constant encoded within the instruction.

39
New cards

What is a register operand?

A value sourced from or placed in a CPU register.

40
New cards

What are the two Thumb instruction lengths noted?

16-bit and 32-bit encodings.

41
New cards

Why use mixed 16/32-bit instruction lengths?

Balance compact code with more capable instruction encodings.

42
New cards

What tradeoff comes with 16-bit instruction encoding?

Compact code but fewer bits for operands/operations.

43
New cards

What tradeoff comes with 32-bit instruction encoding?

More encoding capacity but greater code size per instruction.

44
New cards

How can a Thumb decoder distinguish instruction lengths?

It examines leading bits of the instruction halfword.

45
New cards

What happens in a conditional branch?

Execution changes address only if a flag condition is satisfied.

46
New cards

What does B do?

Branches to another instruction address.

47
New cards

What does BL do?

Branches with link to call a function and saves return information in LR.

48
New cards

What does BX do?

Branches to the address held in a register.

49
New cards

What does BLX do?

Branches with link using a register/target, depending on encoding.

50
New cards

Name conditional branches in the notes.

BEQ, BNE, CBZ, and CBNZ.

51
New cards

What does BEQ test?

Equal/zero condition flag (Z = 1).

52
New cards

What does BNE test?

Not-equal/zero flag clear (Z = 0).

53
New cards

What does CBZ do?

Branches if the tested register contains zero.

54
New cards

What does CBNZ do?

Branches if the tested register is nonzero.

55
New cards

How does a function commonly return on Cortex-M?

Branch to the saved return address, commonly with BX LR.

56
New cards

What does LDR do?

Loads a value from memory into a register.

57
New cards

What does STR do?

Stores a register value into memory.

58
New cards

What does PUSH do?

Saves selected registers onto the stack.

59
New cards

What does POP do?

Restores selected registers from the stack.

60
New cards

What does LIFO mean?

Last in, first out: newest saved item is removed first.

61
New cards

What is the stack?

A region of RAM used for calls, saved registers, and local data.

62
New cards

How is stack storage managed?

Typically automatically by generated code using SP adjustments.

63
New cards

What happens to SP on a common descending Cortex-M stack push?

It decreases as data is pushed.

64
New cards

What happens to SP on a corresponding pop?

It increases as data is removed.

65
New cards

What is register-direct addressing?

The operand value is in a named register.

66
New cards

What is immediate addressing?

The operand value is encoded in the instruction.

67
New cards

What is register-indirect memory addressing?

A register contains the memory address to access.

68
New cards

What is direct memory addressing (conceptually)?

The instruction specifies a memory address directly.

69
New cards

What is indirect memory addressing (conceptually)?

A stored pointer/address is used to locate the operand.

70
New cards

What is the stack's role in a function call?

Preserves return information, registers, and local variables as needed.

71
New cards

Why must SP be updated when reserving stack space?

So subsequent stack use does not overwrite active local data.

72
New cards

What is wrong with writing to [SP,#-4] without reserving space?

The write may be outside allocated stack space and be overwritten.

73
New cards

Why must saved registers be restored?

To preserve caller-visible state required by the calling convention.

74
New cards

What is the heap?

A RAM region for dynamically allocated objects.

75
New cards

How is the heap typically managed in C?

Explicit allocation with functions such as malloc and free.

76
New cards

How are stack and heap allocation different?

Stack is tied to function scope; heap allocation persists until freed.

77
New cards

What is heap memory useful for?

Data whose required size or lifetime is decided at runtime.

78
New cards

What can happen if heap memory is never freed?

Memory leakage and eventual exhaustion.

79
New cards

What is the first source-language stage of program creation?

Write source code, e.g., C.

80
New cards

What does the compiler do?

Translates high-level source into target assembly or machine-level code.

81
New cards

What does the assembler do?

Translates assembly instructions into machine code in object files.

82
New cards

What is an object file?

Compiled code/data that may still contain unresolved references.

83
New cards

What does .o typically represent?

A relocatable object file.

84
New cards

What is a relocatable object?

Code/data not yet assigned all final memory addresses.

85
New cards

What does a linker do?

Combines object files/libraries and resolves symbols and references.

86
New cards

Why are libraries provided to the linker?

To supply reusable compiled code or data.

87
New cards

What is an ELF file?

An executable and linkable file format containing code/data plus metadata.

88
New cards

Is .text a separate file extension?

No; .text is a section inside ELF/object files.

89
New cards

What is the .text section?

Executable program instructions, usually stored in flash.

90
New cards

What is the .data section?

Initialized writable variables, used in RAM at runtime.

91
New cards

Where are initial .data values kept before startup?

Typically in the firmware image in flash.

92
New cards

What does startup code do with .data?

Copies initial values from flash to RAM.

93
New cards

What is the .bss section?

Zero-initialized or uninitialized writable variables in RAM.

94
New cards

What happens to .bss during startup?

It is normally zeroed before main executes.

95
New cards

What is the .rodata section?

Read-only constant data, commonly stored in flash.

96
New cards

Why don't .data and .bss mean extra ELF files?

They are named sections within one file.

97
New cards

What is a linker command file/script?

Rules describing how sections are placed in memory regions.

98
New cards

What does a locator do in this workflow?

Assigns addresses to linked sections according to memory layout rules.

99
New cards

What is memory mapping at link time?

Choosing addresses/regions for code, constants, and variables.

100
New cards

What physical constraints influence memory mapping?

RAM/flash sizes, memory speeds, permissions, and CPU architecture.