microprocessor lab manual

105
MICROPROCESSORS LAB CODE NO: 05401 I. Microprocessor 8086 1. Introduction to MASM/TASM 2. Arithmetic operations – 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. By using string operation and instruction prefix: Move block, Reverse string, Sorting, Inserting, Deleting, and Length of the string, String comparison 5. DOS/BIOS Programming: Reading keyboard (Buffered with and with out echo) - Display characters, Strings. II.INTERFACING 1. 8259-Interuupt 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 establish communication between to processors. III.MICROCONTROLLER 8051 1

Upload: dhiraj-ippili

Post on 02-Nov-2014

109 views

Category:

Documents


0 download

DESCRIPTION

gud for reference

TRANSCRIPT

Page 1: Microprocessor Lab Manual

MICROPROCESSORS LAB CODE NO: 05401

I. Microprocessor 8086 1. Introduction to MASM/TASM

2. Arithmetic operations – 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. By using string operation and instruction prefix: Move block, Reverse string,

Sorting, Inserting, Deleting, and Length of the string, String comparison

5. DOS/BIOS Programming: Reading keyboard (Buffered with and with out

echo) - Display characters, Strings.

II.INTERFACING

1. 8259-Interuupt 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 establish communication between       

to processors.

III.MICROCONTROLLER 8051

1. Reading and writing on a parallel port.

2. Timer in different modes.

3. Serial communication implementation.

1

Page 2: Microprocessor Lab Manual

MICROPROCESSORS LAB

I. Microprocessor 8086

1. Introduction to MASM/TASM2. Arithmetic operations – 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. By using string operation and instruction prefix: Move block, Reverse string, Sorting, Inserting, Deleting, and Length of the string, String comparison

5. DOS/BIOS Programming: Reading keyboard (Buffered with and with out echo) - Display characters, Strings.

II. INTERFACING

1. 8259-Interuupt controller: 1. Pulse Counter 2. Frequency Counter

2. 8279-Keyboard display: Display String of Characters

3. 8255-PPI: Sine wave generation

4. 8251-USART: Write a program in ALP establish communication between        to processors.

III. MICROCONTROLLER 8051

1. Arithmatic operations.

2. Timer in different modes.a. Generate delay using timer 0 in mode 1 for square waveb. Generate delay using timer 0 in mode 2 for square wave

EXPERIMENTS OTHER THAN JNTU SYLLABUS

1. 8279-Keyboard display: Write a small program to display a string of Characters.

a. Display of Single Character b. Reading character from keyboard and displaying it

2. 8255-PPI: a. Square wave generation b. Stepper motor speed and direction control

3. Decimal counter display.

2

Page 3: Microprocessor Lab Manual

MICRO PROCESSOR 8086

1. INTRODUCTION TO MASM/TASM

3

Page 4: Microprocessor Lab Manual

INTRODUCTION TO MASM/TASM

The assembler is a program that converts an assembly input file also called source file to an object file that can further be converted in to machine codes or an executable file using a linker. There are a number of assemblers available like MASM, TASM and DOS assembler.TASM is one of the popular assemblers used along with a link program to structure the codes generated By TASM in the form of executable files.TASM reads the source program as its input and provides an object file. The link accepts the object file produced by TASM as input and produces an EXE file.

Before staring the process ensure that all the files namely, TASM, .EXE, LINK .EXE, DEBUG. EXEAre available in the same directory which is working .Start the procedure with the following command after boot the terminal and enter the directory containing all the files mentioned. D: Valid directory Cod: Change the directory with all files Edit: Edit the assembler to enter the program Save the files with. .ASM. ASSUME CS:CODE,DS:DATA

DATA SEGMENT OPR1 DW 1234H OPR DW 0002H RESULT DW 01H DUP ? DATA ENDS CODE SEGMENT START: MOV AX, DATA MOV DS, AX MOV AX, OPR1 MOV BX, OPR2 CLC ADD AX, BX MOV DI, OFFSET RESULT MOV DI, AX MOV AH, 4CH INT 03H CODE ENDS. END START.

The main task of any assembler program is to accept the text _assembly language program file as input and prepare an object file .the TASM accepts the file names only with the extension .ASM.The TASM linking program LINK.EXE .links the different object modules of a source program and function library routines to generate an integrated executable code of the source program. The main input to the linker is the .OBJ file that contains the object modules of the source program.Debug .Exe facilitates the debugging and trouble shooting of assembly language program. The debug utility enables to have the control these resources unto some extent.

4

Page 5: Microprocessor Lab Manual

TASM file name. ASM TLINK file name Debug file name.exe G- Execute current CS: IP. - Execute from offset in the current series U- Un assemble from the current CS: IP - Un assemble from the address SEG: OFFSET D- Display 128 memory locations of RAM starting from the current display

pointer -Display memory contents SEG from offset1 to offset2

ASSEMBLER DIRECTIVES:

An Assembler is a program used to convert an assembly language program in to equivalent machine code modules which may further be converted in to executable codes. The assembler decides the address of each label and substitutes the values for each of the constants and variables. It then forms the machine code for the mnemonics and data in assembly language program. While doing all these all these things, the assembler may find out Syntax errors. The logical errors or other programming errors are not find out by the assembler. For completing all these tasks, an assembler needs some hints from the programmer, i.e. the required storage for a particular constant or variable, logical names of the segments, types of the different routines and modules, end of file etc. These types of hints are given to assembler using some predefined alphabetical strings called “ASSEMBLER DIRECTIVES”.

DB:This is used to reserve byte or bytes of memory locations in the available

memory. While preparing the EXE file, this directive directs the assembler to allocate the specified number of memory bytes to the said data type that may be constant, variable or stringent.

DW:This directive serves the same purposes as the DB directive, but it now

makes the assembler Reserve the number of memory words instead of bytes.

DQ:This directive is used to direct the assembler to reserve words of memory for

the specified variable and may initialize it with the specified values.ASSUME:

The ASSUME directive is used to inform the assemble, the names of the logical segments to be assumed for different segments used in the program.

5

Page 6: Microprocessor Lab Manual

END:The END directive marks the end of an assembly language program. When the assembler comes across this directive, it ignores the source lines available later on.

ENDP:In assembly language programming, the subroutines are called procedures. Thus, procedures may be

Independent program modules which return particular results or values to the calling programs. The ENDP

Directive is used to indicate an end of procedures. A procedure is usually assigned a name, i.e. label. To mark

The end of a particular procedure, the name of the procedure, i.e label appear as a prefix with the directive

ENDP.

ENDS: This directive marks the end of a logical segment. The logical segments are assigned with names

Using the ASSUME directive. The names appear with the ENDS directive as prefixes to mark the end of

Those particular segments.

LABEL: This is used to assign a name to the current content of the location counter.

At the start of the assembly process, the assembler initializes a location counter to keep track of

memory Locations assigned to the program. As the program assembly proceeds, the

contents of the Location counter are updated.

LENGTH: This is used to refer the length of a data array or string.

OFFSET: When the assembler comes across the offset operator along with a label, it first

computes the 6-bit Displacement of the particular label, and replaces the string ‘offset label’ by the

computed displacement.

SEGMENT: This marks the staring of a logical segment .The started segment is also

assigned a namei.e., label by this statement. The SEGMENT and ENDS directive must bracket each

logical Segment of a program.

6

Page 7: Microprocessor Lab Manual

2. ARITHMETIC OPERATIONS Multi byte addition

Multi byte Subtraction

Multi byte multiplication

Multi byte division

+Ve & -ve No.s of array

GCD of two numbers

0s &1s in 16-bit number

Prime number checking

Solving the equation

7

Page 8: Microprocessor Lab Manual

THIS PROGRAM PERFORMS MULTIBYTE ADDITION

Turbo Assembler Version 2.51 add.asm/* the data segment in array1 and the data segment in array2 is added and the resultWill be stored and displayed in data segment array3*/

1 assume cs: code,ds: data 2 3 0000 code segment 4 5 0000 B8 0000s start: move ax, data 6 0003 8E D8 mov ds,ax 7 0005 8B 0E 0000r mov cx,n1 ;initialise counter 8 0009 BE 0002r lea si,array1 ;initialise pointer 9 000C BB 0006r lea bx,array2 10 000F BF 000Ar lea di,array3 11 0012 8A 04 l1:mov al,[si] ;perform addition Of 1st byte 12 0014 12 07 ad al,[bx] 13 0016 88 05 mov [di], al ; store the result 14 0018 46 inc si ;update data pointers 15 0019 43 inc bx 16 001A 47 inc di 17 001B 49 dec cx ; repeat addition till

The final byte 18 001C 75 F4 jnz l1 19 001E CC int 03 20 001F code ends 21 22 0000 data segment 23 0000 0004 n1 dw 0004h 24 0002 01020304 array1 dd 01020304h ;specify inputs 25 0006 01020304 array2 dd 01020304h 26 000A ???????? array3 dd? ; store the result 27 000E data ends 28 end start

Input : 1st array: 01020304h 2nd array: 01020304h

Output: 02040608h

8

Page 9: Microprocessor Lab Manual

THIS PROGRAM PERFORMS MULTIBYTE SUBTRACTIONTurbo Assembler Version 2.51 sub.asm

/* The data segment in array1 and the data segment in array2 is subtracted and the resultWill be stored and displayed in data segment array3*/

1 assume cs: code,ds: data 2 3 0000 code segment 4 5 0000 B8 0000s start : mov ax,data 6 0003 8E D8 mov ds,ax 7 0005 8B 0E 0000r mov cx,n1 ;initialise counter 8 0009 BE 0002r lea si,array1 ;initialise array

