I am working on writing a bootloader, and the following tutorial introduces this code:
main:
;----------------------------------------------------
; code located at 0000:7C00, adjust segment registers
;----------------------------------------------------
cli ; disable interrupts
mov ax, 0x07C0 ; setup registers to point to our segment
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
;----------------------------------------------------
; create stack
;----------------------------------------------------
mov ax, 0x0000 ; set the stack
mov ss, ax
mov sp, 0xFFFF
sti ; restore interrupts
Maybe I misunderstood something, but if the SS register contains 0x0000, this does not mean that the the ds, es, fs and gs will overlap the stack? Also what are the functions of the fs and gs registers? Also, does the cs segment automatically install the BIOS? Because he says the code is at 0000: 7c00. In addition, the tutorial does not say why interrupts are disabled. I read somewhere that interrupts are usually disabled to avoid a dead end. What does this mean and why is this happening?
source
share