Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1, Given the following piece of C code: char * str \"abcd\". Suppose str points

ID: 3606854 • Letter: 1

Question

1, Given the following piece of C code: char * str "abcd". Suppose str points to memory address Ox50. Show what values are laid out in memory from memory address 0x50 to 0x54 after the code runs. Additionally, explain why a character needs a byte of memory. 2. Explain how you would concatenate a C-string input2 to the end of another C-string input1 in assembly. You do not need to provide code. Assume enough memory has been allocated to accommodate the length of the new string, and the starting address of the new string is the same as the starting address of input1 3. Explain what information a function nceds to preserve as the callec

Explanation / Answer

0x50 a

0x51 b

0x52 c

0x53 d

0x54 null

It is a standard that char takes 1 byte of memory because probably when we can store binary representation of a char into 1 byte of memory.
Also when C was developed, ASCII and EBC standards were available which require 7bit andd 8bit encoding respectively and could easily be stored in 1byte.


In this case we need to append string 2 to string 1. Since we enough memory block with input 1 to store input 2, content of input2 is stored in input 1 memory block just after the contents of input1 enand then after content of input 2 end we have a null.

When a function is called 2 parties are involved i.e Caller and Callee. Caller calls the calle, which is the function called, but callee does not have any information about the section of code which called it. It just knows that it has been called and after performation all the required operations on the arguments passed by caller it returns the results and passes the control to caller.