Hi! Readers. I hope you have stored in your mind previous topics from Previous lessons. I am Just using simple method to learn even the readers are new. If you are already have knowledge please skip these topics. Now I am going to tell How to print a string to your 16 bit operating system. The commands are here below
;Stringprint.asm
mov ax, 0x07c0
mov ds, ax
mov si, msg
ch_loopmain:
lodsb
cmp al, 0 ;
je hangmain ; if char is Null then finish this loop
mov ah, 0x0E
int 0x10
jmp ch_loopmain
hangmain:
msg dw 'ManiCMD>'
times 510-($-$$) db 0
db 0x55
db 0xAA
See the above example. This program will show your string in your operating system screen.
The statements in green colors are already explained. Now I am going to explain the unknown statements.
msg dw 'ManiCMD>'
This statement tells compiler make define word for msg variable and store the string "ManiCMD> " in that string variable.
mov si, msg
This statement used for move your stack index to msg string. Stack index is used as source index in string operations. So source Index is in msg string now.
lodsb
This statement is used to load the string to stack.
Load byte at address DS:SI into AL so the character will print where the index is pointing.
cmp al, 0 ;
je hangmain
Compare the character is Null(cmp al,0) if Null finish that loop. If NOT NULL print the character and do again that loop.
I hope you understood our previous program.
You can save this program any .asm file separately and compile and make any .img file.
Thank you for Reading.....
Create Your own 16bit Operating system - Assembly language
Sunday, 10 April 2016
Thursday, 7 April 2016
Key Press in your own assembly 16 bit operating system
Hi Readers ! Ok in before lessons you viewed and practiced for Booting and printing characters right?
But, Even if you press any key in the screen will not appear. Because this is your own operating system. So you should give command to your operating system to print the character.
Now I will tell you some commands to get character from keyboard and print the character in screen for 16 bit operating system.
mov ax, 0x07c0
mov ds, ax
keypr: ; this command is label to come back here
;''''''''' wait for a key stroke
mov ah,00 ; BIOS keyboard input function
int 16h
mov ah,0x0E ; Print and go to the next character
int 0x10
jmp keypr ; again jump to keypr to get next key and print
times 510-($-$$) db 0
db 0x55
db 0xAA
See the above program . The green color statements already I explained in previous posts. Now you are going to understand the label and jmp statement and 00 function in interrupt 16h.
I used here keypr: (you should give with colon(:)) you can use any valid word for this label. It means this is starting of some statements. If you give jmp keypr (here you should not use (:)) anywhere in the program the compiler will jmp immediately without condition to keypr: label where you put.
Int 16h is a Keyboard interrupt. 00 is function for wait a keystroke. The compiler will wait for user key stroke When the compiler executes this statements. After get your key press the
Ascii code of your key will store in AL register.
So Now the AL is filled with ascii character of your key.
Then the command will go to
mov ah,0x0E
Int 10h
You know already this statement. It is used print that character which is stored in Al register.
Here you can watch the video for demo
https://www.youtube.com/watch?v=T_atx-3H3Gk
But, Even if you press any key in the screen will not appear. Because this is your own operating system. So you should give command to your operating system to print the character.
Now I will tell you some commands to get character from keyboard and print the character in screen for 16 bit operating system.
mov ax, 0x07c0
mov ds, ax
keypr: ; this command is label to come back here
;''''''''' wait for a key stroke
mov ah,00 ; BIOS keyboard input function
int 16h
mov ah,0x0E ; Print and go to the next character
int 0x10
jmp keypr ; again jump to keypr to get next key and print
times 510-($-$$) db 0
db 0x55
db 0xAA
See the above program . The green color statements already I explained in previous posts. Now you are going to understand the label and jmp statement and 00 function in interrupt 16h.
I used here keypr: (you should give with colon(:)) you can use any valid word for this label. It means this is starting of some statements. If you give jmp keypr (here you should not use (:)) anywhere in the program the compiler will jmp immediately without condition to keypr: label where you put.
Int 16h is a Keyboard interrupt. 00 is function for wait a keystroke. The compiler will wait for user key stroke When the compiler executes this statements. After get your key press the
Ascii code of your key will store in AL register.
So Now the AL is filled with ascii character of your key.
Then the command will go to
mov ah,0x0E
Int 10h
You know already this statement. It is used print that character which is stored in Al register.
Here you can watch the video for demo
https://www.youtube.com/watch?v=T_atx-3H3Gk
Wednesday, 6 April 2016
Make Color words / Characters in operating system
Program
; boot.asm
mov ax, 0x07c0
mov ds, ax
mov ah,09h ; write a character at cursor position(function)
mov bl,0Dh ; Font Character colour (Pink)
int 10h
mov ah, 0x0e;
mov al,'W'
int 0x10;
mov ah,09h ; write a character at cursor position(function)
mov bl,0Ah ; Font Character colour (Green)
int 10h
mov ah, 0x0e;
mov al,'E'
int 0x10;
times 510-($-$$) db 0
db 0x55
db 0xAA
In that above program Green color text are your Known codes.(Explained codes) But the pink color codes, you didn't know before . I will explain how to make color in your operating system first set of code i will explain down.
So that you can understand the other and you can make how to plan colorful texts in your 16 bit operating system.
explaining for
mov ah,09h ; write a character at cursor position(function)
mov bl,0Dh ; Font Character colour (Pink)
int 10h
; boot.asm
mov ax, 0x07c0
mov ds, ax
mov ah,09h ; write a character at cursor position(function)
mov bl,0Dh ; Font Character colour (Pink)
int 10h
mov ah, 0x0e;
mov al,'W'
int 0x10;
mov ah,09h ; write a character at cursor position(function)
mov bl,0Ah ; Font Character colour (Green)
int 10h
mov ah, 0x0e;
mov al,'E'
int 0x10;
times 510-($-$$) db 0
db 0x55
db 0xAA
In that above program Green color text are your Known codes.(Explained codes) But the pink color codes, you didn't know before . I will explain how to make color in your operating system first set of code i will explain down.
So that you can understand the other and you can make how to plan colorful texts in your 16 bit operating system.
explaining for
mov ah,09h ; write a character at cursor position(function)
mov bl,0Dh ; Font Character colour (Pink)
int 10h
As I already mentioned, in register AH we should store the functions (Mind AX is divided by AH, and AL). So 09h function in interrupt 10 is write a character at cursor position. So It tells the assembler whatever the character you write at cursor position. The next BL register holds the color of text. In the above example i gave the constant for character 'W' is pink, and for character 'E' is Green. So in screen after booting it will be appeared W in pink color E in Green color. As you like you can make other colors for other texts.
Please practice if you have any doubt. Please give me a comment. I will reply for you.
Watch the video for the above program:
Please write comments if you have any suggestions.
Tuesday, 5 April 2016
Print WELCOME in your 16 bit Operating system
Welcome screen :
Now the program You are going to create welcome screen in your operating system by assembly language. using before commands.
; boot.asm
mov ax, 0x07c0
mov ds, ax
mov ds, ax
mov ah, 0x0E ; This is function of 0x10 interrupt to print a character and move next
mov al, ‘W’ ; This is character to print
int 0x10 ; This is Interrupt to print a character
mov ah, 0x0E ; This is function of 0x10 interrupt to print a character and move next
mov al, ‘E’ ; This is character to print
int 0x10 ; This is Interrupt to print a character
mov ah, 0x0E ; This is function of 0x10 interrupt to print a character and move next
mov al, ‘L’ ; This is character to print
int 0x10 ; This is Interrupt to print a character
mov ah, 0x0E ; This is function of 0x10 interrupt to print a character and move next
mov al, ‘C’ ; This is character to print
int 0x10 ; This is Interrupt to print a character
mov ah, 0x0E ; This is function of 0x10 interrupt to print a character and move next
mov al, ‘O’ ; This is character to print
int 0x10 ; This is Interrupt to print a character
mov ah, 0x0E ; This is function of 0x10 interrupt to print a character and move next
mov al, ‘M’ ; This is character to print
int 0x10 ; This is Interrupt to print a character
mov ah, 0x0E ; This is function of 0x10 interrupt to print a character and move next
mov al, ‘E’ ; This is character to print
int 0x10 ; This is Interrupt to print a character
times 510-($-$$) db 0
db 0x55
db 0xAA
db 0x55
db 0xAA
save as "welcomeboot.asm"
then command
nasm -f bin -o welcomeboot.img welcomeboot.asm
now welcomeboot.img file was created
so you will use this image file to boot as following video
The Program print WELCOME in our first screen after boot.
you can check this video
https://youtu.be/2DIwgGki6gwhttps://youtu.be/2DIwgGki6gw
Format of Boot Record of a Floppy
Boot Record of a Floppy
First we are going to write a boot program to a floppy disk.
see this picture the round inside the discs are called as Track. Cross lines in the disks are called as sectors.

