; ======================================================================================== ; DATATRANSFER.asm - Memory-Based Data Transfer Operations Demonstration ; ======================================================================================== ; This program demonstrates how to transfer data from memory locations to registers ; using ARM load instructions. It shows the difference between loading an address ; and loading the actual data stored at that address. AREA RESET,DATA,READONLY ; Define a read-only data section for the vector table EXPORT __Vectors ; Export the vector table for external linking __Vectors ; Start of the vector table DCD 0x10001000 ; Stack pointer initial value (points to top of stack) DCD Reset_Handler ; Address of the reset handler (program entry point) ALIGN ; Ensure proper alignment for the next section AREA mycode,CODE,READONLY ; Define the code section as read-only ENTRY ; Mark the entry point of the program EXPORT Reset_Handler ; Export the reset handler function ; ======================================================================================== ; Reset_Handler - Main program execution ; ======================================================================================== ; This function demonstrates memory data transfer operations: ; 1. Load the address of a data array into a register ; 2. Load the actual data from that memory location ; 3. Load an immediate negative value for comparison Reset_Handler ; Step 1: Load memory address into register ; LDR with = syntax loads the address of the SRC array into R0 ; This gives us a pointer to the beginning of the data array LDR R0, =SRC ; R0 = address of SRC array ; Step 2: Load data from memory location ; LDR with [] syntax loads the actual data stored at the address in R0 ; This reads the first 32-bit word from the SRC array (0x12345678) LDR R1, [R0] ; R1 = data at address in R0 (first element of SRC) ; Step 3: Load immediate negative value ; MOV instruction loads the immediate negative value -8 into R5 ; This demonstrates mixing memory loads with immediate loads MOV R5, -8 ; R5 = -8 (immediate negative value) ; Step 4: Program termination ; Create an infinite loop to stop program execution STOP B STOP ; Branch to STOP label (infinite loop) ALIGN ; Ensure proper alignment for data section ; ======================================================================================== ; Data Section - Source data array ; ======================================================================================== ; SRC array contains three 32-bit words in hexadecimal format: ; - First word: 0x12345678 (305419896 in decimal) ; - Second word: 0xABCDEF55 (2882400341 in decimal) ; - Third word: 0x55 (85 in decimal) SRC DCD 0x12345678, 0xABCDEF55, 0x55 END ; End of the assembly program