
ARCHITECTURE AND INSTRUCTIONS
The need for an assumption about DS is that some
The assembler needs to know which segment registers (if any) will contain MY_ DATA's starting address, at the time these instructions are executed. With this information, the assembler can determine if a
SUMMARY
So, why assume some segment register would contain MY_DATA's starting address at
PORTS3AND 4
Line 6 specifies that PORT_VAL is equiva- lent to the constant 3. This permits PORT_ VAL to be used in place of 3 on succeeding lines. This makes PORT_VAL a symbolic name for port 3 and refers to PORT_VAL whenever port 3 is wanted. Now if we decide
to rewrite the program to use port 4 instead, we need make only one change: line 6 is changed to:
The instructions on lines 7 through 17 will keep adding inputs from port 3 until the sum exceeds 100, output that sum to port 3, then halt. This is accomplished as follows: The instruction on line 7 puts - the 16 most- significant bits of - the starting address of segment MY..DATA into register AX; on line 8 this value is moved from AX to DS. This makes SUM accessible in succeeding in- structions.
The instruction on line 9 initializes SUM to
O.Observe that on lines 7, 8, and 9, the desti- nations, such as SUM on line 9, are always written before the sources, as 0 on line 9.
Line 10 compares (CMP) the value in SUM to 100 and sets processor flags, indicating comparison results.
Line 11 tests the flags and jumps, if SUM was not above 100 (JNA). The target of ,the jump is the instruction labeled NOLDONE (line 15). If the jump on line 11 is not taken (SUM
>100), the SUM is moved into AL (line 12); the contents of AL is sent to output port 3 (line 13), and the processor halts (line 14).
If the jump on line 11 is taken (SUM < 100), the value on input port 3 is sent to AL (line 15), added to SUM (line 16), and the jump on line 17 transfers control back to line 10.
General Conclusions
Now, from the above example, what can be noticed about the structure of an