Sie sind auf Seite 1von 85

Hardware Lab Manual

PIMPRI CHINCHWAD COLLEGE OF ENGINEERING


DEPARTMENT OF COMPUTER ENGINEERING
PRACTICAL MANUAL
CLASS

: T.E. Computer

SEMESTER- I

SUBJECT : Hardware Laboratory


Assignment No:
Aim:

Write an Assembly Language Program (ALP) to simulate TYPE command using


Program Segment Prefix (PSP).

Objective:
1)

To study file related functions of INT 21H, like open file, close file, read
file and write file.

2)

To Study the structure of Program Segment Prefix.

3)

To write an ALP to simulate TYPE command using PSP.

Theory:
DOS/ BIOS interrupt functions used:
1) Open File
INT 21H

Open File

Function 3DH

Given an ASCIIZ pathname opens the specified file in the designated or default directory on
the designated or default disk drive. A handle is returned which can be used by the program
for subsequent access to the file.
Calling Parameters:
AH = 3DH
AL = Access Mode
Bits
0-2

Significance
access mode
000 = read access
001 = write access
000 = read/write access
DS : DX = Segment : offset of ASCIIZ path name
Returns:
1

Hardware Lab Manual

If function successful
Carry flag = Clear
AX = handle
If function un successful
Carry flag = Set
AX = Error Code

2) Close File
INT 21H

Close File

Function 3EH

A handle that was obtained by a previous successful open or create operation, flushes all
internal buffers associated with the file to disk, close the file, and releases the handle for
reuse. If the file was modified, the time and date stamp and file size are updated in the files
directory entry.
Calling Parameters:
AH = 3EH
BX = handle
Returns:
If function successful
Carry flag = Clear
If function un successful
Carry flag = Set
AX = Error Code

3) Read File
INT 21H

Read File or Device

Function 3FH

Given a valid file handle from a previous open or create operation, a buffer address, and a
length in bytes, transfers data at the current file pointer position from the file into the
buffer and then updates the file pointer position.
Calling Parameters:
AH = 3FH
BX = handle
CX = number of bytes to read
DS : DX = segment : offset of buffer
Returns:
If function successful
Carry flag = Clear
2

Hardware Lab Manual

AX = bytes transferred
If function un successful
Carry flag = Set
AX = Error Code

4) Write File
INT 21H

Write File or Device

Function 40H

Given a valid file handle from a previous open or create operation, a buffer address, and a
length in bytes, transfers data from the buffer into the file and then updates the file pointer
position.
Calling Parameters:
AH = 40H
BX = handle
CX = number of bytes to write
DS : DX = segment : offset of buffer
Returns:
If function successful
Carry flag = Clear
AX = bytes transferred
If function un successful
Carry flag = Set
AX = Error Code

Hardware Lab Manual

Structure of PSP:
Figure : Structure of Program Segment Prefix

Hardware Lab Manual

Algorithm:
1.

Start

2.

Request for PSP address (INT 21H/ function 62H)

3.

PSP will return address in BX. Initialize ES with BX

4.

Check ES:[0080H] for command length. If command length = 0 then display


Syntax Error message and exit.

5.

If command length is not zero, then copy filename in FileName variable from ES:
[0082H] upto command length -1 or upto 0DH. At ES:[0081H] space character
(20H) is stored.

6.

Open file in read mode with INT 21H/ Function 3DH.

7.

If Carry = 1 then display File not exists message and exit. Else store handle in
handle variable.

8.

Read file contents in buffer using INT 21H / Function 3FH and handle.

9.

If Carry = 1 then display Error in Reading File message and exit. Else store bytes
transferred (from AX).

10.

Write buffer contents to screen (handle = 0001H) using INT 21H / Function 40H
and screen handle.

11.

Check the end of file. If end of file not occurs then goto step 8

12.

Close the file using INT 21H/ Function 3EH and handle.

13.

Stop

Conclusion:
Hence we studied File management functions of operating system by using
interrupt 21H functions and simulated the TYPE command using PSP.

Hardware Lab Manual

PIMPRI CHINCHWAD COLLEGE OF ENGINEERING


DEPARTMENT OF COMPUTER ENGINEERING
PRACTICAL MANUAL
CLASS

: T.E. Computer

SEMESTER- I

SUBJECT : Hardware Laboratory


Assignment No:
Aim:

Write an Assembly Language Program (ALP) to simulate COPY command using


Program Segment Prefix (PSP).

Objective: 1)
2)

To study file related functions of INT 21H, like create a file and create a
new file.
To write an ALP to simulate COPY command using PSP.

Theory:
DOS/ BIOS interrupt functions used:
1) Create File
INT 21H

Create File

Function 3CH

Given an ASCIIZ pathname creates a new file in the designated or default directory on the
designated or default disk drive. If the specified file is already exists,. In either case, the file
is opened and a handle is returned that can be used by the program for subsequent access to
the file.
Calling Parameters:
AH = 3CH
CX = file attribute
Bits Significance (if set)
0
read only
1
hidden
2
system
3
volume label
DS : DX = Segment : offset of ASCIIZ path name
Returns:
6

Hardware Lab Manual

If function successful
Carry flag = Clear
AX = handle
If function un successful
Carry flag = Set
AX = Error Code

2) Create New File


INT 21H

Create new File

Function 5BH

Given an ASCIIZ pathname creates a new file in the designated or default directory on the
designated or default disk drive, and a handle is returned that can be used by the program
for subsequent access to the file. If the same name already exists, the function fails.
Calling Parameters:
AH = 5BH
CX = file attribute
Bits Significance (if set)
0
read only
1
hidden
2
system
3
volume label
DS : DX = Segment : offset of ASCIIZ path name
Returns:
If function successful
Carry flag = Clear
AX = handle
If function un successful
Carry flag = Set
AX = Error Code

Hardware Lab Manual

Algorithm:
1.

Start

2.

Request for PSP address (INT 21H/ function 62H)

3.

PSP will return address in BX. Initialize ES with BX

4.

Check ES:[0080H] for command length. If command length = 0 then display


Syntax Error message and exit.

5.

If command length is not zero, then copy filenames in FileName1 & FileName2
variables from ES:[0082H] upto command length -1 or upto 0DH. At ES:[0081H]
space character (20H) is stored.

6.

Open 1st file in read mode with INT 21H/ Function 3DH.

7.

If Carry = 1 then display Source File not exists message and exit. Else store
handle1 in handle variable.

8.

Create 2nd file in write mode with INT 21H/ Function 3CH or INT 21H/ Function
5BH.

9.

If Carry = 1 then display Destination File creation error message and exit. Else
store handle2 in handle variable.

10.

Read file1 contents in buffer using INT 21H / Function 3FH and handle1.

11.

If Carry = 1 then display Error in Reading Source File message and exit. Else
store bytes transferred (from AX).

12.

Write buffer contents to file2 using INT 21H / Function 40H and handle2.

13.

If Carry = 1 then display Error in Writing Destination File message and exit.

14.

Check the end of file1. If end of file not occurs then goto step 10.

15.

Close the files using INT 21H/ Function 3EH and handle1 & handle2.

16.

Display File copied successfully message.

17.

Stop

Conclusion:
Hence we studied File functions of operating system by using interrupt 21H
functions and simulated the COPY command using PSP.

Hardware Lab Manual

PIMPRI CHINCHWAD COLLEGE OF ENGINEERING


DEPARTMENT OF COMPUTER ENGINEERING
PRACTICAL MANUAL
CLASS

: T.E. Computer

SEMESTER- I

SUBJECT : Hardware Laboratory


Assignment No:
Aim:

Write an ALP / in line code for displaying boot sector of floppy and boot record
of hard disk.

Objective:
1)

To study functions related to ROM BIOS of INT 13H, like read sector and
Absolute disk read of INT 25H.

2)

To study the structure of Boot Sector of Floppy.

3)

To study the structure of boot sector of Hard Disk.

4)

To write an in-line code for reading and displaying the boot sector of
floppy and boot record of hard disk.

Theory:
DOS/ BIOS interrupt functions used:
1) Read Sector
INT 13H

Read Sector

Function 02H

Reads one or more sectors from disk into memory


Calling Parameters:
AH = 02H
AL = number of sectors
CH = cylinder / track
CL = sector
DH = head
DL = drive
(00H 7FH floppy disk
80H FFH fixed disk)
DS : BX = Segment : offset of buffer
Returns:
9

Hardware Lab Manual

If function successful
Carry flag = Clear
AH = 00H
AL = number of sectors transferred
If function un successful
Carry flag = Set
Ah = status
AH contains
00H No Error
01H bad command
02H bad address
03H disk write protected
04H sector not found
06H floppy disk removed
0AH bad sector flag
0BH bad track flag
40H seek operation failed
80H disk timed-out

2) Absolute disk read


INT 25H

Absolute disk read

Provides a direct linkage to the MS DOS BIOS module to read data from a logical disk
sector into memory.
Calling Parameters:
For access to partitions <=32 MB
AL = Drive number ( 0 =A, 1=B, etc)
CX = number of sectors to read
DX = starting sector number
DS : BX = Segment : offset of buffer
Returns:
If function successful
Carry flag = Clear
If function un successful
Carry flag = Set
AX = Error Code
AH contains
00H No Error
01H bad command
02H bad address
03H disk write protected
04H sector not found
06H floppy disk removed
0AH bad sector flag
0BH bad track flag
40H seek operation failed
10

Hardware Lab Manual

80H

disk timed-out

Boot Sector of Floppy:


Figure:

Structure of Boot Sector of Floppy

11

Hardware Lab Manual

