Skip to main content

Posts

Showing posts from July, 2012

Reading Disk Properties in Assembler - INT 13H

This post is a continuation from the previous post [ Writting a Bootloader ] which was an attempt to build a Bootloader for the x86 architecture. Although the executable size is limited to 512 Bytes, there are several important tasks that can be accomplished during booting process. One of them is to read the Geometry from several storage devices. Interrupt 13h [ INT 13h ] provides sector-based disk access services using the CHS addressing  method (Cylinder/Head/Sectors). This values provide the physical location of the data (although this is not completely true nowadays). The code below is an example of this interrupt. It reads the CHS from the first Hard Disk using Interrupt 13h. Briefly, interrupt parameters are set in AX and DX registers. After interrupt is completed, its values can be read from the appropriate registers (CX, DX). The rest of the code includes helper functions to print numbers and strings to present results properly. After booting our virtual s

Writing a Bootloader

I am starting to think of any reason to Write a Bootloader ... I've been always interested not only how to write applications but understanding how the whole system works, from the moment the machine boots. The first steps in computer booting can be described in general as follows: Power Up Start Processing ROM BIOS Execute POS (Power-on self Test) Check hardware devices Look for OS to load During the last step, BIOS will search for Storage Devices (described in the device Boot Order). These are usually CD-Rom, Hard Drives,  USB Drives,  Disk Drives, etc. For each Device (In order), BIOS will look for MBR (Master Boot Record) which corresponds to the first 512 bytes of the Device Image.  These 512 Bytes are loaded then into the memory and executed. It's a very small space in memory to be able to achieve many tasks.  Bootloaders are commonly used to access the kernel loader located in the boot sector of the drive. Other tasks includes initialize critical hardwa