The first track in first sector is a Boot sector of a floppy.
Every track in the disk has number. our first sector (Boot sector) has a number 0, 0, 1. It means 0 th drive (floppy) 0 th sector , 1st Track.
In that first sector should holds the boot program. or otherwise the system consider that is not a bootable disk and displayed the message "Non-System disk or disk error" "Replace and press any key when ready".
Ok the boot record How it should be
the first instruction is load this program into 0x07c0 (see in memory map in previous chapter. In that chapter boot program was loaded in this memory location)
all the bytes are 00 and last two bytes should be 55 and AA.
Simple Booting Assembly program:
; boot.asm
mov ax, 0x07c0
mov ds, ax
mov ax, 0x07c0
mov ds, ax
times 510-($-$$) db 0
db 0x55
db 0xAA
db 0x55
db 0xAA
How you will execute this program please click the link and see the video:
https://youtu.be/x6cJ-GqQXSg
https://youtu.be/x6cJ-GqQXSg
There you can understand how to make assembly program using NASM assembler and run that booting program .
(If the command is not showing in video I Will explain here)
nasm -f bin -o booting.img booting.asm
Ok in the same program we will add one small code to display one character how it will be
Booting program with print a character
; boot.asm
mov ax, 0x07c0
mov ds, ax
mov ax, 0x07c0
mov ds, ax
mov ah, 0x0E ; This is function of 0x10 interrupt to print a character and move next
mov al, 'a' ; This is character to print
int 0x10 ; This is Interrupt to print a character
times 510-($-$$) db 0
db 0x55
db 0xAA
db 0x55
db 0xAA
Compile same before and add it in Virtual box to boot Now the character 'a' will be displayed after booting.
See the below video
https://youtu.be/ReWaq7-WR_0
https://youtu.be/ReWaq7-WR_0
so you are asking now What is ah, al ? what is int? in next chapter we are going to explain about 16 bit registers in that chapters all you can understand.
Input / Output in computer
Input / Output in computer
First, You should know how the Instruction and datas are processing inside computer. You can handle components easily by program (means in mid level programming like assembly language program) if you know how the datas and Instructions transacted through components.
Computer is an electronic machine so it can only understand ON or OFF right.
Here we assume ON value is - 1 OFF value is equal to -0
the above method is called binary (1 or 0 only mentioned in binary)
We are saying the place holding a '0' or a '1' is bit.
8 bit is called as 1 byte
1024 Byte is called 1 Kilo Byte (KB)
1024 Kilo byte is called 1 Mega byte.(MB)
1024 Mega byte is called as 1 Giga byte(GB)
so if you buy 1 hard disk from store they are written on that hard disk like (320 GB, 360 GB, 500 GB, 1TB) so you can understand how much that hard disk have bytes, Kilo bytes, Mega bytes places.
ram also same like way we can calculate.

