Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3692130
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:13:37+00:00 2026-05-19T04:13:37+00:00

I decided to write a simple asm bootloader and a c++ kernel. I read

  • 0

I decided to write a simple asm bootloader and a c++ kernel. I read a lot of tutorials, but I cant compile an assembly file seems like this:

[BITS 32]
[global start]
[extern _k_main]
start:
   call _k_main
   cli
   hlt

(I would like to call th k_main function from c file)

Compile/assemble/linking errors:

nasm -f bin -o kernelstart.asm -o kernelstart.bin:
error: bin file cannot contain external references

okay, then i tried create a .o file:

nasm -f aout -o kernelstart.asm -o kernelstart.o  (That's right)
ld -i -e _main -Ttext 0x1000 kernel.o kernelstart.o main.o
error: File format not recognized

Someone give me plz a working example or say how to compile. :/
(I’m browsing the tutorials and helps 2 days ago but cannot find a right answer)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T04:13:38+00:00Added an answer on May 19, 2026 at 4:13 am

    I don’t have a direct answer on where your error comes from. However, I do see a lot of things going wrong so I’ll write these here:

    nasm

    nasm -f aout -o kernelstart.asm -o kernelstart
    

    Does that even work? That should be something like

    nasm -f aout -o kernelstart kernelstart.asm
    

    ld

    ld -i -e _main -Ttext 0x1000 kernel.o kernelstart.o main.o
    

    Since you said you wanted to make a bootloader and a kernel, I’m assuming your goal here is to make ld output something that can be put in the MBR. If that’s the case, here are some things to keep in mind:

    • You didn’t specify the output format. If you want to make an MBR image, add --oformat=binary to the command line options. This makes sure a flat binary file is generated.
    • You set the entry point to _main. I’m not sure where that symbol is defined, but I guess you want your entry point to be start because that’s where you call your kernel.
    • You link your text section starting at 0x1000. If you want to put your image in the MBR to be loaded by the BIOS, it should be linked at 0x7c00.
    • As a side note: it seems your trying to link your bootloader and kernel together in one image. Just remember that the MBR is can only hold 512 bytes (well, actually 510 bytes since the last 2 should contain a magic value) so you won’t be able to write much of a kernel there. What you should do is create a separate kernel image and load this from your bootloader.

    I hope these points will help you in solving your problem.

    Also, you’ll find a lot of useful information as OSDev. Here is a tutorial on writing a real mode “kernel” that only uses the MBR. The tutorial contains working code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The other day I decided to write an implementation of radix sort in Java.
I've been working through Practical Common Lisp and as an exercise decided to write
I decided to teach myself assembly language. I have realized that my program will
What criteria should I use to decide whether I write VBA code like this:
I decided to make a system for a client using Castle ActiveRecord , everything
I decided to try http://www.screwturn.eu/ wiki as a code snippet storage utility. So far
I decided to install APC to speed up the site that I work for.
I decided to use log4net as a logger for a new webservice project. Everything
I decided to learn C++ (I program in C at work), and I have
We decided to use the minimumRequiredVersion in our clickOnce application manifest, and now when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.