Sunday, February 9, 2014

"Hello World" Program!!! (Writing assembly code!! Day 5)

So from now on we will follow the steps mentioned in the previous post. Today we will write a bit of assembly code 

First few questions that came to my mind when I started writing the hello world program were
#)Why do we need assembly code!!??
#)Why cant we just start with C program?
Few reasons for these questions are:
1) You cannot enter protected mode with just C (I mentioned about protected mode in my previous posts).
2) Putting the multiboot header in the right section.
Multiboot header is something which tells the GRUB that  
3) setting up the stack etc. 
If you know other reasons please post them in the comment section.

Assembly code is here. You have to use the code from that page.  Save the code as "boot.s"
Then compile it using the following command. But this code wont compile It has errors. The code has error some where. Hence use this code instead.

#remember that every time you want to compile the code you develop you should set the environment variables in the terminal as given below

export PREFIX="$HOME/opt/cross"
export TARGET=i586-elf  
export TARGET=i586-elf 
export PATH="$PREFIX/bin:$PATH"

# The reason why you do this is because without these the computer will not  know which compiler to use and it will use your default compiler which is not meant to compile code for the new operating system you are developing.
#after these steps execute the following command after you cd to the folder which contains boot.s

i586-elf-as boot.s -o boot.o

For now and I think for a very long time you are free from this assembly language. You don't have to worry about this any more.




No comments:

Post a Comment