Lately I've been wanting to get into assembly coding, just to have some experience under my belt. I decided to look into it and was getting some good results(though its simple asm), however everything is still blurry, and I would much appreciate some input from others on how to correctly build multiple .asm files into .. &.. &.. to finish with a .vfd or a .img file for Oracle VM.
So over the past few weeks in my spare time, I've been researching around the web trying to find a working method that will enable me to:
1. Compile my .asm files into individual .obj files
2. Link these multiple files into one .bin
3. Place this .bin into a .vfd or .img
4. Finally ran on the Oracle VM.
The programs i am currently using on my windows 7 64bit system are:
(all through MinGW)
1. nasm - to compile the asm to .obj / .bin files
2. ld - to link .obj files into a .bin (I think)
3. dd - to create a .img file from a .bin file
After some time of messing about I've been able to compile a single .asm file into a .bin file, and then placed it into a .img using dd (the below was from tutorials online):
(a bat file which executes these commands in the order below)
1. nasm -f bin -o bootloader.bin bootloader.asm
2. dd if=bootloader.bin of=output.img count=1440
and then I just ran the Oracle VM which reads the output.img and displays it correctly. YAY.
Now. I've coded in Visual c++ for some years now, and i typically use many files in single solution. I feel that when coding in asm, I should also be able to have multiple files. So I've read around and many use 'ld' - a linker which 'joins' .obj files into .bin files?
So I edited the above bat file to the following:
1a. nasm -f bin -o bootloader.bin bootloader.asm
1b. nasm -f bin -o kernel.bin kernel.asm
2. ld -o link.bin bootloader.obj kernel.obj
3. dd if=link.bin of=output.img count=1440
The first error i got was: "cannot perform PE operations on non PE output file". After I Googled.. and Googled... and Googled.... and Googled..... (one link to the next) and I couldn't find any other methods that worked - I just got more errors! I'm honestly lost. - I tried several different programs (eg objcopy), lots of different parameters, etc.. and I haven't made too much progress. I need guidance. :)
And here is my final questions. Will ''linking'' these files together with ld give me the desired results I seek? (multiple files in one final binary file) and how can I do it correctly on my windows system?
I'm not all to in-depth with asm or these programs so I've tried to read up as much as I could before i got here. So please if you could keep the explanations nice and clear. Im sorry if its a lot to ask for, and please no grilling. :)
Thanks!