8255 Sinusoidal Wave alp

37
DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING LAB MANUAL MICROPROCESSOR & INTERFACING LAB III - B. Tech., II - Semester PRASAD V POTLURI SIDDHARTHA INSTITUTE OF TECHNOLOGY (Autonomous, Accredited by NBA & NAAC, an ISO 9001:2008 certified institution) (Sponsored by Siddhartha Academy of General & Technical Education) VIJAYAWADA 520 007, ANDHRA PRADESH

description

a

Transcript of 8255 Sinusoidal Wave alp

Page 1: 8255 Sinusoidal Wave alp

DEPARTMENT OF

ELECTRONICS & COMMUNICATION ENGINEERING

LAB MANUAL

MICROPROCESSOR & INTERFACING LAB

III - B. Tech., II - Semester

PRASAD V POTLURI

SIDDHARTHA INSTITUTE OF TECHNOLOGY

(Autonomous, Accredited by NBA & NAAC, an ISO 9001:2008 certified institution)

(Sponsored by Siddhartha Academy of General & Technical Education)

VIJAYAWADA – 520 007,

ANDHRA PRADESH

Page 2: 8255 Sinusoidal Wave alp

MICROPROCESSOR & INTERFACING LAB

1. Introduction to MASM/TASM/Debugger

2. Arithmetic operation –Multi byte Addition and Subtraction, Multiplication and Division –

Signed and unsigned Arithmetic operation, ASCII –arithmetic operation.

3. Logic operations – Shift and rotate – Converting packed BCD to unpacked BCD, BCD to

ASCII conversion.

4. String operation and Instruction prefix: Move Block, Reverse string, Inserting, Deleting,

Length of the string, String comparison, Implement various sorting algorithms.

5. DOS/BIOS programming: Reading keyboard (Buffered with and without echo) –Display

characters, Strings.

II. Interfacing:

1. 8259 interrupt controller: generate an interrupt using 8259 timer.

2. 8279 –Keyboard Display: Write a small program to display a string of characters.

3. 8255 PPI: write ALP to generate sinusoidal wave using PPI.

4. 8251 – USART: Write a program in ALP to establish Communication between two

processors.

Microcontrollers:

1. Reading and writing on a parallel port

2. Timer in different modes

3. Serial communication implementation

Page 3: 8255 Sinusoidal Wave alp

1. Introduction to MASM /TASM

MASM: (Microsoft assembler) To Create Source File: An editor is a program which allows you to create a file containing the

assembly language statements for your program. This file is called a source file.

Command to create a source file

C:\MASM\BIN> Edit filename. asm The next step is to process the source file with an assembler. When you run the assembler, it

reads the source file of your program. On the first pass through the source program, the assembler

determines the displacement of named data items, the offset labels, etc. and puts this information

in a symbol table. On the second pass through the source program the assembler produces the

binary code for each instruction and inserts the offsets, etc. that it calculated during first pass.

C:\MASM\BIN > Masm filename. asm X, Y, Z With this command assembler generates three files.

1. The first file (X) called the object file, is given the extension .OBJ

The object file contains the binary codes for the instructions and

Information about the addresses of the instructions.

2. The second file (Y) generated by the assembler is called the assembler list file and is given the

extension .LST. The list file contains your assembly language statements, the binary codes for each instruction and the offset for each instruction.

3. The third file (Z) generated by this assembler is called the cross-reference file and is given the

extension .CRF. The cross-reference file lists all labels and pertinent information required for

cross – referencing

NOTE : The Assembler only finds syntax errors : It will not tell you whether

program does what it is supposed to do. To determine whether your

program works, you have to run the program and test it.

Next step is to process the object file with linker. C:\MASM\BIN>LINK filename. obj Run File [Filename1.exe]: “filename1.exe”

Lists file [nul.map]: NUL

Libraries [.lib] : library_name

Definitions File [ nul.def] :

Creation of Library: Refer Modular Programming Section

A Linker is a program used to join several object files into one layer object file

NOTE: On IBM PC – type Computers, You must run the LINK program on your .OBJ file even

if it contains only one assembly module.

The linker produces a link file with the .EXE extension (an execution file)

Next Run C:\MASM\BIN> filename TASM: (Turbo Assembler)

To Create Source File : An editor is a program which allows you to create a file containing the

assembly language statements for your program. This file is called a source file.

Command to create a source file

C:\TASM\BIN> Edit filename. Asm The next step is to process the source file with an assembler. When you run the assembler, it

reads the source file of your program. On the first pass through the source program, the assembler

determines the displacement of named data items, the offset labels, etc. and puts this information

in a symbol table. On the second pass through the source program the assembler produces the

binary code for each instruction and inserts the offsets, etc. that it calculated during first pass.

C:\TASM\BIN > TASM filename. asm X, Y, Z With this command assembler generates three files.

Page 4: 8255 Sinusoidal Wave alp

4. The first file (X) called the object file, is given the extension .OBJ

The object file contains the binary codes for the instructions and information about the addresses of the instructions.

