comm
This commit is contained in:
parent
c37a788cbd
commit
dbabb956d5
16 changed files with 1319 additions and 426 deletions
|
@ -1,20 +1,53 @@
|
|||
AREA RESET,DATA,READONLY
|
||||
EXPORT __Vectors
|
||||
__Vectors
|
||||
DCD 0x10001000 ;
|
||||
DCD Reset_Handler ;
|
||||
ALIGN
|
||||
AREA mycode, CODE, READONLY
|
||||
ENTRY
|
||||
EXPORT Reset_Handler
|
||||
Reset_Handler
|
||||
MOV R0,#10
|
||||
MOV R1, #0x10
|
||||
MOV R3, #2_1010
|
||||
MOV R4, #5_34
|
||||
MOV R5, #-8
|
||||
|
||||
; ========================================================================================
|
||||
; DATATRANSFER.asm - Basic Data Transfer Operations Demonstration
|
||||
; ========================================================================================
|
||||
; This program demonstrates various ways to transfer immediate data into ARM registers
|
||||
; using different number formats (decimal, hexadecimal, binary, and negative values).
|
||||
; The program loads different types of immediate values into registers R0-R5 to show
|
||||
; the flexibility of ARM's MOV instruction for data transfer operations.
|
||||
|
||||
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 starts here
|
||||
; Step 1: Load decimal immediate value
|
||||
; MOV instruction transfers immediate data (value 10) into register R0
|
||||
; This demonstrates basic decimal number loading
|
||||
MOV R0,#10 ; R0 = 10 (decimal)
|
||||
|
||||
; Step 2: Load hexadecimal immediate value
|
||||
; Load hexadecimal value 0x10 (16 decimal) into register R1
|
||||
; Shows how hexadecimal values are represented in assembly
|
||||
MOV R1, #0x10 ; R1 = 0x10 (16 decimal)
|
||||
|
||||
; Step 3: Load binary immediate value
|
||||
; Load binary value 1010 (which equals 10 decimal) into register R3
|
||||
; The '2_' prefix indicates binary notation in ARM assembly
|
||||
MOV R3, #2_1010 ; R3 = 2_1010 (10 decimal in binary)
|
||||
|
||||
; Step 4: Load another decimal immediate value
|
||||
; Load decimal value 34 into register R4
|
||||
; The '5_' prefix indicates decimal notation (though redundant here)
|
||||
MOV R4, #5_34 ; R4 = 34 (decimal)
|
||||
|
||||
; Step 5: Load negative immediate value
|
||||
; Load negative value -8 into register R5
|
||||
; Demonstrates how negative numbers are handled in immediate loads
|
||||
MOV R5, #-8 ; R5 = -8 (negative value)
|
||||
|
||||
; Step 6: Program termination
|
||||
; Create an infinite loop to stop program execution
|
||||
; This prevents the processor from executing undefined instructions
|
||||
STOP
|
||||
B STOP
|
||||
|
||||
END;
|
||||
B STOP ; Branch to STOP label (infinite loop)
|
||||
|
||||
END ; End of the assembly program
|
|
@ -1,25 +1,60 @@
|
|||
AREA RESET,DATA,READONLY
|
||||
EXPORT __Vectors
|
||||
; ========================================================================================
|
||||
; 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.
|
||||
|
||||
__Vectors
|
||||
DCD 0x10001000
|
||||
DCD Reset_Handler
|
||||
ALIGN
|
||||
AREA mycode,CODE,READONLY
|
||||
ENTRY
|
||||
EXPORT Reset_Handler
|
||||
|
||||
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
|
||||
LDR R0, =SRC ; gives memory address of SRC array
|
||||
LDR R1, [R0] ; writes from first location of SRC array
|
||||
MOV R5, -8;
|
||||
|
||||
; 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
|
||||
ALIGN;
|
||||
|
||||
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 ; End of the assembly program
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue