Question & Answer: main function in C/C++ uses the same type with a "char argv[]". Assume the foll…..

(400 pts) Cs 3843 Comporg Final Exam Name/abo 123 CiC++ Interfacing (51 pts) 1. (3 Part #2 (175 pts) 5 pts) For homework #9, we the same type with a char -argv Fr homework #9, we used an array of pointers for the wordlist. The main function in C/c++ uses n Assumethe following declaration is made in C: pass }; gwordList 【 】-{ done, huh?, final, sleep, party, -38, -success, d. (5 pts) How many bytes are used to hold the variable gWordl.ist? D (5 pts) How many bytes will the compiler use to store the characters 387 C (5 pts) How many character pointer addresses are stored in gWordList? d. (10 pts) Write the assembly instruction(s) to get the address of the word huh? into the edi register. Then, change the question mark to an explanation point ( . = 0x21). (10 pts) Given that ebx contains the address of gWordList, write the assembly code to swap the ord 38 and done. e. ts) Write functionally equivalent CIC++ code for the assembly code below. Name any parame ng with a P such as Pi, P2, etc., and local variables with a V, as in Vi, V2, etc. Does NOT nee or line translation, but rather simply the CIC++ code to accomplish the same thing. ecx, [ebp-4 ecx, [ebp+8 dx, lebp+81 ebp-121, edx Help no 1

For homework #9, we used an array of pointers for the wordlist. The main function in C/C++ uses the same type with a “char argv[]”. Assume the following declaration is made in C: char gWordList [] = { “done”, “huh?”, “final”, “sleep”, “party”, “38”, “success”, “pass” }: a. How many bytes are used to hold the variable gWordList? b. How many bytes will the compiler use to store the characters “38”? c. How many character pointer addresses are stored in gWordList? d. Write the assembly instruction(s) to get the address of the word “huh?” into the edi register. Then, change the question mark to an explanation point (‘!’ = 0 times 21). e. Given that ebx contains the address of gWordList, write the assembly code to swap the ord “38” and “done”. Write functionally equivalent CC++ code for the assembly code below. Name any parame with a P such as P_1, P_2, etc., and local variables with a V, as in V_1, V_2, etc. Does NOT need line translation, but rather simply the CC++ code to accomplish the same thing.

Expert Answer

 

1.

a.

gWordList is an array of pointers and a pointer will occupy 4 bytes, here we have

a total of 8 elements in the array hence it will take 8*4 = 32 bytes of space.

b.

A character will occupy 1 byte hence for “38” complier will take 2 bytes to store.

c.

In the list there are 8 elements hence 8 char pointers addresses are stored.

d.

mov edi, gWordList

mov eax, [edi+4]       ; this will read second element “huh?”

mov byte ptr [eax+3], 21h   ; this will replace ? with !

Still stressed from student homework?
Get quality assistance from academic writers!