pointers 9 000C BB 000Ar lea bx,array2 10 000F BF 0012r lea di,array3 11 0012 8A 04 l1:mov al,[si] ;perform subtraction of

ls byte 12 0014 1A 07 sbb al,[bx] 13 0016 89 05 mov [di],ax ;store result 14 0018 46 inc si ;update data pointers 15 0019 43 inc bx 16 001A 47 inc di ;repeat subtraction till

last byte 17 001B 49 dec cx 18 001C 75 F4 jnz l1 19 001E CC int 03 20 001F code ends 21 22 0000 data segment 23 24 0000 0004 n1 dw 0004h 25 0002 0000000005060809 array1 dq 05060809h;specify input 26 000A 0000000001020304 array2 dq 01020304h 27 0012 ???????????????? array3 dq ? ;store output 28 001A data ends 29 end start ;stop

Input: array1 :05060809h array2 :01020304h

Output: 04040505h

9

Page 10: Microprocessor Lab Manual

THIS PROGRAM PERFORMS MULTIBYTE MULTIPLICATIONTurbo Assembler Version 2.51 mul.asm

/* The data segment in data1 and the data segment in n2 is multiplied and the resultWill be stored and displayed in data segment data2*/

1 assume cs: code,ds: data 2 3 0000 code segment 4 5 0000 B8 0000s start:mov ax,data 6 0003 8E D8 mov ds,ax 7 0005 8B 0E 0000r mov cx,n1 ;length of array 8 0009 8A 1E 0002r mov bl,n2 ;multiplier 9 000D BA 0000 mov dx,00h 10 0010 BE 0003r lea si,data1 ;array pointer 11 0013 BF 0007r lea di,data2 ;result pointer 12 0016 8A 04 l1: mov al,[si] ;get 1st byte of

multiplicand 13 0018 F6 E3 mul bl ;multiply 14 001A 03 C2 add ax,dx 15 001C 8A D4 mov dl,ah 16 001E 88 05 mov [di],al ;store result in result

pointer 17 0020 46 inc si ;update data pointer 18 0021 47 inc di ;perform multiplication till

the last multiplicand 19 0022 49 dec cx 20 0023 75 F1 jnz l1 21 0025 CC int 03 22 0026 code ends 23 24 0000 data segment 25 0000 0004 n1 dw 0004h 26 0002 05 n2 db 05h 27 0003 01020304 data1 dd 01020304h 28 0007 ???????? data2 dd ? 29 000B data ends 30 end start ;stop

Input: Multiplier: 05h Multiplicand: 01020304h

Output: 050A0F14h

10

Page 11: Microprocessor Lab Manual

THIS PROGRAM PERFORMS MULTIBYTE DIVISIONTurbo Assembler Version 2.51div.asm

/* The data segment in data1 and the data segment in n2 is divided and the resultWill be stored and displayed in data segment data2*/

1 assume cs: code,ds: data 2 3 0000 code segment 4 5 0000 B8 0000s start: mov ax, data 6 0003 8E D8 mov ds,ax 7 0005 8B 0E 0000r mov cx,n1 ;dividend length 8 0009 8A 1E 0002r mov bl,n2 ;divisor 9 000D BE 0003r lea si,data1 ;initialize data pointer 10 0010 BF 0007r lea di,data2 11 0013 B4 00 mov ah,00h 12 0015 8A 04 l1:mov al,[si] ;get 1st byte of dividend 13 0017 98 cbw 14 0018 F6 F3 div bl ;perform division 15 001A 1B C2 sbb ax,dx 16 001C 8A D4 mov dl,ah 17 001E 88 05 mov [di],al ;store quotient 18 0020 46 inc si ;update dividend and

result pointers 19 0021 47 inc di 20 0022 49 dec cx ;perform this till MSB 21 0023 75 F0 jnz l1 22 0025 CC int 03 ;stop 23 0026 code ends 24 25 0000 data segment 26 27 0000 0004 n1 dw 0004h 28 0002 05 n2 db 05h 29 0003 140F0A19 data1 dd 140f0a19h 30 0007 ???????? data2 dd ? 31 32 000B data ends 33 end start

Input: Divisor: 05h Dividend; 140F0A19h

Output: 04030205h

11

Page 12: Microprocessor Lab Manual

THIS PROGRAM FINDS NO.OF +VE & -VE NO.S IN ARRAYTurbo Assembler Version 2.51pos_neg.asm

/*The data segment in the list finds whether it is a positive number or negative number if msb is 1 it is negative otherwise considered as positive*/

1 assume cs: code,ds: data 2 3 0000 code segment 4 5 0000 33 DB start: xor bx,bx ;initialise result

pointer 6 0002 33 D2 xor dx,dx 7 0004 B8 0000s mov ax,data 8 0007 8E D8 mov ds,ax 9 0009 B1 05 90 90 mov cl,count ;declare length of array 10 000D BE 0000r mov si,offset list 11 0010 8B 04 again:mov ax,[si] ;get 1st no. 12 0012 D1 E0 shl ax,01h ;check whether msb is 1 13 0014 72 04 jc nega ;if 1 the no.is -ve 14 0016 43 inc bx ;if 0 the no.is +ve 15 0017 EB 02 90 jmp next 16 001A 42 nega:inc dx 17 001B 83 C6 02 next:add si,02h ;updte data pointer 18 001E FE C9 dec cl ;decrement length counter 19 0020 75 EE jnz again ;repeat untill final no. 20 0022 CC int 03 21 0023 code ends ;store result 22 23 0000 data segment 24 0000 A500 C009 0159 B900 list dw 0a500h,0c009h,0159h,0b900h 25 = 0005 count equ 05h 26 0008 data ends 27 end start

Input: 0a500h,0c009h,0b900h,0159h

Output: no of positive nos :0159h no of negative nos:0a500h,0c009h,0b900h

12

Page 13: Microprocessor Lab Manual

THIS PROGRAM FINDS THE GCD OF TWO NUMBERSTurbo Assembler Version 2.51gcd.asm

/*This program calculates the GCD of two numbers stored at data segment num1 and num2 locations and gives the result at the data segment gcd offset address*/

1 assume cs: code,ds: data 2 3 0000 code segment 4 5 0000 B8 0000s start: mov ax,data 6 0003 8E D8 mov ds,ax 7 0005 BE 0000r mov si,offset num1 ;get 1st no. 8 0008 8B 04 mov ax,[si] 9 000A BE 0002r mov si,offset num2 ;get 2nd no. 10 000D 8B 1C mov bx,[si] 11 000F 3B C3 cmp ax,bx ;get big no,asdividend 12 0011 7F 01 jg go 13 0013 93 back : xchg ax,bx 14 0014 2B C3 go : sub ax,bx ;get gcd using

repeated 15 0016 3B C3 cmp ax,bx 16 0018 7F FA jg go ;division 17 001A 7C F7 jl back 18 001C BE 0004r mov si,offset gcd ;store result 19 001F 89 04 mov [si],ax 20 21 0021 CC int 03 ;stop 22 23 0022 code ends 24 25 0000 data segment 26 0000 0018 num1 dw 0018h ;the no.s in data

segment 27 0002 0006 num2 dw 0006h 28 0004 ???? gcd dw ? 29 0006 data ends 30 31 end start

Input : num1 is 0018h num2 is 0006h

Output: 0006h

13

Page 14: Microprocessor Lab Manual

THIS PROGRAM FINDS NO.OF 0's AND 1's IN A 16-BIT NUMBERTurbo Assembler Version 2.51zer_one.asm

/*The data segment in the num finds no. of 1’s and no. of 0’s by converting the given number into binary */

1 assume cs: code,ds: data 2 3 0000 code segment 4 5 0000 33 DB start: xor bx,bx ;clear result counters 6 0002 33 D2 xor dx,dx 7 0004 B8 0000s mov ax,data 8 0007 8E D8 mov ds,ax 9 0009 B1 10 90 90 mov cl,count ;declare no. bit count 10 000D A1 0000r mov ax,num ;get the no. 11 0010 D1 C0 again:rol ax,01h ;finds msb is 0 or 1 12 0012 72 04 jc ones ;if 0 increment 0s count 13 0014 43 inc bx ;otherwise 1s count 14 0015 EB 02 90 jmp next ;perform this until the

1st bit 15 0018 42 ones:inc dx 16 0019 FE C9 next:dec cl 17 001B 75 F3 jnz again 18 001D CC int 03 ;stop 19 001E code ends 20 21 0000 data segment 22 0000 D759 num dw 0d759h ;no. in data segment 23 = 0010 count equ 10h 24 0002 data ends 25 end start

Input : num is 0d759h

Output: number of 0’s :06 Number of 1’s:0A

14

Page 15: Microprocessor Lab Manual

THIS PROGRAM FINDS WHETHER GIVEN NUMBER IS PRIME OR NOTTurbo Assembler Version 2.51prime.asm

/*The data segment in num is prime the same data will be displayed at res otherwise zero will be displayed*/

1 assume cs: code,ds: data 2 3 0000 code segment 4 5 0000 B8 0000s start: mov ax,data 6 0003 8E D8 mov ds,ax 7 0005 BE 0000r mov si,offset num 8 0008 8B 1C mov bx,[si] ;get the number 9 000A 8B 04 loop1 :mov ax,[si] ;if no.is 1 10 000C B9 0001 mov cx,0001h 11 12 000F BA 0000 mov dx,0000h ;no.is prime 13 0012 4B dec bx 14 0013 3B D9 cmp bx,cx 15 0015 74 0B jz ahead2 ;otherwise perform div 16 0017 F7 F3 div bx ;if remainder 0 then