Conclusion:
Hence we studied the structure of Boot sector of floppy and boot record of hard
disk. Also we have studied functions for reading a sector of floppy and hard disk
of INT 13H/function 02H or INT 25H.

12

Hardware Lab Manual

PIMPRI CHINCHWAD COLLEGE OF ENGINEERING


DEPARTMENT OF COMPUTER ENGINEERING
PRACTICAL MANUAL
CLASS

: T.E. Computer

SEMESTER- I

SUBJECT : Hardware Laboratory


Assignment No:
Aim:

Write an Assembly Language Program (ALP) / in line code for displaying file
contents using Root Directory and FAT for floppy disk.

Objective:
1)

To study Structure of Root Directory

2)

To study structure of FAT (File Allocation Table), and calculation of FAT


Chain for a particular file.

Theory:
File Allocation Table (FAT):
Fat is the master index of where all information is stored on a disk. The FAT stores
information about every cluster of the disk residing in the data area of the disk. The data
area of the disk refers to all sectors that follow the reserved disk sectors. Reserved
sectors are used for boot, FAT, and root directory information.
Diskette
3.5, 1.44MB

FAT sectors

DIR Sectors

18

14

Data Area
2847

The free data sectors are grouped into clusters, with the first free cluster numbered 2.
Thus, the first file stored on a disk begins at cluster 2.
The Fat stores a special number for each cluster on the disk. This number, called a FAT
entry, is 12 bit long for floppy diskettes. The first 2 entries (03 bytes) of the FAT are
reserved by DOS (to store media descriptor byte for the disk (F0H).
The cluster entry in a FAT may contain any of the following values:
13

Hardware Lab Manual

Value

Meaning

000

Cluster Available

002 FEF

Next cluster in file or directory

FF0 FF6

Reserved

FF7

Bad sector in cluster

FF8 FFF

Last cluster in file or directory

Because FAT cluster entries are 12 bits long, they do not completely fill a 16 bit
word. DOS places two FAT entries together, resulting in a 24 bit pattern that fits
exactly into 3 bytes. The structure of this 24 bit FAT entry pair is shown below:

Figure:
A7-4

A3-0

Structure of a FAT entry pair

B3-0

1st Byte

A11-8

B11-8 B7-4

2nd Byte

3rd Byte

FAT Chain :
The FAT entries for a particular file form a chain. When a FAT entry is between 002H
and FEFH, it represents the next cluster in a chain of clusters. A simplified Fat is shown
in figure. The FAT contains entries for two files. If the first file begins with cluster 2,
we get the cluster chain:
2

The chain ends at cluster 5 due to the FFFH entry. If the starting cluster for the 2 nd file is
6, the resulting cluster chain is
6

14

12

11

The files may be physically stored all over a disk, and still be logically connected,
through their associated cluster chain.

Figure:

Simplified FAT with cluster chains


14

Hardware Lab Manual

* Reserved

Interpreting the FAT

o If the FAT has 12 bit entries, use the following procedure:


1.

Use the directory entry to find the starting cluster of the file.

2.

Multiply the cluster number by 1.5.

3.

Use integral part of the product as the offset into the FAT and move the
word at that offset into a register.

4.

If the product is a whole number, AND the register with 0FFFH.

5.

Otherwise, logical shift the register right 4 bits.

6.

If the result is a value from 0FF8H through 0FFFH, the file has no more
clusters. Otherwise, the result is the number of the next cluster in the file.

o If the FAT has 16 bit entries, use the following procedure:


1.

Use the directory entry to find the starting cluster of the file.

2.

Multiply the cluster number by 2.

3.

the product as the offset into the FAT and move the word at that offset into
a register.

4.

If the result is a value from 0FFF8H through 0FFFFH, the file has no more
clusters. Otherwise, the result is the number of the next cluster in the file.

15

Hardware Lab Manual

Root Directory :
Following the File Allocation Table is an area known as the root directory. The root
directory contains 32-byte entries that describe files, other directories, and the optional
volume label. An entry beginning with the byte value E5H is available for reuse; it
represents a file or directory that has been erased. An entry beginning with a null (zero)
byte is the logical end of directory; that entry and all subsequent entries have never
been used.
Figure: Format of a single entry in a disk directory.
Total length is 32 bytes (20H bytes)

16

Hardware Lab Manual

17

Hardware Lab Manual

Figure :

Figure :

Figure :

Figure :

18

Hardware Lab Manual

Algorithm:
1.

Start

2.

Read FAT Sectors in buffer using INT 25 (absolute disk read).


[Sector no : 01-09 ( total 09 sectors)

3.

If FAT sector read unsuccessful then display error message and exit.

4.

Read Root Directory Entry Sectors in buffer using INT 25 (absolute disk read).
[Sector no : 19-32 ( total 14 sectors)

5.

If Root Directory Entry read unsuccessful then display error message and exit.

6.

Read file name and convert it into uppercase.

7.

Read file extension and convert it into uppercase.

8.

Compare file name with entry from root directory.

9.

If file name is same then check for extension. Else goto step 8.

10.

If extension is same then read starting sector of file at offset 26 (1AH), set flag
= 1 and come out of the loop. Else goto step 8.

11.

If flag = 0, then display message File not found.. and exit.

12.

Read fat chain using starting sector number and display on the screen.

13.

If cluster number = FFF H then display message End of file and exit.

19

Hardware Lab Manual

14.

Convert cluster number into sector number using formula:


Sector no = (Cluster no 2) x (no. of sectors / Cluster) + Data Sector
Sector no = (cluster no 2) x 1 + 33

15.

Read Sector contents from floppy in buffer.

16.

Display buffer contents on the screen.

17.

Read next cluster number.

18.

Goto step 13.

Conclusion:
Hence we studied structure of FAT, structure of Root directory entry and also
calculated the fat chain of file. We have implemented an in line code for reading
contents of file from floppy disk using FAT and Root directory.

20

Hardware Lab Manual

PIMPRI CHINCHWAD COLLEGE OF ENGINEERING


DEPARTMENT OF COMPUTER ENGINEERING
PRACTICAL MANUAL
CLASS

: T.E. Computer

SEMESTER- I

SUBJECT : Hardware Laboratory


Assignment No:
Aim:

Write an installable DOS Device Driver for a printer.

Objective:
1)

To study MS DOS Device Driver Basics i.e. Types of Device Drivers,


Creating Device Driver, Structure of Device Driver, etc.

2)

To Study the structure of Program Segment Prefix.

3)

To write an ALP for DOS device Driver for Printer (Character Device
Driver).

Theory:
Installable Device Drivers:
Device drivers are the modules of an operating system that control hardware. The
motherboard ROM and IBMBIO.COM or IO.sys files contains the basic driver for
allowing DOS to talk to the console, disk drives, serial and parallel ports, clock and
other resources.
The device driver is a COM file that contains all the code needed to control an addin device.
DOS can install the device driver anywhere in memory, so care must be taken in
any FAR memory references. We should not expect that your driver will be loaded
in the same place every time.

MS-DOS device drivers Types:


There are two types of device drivers supported by MS-DOS:
21

Hardware Lab Manual

1) Character device drivers:


Character device drivers control peripheral devices that perform input and
output one character at a time, such as terminal or printer.
2) Block Device Drivers:
Block device drivers usually control random access mass storage
devices. Such as floppy disk drivers and fixed disk, although they can also
be used to control non random access devices such as magnetic tape drive.

Comparison between Character and Block drivers


Sr.No.

Character Device Drivers

Block Device Drivers

Perform input and output at a time

Transfers data in blocks rather than one


byte at a time

Support single hardware

Support more than one hardware unit

Have logical name assigned to them

Do not have file like logical names

Usually control terminal or printer

Usually Control Floppy- disk, fixed or


magnetic tape drivers.

Creating a Device Driver:


To create a device driver that DOS can install, we must do the following.
1. Create a COM file with a device header at the start of the file.
2. Originate the code (including the device header) at 0, instead of 100H.
3. Set the next device header field. Refer to Pointer to Next Device Header Attribute
Field for more information.
4. Set the attribute field of the device header. Refer to attribute field for more
information.
5. Set the entry points for the interrupt and Strategy routines.
6. Fill in the name/unit field with the name of the character device or the unit number of
the block device.

Structure of a Device Driver:


22

Hardware Lab Manual

A device driver consists of three major parts


1. A device header
2. A strategy routine
3. An interrupt routine
Device Header
Strategy Routine
Initialization
Media check
Build BPB
IOCTL read and write
Status
Read
Interrupt Entry

Write, write/verify
Output until busy
Flush buffers
Device open
Device close
Check whether removable
Generic IOCTL
Get/Set logical device

Figure: General Structure of an MS DOS Installbale Device Driver


1.

A Device Header
The driver has a special header to identify it as a device and to define the Strategy and
Interrupt Entry points and its various attributes. This header is located at the beginning of
the file.

23

Hardware Lab Manual

Figure: Device-driver header.

Bit Significance (Attribute word)

24

Hardware Lab Manual

Pointer to strategy Routine


This field contains a pointer to device strategy function in the driver. This function is
called whenever a request is made to the driver, and must store the location of the request
header from DOS

Pointer to Interrupt Routine


This field contains a pointer to the function which activates driver routine to perform the
command in the current request header.

Logical Name field (Device ID)


This is an 8- byte field that contains the name of a character device of the number of units
in a block device.

2.

Strategy Routine:
MS-DOS calls the strategy routine (strat) for the device when the driver is first loaded
and installed, and again whenever an application program issues an I/O request for the
device. MS-DOS passes the strategy routine a double-word pointer to a data structure
called a request header. This structure contains information about the type of operation to
be performed.
In this strategy routine, save es ; bx returned for the request header

