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

  • SEARCH
  • Home
  • 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 6960387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:23:46+00:00 2026-05-27T15:23:46+00:00

i am a newbie to assembly and program in c (use GCC in Linux)

  • 0

i am a newbie to assembly and program in c (use GCC in Linux)

can anyone here tell me how to compile c code into assembly and boot from it using pen drive

i use the command (in linux terminal) :

 gcc -S bootcode.c

the code gives me a bootcode.S file

what do i do with that ???

i just wanna compile the following code and run it directly from a USB stick

#include<stdio.h>
void main()
{
  printf ("hi");
}

any help here ???

  • 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-27T15:23:46+00:00Added an answer on May 27, 2026 at 3:23 pm

    First of all,

    You Should be aware that when you are writing bootloader codes , you should know that you are CREATING YOUR OWN ENVIRONMENT of CODE, that means, there is nothing such ready made C Library available to you or anything similar , ONLY and ONLY BIOS SERVICES (or INTERRUPT ROUTINES).

    Now, if you got this, you will probably figure out that the above code won’t boot since, you don’t have the “stdio.h” header, this means that the CPU when executing your compiled code won’t find this header and thereby won’t understand what is “printf” (since printf is a method of the stdio.h header).
    So if you want to print any string you need to write this function by YOUR OWN either in a separate file as a header and link its object file at compilation time when creating the final binary file or in the same file. it is up to you. There could be other ways, I’m not well familiar with them, just do some researches.

    Another thing you should know, it is the BIOS who is responsible for loading this boot code (your above code in your case) into memory location 0x07C00 (0x0000h:0x7C00 in segment:offset representation), so you HAVE to mention in your code that you are writing this code on this memory location, either by

    1-using the ORG instruction

    2-Or by loading the appropriate registers for that (cs,ds,es)

    Also, you should get yourself familiar with the segment:offset memory representation scheme, just google it or read intel manuals.

    Finally, for the BIOS to load your code into the 0x07C00, the boot code must not exceed 512byte (ONLY ON FIRST SECTOR OF THE BOOTABLE MEDIA, since a sectore is 512byte) and he must find at the last two byte of this first sector (byte 510 & byte 511) of your code the boot signature 0x55AA, otherwise the BIOS won’t consider this code AS BOOTABLE.
    Usually this is coded as :

    ORG 0x7C00

    …

    your boot code and to load more codes since 512byte won’t be sufficient.

    …

    times 510 – ($ – $$) db 0x00 ; Zerofill up to 510 bytes

                   dw 0xAA55 ;Boot Sector signature,written in reverse order since it
    
                                 will be stored as little endian notation
    

    Just to let you know, I’m not covering everything here, because if so, I’ll be writing pages about it, you need to look for more resources on the net, and here is a link to start with(coding in assembly):

    http://www.brokenthorn.com/Resources/OSDevIndex.html

    That’s all, hopefully this was helpful to you…^_^

    Khilo – ALGERIA

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

Sidebar

Related Questions

Newbie here...can I write one program which incorporates .NET LINQ and also various Java
Newbie here (to C, objective-C, and iOS)... For this code in my AppDelegate.m, why
Newbie here. I am looking at company code. It appears that there are NO
Newbie to .NET data apps here, coming from a Visual Foxpro background. I'm planning
Haskell newbie here. I wrote an evaluator for a minimal assembly-like language. Now, I
Here's the context for my question: I use a ARM7 architecture (ARM720T TDMI...) Compile
Newbie (perhaps stupid) question: How can I use the value of alt in the
Newbie here programming my first app (having made several tutorial apps). I am using
Newbie here, I have a struct for a word, which contains a char array
Newbie question here: I'm using ANSI C on server to crunch numbers for a

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.