Memory Segmentation Calculation Exercise
Below are 12 questions pertaining to the scenario described. Please submit answers to them onto the remote Unix machine using these preparation and submittal instructions.
This assignment requires you to perform hexadecimal arithmetric and to visualize segments within larger memory. You may find it useful to draw diagrams of the memory locations discussed in the scenario, and to use a hexadecimal calculator. Such calculators can be found on the web (see link on main page or "View" Microsoft's in "scientific" mode Start/Programs/Accessories/Calculator). The calculations can be done by the "shift and add" method described in Two-part Addresses and Memory Segmentation.
Suppose a program in a 16-bit computer contains a sequence of machine language instructions for adding two numbers. All instructions in this program are found in the code segment of memory, while all data it manipulates are found in the data segment.
The "code segment" is defined by the value stored in the code segment register of the CPU. That 16-bit value positions the start of the segment at some point in memory. The segment itself then consists of the ensuing 64K bytes. The data segment, similarly, is defined by whatever value is stored in the data segment register of the CPU.
The code that adds the numbers is a sequence of 4 instructions. They instruct the following, respectively:
- get the first addend from memory and put it into a CPU register
- get the second addend from memory and put it into another CPU register
- add what's in those 2 registers (leaving the sum in a CPU register)
- put the sum into memory
These instructions (including any operands) occupy 2 bytes each, except for the 3rd one which occupies 4 bytes (machine language instructions can be of different lengths).
The program refers to the addresses of these instructions and data. It refers to the first instruction as 0B10H. This is intended as an offset address. It is the location of the first of the instruction's 2 bytes. And the program refers to the addresses of the addends as 4000H and 4001H respectively, and to the target location reserved for the sum as A800H. (The "H" at the end of an address indicates that it is a hexadecimal number, so it can't be confused with its decimal or other counterpart.)
If the code segment register contains D000H and the data segment register contains 0100H,
1. In memory, the fourth instruction is a) above or b) below the first addend. (Visualize the whole memory; visualize the 2 segments within it. "Above/below" means numerically so; 1 is below 2, 9FFF is below A888.)
2. The absolute/physical address of the first instruction above is
3. The absolute/physical address of the fourth instruction above is
4. The offset address of the fourth instruction above is
5. The absolute/physical address of the sum is
Now if instead the code segment register contains 1111H and the data segment register contains 2915H,
6. In memory, the fourth instruction is a) above or b) below the first addend.
7. The absolute/physical address of the first instruction above is
8. The absolute/physical address of the fourth instruction above is
9. The offset address of the fourth instruction above is
10. The absolute/physical address of the sum is
11. If the first instruction lies at absolute/physical address 44440, then
the code segment register contains
12. If the second addend is at absolute/physical address 76541, then the data
segment register contains