Pergunta

I am approaching to x86 real mode coding, and I have found some example code here: http://www.nondot.org/sabre/os/files/Booting/nasmBoot.txt

The third example in that article loads a few sector of the floppy in the memory using the BIOS calls in real mode, and then jumps to them. It is a simple boot loader. It loads 5 sectors from 2nd sector. On the second sector (after 512 bytes of the first sector), there are a few instructions for printing out some text.

Well, I compiled it and tried the binary, but the text doesn't get printed out. Can you reproduce this dysfunction and tell me how to fix it?

I thank you for your help, and I apologise for the banality of my question. (Yet I can't figure out where things went wrong).

Foi útil?

Solução

If you use qemu you need to pad your image to a integer multiple of the size of a sector.

Add this at the end of image.asm:

times 512*2-($-$$) db 0

And assemble and run with:

nasm -f bin -o image.bin image.asm
qemu-system-i386 -fda image.bin

With another emulator you might have to pad to a total length of (1+5)*512 or even to the full length of a floppy (1474560 bytes).

Outras dicas

One thing I can tell immediately is that that code does not ensure that the stack isn't near 1000h:0000.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top