| ||
There is one convenient method of working with structures and unions that deserves a special mention. It is based on the ASSUME directive. Actually, I make practically no use of this directive in this book. When programming for MS-DOS, this directive is mainly used to inform the assembler that the segment register points to the current segment. However, this directive can be used with more than segment registers. Here is the fragment that illustrates such a technique.
COMPLEX STRUC RE DD ? IM DD ? COMPLEX ENDS . . . ; In data segment COMP COMPLEX <0> ; In code segment MOV EBX, OFFSET COMP ASSUME EBX:PTR C0MPLEX MOV [EBX].RE, 10 MOV [EBX].IM, 10 ASSUME EBX:NOTHING
Actually, the MOV [EBX] .RE , 10 command is equivalent to MOV DWORD PTR [EBX] , 10 , and the MOV [EBX].IM , 10 command is equivalent to MOV DWORD PTR [EBX+4] , 10 . You likely will agree that this is very convenient.
| ||