(NASM) This is a lab about indexing an array and a string (C string with a null character at the end). Translate the following C program into NASM . int ary[] = {12, 40, -2, 89, 35, -7, 6}; int main()...





(NASM)
This is a lab about indexing an array and a string (C string with a null character at the end).




  1. Translate the following C program into
    NASM.


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 <>


              highest = ary[x];


         sum += ary[x];


     }


     printf("Sum is %d\n", sum);


     printf("Highest value is %d\n", highest);


}


Use indexing (the [ebx+esi] or [ebx+edi] form). You can have several “dw” values on the same line. Use the “loop” command.




  1. Translate the following C program into
    NASM.


int main()


{


    int x = 0;


    char sent[20];


    printf("Enter sentence: ");


    scanf("%[^\n]s", sent);


    while (sent [x] != '\0'){


        if (sent[x] >= 'a' && sent[x] <=>


            sent[x] = sent[x] & 0xDF;


        x++;


    }


    printf("%s \n", str);


}


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 “%[^\n]s” keeps reading characters until the newline (otherwise it would end at the first space).





Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here