Vol. 3A 9-25
PROCESSOR MANAGEMENT AND INITIALIZATION
9.10.3
MAIN.ASM Source Code
The file MAIN.ASM shown in Example 9-2 defines the data and stack segments for this application and can be
substituted with the main module task written in a high-level language that is invoked by the IRET instruction
executed by STARTUP.ASM.
Example 9-2. MAIN.ASM
NAME main_module
data SEGMENT RW
dw 1000 dup(?)
DATA ENDS
stack stackseg 800
CODE SEGMENT ER use32 PUBLIC
main_start:
nop
nop
nop
CODE ENDS
END main_start, ds:data, ss:stack
9.10.4 Supporting
Files
The batch file shown in Example 9-3 can be used to assemble the source code files STARTUP.ASM and MAIN.ASM
and build the final application.
Figure 9-6. Task Switching (Lines 282-296 of List File)
GDT RAM
RAM_START
TSS RAM
IDT RAM
GDT Alias
IDT Alias
DS
EIP
EFLAGS
CS
SS
0
ES
ESP
•
•
•
•
•
•
SS = TSS.SS
ESP = TSS.ESP
PUSH TSS.EFLAG
PUSH TSS.CS
PUSH TSS.EIP
ES = TSS.ES
DS = TSS.DS
IRET
GDT