0% found this document useful (0 votes)
28 views

Exp 1: Loading The Array From The Memory of One Address and Storing at Memory 0x40000000

The document describes three methods to load an array from memory and store it at a new memory location. Method 1 decrements a counter in a loop. Method 2 increments a counter in a loop. Method 3 loads and stores the entire array in one instruction without looping by using multiple load and store instructions.

Uploaded by

VAISHAKA N RAJ
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Exp 1: Loading The Array From The Memory of One Address and Storing at Memory 0x40000000

The document describes three methods to load an array from memory and store it at a new memory location. Method 1 decrements a counter in a loop. Method 2 increments a counter in a loop. Method 3 loads and stores the entire array in one instruction without looping by using multiple load and store instructions.

Uploaded by

VAISHAKA N RAJ
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Vaishaka N Raj

1RV17EI061

Exp 1: Loading the array from the memory of one address and storing at memory 0x40000000

METHOD 1: Decrement the counter

AREA MULTISTORE, CODE, READONLY


ENTRY
LDR R0, =VALUE1 ; Load the value1 values in data memory to register R0
LDR R1, =0X40000000 ; load the base address 0x40000000 to register R1
MOV R3, #05 ; assign the counter value to register R3
RETURN
LDR R2, [R0], #4 ; load the value in R0 to R2 And R0=R0+4
STR R2, [R1], #4 ; store the value in R2 to R1 and R1=R1+4
SUBS R3, #1 ; decrement R3-> R3=R3-1
BNE RETURN ; Branch to return if R3 not equal to zero
STOP B STOP
AREA VALUE1, DATA, READONLY
DCD 7,12,35,30,53 ; array of numbers
END

RESULT
BEFORE EXECUTION
AFTER EXECUTION

METHOD 2: Increment the counter

AREA MULTISTORE, CODE, READONLY


ENTRY
LDR R0, =VALUE1 ; Load the value1 values in data memory to register R0
LDR R1, =0X40000000 ; load the base address 0x40000000 to register R1
MOV R3, #0 ; assign the counter value to register R3
RETURN
LDR R2, [R0], #4 ; load the value in R0 to R2 And R0=R0+4
STR R2, [R1], #4 ; store the value in R2 to R1 and R1=R1+4
ADD R3, #1 ; increment R3-> R3=R3+1
CMP R3, #5 ; compare R3 with 5
BLT RETURN ; if R3 is less than 5 then branch to return
STOP B STOP
AREA VALUE1, DATA, READONLY
DCD 7,12,35,30,53 ; array of numbers
END
RESULT

BEFORE EXECUTION

AFTER EXECUION
METHOD 3: loading and storing the array WITHOUT LOOPING

AREA MULTISTORE, CODE, READONLY


ENTRY
LDR R0, =VALUE1 ; Load the value1 values in data memory to register R0
LDR R1, =0X40000000 ; load the base address 0x40000000 to register R1
LDMIA R0, {R6-R10} ; multiple load by incrementing after R0
STMIA R1, {R6-R10} ; multiple store by incrementing after R1
STOP B STOP
AREA VALUE1, DATA, READONLY
DCD 7,12,35,30,53 ; value of array
END

RESULT
BEFORE EXECUTION
AFTER EXECUTION

You might also like