no.is not prime 17 0019 83 FA 00 cmp dx,0000h 18 001C 74 02 jz ahead1 19 001E EB EA jmp loop1 ;no remainder no. is

prime 20 0020 8B C2 ahead1: mov ax,dx ;perform div from -1to1 21 22 0022 BE 0002r ahead2: mov si,offset res 23 0025 89 04 mov [si],ax 24 25 0027 CC int 03 ;stop 26 27 0028 code ends 28 29 0000 data segment 30 0000 0012 num dw 0012h ;give the input no. 31 0002 ???? res dw ? ;store result here 32 0004 data ends 33 34 end start

Input : num=0012h

Output: result is 0000hi.e,num is not prime.

15

Page 16: Microprocessor Lab Manual

THIS PROGRAM SOLVES THE EQUATION (P+(Q*R)/S)Turbo Assembler Version 2.51equ.asm

/*The data segment in the P,Q,R and S substituted in the equation (P+(Q*R)/S) and the calculated result will be stored in res*/

1 assume cs: code,ds: data 2 3 0000 code segment 4 5 0000 B8 0000s start: mov ax,data 6 0003 8E D8 mov ds,ax 7 0005 B8 0012 mov ax,q ;get no.q 8 0008 BB 0005 90 mov bx,r 9 000C F7 E3 mul bx ;multiply with r 10 000E B9 0009 90 mov cx,s 11 0012 F7 F1 div cx ;div the res by s 12 0014 BA 0023 90 mov dx,p ;add it to p 13 0018 03 C2 add ax,dx 14 001A BF 0000r mov di,offset res ;store the result 15 001D 89 05 mov [di],ax 16 001F CC int 03 17 0020 code ends 18 19 0000 data segment ;no.s in datasegment 20 21 = 0023 p equ 0023h 22 = 0012 q equ 0012h 23 = 0005 r equ 0005h 24 = 0009 s equ 0009h 25 0000 ???? res dw ? ;result in data segment 26 27 0002 data ends 28 end start ;stop

Input : p=0023h , q=0012h , r= 0005h , s=0009h

Output: ax=002Dh

16

Page 17: Microprocessor Lab Manual

3.LOGICAL OPERATIONS

Conversion of ASCII no. to packed BCD

Conversion of packed BCD no. to ASCII

Conversion of BCD no. into binary

17

Page 18: Microprocessor Lab Manual

THIS PROGRAM CONVERTS ASCII NOS INTO PACKED BCD

Turbo Assembler Version 2.51 10/11/07 14:11:42 Page 1equa.asm

/*The ASCII no’s directly store in the registers bl and al is converted into packed BCD and the result will be stored in the accumulator */

1 assume cs:code 2 0000 code segment 3 0000 B3 32 start: mov bl,'2' ;GET 1ST ASCII no. 4 0002 B0 34 mov al,'4' ;get 2nd ASCII no. 5 0004 80 E3 0F and bl,0fh ;mask the upper nibble 6 0007 24 0F and al,0fh ;of 2 ASCII nos 7 0009 B1 04 mov cl,04h ;pack the 2 nos. 8 000B D2 C3 rol bl,cl 9 000D 0A C3 or al,bl ;BCD result in reg.AL. 10 000F CC int 03h 11 0010 code ends 12 end start

Input: bl=02h al=04h

Output: BCD value is 24h in al register.

18

Page 19: Microprocessor Lab Manual

THIS PROGRAM CONVERTS PACKED BCD TO ITS EQUIVALENT ASCII NO.Turbo Assembler Version 2.51bcd_asc.asm

/*The packed BCD number 0095h is converted into its equivalent ASCII number and result will stored in res1 and res2*/

1 assume cs: code,ds: data 2 3 0000 code segment 4 5 0000 B8 0000s start: mov ax,data 6 0003 8E D8 mov ds,ax 7 0005 32 E4 xor ah,ah 8 0007 B0 95 90 mov al,bcd ;get the no. 9 000A 8A E0 mov ah,al ;convert into unpacked bcd 10 000C 24 0F and al,0fh 11 000E 0C 30 or al,30h ;find res1 ascii 12 0010 80 E4 F0 and ah,0f0h 13 0013 B1 04 mov cl,04h 14 0015 D2 C4 rol ah,cl 15 0017 80 CC 30 and ah,30h ;find res2 ascii 16 001A A2 0000r mov res1,al ;store result 17 001D 88 26 0001r mov res2,ah 18 0021 CC int 03 19 0022 code ends 20 21 0000 data segment 22 = 0095 bcd equ 0095h ;BCD INPUT 23 0000 ?? res1 db ? ;result display 24 0001 ?? res2 db ? 25 0002 data ends 26 end start

Input : 0095h

Output: ASCII value of 9 is 39h ASCII value of 5 is 35h

19

Page 20: Microprocessor Lab Manual

THIS PROGRAM IS FOR THE CONVERSION OF BCD TO BINARYTurbo Assembler Version 2.51bcd2bin.asm/*The data segment in the bcd_input is converted into binary value and result will be displayed in bin_value*/ 1 assume cs: code,ds: data,ss:stack_seg 2 3 0000 code segment 4 5 0000 B8 0000s start:mov ax,data 6 0003 8E D8 mov ds,ax 7 0005 B8 0000s mov ax,stack_seg 8 0008 8E D0 mov ss,ax 9 000A B8 0000 mov ax,0000h 10 000D BC 00C8r lea sp,top_stack 11 0010 A0 0000r mov al,bcd_input ;get bcd input 12 0013 E8 0004 call bcd_bin ;call bin procedure 13 0016 A2 0001r mov bin_value,a ;store resultl 14 0019 CC int 03 ;stop 15 001A bcd_bin proc near ;save main program status 16 001A 9C pushf 17 001B 53 push bx 18 001C 51 push cx ;convert packed bcd

input 19 001D 8A D8 mov bl,al 20 001F 80 E3 0F and bl,0fh ;unpacked bcd 21 0022 24 F0 and al,0f0h 22 0024 B1 04 mov cl,04h 23 0026 D2 C8 ror al,cl ;multiply each digit by

its pos. 24 0028 B7 0A mov bh,0ah 25 002A F6 E7 mul bh 26 002C 02 C3 add al,bl ;add the resultants 27 002E 59 pop cx 28 002F 5B pop bx ;back to main program 29 0030 9D popf 30 0031 C3 ret 31 0032 bcd_bin endp 33 0032 code ends 35 0000 data segment 36 0000 11 bcd_input db 17 ;bcd input data segment 37 0001 ?? bin_value db ? ;result area 38 0002 data ends 39 40 0000 stack_seg segment ;reserve stack area 41 0000 64*(0000) dw 100 dup(0) 42 00C8 top_stack label word 43 00C8 stack_seg ends 44 end start Input: 17h Output: 11h

20

Page 21: Microprocessor Lab Manual

4.STRING OPERATIONS AND INSTRUCTION PREFIX

String transfer

Ascending order

Inserting character and spell checking

Deleting character

String comparision

21

Page 22: Microprocessor Lab Manual

THIS PROGRAM TRANSFERS A STRING OF CHARACTERS FROMONE LOCATION TO ANOTHER

Turbo Assembler Version 2.51trfr_str.asm

/*The data segment in the first_string is transferred to new location a and in between it leaves 100 locations*/

1 assume cs: code,ds: data,es:data 2 3 0000 code segment 4 5 0000 B8 0000s start:mov ax,data 6 0003 8E D8 mov ds,ax 7 0005 8E C0 mov es,ax 8 0007 BE 0000r lea si,first_string ;declare source &

destination 9 000A BF 0068r lea di,new_loc ;pointers 10 000D B9 001E mov cx,30 ;specify string length 11 0010 FC cld ;move the string from

source to destination 12 0011 F3> A4 rep movsb 13 0013 CC int 03 14 0014 code ends ;stop 15 16 0000 data segment 17 0000 72 61 76 69 first_string db 'ravi' 18 0004 64*(??) db 100 dup(?) ; leave 100

locations 19 0068 1E*(00) new_loc db 30 dup(0) ;locations for

destination 20 0086 data ends 21 end start

Input : String is ‘ravi’ at 0B7F:0000

Output: String is ‘ravi’ at 0B7F:0071

22

Page 23: Microprocessor Lab Manual

THIS PROGRAM IS TO ARRANGE NUMBERS IN ASCENDING ORDER USING BUBBLE SORT

Turbo Assembler Version 2.51bubsrt.asm

/*The data segment in the list are arranged in ascending order */

1 assume cs: code,ds: data,es:data 2 3 0000 code segment 4 5 0000 B8 0000s start: mov ax,data 6 0003 8E D8 mov ds,ax 7 0005 B2 04 90 90 mov dl,count-1 ;initialise counter 8 0009 8A CA again1: mov cl,dl 9 000B BE 0000r mov si,offset list ;get offset address 10 000E 8A 04 again2: mov al,[si] ;getsmallno.in1stlocation 11 0010 3A 44 01 cmp al,[si+1] 12 0013 77 05 jb ahead ;compares till the end of

array 13 0015 86 44 01 xchg [si+1],al 14 0018 86 04 xchg [si],al 15 001A 83 C6 01 ahead: add si,01 ;bring small no.s into 1st

location 16 17 001D E2 EF loop again2 ;in each location 18 001F FE CA dec dl 19 0021 75 E6 jnz again1 ;perform untill no.s are

