user1314075
user1314075

Reputation: 83

Hello World Boot Loader

I'm trying to do a hello world for a boot loader in assembly. I'm following this tutorial: http://www.osdever.net/tutorials/view/hello-world-boot-loader

I searched and it seems people are saying gcc doesn't work for compiling assembly. So I searched and found flat assembler. When I try to compile the example, it gives me an error at the first line [BITS 16]. Basically it states 'Illegal Instruction'.

What type of assembler does this code require?

Upvotes: 1

Views: 1444

Answers (3)

BigBrownBear
BigBrownBear

Reputation: 25

Try removing square brackets around BITS 16 in case you didn't.

Upvotes: 0

RCC
RCC

Reputation: 1

I simply commented the line out and it worked in FASM. It seems like FASM defaults to 16 bit automatically. After it compiled, it generated a BIN file by the same name. I renamed it to an IMG extention and then assigned it as a Floppy Disk image using VirtualBox to test it. Worked great and booted.

As long as you write this BIN/IMG file to the drive on the first sector it seems to work okay. I used the tutorials on the above website also.

Upvotes: 0

Andrew J. Brehm
Andrew J. Brehm

Reputation: 4758

I don't know if some tool in GCC can compile assembler (and if it does, whether it can compile to 16 bit code), but the site you refer to recommends NASM. Did you try it with NASM?

Upvotes: 1

Related Questions