MIT-Curricular/ES/Lab/LAB5/SEARCH.asm
2025-08-21 12:09:24 +05:30

45 lines
No EOL
698 B
NASM

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