Question

C++ help Computer Architecture, Memory and Data Representation (a) The basic layout of memory can be...

C++ help

Computer Architecture, Memory and Data Representation

(a) The basic layout of memory can be divided into four main areas. What arethey and what are they used for?

(b) Give a short description to explain each of the following statements, including any terms used.

i. We sometimes have to defragment the heap.

ii. Local variables within a function do not need to be explicitly deleted when you return from that function.

(c) What is the decimal number 126 in binary notation? Note: the most significant bit should be on the left-hand side. Show your working.

(d) What is the decimal value of the hexadecimal number 0xFE? Show your working

0 0
Add a comment Improve this question Transcribed image text
Answer #1

(a) The four main areas of basic layout of memory in a typical C++ program are as follows :-

1. Code Segment :-

The code segment (a.k.a text segment) is the part of memory that contains machine code of the compiled C++ program. Code segment is exactly what the CPU executes. This part of memory is shareable to avoid wastage of memory since some frequently executing applications such as text editors and web browsers need this repeatedly. Also, since the code for a text editor won't change (and shouldn't too, for proper functioning), this part is usually read-only.

2. Data segment :-

This part of memory contains the static and global variables.

It is of two types ;-

1. Initialized data segment :-

Contains variables that are initialized to some fixed value.

Example :

int a = 5; // a can be assigned a different value and a is initialized to 5

2. Uninitialized data segment (BSS segment) :-

Contains variables that aren't initialized by programmer. Variables in this segment are initialized by kernel to arithmetic 0.

Example :

long b , arr[100]; // b is not assigned any value and arr is an array of 100 integers that haven't been initialized

3. Stack Segment :-

This segment holds the function caller stack - every time a function is called information is saved onto the stack segment. This information includes the address to return to along with some registers. Other things that are stored on stack segment are automatic variables.

4. Heap :-

Heap is the part of memory where dynamic allocation of memory usually happens. Heap usually grows upwards whereas the stack grows downwards

Usually the stack and heap are adjacent because if we keep code or data segment in between them, chances are heap and stack will expand and overwrite them.

Please upvote the answer if you liked it. Feel free to comment for any explanations/clarifications.

Add a comment
Know the answer?
Add Answer to:
C++ help Computer Architecture, Memory and Data Representation (a) The basic layout of memory can be...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Name: Robert Skinner Miles College CIS 330 Computer Architecture Test 1 Please, clearly show your work...

    Name: Robert Skinner Miles College CIS 330 Computer Architecture Test 1 Please, clearly show your work on the attached sheets of paper. 1. Convert the Decimal number 26 to: A. Binary number B. Hexadecimal number 2. Why is Binary data representation the preferred method of computer hardware implementation? 3. Convert 01001110 in Binary to: A. To Decimal B. To Hexadecimal 4. Convert the following Binary numbers to twos Complement A. 00011010 B 00011100 5. List at least 5 types resources...

  • Given the interpretation and the word(s), tell what characters or decimal numbers are stored in main memory by the desig...

    Given the interpretation and the word(s), tell what characters or decimal numbers are stored in main memory by the designated word(s). We assume our computer uses 8 bits for characters and 16 bits for binary integers: (show your work) Word I 1011 0010 0010 0000 Word II 0100 1001 0101 0010 1) Binary Integer - Word I 2) Character (ASCII) – Word II _____________________________________________________________________________________________________________________________________________________ For the following problems, assume that our computer uses 16 bits for binary integers. Find the...

  • 26. The is a group of bits that tells the computer to perform a specific operation...

    26. The is a group of bits that tells the computer to perform a specific operation A). program counter B). Opcode C). register D). microoperation 27. A condition called occurs in unsigned binary representation of a number when the result of an arithmetic operation is outside the range of allowable precision for the given number of bits. A). underflow B). 2's complement C). overflow D) bitwise complement 28. An iteration of the fetch-decode-execute cycle includes which of the following events?...

  • computer architecture The sum of the two 32 bit integers may not be representable in 32 bits. In this case, we say that an overflow has occurred. Write MIPS instructions that adds two numbers stor...

    computer architecture The sum of the two 32 bit integers may not be representable in 32 bits. In this case, we say that an overflow has occurred. Write MIPS instructions that adds two numbers stored in registers Ss1 and Ss2, stores the sum in register $s3, and sets register Sto to 1 if an overflow occurs and to 0 otherwise. 5. (16pts) 6. Show the IEEE 754 binary representation of the number -7.425 in a single and double 7. If...

  • 4. Translate 10*2to exactly 8-digit hexadecimal number. Answers: If the cost for all RAM chips to...

    4. Translate 10*2to exactly 8-digit hexadecimal number. Answers: If the cost for all RAM chips to utilize the maximum memory space of the MIPS architecture is SI dolloars, how much will it cost, approximately, to implement the maximum memory space of the a 64-bit computer architecture Answer: Approximately 6 billions Filli an integer. No fraction.) 6. Fill in the missing pieces of the MIPS assembly codes that translate the following C codes int A[1001. BI 1001; B12] = h +...

  • 1 to 15 blanks thank you! (1 point) For registers, Integers are encoded in one of...

    1 to 15 blanks thank you! (1 point) For registers, Integers are encoded in one of two basic types 1. and 2. (1 point) The number 201 as a one byte unsigned integer is represented as in binary and in hexadecimal. (1 point) The 2 methods for representing signed integers are 3. and (5 points) What is the 16 bit representation of -125 in 2's complement notation? 4. (5 points) What is the decimal representation of the signed integer 10000001?...

  • High-level computer languages are created to be understood by humans. As a result, the keywords and...

    High-level computer languages are created to be understood by humans. As a result, the keywords and the commands of these languages are easy to understand. Machine languages are harder to understand and operate. For this assignment, you should assume that the memory cells at addresses F0 to F9 are in the machine described in FIGURE 1, and that it contains the hexadecimal bit patterns described in the following table. Note: Each memory address contains 2 values that must be used...

  • Please help me out.. A and C Question. 5. (30 points) Consider a computer with byte...

    Please help me out.. A and C Question. 5. (30 points) Consider a computer with byte addressable main memory bytes, and the block size is 8 bytes. Assume that a direct mapping cache consisting 32 lines is used with this machine. (a) (5 points) How many bits are required to hold a memory address? (b) (5 points) How many total bytes of memory can be stored in the cache? 256 bytes (C) (10 points) How is that memory address divided...

  • Question 1: Pointers You are given the following C code and memory diagram. The “contents” column...

    Question 1: Pointers You are given the following C code and memory diagram. The “contents” column of the memory diagram shows the value of the variable. Update the “contents” column of the memory diagram for each assignment in main(). long *pt; long data;    long buffer[4]; void main(void){   pt = &buffer[1];   *pt = 1234;   data = *pt; } address      contents   variable 0x20000000 0x00000000    pt 0x20000004 0x00000000    data 0x20000008 0x00000000    buffer[0] 0x2000000C 0x00000000    buffer[1] 0x20000010 0x00000000    buffer[2] 0x20000014 0x00000000    buffer[3]...

  • C++ please Project: Working with Text Write an object-oriented program the performs the following tasks: ....

    C++ please Project: Working with Text Write an object-oriented program the performs the following tasks: . Reads a text file provided along with this data and maintains it an object. Determines the number of characters and keeps in the object. Determines the number of words and retains the result in the object. Determines the number of paragraphs and keeps the result in the object. A possible class definition: class Textutil { string text = ** int words = @; int...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT