53 lines
		
	
	
		
			No EOL
		
	
	
		
			2.7 KiB
		
	
	
	
		
			NASM
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			No EOL
		
	
	
		
			2.7 KiB
		
	
	
	
		
			NASM
		
	
	
	
	
	
; ========================================================================================
 | 
						|
; 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                          ; Branch to STOP label (infinite loop)
 | 
						|
 | 
						|
	END                             ; End of the assembly program |