Re: PC boot block programming madness
From: Erik Larsson (spamtrap_at_crayne.org)
Date: Fri, 22 Oct 2004 05:42:11 +0000 (UTC)
Thanx very much for the reply, but I actually know this... and consequently
I have my 0x55aa at offset 510. Maybe I forgot to say.
This is my source code by the way (NASM-style).
[BITS 16] ; Generate 16-bit code
; Do a bit of looping to slow things down a bit
mov ax, 0xFFFF
oloop: ; Outer loop
mov bx, 0xFF ; Fine tune this to match your processor speed
iloop: ; Inner loop
cmp bx, 0x0000
cmp ax, 0x0000
; Finished slowing down...
mov si, OFFSET+s ; Load address to the first character
lodsb ; Load string (what this acually means, I don't know yet)
mov ah, 0x0E ; Argument to i10,A. 0E = "write text teletype"
mov bx, 0x0 ; Argument to i10,A. Page 0, foreground color 0
int 0x10 ; Call the BIOS VIDEO_IO
cmp si, OFFSET+se ; End of string reached?
; Do the whole process again, including the slowdown-loops
end: ; End of program
; Here comes the data
dw "Hello world! :)"
dw 13 ; carriage return
dw 10 ; linefeed
OFFSET: equ 0x7C00 ; The place in memory where the code is loaded
TIMES 510-($-$$) DB 0 ; make sure that the 512 bytes of the
bootsector are padded with zeros
BootSignature DW 0xAA55 ; boot signature, to make BIOS detect my disk
As you can see, the idea is to print "Hello world :)" an infinite number of
times (or at least until I press the reset button =) ) and using a simple
loop to slow the program down.
But my problems remain:
1. A real world computer won't boot from my diskette containing this
512-byte code segment at the beginning of the disk... but Bochs (x86 system
emulator) and VMWare (sort of the same thing) will boot.
2. VMWare and real world computers won't output any visible text. The cursor
moves though. Bochs outputs the text just as I would expect it to be
So, if anyone has time to look into this, please do. I don't understand a
thing : )
"alex" <firstname.lastname@example.org> skrev i meddelandet
> A lot of BIOS's will check for the boot signature 0x55aa at offset 510
> of the bootsector, if this is not found then you may recieve a message
> saying its unbootable.
> "Erik Larsson" <email@example.com> wrote in message
> > Hello everyone.
> > I've just gotten into assembler programming for the pc, using NASM to
> > out programming some boot-code to start from a floppy or whatever.
> > But it totally drives me nuts...
> > 1. First, I want to be able to boot my program... So I write the 512
> > containing my code to the beginning of a floppy, and try to boot it.
> > Testing it in Bochs and VMware indicates that it recognizes and boots
> > program, but when inserting the disk into a 'real' computer it isn't
> > recognized as a bootable disk.
> > What properties must be satisfied for the bios to recognize the disk as
> > bootable?
> > 2. I want to print something to be able to see that I've actually
> > something. As far as I understand it, you do the 'int 0x10' thing with
> > =
> > 0xE (write text teletype), bh = 0 (page number), bl = 0 (or whatever
> > you want) and al = ascii code of the character to print.
> > This works fine in bochs, but not in vmware or in the real world. In
> > the text is printed just as it should be, but in the real world, it
> > that it tries to print something (the cursor moves) but nothing comes
> > =).
> > If anyone has experience with boot-programming or can supply me with a
> > working nasm source code example that I can play around with... that
> > be great. : )
> > Erik