From 9343c63874a90eb4113c0717d3dc97ac21cf630c Mon Sep 17 00:00:00 2001 From: aadit Date: Thu, 21 Aug 2025 12:09:24 +0530 Subject: [PATCH] Add ES/Lab/LAB5/SEARCH.asm --- ES/Lab/LAB5/SEARCH.asm | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 ES/Lab/LAB5/SEARCH.asm diff --git a/ES/Lab/LAB5/SEARCH.asm b/ES/Lab/LAB5/SEARCH.asm new file mode 100644 index 0000000..ee9a85b --- /dev/null +++ b/ES/Lab/LAB5/SEARCH.asm @@ -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 \ No newline at end of file