5. The second file (Y) generated by the assembler is called the assembler list file and is given the

extension .LST. The list file contains your assembly language

statements, the binary codes for each instruction and the offset for each instruction.

6. The third file (Z) generated by this assembler is called the cross-reference file and is given the

extension .CRF. The cross-reference file lists all labels and pertinent information required for

cross – referencing

NOTE: The Assembler only finds syntax errors : It will not tell you whether

program does what it is supposed to do. To determine whether your

program works, you have to run the program and test it.

Next step is to process the object file with linker.

C:\TASM\BIN>TLINK filename . obj A Linker is a program used to join several object files into one layer object file

NOTE: On IBM PC – type Computers, You must run the LINK program on your .OBJ file even

if it contains only one assembly module.

The linker produces a link file with the .EXE extension (an execution file)

Next Run

C:\TASM\BIN> TD filename.exe

Assembly Language Program Format: The assembler uses two basic formats for developing S/W a) One method uses MODELS and

b) Other uses Full-Segment Definitions

* The models are easier to use for simple tasks.

* The full – segment definitions offer better control over the assembly language

task and are recommended for complex programs.

a) Format using Models: ; ABSTRACT ; 8086 program

; Aim of Program

; REGISTERS ; Registers used in your program

; PORTS ; PORTS used in your program

. MODEL (type of model i.e. size of memory system)

FOR EXAMPLE . MODEL SMALL

. STACK size of stack ; define stack

. DATA ; define data segment

------

------Define variables

------

------

. CODE ; define code segment s

HERE : MOV AX, @DATA ; load ES,DS

MOV ES, AX

MOV DS, AX

---------

---------

---------

Page 5: 8255 Sinusoidal Wave alp

. EXIT 0 ; exit to DOS

END HERE

(or) We can write Code segment as follows.

. CODE ; Define Code Segment

. STARTUP

---------- EXIT 0

END

Page 6: 8255 Sinusoidal Wave alp

2. Multi Byte Operations

Aim: To perform multi byte operation addition, subtraction using debugger

Apparatus: A PC with a debugger

Adding two multi byte numbers and store the result as the third number:

DATA SEGMENT

BYTES EQU 08H

NUM1 DB 05H, 5AH, 6CH, 55H, 66H, 77H, 34H, 12H

NUM2 DB 04H, 56H, 04H, 57H, 32H, 12H, 19H, 13H

NUM3 DB 0AH DUP (00)

DATA ENDS

CODE SEGMENT

ASSUME CS: CODE, DS: DATA

START: MOV AX, DATA

MOV DS, AX

MOV CX, BYTES

LEA SI, NUM1

LEA DI, NUM2

LEA BX, NUM3

MOV AX, 00

NEXT: MOV AL, [SI]

ADC AL, [DI]

MOV [BX], AL

INC SI

INC DI

INC BX

DEC CX

JNZ NEXT

INT 3H

CODE ENDS

END START

Page 7: 8255 Sinusoidal Wave alp

Subtracting two multi byte numbers and store the result as the third number:

DATA SEGMENT

BYTES EQU 08H

NUM2 DB 05H, 5AH, 6CH, 55H, 66H, 77H, 34H, 12H

NUM1 DB 04H, 56H, 04H, 57H, 32H, 12H, 19H, 13H

NUM3 DB 0AH DUP (00)

DATA ENDS

CODE SEGMENT

ASSUME CS: CODE, DS: DATA

START: MOV AX, DATA

MOV DS, AX

MOV CX, BYTES

LEA SI, NUM1

LEA DI, NUM2

LEA BX, NUM3

MOV AX, 00

NEXT: MOV AL, [SI]

SBB AL, [DI]

MOV [BX], AL

INC SI

INC DI

INC BX

DEC CX

JNZ NEXT

INT 3H

CODE ENDS

Page 8: 8255 Sinusoidal Wave alp

Multiplying two multi byte numbers and store the result as the third number:

DATA SEGMENT

BYTES EQU 08H

NUM1 DB 05H, 5AH, 6CH, 55H, 66H, 77H, 34H, 12H

NUM2 DB 04H, 56H, 04H, 57H, 32H, 12H, 19H, 13H

NUM3 DB 0AH DUP (00)

DATA ENDS

CODE SEGMENT

ASSUME CS: CODE, DS: DATA

START: MOV AX, DATA

MOV DS, AX

MOV CX, BYTES

LEA SI, NUM1

LEA DI, NUM2

LEA BX, NUM3

MOV AX, 00

NEXT: MOV AL, [SI]

MOV DL,[DI]

MUL DL

MOV [BX], AL

MOV [BX+1], AH

INC SI

INC DI

INC BX

INC BX

DEC CX

JNZ NEXT

INT 3H

CODE ENDS

END START

Page 9: 8255 Sinusoidal Wave alp

Dividing two multi byte numbers and store the result as the third number:

DATA SEGMENT

BYTES EQU 08H

NUM2 DB 05H, 5AH, 6CH, 55H, 66H, 77H, 34H, 12H

