In: Computer Science
#define count
int8_t arrayInt8[COUNT] = {111, 52, 16, 100, 90};
arrayInt8[2] = 0;
arrayInt8[3] = -1;
arrayInt8[4] = -120;
printf("Question 6, countNegative: Correct answer = 2\n");
printf("Question 6, countNegative: Student answer = %u\n\n", countNegative(arrayInt8, COUNT));
I need the arm assembly code for this.
ARM PROGRAM :-
.LC1:
.ascii "Question 6, countNegative: Correct answer = 2\000"
.LC2:
.ascii "Question 6, countNegative: Student answer = %u\012\012"
.ascii "\000"
.LC0:
.byte 111
.byte 52
.byte 16
.byte 100
.byte 90
main:
push {fp, lr}
add fp, sp, #4
sub sp, sp, #8
ldr r2, .L2
sub r3, fp, #12
ldm r2, {r0, r1}
str r0, [r3]
add r3, r3, #4
strb r1, [r3]
mov r3, #0
strb r3, [fp, #-10]
mvn r3, #0
strb r3, [fp, #-9]
mvn r3, #119
strb r3, [fp, #-8]
ldr r0, .L2+4
bl puts
sub r3, fp, #12
mov r1, #5
mov r0, r3
bl countNegative
mov r3, r0
mov r1, r3
ldr r0, .L2+8
bl printf
nop
sub sp, fp, #4
pop {fp, lr}
bx lr
.L2:
.word .LC0
.word .LC1
.word .LC2
Respective C program :-
#include <stdint.h>
#define COUNT 5
void main()
{
int8_t arrayInt8[COUNT] = {111, 52, 16, 100, 90};
arrayInt8[2] = 0;
arrayInt8[3] = -1;
arrayInt8[4] = -120;
printf("Question 6, countNegative: Correct answer = 2\n");
printf("Question 6, countNegative: Student answer = %u\n\n", countNegative(arrayInt8, COUNT));
}