Request Header Structure


Request
Rlength
Unit
Command
Status
Reserve
Media
Address
Count
Sector
Request

3.

Structure
DB ?
DB ?
DB ?
DW ?
DB 8 DUP (?)
DB ?
DD ?
DW ?
DW ?
ENDS

Request Header Template Structure


0 length of request header
1 unit number for this request
2 request header's command code
3 driver's return status word
5 reserved area
13 media descriptor byte
14 memory address for transfer
18 byte/sector count value
20 starting sector value
end of request header template

Interrupt routine
25

Hardware Lab Manual

The last and most complex part of a device driver is the interrupt routine (intr), which
MS-DOS calls immediately after it calls the strategy routine. The interrupt routine
implements the device driver proper; it performs (or calls other resident routines to
perform) the actual input or output operations, based on the information passed in the
request header.
The interrupt routine usually consists of the following elements:
A collection of subroutines to implement the various function types that may be
requested by MS-DOS (sometimes called the command-code routines)
A centralized entry point that saves all affected registers, extracts the desired function
code from the request header, and branches to the appropriate command-code routine
(typically accomplished with a jump table)
A centralized exit point that stores status and error codes into the request header (Figure)
and restores the previous contents of the affected registers
Bit(s)

Significance

15

Error

12-14

Reserved

Busy

Done

0-7

Error code if bit 15 = 1

In Summary Interrupt Routine :


o Called after the strategy routine
o Implements the device driver properly
o Performs the actual I/O operations
o Collection of subroutines to implement various centralized entry routine, saves
registers and sets up driver ops
o Centralized exit routine restores registers and sets status & error codes.

26

Hardware Lab Manual

The Command-Code Routines


A total of 20 command codes are defined for MS-DOS device drivers. The command
codes (which are not consecutive), the names of the associated driver-interrupt routines,
and the MS-DOS versions in which they are first supported are as follows:
Command Code
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
19
23
24

Function
Init (Initialization)
Media Check
Build BPB
IOCTL Read
Read
Nondestructive Read
Input Status
Flush Input Buffers
Write
Write with verify
Output Status
Flush Output Buffers
IOCTL Write
Device Open
Device Close
Removable Media
Output until Busy
Generic IOCTL
Get Logical Device
Set Logical Device

Printer Interrupt functions used:


1) Write Character to Printer
INT 17H

Write Character to Printer

Function 00H

Sends character to the specified Parallel Printer Interface Port and return the current status
of port.
Calling Parameters:
AH = 00H
AL = Character
DX = Printer Number
[0 LPT1, 1 LPT2, 2 LPT3, etc.]
Returns:
AH = Status

2) Initialize Printer Port


27

Hardware Lab Manual

INT 17H

Initialize Printer Port

Function 01H

Initialize the specified Parallel Printer Interface Port and returns its status.
Calling Parameters:
AH = 01H
DX = Printer Number
[0 LPT1, 1 LPT2, 2 LPT3, etc.]
Returns:
AH = Status

Installing Device Drivers:


o DOS installs new device drivers dynamically at boot time by reading &
processing the DEVICE command in the CONFIG.SYS file.
o For example if you have written a device driver called PRINTER_DRV. To
install it, put this command in the CONFIG.SYS file.
DEVICE = [drive][path]
i.e. DEVICE = d:\masm\PRINTER_DRV.exe
o DOS issues a FAR call to the device driver at its strategy entry point first using
the request header to pass information describing what DOS wants the device
driver to do.
o The 2nd entry point is the interrupt routine and is called by DOS immediately after
the strategy routine returns.

Note: It is the responsibility of the device driver to preserve the machine state.
For example: Save all registers on entry (push) and restore them on exit (pop).

28

Hardware Lab Manual

Algorithm:
1.
2.

Start
Define a header block which initializes all the links & makes them point to the
desired locations.

3.
4.
5.
6.

In the strategy routine save ES : BX returned for the request header.


In the interrupt routine, push all the register contents on the stack.
In the interrupt routine, check the command codes of the request header.
If the command code is 00H (init), call the initialization procedure that initializes
the printer

7.

If the command code is 08H(write) then call the simple write procedure that
writes the character to printer.

8.
9.
10.

At the end, set the done bit and pass it back to the request header.
Pop all register contents from stack.
Implement all procedures [commands], at the end of the interrupt routine and
initialization procedure should be the last procedure.

11.

Stop

29

Hardware Lab Manual

Steps for Execution:


1.

Create print.asm file

(program)

2.

Create print.obj

(using masm)

3.

Create print.exe

(using link)

4.

Create config.sys file in boot drive e.g. C:


like
c:\> edit config.sys

5.

Type following line in config.sys


DEVICE = D:\masm\print.exe
& save the file.
[here give the path of the .exe file]

6.

Restart the computer & press F8.

7.

Boot Menu will be displayed. Choose Command Prompt Only.

8.

Create a text file e.g. abc.txt.

9.

Type the following command on command prompt.


C:\> Type abc.txt > TECOMP

10.

This command will print the contents of abc.txt on printer page using printer.

11.

Here TECOMP is the logical device driver name declared in header field.

Conclusion:

30

Hardware Lab Manual

PIMPRI CHINCHWAD COLLEGE OF ENGINEERING


DEPARTMENT OF COMPUTER ENGINEERING
PRACTICAL MANUAL
CLASS

: T.E. Computer

SEMESTER- I

SUBJECT : Hardware Laboratory


Assignment No:
Aim:

Write a C Program for PC to PC Communication.


a)

File Transfer

b)

Full duplex character transfer (Chat Application)

1)

To study communication related functions of INT 14H, like initialize


communication port, Send, Receive, Check Status of Port.

2)

To Study C functions related to communication link bioscom(), inportb(),


outportb().

3)

To write C program for File Transfer & Receive.

4)

To write C program for Chat application.

Objective:

Theory:
Serial Communication Interrupt (INT 14H) functions used:
1) Initialize Communications Port
INT 14H

Initialize Communications Port

Function 00H

Initializes a serial communications port to a desired baud rate, parity, word length, and
number of stop bits.
Calling Parameters:
AH = 00H
AL = Initialization Parameter (see notes)
DX = Communication Port Number
[0 COM1, 1 COM2, etc.]
Returns:
31

Hardware Lab Manual

AH = Port Status
Bits Significance (if set)
0
receive data ready
1
overrun error detected
2
parity error detected
3
framing error detected
4
break detected
5
transmit holding register empty
6
transmit shift register empty
7
timed-out
Note : The initialization parameter byte is defined as follows:
7 6 5
4 3
2
1 0
Baud rate
Parity
Stop bits
Word length
000 = 110
X0 = none
0 = 1 bit
10 = 7 bits
001 = 150
01 = odd
1 = 2 bits
11 = 8 bits
010 = 300
11 = even
011 = 600
100 = 1200
101 = 2400
110 = 4800
111 = 9600

2) Write character to communications port


INT 14H

Write character to communications port

Function 01H

Writes a character to the specified serial communications port, returning the current status
of the port..
Calling Parameters:
AH = 01H
AL = Character
DX = Communication Port Number [0 COM1, 1 COM2, etc.]
Returns:
If function successful
AH bit 7 = 0
AH bits 0 6 = Port Status
If function un successful
AH bit 7 = 1
AL = Character

3) Read character from communications port


32

Hardware Lab Manual

INT 14H

Read character from communications port

Function 02H

Reads a character from the specified serial communications port, also returning the port's
status.
Calling Parameters:
AH = 02H
DX = Communication Port Number [0 COM1, 1 COM2, etc.]
Returns:
If function successful
AH bit 7 = 0
AH bits 0 6 = Port Status
AL = Character
If function un successful
AH bit 7 = 1

4) Get Communications Port Status


INT 14H

Get Communications Port Status

Function 03H

Returns the status of the specified serial communications port.


Calling Parameters:
AH = 03H
DX = Communication Port Number [0 COM1, 1 COM2, etc.]
Returns:
AH = Port Status
AL = Modem Status

33

Hardware Lab Manual

Serial Communication C functions used:


There are two popular methods of sending data to or from the serial port in Turbo C. One
is using outportb(PORT_ID, DATA) or outport(PORT_ID,DATA) defined in dos.h.
Another method is using bioscom() function defined in bios.h.

1) BIOSCOM:
The macro bioscom () and function _bios_serialcom() are used in this method in the
serial communication using RS-232 connecter. First we have to set the port with the
settings depending on our need and availability. In this method, same function is used to
make the settings using control word, to send data to the port and check the status of the
port. These actions are distinguished using the first parameter of the function. Along with
that we are sending data and the port to be used to communicate.
Here are the deatails of the Turbo C Functions for communication ports.
Declaration:
bioscom(int cmd, char abyte, int port)
Bioscom uses BIOS interrupt 14H to perform various RS 232 communications over
the I/O ports given in port.
cmd: The I/O operation to be performed.
cmd (boiscom)

Action

Initialise the parameters to the port

Send the character to the port

Receive character from the port

Returns rhe current


communication port

status

of

the

portid: port to which data is to be sent or from which data is to be read.


34

Hardware Lab Manual

0: COM1
1: COM2
2: COM3
abyte:
When cmd =2 or 3 parameter abyte is ignored.
When cmd = 0, abyte is an OR combination of the following bits
(One from each group):
value of abyte

Meaning

0x02
0x03

7 data bits
8 data bits

0x00
0x04

1 stop bit
2 stop bits

0x00
0x08
0X10

No parity
Odd parity
Even parity

