Three examples of assemblers for real machines are: 1. MASM assembler 2. SPARC assembler 3. AIX assembler
MASM Assembler The programs of x86 system views memory as a collection of segments. Each segment belongs to a particular class corresponding to its contents.
The commonly used classes are: 1. CODE 2. DATA 3. CONST 4. STACK
During program execution segments are addressed via an x86 segment register. In most cases: Code Segments are addressed using register CS. Stack Segments are addressed using register SS. * The loader automatically sets CS and SS when the program is loaded. * CS is set to indicate the segment that contains the starting label specified by the ‘END’ statement of the program. * SS is set to indicate the last stack segment processed by the loader. * The programmer can specify explicitly the segment register to be used, else the assembler selects one. * Data segments are addressed using DS,ES,FS and GS. * By default the assembler assumes that all references to data segments use register ‘DS’, but the following statement with the assembler directive ASSUME tells the assembler to assume that register ES indicates the segment DATAEG2. ASSUME ES:DATASEG2 | * Thus any references to labels that are defined in DATASEG2 will be assembled using register ‘ES’. * It is also possible to group several segments together.
The following instruction would set ‘ES’ to indicate data segment DATASEG2. MOV AX,DATASEG2MOV ES, AX | * BASE directive tells the SIC/XE assembler the contents of register ‘B’/ * ASSUME directive tells MASM the content of a segment register.
Jump instructions are assembled is two ways 1. Near Jump 2. Far Jump
Near Jump * It is a jump to a target location in the same code segment. * Assembled instruction for NEAR JUMP is 2