NUM1 DB 04H, 56H, 04H, 57H, 32H, 12H, 19H, 13H

NUM3 DB 0AH DUP (00)

DATA ENDS

CODE SEGMENT

ASSUME CS: CODE, DS: DATA

START: MOV AX, DATA

MOV DS, AX

MOV CX, BYTES

LEA SI, NUM1

LEA DI, NUM2

LEA BX, NUM3

NEXT: MOV AX, 00

MOV AL, [SI]

MOV DL, [DI]

MUL DL

MOV [BX], AL

MOV [BX+1], AH

INC SI

INC DI

INC BX

INC BX

DEC CX

JNZ NEXT

INT 3H

CODE ENDS

Page 10: 8255 Sinusoidal Wave alp

Addition of two UNSIGNED Operands:

ASSUME CS: CODE, DS: DATA

DATA SEGMENT

N1 DW 4269H

N2 DW 1000H

RES DW 0H

DATA ENDS

CODE SGMENT

START

MOV AX, DATA

MOV DS, AX

MOV AX, N1

MOV AX, N2

ADD AX, N2

MOV RES, AX

INT 03H

CODE ENDS

END START

END

Addition of two SIGNED Operands:

ASSUME CS: CODE, DS: DATA

DATA SEGMENT

N1 DW 9763H

N2 DW 0A973H

RES DW 0H

DATA ENDS

CODE SGMENT

START

MOV AX, DATA

MOV DS, AX

MOV AX, N1

ADC AX, N2

MOV RES, AX

INT 03H

CODE ENDS

END START

END

Page 11: 8255 Sinusoidal Wave alp

Subtraction of two UNSIGNED Operands:

ASSUME CS: CODE, DS: DATA

DATA SEGMENT

N1 DW 4269H

N2 DW 1000H

RES DW 0H

DATA ENDS

CODE SGMENT

START:

MOV AX, DATA

MOV DS, AX

MOV AX, N1

SUB AX, N2

MOV RES, AX

INT 03H

CODE ENDS

END START

END

Subtraction of two SIGNED Operands:

ASSUME CS: CODE, DS: DATA

DATA SEGMENT

N1 DW 9763H

N2 DW 00973H

RES DW 0H

DATA ENDS

CODE SGMENT

START

MOV AX, DATA

MOV DS, AX

MOV AX, N1

SBB AX, N2

MOV RES, AX

INT 03H

CODE ENDS

END START

END

Page 12: 8255 Sinusoidal Wave alp

ASCII ARTHEMATIC OPERATIONS

AIM: To write a program to perform arithmetic operation on ASCII numbers.

SOFTWARE REQUIRED: A PC with TASM software

Procedure:

1) Open command prompt from start menu.

2) Enter drive name in which the TASM software is being saved. (Make sure of drive in

which TASM is present).

3) Now drive name will be changed to the corresponding drive entered.

4) Enter CD TASM

Ex: E:/CD TASM

5) Enter edit filename.asm

6) Opens a TASM window saved with the specified name.

7) Now enter the program, save and exit

8) In the command prompt window enter TASM filename.asm

9) The above step is to check if there are any errors in the program.

10) Next in the command prompt enter TLINK filename to check the stack address.

11) Enter TD filename to execute the program.

12) A window is opened where result can be viewed.

13) Go to run menu and select run or press F9 to run the program.

14) Display the code segment along with program and machine code.

15) Result is obtained on the right side of window.

ASCII Addition:

CODE SEGMENT

ASSUME CS: CODE

START: MOV AL,’5’

MOV BL,’9’

ADD AL, BL

AAA

OR AX, 3030H

INT 3H

CODE ENDS

END START

Page 13: 8255 Sinusoidal Wave alp

ASCII Subtraction:

CODE SEGMENT

ASSUME CS: CODE

START: MOV AL,’9’

MOV BL,’5’

SUB AL, BL

AAS

OR AX, 3030H

INT 3H

CODE ENDS

END START

ASCII Multiplication:

CODE SEGMENT

ASSUME CS: CODE

START: MOV AL, 5

MOV BL, 9

MUL BL

AAM

OR AX, 3030H

INT 3H

CODE ENDS

END START

ASCII Division:

CODE SEGMENT

ASSUME CS: CODE

START: MOV AX, 0607H

MOV CH, 09H

AAD

DIV CH

OR AX, 3030H

INT 3H

CODE ENDS

END START

Page 14: 8255 Sinusoidal Wave alp

3. LOGIC OPERATIONS - SHIFT AND ROTATE

OPERATIONS Aim: To perform the rotate and shift operations using TASM software.

Software Required: A pc with TASM software.

Apparatus: A PC with a debugger

Shift Right:

CODE SEGMENT

ASSUME CS: CODE

START: MOV AX, 1234H

MOV CL, 04H

SHR AX, CL

INT 03H

CODE ENDS

END START

END

Shift Left:

CODE SEGMENT

ASSUME CS: CODE