0x00
0x20
0x40
0x60
0x80
0xA0
0xC0
0xE0

_COM_110
_COM_150
_COM_300
_COM_600
_COM_1200
_COM_2400
_COM_4800
_COM_9600

110 baud
150 baud
300 baud
600 baud
1200 baud
2400 baud
4800 baud
9600 baud

For example, if
abyte = 0x8B = (0x80 | 0x08 | 0x00 | 0x03)
The communications port is set to
1200 baud

(0x80 = _COM_1200)

Odd parity

(0x08 = _COM_ODDPARITY)

1 stop bit

(0x00 = _COM_STOP1)

8 data bits (0x03 = _COM_CHR8)


To initialise the port with above settings we have to write,
bioscom(0, 0x8B, 0);
35

Hardware Lab Manual

To send a data to COM1, the format of the function will be bioscom(1, data, 0).
Similarly bioscom(1, 0, 0 ) will read a data byte from the port.
The following example illustrate how to serial port programs. When a data is
available in the port, it inputs the data and displays onto the screen and if a key is pressed
the ASCII value will be sent to the port
Example: BIOSCOM
#include <bios.h>
#include <conio.h>
#define COM1
0
#define DATA_READY 0x100
#define TRUE
1
#define FALSE
0
#define SETTINGS ( 0x80 | 0x02 | 0x00 | 0x00)
int main(void)
{
int in, out, status, DONE = FALSE;
bioscom(0, SETTINGS, COM1);
/*initialize the port*/
cprintf("... BIOSCOM [ESC] to exit ...\n");
while (!DONE)
{
status = bioscom(3, 0, COM1);
/*wait until get a data*/
if (status & DATA_READY)
if ((out = bioscom(2, 0, COM1) & 0x7F) != 0) /*input a data*/
putch(out);
if (kbhit())
{
if ((in = getch()) == '27')
/* ASCII of Esc*/
DONE = TRUE;
bioscom(1, in, COM1);
/* output a data*/
}
}
return 0;
}

36

Hardware Lab Manual

2) INPORTB:
It reads a byte from a hardware port. It is a macro that reads a byte.
Declaration :
unsigned char inportb (int portid);
INPORTB EXAMPLE
#include <stdio.h>
#include <dos.h>
int main(void)
{
unsigned char result;
int port = 0;
/* serial port 1 */
result = inportb(port);
printf("Byte read from port %d = 0x%X\n", port, result);
return 0;
}

3) OUTPORTB:
Outportb outputs a byte to a hardware port. outportb is a macro that writes value.
Declaration :
void outportb (int portid, unsigned char value);
OUTPORTB EXAMPLE
#include <stdio.h>
#include <dos.h>
int main(void)
{
int port = 0;
char value = 'C';
outportb(port, value);
printf("Value %c sent to port number %d\n", value, port);
return 0;
}

37

Hardware Lab Manual

RS 232 DB9 Connector:


RS-232 stands for Recommend Standard number 232 and C is the latest revision of the
standard. The serial ports on most computers use a subset of the RS-232C standard. The
full RS-232C standard specifies a 25-pin "D" connector of which 22 pins are used. Most
of these pins are not needed for normal PC communications, and indeed, most new PCs
are equipped with male D type connectors having only 9 pins. The pin outs of D-9 is
shown below.

The transmit and receive line on this connecter send and receive data between the
computers. As the name indicates, the data is transmitted serially. The two pins are TXD
& RXD. There are other lines on this port as RTS, CTS, DSR, DTR, and RTS, RI. The
1 and 0 are the data which defines a voltage level of 3V to 25V and -3V to -25V
respectively.

38

Hardware Lab Manual

About DTE & DCE:


Devices, which use serial cables for their communication, are split into two categories.
These are DCE (Data Communications Equipment) and DTE (Data Terminal
Equipment.) Data Communications Equipments are devices such as your modem. A
typical Data Terminal Device is a computer and a typical Data Communications Device
is a Modem.
NULL MODEM
Null modem is used to connect two DTE's together. This is used to transfer files between
the computers using protocols like Zmodem protocol, xmodem protocol, etc

Figure: Above shows the connections of the Null modem using RS-232D connecter
Above-mentioned figure shows the wiring of the null modem. The main feature indicated
here is that to make the computer to chat with the modem rather than another computer.
The guest & host computer connected through the TD, RD, and SG pins. Any data that is
transmitted through TD line from the Host to Guest is received on RD line. The Guest
computer must have the same setup as the Host. The signal ground (SG) line of the both
must be shorted so that grounds are common to each computer.
The Data Terminal Ready (DTR) is looped back to Data Set Ready and Carrier
Detect on both computers. When the Data Terminal Ready is asserted active, then the
Data Set Ready and Carrier Detect immediately become active. At this point, the
39

Hardware Lab Manual

computer thinks the Virtual Modem to which it is connected is ready and has detected the
carrier of the other modem.
All left to worry about now is the Request to Send and Clear To Send. As both
computers communicate together at the same speed, flow control is not needed thus these
two lines are also linked together on each computer. When the computer wishes to send
data, it asserts the Request to Send high and as it is hooked together with the Clear to
Send, It immediately gets a reply that it is ok to send and does so.
The Ring indicator line is only used to tell the computer that there is a ringing
signal on the phone line. As we do not have, a modem connected to the phone line this is
left disconnected.

Algorithm:

TRANSMITTER

1.

Start

2.

Initialize the port using bioscom().

3.

Get the filename from user and open file in read mode.

4.

Do the following steps until the end of the file not occurred.
a) Get a character.
b) Outputs character to port using outportb().

5.

Close the file.

6.

Output special character indicate end of transmission to port using outportb().

7.

Get the acknowledgement and print the message


Acknowledgement Received.
Transmission successful.
Transmission Complete.

8.

Stop.

40

Hardware Lab Manual

Algorithm:

RECEIVER

1.

Start

2.

Initialize the port using bioscom().

3.

Get the filename from user and open file in Write mode.

4.

Read a character from port using inportb()

5.

Do the following steps till Special character is not received..


a) Puts a character in the file.
b) Reads a character from port using inportb().

6.

Close the file.

7.

Send the acknowledgement and print the message


Transmitting Acknowledgement.
Reception Complete.

8.

Stop.

Conclusion:

41

Hardware Lab Manual

PIMPRI CHINCHWAD COLLEGE OF ENGINEERING


DEPARTMENT OF COMPUTER ENGINEERING
PRACTICAL MANUAL
CLASS

: T.E. Computer

SEMESTER- I

SUBJECT : Hardware Laboratory


Assignment No:
Aim:

Write an Assembly Language Program (ALP) for Mouse Interface.

Program Statement:
1)

Determine if mouse driver is present or not. If so, display mouse pointers


horizontal / vertical position that will be updated as per the mouse
movement.

2)

Make speaker beep whenever mouse pointer is at the center of the screen.
Display * on the screen and will terminate whenever left mouse button is
pushed while the mouse pointer is over *.

3)

The program will also terminate if user enters q. Program will hide or
show mouse pointer if user presses h or s key respectively.

1)

To study MOUSE related functions of INT 33H, like reset mouse, show
mouse pointer, hide mouse pointer, get mouse pointer and button status.

2)

To study keyboard related functions of INT 21H, like check key is


pressed, read char without echo, display char on the screen, display string
on the screen.

3)

To study functions of ROM BIOS INT 10H, like set video mode, set
cursor position.

Objective:

Theory:
DOS/ BIOS interrupt functions used:
1) Reset Mouse and get status
INT 33H

Reset Mouse and get status

Function 00H
42

Hardware Lab Manual

Initialize the mouse and returns the driver status. If the mouse pointer was previously
visible, it is removed from the screen, and any previously installed user handles for mouse
events are disabled.
Calling Parameters:
AX = 0000H
Returns:
If function successful
AX = FFFFH
BX = Number of mouse buttons
If function un successful
AX = 0000H
Note: After a call to this function, the mouse is initialized to following
state:
Mouse pointer at the center of the screen
Mouse pointer hidden (-1)
Mouse pointer set to default arrow shape.

2) Show mouse pointer


INT 33H

Show mouse pointer

Function 01H

Displays the mouse pointer, and cancels any mouse pointer exclusion are previously
defined.
Calling Parameters:
AX = 0001H
Returns:
Returns:

Nothing
Note: A counter is maintained which is incremented (if nonzero) by this
function. When the counter is zero or becomes zero, the mouse
pointer is displayed.

3) Hide mouse pointer


INT 33H

Hide mouse pointer

Function 02H

Removed the mouse pointer from the display. The driver continues to track the mouse
position.
43

Hardware Lab Manual

Calling Parameters:
AX = 0002H
Returns:

Nothing
Note: A counter is maintained which is decremented by this function.
When the counter is zero or becomes zero, then only mouse
pointer is displayed.

4) Get mouse position and button status


INT 33H

Get mouse position and button status

Function 03H

Returns the current mouse button status and pointer position.


Calling Parameters:
AX = 0003H
Returns:
BX = mouse button status
Bits Significance (if set)
0
Left button is down
1
Right button is down
2
Center button is down
3
Reserved
CX = horizontal (X) coordinate
DX = Vertical (Y) coordinate
Note: Coordinates are returned in pixels regardless of the current
display mode. Position (x, y) = (0,0) is the upper left corner of the
screen.

5) Check input status


INT 21H

Check input status

Function 0BH

Checks whether a character is available from the keyboard.


Calling Parameters:
AH = 0BH
Returns:
AL

= 00H
= FFH

if no character is available
if at least one character is available

44

Hardware Lab Manual

6) Set Video Mode


INT 10H

Set Video mode

