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.

Scenario:

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.)

Assignment:

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
a. D0000
b. D0B10
c. 011B0
d. D000

3. The absolute/physical address of the fourth instruction above is
a. D01BA
b. 0B18
c. 0D000
d. D0B18

4. The offset address of the fourth instruction above is
a. 0B10
b. 0B18
c. D01B8
d. D01BA

5. The absolute/physical address of the sum is
a. 0B800
b. 0A900
c. DA800
d. B8000

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
a. 1111
b. 11110
c. 11C20
d. 11B11

8. The absolute/physical address of the fourth instruction above is

a. 11C28
b. 1C21
c. 0B18
d. 11110

9. The offset address of the fourth instruction above is
a. 1C210
b. 11C28
c. 1C21
d. 0B18

10. The absolute/physical address of the sum is
a. 339A8
b. 0A800
c. 33950
d. A8000

11. If the first instruction lies at absolute/physical address 44440, then the code segment register contains
a. 4344
b. 4393
c. 4440
d. 4444

12. If the second addend is at absolute/physical address 76541, then the data segment register contains
a. 7265
b. 6541
c. 7654
d. 7254