arrange in order 20 21 0023 CC int 03h ; stop 22 23 0024 code ends 24 25 0000 data segment 26 0000 34 50 78 81 12 list db 34h,50h,78h,81h,12h 27 = 0005 count equ 05h 28 0005 data ends 29 30 end start

Input : 34h,50h,78h,81h,12h

Output: 12h,34h,50h,78h,81h

23

Page 24: Microprocessor Lab Manual

THIS PROGRAM INSERTS A MISSED CHARACTER IN A WORD / CORRECTS AMISSPELT WORD

Turbo Assembler Version 2.51miscr.asm/*The data segment in the array1 is compared with data segment array and correct the      misspelt word*/

1 assume cs: code,ds: data 2 3 0000 code segment 4 5 0000 B8 0000s start:mov ax,data 6 0003 8E D8 mov ds,ax 7 0005 8E C0 mov es,ax 8 0007 BE 0000r lea si,array ;get the right word 9 000A B9 0005 90 mov cx,num 10 000E BF 0005r lea di,array1 ;compare the right word 11 0011 FC l2: cld ;the word to be corrected 12 0012 F3> A6 repe cmpsb 13 0014 E3 05 jcxz l1 14 0016 E8 0003 call procedure ;call procedure 15 0019 EB F6 jmp l2 ;if mismatch found 16 001B CC l1: int 03h 17 001C 57 procedure: push di 18 001D 51 push cx ;insert the character 19 001E 56 push si 20 001F 4E dec si 21 0020 4F dec di 22 0021 8A 04 mov al,[si] 23 0023 86 05 l3: xchg al,[di] 24 0025 47 inc di 25 0026 49 dec cx 26 0027 75 FA jnz l3 27 0029 88 05 mov byte ptr[di],al ;make final byte 0 28 002B 5E pop si 29 002C 59 pop cx 30 002D 5F pop di 31 002E C3 ret 32 33 002F code ends 34 35 0000 data segment 36 0000 6B 69 72 61 6E array db 'kiran' 37 = 0005 num equ ($-array) 38 0005 6E 6B 72 69 array1 db 'nkri' 39 0009 data ends 40 41 end start ; stopInput: mispelt word is ‘nkri’ Output: Correct word is ‘kiran’

24

Page 25: Microprocessor Lab Manual

THIS PROGRAM DELETES SPECIFIED CHARACTER FROM STRINGTurbo Assembler Version 2.51del_char.asm/*The data segment in the array1 and the specified character in accumulator al will be deleted*/ 1 assume cs: code,ds: data,es:data 2 3 0000 code segment 4 5 0000 B8 0000s start: mov ax,data 6 0003 8E D8 mov ds,ax 7 0005 8E C0 mov es,ax 8 0007 BE 0000r lea si,array1 ;get the string address 9 000A B9 0007 90 mov cx,num 10 000E B0 65 mov al,'e' ;get the character to be

deleted 11 0010 3A 04 l2:cmp al,[si] ;find the character to be

deleted 12 0012 75 06 jne l1 13 0014 E8 0008 call procedure ;call the delete

procedure 14 0017 49 dec cx 15 0018 75 F6 jnz l2 16 001A 46 l1:inc si 17 001B 49 dec cx 18 001C 75 F2 jnz l2 ;stop 19 001E CC int 03 20 001F 51 procedure:push cx 21 0020 56 push si 22 0021 8B FE mov di,si ;initialise pointers 23 0023 49 dec cx 24 0024 46 inc si ;move the string 1 byte

forth 25 0025 FC cld 26 0026 F3> rep 27 0027 A4 movsb 28 0028 C6 05 00 mov byte ptr[di],00h ;make final byte 0 29 002B 5E pop si 30 002C 59 pop cx 31 002D C3 ret 32 002E code ends ;back to main program 33 34 0000 data segment 35 0000 65 6C 65 6D 65 6E 74 array1 db 'element' ;string 36 = 0007 num equ ($-array1) 37 0007 data ends 38 end start

Input : element Output: lmnt

25

Page 26: Microprocessor Lab Manual

THIS PROGRAM COMPARES 2 STRINGS & DISPLAY 0 IF NOT EQUALAND DISPLAY 00 FF EQUAL

Turbo Assembler Version 2.51cmpr2str.asm/* The string stored in the second_string is if equal to the string in first_string then display 00 FF other wise 00*/ 1 assume cs: code,ds: data,es:data 2 3 0000 code segment 4 5 0000 B8 0000s start: mov ax,data ;initialise the segments

needed 6 0003 8E D8 mov ds,ax 7 0005 8E C0 mov es,ax ;compare 2 strings 8 0007 BE 0000r lea si,first_string 9 000A BF 000Er lea di,second_string 10 000D B9 000E 90 mov cx,str_length 11 0011 FC cld 12 0012 F3> A6 repe cmpsb 13 0014 75 03 jne sound_alarm 14 0016 EB 05 90 jmp ok ;display 0 if not equal 15 0019 sound_alarm: 16 0019 B8 0000 mov ax,0000h 17 001C CC int 03 18 19 001D ok: 20 001D B8 00FF mov ax,00ffh ;display 00 if equal 21 0020 CC int 03h 22 0021 code ends 23 24 0000 data segment 25 0000 6D 69 63 72 6F 70 72+ first_string db'microprocessor';declare2

strings 26 6F 63 65 73 73 6F 72 27 = 000E str_length equ($first_string);specify

length of string 28 000E 6D 69 63 72 6F 70 72+ second_string db 'microprocessor' 29 6F 63 65 73 73 6F 72 30 001C data ends 31 end start

Input: first string’ MICROPROCESSOR' second string 'MICROPROCESSOR'

Output: 00FF i.e, string is equal.

26

Page 27: Microprocessor Lab Manual

6.DOS/BIOS PROGRAMMING

Reading keyboard (Buffered with and with out echo) - Display characters

27

Page 28: Microprocessor Lab Manual

THIS PROGRAM READS CHARACTER FROM KEY BOARD AND DISPLAYS THE PRESSED KEY Turbo Assembler Version 2.51 10/11/07 14:09:15 Page 1cons.asm

/*The data segment in the mesg1rreads the character from the keyboard and the same character displayed on the mesg2*/

1 assume cs:code,ds:data 2 0000 code segment 3 0000 B8 0000s start:mov ax,data ;initialize data segment 4 0003 8E D8 mov ds,ax 5 0005 B4 09 mov ah,09h ;prompt for key press 6 0007 BA 0000r mov dx,offset mesg1 7 000A CD 21 int 21h 8 000C B4 01 mov ah,01h ;read character 9 000E CD 21 int 21h 10 0010 A2 001Cr mov char,al 11 0013 BA 2000 mov dx,2000h ;wait for some time 12 0016 B9 FFFF again1:mov cx,0ffffh 13 0019 90 again2:nop 14 001A 90 nop 15 001B 49 dec cx 16 001C 75 FB jnz again2 17 001E 4A dec dx 18 001F 75 F5 jnz again1 19 0021 B4 09 mov ah,09h display msg2 &character 20 0023 BA 000Er mov dx,offset mesg2 21 0026 CD 21 int 21h 22 0028 B4 02 mov ah,02h 23 002A 8A 16 001Cr mov dl,char 24 002E CD 21 int 21h 25 0030 B4 4C mov ah,4ch 26 0032 CD 21 int 21h 27 0034 code ends 28 0000 data segment 29 0000 74 79 70 65 20 61 6E+ mesg1 db 'type any key:$';msgs in data seg. 30 79 20 6B 65 79 3A 24 31 000E 74 79 70 65 64 20 6B+ mesg2 db 'typed key is:$' 32 65 79 20 69 73 3A 24 33 001C 00 char db 0 34 001D data ends 35 end start

Input: ‘Type any key’: u

Output: ‘Type any key’: u

28

Page 29: Microprocessor Lab Manual

II.INTERFACING

29

Page 30: Microprocessor Lab Manual

1.8259-INTERRUPT CONTROLLER : GENERATE AN INTERRUPT USING 8259 INTERRUPT CONTROLLER

AIM: a) To display the pulse counter.

b) To derive the frequency counter.

APPARATUS:

1. ESA 86/88-2 Microprocessor kit.

2. Function generator.

3. Connecting wires.

THEORY:

The Processor 8085 had five hardware interrupt pins. Out of these five

interrupt pins, four pins were allotted fixed vector addresses but the pin INTR was

not allotted any vector address, rather an external

Device was supposed to hand over the type of the interrupt to the microprocessor.

The microprocessor then gets this type and derives the interrupt vector address from

that. Consider an application where a number of

I/O devices connected with CPU desire to transfer data using interrupt driven data

transfer mode. In this type of applications more number of interrupts are required

than available in typical microprocessor. Moreover ,in this multiple interrupts systems

the processor will have to take the care of priorities for the interrupts, simultaneously

occurring at the interrupt request pins to overcome all this difficults ,we require a

Programmable interrupt controller which is able to handle a number of interrupts at a

time.8259A was operated with 8-bit as well as 16-bit processors.

PORT ADDRESSES OF 8279

Control word register = FFF4Data Port Address = FFF6

30

Page 31: Microprocessor Lab Manual

8259INTERFACING

31

Page 32: Microprocessor Lab Manual

PROGRAM:

PULSE COUNTER

Main program:

Memory address

Op codes labels Mnemonics Operands Comments

20002006200C2012201520172018201B201D201E20202021202320242025

C7,06,00,30,00,00C7,06,20,01,50,20C7,06,22,01,00,00BA,F4,FFB0,13EEBA,F6,FFB0,48EEB0,03EEB0,FEEEFBEB,FE

L1:

