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 7080329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:46:55+00:00 2026-05-28T06:46:55+00:00

I’m currently reading the boot.s file in the source for the first ever Linux

  • 0

I’m currently reading the boot.s file in the source for the first ever Linux kernel (assuming that 0.01 is indeed the first public release).

I know C and ASM, the latter considerably less than the former. Even so, I seem to be able to understand and essentially grasp the code in the source files.

This file has me confused though. I now realise that’s because it’s in real mode, not protected mode. Needless to say, I’ve never seen ASM code written in real mode before. Protected mode was the defacto mode x86 OSes ran on before I was even born, so it’s to be expected.

Here’s a routine I want to comprehend better:

/*
 * This procedure turns off the floppy drive motor, so
 * that we enter the kernel in a known state, and
 * don't have to worry about it later.
 */
kill_motor:
    push dx
    mov dx,#0x3f2
    mov al,#0
    outb
    pop dx
    ret

Looking up outb, I find it’s used to pass bytes to ports on the computer. I’ll hazard a guess based on C documentation that this scenario passes the ‘stop motor’ byte as the first argument, and as the floppy drive port number as the second.

Is this interface provided by the BIOS? Or by the floppy drive directly? I’m assuming the BIOS has frugal ‘drivers’ for very basic operation of all the fundamental devices.

Here’s where I’m stumped: it seems that numbers like #0x3f2 are being pulled out of thin air. They’re clearly hardware port numbers or something. This file is sprinkled with such numbers, with no explanation what they’re referring to. Where can I find a comprehensive reference that shows all the hardware ports and control numbers they can receive from real mode? Also, it seems the file moves the kernel around in memory throughout the booting processes, with hard-coded memory addresses. Where can I find a guide for what memory address ranges are available to write over during real mode?

I also read a comment by Linus about reprogramming interrupts to avoid a collision between the BIOS and internal hardware interrupts. I’m not going to lie, that went right over my head.

Help would be great; Google seems sparse on the topic, in case you’re wondering.

  • 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-28T06:46:56+00:00Added an answer on May 28, 2026 at 6:46 am

    Firstly, welcome to the world of realmode assembler!
    You’ve probably already realised that the actual assembler is much the same between realmode and protected mode – the primary differences being operand sizes and memory layout/management.

    There are some resources for realmode out there on the internet – you’ve just got to hunt them down! One very important resource is Ralf Brown’s Interrupt List (known as RBIL) – it provides a lot of information about the various interrupts used in realmode programming. Another is BiosCentral’s CMOS memory map which describes what information the BIOS stores (or should store) in various memory locations.

    To answer some of your questions on the Linux code you posted:
    outb is the instruction to write the byte in al to port dx – 0x3f2 is the floppy controller port. Wikipedia can help you out with the basic list of x86 port numbers, but you’ll have to dig around for detailed information about the actual format of the al bits.

    what memory address ranges are available to write over during realmode?

    You should do some research into INT 15h, AX=E820h – it returns a memory map describing which memory areas can be used and which are reserved. Take note though: when looking at interrupts, it’s important to see how “new” they are because older BIOSes may not support them.

    …reprogramming interrupts to avoid a collision between the BIOS and internal hardware
    interrupts

    Many hardware devices have programmable interrupts (which are used to service the hardware when it needs attention). Typically the BIOS will sort out an initial assignment during its startup routines, but it’s not unusual for OS’s to rejig the hardware interrupts for its own purposes or to prevent known incompatibilities.

    One last note: it seems that numbers like #0x3f2 are being pulled out of thin air. The answer is yes. A lot of the Linux boot source is horrific (yes, it’s just my opinion) and does appear to sprinkle seemingly random address, port numbers and other bits without any meaningful explanation. Stick with it, look up other realmode resources and eventually it will make sense. Oh, and if you come across a comprehensive reference – tell EVERYONE (because it doesn’t currently exist).

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

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I've got a string that has curly quotes in it. I'd like to replace
I am currently running into a problem where an element is coming back from
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

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.