Write an ASM program to find sum of negative numbers in an array?

All QuestionsCategory: Embedded SystemWrite an ASM program to find sum of negative numbers in an array?
Chetan Shidling Staff asked 5 years ago

I need code.

1 Answers
Chetan Shidling Staff answered 5 years ago

Code 01:

AREA NEGATIVESUM, CODE
ENTRY
LDR R0,= 0X40000000
MOV R5, #05
MOV R6, #00
NEG LDR R2, [R0], #4
MOV R3, R2
MOVS R2, R2, LSL #1
ADDCS R6, R6, R3
SUBS R5, R5, #1
BNE NEG
STOP B STOP
END

Code 02:

AREA NEG_SUM, CODE
ENTRY
LDR R0,= 0X40000000
MOV R5, #5
MOV R3, #00
MOV R6, #0Xffffffff
NEG LDR R7, [R0], #4
MOV R8, R7
AND R11, R6, R7
MOVS R11, R11, LSL #1
ADDCS R9, R9, R8
SUBS R5, R5, #1
BNE NEG
STOP B STOP
END