MOVMOVMOVMOVMOVOUTMOV MOVOUTMOV OUTMOVOUTSTIJMP

[3000],0000H[0120],2050H[0122],0000HDX,FFF4HAL,13HDX,ALDX,FFF6HAL,48HDX,ALAL,03HDX,ALAL,FEHDX,AL

L1

;Initial cnt.0; ISR addr .in INT vector location.

;Initialize 8259 in edge triggered interrupt ,8086 processor, automatic end of interrupt , interrupt no. 0

; Keep monitoring the interrupt.

Delay subroutine:

Memory address

Op codes labels Mnemonics Operands Comments

20502053205520562059205E

A1,00,3004,0127A3,00,309A,0A,0B,00,FFCF

MOVADDDAAMOVCALLIRET

AX,[3000]AL,01H

[3000],AXFF00:0B0A

; Increment the counter by 1.

;Display count; Back to main.

32

Page 33: Microprocessor Lab Manual

FREQUENCY COUNTER

Main program:

Memory address

Op codes labels Mnemonics Operands Comments

20002006200C2012201520172018201B201D201E202020212023202420252028202B202C202D202F203020322037

C7,06,00,30,00,00C7,06,20,01,50,20C7,06,22,01,00,00BA,F4,FFB0,13EEBA,F6,FFB0,48EEB0,03EEB0,FEEEFBBB,0C,00B9,02,63904975,FC4B75,F69A,0A,0B,00,FFEB,FE

L2: L1:

L3:

MOVMOVMOVMOVMOVOUTMOV MOVOUTMOV OUTMOVOUTSTIMOVMOVNOPDECJNZDECJNZCALLJMP

[3000],0000H[0120],2050H[0122],0000HDX,FFF4HAL,13HDX,ALDX,FFF6HAL,48HDX,ALAL,03HDX,ALAL,FEHDX,AL

BX,000CHCX,6302H

CXL1BXL2FF00:0B0AL3

;Initial cnt.0; ISR adder .in INT vector location.;Initialize 8259 in edge triggered interrupt ,8086 processor, automatic end of interrupt , interrupt no. 0

;Activate interrupt; Initialize counters for 1 sec delay.

; Wait for 1sec.

; Display the frequency value.

Interrupt service subroutine:

Memory address

Op codes labels Mnemonics Operands Comments

20502053205520562059

A1,00,3004,0127A3,00,30CF

MOVADDDAAMOVIRET

AX,[3000]AL,01H

[3000],AX

;Count the pulses

; Back to main.

33

Page 34: Microprocessor Lab Manual

RESULT:The count of the pulses is displayed on the microprocessor data field.The frequency is measured and displayed.

VIVA QUESTIONS:

1. Which initialisation command word indicates whether PIC is being used in

single or cascaded mode?

2. What is meant by handshaking?

3. Explain IRET instruction?

4. In the PIC which registers is used to mask the interrupts?

5. What are the total numbers of interrupts available if all the 8-inputs of PIC are

having slave?

6. What is MACRO?

7. What are the flags of 8086?

8. Which pin is used to distinguish the minimum mode and maximum mode?

34

Page 35: Microprocessor Lab Manual

35

Page 36: Microprocessor Lab Manual

2.8279-KEYBOARD DISPLAY : WRITE A SMALL PROGRAM TO DISPLAY A STRING OF CHARACETRS.

AIM: To display string of characters.

APPARATUS: ESA 86/88-2 Microprocessor kit.

THEORY: Intel’s 8279 is a general purpose keyboard display controller that simultaneously drives the display of a system and interfaces a key board with the CPU, leaving it free for its routine task .The keyboard display interface scans the keyboard to identify if any key has been pressed and sense the code of the pressed key to Performed by the controller in repetitive fashion with out involving the Cup-Tie keyboard is interfaced either in interrupt mode or polled mode. In the interrupt mode the processor is requested service only if any key is pressed otherwise the CPU can proceed with its main task. In the polled mode the CPU periodically reads an internal flag of 8279 to check for a key pressure. The keyboard section can interface an array of a maximum of64 keys with the CPU.The keyboard entries are debounced and stored in 8-byte FIFO RAM that is further accessed by the CPU to read the key codes. If more than 8-characters are entered in the FIFO. Before anyFIFO read operation the overrun status is set. The 8279 is normally provides maximum of sixteen 7 segmentDisplay interface with CPU.

PORT ADDRESSES OF 8279

Control word register = FFEBData Port Address = FFE9

8279A Interfacing:

8086 8279 7-seg display

36

Page 37: Microprocessor Lab Manual

8279 INTERNAL ARCHITECTURE

PROGRAM: To display string of characters

Memory address

Op codes labels Mnemonics Operands Comments

200020032005200620082009200B200C200F20122015201720182019201A201C

BA,EB,FFB0,00EEB0,38EEB0,90EEBE,00,30B9,LENGTHBA,E9,FF8A,04EE464975,F9EB,FE

L1:

L2:

MOVMOVOUTMOV OUTMOV OUTMOVMOVMOVMOVOUTINCDECJNZJMP

DX,FFEBHAL,00HDX,ALAL,38HDX,ALAL,90HDX,ALSI,3000HCX,LENGTHDX,FFE9HAL,[SI]DX,ALSICXL1L2

; Initialize 8279 in encoded scan keypad 2key lock out,8char display left entry.;Select display position 0

;Display the string of characters

37

Page 38: Microprocessor Lab Manual

RESULT:A character is displayed at 0 position of the display.A string characters is displayed on left entry basis.A character is read from the keyboard and displayed the key no on the display using look-up table method.

VIVA QUESTIONS:

1. What is the value in AH perform input from keyboard?2. A keyboard is made using 12 keys connected not as a matrix. How many pins

of the I/O port are used?3. Write a 7–segment code for ‘B’?4. In the single character display using interrupt 21H, DL is the register contains

character to display.If DL contains 41H, which character is displayed?

5. What is the difference between CALL and JMP?6. What is the purpose of ALE?7. What are the difference between microprocessor and micro controller?

38

Page 39: Microprocessor Lab Manual

39

Page 40: Microprocessor Lab Manual

3.8255- PROGRAMMABLE PERIPHERAL INTERFACE (PPI)

AIM: To generate sine wave.

APPARATUS: 1. ESA 86/88-2 Microprocessor kit.2. C.R.O.3. Stepper motor interface module with stepper motor.4. F R C Cable.5. Power supply- +15v.

THEORY: The parallel input-output port chip 8255 is also called as Programmable peripheral input-outputPort. The Intel’s 8255 are designed for use with Intel’s 8-bit, 16-bit and higher capability microprocessors. It has 24 input/output lines which may be individually programmed in 2-groups of 12 lines each, or 3 groups of 8 lines .The two groups of I/O pins are named as GROUP A and GROUP B. Each of these two groups contain a sub group of 8 I/O lines called as 8-bit Port and other sub group of 4 I/O lines are a 4-bit port. Thus GROUP AContains an 8-bit port A along with a 4-bit port, C upper. Port lines are identified by symbols PAO-PA7,While the port C lines are identified as PC4-PC7 .Similarly group B contains an 8-bit port B, containing linesPB0-PB7 and a 4-bit port C with lower bits PC0-PC3 .The port C upper and port C lower can be used in recombination as an 8-bit port-C .Both the port Cs are assigned the same address. Thus one may have eitherThree 8-bit I/O ports are two 8-bit and two 4-bit I/O ports from 8255.All of these ports can function independently either as input or as output ports. This can be achieved by programming the bits of an internal register of 8255 called as Control word register. (CWR).

PORT ADDRESSES OF 8255

Control word register = FFE7Port A = FFE1Port B = FFE3

Port AC = FFE5

Block diagram of 8255 Interfacing

Stepper motor inter face

8255PPI

Micro processor8086

40

Page 41: Microprocessor Lab Manual

Block diagram of 8255 programmable peripheral interface:

Generation of a Sine Waveform:

GroupA

control

GroupB

control

GroupA

PortA(8)

GroupA

PortC upper

(4)

GroupB

PortC lower

(4)

GroupB

PortB(8)

DATABUS

BUFFER

Read/write

Control logic

8 bit internal bus

I/OPA7-PA0

I/OPC7-PC4

I/OPC3-PC0

I/OPB7-PB0

BIDIRECTIOAL DATA BUS BUFFER

D7--D0

POWER SUPPLIES

+5V

GND

__ RD __ WR

A1

A0

RESET

__ CS

8086MICRO

PROCESSOR

8255PPI

8-BITDAC CRO

41

Page 42: Microprocessor Lab Manual

Program:

Memory address

Op codes labels Mnemonics Operands Comments

20002002200520062009200C201020122013201420152017

B0,80BA,E7,FFEEBA,E1,FFB9, 22,008B,36,00,308A,04EE464975,F9EB,F0

BACK:

L1:

MOVMOV OUT MOVMOVMOVMOVOUTINCDECJNZJMP

AL,80HDX,FFE7HDXDX,FFE1HCX,22HSI,[3000H]AL,[SI]DXSICXL1BACK

;Initialize 8255 all ports o/p

;Keep on writing the sine wave co ordinate data values to port A

Lookup table:

Memory address

Corresponding values

3000 7F,80,82,83,84,86, 87,88,89,8A,8B,8C,8C,8D,8E,8E,8F,8F,8F,

RESULT:Amplitude and time period of the square wave are measured.Stepper motor is rotated.

VIVA QUESTIONS:1. Give the BSR format?2. What is the angle of a stepper motor in full step mode?3. 8255 has how many pins?4. If the Control word 09bH is given to control register of the 8255 ppi then

explain what is the condition of ports?5. If the 8255 is selected for addresses 0F800H-0F806H what is the address of

port C?6. Mode 1 of 8255 is used for which of the I/O methods?7. 8255 has how many ports?8. What are the applications of the ports?9. Why we need interfacing devices?

42

Page 43: Microprocessor Lab Manual

43

Page 44: Microprocessor Lab Manual

4.8251- UNIVERSAL SYNCHRONOUS ASYNCHRONOUS RECEIVER TRANSMITTER (USART)

AIM: To transfer a block of data.To receive a block of data.

APPARATUS: ESA 86/88-2 Microprocessor kits—2n0s. R S 232 Cable.

THEORY:

Intel’s 8251A is a Universal Asynchronous receiver and transmitter compatible with Intel’s processors. This may be programmed to operate in any of the serial communication modes built in to it.

This chip converts the parallel data in to serial stream of bits suitable for serial transmission. It is able to receive a serial stream of bits and convert in to parallel data bytes to be read by a microprocessor.

The data transmission between two points involves unidirectional or bidirectional transmission of meaningful digital data through a media. There are basically three modes of data transmission.

a) Simplex

b) Duplex

c) Half-duplex

In simplex mode data is transmitted only in one direction over a Single communication channel. In Duplex mode data may be transferred between two transreceivers.In both

Directions simultaneously. In half-duplex mode data transmission may take place in either direction, but at a time data may be transmitted only in one direction.

PORT ADDRESSES OF 8279

Control word register = FFF2

Data Port Address = FFF0

8251A Interfacing

44

Page 45: Microprocessor Lab Manual

FUNCTIONAL BLOCK DIAGRAM OF 8251 USART

I

N

T

E

R

N

A

L

B

U

S

RECEIVERBUFFER(S—P)

TRANSMITCONTROL

TRANSMITBUFFER(P—S)

RECEIVECONTROL

DATA BUSBUFFER

TxD

TxRdy

TxEMPT

TxC

RxD

RxRdy___RxC

SYNDET/BRKDET

READ/WRITE

CONTROLLOGIC

MODEMCONTROL

D7-D0

RESET

CLK

C/D__RD__WR__CS

___DSR__DTR__CTS__RTS

45

Page 46: Microprocessor Lab Manual

PROGRAM:

Transmitter

Memory address

Op codes labels Mnemonics Operands Comments

20002003200520062009200B200C200F20112012201520172019201A201D201F20212022202520272029202A202D20302033203420362028203A203D203F2040204120422044

BA,F2,FFB0,00EEB9,02,00E2,FEEEB9,02,00E2,FEEEB9,02,00E2,FEB0,40EEB9,02,00E2,FEB0,CEEEB9,02,00E2,FEB0,37EEB9,0A,00BE,00,30BA,F2,FFEC24,813C,8175,F9BA,F0,FF8A,04EE464975,ECCC

L1:

L2:

L3:

L4:

L5:

L7: L6:

MOVMOVOUTMOV LOOPOUTMOV LOOPOUTMOV LOOPMOV OUTMOVLOOPMOVOUTMOVLOOPMOVOUTMOVMOVMOVINANDCMPJNZMOVMOVOUTINCDECJNZINT

DX,FFF2HAL,00HDX,ALCX,0002HL1DX,ALCX,0002HL2DX,ALCX,0002HL3AL,40HDX,ALCX,0002HL4AL,CEHDX,ALCX,0002HL5AL,37HEECX,000AHSI,3000HDX,FFF2HAL,DXAL,81HAL,81HL6DX,FFF0HAL,[SI]DX,ALSICX L703

; Soft ware reset 8251.

;activate both Txer and Rxer with communication parameters b.r.f 16,char length 8,no stop bits,2 start bits, no parity.

;transmitting block length 10, start addr.3000

;wait for Txer ready

;transmit the total block on polling basis

46

Page 47: Microprocessor Lab Manual

Receiver

Memory address

Op codes labels Mnemonics Operands Comments

20002003200520062009200B200C200F20112012201520172019201A201D201F20212022202520272029202A202D20302033203420362038203B203D203F204020412042

BA,F2,FFB0,00EEB9,02,00E2,FEEEB9,02,00E2,FEEEB9,02,00E2,FEB0,40EEB9,02,00E2,FEB0,CEEEB9,02,00E2,FEB0,37EEB9,0A,00BE,00,30BA,F2,FFEC24,8175,FBBA,F0,FF8A,04EE464975,EECC

L1:

L2:

L3:

L4:

L5:

L7:L6:

MOVMOVOUTMOV LOOPOUTMOV LOOPOUTMOV LOOPMOV OUTMOVLOOPMOVOUTMOVLOOPMOVOUTMOVMOVMOVINANDJNZMOVMOVOUTINCDECJNZINT

DX,FFF2HAL,00HDX,ALCX,0002HL1DX,ALCX,0002HL2DX,ALCX,0002HL3AL,40HDX,ALCX,0002HL4AL,CEHDX,ALCX,0002HL5AL,37HEECX,000AHSI,3000HDX,FFF2HAL,DXAL,02HL6DX,FFF0HAL,[SI]DX,ALSICX L703

;software reset 8251.

; activate both Txer and Rxer with communication parameters b.r.f 16, char length 8, no stop bits, 2 start bits, no parity.

;receiving block length 10, start addr.3000

;wait for Rear ready

;receive the total block on polling basis

47

Page 48: Microprocessor Lab Manual

RESULT:

A block of 10 bytes is transmitted from the location 3000.A block of 10 bytes is received and stored at location 3000.

VIVA QUESTIONS:

1. What signal is used to receive serial data by the DTE from the DCE?2. What is device from which data originate s or terminates?3. What are the data transmission techniques?4. What is the difference between simplex and duplex?5. What is baud rate factor?6. The L2 and L1 bits in mode word are used for setting which parameter?7. What is the full form of USART?8. Which parameter is set by using bits S1 and S2?

48

Page 49: Microprocessor Lab Manual

49

Page 50: Microprocessor Lab Manual

III.MICRO CONTROLLER 8051

50

Page 51: Microprocessor Lab Manual

INTRODUCTION TO 8051 MICROCONTROLLER: Feature of 8051 Microcontroller:

1. ESA 51e operates on single +5v power supply either in stand alone mode using PC keyboard and LCD or with host PC through its RS-232C interface in serial mode implemented using the On-chip serial port of Microcontroller.

2. Stand alone and serial monitor programs support the entry of user programs editing and debugging facilities like single stepping and full speed execution of user programs.

3. Total On-board memory is 128Kbytes of which 88K bytes RAM has back-up provision.

4. I/O lines and four programmable interval timers.

5. INTERRUPTS:

EXTERNAL: INT is used for implementing single stepping and user’s break switching is available to user.

INTERNAL: Internal timer and serial interrupts are used by the system monitor.

COMMANDS: A Assembler: ESA 5E provides the powerful, PROM resident one-line assembler to enhance development work. This assembler supports the entire standard mnemonics and addressing modes of Intel /5 microcontrollers.

FUNCTION: The assembler generates the actual machine and stores them in the memory locations defined by the program.Also, the system will display the codes generated as well as the source statements.

Any error detected is also displayed on the screen.

C Compare a block of memory with destination block Function: Compare command can be used to compare the contents of one memory block withThe content of another memory block.

F Fill memory Fill a block of memory with a constant or search a string of data in program memory, external data memory and internal data memory. Function: This command is used to fill a block of memory with specified constant. G Go command Transfer the processor control from the monitor to user program.

51

Page 52: Microprocessor Lab Manual

Function: The GO command is used to transfer the control of the system from monitor to the users Program. H Help command List all the commands supported by serial monitor. Function: The help command is used to list all the commands supported by the monitor.

J Jump to address: Function: The J command is used to change the program counter value to the desired address Before executing a program by either GO command or SINGLE STEP command. M Modify/Display/Move memory Modify/Display/Move memory contents in program memory, external data memory ands internal Data memory with all combinations Function: The M Modify memory command is used to examine the contents of specified memory locations. Further if location are in RAM their contents can be altered if desired and block move contents of memory from program, data or internal memory to program or data or internal memory for all combinations. The M Display memory command is used to display the contents of the program memory, external or internal data memory. The M Move memory command is used to move a block of data from one area of the memory to another area.

P Programmer: S Single step command: The command is used to execute a program one instruction at a time. With each instruction Executed, control is returned to the monitor. Thus this command is an extremely useful debugging tool. Provision has been made for single stepping with disassembly.

S Single step command with disassembly: Function: This command is used to single step a program with disassembly. The register contentWill not be displayed.

Z Disassemble: Disassembly is an extremely useful feature, often employed during debugging Function: A disassemble converts machine language codes in to assembly language mnemonics, making it easy for user to understand the/verify the program.

52

Page 53: Microprocessor Lab Manual

PORT0DRIVER

PORT2DRIVER

RAM ADDRREGISTER RAM PORT0

LATCHPORT2LATCH ROM

BREGISTER ACC

C

TMP1 TMP2

STACKPOINTER

BUFFER

PCINCREMENT

ALU

INTERRUPT,SERIEL PORTAND TIMER BLOCKS

TIMING AND CONTROL

INSTRUCTION REGISTER

PORT1DRIVERS

DRIVER

PORT3LATCH

OSCILLATOR

PSW

PROGRAMADDRREGISTER

PROGRAMCOUNTER

PORT1

PORT3DRIVERS

DPTR

53

Page 54: Microprocessor Lab Manual

1. ARITHMATIC OPERATIONS

