Tuesday, December 15, 2009

The Memory of Persistence

Tonight, I started playing with saving and loading data to/from memory.

First, I modified the startup.s since it seemed to have a 0 length heap. Again, I assume that is a place holder than anyone would modify according to their design. I set it to 100. (The SPACE directive uses bytes, not words.)

Then I set up an IMPORT statement and an EXPORT statement for Heap_Mem and used indirect addressing to store a number and load it to another register.

Here is the code:

; A Hello World type of program intended to see if I can get something to compile.
; Name: HelloWorld.s
; modifying to play with different aspects.

AREA HelloWorld, CODE, READONLY ;
EXPORT mystart ; Export this code to the project
IMPORT Heap_Mem ; This is the base of the heap.
mystart
MOV R3, #25 ; Set R3 to 25
LDR R2, = Heap_Mem ; Load memory location into R2
STR R3, [R2] ; Store contents of R3 in R2
LDR R4, [R2] ; Load contents at R2 into R3

stop
BAL stop ; gives me a loop to be caught in
END ; end.

I also did an example with an offset, just to try it out.

No comments:

Post a Comment