Presentation is loading. Please wait.

Presentation is loading. Please wait.

ARM Memory.

Similar presentations


Presentation on theme: "ARM Memory."— Presentation transcript:

1 ARM Memory

2 Sections Programs = Code Data

3 Sections Compiled program stored in sections
.text : Executable code read/executable .rodata : Read Only Data read .data : Data read/write .bss : Uninitialized Data read/write

4 Sections Compile C++

5 Identifiers Identifier: Placed at name the next location (rest or or next line)

6 Data Directives .word X Store 32 bit value X in memory
.space X Reserve X bytes in memory

7 Sections Sections placed in memory for execution:

8 Simplified .data Things to place into memory after code .text Code

9 Same Segment Access Can place data in .text
Make sure doesn’t get executed!!!

10 Same Segment Access LDR : Load Register LDR rd, identifier
Pseudo instruction LDR rd, identifier Load value at identifier

11 Same Segment Access Fun Fact LDR :
Calculates location as currentLocation immediate C ( ) (2010)

12 Same Segment Access Fun Fact LDR :
Calculates location as currentLocation immediate ( ) C (10810) C

13 LDR Immediate LDR rd, =longConstant Puts immediate at end of .text
Automatically loads that address

14 Cross Segment Access Can not directly load identifier in other segment
May be too far

15 Cross Segment Access LDR rd, =identifier Load address of identifier

16 Cross Segment Access LDR rd, =identifier Load address of identifier

17 How It Works LDR rd, =identifier
Stores address of target at end of current .text Calculates location as current offset C ( ) (2010) Loads real address from that location

18 Cross Segment Access LDR rd, [rs]
Load value at the address stored in rs

19 Cross Segment Access LDR rd, [rs] : always second step
First load address into rs Then load data from that address

20 STR STR rs, [rd] Store value from rs to address in rd
NOTE: Reverse order of operands

21 STR Notes Process: Load address in register Store other register to that address

22 Memory Address Word = 32 bits = 4 bytes
Word addresses = multiples of 4 C = 1210 10 = 1610 14 = 2010

23 Memory Address Bytes in word numbered right to left 1000 = 64
aka “Little Endian” 1000 = 64 1001 = FF 1003 = 00 1012 = 81 +3 +2 +1 +0

24 Memory Address Bytes in word numbered right to left 1000 = 64
1005 = 89 100F = 81 1010 = 81 +11 +10 +9 +8 +15 +14 +13 +12 +3 +2 +1 +0 +7 +6 +5 +4

25 Other Memory Directives
.byte : Store 8 bit value .hword : Store 16 bit value (half-word)

26 Alignment .word should be at multiple of 4 .hword should be at multiple of 2 .byte anywhere BAD Alignment: D = 13!!!

27 Align .align : pad with 0’s until next word boundary

28 Alignment Tips Load/Store to unaligned address = silent failure!
Unneeded .align’s ignored When in doubt, .align

29 Byte Packing Byte packing : ordering class/struct members for proper alignment

30 Load/Store Bytes LDRB rd, [rs] STRB rs, [rd]
Load one byte from address rs into rd STRB rs, [rd] Store value in rs to address in rd

31 Sign Issues 34 + -1 = 289???? -1 as byte = 0xFF
0xFF as 32 bit value = 255 = 289????

32 Sign Extension LDRSB rd, [rs]
Load one byte from address rs into rd; extend sign bit

33 LDR Variants LDR rd, identifier LDR rd, [rs] LDR rd, =immediate
Load value at identifier; same section only Load value at address in rs LDR r3, [r2] LDR r1, x LDR rd, =immediate LDR rd, =identifier Put constant into .text; Load that constant Load address of identifier LDR r2, =x LDR r3, =0x1234ABCD


Download ppt "ARM Memory."

Similar presentations


Ads by Google