AIM: To execute the program in stand alone mode and print ESA PVT LTD

APPARATUS: 1.ESA-51 microcontroller kit

2. Power supply 3. Key board

THEORY:                            8051 is an 8 bit Microcontroller which a Microprocessor with integrated peripherals.The accumulator register act as an operand register in case of some instructions. The accumulator has been allotted an address in the on chip special for register bank.                            Data pointer register is a 16-bit register and contains a high byte and positive lower byte Of a 16-bit register external RAM address. It is accessed as a 16-bit register or 28-bit register as a specified above. It has allotted to address as a specified also in the special function register bank for its two bytes DPH and DPL .SWAP is an instruction which interchanges the upper and lower nibble of a register for example SWAPS means it interchanges the upper and lower nibble of the contents of accumulator register.

Memory address

Op codes labels Mnemonics Operands Comments

8000

8003

8005

8008

800B

800E

8013

8018

12,03,BB

C2,D5

90,80,0E

12,03,2A

02,80,0B

45,53,41,20,50

56,54,20,4C,54

44,2E,00

LCALL

CLR

MOV

LCALL

LJMP

STG DB‘ESA PVT LTD’

03BB

D5

DPTR,#800E

0348h

800B

To select theProgram memory

Out routine to display string of characters

INPUT: 45,53,41,20,50,56,54,20,4C,54,44,2E,00

OUTPUT: ’ESA PVT LTD’

RESULT:’ESA PVT LTD’ is displayed on the LCD in stand alone mod

54

Page 55: Microprocessor Lab Manual

AIM: By using 8051 microcontroller a) To perform addition of two numbersb) To perform subtraction of two numbersc) To perform multiplication of two numbersd) To perform division of two numbers

APPARATUS:                      1.ESA-51 microcontroller kit 2. Power supply 3. Key board

THEORY:                           The 8051 is an 8-bit Microcontroller designed by Intel. It was optimized for 8-bit Mathematics and single bit Boolean operations. Microcontroller consists of Cutworm kinds of memory Sections I/O ports, special function registers and control logic needed foe a variety of peripheral functions.These elements communicate through an 8-bit data bus which runs through out the chip referred to as internal Data bus. This bus if buffered to the outside world through an I/O port when memory or I/O expansion is desiredADDITION

Memory address

Op codes labels Mnemonics Operands Comments

8000

8003

8004

8006

8007

8008

800A

800B

800C

90,90,00

E0

E5,0B

A3

A0

25,0B

A3

F0

02,00,00

MOV

MOVX

MOV

INC

MOVX

ADD

INC

MOVX

LJMP

DPTR,#9000H

A,@DPTR

B,A

DPTR

A,@DPTR

A,B

DPTR

@DPTR,A

0

Keep data in 9000h and 9001h;data memory

Perform addition operationStore the result in 9002h and 9003h of data memory.

INPUT: 9000-05H OUTPUT: 9002-0AH 9001-02H

55

Page 56: Microprocessor Lab Manual

SUBTRACTION

Memory address

Op codes labels Mnemonics Operands Comments

8000

8003

8004

8006

8007

8008

800A

800B

800C

90,90,00

E0

E5,0B

A3

A0

95,0B

A3

F0

02,00,00

MOV

MOVX

MOV

INC

MOVX

SUBB

INC

MOVX

LJMP

DPTR,#9000H

A,@DPTR

B,A

DPTR

A,@DPTR

A,B

DPTR

@DPTR,A

0

Keep data in 9000h and 9001h;data memory

Perform subtraction operationStore the result in 9002h and 9003h of data memory.

INPUT: 9000-06H OUT PUT: 04H 9001-02H

56

Page 57: Microprocessor Lab Manual

MULTIPLICATIONMemory address

Op codes labels Mnemonics Operands Comments

8000

8003

8004

8006

8009

800A

800B

800E

800F

8010

8012

8013

90,90,01

E0

F5,F0

90,90,00

E0

A4

90,90,02

F0

A3

E6,F0

F0

02,00,00

MOV

MOVX

MOV

MOV

MOVX

MUL

MOV

MOVX

INC

MOV

MOVX

LJMP

DPTR,#90001H

A,@DPTR

0F0H,A

DPTR,#9000H

A,@DPTR

AB

DPTR,#9002H

@DPTR,A

DPTR

A,OFOH

@DPTR,A

0

Keep data in 9000h and 9001h;data memory

Perform multiplication operationStore the result in 9002h and 9003h of data memory.

INPUT: 9000- 05 H 9001- 04 H OUTPUT: 9002-09H

57

Page 58: Microprocessor Lab Manual

DIVISION

Memory address

Op codes labels Mnemonics Operands Comments

8000

8003

8004

8006

8008

8009

800A

800D

800E

800F

8011

8012

90,90,01

E0

F5,F0

16,82

E0

84

90,90,02

F0

A3

E6,F0

F0

02,00,00

MOV

.MOVX

MOV

DEC

MOVX

DIV

MOV

MOVX

INC

MOV

MOVX

LJMP

DPTR,#90001H

A,@DPTR

0F0H,A

82H

A,@DPTR

AB

DPTR,#9002H

@DPTR,A

DPTR

A,OFOH

@DPTR,A

0

Keep data in 9000h and 9001h;data memory

Perform division operationStore the result in 9002h and 9003h of data memory.

INPUT: 9000-04H 9001-05H

OUTPUT: 9002-01H

RESULT: Hence arithmetic operations like addition, subtraction, multiplication and division are performed on 8051 Microcontroller.

58

Page 59: Microprocessor Lab Manual

2. TIMER IN DIFFERENT MODES

AIM: To generate a square wave with frequency using Timer 0 and Interrupts

APPARATUS:1. Microcontroller kit2. Cathode ray oscilloscope3. Keyboard4. CRO probes

THEORY:

8051 has two 8-bit register A and B, which can be used to store operands, as allowed by the instruction set.8051 has a family of special function registers called a special function registers including A and B registers. There is total number of 21-bit addressable 8-bit registers. The registers TH0-TL0 from 16-bit counter or timer registers, with H indicating the upper byte and L indicating the lower byte of 16-bit timer registers.TMOD is ca be used for programming the modes of Times/Counters .TCON is called Timer/Counter control register. Some of the bits of this registers are used to turn the Timers on or off. This registers are also contains interrupt control flags for external interrupts

INT1 or INT0.

MAIN PROGRAM:

Memory address

Op codes labels Mnemonics Operands Comments

8000

8003

8004

8006

8007

8008

75,89,01

75,8C,F0

75,8A,FF

11,20

80,FE

53,41,20

MOV

MOV

MOV

ACALL

CPL

SJMP

TMOD 89,#01

TL1 8A,#0F0

TH1 8C,#0FF

8020

95

8003

Initialize timer 0In mode 1,16-bit count reg.mode

Introduce delay

Keep complimenting port 1,5-bitTo get square wave

59

Page 60: Microprocessor Lab Manual

DELAY PROGRAM:

Memory address

Op codes labels Mnemonics Operands Comments

8020

800

8004

8006

8007

D2,8C

C2,8C

C2, 8D

22

SETB

JNB

CLR

CLR

RET

8C

8D,8022

8C

8D

Start the timer

Wait for delay timeReset timer

Reset timer over flow flag

MAIN PROGRAM:

Memory address

Op codes labels Mnemonics Operands Comments

8000

800

8004

8006

8007

75,89,02

75,A8,82

75,8C,F0

D2,8C

80,0B

MOV

MOV

MOV

SETB

SJMP

89,#02

0A8,#82

8C,#0F0

8C

800B

Initialize timer 0 in mode 2,Declare TF 0 as an interruptLoad timer count reg.TL1Start the timer

Keep monitoring the interrupt

INTERRUPT SERVICE ROUTINE:

Memory address

Op codes labels Mnemonics Operands Comments

FFF1

FFF2

B2,95

32

CPL

RETI

95 Generate a square wave on interrupt basis

60

Page 61: Microprocessor Lab Manual

OBSERVATIONS:

Time period calculations for Timer0 mode1

16-bit counter =FOFFH Number of clock cycles = FFFF – FOFF=F00H Clock period =11.095 µSec/12=0.925µSec Delay= Clock period* Number of clock cycles=0.925µSec* F00H=3.78msec. Therefore ON time=3.78msec OFF time=3.78msec Time period=ON time OFF time= 7.56msec Frequency=1/Time period=1/7.56msec=132Hz

Time period calculations for Timer0 mode2

16-bit counter =FFH Number of clock cycles = FF – FO=0FH Clock period =11.095 µSec/12=0.925µSec Delay= Clock period* Number of clock cycles=0.925µSec* 0F=13.875µSec. Therefore ON time=13.875µSec.         OFF time=13.875µSec.

Time period=ON time OFF time= 27.75 µSec                Frequency=1/Time period=1/27.75 µSec =36.04 KHz.

RESULT: Hence square wave in Timer0 mode1 with a frequency 132Hz and in timer0 mode2 with a frequency 36.04 KHz was generated.

61

Page 62: Microprocessor Lab Manual

EXPERIMENTS OTHER THAN JNTU SYLLABUS

62

Page 63: Microprocessor Lab Manual

1.8279-KEYBOARD DISPLAY : PROGRAM TO DISPLAY A CHARACETR & READING KEYBOARD AND DISPLAY CHARACTER

AIM: To display single character.To read the character from the keyboard and display.

APPARATUS: ESA 86/88-2 Microprocessor kit.

THEORY: Intel’s 8279 is a general purpose keyboard display controller that simultaneously drives the display of a system and interfaces a key board with the CPU, leaving it free for its routine task .The keyboard display interface scans the keyboard to identify if any key has been pressed and sense the code of the pressed key to Performed by the controller in repetitive fashion with out involving the Cup-Tie keyboard is interfaced either in interrupt mode or polled mode. In the interrupt mode the processor is requested service only if any key is pressed otherwise the CPU can proceed with its main task. In the polled mode the CPU periodically reads an internal flag of 8279 to check for a key pressure. The keyboard section can interface an array of a maximum of64 keys with the CPU.The keyboard entries are debounced and stored in 8-byte FIFO RAM that is further accessed by the CPU to read the key codes. If more than 8-characters are entered in the FIFO. Before anyFIFO read operation the overrun status is set. The 8279 is normally provides maximum of sixteen 7 segment Display interface with CPU.

PORT ADDRESSES OF 8279

Control word register = FFEBData Port Address = FFE9

8279A Interfacing:

8086 8279 7-seg display

63

Page 64: Microprocessor Lab Manual

8279 INTERNAL ARCHITECTURE

PROGRAM:

To display single character

Memory address

Op codes labels Mnemonics Operands Comments

200020032005200620082009200B200C200F20112012

BA,EB,FFB0,00EEB0,38EEB0,90EEBA,E9,FFB0,CHAREEEB,FE

L1:

MOVMOVOUTMOV OUTMOV OUTMOVMOVOUTJMP

DX,FFEBHAL,00HDX,ALAL,38HDX,ALAL,90HDX,ALDX,FFE9HAL,CHARDX,ALL1

; Initialize 8279 in encoded scan keypad 2key lock out, 8char display left entry.;Select display position 0

;Display the character

64

Page 65: Microprocessor Lab Manual

To read the character and display

Memory address

Op codes labels Mnemonics Operands Comments

200020032005200620082009200C200D200F20112013201420172018201B201D201F2022202420252028202A202B

BA,EB,FFB0,00EEB0,38EEBA,EB,FFEC24,0774,F8B0,40EEBA,E9,FFECBE,00,40B4,000B,F0BA,EB,FFB0,90EEBA,E9,FF8A,04EEEB,DC

L1:

MOVMOVOUTMOV OUTMOVINANDJZMOVOUTMOVINMOVMOVORMOVMOVOUTMOVMOVOUTJMP

DX,FFEBHAL,00HDX,ALAL,38HDX,ALDX,FFEBHAL,DXAL,07L1AL,40HDX,ALDX,FFE9HECSI,4000HAH,00HSI,AXDX,FFEBHAL,90HDX,ALDX,FFE9HAL,[SI]DX,ALL1

;Initialize 8279 in encoded scan keypad 2key lock out,8char display left entry.; scan the key board for key press.

;read the character

; get the address of the character code.;Select display position 0

;Display the key no. pressed; wait for next key.

RESULT:A character is displayed at 0 position of the display.A string characters is displayed on left entry basis.A character is read from the keyboard and displayed the key no on the display using look-up table method.

VIVA QUESTIONS:

8. What is the value in AH perform input from keyboard?9. A keyboard is made using 12 keys connected not as a matrix. How many pins

of the I/O port are used?10.Write a 7–segment code for ‘B’?11. In the single character display using interrupt 21H, DL is the register contains

character to display.If DL contains 41H, which character is displayed?

12.What is the difference between CALL and JMP?13.What is the purpose of ALE?

What are the difference between microprocessor and micro controller?

65

Page 66: Microprocessor Lab Manual

66

Page 67: Microprocessor Lab Manual

2.8255- PROGRAMMABLE PERIPHERAL INTERFACE (PPI)

AIM: To generate square wave.To control the speed & direction of stepper motor.

APPARATUS: ESA 86/88-2 Microprocessor kit.C.R.O.Stepper motor interface module with stepper motor.F R C Cable.Power supply- +15v.

THEORY: The parallel input-output port chip 8255 is also called as Programmable peripheral input-outputPort. The Intel’s 8255 are designed for use with Intel’s 8-bit, 16-bit and higher capability microprocessors. It has 24 input/output lines which may be individually programmed in 2-groups of 12 lines each, or 3 groups of 8 lines .The two groups of I/O pins are named as GROUP A and GROUP B. Each of these two groups contain a sub group of 8 I/O lines called as 8-bit Port and other sub group of 4 I/O lines are a 4-bit port. Thus GROUP AContains an 8-bit port A along with a 4-bit port, C upper. Port lines are identified by symbols PAO-PA7,While the port C lines are identified as PC4-PC7 .Similarly group B contains an 8-bit port B, containing linesPB0-PB7 and a 4-bit port C with lower bits PC0-PC3 .The port C upper and port C lower can be used in recombination as an 8-bit port-C .Both the port Cs are assigned the same address. Thus one may have eitherThree 8-bit I/O ports are two 8-bit and two 4-bit I/O ports from 8255.All of these ports can function independently either as input or as output ports. This can be achieved by programming the bits of an internal register of 8255 called as Control word register. (CWR).

PORT ADDRESSES OF 8255

Control word register = FFE7Port A = FFE1Port B = FFE3

Port AC = FFE5

Block diagram of 8255 Interfacing

Stepper motor inter face

8255PPI

Micro processor8086

67

Page 68: Microprocessor Lab Manual

Block diagram of 8255 programmable peripheral interface:

GroupA

control

GroupB

control

GroupA

PortA(8)

GroupA

PortC upper

(4)

GroupB

PortC lower

(4)

GroupB

PortB(8)

DATABUS

BUFFER

Read/write

Control logic

8 bit internal bus

I/OPA7-PA0

I/OPC7-PC4

I/OPC3-PC0

I/OPB7-PB0

BIDIRECTIOAL DATA BUS BUFFER

D7--D0

POWER SUPPLIES

+5V

GND

__ RD __ WR

A1

A0

RESET

__ CS

68

Page 69: Microprocessor Lab Manual

SQUARE WAVE GENERATION

PROGRAM:

Main program:

Memory address

Op codes labels Mnemonics Operands Comments

20002003200520062009200B200C200F2011

BA,E7,FFB0,80EEBA,E1,FFB0,FFEEE8,11,00F6,D0EB,F8

L1:

MOVMOVOUTMOV MOVOUTCALLNOTJMP

DX,FFE7HAL,80HDX,ALDX,FFE1HAL,FFHDX,ALDELAYALL1

;Initialize 8255 all ports o/p

;Make port a high

;Wait for on/offCompliment port A continuously

Delay subroutine:

Memory address

Op codes labels Mnemonics Operands Comments

20202023202620272028202A202B202D

BB,01,00B9,99,00904975,FC4B75,F6C3

L3: L2:

MOVMOVNOPDECJNZDECJNZRET

BX,0001HCX,0099H

CXL2BXL3

;Initialize the counters for delay

;Wait for 0.5 ms.

69

Page 70: Microprocessor Lab Manual

STEPPER MOTORPROGRAM:

Main program:

Memory address

Op codes labels Mnemonics Operands Comments

20002003200520062009200B200C

200F2011

BA,E7,FFB0,80EEBA,E1,FFB0,FFEEE8,11,00

D0,C8/C0EB,F8

L1:

MOVMOVOUTMOV MOVOUTCALL

ROR/ROLJMP

DX,FFE7HAL,80HDX,ALDX,FFE1HAL,88HDX,ALDELAY

ALL1

;Initialize 8255 all ports o/p

; Start stepper motor in half step mode.;Wait for step time;Rotate the stepper motor continuously

Delay subroutine:

Memory address

Op codes labels Mnemonics Operands Comments

20202023202620272028202A202B202D

BB,0A,00B9,02,5D904975,FC4B75,F6C3

L3: L2:

MOVMOVNOPDECJNZDECJNZRET

BX,000AHCX,5D02H

CXL2BXL3

;Initialize the counters for delay

;Wait for 1 sec.

RESULT:Amplitude and time period of the square wave are measured.Stepper motor is rotated.

VIVA QUESTIONS:1. Give the BSR format?2. What is the angle of a stepper motor in full step mode?3. 8255 has how many pins?4. If the Control word 09bH is given to control register of the 8255 ppi then

explain what is the condition of ports?5. If the 8255 is selected for addresses 0F800H-0F806H what is the address of

port C?6. Mode 1 of 8255 is used for which of the I/O methods?7. 8255 has how many ports?8. What are the applications of the ports?9. Why we need interfacing devices?

70

Page 71: Microprocessor Lab Manual

71

Page 72: Microprocessor Lab Manual

3 .DECIMAL COUNTER

AIM: To display decimal counter on the data field of ESA-86/88-2 kit.

APPARATUS: ESA 86/88-2 Microprocessor kit.

PROGRAM:

Main program:

Memory address

Op codes labels Mnemonics Operands Comments

2000200320042009200C200D200F2010

B8,00,00509A,0A,0B,00,FFE8,14,005804,0127EB,F1

L1:MOVPUSHCALLCALLPOPADDDAAJMP

AX,0000HAXFF00:0B0ADELAYAXAL,01H

L1

; Get the 1st

no.

; Display the no.

; Add 1 to previous no.;Jump back

Delay subroutine:

Memory address

Op codes labels Mnemonics Operands Comments

20202023202620272028202A202B202D

BB,0A,00B9,02,5D904975,FC4B75,F6C3

L3: L2:

MOVMOVNOPDECJNZDECJNZRET

BX,000AHCX,5D02H

CXL2BXL3

;Initialize the counters for delay

;Wait for 1 sec.

RESULT : The decimal counter is displayed on the data field of the microprocessor display.

72