Add ES/Lab/LAB5/SEARCH.asm
This commit is contained in:
		
							parent
							
								
									8b43ad81ed
								
							
						
					
					
						commit
						9343c63874
					
				
					 1 changed files with 45 additions and 0 deletions
				
			
		
							
								
								
									
										45
									
								
								ES/Lab/LAB5/SEARCH.asm
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								ES/Lab/LAB5/SEARCH.asm
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,45 @@
 | 
			
		|||
	AREA RESET, DATA, READONLY
 | 
			
		||||
	EXPORT __Vectors
 | 
			
		||||
__Vectors
 | 
			
		||||
	DCD 0x10001000
 | 
			
		||||
	DCD Reset_Handler
 | 
			
		||||
	ALIGN
 | 
			
		||||
 | 
			
		||||
	AREA MYCODE, CODE, READONLY
 | 
			
		||||
	ENTRY
 | 
			
		||||
	EXPORT Reset_Handler
 | 
			
		||||
 | 
			
		||||
Reset_Handler
 | 
			
		||||
	MOV    R5, #8
 | 
			
		||||
	LDR    R0, =SRC
 | 
			
		||||
	LDR    R2, =target
 | 
			
		||||
	LDR    R7, [R2]
 | 
			
		||||
	LDR    R3, =result
 | 
			
		||||
	LDR    R8, =found_addr
 | 
			
		||||
	MOV    R4, #0
 | 
			
		||||
	STR    R4, [R3]
 | 
			
		||||
	STR    R4, [R8]
 | 
			
		||||
loop
 | 
			
		||||
	LDR    R1, [R0], #4
 | 
			
		||||
	CMP    R1, R7
 | 
			
		||||
	BEQ    found
 | 
			
		||||
	SUBS   R5, R5, #1
 | 
			
		||||
	BNE    loop
 | 
			
		||||
	B      STOP
 | 
			
		||||
found
 | 
			
		||||
	MOV    R4, #1
 | 
			
		||||
	STR    R4, [R3]
 | 
			
		||||
	SUB    R6, R0, #4
 | 
			
		||||
	STR    R6, [R8]
 | 
			
		||||
STOP
 | 
			
		||||
	B      STOP
 | 
			
		||||
 | 
			
		||||
	AREA CONSTS, DATA, READONLY
 | 
			
		||||
SRC        DCD 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0x1, 0x2
 | 
			
		||||
target     DCD 0x1
 | 
			
		||||
 | 
			
		||||
	AREA DATA1, DATA, READWRITE
 | 
			
		||||
result     DCD 0
 | 
			
		||||
found_addr DCD 0
 | 
			
		||||
 | 
			
		||||
	END
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue