Partner Link

Cheap Mobile Phones
- Cheap Mobile Phones - Best Mobile Phone Deals, Laptops, Sat Nav Devices, Cordless Phones, Internet Phones, Broadband Internet Deals from leading retailers of UK. Choose Products and Compare Prices for best deals.

||

Mobile Phones
- Offers mobile phones on contract, pay as you go, sim free deals with free gifts. We compare latest phone deals from leading retailers of UK.

. ||

Custom logo design
Get your company a logo design. Professional logo designs by expert logo designers. Call 0208 133 2514 for custom logo design packages.

||

Top Site

Flyer Printing Flyer Printing – Print your flyers on latest design. We offer cheap flyer printing services in all over UK. Full color flyer printing & art work in your own budget. Order for online flyer printing from your home.
Mobile Broadband Deals  Mobile Broadband - Buy Mobile Broadband Deals, Best Mobile Internet Offers With Free Line Rental, USB Modem and Cheapest Network Connection Offers from 3 Mobile in UK
Mobile Upgrades Upgrade Mobile Phone Deals – upgrade your mobile phones from o2, orange, virgin, vodafone, t-mobile and all Manufacturers Nokia, Samsung, Sony Ericsson, LG ,Blackberry and Motorola. Mobile Broadband Deals Mobile Broadband - Buy Mobile Broadband Deals, Best Mobile Internet Offers With Free Line Rental, USB Modem and Cheapest Network Connection Offers from 3 Mobile in UK.

Medicine and Virtual Surgery

Computer graphics has extensive use in tomography and simulations of operations. Tomography is the technique that allows cross-sectional views of physiological systems in X-rays photography.Moreover, recent advancement is to make model and study physical functions to design artificial limbs and even plan and practice surgery.
Computer-aided surgery is currently a hot topic.

ART AND DESIGN

Computer graphics is widely used in Fine Arts as well as commercial arts for producing better as
well as cost effective pictures. Artists use a variety of programs in their work, provided by
computer graphics. Some of the most frequently used packages include:

  1. Artist’s paintbrush
  2. Pixel paint
  3. Super paint

The Turing test

A test proposed to determine if a computer has the ability to think. In 1950, Alan Turing
(Turing, 1950) proposed a method for determining if machines can think. This method is
known as The Turing Test.
The test is conducted with two people and a machine. One person plays the role of an
interrogator and is in a separate room from the machine and the other person. The
interrogator only knows the person and machine as A and B. The interrogator does not
know which the person is and which the machine is.
Using a teletype, the interrogator, can ask A and B any question he/she wishes. The aim
of the interrogator is to determine which the person is and which the machine is.
The aim of the machine is to fool the interrogator into thinking that it is a person. If the
machine succeeds then we can conclude that machines can think.

Scientific Visualization and Analysis

Computer graphics is very helpful in producing graphical representations for scientific
visualization and analysis especially in the field of engineering and medicine. It helps a lot in
drawing charts and creating models

Layout and Design

Layout and Design

User Interfaces

Almost all the software packages provide a graphical interface. A major component of graphical interface is a window manager that allows a user to display multiple windows like areas on the screen at the same time. Each window can contain a different process that can contain graphical or non-graphical display. In order to make a particular window active, we simply have to click in that window using an interactive pointing device.
Graphical Interface also includes menus and icons for fast selection of programs, processing operations or parameter values. An icon is a graphical symbol that is designed to look like the processing option it represents.

Graphics Applications

Due to rapid growth in the field of computing, now computer is used as an economical and
efficient tool for the production of pictures. Computer graphics applications are found in almost all
areas. Here we will discuss some of the important areas including:

  1. User Interfaces
  2. Layout and Design
  3. Scientific Visualization and Analysis
  4. Art and Design
  5. Medicine and Virtual Surgery
  6. Layout Design & Architectural Simulations
  7. History and cultural heritage
  8. Entertainment
  9. Simulations
  10. Games

C language program Lecture 1

The above described service can be used to get the size of a file in the described manner. The following C language program tries to accomplish just that. This program has been saved as .C file and not as .CPP file and then compiled.

Example 21H/42H:
#include
#include

#include
#include

#include

unsigned int handle;
void main()

