exporting nasm code as win64 causes it to add extra junk

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
CalebKeatts
Posts: 1
Joined: Fri May 08, 2020 10:03 am

exporting nasm code as win64 causes it to add extra junk

Post by CalebKeatts »

I have created a custom bootloader and created the kernel in c++ following the osdev wiki. When I try to compile the assembly with

Code: Select all

nasm.exe -f win64 boot.asm -o boot.obj
, compile the kernel.cpp to kernel.obj, and link it with

Code: Select all

~\tdm-gcc64\c++.exe -T linker.ld -o Boot.img -ffreestanding -nostdlib boot.obj kernel.obj
it will have extra "This program cannot be run in DOS mode" I also don't know how to set it to start at 0x7c00 as

Code: Select all

org 0x7c00
doesn't work unless in binary format. Any help will be appreciated.
Octocontrabass
Member
Member
Posts: 5575
Joined: Mon Mar 25, 2013 7:01 pm

Re: exporting nasm code as win64 causes it to add extra junk

Post by Octocontrabass »

You're using a compiler targeted towards Windows, so it creates Windows EXE files by default. Does your linker script tell it you want a flat binary?

I strongly recommend using a cross-compiler. It's much easier to get help with your compiler when you're using the same compiler that everyone else is using.
Post Reply