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.

1byte.png

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.

binary

 

 

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.

Memory mapping

how you call interrupt (You should know about assembly language program to understand this program)

What is your requirements :

  1. Assembler – I am using NASM you can download this from  www.nasm.us
  2. 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 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.

 

Leave a comment