START: MOV AX, 1234H

MOV CL, 04H

SHL AX, CL

INT 03H

CODE ENDS

END START

END

Rotate Right Without Carry:

CODE SEGMENT

ASSUME CS: CODE

START: MOV AX, 1234H

MOV CL, 04H

ROR AX, CL

INT 03H

CODE ENDS

END START

END

Page 15: 8255 Sinusoidal Wave alp

Rotate Left Without Carry:

CODE SEGMENT

ASSUME CS: CODE

START: MOV AX, 1234H

MOV CL, 04H

ROL AX, CL

INT 03H

CODE ENDS

END START

END

Rotate Right With Carry:

CODE SEGMENT

ASSUME CS: CODE

START: MOV AX, 1234H

MOV CL, 04H

RCR AX, CL

INT 03H

CODE ENDS

END START

END

Rotate Left With Carry:

CODE SEGMENT

ASSUME CS: CODE

START: MOV AX, 1234H

MOV CL, 04H

RCL AX, CL

INT 03H

CODE ENDS

END START

END

Page 16: 8255 Sinusoidal Wave alp

LOGICAL OPERATIONS

Aim: To perform logical AND, OR, XOR, and NOT operations.

Apparatus: PC loaded with TASM software.

Procedure:

1) Open command prompt from start menu.

2) Enter drive name in which the TASM software is being saved. (Make sure of drive in

which TASM is present).

3) Now drive name will be changed to the corresponding drive entered.

4) Enter CD TASM

Ex: E:/CD TASM

5) Enter edit filename.asm

6) Opens a TASM window saved with the specified name.

7) Now enter the program, save and exit

8) In the command prompt window enter TASM filename.asm

9) The above step is to check if there are any errors in the program.

10) Next in the command prompt enter TLINK filename to check the stack address.

11) Enter TD filename to execute the program.

12) A window is opened where result can be viewed.

13) Go to run menu and select run or press F9 to run the program.

14) Display the code segment along with program and machine code.

15) Result is obtained on the right side of window.

LOGICAL AND:

CODE SEGMENT

ASSUME CS: CODE

START: MOV AL, 85H

MOV BL, 99H

AND AL, BL

INT 3H

CODE ENDS

END START

END

Page 17: 8255 Sinusoidal Wave alp

LOGICAL OR:

CODE SEGMENT

ASSUME CS: CODE

START: MOV AL, 85H

MOV BL, 99H

OR AL, BL

INT 3H

CODE ENDS

END START

END

LOGICAL NOT:

CODE SEGMENT

ASSUME CS: CODE

START: MOV AL, 85H

NOT AL

INT 3H

CODE ENDS

END START

END

LOGICAL XOR:

CODE SEGMENT

ASSUME CS: CODE

START: MOV AL, 85H

MOV BL, 99H

XOR AL, BL

INT 3H

CODE ENDS

END START END

Page 18: 8255 Sinusoidal Wave alp

PACKED BCD TO UNPACKED & BCD TO ASCII

Aim: To perform conversion operations, convert packed BCD to UNPACKED BCD

Apparatus: PC loaded with TASM software.

Converting Packed BCD to unpacked BCD:

DATA SEGMENT

NUM DB 45H

DATA ENDS

CODE SEGMENT

ASSUME CS: CODE, DS: DATA

START: MOV AX, DATA

MOV DS, AX

MOV AX, NUM

MOV AH, AL

MOV CL, 4

SHR AH, CL

AND AX, 0F0FH

INT 3H

CODE ENDS

END START

END

Converting BCD to ASCII:

DATA SEGMENT

NUM DB 45H

DATA ENDS

CODE SEGMENT

ASSUME CS: CODE, DS: DATA

START: MOV AX, DATA

MOV DS, AX

MOV AX, NUM

MOV AH, AL

MOV CL, 4

SHR AH, CL

AND AX, 0F0FH

OR AX, 3030H

INT 3H

CODE ENDS

END START

END

Page 19: 8255 Sinusoidal Wave alp

4. STRING OPERATIONS

Aim: To perform string operations such as moving, reversing, comparison, insertion and

deletion.

Apparatus: PC with TASM software.

Moving a Block using strings

DATA SEGMENT

SRC DB ‘MICROPROCESSOR’

DB 10 DUP (?)

DST DB 20 DUP (0)

DATA ENDS

CODE SEGMENT

ASSUME CS: CODE, DS: DATA, ES: DATA

START: MOV AX, DATA

MOV DS, AX

MOV ES, AX

LEA SI, SRC

LEA DI, DST

MOV CX, 20

CLD

REP MOVSB

INT 3H

CODE ENDS

END START

END

String reversal

DATA SEGMENT

ORG 2000H

SRC DB ‘MICROPROCESSOR$’

COUNT EQU ($-SRC)

DEST DB?

DATA ENDS

CODE SEGMENT

ASSUME CS: CODE, DS: DATA

START: MOV AX, DATA

MOV DS, AX

MOV CX, COUNT

LEA SI, SRC

