131 Week 14 - Memory Flashcards

1
Q

Cortex-M3 memory map

A

Cortex-M3 processor is a memory-mapped system.
It has a fixed linear memory map of 4 gigabytes of addressable memory space.
It has dedicated address ranges for code (code space), SRAM (memory space), external memories/devices and internal/external peripheral.

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

Cortex-M3 memory layout

A

The stack (SRAM region) stores all local variables and function arguments. The stack pointer register points at the bottom.
The heap (SRAM region) stores data allocated during runtime (e.g. malloc).
The global data (SRAM region) area stores global variables. ARM uses R9 as the static base pointer (SB).
Global contains the bss area (uninitialized global data).
The text segment (CODE region) stores the machine language program.

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

ARM ISA memory

A

ARM uses a byte-addressable memory (Each byte has a unique address)
1 word = 32 bits = 4 bytes

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

Loading from memory

A

Can load from memory using ldr the syntax:
ldr destinationRegister [baseAddress, offset]
E.g., ldr r0, [r2, #100]

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

Storing to memory

A

Can load from memory using ldr the syntax:
str sourceRegister [baseAddress, offset]
E.g., str r0, [r2, #100]

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

Storing keywords

A

Base Address: the starting address before the offset is added
Offset: the value to add to the base address to get a new address.

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

Addressing modes

A

reg+const mode: use a register and a constant to compute the read/write address. E.g., ldr r0, [r1, #20]
reg+reg mode: use the sum of 2 registers to compute the read/write address. E.g., ldr r0, [r1, r2]
reg+reg«scale: shift the second register parameter and add to the
first register, to compute the read/write address. E.g., ldr r0, [r1, r2, LSL #2]

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

Memory layout and directives

A

.bss: Contains statically allocated variables that are declared but have not been assigned a value yet.
.data: Contains initialized static variables, i.e., global variables and static local variables set to a value.
.rodata: Contains initialized static variables that constant.
.text: Contains the executable instructions

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

Data types directives

A

.word: 4-byte integer.
.byte: 1 byte integer.
.ascii: quote enclosed string.
.asciz: null-terminated string.
.fill repeat, size, value: fills memory with a repeated value of size bytes.
.zero size: fill memory with zeroes.

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

Defining data in memory

A

.region
label: .type optionalValue
where:
.region specifies the region where data is stored
label is a name to reference the data
.type is an optional data type to help the assembler to
allocate appropriate space
value is an optional value to initialize memory
E.g.,
.section .data
test1: .word 0x11223344

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

Loading a label from memory

A

Use
ldr destinationRegister, labelName
to load a label from memory into a register
E.g.,
ldr r0, =test1

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

Addressing specific memory

A

ldrb (load byte): access individual byte in memory, zero extend.
ldrsb (load signed byte): access individual byte in memory, sign extend.
strb (store byte): stores the least significant byte of the 32-bit register into the specified byte address in memory.

ldrh (load halfword): access 16-bits from memory, zero extend.
ldrsh (load signed halfword): access 16-bits in memory, sign extend.
strh (store halfword): stores the least significant 16-bits of the 32-bit register into the specified byte address in memory.

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

Extend modes for memory addressing

A

Zero extend: remaining bits are filled with zeros after loading the byte.
Sign extend remaining bits are filled with the sign bit (most significant byte).

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