In the above picture is showing binary 1001 0111 (but in decimal that value of above binary is 151). How i will explain you.
if first bit from right we added 1 , 2 , 4 , 8 , 16, 32 , 64 ,128
if right most bit is enabled as 1 we should add 1 but if the 3rd bit is enabled as 1 we should add 4.
so in that above example
right most 1 st bit value is 1 so add = 1
from right 2 nd bit value is 1 so add = 2
from right 3 nd bit value is 1 so add = 4
from right 4th bit value is 0 so add = 0 (None)
from right 5 th bit value is 1 so add = 16
from right 6 th bit value is 0 so add = 0
from right 7 th bit value is 0 so add = 0
from right 8 th bit value is 0 so add = 128
The total value is 151
Instruction and datas will be sent as and stored as binary format in your computer.

Interrupt :
In computer every process is doing by interrupt. Those interrupts are stored in BIOS chip which is inside the CPU. You can check that memory map of the RAM after loaded.
The following sample Picture shows how the programs and interrupts loaded in memory.
As per following sample. After booting computer from 0000h (Address of memory) upto 0699h interrupt vector table is loaded. after 0700h the operating system loaded.

how you call interrupt (You should know about assembly language program to understand this program)
What is your requirements :
- Assembler - I am using NASM you can download this from www.nasm.us
- oracle VM Virtual box www.oracle.com/technetwork/server-storage/virtualbox/downloads/index.html this link will be help to download virtual box.
here is an example ( To print a character I write a assembly code)
mov ah,0x0E ; in register ah we are storing function of an interrupt 0x0e is used to print character and go to next character ah is a register having 8 bit data
mov al,'a' ; Here we are giving input to AL register. AL register having data to process
int 0x10 ; Here we giving interrupt this interrupt for display
Explanation of above example :
Interrupt having many functions so interrupt no 0x10 has one of many function is 0x0e is used to print a character and go to next line. so, when we call the interrupt 0x10 the printing character interrupt is triggered. It will find out the function. Here we given 0x0e is print a character and goto next character in screen. We have given character 'a' to AL register. so it will take a input from AL register as per AH function the interrupt 0x10 will be activated.
so 'a' character will be printed in cursor position and cursor will go to next character.
nasm :
How u will program for this take notepad in your system type the following code
mov ah, 0x0E,
mov al, 'a'
int 0x10
click save as in note pad in file name you type "printa.asm" type the file name in between double quote. or otherwise it will be saved with .txt extension. But we need .asm extension.
Now print.asm assembly language program created.
This is the method to call interrupt and process.
So, Next we can write program to boot from computer.
Operating System - Introduction
Operating system
Operating system is a software create by programmers to operate a computer. Computer is an electronics device. First when you pressing the power button in a computer the computer do self test (because to know themselves and for user that what are the components are attached with the processing unit). After completed self test it will check the disc's Boot sector which is mentioned to boot from (in BIOS setup). The program which is stored in Master Boot record of a disc is Boot Loader. The boot loader contains 512 bytes executing machine code.
Then the boot loader loads another program named Kernel for users to handle all the input,output, storage,process devices to simplifying the usage of computer. after loading kernel the ordinary user can use the computer very easily.
Boot Loader + Kernel = Operating system
(First this is enough for understand that what is Operating system. Later we will going to deeply in future about operating system making.)
First I want to tell about computer then only we can briefly understand that how to make operating system. because we should operate each and every components in ourselves.
The attractive word in all the world. Because this machine doing so many works taking less time long time before doing by man with more times. Even Accuracy and time consuming is one of the advantage in Computer. All the fields are affected today by computers. So Everyone need to Know about that miracle machine. Someone still don't know about computers. I am here to teach something about that Unknown peoples (Dummies in computers) who is fearing about that simplest thing as simple and very very simple.
Computer:
Named because of computing machine. At first, that machine was innovated for reason calculating (Computing).
After that it was coming to document preparation, databases maintenance, security of data, images manipulation, video editing and variety of uses.
Architecture of computer simply is
- Input (Keyboard, Mouse etc.,) Unit - To give input from user
- Processing Unit (CPU) - To process and store datas and instructions.
- Output (Monitor, Printer) - To get output after Processing.

Input --------------> Process-------------------->Output
Basic structure of computer
Physically you are seeing like below image

Author : Manikandan Thiyagarajan
Contact mail : Niranjanwin2016@gmail.com
Subscribe to:
Posts (Atom)