Re: PC boot block programming madness

From: Erik Larsson (spamtrap_at_crayne.org)
Date: 10/22/04


Date: Fri, 22 Oct 2004 05:42:11 +0000 (UTC)

Hey Alex...
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

start:

; Do a bit of looping to slow things down a bit

mlinit:
 mov ax, 0xFFFF
oloop: ; Outer loop
 dec ax
 mov bx, 0xFF ; Fine tune this to match your processor speed
iloop: ; Inner loop
 dec bx
 cmp bx, 0x0000
 jne iloop
 cmp ax, 0x0000
 jne oloop

; Finished slowing down...

print:
 mov si, OFFSET+s ; Load address to the first character
printl:
 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?
 jb printl

; Do the whole process again, including the slowdown-loops
 jmp mlinit

end: ; End of program

; Here comes the data
s:
 dw "Hello world! :)"
 dw 13 ; carriage return
 dw 10 ; linefeed
se:

; Constants
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 bootable?
--------------------------------------------------------

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
outputted.

So, if anyone has time to look into this, please do. I don't understand a
thing : )

  Erik

"alex" <me@me.com> skrev i meddelandet
news:417833ee$0$4310$afc38c87@news.optusnet.com.au...
> 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.
>
> Cheers
> Alex
>
> "Erik Larsson" <spamtrap@crayne.org> wrote in message
> news:x8Udd.6758$d5.57125@newsb.telia.net...
> > Hello everyone.
> >
> > I've just gotten into assembler programming for the pc, using NASM to
try
> > 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
bytes
> > 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
the
> > 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
achieved
> > something. As far as I understand it, you do the 'int 0x10' thing with
ah
> > =
> > 0xE (write text teletype), bh = 0 (page number), bl = 0 (or whatever
color
> > 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
bochs
> > the text is printed just as it should be, but in the real world, it
seems
> > that it tries to print something (the cursor moves) but nothing comes
out
> > =).
> >
> > 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
would
> > be great. : )
> >
> > Erik
> >
>
>



Relevant Pages

  • Re: Booting SCO 3.2v4.0 hard disk image in VMware or Bochs
    ... > Hi folks - I'm trying to boot a dd'd disk image of an IDE-based SCO system ... > inside VMware 5.5, Bochs IA-32 emulator, or an actual Athlon-based PC. ... so I'd guess the image is valid - but I've heard that SCO's IDE ...
    (comp.unix.sco.misc)
  • Re: VMware Workstation with raw disk in F12
    ... and WinXP as the guest. ... Does anyone have VMware Workstation 7 or equivalent working with an F12 ... When I define the VM and select the raw disk, ... I have a grub floppy image that I use as a boot loader for the VM. ...
    (Fedora)
  • Windows disk imaging with dd, vmware, and ntfstools
    ... and install Windows and miscellaneous ... I then shut down VMware, ... did a dd dump to the remote disk using the VMware disk file mounted ... the machine will either boot partially and say inaccessible boot ...
    (comp.os.linux.misc)
  • Re: [opensuse] vmware and fake scsi devs
    ... scsi disk x. ... One such application is vmware. ... I always boot VMware with physical SCSI drives and it works! ...
    (SuSE)
  • Re: PC boot block programming madness
    ... A lot of BIOS's will check for the boot signature 0x55aa at offset 510 ... > out programming some boot-code to start from a floppy or whatever. ... > recognized as a bootable disk. ... > This works fine in bochs, but not in vmware or in the real world. ...
    (comp.lang.asm.x86)