Skip to content
/ oslab Public

Practice on assembly language via Nasm, mostly in real-mode, preparation for os development

License

Notifications You must be signed in to change notification settings

icecoobe/oslab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

oslab

Introduction

I must Create a System, or be enslav'd by another Man's; I will not Reason and Compare: my business is to Create. —William Blake

In the early days, engineers knew everything about computing systems: mainboard, hardware, networking, compiler and so on. I still have many questions on computing systems even as a graduated student of CS.

After reading the interesting book - The Elements of Computing Systems, I was inspired to write something from scratch. This repo. records the practices on OS development.

I wrote a real-mode program that can handle an old hardware, registered my own interrupt service routine, and configured the interrupts in Intel 8259A. And it worked. Due to some reason, I can not put it here, if you are interested in how interrupt stuffs work, ping me.

Links

Assembler

NASM provides some useful features that are similar to C language. You can define macro, trace compilation with %warning, and memory model is easy understood.

;; macro of variable
%define BASE 0x7C00

;; constant
mbr_length equ 512

;; I hate LEA
mov byte [es:xx], XXXh

;; like pointer in C
mov si, msg
mov word target, 0x7E00
jmp [target] 

msg     db 'Hello World'
target  dw 0x0

;; compilation trick
size equ ($ - start)
%if size+2 > 512
    %error "[ERROR] code is too large for boot sector"
%else
    %warning Nasm version: __NASM_VER__
    %warning Current date: __DATE__ __TIME__
    %warning Current bits mode: __BITS__
%endif

Editor

Visual Studio Code is good for me with useful extensions:

With these extensions, integrated terminal and the following nmake.sh(or nmake.bat), I could just focus on editor and coding.

Emulator

  • VirtualBox: best performance and fully support for running os.
  • DOSBox or DOSEmu: useful for dos program, you can debug your *.COM file with debug.exe
  • QEMU
  • Bochs: It's useful for debugging. However, you shouldn't expect the performance.

Build & Run

Use nmake.sh

cd bootloader
./nmake.sh gos

After building, the emulator will start automatically.

Makefile

Recently I was working with nmake.sh, later I will improve the Makefile.

cd bootloader
make name=gos
cd bin

Screenshot

Gauss calculation


Hope these will help you.

About

Practice on assembly language via Nasm, mostly in real-mode, preparation for os development

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published