Page 2 of 2

Re: NASM & bootloader crazy stuff

Posted: Thu Feb 11, 2010 9:41 am
by DednDave
yes - ms usually sets the stack at 0000:7C00 :D

Code: Select all

        mov     ax,7C00h
        cli
        mov     sp,ax
        xor     ax,ax
        mov     ss,ax
        sti

Re: NASM & bootloader crazy stuff

Posted: Fri Feb 12, 2010 2:24 am
by qw
DednDave wrote:yes - ms usually sets the stack at 0000:7C00 :D

Code: Select all

        mov     ax,7C00h
        cli
        mov     sp,ax
        xor     ax,ax
        mov     ss,ax
        sti
Dedndave,
You don't need to load SP through AX. SP may be loaded with an immediate value. Also, if you load SP immediately after SS, then you don't need to clear and set the interrupt flag. After loading SS, interrupts will be automatically disabled for one instruction. The intended instruction for that is loading SP. So this will do:

Code: Select all

xor ax, ax
mov ss, ax
mov sp, 0x7c00
Roel

Re: NASM & bootloader crazy stuff

Posted: Fri Feb 12, 2010 3:47 am
by DednDave
quite right Roel - lol
i was totally asleep at the wheel #-o
as for the cli/sti, i guess ms writes their boot sectors like that
so that they will still boot up on xt class machines :D
it has been a while since i have done this sort of stuff
thanks for the tip