Hi,

I am reading the code for boot0 (/usr/src/sys/boot/i386/boot0/boot0.S).
This is the part i am trying to understand:

--------------------------------------------------------------------------------------------------------
/*
* Initialise segments and registers to known values.
* segments start at 0.
* The stack is immediately below the address we were loaded to.
*/
start:          cld                             # String ops inc
               xorw %ax,%ax                    # Zero
               movw %ax,%es                    # Address
               movw %ax,%ds                    #  data
               movw %ax,%ss                    # Set up
               movw $LOAD,%sp                  #  stack

/*
* Copy this code to the address it was linked for
*/
               movw %sp,%si                    # Source
               movw $start,%di                 # Destination
               movw $0x100,%cx                 # Word count
               rep                             # Relocate
               movsw                           #  code
/*
* Set address for variable space beyond code, and clear it.
* Notice that this is also used to point to the values embedded in the block,
* by using negative offsets.
*/
               movw %di,%bp                    # Address variables
               movb $0x8,%cl                   # Words to clear
               rep                             # Zero
               stosw                           #  them
/*
* Relocate to the new copy of the code.
*/
               incb -0xe(%di)                  # Sector number
               jmp main-LOAD+ORIGIN            # To relocated code
----------------------------------------------------------------------------------------------------------------

This is all the information I could gather:

From this first disk's first sector, 512 bytes are read into the memory location of 0x7C00. After that, the BIOS will check for the number 0xAA55 at the memory location of 0x7DFE (the last two bytes of the boot block code). After the boot0 program is loaded and control is transferred to it, it will set up its registers and stack information. Then, boot0 relocates itself into a lower memory location and jumps to the new address offset to its main routine.

Whats the memory location of start?
what's this for incb -0xe(%di)  ?
where are we jumping to in jmp main-LOAD+ORIGIN?
whats ORIGIN?

I would really appreciate if some could kindly help me out with this.

_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to