Question: Translate the following C program into NASM ( 2 0 pts ) . #include int ary [ ] = { 1 2 , 4 0

Translate the following C program into NASM (20 pts).
#include
int ary[]={12,40,-2,89,35,-7,6};
int main()
{
int sum =0;
int highest =0;
for (int x =0; x <7; x++){
if (highest < ary[x])
highest = ary[x];
sum += ary[x];
}
printf("Sum is %d
", sum);
printf("Highest value is %d
", highest);
}
Use indexing (the [ebx+esi] or [ebx+edi] form). You can have several dw values on the same line. Use the loop command.
Translate the following C program into NASM. (10 pts extra credit)
#include
int main()
{
int x =0;
char sent[20];
printf("Enter sentence: ");
scanf("%[^
]s", sent);
while (sent [x]!='\0'){
if (sent[x]>='a' && sent[x]<='z')
sent[x]= sent[x] & 0xDF;
x++;
}
printf("%s
", sent);
}
Use indexing (the [ebx] form). You can use the following pseudocode in the bss to allocate the array:
slen equ 20
sent resb slen
Note: the scanf format string of %[^
]s keeps reading characters until the newline (otherwise it would end at the first space).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!