
ARCHITECTURE AND INSTRUCTIONS
The first time the INC instruction is exe- cuted, DS will contain OLD_DATA and the indicated assumption on DS will be correct. But then DS will be changed to NEW _DATA, and the same INC instruction will be executed a second time. Therefore, it would be wrong for the assembler to make assumptions about the contents of DS when the INC instruction is executed. The assem- bler must generate a
-specifying the extra segment - on the INC instruction, even though this prefix would be unnecessary on the first execution of INC.
In order to tell the assembler not to make any assumptions about DS, we must place the following assumption just before the INC instruction:
ASSUME DS:NOTHING
CYCLE: INC OLD~BYTE
Prior to, or at the very beginning of any seg- ment containing code, we must tell the assembler (via an ASSUME statement) what it should assume will be in the CS register when that segment of code is executed.
Instead of using an ASSUME statement, we could tell the assembler which segment regis- ter should be used for the execution of each instruction. For example, the move of X to ALPHA in the previous example could be written as:
MOV BX, DS:X
MOV ES:ALPHA,BX
This says that DS should be used when X is accessed, and ES should be used when ALPHA is accessed. Since the processor
would normally use DS when executing tbese instructions, the assembler produces a segment- overriding prefix when .generating object code for the second instruction, but not for the first instruction.
Efficient Programming
Now let's look at one of the shortcomings of memory segments to see how to get around it.
Memory segments always start on
Suppose the first segment starts at address 10000 (hexadecimal) and uses only 6D (hexadecimal) bytes. So the last byte used is at address 1006C. The closest the second seg- ment could start would be at address 10070, thereby wasting the bytes at 1006D, 1006E, and 1006F.
Now, instead of starting the second segment at the lowest
But the second segment would then simply not use its first few bytes, which is efficient. So, if the second segment starts at 10060, the bytes in the second segment below offset 0000 are simply not used by the second seg- ment. Therefore, no bytes are wasted.