Function 00H

Selects the current video mode. Also selects the active video controller, if more than one
video controller is present.
Calling Parameters:
AH = 00H
AL = Video mode
Returns:

Nothing
Note: Various video modes
Mode Resolution text/graphics
01H
40-by-25
text
03H
80-by-25
text

7) Set cursor position


INT 10H

Set cursor position

Function 02H

Positions the cursor on the display, using text co-ordinates.


Calling Parameters:
AH = 02H
AL = page
DH = row (y coordinates)
DL = column (x coordinates)
Returns:

Nothing

45

Hardware Lab Manual

Algorithm:
1.

Start

2.

Initialize the Mouse Driver.

3.

If Mouse Driver Successfully initialized then clear the screen (set video mode 80
cols X 25 rows) and display message Mouse Driver Initialized... Otherwise
display message Error in initialization of Mouse Driver!!!, and exit.

4.

Print * at the center of the screen.

5.

Check whether any key has been pressed or not using INT 21H/ Function 0BH.

6.

If any key has been pressed then read it using INT 21H/ Function 08H. Otherwise
goto step 10.

7.

If key h is pressed then call the procedure hide_mouse, and goto step 10.

8.

If key s is pressed then call the procedure show_mouse, and goto step 10.

9.

If key q is pressed then display message Exit from the Mouse Interface Program,
call hide_mouse procedure and exit.

10.

Call the procedure get_mouse to get the mouse pointer position and button status.

11.

Display the X and Y co-ordinates on the screen.

12.

Check the mouse pointer is at the center of the screen or not. If not then goto step 5.

13.

If mouse pointer is at the center of the screen then generate beep (07H). Also check
that if left mouse button is pressed or not. If pressed then display message Exit
from the Mouse Interface Program, call hide_mouse procedure and exit.

14.

Goto step 5.

Conclusion:
Hence we studied Mouse related functions of interrupt 33H, Keyboard related
functions of interrupt 21H, and video related functions of interrupt 10H. We have
implemented an assembly language program for mouse interface.

46

Hardware Lab Manual

PIMPRI CHINCHWAD COLLEGE OF ENGINEERING


DEPARTMENT OF COMPUTER ENGINEERING
PRACTICAL MANUAL
CLASS

: T.E. Computer

SEMESTER- I

SUBJECT : Hardware Laboratory


Assignment No:
Aim:

Write an ALP to perform


1)

Detection of DPMI

2)

Make CPU identification

3)

Capture MSW (Machine Status Word).

4)

Display contents of TR (Task Register), GDTR (Global Descriptor Table


Register), IDTR (Interrupt Descriptor Table Register), and LDTR (Local
Descriptor Table Register).

Theory:
Protected Mode Definition:
The 80286, 80386, 80486 and Pentium microprocessors are capable of operating in two
basic modes of operation:

Real mode

Protected mode.

In protected mode, the full power of the processor is available. Registers are 32 bits wide.
DOS is an example of a program that runs in real mode, because DOS was created for an
8086 based machine. An example of a program that runs in protected mode is Windows
TM

When Windows loads and executes, a DOS Protected Mode Interface [DPMI] is
established through windows code. This DPMI is accessible through the use of Multiplex
Interrupt 2FH.
47

Hardware Lab Manual

The multiplex interrupt is provided by DOS to support background programs. The


multiplex interrupt requires AX to be equal to 1687H to check DPMI status. If a DPMI
program is active we get the following:
AX
BX
CL
DI
ES

:
:
:
:
:

0
32-bit Support Flag
Processor Type
Entry Point Offset
Entry Point Segment

Protected Mode Application:


If a DPMI host is present, function 1687H returns a mode switch entry point in register
ES:DI. Performing a CALL to the entry point places the Pentium into protected mode.
The program presented here takes advantage of the capabilities provided by the DPMI
host to execute some privileged instructions such as SGDT and STR, and display the
results of the execution. A number of instructions are included in this program.
The SMSW instruction saves a copy of the lower 16 bit of CR0. These bits are known as
the Machine Status Word and can be loaded with new data using LMSW (Load
Machine Status Word) instruction.

Protected mode Registers


1. Global Descriptor Table Register (GDTR):

GDTR is a 48 bit register of the Pentium processor.

The lower 2 bytes [bit 0 to bit 15] are called as LIMIT.

The upper 4 bytes of GDTR is called as BASE. The BASE gives beginning
physical address of GDT in memory.

This 32 bit base address allows the GDT to be place anywhere in the Pentiums
address space.

Eg.

If BASE = 00 10 00 00 H
then GDT starts at 00 10 00 00 H in physical memory Space
48

Hardware Lab Manual

Figure:

GDTR and GDT

2. Interrupt Descriptor Table Register [IDTR]:

IDTR is a 48 bit register of the Pentium processor

The lower 2 bytes of the register [LIMIT] gives the size of the IDT and upper
four bytes [BASE] identifies the starting address of the IDT in physical memory.

The size of the IDT is equal to LIMIT +1 and IDT can be up to 65,536 bytes long.

Similar to GDTR, the IDTR has to be loaded before switching the Pentium from
the real mode operation to the protected mode operation.

3. Local Descriptor Table Register (LDTR):

LDTR is a 16-bit register of the Pentium processor

The LDTR does not directly select the LDT, rather it gives a selector which
points to an LDT descriptor in the GDTR.

The 32-bit base value in local descriptor table cache of Pentium gives the starting
point of the LDT table in physical memory and the value of the 16-bit limit in it
gives the size of the LDT.
49

Hardware Lab Manual

Figure:

IDTR and IDT

Figure:
Global and Local Descriptor Tables

50

Hardware Lab Manual

4. Task Register

Whenever a task Switch occurs, Pentium automatically saves the complete


context of the old task in a TSS and loads the context of a new task specified in
another TSS.

The Task register consist of two parts a visible part and an invisible part. The
visible part is accessible to the user. The invisible part is automatically loaded
with the information associated with the TSS descriptor.

It is a 16- bit selector for (TSS) Task State Segment Descriptor.

Figure : Task Register

51

Hardware Lab Manual

Algorithm:
1.

Start

2.

Get mode switch entry point of DOS Protected Mode Interface using function
1687H of INT 2FH.

3.

Check contents of AX:


If AX = 00H then print message DPMI host is present
else print message DPMI host is not present and go to step 12

4.

Check contents of BX:


If BX = 00 then print message 32 bit programs are not supported
else print 32 bit programs are supported

5.

Compare CL with 02:


If yes print message Processor is 80286 and go to step 6

Else compare CL with 03:


o If yes print message Processor is 80386 and go to step 6
o Else compare CL with 04:

If yes print message Processor is 80486 or Pentium


and go to step 6,
Else print message Processor Unidentified.

6.

Save Mode Switch Entry Address & switch to Protected Mode.


If carry is generated then print the message Cannot switch to protected mode
and go to step 12.

7.

Print the contents of TR (Task Register).

8.

Print the contents of MSW (Machine Status Word) (16 bits of CR0 [0-15]).

9.

Print the contents of IDTR (Interrupt Descriptor Table Register).

10.

Print the contents of LDTR (Local Descriptor Table Register).

11.

Print the contents of GDTR (Global Descriptor Table Register).

12.

Stop.

Conclusion:

52

Hardware Lab Manual

PIMPRI CHINCHWAD COLLEGE OF ENGINEERING


DEPARTMENT OF COMPUTER ENGINEERING
PRACTICAL MANUAL
CLASS

: T.E. Computer

SEMESTER- I

SUBJECT : Hardware Laboratory


Assignment No:
Aim:

Study of Pentium motherboard.

Objective:
1)

Theory:
DOS/ BIOS interrupt functions used:

53

Hardware Lab Manual

PIMPRI CHINCHWAD COLLEGE OF ENGINEERING


DEPARTMENT OF COMPUTER ENGINEERING
PRACTICAL MANUAL
CLASS

: T.E. Computer

SEMESTER- I

SUBJECT : Hardware Laboratory


Assignment No:
Aim:

10

Write an Assembly Language Program (ALP) to implement multitasking using


Pentium programming.

Objective:
1)

Theory:
DOS/ BIOS interrupt functions used:

54

Hardware Lab Manual

PIMPRI CHINCHWAD COLLEGE OF ENGINEERING


DEPARTMENT OF COMPUTER ENGINEERING
PRACTICAL MANUAL
CLASS

: T.E. Computer

SEMESTER- I

SUBJECT : Hardware Laboratory


Assignment No:
Aim:

11

Write an 8051 Assembly Language Program (ALP) for rate generation using
Timer0/Timer1 by using.
a)

Polling method

b)

ISP method

Objective:
1)

To Study 8051 Register Set.

2)

To study 8051 Timer / Counter Registers (TMOD), Control register


(TCON), and Interrupt register (IE).

3)

To write an Assembly Language Program (ALP) for rate generator using


Timer.

Theory:
A microcontroller is a computer with most of the necessary support chips onboard. All
computers have several things in common, namely:

A central processing unit (CPU) that executes programs.

Some random-access memory (RAM) where it can store data that is variable.

Some read only memory (ROM) where programs to be executed can be stored.

Input and output (I/O) devices that enable communication to be established with
the outside world i.e. connection to devices such as keyboard, mouse, monitors
and other peripherals.

There are a number of other common characteristics that define microcontrollers. If a


computer matches a majority of these characteristics, then it can be classified as a
microcontroller. Microcontrollers may be:

55

Hardware Lab Manual

Embedded inside some other device (often a consumer product) so that they can
control the features or actions of the product. Another name for a microcontroller
is therefore an embedded controller.

