booting from a floppy in real mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi I saw the Makefile for bootsect.S in arch/i386/boot/
The bootsect.S file is linked at origin 0x00.  (-Ttext option)

ld -Ttext 0x00 --oformat binary -o bootsect bootsect.o

There is a small code that prints a string "hello world" in real mode.
When I link this code with the same options as above the string does not
print.    That is, I link the code and write it to a boot sector of a
floppy using the dd command and then boot from the floppy.    When i link
the code with the option "-Ttext 0x7c00" it works.  I guess the reason for
it to work is that ROM will load the boot code at 0x7c00 as mentioned in a
lot of docs.

The problem with my code was that there was code that stores the address of
the string in BP
mov $my_string, %bp         ; real mode code

my_string was defined as -
my_string
      .ascii "hello world\r\n"

I guess the linker was not adding the extra offset 0x7c00 to the string
address and hence it was not working.  Now for some doubts that came up due
to this -

1.  Shouldn't the bootsect.S code face the same problems?  Where exactly is
the whole code relocated to 0x7c00?
2.  I was also calling functions in my code.  For example I had code like
call clrscr where clrscr is a label.  This code works fine even with -Ttext
0x00.  Is there a reason why labels work fine but mov $my_string, %bp does
not?

TIA.
-mohit
Regards,
Mohit Kalra

"It is a capital mistake to theorize before one has data.
Insensibly one begins to twist facts to suit theories, instead of theories
to suit facts."
-SH

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux