Write an ASM language to find sum of odd numbers in given array of 5 elements?

All QuestionsCategory: Embedded SystemWrite an ASM language to find sum of odd numbers in given array of 5 elements?
Chetan Shidling Staff asked 5 years ago

I need code.

1 Answers
Chetan Shidling Staff answered 5 years ago

Code 01:

AREA SUMODD, CODE
ENTRY
MOV R3, #0
MOV R5, #05
LDR R0,= 0X40000000
ODD LDR R2, [R0], #4
MOVS R6, R2, ROR #01
ADDCS R3, R3, R2
SUBS R5, R5, #1
BNE ODD
STOP B STOP
END

 

Code 02:

 

AREA SUMODD2, CODE
ENTRY
MOV R3, #0
MOV R5, #05
MOV R1, #00000001
LDR R0,= 0X40000000
ODD LDR R2, [R0], #4
MOV R6, R2
AND R8, R1, R6
MOVS R8, R8, LSR#1
ADDCS R3, R3, R2
SUBS R5, R5, #1
BNE ODD
STOP B STOP
END