LEA DI, DEST

ADD SI, CX

DEC CX

BACK: MOV AL, [SI]

MOV [DI], AL

DEC SI

Page 20: 8255 Sinusoidal Wave alp

INC DI

DEC CX

JNZ BACK

INT 3H

CODE ENDS

END START

Comparison of two Strings

PRINTSTRING MACRO MSG

MOV AH, 09H

LEA DX, MSG

INT 21H

ENDM

DATA SEGMENT

ORG 2000H

STR1 DB ‘MICROPROCESSORS’

LEN EQU ($-STR1)

STR2 DB ‘MICROPROCSSOR’

M1 DB “STRINGS R EQUAL$”

M2 DB “STRINGS R NOT EQUAL$”

DATA ENDS

CODE SEGMENT

ASSUME CS: CODE, DS: DATA, ES: DATA

START: MOV AX, DATA

MOV DS, AX

MOV ES, AX

LEA SI, STR1

LEA DI, STR2

MOV CX, LEN

CLD

REPE CMPSB

JNE FAIL

PRINTSTRING M1

INT 3H

FAIL: PRINTSTRING M2

INT 3H

CODE ENDS

END START

Length of the String:

DATA SEGMENT

STRA DB ‘WELCOME’, ‘$’

LENG DW 1 DUP (00H)

DATA ENDS

CODE SEGMENT

ASSUME CS: CODE, DS: DATA

START: MOV AX, DATA

MOV DS, AX

Page 21: 8255 Sinusoidal Wave alp

MOV AL, ‘$’

MOV CX, 000H

LEA SI, STRA

BACK: CMP AL, [SI]

JZ GO

INC CX

INC SI

JNZ BACK

GO: MOV LENG, CX

INT 03H

CODE ENDS

END START

END

STRING INSERTION:

DATA SEGMENT

STRA DB ‘EMPTY VESSELS MORE NOISE’, ‘$’

COUNT EQU [$-STRA]

DATA ENDS

EXTRA SEGMENT

ORG 2000H

STRB DB COUNT+5 DUP (00)

EXTRA ENDS

CODE SEGMENT

ASSUME CS: CODE, DS: DATA, ES: EXTRA

START: MOV AX, DATA

MOV DS, AX

MOV AX, EXTRA

MOV ES, AX

LEA SI, STRA

LEA DI, STRB

MOV CX, OEH

CLP

REP MOV SB

MOV DL, 05H

BACK: MOV AH, O1H

INT 21H

STOS STRB

DEC DL

JNZ BACK

MOV CX, OAH

REP MOV SB

INT 03H

CODE ENDS END START

END

Page 22: 8255 Sinusoidal Wave alp

STRING DELETION:

DATA SEGMENT

STRA DB ‘EMPTY VESSELS MORE NOISE’, ‘$’

COUNT EQU [$-STRA]

DATA ENDS

EXTRA SEGMENT

ORG 2000H

STRB DB COUNT-5 DUP (00)

EXTRA ENDS

CODE SEGMENT

ASSUME CS: CODE, DS: DATA, ES: EXTRA

START: MOV AX, DATA

MOV DS, AX

MOV AX, EXTRA

MOV ES, AX

LEA SI, STRA

LEA DI, STRB

MOV CX, OEH

CLP

REP MOV SB

MOV SI, 0012H

MOV CX, 0012H

REP MOV SB

INT 03H

CODE ENDS

END START

END

Page 23: 8255 Sinusoidal Wave alp

SORTING Aim: To write a program for sorting the numbers in

a) Ascending Order

b) Descending Order

Software Required: A PC with TASM software.

Program for Sorting in Ascending Order:

DATA SEGMENT

STRA DB 54H, 99H, 23H, 90H, 11H

COUNT EQU 0004H

DATA ENDS

CODE SEGMENT

ASSUME: CS: CODE, DS: DATA

START: MOV AX, DATA

MOV DS, AX

L3: MOV BX, CX

LEA SI, STRA

MOV DI, SI

ADD DI, 0001H

L2: MOV AL, [SI]

CMP AL, [01]

JC L1

XCHG AL, [DI]

MOV [SI], AL

L1: INC SI

INC DI

DEC BX

JNZ L2

LOOP L3

INT 03H

CODE ENDS

END START

END

Page 24: 8255 Sinusoidal Wave alp

Program for Sorting in Descending Order:

DATA SEGMENT

STRA DB 54H, 99H, 23H, 90H, 11H

COUNT EQU 0004H

DATA ENDS

CODE SEGMENT

ASSUME: CS: CODE, DS: DATA

START: MOV AX, DATA

MOV DS, AX

MOV CX, COUNT

L3: MOV BX, CX

LEA SI, STRA

MOV DI, SI

ADD DI, 0001H

L2: MOV AL, [SI]

CMP AL, [01]

JNC L1

XCHG AL, [DI]

MOV [SI], AL

L1: INC SI

INC DI

DEC BX

JNZ L2

LOOP L3

INT 03H

CODE ENDS

