NASM & bootloader crazy stuff

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
DednDave
Posts: 18
Joined: Fri Feb 05, 2010 10:40 am
Location: Mesa, Arizona

Re: NASM & bootloader crazy stuff

Post 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
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: NASM & bootloader crazy stuff

Post 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
User avatar
DednDave
Posts: 18
Joined: Fri Feb 05, 2010 10:40 am
Location: Mesa, Arizona

Re: NASM & bootloader crazy stuff

Post 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
Post Reply