Dedicated to one task and run one specific program. The program is stored in
ROM and generally does not change.

A low power device. A battery-operated microcontroller might consume as little


as 50 mili-watts.

A microcontroller may take an input from the device it is controlling and controls the
device by sending signals to different components in the device. A microcontroller is
often small and low cost. The components may be chosen to minimise size and to be as
inexpensive as possible.
Microprocessor
CPU is stand-alone, RAM, ROM, I/O,
timer are separate
designer can decide on the amount of
ROM, RAM and I/O ports.
expansive
versatility
general-purpose

Microcontroller
CPU, RAM, ROM, I/O and timer are all on
a single chip
fix amount of on-chip ROM, RAM, I/O
ports
Highly bit addressable
for applications in which cost, power and
space are critical
single-purpose

Figure : Microcontroller vs. General- Purpose Microprocessor

56

Hardware Lab Manual

ALU: Arithmetic and logic unit of 8051 performs arithmetic and logic operation on 8-bit
operands. Apart from addition and subtraction, the 8051 hardware also performs
multiplication and division operations. Each of the logic operations involves digital gates.
AND, OR, EXOR, NOT operations are possible.
Program and Data Memories: There are two separate memories namely, program and
data memories. The program memory of 8051 is 4K ROM. Data memory is 128 bytes
RAM.
The Oscillator: 8051 operates at 12 MHz frequency. It must be noted that it is only
required to connect the quartz crystal externally and all the remaining oscillator circuitry
is on the chip.
Timing and Control: The entire operation of 8051 microcontroller is synchronous with
the clock. Everything happens in step with the clock. Apart from the internal timing and
control signals namely, ALE, PSEN (active low), RD (active low) and WR (active low),
there are others that are generated by the timing and control unit for accessing the offchip devices.

57

Hardware Lab Manual

Address and Data Buses: 8051 microcontroller has an 8-bit data bus and a 16-bit
address bus.

Accumulator: Accumulator is used by all the arithmetic and logic instructions.


Accumulator has a special importance in the sense that, one of the operands is stored in it
before the execution of an instruction and it also stores the result after the execution of an
instruction. It is also referred to as A. Accumulator has a direct path to ALU and can
immediately store the intermediate result of operation.
B-Register: B-register is an 8-bit register. B-register is available as a general purpose
register when it is not being used in multiplication or division operation.
Registers R0 through R7: These eight registers are used as scratch-pad registers. There
are four register banks each containing R0 through R7 registers. Each of these registers is
8-bit wide. At a time only one bank can be selected. These register banks are located in
the on-chip RAM starting from address 00H.
Stack Pointer (SP): Stack pointer of 8051 is 8-bit wide. It is incremented during the
PUSH or CALL operation and is decremented during POP or RETURN operation. After
the reset, the SP is initialized to 07H, causing the stack to begin at 08H.

58

Hardware Lab Manual

Program Counter (PC): Instruction opcode bytes are fetched from the program memory
location addressed by the Program Counter.
Special Function Registers (SFR): The 128 bytes of on-chip additional RAM, from
locations 80H to 0FFH, are reserved for the special functions and therefore these are
called as Special Function Registers (SFR). These SFRs are used for control or to show
the status of various functions done by 8051 c. All SFRs are directly addressable and
can be read from or written into. Note that SFR space is only reserved for the special
functions and cannot be used for any other purpose.
Program Status Word (PSW): PSW is an 8-bit register. The figure below shows the
structure of PSW register.

a) Carry flag (C) is set when there is a carry out of 7th bit of result due to certain
arithmetic and logic operations.
b) Auxiliary Carry flag (AC) is set when there is a carry out of 3rd bit, during addition
or subtraction. If there is no carry, then it is cleared. This is useful for BCD arithmetic.
c) F0 is available to users as a general purpose flag. This flag can be set or cleared by
software.
d) RS1 and RS0 bits are for selecting one of the four register banks.

Data Pointer (DPTR): DPTR is a 16-bit register. The higher order byte is referred to as
DPH, whereas the lower order byte is referred to as DPL. DPTR is used for addressing
the off-chip data and coding with MOVX and MOVC commands.
Timer registers: (TH0, TL0), (TH1, TL1), TMOD and TCON registers are associated
with Timer/Counter operations.
59

Hardware Lab Manual

P0, P1, P2 and P3 are the SFRs corresponding to the four I/O ports respectively.
SCON is an SFR used to configure the serial port for communication.

TIMER/COUNTERS
The 8051 has two 16-bit Timer/Counter registers: Timer 0 and Timer 1. Both can be
configured to operate either as timers or event counters (see Figure).

There are no restrictions on the duty cycle of the external input signal, but to ensure that a
given level is sampled at least once before it changes, it should be held for at least one
full cycle. In addition to the Timer or Counter selection, Timer 0 and Timer 1 have
four operating modes from which to select.

60

Hardware Lab Manual

In the Timer function, the register is incremented every machine cycle. Thus, one can think
of it as counting machine cycles. Since a machine cycle consists of 12 oscillator periods,
the count rate is 1/12 of the oscillator frequency.

In the Counter function, the register is incremented in response to a 1-to-0 transition at its
corresponding external input pin, T0 or T1. In this function, the external input is sampled
during S5P2 of every machine cycle.
o When the samples show a high in one cycle and a low in the next cycle, the count is
incremented. Since it takes 2 machine cycles (24 oscillator periods) to recognize a
1-to-0 transition, the maximum count rate is 1/24 of the oscillator frequency.
TIMER 0 AND TIMER 1
The Timer or Counter function is selected by control bits C/T in the Special Function
Register TMOD. These two Timer/Counters have four operating modes, which are
selected by bit-pairs (M1, M0) in TMOD. Modes 0, 1, and 2 are the same for both
Timers/Counters. Mode 3 is different. The four operating modes are described in the
following text.

MODE 0
Putting either Timer into Mode 0 makes it look like an 8048 Timer, which is an 8-bit
Counter with a divide-by-32 prescaler. Figure shows the Mode 0 operation as it applies to
Timer 1. (Same is applicable for Timer 0)
In this mode, the Timer register is configured as a 13-bit register.
As the count rolls over from all 1s to all 0s, it sets the Timer interrupt flag TF1.
The counted input is enabled to the Timer when TR1 = 1 and either GATE = 0 or INT1 =
1. (Setting GATE = 1 allows the Timer to be controlled by external input INT1, to
facilitate pulse width measurements).
TR1 is a control bit in the TCON (Figure ).
The 13-bit register consists of all 8 bits of TH1 and the lower 5 bits of TL1. The upper 3
bits of TL1 are indeterminate and should be ignored. Setting the run flag (TR1) does not
clear the registers.

61

Hardware Lab Manual

Mode 0 operation is the same for the Timer 0 as for Timer 1. Substitute TR0, TF0, and
INT0 for the corresponding Timer 1 signals in Figure . There are two different GATE
bits, one for Timer 1 (TMOD.7) and one for Timer 0 (TMOD.3).

MODE 1 :
Mode 1 is the same as Mode 0, except that the Timer register is being run with all 16 bits.
62

Hardware Lab Manual

MODE 2:
Mode 2 configures the Timer register as an 8-bit Counter (TL1) with automatic reload, as
shown in Figure.
Overflow from TL1 not only sets TF1, but also reloads TL1 with the contents of TH1,
which is preset by software. The reload leaves TH1 unchanged.
Mode 2 operation is the same for Timer/Counter 0.

MODE 3
Timer 1 in Mode 3 simply holds its count. The effect is the same as setting TR1 = 0.
Timer 0 in Mode 3 establishes TL0 and TH0 as two separate counters. The logic for
Mode 3 on Timer 0 is shown in Figure.
TL0 uses the Timer 0 control bits: C/T, GATE, TR0, INT0, and TF0. TH0 is locked into
a timer function (counting machine cycles) and takes over the use of TR1 and TF1 from
Timer 1. Thus, TH0 now controls the Timer 1 interrupt.
Mode 3 is provided for applications requiring an extra 8-bit timer on the counter. With
Timer 0 in Mode 3, an 8051 can look like it has three Timer/Counters.
When Timer 0 is in Mode 3, Timer 1 can be turned on and off by switching it out of and
into its own Mode 3, or can still be used by the serial port as a baud rate generator, or in
fact, in any application not requiring an interrupt.
63

Hardware Lab Manual

Mode 1 Programming

The following are the characteristics and operations of mode1:

1. It is a 16-bit timer; therefore, it allows value of 0000 to FFFFH to be loaded into


the timers register TL and TH
2. After TH and TL are loaded with a 16-bit initial value, the timer must be started
This is done by SETB TR0 for timer 0 and SETB TR1 for timer 1
3. After the timer is started, it starts to count up
It counts up until it reaches its limit of FFFFH
When it rolls over from FFFFH to 0000, it sets high a flag bit called TF
(timer flag)
o Each timer has its own timer flag: TF0 for timer 0, and TF1 for
timer 1
o This timer flag can be monitored
When this timer flag is raised, one option would be to stop the timer with
the instructions CLR TR0 or CLR TR1, for timer 0 and timer 1,
respectively
4. After the timer reaches its limit and rolls over, in order to repeat the process
TH and TL must be reloaded with the original value, and
64

Hardware Lab Manual

TF must be reloaded to 0

Steps to generate a time delay


1. Load the TMOD value register indicating which timer (timer 0 or timer 1) is to be
used and which timer mode (0 or 1) is selected
2. Load registers TL and TH with initial count value
3. Start the timer
4. Keep monitoring the timer flag (TF) with the JNB TFx, target instruction to see if
it is raised
Get out of the loop when TF becomes high
5. Stop the timer
6. Clear the TF flag for the next round
7. Go back to Step 2 to load TH and TL again