END START

END

Page 25: 8255 Sinusoidal Wave alp

5. DOS AND BIOS Programming

DOS (Disk operating System), BIOS (Basic I/O System) are used by assembly language to

control the personal computer. The function calls control the personal computer .The function

calls control everything from reading and writing disk data to managing the keyboard and

displays.

DOS Function Calls: - In order to use DOS function calls, always place function number into

register AH, and load other information into registers. Following is INT 21H, which is software

interrupt to execute a DOS function.

All function calls use INT 21H, and AH contains function call number.

User can access the hardware of PC using DOS subroutine .DOS subroutines are invoked or

called via software interrupt INT 21H.

BIOS Function Calls: - In addition to DOS Function call INT 21H, some other BIOS function

calls are useful in controlling the I/O environment of a computer. BIOS function calls are found

stored in the system and video BIOS ROMs. These BIOS ROM functions directly control the I/O

devices with or without DOS loaded into a system.

INT 10H: - The INT 10H BIOS interrupt is often called the video services interrupt because it

directly controls the video display in a system .The INT 10H instruction uses AH to select the

video service provided by this interrupt.

INT 11H: - This function is used to determine the type of equipment installed in the system.

INT 12H: - The memory size is returned by the INT 12 H instruction.

INT 13H: - This call controls the diskettes, and also fixed or hard disk drives attached to the

system.

DOS FUNCTIONS:

Reading a key with an echo: To read and echo a character, the AH is loaded with DOS function

number 01H. This is followed by the INT 21H instruction. Upon return from the INT 21H, the

AL register contains the ASCII character typed; the video display also shows the typed character.

Reading a key without an echo: To read a key without an Echo the AH register is loaded with

DOS function number 06H and DL=0FFH to indicate that the function call will read the key

board an echo.

Read an entire line with an echo: Sometimes it is advantageous to read an entire line of data

with one function call. Function call number 0AH reads entire line of information up to 255

characters from the keyboard. It continues to acquire keyboard data until it either enter key (0DH)

is typed or the character count expires.

Writing to video display: With almost any program, data must be displayed on the video

display. We use functions 02H or 06H for displaying one character at a time or function 09H for

displaying an entire string of characters. Because function 02H and 06H are identical, we intend

to use function 06H because it is also used to read a key. The character string can be of any length

and may contain control characters such as carriage return (0DH) and line feed (0AH).

Terminate a process: To terminate a process the AH register is loaded with function value 4CH.

This function returns control to DOS with the error code saved.

Page 26: 8255 Sinusoidal Wave alp

DOS / BIOS Programming FUNCTION CALLS SHOULD BE AVAILABLE IN AH REGISTER

PROGRAM WITH ECHO DOS FUNCTION:

DATA SEGMENT

MSG DB ‘ENTER CHARACTERS FROM KEYBOARD<#TO END>’, ‘$’

DATA ENDS

CODE SEGMENT

ASSUME CS: CODE, DS: DATA

START: MOV AX, DATA

MOV DS, AX

MOV AH, 09H

MOV DX, OFFSET MSG

INT 21H

NEXT: MOV AH, 08H

INT 21H

; MOV AH, 02H

; MOV DL, AL

; INT 21H

CMP AL, ‘#’

JNE NEXT

MOV, 4CH

MOV AL, 00H

INT 21H

CODE ENDS

END START

END

PROGRAM with Echo

DATA SEGMENT

MSG DB ‘ENTER CHARACTERS FROM KEYBOARD<#TO END>’, ‘$’

DATA ENDS

CODE SEGMENT

ASSUME CS: CODE, DS: DATA

START: MOV AX, DATA

MOV DS, AX

MOV AH, 09H

MOV DX, OFFSET MSG

INT 21H

NEXT: MOV AH, 01H

INT 21H

CMP AL, ‘#’

JNE NEXT

MOV, 4CH

MOV AL, 00H

INT 21H

CODE ENDS

END START

END

Page 27: 8255 Sinusoidal Wave alp

PART –B

INTERFACING

8259 INTERRUPT CONTROLLER

AIM: - To perform the interrupt for 8086 microprocessor using study card 8259

(Programmable Interrupt Controller)

APPARATUS: - ESA 8086 Microprocessor System

8259 Study Card

Power Supply

PROGRAM: -

ADDRESS OPCODE LABEL MNEMONIC OPERAND

2000 MOV AX,0000H

MOV CS,AX

MOV ES,AX

MOV SS,AX

MOV SP,3000

MOV SI,0120

MOV AX,2200

MOV [SI],AX

ADD SI,02

MOV AX,0000

MOV [SI],AX

ADD SI,02

MOV AX,2210

MOV [SI],AX

ADD SI,02

MOV AX,0000

MOV [SI],AX

ADD SI,02

MOV AX,2220

MOV [SI],AX

ADD SI,02

MOV AX,0000

MOV [SI],AX

ADD SI,02

MOV AX,2230

MOV [SI],AX

ADD SI,02

MOV AX,0000

