1

I want MINIX to first execute my code and then continue with executing default bootloader.

What I have so far is:

org 0x7c00 
jmp 0:start  
start:
    mov ax, cs      
    mov ds, ax      
    mov es, ax      
    mov ss, ax      
    mov sp, 0x8000

    ; ... my code ... ;

    ; that is supposed to mark code as bootloader:
    times 510-$+$$ db 0
    dw 0xaa55 

My whole code is here. I run it by executing commands:

pkgin -y in nasm 
nasm -f bin my_bootloader.asm -o my_bootloader
dd bs=512 count=1 if=my_bootloader of=/dev/c0d0 
reboot

After rebooting, my program starts, but of course the system doesn't load afterwards. What can I do to "attach" the original bootloader to my code?

Jecke
  • 239
  • 2
  • 13

1 Answers1

0

The usual solution is to perform what all the MBR boot loaders do: moving themselves out of the standard place (00600 is the usual target place), then loading the "regular" boot loader from another sector of the disk to 07C00and jumps to it.

You can find the assembly code which does that, with comments, either in MINIX (GAS assembler), in previous releases of MINIX (ACK syntax, close but not the same as NASM), in SYSLINUX if you insist to use NASM, on the web, etc.

AntoineL
  • 888
  • 4
  • 25