Finding the Loaded Timer Values


To calculate the values to be loaded into the TL and TH registers, look at the following
example

Assume XTAL = 11.0592 MHz, we can use the following steps for finding the
TH, TL registers values

1. Divide the desired time delay by 1.085 us


2. Perform 65536 n, where n is the decimal value we got in Step1
3. Convert the result of Step2 to hex, where yyxx is the initial hex value to be loaded
into the timers register
4. Set TL = xx and TH = yy

Mode 2 Programming

The following are the characteristics and operations of mode 2:

1. It is an 8-bit timer; therefore, it allows only values of 00 to FFH to be loaded into


the timers register TH
2. After TH is loaded with the 8-bit value, the 8051 gives a copy of it to TL
65

Hardware Lab Manual

Then the timer must be started


This is done by the instruction SETB TR0 for timer 0 and SETB TR1 for
timer 1
3. After the timer is started, it starts to count up by incrementing the TL register
It counts up until it reaches its limit of FFH
When it rolls over from FFH to 00, it sets high the TF (timer flag)
4. When the TL register rolls from FFH to 0 and TF is set to 1, TL is reloaded
automatically with the original value kept by the TH register
To repeat the process, we must simply clear TF and let it go without any
need by the programmer to reload the original value
This makes mode 2 an auto-reload, in contrast with mode 1 in which the
programmer has to reload TH and TL

Steps to generate a time delay


1. Load the TMOD value register indicating which timer (timer 0 or timer 1) is to be
used, and the timer mode (mode 2) is selected
2. Load the TH registers with the initial count value
3. Start timer
4. Keep monitoring the timer flag (TF) with the JNB TFx,target instruction to see
whether it is raised
Get out of the loop when TF goes high
5. Clear the TF flag
6. Go back to Step4, since mode 2 is auto-reload.

66

Hardware Lab Manual

PROGRAMMING THE FLASH


For programming, flash magic is used. Connect standard RS232 cable to SERIAL PORT and
press PROGRAM SWITCH to NORMAL and then RESET button. Double click on flash magic
icon and select the following:
1. In field1 select,
a. Com port as COM1.
b. Baud rate as 9600.
c. Device as 89V51RD2X.
d. Mode as None (ISP).s
2. In field 2 select the option erase blocks used by Hex file.
3. In field 3 select the Hex file by browsing.
4. In field 4 select Execute block only.
After selecting all the above click start in field 5 as well as RESET switch on kit and wait until
you get the status as finished on the status bar. After programming Press (reset) button to execute
the program.

67

Hardware Lab Manual

PROCEDURE for Timer Application:


1. Make the connection of cable as mentioned above and connect power supply.
2. Set the microcontroller board in normal mode.
3. Write the assembly language program in 8051 software
4. Create the HEX file for RD2
5. Program the HEX file by using FLASH MAGIC software by selecting the device.
6. Come out from programming mode and press RESET switch for execution of program.
7. Observe the LED status on LEDs.

Conclusion:

68

Hardware Lab Manual

PIMPRI CHINCHWAD COLLEGE OF ENGINEERING


DEPARTMENT OF COMPUTER ENGINEERING
PRACTICAL MANUAL
CLASS

: T.E. Computer

SEMESTER- I

SUBJECT : Hardware Laboratory


Assignment No:
Aim:

12

Write an 8051 Assembly Language Program (ALP) for Serial port programming
to transfer block of data using.
a)

Polling method

b)

ISP method

Objective:
1)

To study 8051 Serial Communication Register (SBUF), Control register


(SCON), and Interrupt register (IE).

2)

To write an Assembly Language Program (ALP) for block transfer using


serial port programming.

Theory:
Basics of Serial Communication
Computers transfer data in two ways:
o Parallel

Often 8 or more lines (wire conductors) are used to transfer data to a


device that is only a few feet away

o Serial

To transfer to a device located many meters away, the serial method is


used
The data is sent one bit at a time

69

Hardware Lab Manual

At the transmitting end, the byte of data must be converted to serial bits using
parallel-in-serial-out shift register.

At the receiving end, there is a serial-in- parallel-out shift register to receive the serial
data and pack them into byte.

When the distance is short, the digital signal can be transferred as it is on a simple
wire and requires no modulation.

If data is to be transferred on the telephone line, it must be converted from 0s and 1s


to audio tones.
o This conversion is performed by a device called a modem, Modulator /
demodulator

Serial data communication uses two methods:


o Synchronous method transfers a block of data at a time
o Asynchronous method transfers a single byte at a time

It is possible to write software to use either of these methods, but the programs can be
tedious and long

If data can be transmitted and received, it is a duplex transmission


o If data transmitted one way a time, it is referred to as half duplex
o If data can go both ways at a time, it is full duplex

This is contrast to simplex transmission

To allow data transfer between the PC and an 8051 system without any error, we
must make sure that the baud rate of 8051 system matches the baud rate of the PCs
COM port
70

Hardware Lab Manual

Hyper-Terminal function supports baud rates much higher than listed below

STANDARD SERIAL INTERFACE


The serial port is full duplex, meaning it can transmit and receive simultaneously.
It is also receive-buffered, meaning it can commence reception of a second byte before a
previously received byte has been read from the register. (However, if the first byte still
hasn't been read by the time reception of the second byte is complete, one of the bytes
will be lost.)
The serial port receive and transmit registers are both accessed at Special Function
Register SBUF. Writing to SBUF loads the transmit register, and reading SBUF accesses
a physically separate receive register.

SBUF Register
SBUF is an 8-bit register used solely for serial communication. For a byte data to be
transferred via the TxD line, it must be placed in the SBUF register. The moment a byte
is written into SBUF, it is framed with the start and stop bits and transferred serially via
the TxD line. SBUF holds the byte of data when it is received by 8051 RxD line. When
the bits are received serially via RxD, the 8051 deframes it by eliminating the stop and
start bits, making a byte out of the data received, and then placing it in SBUF.

71

Hardware Lab Manual

The serial port can operate in 4 modes:


MODE 0: Serial data enters and exits through RxD. TxD
8 bits are transmitted/received (LSB first).
The baud rate is fixed at 1/12 the oscillator frequency.
MODE 1: 10 bits are transmitted (through TxD) or received (through RxD):
A start bit (0), 8 data bits (LSB first), and a stop bit (1). On receive, the stop bit
goes into RB8 in Special Function Register SCON.
The baud rate in mode 1 is variable.
MODE 2:

11 bits are transmitted (through TxD) or received (through RxD):

start bit (0), 8 data bits (LSB first), a programmable 9th data bit, and a stop bit (1).
On Transmit, the 9th data bit (TB8 in SCON) can be assigned the value of 0 or 1.
Or, for example, the parity bit (P, in the PSW) could be moved into TB8. On
receive, the 9th data bit goes into RB8 in Special Function Register SCON, while
the stop bit is ignored.
The baud rate is programmable to either 1/32 or 1/64 the oscillator frequency.
MODE 3:

11 bits are transmitted (through TxD) or received (through RxD):

a start bit (0), 8 data bits (LSB first), a programmable 9th data bit, and a stop bit
(1). In fact, Mode 3 is the same as Mode 2 in all respects except baud rate.
The baud rate in Mode 3 is variable.

In all four modes, transmission is initiated by any instruction that uses SBUF as a
destination register. Reception is initiated in Mode 0 by the condition RI = 0 and REN =
1. Reception is initiated in the other modes by the incoming start bit if REN = 1.

72

Hardware Lab Manual

MULTIPROCESSOR COMMUNICATIONS
SM2 is used for multiprocessor communications. For our purpose it is 0.
SERIAL PORT CONTROL REGISTER (SCON)
The serial port control and status register is the Special Function Register SCON, shown
in Figure 11. This register contains not only the mode selection bits, but also the 9th data
bit for transmit and receive (TB8 and RB8), and the serial port interrupt bits (TI and RI).
SCON is an 8-bit register used to program the start bit, stop bit, and data bits of data
framing, among other things

73

Hardware Lab Manual

Importance of TI Flag

The steps that 8051 goes through in transmitting a character via TxD
1. The byte character to be transmitted is written into the SBUF register
2. The start bit is transferred
3. The 8-bit character is transferred on bit at a time
4. The stop bit is transferred

It is during the transfer of the stop bit that 8051 raises the TI flag,
indicating that the last character was transmitted

5. By monitoring the TI flag, we make sure that we are not overloading the SBUF

If we write another byte into the SBUF before TI is raised, the untransmitted portion of the previous byte will be lost

6. After SBUF is loaded with a new byte, the TI flag bit must be forced to 0 by CLR
TI in order for this new byte to be transferred

By checking the TI flag bit, we know whether or not the 8051 is ready to transfer
another byte
It must be noted that TI flag bit is raised by 8051 itself when it finishes data
transfer
It must be cleared by the programmer with instruction CLR TI
If we write a byte into SBUF before the TI flag bit is raised, we risk the loss
of a portion of the byte being transferred

The TI bit can be checked by


The instruction JNB TI,xx
Using an interrupt

74

Hardware Lab Manual

Importance RI Flag

In receiving bit via its RxD pin, 8051goes through the following steps
1.

It receives the start bit

Indicating that the next bit is the first bit of the character byte it is
about to receive

2.

The 8-bit character is received one bit at time

3.

The stop bit is received

When receiving the stop bit 8051 makes RI = 1, indicating that an


entire character byte has been received and must be picked up
before it gets overwritten by an incoming character

4.

