;Salwa Fayyad AREA RESET,DATA ,READONLY EXPORT __Vectors;DEFINITION __Vectors DCD 0X20001000 DCD Reset_Handler X EQU 0XA ; define x =10 ALIGN Num DCB 7,4,6,5,1,5,9,2,3,2 ; the number AREA MYCODE,CODE,READONLY ENTRY EXPORT Reset_Handler Reset_Handler LDR R0,=Num MOV R1,#10; the index MOV R9,#0; sum loopCount LDRB R2,[R0]; ldrb each number CMP R2,#0; compare if the number is ended BEQ countDone ; chexk if the number is end MUL R3,R2,R1 ; multiply the number and their index ADD R9,R3; the sum of the equation SUB R1,#1 ;decrease the index ADD R0,R0,#1 ; increment index to the next number CMP R1,#1 ; we want index to 2 BEQ countDone ; branch if equal B loopCount; loop ending countDone ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; to find the firsh index LDR R4,=Num MOV R5,#10 loop LDRB R8,[R4] CMP R8,#0 BEQ count SUB R5,#1 ADD R4,R4,#1 CMP R5,#0 BEQ count B loop count ;;;;; R8 is the first index ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;; divide the number by 11 MOV R11,#11 MOV R6,#0 L1 CMP R9,R11 ; compare if the sum less than 11 BLO F SUB R9 ,R9,R11 ; sum the sum 11 ADD R6,R6,#1 MOV R10 ,#11 ; R10=11 SUB R10,R9 ; sub the mod result by 11 B L1 F CMP R8,R10 ; compare check sum , if the first index equal the result or not BEQ check ; Branch if equal MOV R7,#0 ; if false set R7 =0 B FINISH ;end the program check MOV R7 ,#1 ; if true set R7=1 FINISH B FINISH ; end the program END