MOV [SI],AX

ADD SI,02

MOV AX,2240

MOV [SI],AX

ADD SI,02

MOV AX,0000

MOV [SI],AX

ADD SI,02

Page 28: 8255 Sinusoidal Wave alp

MOV AX,2250

MOV [SI],AX

ADD SI,02

MOV AX,0000

MOV [SI],AX

ADD SI,02

MOV AX,2260

MOV [SI],AX

ADD SI,02

MOV AX,0000

MOV [SI],AX

ADD SI,02

MOV AX,2270

MOV [SI],AX

ADD SI,02

MOV AX,0000

MOV [SI],AX

MOV DX,0FFC8

MOV AL,17

OUT DX,AL

MOV DX,0FFCA

MOV AL,48

OUT DX,AL

MOV AL,03

OUT DX,AL

MOV AL,00

OUT DX,AL

STI

HERE: JMP HERE

2200 CLI

LEA DX,@MSG0

JMP DISP

INT 03

2210 CLI

LEA DX,@MSG1

JMP DISP

INT 03

2220 CLI

LEA DX,@MSG2

JMP DISP

INT 03

2230 CLI

LEA DX,@MSG3

JMP DISP

INT 03

2240 CLI

Page 29: 8255 Sinusoidal Wave alp

LEA DX,@MSG4

JMP DISP

INT 03

2250 CLI

LEA DX,@MSG5

JMP DISP

INT 03

2260 CLI

LEA DX,@MSG6

JMP DISP

INT 03

2270 CLI

LEA DX,@MSG7

JMP DISP

INT 03

2300 DISP: MOV SI,DX

MOV CX,011

L1: MOV AL,[SI]

CALLS 0FE00:0000

INC SI

LOOP L1

ST1

IRET

RESULT: -

Input: -

; MESSAGES FOR ISRs

2100 20 20 0A 49 4E 54 MSG0: DB 20H 20H 0AH ‘INT0

OCCURRED’, 0AH, DH

2106 30 20 4F 43 43 55

210C 52 45 44 0A 0D

2111 20 20 0A 49 4E 54 MSG1: DB 20H 20H 0AH ‘INT1

OCCURRED’, 0AH, DH

2117 31 20 4F 43 43 55

211D 52 45 44 0A 0D

2122 20 20 0A 49 4E 54 MSG2: DB 20H 20H 0AH ‘INT2

OCCURRED’, 0AH, DH

2128 32 20 4F 43 43 55

212E 52 45 44 0A 0D

2133 20 20 0A 49 4E 54 MSG3: DB 20H 20H 0AH ‘INT3

OCCURRED’, 0AH, DH

2139 33 20 4F 43 43 55

Page 30: 8255 Sinusoidal Wave alp

213F 52 45 44 0A 0D

2144 20 20 0A 49 4E 54 MSG4: DB 20H 20H 0AH ‘INT4

OCCURRED’, 0AH, DH

214A 34 20 4F 43 43 55

2150 52 45 44 0A 0D

2155 20 20 0A 49 4E 54 MSG5: DB 20H 20H 0AH ‘INT5

OCCURRED’, 0AH, DH

215B 35 20 4F 43 43 55

2161 52 45 44 0A 0D

2166 20 20 0A 49 4E 54 MSG6: DB 20H 20H 0AH ‘INT6

OCCURRED’, 0AH, DH

216C 36 20 4F 43 43 55

2172 52 45 44 0A 0D

2177 20 20 0A 49 4E 54 MSG7: DB 20H 200H 0AH ‘INT7

OCCURRED’, 0AH, DH

217D 37 20 4F 43 43 55

2183 52 45 44 0A 0D

Output: -

Page 31: 8255 Sinusoidal Wave alp

8255 - PPI AIM: - To generate sinusoidal wave using 8255 PPI

APPARATUS: - ESA 8086 Microprocessor kit

Keyboard

Power Supply

PROGRAM: -

ADDRESS OPCODE LABEL MNEMONIC OPERAND

MOV DX, FFE6H

MOV AL,80

OUT DX , AL

L7 MOV AL ,00

L1 : MOV DX , FFE0

OUT DX , AL

INC AL

CMP AL , 0F

JB L1

L2 MOV DX , FFE0

OUT DX , AL

INC AL

INC AL

INC AL

CMP AL , EF

JB L2

L3 : MOV FFE0

OUT DX , AL

INC AL

CMP AL , FF

JB L3

L4 : MOV DX , FFE0

OUT DX , AL

DEC AL

CMP AL , EF

JNBE L4

L5 MOV DX , FFE0

OUT DX , AL

DEC AL

DEC AL

DEC AL

CMP AL , 0F

JNBE L5

L6 : MOV DX , FFE0

OUT DX, AL

Page 32: 8255 Sinusoidal Wave alp

DEC AL

CMP AL , 00

JNBE L6

JMP L7

OUTPUT:

Page 33: 8255 Sinusoidal Wave alp

8251- USART

AIM: - To generate sinusoidal wave using 8255 PPI

