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

1. How many memory addresses are needed for a 32-bit word? 2. How big is the add

ID: 3679041 • Letter: 1

Question

1. How many memory addresses are needed for a 32-bit word?
2. How big is the address space of a SPARC process?
3. Where in the process address space are the executable instructions loaded?
4. Where in the process address space is the call stack?
5. What does it mean for a memory access to be aligned?
6. What section of the assembly code file contains static memory allocations?
7. What is a null-terminated ASCII string?
8. What is the largest data size that can be loaded or stored with one instruction?
9. How many instructions are necessary to load or store a 15-byte value?
10. What is the notation for the memory address used with the load and store mnemonics?
11. Why are there more load instructions than store instructions?
12. If a 32-bit word is stored to memory address 100,
what is the address of the most significant byte?
13. What single instruction will round %l0 down to the nearest multiple of 8?
14. How do you expand the stack frame to make room for local variables?
15. Given a pointer to an array and an index, give a mathematical expression for the address of
the element at that index.

Explanation / Answer

1. For 32-bit word usually allows 32-bit memory addresses; a byte-addressable 32-bit computer can address 232 = 4,294,967,296 bytes of memory, or 4 gibibytes (GiB).

2. SPARC has three different address space layouts:

3. The executable instructions loaded in secondary storage such as hard disk (HDD) as an executable image.

4. Since the call stack is organized as a stack, the caller pushes the return address onto the stack, and the called subroutine, when it finishes, pulls or pops the return address off the call stack and transfers control to that address.call stack associated with a running program .In the called subroutine, the first code executed is usually termed the subroutine prologue, since it does the necessary housekeeping before the code for the statements of the routine is begun.The prologue will commonly save the return address left in a register by the call instruction by pushing the value onto the call stack.

5. In worse case scenario unaligned memory access can be quiet expensive, in terms of CPU ticks. Luckily, hardware engineers continuously make it harder and harder to reach this scenario. Yet, at least at the moment, it is still quiet doable. Therefore, while guys at Intel breaking their heads over this problem, it is better to keep your structures well aligned in the memory. This is especially important for large data structures, because such data structures cannot utilize memory cache completely. It is also important for data structures that being rarely (relatively) used. Such data structures tend to disappear from the cache, and has to be returned into cache, each time you access them.

6. In assembly programming, a program needs to access the memory locations. All memory locations within a stack segment are relative to the starting address of the segment. A stack segment begins in an address evenly divisible by 16 or hexadecimal 10. So, the rightmost hex digit in all such memory addresses is 0, which is not generally stored in the segment registers.

7. In computer programming, a null-terminated string is a character string stored as an array containing the characters and terminated with a null character ('', called NUL in ASCII). Alternative names are C string, which refers to the C programming language and ASCIIZ (note that C strings do not imply the use of ASCII).

8. The largest data size that can be loaded or stored with one instruction is petabyte is a multiple of the unit byte for digital information ,1 PB = 1000000000000000B = 1015bytes = 1000terabytes.

10. Commercial processors use mnemonics,usually abbreviations (e.g., LD, ST, and ADD)Mnemonics differ from processor to processor.In generic assembly language with mnemonics the same instruction might actually appear as
                   BGT       R4, R5, LOOP

Mnemonics (LD/ADD instead of Load/Add) used when programming specific computers.The mnemonics represent the OP codes.Assembly language is the set of mnemonics and rules for using them to write programs.The rules constitute the language syntax

Example: suffix ‘I’ to specify immediate mode
                   ADDI   R2, R3, 5    (instead of #5)

12. In particular, suppose you had a 32-bit word denoted as B31..0. You can divide this into four bytes: B31..24, B23..16, B15..8, and B7..0. We'll call B31..24 the most significant byte, or the high byte. We'll call B7..9 the least significant byte, or the low byte.

14. A function can also declare local variables or arrays. Local variables are declared Within a function and Can be accessed only Within that function. if there are too many local variables, they can also be stored in the function's stack frame. In particular, local arrays are stored on the stack.

15. if an array of integers is stored in a region of the computer's memory starting at the memory cell with address 3000 (the base address), and each integer occupies four cells (bytes), then the elements of this array are at memory locations 3000, 3004, 3008, ..., 0x3000 + 4(n-1). In general, the address of the ith element of an array with base address b and element size s is b+is. we can write the above as *(base + i) (pointer form) or base[i] (array indexing form), which is exactly equivalent because the C standard defines the array indexing form as a transformation to pointer form. Coincidentally, since pointer addition is commutative, this allows for obscure expressions such as 3[base] which is equivalent to base[3]