Assembly Gui Programming

  

When building a GUI with assembly, you'll be working directly with the windowing system of the operating system you are compiling for. For Windows, that the Windows API. For Linux, X Window System (X11) is probably the most popular, though there are others. My question is, is this a good way to go. Assembly language is a low-level programming language for a computer or other programmable device specific to a particular computer architecture in contrast to most high-level programming languages, which are generally portable across multiple systems.

This article's tone or style may not reflect the encyclopedic tone used throughout the wiki. See Wikipedia's article on tone for suggestions.

This page or section refers to its readers or editors using I, my, we or us. It should be edited to be in an encyclopedic tone.

Difficulty level

Beginner

In this tutorial we will assemble a small 16-bit assembly language kernel with NASM and boot it.

WARNING: Please see the Real Mode OS Warning page before continuing.

  • 2So what's it going to look like?

Overview

You're probably going to sigh and dismiss yet another tutorial on writing operating systems in x86 assembly language, especially since this one uses real mode. But there's a catch to this one; it actually does more than printing 'Hello World' to the screen and halting.

For this, you'll need:

  • the latest version of NASM (2.05.01 as of November 28th, 2008)
  • PARTCOPY on Windows or dd on Linux
  • an emulator like QEMU, Bochs, or Microsoft Virtual PC
Gui programming languageWhat is gui programming

So what's it going to look like?

Well, there will be a single source file, the kernel. What about a bootloader? This is such a small kernel, we're not going to use a filesystem at all, we're just going to put the kernel into the first few sectors of the disk image!

The system will have a string printing call (of course), keyboard input, and a strcmp call similar to that of C, all packaged into less than a sector.

But I want a GUI and sound effects and all the Windows games to work on my OS...

So where's the code?

Here you go, go wild.

To assemble on Windows:

Java Gui Programming Example

Or on Linux:

Those commands assemble your kernel binary and write them to the first disk (sda might be your system disk, so use sdb, sdc etc. according to your configuration. USB-sticks also appear as one of the 'sd' devices). Go ahead and test out your operating system now!

What next?

Why, that's up to you of course! You could add more commands, expand your OS to another sector and learn to use the BIOS sector load functions, add a stack and improve the calls, etc.

Java

Have fun with your OS, however you decide to write it!

Assembly Gui Programming Software

EDIT on December 12 2008: I've written a second part to this tutorial at Real mode assembly II. This and future parts will have less code to copy and paste and more theory!

Assembly Gui Programming

Assembly Gui Programming Tutorial

Retrieved from 'https://wiki.osdev.org/index.php?title=Real_mode_assembly_I&oldid=25012'