I would like to use GNU 'as' and do this from a GNU/linux box.
Can someone give me a quick intro / some good pointer for the same ?
Thanks in advance
Varghese
> I would like to use GNU 'as' and do this from a GNU/linux box.
ASM coding style doesn't matter to the CPU just that machine language code +
your bootsector data + any padding must fit in 512 bytes with the boot sign
'55 AA' hex value.
For linux you can use "dd" cmd. I use windows so you need to check out
"http://www.osdever.net/tutorials/hello_btldr.php" under "Installing a boot
loader" heading...
How do I get GNU as to assemble in native code without all elf/whatever
headers etc in so that I can put the code into the boot sector.
I couldn't figure out the options..
-Varghese
You can generate your code using GAS (keeping in mind you must use
16bit code), and once compiled you can convert it to a raw data using:
objcopy -b binary boot finalboot
See the GRUB source code as it's a clear example of what you want to
do.
The Grub Manual gives info on Grub .97 which they now call Grub Legacy.
That version seems to be easy to me.. build the stage1 and stage2..
and then create the boot device..
How different is using Grub 2?
Have you or any one else found any good doc for Grub 2?
Thanks. I haven't looked into GRUB sources.. Too many things on my
plate.. Hope to do that someday..
I haven't had much time to get back to that core programming level because I
am still just starting out until an OS class at my university is offered.
Some time ago I decided to learn some of OS stuff at a higher programming
level letting Windows do some of the work virtually like I can learn to
build a virtual FAT filesystem and other subsystems. Then one day from
strach get back to core level using Grub 2 or higher.
I'm not finding much on bootloaders in GAS (Gnu AS). It might be easier to
learn how to code a bootloader NASM, and port to GAS.
Links for creating various formats:
http://www.yeyan.cn/Programming/gcc-ld-compile-binary-formats.aspx
http://devpit.org/wiki/Compiler_Options_for_Creating_Odd_Binaries
The dd command, for *nix, is used to install the bootsector, once compiled.
Typically, something like so:
dd if=mbr of=/dev/hda bs=512 count=1
These two on GAS bootloaders may help. One is in Italian... The second
also shows commands on how to compile.
http://packz.noblogs.org/post/2007/11/18/creare-un-bootloader
http://www.in-nomine.org/~asmodai/booting-documentation.txt
You may want to learn about GAS directives: .code16, .fill, etc. here:
http://www.gnu.org/software/binutils/manual/gas-2.9.1/html_mono/as.html#SEC67
http://www.gnu.org/software/binutils/manual/gas-2.9.1/html_mono/as.html#SEC205
The .fill directive is the GAS version of NASM's times. It'll be used to
fill upto 510th byte prior to 0xAA55.
RP
It seems some GAS bootloaders use .org instead of .fill:
http://www.osdev.org/osfaq2/index.php/GasAllInOne
Giese's recommendations on bootloaders:
http://my.execpc.com/CE/AC/geezer/osd/boot/
RP
Recently came across this public domain GPL licensed book
Bartlett, Jonathan - Programming from the Ground up
http://programminggroundup.blogspot.com/2007/01/programming-from-ground-up.html
http://savannah.nongnu.org/projects/pgubook/
This book teaches x86 assembly on Linux platforms using the GNU toolset
including GNU as.
FYI, if anyone else is interested in the ATT/gas way of doing assembly.
/varghese