APPARATUS: - ESA 8086 Microprocessor kit

Keyboard

Power Supply

PROGRAM FOR TRANSMITTER:

ADDRESS OPCODE LABEL MNEMONIC OPERAND

MOV BX , 2000

MOV DX , FFF2

L1 : IN AL , DX

AND AL , 81

CMP AL , 81

JNE L1

MOV DX , FFF0

MOV AL , [BX ]

OUT DX , AL

INT 03

PROGRAM FOR RECEIVER:

MOV DX , 0FFF2

L1 : IN AL , DX

AND AL , 02

JE L1

MOV DX , FFF0

IN AL , DX

INT 03

Input:

Output:

Page 34: 8255 Sinusoidal Wave alp

READING & WRITING ON A PARALLEL PORT

AIM: - To perform Reading and Writing on a parallel port using 8051.

APPARATUS: - Micro controller kit

Key Board

Power Supply

ALGORITHM: -

1. Move data from #8050 to DPTR

2. Routine to

3. Else go to K.B. prompt

4. END.

PROGRAM: -

ADDRESS OPCODE LABEL MNEMONIC OPERAND

MOV A , 0FF

MOV 90 , A

TOP : MOV A , 90

MOV 80 ,A

SJMP TOP

RESULT: -

Input:

Output:

Page 35: 8255 Sinusoidal Wave alp

TIMER IN DIFFERENT MODES

AIM: - To perform the operation of timer in different modes using 8051.

APPARATUS: - Micro controller kit

Key Board

Power Supply

PROGRAM: -

ADDRESS OPCODE LABEL MNEMONIC OPERAND

MOV 89, #01

WAIT : MOV 8A,#0F2

MOV 8C,#0FF

CPL 95

ACALL DELAY

SJMP WAIT

DELAY : SETB 8C

HERE : JNB 8D, HERE

CLR 8C

CLR 8D

RET

RESULT: -

Input:

Output:

Page 36: 8255 Sinusoidal Wave alp

SERIAL COMMUNICATION IMPEMENTATION

AIM: - To perform serial communication between the Master and Slave microprocessor

using 8051 micro controller.

APPARATUS: 8051 Micro controller

Key board

Power supply

THEORY: -

The serial port is full duplex, meaning it can transmit and receive simultaneously. It is

also receive buffered, meaning it can commence reception of second byte before a previously

received byte has been read from the receive register. The serial port receive and transmit

registers are both accessed at special function register SBUF to SBUF accesses a physically

separate receive register. However, if the first byte still has not been by the time reception of

the second byte is complete, one of the bytes will be last.

OPERATING MODES FOR SERIAL PORT: -

MODE 0: Serial data enters and exists through RXD, TXD outputs the shift clock. 8 bits are

received/transmitted. 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

(LSB first) bits and a stop bit (1). The baud rate is variable.

MODE2: 11 bits are transmitted (through TXD) or received (through RXD): a start bit (0), 8

bits (LSB first), a 9th

data bit and a stop bit (1).

PROGRAMMING 8051 FOR SERIAL DATA TRANSFER: -

1. Clear T1 with CLR T1 instruction.

2. Write a character to be sent into SBUF register

3. Check the T1 flag (register) bit with instruction JNB T1, XXXX to see if the character

has been transferred.

4. Go to step 1 to transfer the next character. The baud rate is 1/32 (or) 1/64 the

oscillator frequency.

PROGRAMMING 8051 FOR RECEIVING SERIAL DATA: -

1. Clear RI to CLR RI instruction.

2. Check the RI flag bit with instruction JNB, RI, XXXX to see if an entire character has

been transferred.

3. If R1 to see, SBUF has the byte save this byte.

4. Go to step 1 to receive the next character.

PROCEDURE: -

Connect the master and slave in series and connect them to system. Press EXE MEM,

PROG MEM and then type the starting address of program (i. E. 8000) in master. Press EXE

MEM, PROG MEM and then 8100 in slave. Press EXE MEM, external data and then enter

the data at 9200 in master. Execute the slave first and then master { Press GO 8100 execute in

slave and GO 8000 execute in master}. Then check contents of O/P register for received data

in slave.

PROGRAM FOR MASTER OPERATION: -

Page 37: 8255 Sinusoidal Wave alp

ADDRESS OPCODE LABEL MNEMONIC OPERAND

8000 LCALL 160E

MOV DPTR, #9200

MOVX A, @DPTR

LCALL 160E

NOP

NOP

NOP

NOP

INC DPTR

MOVX A, @DPTR

LCALL 160E

HERE: SJMP HERE

PROGRAM FOR SLAVE OPERATION: -

ADDRESS OPCODE LABEL MNEMONIC OPERAND

8100 LCALL 16E2

MOV DPTR, #9200

LCALL 16E2

MOVX @DPTR, A

INC DPTR

LCALL 16E2

MOVX @DPTR, A

HERE: SJMP HERE

Result: -

Input: - MD 9200

Output: -

9200 16

9201 14