0

I made a simple bootloader with nasm (that works).. my second program also compiled with nasm should be started from the bootloader... but I don't know how to do that... any ideas?

Here my websitehere. You probably see two textareas, the upper textarea is the bootloader, the second should be the second program started from the bootloader(but which I can't get it to work). Then you should push the 'make iso' button. Then in php I use the command:

$op=system("genisoimage -b prog".$getal.".img -no-emul-boot -boot-load-size 4 -o prog".$getal.".iso  /var/www/html/boot/ >> ".$getal."2.txt 2>&1 ",$back);

This makes an iso file, which burns the first program/bootloader on dvd in the bootsector(512)..this works, but now how to run the second program.

Any ideas?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Frederik
  • 17
  • 3
  • You can create a first stage and second stage, combine them together to create a disk image. I have an answer that shows how this can be done in the [Stackoverflow answer](http://stackoverflow.com/a/34095896/3857942). This code shows how you can load the second sector and also jump to it. Once you have the disk image made you should be able to use genisoimg (or mkisofs) – Michael Petch Mar 21 '16 at 06:14
  • I also have some [general bootloader tips](http://stackoverflow.com/questions/32701854/boot-loader-doesnt-jump-to-kernel-code/32705076#32705076) in this Stackoverflow answer – Michael Petch Mar 21 '16 at 06:21
  • Thx, for your time/fast response... but have to say: ill keep it this way...its too difficult for me. – Frederik Mar 21 '16 at 06:51
  • You have to read the other sector(s) manually via code in your boot sector. It may be difficult (actually it is pretty easy) but your going to be forced to do it. The BIOS will only read the 512 bytes to 0x7c00. It is up to you to read more off the drive and then transfer control to the code you load. You should look at the multitude of other tutorials on the internet about doing this. – Michael Petch Mar 21 '16 at 06:53
  • Both panes of code look the same? – Michael Petch Mar 21 '16 at 12:30
  • Yup, truth in it...i only changed the word welcome into the word second. – Frederik Mar 21 '16 at 16:18

1 Answers1

1

First, I am surprised your bootloader works at all, since it makes use of the stack (push 0a000h) without setting either the sp nor ss registers. So you're relying on the BIOS to have a stack set up somewhere which doesn't screw with the things you're trying to do. The stack might even be sitting at a very low address and overwrite the IVT or your own code – you simply cannot know.

For your original question: try looking into int 0x13. Your ISO making script could glue your two binaries together (just make sure they're appropriately padded), then from your boot code you can use the named interrupt to load your new binary into memory at a specific location and then you can far jmp there.

Yasammez
  • 1,383
  • 12
  • 15