By checking the RI flag bit when it is raised, we know that a character has
been received and is sitting in the SBUF register

We copy the SBUF contents to a safe place in some other register


or memory before it is lost

5.

After the SBUF contents are copied into a safe place, the RI flag bit must
be forced to 0 by CLR RI in order to allow the next received character
byte to be placed in SBUF

Failure to do this causes loss of the received Character

By checking the RI flag bit, we know whether or not the 8051 received a
character byte

If we failed to copy SBUF into a safe place, we risk the loss of the
received byte

It must be noted that RI flag bit is raised by 8051 when it finish receive
data

It must be cleared by the programmer with instruction CLR RI

75

Hardware Lab Manual

If we copy SBUF into a safe place before the RI flag bit is raised, we risk
copying garbage

The RI bit can be checked by

The instruction JNB RI,xx

Using an interrupt

Doubling Baud Rate

There are two ways to increase the baud rate of data transfer

To use a higher frequency crystal

To change a bit in the PCON register

PCON register is an 8-bit register

When 8051 is powered up, SMOD is zero

We can set it to high by software and thereby double the baud rate

76

Hardware Lab Manual

Interrupts
Interrupts vs. Polling
An interrupt is an external or internal event that interrupts the microcontroller to inform it
that a device needs its service. A single microcontroller can serve several devices by two
ways:
Interrupts:

Whenever any device needs its service, the device notifies the
microcontroller by sending it an interrupt signal. Upon receiving an
interrupt signal, the microcontroller interrupts whatever it is doing and
serves the device. The program which is associated with the interrupt is
called the interrupt service routine (ISR) or interrupt handler

Polling:

The microcontroller continuously monitors the status of a given device.


When the conditions met, it performs the service. After that, it moves on
to monitor the next device until everyone is serviced. Polling can monitor
the status of several devices and serve each of them as certain conditions
are met. The polling method is not efficient, since it wastes much of the
microcontrollers time by polling devices that do not need service
ex. JNB TF, target

Interrupt Service Routine


For every interrupt, there must be an interrupt service routine (ISR), or interrupt handler.
When an interrupt is invoked, the microcontroller runs the interrupt service routine. For
every interrupt, there is a fixed location in memory that holds the address of its ISR. The
group of memory locations set aside to hold the addresses of ISRs is called interrupt
vector table.
Steps in Executing an Interrupt
Upon activation of an interrupt, the microcontroller goes through the following steps
1.

It finishes the instruction it is executing and saves the address of the next
instruction (PC) on the stack
77

Hardware Lab Manual

2.

It also saves the current status of all the interrupts internally (i.e: not on the stack)

3.

It jumps to a fixed location in memory, called the interrupt vector table, that holds
the address of the ISR

4.

The microcontroller gets the address of the ISR from the interrupt vector table and
jumps to it

5.

It starts to execute the interrupt service subroutine until it reaches the last
instruction of the subroutine which is RETI (return from interrupt)

Upon executing the RETI instruction, the microcontroller returns to the place
where it was interrupted

First, it gets the program counter (PC) address from the stack by popping
the top two bytes of the stack into the PC

Then it starts to execute from that address

Six Interrupts in 8051


Six interrupts are allocated as follows

Reset power-up reset

Two interrupts are set aside for the timers: one for timer 0 and one for
timer 1

Two interrupts are set aside for hardware external interrupts

P3.2 and P3.3 are for the external hardware interrupts INT0 (or EX1), and
INT1 (or EX2)

Serial communication has a single interrupt that belongs to both receive


and transfer

78

Hardware Lab Manual

Enabling and Disabling an Interrupt


Upon reset, all interrupts are disabled (masked), meaning that none will be responded to
by the microcontroller if they are activated. The interrupts must be enabled by software in
order for the microcontroller to respond to them. There is a register called IE (interrupt
enable) that is responsible for enabling (unmasking) and disabling (masking) the
Interrupts.

Timer Interrupts

The timer flag (TF) is raised when the timer rolls over
In polling TF, we have to wait until the TF is raised
o The problem with this method is that the microcontroller is tied down
while waiting for TF to be raised, and cannot do anything else
Using interrupts solves this problem and, avoids tying down the controller
If the timer interrupt in the IE register is enabled, whenever the timer rolls over,
TF is raised, and the microcontroller is interrupted in whatever it is doing, and
jumps to the interrupt vector table to service the ISR
In this way, the microcontroller can do other until it is notified that the timer has
rolled over.

79

Hardware Lab Manual

Serial Communication Interrupt

TI (transfer interrupt) is raised when the last bit of the framed data, the stop bit, is
transferred; indicating that the SBUF register is ready to transfer the next byte.

RI (received interrupt) is raised when the entire frame of data, including the stop
bit, is received.

In other words, when the SBUF register has a byte, RI is raised to indicate
that the received byte needs to be picked up before it is lost (overrun) by
new incoming serial data.

In the 8051 there is only one interrupt set aside for serial communication

This interrupt is used to both send and receive data

If the interrupt bit in the IE register (IE.4) is enabled, when RI or TI is


raised the 8051 gets interrupted and jumps to memory location 0023H to
execute the ISR

In that ISR we must examine the TI and RI flags to see which one caused
the interrupt and respond accordingly

80

Hardware Lab Manual

Programming Serial Data: Transmitting

In programming the 8051 to transfer character bytes serially

1.

TMOD register is loaded with the value 20H, indicating the use of timer 1 in
mode 2 (8-bit auto-reload) to set baud rate

2.

The TH1 is loaded with one of the values to set baud rate for serial data transfer

3.

The SCON register is loaded with the value 50H, indicating serial mode 1, where
an 8- bit data is framed with start and stop bits

4.

TR1 is set to 1 to start timer 1

5.

TI is cleared by CLR TI instruction

6.

The character byte to be transferred serially is written into SBUF register

7.

The TI flag bit is monitored with the use of instruction JNB TI,xx to see if the
character has been transferred completely

8.

To transfer the next byte, go to step 5

Write a program for the 8051 to transfer letter A serially


at 4800 baud, continuously.
Solution:
MOV
MOV
MOV
SETB

TMOD, #20H
TH1, #-6
SCON, #50H
TR1

;
;
;
;

AGAIN:

MOV

SBUF, #A

; letter A to transfer

HERE:

JNB
CLR

TI, HERE
TI

; wait for the last bit


; clear TI for next char

SJMP AGAIN

timer 1, mode 2(auto reload)


4800 baud rate
8-bit, 1 stop, REN enabled
start timer 1

; keep sending A

81

Hardware Lab Manual

Programming Serial Data: Receiving

In programming the 8051 to receive character bytes serially


1.

TMOD register is loaded with the value 20H, indicating the use of timer 1
in mode 2 (8-bit auto-reload) to set baud rate

2.

TH1 is loaded to set baud rate

3.

The SCON register is loaded with the value 50H, indicating serial mode 1,
where an 8- bit data is framed with start and stop bits

4.

TR1 is set to 1 to start timer 1

5.

RI is cleared by CLR RI instruction

6.

The RI flag bit is monitored with the use of instruction JNB RI,xx to see if
an entire character has been received yet

7.

When RI is raised, SBUF has the byte, its contents are moved into a safe
place

8.

To receive the next character, go to step 5

Write a program for the 8051 to receive bytes of data


serially, and put them in P1, set the baud rate at 4800, 8-bit
data, and 1 stop bit
Solution:
MOV
MOV
MOV

HERE:

TMOD, #20H
TH1, #-6
SCON, #50H

; timer 1, mode 2(auto reload)


; 4800 baud rate
; 8-bit, 1 stop, REN enabled

SETB TR1

; start timer 1

JNB
MOV
MOV
CLR

;
;
;
;

RI, HERE
A, SBUF
P1, A
RI

SJMP HERE

wait for char to come in


saving incoming byte in A
send to port 1
get ready to receive next byte

; keep getting data of

82

Hardware Lab Manual

PROGRAMMING THE FLASH


For programming, flash magic is used. Connect standard RS232 cable to SERIAL PORT and
press PROGRAM SWITCH to NORMAL and then RESET button. Double click on flash magic
icon and select the following:
1. In field1 select,
a. Com port as COM1.
b. Baud rate as 9600.
c. Device as 89V51RD2X.
d. Mode as None (ISP).s
2. In field 2 select the option erase blocks used by Hex file.
3. In field 3 select the Hex file by browsing.
4. In field 4 select Execute block only.
After selecting all the above click start in field 5 as well as RESET switch on kit and wait until
you get the status as finished on the status bar. After programming Press (reset) button to execute
the program.

83

Hardware Lab Manual

PROCEDURE for Serial Communication:


1. Make the connection of cable as mentioned above and connect power supply.
2. Set the microcontroller board in normal mode.
3. Write the assembly language program in 8051 software
4. Create the HEX file for RD2
5. Program the HEX file by using FLASH MAGIC software by selecting the device.
6. Come out from programming mode and press RESET switch for execution of program.
7. Open the hyper terminal and press reset and observe the message on hyper terminal.

Conclusion:

84

Hardware Lab Manual

PIMPRI CHINCHWAD COLLEGE OF ENGINEERING


DEPARTMENT OF COMPUTER ENGINEERING
PRACTICAL MANUAL
CLASS

: T.E. Computer

SEMESTER- I

SUBJECT : Hardware Laboratory


Assignment No:
Aim:

13

Write an 8051 Assembly Language Program (ALP) ALP to interface stepper


motor for following operations.
a)

Full step

b)

Half step

c)

Clock wise

d)

Anticlockwise

Objective:
1)

Theory:
DOS/ BIOS interrupt functions used:

85