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


Warning: Trying to access array offset on false in /home3/indiakep/public_html/wp-content/plugins/dw-question-answer/inc/Template.php on line 8
All QuestionsCategory: Embedded SystemWrite an ASM program to find sum of negative numbers in an array?
Chetan Shidling Staff asked 6 years ago

I need code.

1 Answers
Chetan Shidling Staff answered 6 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