{
union REGS regs;

unsigned long int size;
handle = open("c:\\abc.txt",O_RDONLY);
regs.x.bx = handle;
regs.h.ah = 0x42;
regs.h.al = 0x02; //correction
regs.x.cx = 0;
regs.x.dx = 0;

int86(0x21,&regs,&regs);
*((int*)(&size)) = regs.x.ax;
*(((int*)(&size))+1) =regs.x.dx;

printf ("Size is %d“ ,size);
}

This program opens a file and saves its handle in the handle variable. This handle is passed to the ISR 21H/42H along with the move technique whose value is 2 signifing movement relative to the EOF and the number of bytes to move are specified to be zero indicating that the pointer should move to the EOF. As the file was just opened the previous location of the file pointer will be BOF. On return of this service DX-AX will contain the size of the file. The low word of this size in ax is placed in the low word of size variable and the high word in dx is placed in the high word of size variable.

Another Example:
Lets now illustrate how ISR can be invoked by means of another example of BIOS service. Here we are choosing the ISR 10h/01h. This interrupt is used to perform I/O on the monitor. Moreover this service is used to change the size of cursor in text mode. The description of this service is given as under.



Int # 10H Service # 01H
Entry
AH = 01

CH = Beginning Scan Line
CL = Ending Scan Line
On Exit
Unchanged


The size of the cursor depends upon the number of net scan lines used to display the cursor if the beginning scan line is greater than the ending scan line the cursor will disappear. The following tries to accomplish just that

void main()
{
char st[80];
union REGS regs;
regs.h.ah = 0x01;

regs.h.ch = 0x01;
regs.h.cl = 0x00;
int86(0x10,&regs,&regs); //corrected

gets(st);
}


The program is quite self explanatory as it puts the starting scan line to be 1 and the ending scan line to be 0. Henceforth when the service execute the cursor will disappear.
Use of ISRs for C Library functions
There are various library function that a program
mer would typically use in a program to perform input output operations. These library functions perform trivial I/O operations like character input (putch()) and character output (getch(), getc() etc). All these function call various ISRs to perform this I/O. In BIOS and DOS documentation number of services can be found that lie in correspondence with some C library function in terms of its functionality.
Writing S/W ISRs

Lets now see how can a programmer write an ISR
routine and what needs to be done in order make the service work properly. To exhibit this we will make use of an interrupt which is not used by DOS or BIOS so that our experiment does not put any interference to the normal functions of DOS and BIOS. One such interrupt is interrupt # 65H. The vector of int 65H is typically filled with zeros another indication that it is not being used.
Getting interrupt vector

As we have discussed earlier IVT is a table contai
ning 4 byte entries each of which is a far address of an interrupt service routine. All the vectors are arranged serially such that the interrupt number can be used as an index into the IVT.
Getting interrupt vector refers to the operation which used to reading the far address stored within the vector. The vector is double word, the lower word of it being the offset address and the higher word being the segment address. Moreover the address read from a vector can be used as a function pointer. The C library function used to do the exactly
same is getvect(int#) which requires the interrupt number a parameter and returns the value of its vector.

Fig 1 (Vector being read from IVT )
Function pointers
Another thing required to be understood are the function pointers. C language is a very flexible language just like there are pointers for integers, characters and other data types there are pointers for functions as well as illustrated by the following example


void myfunc()
{

}


void (*funcptr) ( )


funcptr = myfunc;

(*funcptr) ( );
myfunc();

There are three fragments of code in this example. The first fragment shows the declaration of a function myfunc()
The second fragment show declaration of a pointer to function named funcptr which is a pointer to a function that returns void.

In the third fragment funcptr is assigned the address of myfunc as the name of the function can be used as its address just like in the cases of arrays in C. Then the function pointed by funcptr by the statement (*funcptr)(); is called and then the original myfunc() is called. The user will observe in both the cases same function myproc() will be invoked.

Interrupt pointers and functions

Interrupt functions are special function that as compared to simple functions for reasons discussed earlier. It can be declared using the keyword interrupt as shown in the following examples.

void interrupt newint ( )
{
...
...
}


Similarly a pointer to such interrupt type function can also be declared as following
void interrupt (*intptr) ( );

where intptr is the interrupt pointer and it can be assigned an address using the getvect() function

intptr = getvect(0x08);

Now interrupt number 8 can be invoked using the interrupt vector as following

(*intptr) ( );

Setting Interrupt Vector

Setting interrupt vector is just the reverse process of getting interrupt vector. To set the interrupt vector means is to change the double word sized interrupt vector within the IVT. This task can be accomplished using the function setvect(int #, newint) which requires the number of interrupt whose vector is to be changed and the new value of the vector.
In the following example a certain interrupt type function has been declared. The address of this function can be placed on to the vector of any interrupt using setvect() function as following. The following code places the address of newint function at the vector of int 8

void interrupt newint ( )
{


}

setvect(0x08, newint);

C program making use of Int 65H

Here is a listing of a program that makes use of int 65H to exhibit how software interrupts needs to be programmed.

void interrupt (*oldint65)( );
char st[80] = {“Hello World$”};
void interrupt newint65(void);
void main()
{
oldint65 = getvect(0x65);
setvect(0x65, newint65);
geninterrupt (0x65);
geninterrupt (0x65);
geninterrupt (0x65);
setvect(0x65, oldint65);
}
void interrupt newint65( )
{
_AH = 0x09;
_DX=(unsigned int)st;
geninterrupt (0x21);
}
The above listing saves the address of original int 65H in the pointer oldint65. It then places the address of its own function newint65 at the vector of interrupt number 65H. From this point onwards whenever int 65H is invokes the function newint65 will be invoked. Int 65 is invoked thrice which will force the newint65 function to be invoked thrice accordingly. After this the original value of the vector stored in oldint65 is restored. The newint65 function only displays the string st. As the interrupt 65 is invoked thrice this string will be printed thrice.


The Keep function
One deficiency in the above listing is that it is not good enough for other application i.e. after the termination of this program the newint65 function is de-allocated from the memory and the interrupt vector needs to be restored otherwise it will act as a dangling pointer (pointing to a place where there is garbage or where there is no meaningful function). To make the effect of this program permanent the newint65 function need to be memory resident. This can be achieved by the function keep() which is quite similar to exit() function. The exit() function returns the execution to the parent shell program and de-allocates the memory allocated to the program whereas the keep() function also returns the execution to the parent program but the memory allocated to the process may still remain allocated.

keep (return code, no. of paras);

the keep() function requires the return code which is usually zero for normal termination and the number of paragraphs required to be allocated. Each paragraph is 16 bytes in size.

TSR Programs
Following is a listing of a TSR (Terminate and Stay Resident) program which programs the interrupt number 65H but in this case the new interrupt 65H function remains in memory even after the termination of the program and hence the vector of int 65h does not become a dangling pointer.

#include
#include

char st[80] ={"Hello World$"};
void interrupt (*oldint65)( );
void interrupt newint65( );
void main()
{
oldint65 = getvect(0x65);
setvect(0x65, newint65);
keep(0, 1000);
}
void interrupt newint65( )
{
_AH = 0x09;
_DX=(unsigned int)st;
geninterrupt (0x21);
}
The main()function gets and sets the vector of int 65H such that the address of newint65 is placed at its vector. In this case the program is made memory resident using the keep function and 1000 paragraphs of memory is reserved for the program (the amount of paragraphs is just a calculated guess work based upon the size of application). Now if any application as in the following case invokes int 65H the string st which is also now memory resident will be displayed.




#include
#include

void main()
{
geninterrupt (0x65);
geninterrupt (0x65);
}


This program invokes the interrupt 65H twice which has been made resident.

Some History

Some History
The term Computer Graphics was coined in 1960 by william fetter to describe the new design methods that he was developing at Boeing .He created a series of widely reproduced images on a plotter exploring cockpit design using a 3D model of a human body.

Why Study Computer Graphics?

Definition
Computers accept process, transform and present information.
Computer Graphics involves technology to accept, process, transform and present information in
a visual form that also concerns with producing images (or animations) using a computer.

Why Study Computer Graphics?
There are certain important reasons to study computer graphics. We will discuss them under
certain heads:

a. Visualization
I like to see what I am doing. Many a times it happens that you perform certain tasks which you
cannot visualize; for example as a student of data structures, you implement trees, graphs and
other Abstract Data Types (ADTs) but you cannot visualize them whereas you must be having an inner quest to see what these actually look like.

I like to show people what I am doing. Similarly at certain times you would be performing certain
tasks which you know but it would be difficult for others to understand them so there is very
important requirement of showing the things in order to make them understandable.

b. Graphics is interesting
We are visual creatures and for us a picture is worth a thousand words. If we can get rid of text
based static screen and get some graphics; its always interesting to see things in colours and
motion on the screen. Therefore graphics is interesting because it involves simulation, algorithm,
and architecture.

c. Requirement
Well there are certain areas which require use of computer graphics heavily. One example is
drawing of machines. It is required to prepare drawing of a machine before the actual production.The other heavy requirement is for architects as they have to prepare a complete blue print of the building they have to build long before the actual construction work gets underway. Autocad and other applications of the kind are heavily used today for building architecture.

d. Entertainment
Merely a couple of decades back, the idea of a 24 hours Cartoons Network was really a far
fetched one. That was the time when one would wait for a whole week long before getting an
entertainment of mere 15 minutes. Well thanks to computer graphics that have enabled us to
entertain ourselves with animated movies, cartoons etc.

Turing Machine – 1936

2.1 Turing Machine – 1936

Introduced by Alan Turing in 1936, Turing machines are one of the key abstractions
used in modern computability theory, the study of what computers can and cannot do. A
Turing machine is a particularly simple kind of computer, one whose operations are
limited to reading and writing symbols on a tape, or moving along the tape to the left or
right. The tape is marked off into squares, each of which can be filled with at most one
symbol. At any given point in its operation, the Turing machine can only read or write
on one of these squares, the square located directly below its "read/write" head.

Evolution of Computing Today’s Goal

To learn about the evolution of computing
To recount the important and key events
To identify some of the milestones in computer development
Babbage’s Analytical Engine - 1833
Mechanical, digital, general-purpose
Was crank-driven
Could store instructions
Could perform mathematical calculations
Had the ability to print
Could punched cards as permanent memory
Invented by Joseph-Marie Jacquard

Introduction

1.1. Charles Babbage (1791-1871)

Creator of the Analytical Engine - the first general-purpose digital computer (1833)
The Analytical Engine was not built until 1943 (in the form of the Harvard Mark I)

1.2. The Analytical Engine

A programmable, mechanical, digital machine
Could carryout any calculation
Could make decisions based upon the results of the previous calculation
Components: input; memory; processor; output

1.3. Ada, Countess of Lovelace(1815-52)

Babbage: the father of computing
Ada: the mother?
Wrote a program for computing the Bernoulli’s sequence on the Analytical Engine -
world’s 1st computer program
Ada: A programming language specifically designed by the US Dept of Defense for
developing military applications was named Ada to honor her contributions towards
computing
A lesson that we all can learn from Babbage’s Life
Charles Babbage had huge difficulties raising money to fund his research
As a last resort, he designed a clever mathematical scheme along with Ada, the Countess
of Lovelace
It was designed to increase their odds while gambling. They bet money on horse races
to raise enough money to support their research experiments
Guess what happened at the end? The lost every penny that they had.
Fast
Bored
Storage
Here is a fact:

In 1997 Deep Blue(It could analyze up to 300 billion chess moves in
three minutes)
, a supercomputer designed by IBM, beat Gary Kasparov, the World
Chess Champion
That computer was exceptionally fast, did not get tired or bored. It just kept on
analyzing the situation and kept on searching until it found the perfect move from its
list of possible moves …

Goals for Today:

To develop an appreciation about the capabilities of computing
To find about the structure & policies of this course

MOTIVATION AND TOOLS

One of the reasons of motivation towards networking was resource sharing which
is discussed as follows.

RESOURCE SHARING:

Resource sharing means to share the resources available among many users.
In an office as it is very expensive to give a separate printer to each worker. So if
the printer is shared among the workers then a single printer will be accessible to each
worker. This leads to the motivation of resource sharing.

GOAL OF RESOURCE SHARING:

The goal of resource sharing is to make all programs, equipment and date
available to anyone in the network without regard to physical location of the resource and
the user.
For example: the sharing of a printer among the workers in an office and also the
sharing of information is a goal of resource sharing.

MAIN REASON FOR EARLY RESOURCE SHARING:

The main reason for early resource sharing was not to share the peripheral devices
rather to share the large-scale computational power because computer were extremely
expensive in those days and the government budgets were not sufficient to provide
computers for all scientist and engineers. By resource sharing a researcher could use
whichever computer was best suited to perform a given task.

EFFORTS OF ADVANCED RESEARCH PROJECT AGENCY (ARPA):

The efforts of ARPA was to enable all its research groups have access to latest
computers. For this purpose ARPA started investing in ways to do data networking
ARPA use a new approach consisting of packet switching and internet working to fulfill the purpose of resource sharing. As a result of ARPA research the first network was
established which was named ARPA NET.
In this way the internet was emerged in 1970’s and it has grown drastically since
then as shown in the figure below.

Figure. 2.1 Growth of the Internet
As shown in another figure below. In log scale the position on y-axis is proportional to
the log of the number being represented. So the values along y-axis represent the power
of 10.Fig. 2.2 Growth of the internet on Log Scale
We see that on log scale the growth appears almost linear it means that internet experienced an
exponential growth. We also observed that internet has been doubled every nine to twelve
months.

PROBING THE INTERNET:
Let us see how are the figures in above graphs obtained?
In the early days when there were some dozen computers on the network, it was done manually
but now as we have seen that there are millions of computers on the internet so how can we
calculate the number of computers connected to the internet. This is done through probing the
Internet.
Now an automated tool is required that tests to see whether the given computer is online or not.
For this purpose the first tool is the `PING program` which is shown in the figure below.

Figure 2.3 THE PING Command

We see that 5 packets of 64 bytes are sent to sears.com and 5 packets are received. We see that
ping has also given some additional information such the IP addresses of sears.com, the sequence
of packets and the times of transmission known as the round-trip time, as there is no packet loss
so it means that sears.com is connected to the internet

PROBLEM WITH ‘PING’:

Ping, as a tool seems to be simplistic. Now let’s see what are the problems attached with ping.
If ping does not review any responses from host computer it can not tell the reason of problem.
Because one of the following reasons occur but ping will not specify the reason.
  • Remote computer might have a problem.
  • Local computer might have a problem.
  • Ping sometimes fails because of congestion.
Some networks or computers reject the ping packets. They do this to avoid denial of service of
flooding attack.
Inspite of these problems ping is still heavily used as a diagnostic tool.
Network administrators use ping as soon as they learn about the failure.

TRACING A ROUTE:

There is another probing tool i-e Trace Route. To get more detail it is used.


Figure 2.4
As shown in the figure about the route to DANDELION-PATCH.MIT.EDU was traced out and
the program showed all eight computers that were in the way. The additional information is also
shown in the figure.
Thus we see that tracing a route is more interesting tool than Ping as it tells about each computer
that falls in the way of source and destination computers.

MASTERING THE COMPLEXITY

To master the complexity one must follow the following points.

• CONCENTRATE IN UNDERSTANDING THE CONCEPTS:

Instead of details of wires used to connect computers to a specific network, it is important
to understand a few basic categories of wiring schemes their advantages and
disadvantages.
For example:
Instead of how a specific protocol handles congestion, we should concentrate on
what congestion is and why it must be handled.

• LEARNING THE NETWORKING TERMINOLOGY:

The second tool for mastering the complexity is to learn the networking
terminology. In addition to this one must concentrate the concepts and not details,
concentrate on breath and not the depth of technologies, also one should understand the
analogies and illustrations
Network terminology is introduced with new concepts so it is much helpful to learn the
terminology to overcome the complexity of networks.

COMPLEXITY OF NETWORK SYSTEMS

Computer networks is a complex subject due to the following reasons

• MANY DIFFERENT TECHNOLOGIES EXIST:

The first reason for the complexity of networks is that there are many different
technologies exist for networking and each technology features are different from the
other. This is because many companies have developed networking standards, which
are not compatible with each other. In this way multiple technologies exist that are
used to connect different networks.

• NO SINGLE UNDERLYING THEORY OR MODEL:

The second reason for the complexity of networks is that there is no single underlying
theory or model, which specifies or defines different aspects of networking. Rather,
various organizations and research groups have developed conceptual models that can
be used to explain differences and similarities between network hardware and
software.

• MODELS ARE EITHER SO SIMPLISTIC OR SO COMPLEX:

Another reason for the complexity of networks is that the conceptual models
made by organization are either so simplistic that they do not
distinguish between details, or they are so complex that they do not simplify the
subject.

• NO SIMPLE OR UNIFORM TERMINOLOGY:

One reason for the complexity of networks is that there is no simple or uniform
terminology that can be used for the same feature. Different technologies use
different terminologies. In this way terms are confused with product names.

NETWORKS IN DAILY LIFE

The major use of networks is in business side. Networks are used for advertising,
production, shipping, planning, billing and accounting purposes. In fact now there is
an entire industry that develops networking equipment.
In addition to this networks are being used in homes as well for example, to
switch and control different devices from one place.
Networks are very much useful at government level as federal government, local
government and military organization use networks for communication purposes.
In education we have online libraries which we can visit at our home PC. This is
all just due to the networks.

Interrupt Mechanism

Interrupt follow a follow a certain mechanism for their invocation just like near or far procedures. To understand this mechanism we need to understand its differences with procedure calls.

Difference between interrupt and procedure calls
Procedures or functions of sub-routines in various different languages are called by different methods as can be seen in the examples.

  1. Call MyProc
  2. A= Addition(4,5);
  3. Printf(“hello world”);

The general concept for procedure call in most of the programming languages is that on invocation of the procedure the parameter list and the return address (which is the value if IP register in case of near or the value of CS and IP registers in case of far procedure) is pushed Moreover in various programming languages whenever a procedure is called its address need to be specified by some notation i.e. in C language the name of the procedure is specified to call a procedure which effectively can be used as its address.

However in case of interrupts the a number is used to specify the interrupt number in the call
  1. Int 21h
  2. Int 10h
  3. Int3
Fig 1 (Call to interrupt service routine and procedures/functions)
Moreover when an interrupt is invoked three registers are pushed as the return address i.e. the values of IP, CS and Flags in the described order which are restored on return. Also no parameters are pushed onto the stack on invocation parameters can only be passed through registers.
The interrupt vector table

The interrupt number specified in the interrupt call is used as an index into the interrupt vector table. Interrupt vector table is a global table situated at the address 0000:0000H. The size of interrupt vector table is 1024 bytes or 1 KB. Each entry in the IVT is sized 4 bytes hence 256 interrupt vectors are possible numbered (0-FFH). Each entry in the table contains a far address of an interrupt handlers hence there is a maximum of 256 handlers however each handlers can have a number of services within itself. So the number operations that can be performed by calling an interrupt service routine (ISR) is indefinite depending upon the nature of the operating system. Each vector contains a far address of an interrupt handler. The address of the vector and not the address of interrupt handler can be easily calculated if the interrupt number is known. The segment address of the whole IVT is 0000H the offset address for a particular interrupt handler can be determined by multiplying its number with 4 eg. The offset address of the vector of
INT 21H will be 21H * 4 = 84H and the segment for all vectors is 0 hence its far address is 0000:0084H,( this is the far address of the interrupt vector and not the interrupt service routine or interrupt handler). The vector in turn contains the address of the interrupt service routine which is an arbitrary value depending upon the location of the ISR residing in memory.

Fig 2 (Interrupt Vector Table)

Interrupt Vector Table
Moreover it is important to understand the meaning of the four bytes within the interrupt vector. Each entry within the IVT contain a far address the first two bytes (lower word) of which is the offset and the next two bytes (higher word) is the segment addressFig 3 (Far address within Interrupt vector)
Location of ISRs (Interrupt service routines)

Generally there are three kind of ISR within a system depending upon the entity which implements it
  1. BIOS (Basic I/O services) ISRs
  2. DOS ISRs
  3. ISRs provided by third party device drivers
When the system has booted up and the applications can be run all these kind of ISRs maybe provided by the system. Those provided by the ROM-BIOS would be typically resident at any location after the address F000:0000H because this the address within memory from where the ROM-BIOS starts, the ISRs provided by DOS would be resident in the DOS kernel (mainly IO.SYS and MSDOS.SYS loaded in memory) and the ISR provided by third party device drivers will be resident in the memory occupied by the device drivers.


Fig 4 (ISRs in memory)

This fact can be practically analyzed by the DOS command mem/d which gives the status of the memory and also points out which memory area occupied by which process as shown in the text below. The information given by this command indicates the address where IO.SYS and other device drivers have been loaded but the location of ROM BIOS is not shown by this command.

C:\>mem /d
Address Name Size Type
------- -------- ------ ------
000000 000400 Interrupt Vector
000400 000100 ROM Communication Area
000500 000200 DOS Communication Area

000700 IO 000370 System Data
CON System Device Driver
AUX System Device Driver
PRN System Device Driver
CLOCK$ System Device Driver
COM1 System Device Driver
LPT1 System Device Driver
LPT2 System Device Driver
LPT3 System Device Driver
COM2 System Device Driver
COM3 System Device Driver
COM4 System Device Driver

000A70 MSDOS 001610 System Data

002080 IO 002030 System Data
KBD 000CE0 System Program
HIMEM 0004E0 DEVICE=
XMSXXXX0 Installed Device Driver
000490 FILES=
000090 FCBS=
000120 LASTDRIVE=
0007D0 STACKS=
0040C0 COMMAND 000A20 Program
004AF0 MSDOS 000070 -- Free --
004B70 COMMAND 0006D0 Environment
005250 DOSX 0087A0 Program
00DA00 MEM 000610 Environment
00E020 MEM 0174E0 Program
025510 MSDOS 07AAD0 -- Free --
09FFF0 SYSTEM 02F000 System Program

0CF000 IO 003100 System Data
MOUSE 0030F0 System Program
0D2110 MSDOS 000600 -- Free --
0D2720 MSCDEXNT 0001D0 Program
0D2900 REDIR 000A70 Program
0D3380 DOSX 000080 Data
0D3410 MSDOS 00CBE0 -- Free --


655360 bytes total conventional memory
655360 bytes available to MS-DOS
597952 largest executable program size

1048576 bytes total contiguous extended memory
0 bytes available contiguous extended memory
941056 bytes available XMS memory
MS-DOS resident in High Memory Area

Interrupt Invocation

Although hardware and software interrupts are invoked differently i.e hardware interrupts are invoked by means of some hardware whereas software interrupts are invoked by means of software instruction or statement but no matter how an interrupt has been invoked processor follows a certain set steps after invocation of interrupts in exactly same way in both the cases. These steps are listed as below

  1. Push Flags, CS, IP Registers, Clear Interrupt Flag
  2. Use (INT#)*4 as Offset and Zero as Segment
  3. This is the address of interrupt Vector and not the ISR
  4. Use lower two bytes of interrupt Vector as offset and move into IP
  5. Use the higher two bytes of Vector as Segment Address and move it into CS=0:[offset+2]
  6. Branch to ISR and Perform I/O Operation
  7. Return to Point of Interruption by Popping the 6 bytes i.e. Flags CS, IP.

This can be analyzed practically by the use of debug program, used to debug assembly language code, by assembling and debugging INT instructions

C:\>debug
-d 0:84
0000:0080 7C 10 A7 00-4F 03 55 05 8A 03 55 05 |...O.U...U.
0000:0090 17 03 55 05 86 10 A7 00-90 10 A7 00 9A 10 A7 00 ..U.............
0000:00A0 B8 10 A7 00 54 02 70 00-F2 04 74 CC B8 10 A7 00 ....T.p...t.....
0000:00B0 B8 10 A7 00 B8 10 A7 00-40 01 21 04 50 09 AB D4 ........@.!.P...
0000:00C0 EA AE 10 A7 00 E8 00 F0-B8 10 A7 00 C4 23 02 C9 .............#..
0000:00D0 B8 10 A7 00 B8 10 A7 00-B8 10 A7 00 B8 10 A7 00 ................7
0000:00E0 B8 10 A7 00 B8 10 A7 00-B8 10 A7 00 B8 10 A7 00 ................
0000:00F0 B8 10 A7 00 B8 10 A7 00-B8 10 A7 00 B8 10 A7 00 ................
0000:0100 8A 04 10 02 ....

-a
0AF1:0100 int 21
0AF1:0102
-r
AX=0000 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000
DS=0AF1 ES=0AF1 SS=0AF1 CS=0AF1 IP=0100 NV UP EI PL NZ NA PO NC
0AF1:0100 CD21 INT 21
-t
AX=0000 BX=0000 CX=0000 DX=0000 SP=FFE8 BP=0000 SI=0000 DI=0000
DS=0AF1 ES=0AF1 SS=0AF1 CS=00A7 IP=107C NV UP DI PL NZ NA PO NC
00A7:107C 90 NOP
-d ss:ffe8
0AF1:FFE0 02 01 F1 0A 02 F2 00 00
0AF1:FFF0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00

The dump at the address 0000:0084 H shows the value of the vector of the interrupt # 21H i.e. 21H * 4 = 84H. This address holds the value 107CH in lower word and 00A7H in the higher word which indicates that the segment address of interrupt # 21 is 00A7H and the offset address of this ISR is 107CH.
Moreover the instruction INT 21H can be assembled and executed in the debug program, on doing exactly so the instruction is traced through and the result is monitored. It can be seen that on execution of this instruction the value of IP is changed to 107CH and the value of CS is changed to 00A7H which cause the execution to branch to the Interrupt # 21H in memory and the previous values of flags, CS and IP registers are temporarily saved onto the stack as the value of SP is reduced by 6 and the dump at the location SS:SP will show these saved values as well.
Parameter passing into Software interrupts

In case of procedures or function in various programming languages parameters are passed through stack. Interrupts are also kind of function provided by the operating system but they do not accept parameters by stack rather they need to passed parameters through registers.
Software interrupts invocation

Now let’s see how various interrupts can be invoked by means of software statements. First there should be way to pass parameters into a software interrupt before invoking the interrupt; there are several methods for doing this. One of the methods is the use of pseudo variables. A variable can be defined a space within the memory whose value can be changed during the execution of a program but a pseudo variable acts very much like a variable as its value can be changed anywhere in the program but is not a true variable as it is not stored in memory. C programming language provides the use of pseudo variables to access various registers within the processor.
The are various registers like AX, BX, CX and DX within the processor they can be directly accessed in a program by using their respective pseudo variable by just attaching a “_” (underscore) before the register’s name eg. _AX = 5; A = _BX .
After passing the appropriate parameters the interrupt can be directly invoked by calling the geninterrupt () function. The interrupt number needs to be passed as parameter into the geninterrupt() function.

Interrupt # 21H, Service # 09 description

Now lets learn by means of an example how this can be accomplished. Before invoking the interrupt the programmer needs to know how the interrupt behaves and what parameters it requires. Lets take the example of interrupt # 21H and service # 09 written as 21H/09H in short. It is used to print a string ending by a ‘$’ character and other parameters describing the string are as below
Inputs
AH = 0x09
DS = Segment Address of string
DX = Offset Address of string
Output
The ‘$’ terminated string at the address DS:DX is displayed
One thing is note worthy that the service # is placed in AH which is common with almost all the interrupts and its service. Also this service is not returning any siginificant data, if some service needs to return some data it too is received in registers depending upon the particular interrupt.

Example:

#include
#include
#include

#include

char st[80] ={"Hello World$"};

void main()
{
clrscr(); //to clear the screen contents
_DX = (unsigned int) st;
_AH = 0x09;

geninterrupt(0x21);
getch(); //waits for the user to press any key
}

this is a simple example in which the parameters of int 21H/09H are loaded and then int 21H is invoked. DX and AH registers are accessed through pseudo variables and then geninterrupt()is called to invoke the ISR. Also note that _DS is not loaded. This is th
e case as the string to be loaded is of global scope and the C language compiler automatically loads the segment address of the global data into the DS register.

Another Method for invoking software interrupts
This method makes use of a Union. This union is formed by two structure which correspond to general purpose registers AX, BX, CX and DX. And also the half register AH, AL, BH, BL, CH, CL, DH, DL. These structures are combined such that through this str
ucture the field ax can be accessed to load a value and also its half components al and ah can be accessed individually. The declaration of this structure goes as below. If this union is to be used a programmer need not declare the following declaration rather declaration already available through its header file “dos.h”

struct full

{
unsigned int ax;
unsigned int bx;
unsigned int cx;
unsigned int dx;
};
struct half
{
unsigned char al;

unsigned char ah;
unsigned char bl;
unsigned char bh;
unsigned char cl;
unsigned char ch;
unsigned char dl;
unsigned char dh;
};
typedef union tagREGS

{
struct full x;
struct half h;
}REGS;

This union can be used to signify any of the full or half general purpo
se register shows if the field ax in x struct is to be accessed then accessing the fields al and ah in h will also have the same effect as show in the example below.
Example:

#include

union REGS regs;
void main (void )

{
regs.h.al = 0x55;
regs.h.ah = 0x99;
printf (“%x”,regs.x.ax);
}


output:
9955

The int86() function
The significance of this REGS union can only be understood after understanding the int86() function. The int86() has three parameters. The first parameter is the interrupt number to be invoked, the second parameter is the reference to a REGS type union which contains the value of parameters that should be passed as inputs, and third parameter is a reference to a REGS union which will contain the value of registers returned by this function. A
ll the required parameters for an ISR are placed in REGS type of union and its reference is passed to an int86() function. This function will put the value in this union into the respective register and then invoke the interrupt. As the ISR returns it might leave some meaningful value in the register (ISR will return values), these values can be retrieved from the REGS union whose reference was passed into the function as the third parameter.
Example using interrupt # 21H service # 42H

To make it more meaningful we can again elaborate it by means of an example. Here we make use of ISR 21H/42H which is used to move the file pointer. Its detail is as follows

Int # 21 Service # 42H
Inputs
AL = Move Technique

BX = File Handle
CX-DX = No of Bytes File to be moved
AH = Service # = 42H

Output
DX-AX = No of Bytes File pointer actually moved.
This service is used to move the file pointer to a certain position relative to a certain point. The value in AL specify the point relative to which the pointer is moved. If the value of AL = 0 then file pointer is moved relative to the BOF (begin of File) if AL=1 then its moved relative to current position and if AL = 2 then its moved relative to the EOF (end of file).
CX-DX specify the number of bytes to move a double word is needed to specify this value as the size of file in DOS can be up to 2 GB.
On return of the service DX-AX will contain the number of bytes the file pointer is actually moved eg. If the file pointer is moved relative to the EOF zero bytes the DX-AX on return will contain the size of file if the file pointer was at BOF before calling the service.