|
In "Do-it-yourself Operating System", there is the following program:
% include "pm.inc"; constants, macros, and some descriptions
ORG 0100H
JMP LABEL_BEGIN
[SECTION .gdt]
; GDT
LABEL_GDT: Descriptor 0, 0, 0 LABEL_DESC_CODE32: Descriptor 0, SegCode32Len-1, DA_C + DA_32
LABEL_DESC_VIDEO: Descriptor 0B8000h, 0ffffh, DA_DRW
; GDT ends
GDTLEN EQU $-LABEL_GDT; GDT length
GDTPTR DW GDTLEN-1; GDT limit
DD 0; GDT base address
; GDT selector
SELECTORCODE32 EQU LABEL_DESC_CODE32-LABEL_GDT
SELECTORVIDEO EQU LABEL_DESC_VIDEO-LABEL_GDT
; END of [SECTION .gdt]
[SECTION .s16]
[BITS 16]
LABEL_BEGIN:
MOV AX, CS
MOV DS, AX
MOV ES, AX
MOV SS, AX
MOV SP, 0100H
Program execution: MOV AX, CS, CS seems to be 0. Because CS is 0 after CPU initialization, the above program does not seem to modify CS. (Unless "ORG 0100H" can initialize CS to 0100H, otherwise it is 0), "MOV SS, AX" gives the value of CS to SS, it seems that SS is also zero, but in my impression SS seems to point to the bottom of the stack (High address), but it points to a low address. "MOV SP, 0100H" is no problem, but it seems that SS and SP point to 0100H at the bottom of the stack at the beginning of the program.
Please give pointers to masters one or two! |
|