Microprocessor Lab Manual

Share Embed Donate


Short Description

gud for reference...

Description

1

MICROPROCESSORS LAB CODE NO: 05401 I. Microprocessor 8086 1. Introduction to MASM/TASM 2.  Arithmetic operations – Multi byte addition and subtraction, multiplication m ultiplication and

divi divisi sion on-s -sig igne ned d

and and

unsi unsign gned ed Arit Arithm hmet etic ic oper operat atio ion, n, ASCI ASCIII-

arit arithm hmet etic ic

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/BI DOS/BIOS OS Progra Programmi mming: ng: Readin Reading g keyboa keyboard rd (Buffe (Buffered red with with and with with out

echo) - Display characters, Strings.

II.INTERFACING 1. 8259-Interuupt controller: Generate an interrupt using 8259 timer. 2. 8279 8279-K -Key eybo boar ard d disp displa lay y: Writ Write e a smal smalll prog progra ram m to disp displa lay y a stri string ng 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. Readin Reading g and writi writing ng on a para paralle llell port. port. 2. Timer Timer in differ different ent modes modes.. 3. Serial Serial commun communica icatio tion n implemen implementat tation ion..

2

MICROPROCESSORS LAB I.

Micr Microp opro roce cess ssor or 8086 8086

1. Introd Introduct uction ion to MASM/T MASM/TASM ASM 2.  Arithmetic operations – Multi byte addition and subtraction, multiplication m ultiplication and divi divisi sion on-s -sig igne ned d and and unsi unsign gned ed Arit Arithm hmet etic ic oper operat atio ion, n, ASCI ASCIII- arit arithm hmet etic ic operation. 3. Logic operati operationsons- Shift Shift and rotate-Con rotate-Converti verting ng packed packed BCD to Unpacked Unpacked BCD, 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/BI DOS/BIOS OS Progra Programmi mming: ng: Readin Reading g keyboa keyboard rd (Buffe (Buffered red with with and with with out echo) - Display characters, Strings. II. INTERFACING

1. 8259-I 8259-Inte nteruu ruupt pt contro controlle ller: r: 1. Puls Pulse e Coun Counte ter  r  2. Frequency Counter  2. 8279-K 8279-Key eyboa board rd displa display: y: Display String of Characters 3. 8255-PPI: Sine wave generation 4. 8251-USART 8251-USART:: Write a program program in ALP ALP establish establish communi communicatio cation n between between to processors. III. MICROCONTROLLER 8051

1. Arit Arithm hmat atic ic oper operat atio ions ns.. 2. Timer Timer in differ different ent modes modes.. a. Generate Generate delay delay using using timer timer 0 in mode mode 1 for for square square wave wave b. Generate Generate delay delay using using timer timer 0 in mode mode 2 for for square square wave wave EXPERIMENTS OTHER THAN JNTU SYLLABUS SYLLABUS

1. 827 8279-Ke 9-Key yboar board d dis display lay: Writ Write e a smal smalll progr rogra am to disp displa lay y a strin tring g of  Characters. a. Displa Display y of of Sing Single le Charac Character  ter  b. Reading Reading charac character ter from from keyboard keyboard and display displaying ing it 2. 8255-PPI: a. Square wave generation b. Stepper motor speed and direction control 3. Decimal counter display.

3

MICRO PROCESSOR 8086 1. INTRODUCTION TO MASM/TASM

4

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. EXE  Are 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 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 assembler program is to accept the text _assembly _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.

5

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 exec execut utab able le code codes. s. The The asse assemb mble lerr deci decide des s the the addr addres ess s of each each labe labell and 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 types of the different different routines and modules, modules, end of file etc. These types types of hints are giv given to ass assembl embler er usin using g some ome prede redefi fine ned d alph lphabet abetic ica al stri strin ngs calle alled d “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.

6

END:

The END directive directive marks marks the end of an assembly assembly language program. When the ass assemb embler ler come comes s across across this direc directiv tive, e, it ignore ignores s the sour source ce lines lines available later on. ENDP:

In assembly language programming, the subroutines 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 name i.e., label by this statement. The SEGMENT and ENDS directive must bracket each logical Segment of a program.

7

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

8

THIS PROGRAM PERFORMS MULTIBYTE ADDITION

Turbo urbo Ass Assemble mblerr Versi ersion on 2.51 .51 add.asm /* the data segment in array1 and the data segment in array2 is added and the result Will be stored and displayed in data segment array3*/ 1 2 3 0000 4

assume cs: code,ds: data code segment

5 6 7 8 9 10 11

0000 B8 0000s 0003 8E D8 0005 0005 8B 0E 0000 0000rr 0009 BE 0002r 000C BB 0006r 000F BF 000Ar 0012 8A 04

12 13 14 15 16 17

0014 12 07 0016 88 05 0018 46 0019 43 001A 47 001B 49

18 00 001C 75 F4 19 001E CC 20 21 22 23 24 25 26 27 28

00 001F 00 0 000 0000 0002 0006 000A 00 000E

start: move ax, data mov ds,ax mov mov cx,n cx,n1 1 ;init ;initia ialis lise e coun counte ter  r  lea si,array1 ay1 ;in ;iniitiali ialis se point inter  lea bx,array2 lea di,array3 l1:mov al,[si] ;perform addition Of 1st byte ad al,[bx] mov [di], al ; store the result inc si ;update data pointers inc bx inc di dec cx ; repeat addition till The final byte jnz l1 int 03 code ends

data segment 0004 n1 dw 0004h 01 01020304 array1 dd 01020304h ;s ;specify inputs 01020304 array2 dd 01020304h ???????? array3 dd? ; store the result data ends end start

Input :

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

9

Output:

02040608h

10

THIS PROGRAM PERFORMS MULTIBYTE SUBTRACTION

Turbo urbo Ass Assemble mblerr sub.asm

Versi ersion on 2.51 .51

/* The data segment in array1 and the data segment in array2 is subtracted and the result Will be stored and displayed in data segment array3*/ 1 2 3 4 5 6 7 8

assume cs: code,ds: data 0000 0000 0003 0005 0009

code segment B8 0000s 8E D8 8B 0E 0000r BE 0002r

9 000C BB 000Ar 10 000F BF 0012r 11 0012 8A 04 12 13 14 15 16

0014 0016 0018 0019 001A

1A 07 89 05 46 43 47

17 18 19 20 21 22 23 24 25 26 27 28 29

001B 49 00 001C 75 F4 001E CC 00 001F 00 0 000 0000 0002 000A 0012 001A

Input:

Output:

start : mov ax,data mov ds,ax mov cx,n1 ;initialise counter   lea si,array1 ;initialise array pointers lea bx,array2 lea di,array3 l1:mov al,[si] ;perform subtraction of   ls byte sbb al,[bx] mov [di],ax ;store result inc si ;update data pointers inc bx inc di ;repeat subtraction till last byte dec cx jnz l1 int 03 code ends data segment

0004 n1 dw 0004h 0000000005060809 array ray1 dq 05060809h;specify ify input 0000000001020304 array2 dq 01020304h ???????????????? array3 dq ? ;store output data ends end start ;stop array1 :05060809h array2 :01020304h 04040505h

11

THIS PROGRAM PERFORMS MULTIBYTE MULTIPLICA M ULTIPLICATION TION

Turbo urbo Ass Assemble mblerr mul.asm

Versi ersion on 2.51 .51

/* The data segment in data1 and the data segment in n2 is multiplied and the result Will be stored and displayed in data segment data2*/ 1 2 3 4 5 6 7 8 9 10 11 12

assume cs: code,ds: data

0000 0003 0005 0005 0009 0009 000D 0010 0013 0016

B8 0000s 8E D8 8B 0E 0000 0000rr 8A 1E 0002 0002rr BA 0000 BE BE 0003r BF BF 0007r 8A 8A 04

13 14 15 16

0018 001A 001C 001E

F6 E3 03 C2 8A D4 88 05

0000

code segment

17 0020 46 18 0021 47 19 20 21 22 23 24 25 26 27 28 29 30

00 0 022 49 0023 75 F1 00 0 025 CC 0026 0000 0000 0002 0003 0007 000B

Input:

start:mov ax,data mov ds,ax mov mov cx,n cx,n1 1 ;len ;lengt gth h of array array mov mov bl,n bl,n2 2 ;mul ;multi tipl plie ier  r  mov dx,00h lea si,data1 ;a ;array pointer   lea di,data2 ;r ;result pointer   l1: mov al,[si] ;get 1st byte of   multiplicand mul bl ;multiply add ax,dx mov dl,ah mov [di],al ;store result in result pointer  inc si ;update data pointer   inc di ;perform multiplication till the last multiplicand dec cx jnz l1 int 03 code ends

data segment 0004 n1 dw 0004h 05 n2 db 05h 01020304 01020304 data1 dd 01020304 01020304h h ???????? data2 dd ? data ends end start ;stop Multiplier: 05h Multiplicand: 01020304h

Output:

050A0F14h

12

THIS PROGRAM PERFORMS MULTIBYTE DIVISION

Turbo urbo Ass Assemble mblerr div.asm

Versi ersion on 2.51 .51

/* The data segment in data1 and the data segment in n2 is divided and the result Will be stored and displayed in data segment data2*/ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

assume cs: code,ds: data 0000

code segment

0000 0003 0005 0005 0009 0009 000 000D 0010 0013 0015 0017 0018 001A 001C 001E 0020

B8 0000s 8E D8 8B 0E 0000 0000rr 8A 1E 0002 0002rr BE 0003 0003rr BF 0007r B4 00 8A 04 98 F6 F3 1B C2 8A D4 88 05 46

19 20 21 22 23 24

0021 0022 0023 00 0025 00 0026

47 49 75 F0 CC

25 26 27 28 29 30 31 32 33

00 0 000 0000 0002 0003 0007 000B

start: mov ax, data mov ds,ax mov mov cx,n cx,n1 1 ;div ;divid iden end d leng length th mov mov bl,n bl,n2 2 ;div ;divis isor  or  lea si,d i,data ata1 ;in ;initia itiali lize ze data data point ointe er  lea di,data2 mov ah,00h l1:mov al,[si] ;get 1st byte of dividend cbw div bl ;perform division sbb ax,dx mov dl,ah mov [di],al ;store quotient inc si ;update dividend and result pointers inc di dec cx ;perform this till MSB jnz l1 int 03 ;stop code ends data segment

0004 05 140F0A19 ????????

n1 dw 0004h n2 db 05h data1 dd 140f0a19h data2 dd ? data ends end start

Input:

Divisor: 05h Dividend; 140F0A19h

Output:

04030205h

13

THIS PROGRAM FINDS NO.OF +VE & -VE NO.S IN ARRAY

Turbo urbo Ass Assemble mblerr pos_neg.asm

Versi ersion on 2.51 .51

/*The data segment in the list finds whether it is a positive number or negative number  if msb is 1 it is i s negative otherwise considered as positive*/ 1 2 3 0000 4 5 0000 33 DB 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

0002 0004 0007 0009 000D 0010 0012 0014 0016 0017 001A 001A 001B 001B 001E 0020 0022 0023

assume cs: code,ds: data code segment start: xor bx,bx

;initialise result pointer 

33 D2 xor dx,dx B8 0000s mov ax,data 8E D8 mov ds,ax B1 B 1 05 90 90 mov cl,count ;declare length of array BE 0000r mov si,offset list 8B 8B 04 again:mov ax,[si] ;get 1st no. D1 E0 shl ax,01h ;check whether msb is 1 72 04 jc nega ;if 1 the no.is -ve 43 inc bx ;if 0 the no.is +ve EB 02 90 jmp next 42 nega:i nega:inc nc dx 83 83 C6 02 next: ext:a add si,0 i,02h ;up ;updte dte data point ointer  er  FE C9 dec cl ;decrement length counter  75 EE jnz again ;repeat untill final no. CC int 03 code ends ;store result

0000 data segment 0000 0000 A500 A500 C009 C009 0159 0159 B900 B900 list list dw 0a50 0a500h 0h,0 ,0c0 c009 09h, h,01 0159 59h, h,0b 0b90 900h 0h = 0005 count equ 05h 0008 data ends end start

Input:

0a500h,0c009h,0b900h,0159h

Output:

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

14

THIS PROGRAM FINDS THE GCD OF TWO NUMBERS

Turbo urbo Ass Assemble mblerr gcd.asm

Versi ersion on 2.51 .51

/*This program calculates the GCD of two numbers stored at data segment num1 and num2 locations and gives gives the result at the the data segment gcd gcd offset address*/ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

assume cs: code,ds: data 0000

code segment

0000 0003 0005 0008 000A 000D 000F 0011 0013 0014

B8 0000s 8E D8 BE 0000r 8B 04 BE BE 0002r 8B 1C 3B C3 7F 01 93 2B C3

0016 0018 001A 001C 001F

3B C3 7F FA 7C F7 BE BE 0004r 89 04

start: mov ax,data mov ds,ax mov si,offset num1 ;get 1st no. mov ax,[si] mov si,offset num2 ;get 2nd no. mov bx,[si] cmp ax,bx ;get big no,asdividend jg go back : xchg ax,bx go : sub ax,bx ;get gcd using repeated cmp ax,bx jg go ;division jl back mov si,offset gcd ;store result mov [si],ax

0021 CC

int 03

0022

code ends

0000 0000 0018

data segment num1 dw 0018h

27 0002 00 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

;stop

;the no.s in data segment

15

THIS PROGRAM FINDS NO.OF 0's AND 1's IN A 16-BIT NUMBER

Turbo urbo Ass Assemble mblerr zer_one.asm

Versi ersion on 2.51 .51

/*The data segment in the num finds no. of 1’s and no. of 0’s by converting the given number into binary */ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

assume cs: code,ds: data 0000

code segment

0000 0002 0004 0007 0009 0009 000D 0010 0012 0014 0015

33 33 DB 33 D2 B8 0000s 8E D8 B1 10 90 90 A1 0000r D1 D1 C0 72 04 43 EB 02 90

0018 0019 001B 001D 00 001E

42 FE C9 75 F3 CC

00 0 000 0000 D759 = 0010 00 0002

start: xor bx,bx ;clear result counters xor dx,dx mov ax,data mov ds,ax mov mov cl,c cl,cou ount nt ;dec ;decla lare re no. no. bit bit coun countt mov ax,num ;get the no. again:rol ax,01h ;finds msb is 0 or 1 jc ones ;if 0 increment 0s count inc bx ;otherwise 1s count jmp next ;perform this until the 1st bit ones:inc dx next:dec cl jnz again int 03 ;stop code ends data segment num dw 0d759h count equ 10h data ends end start

Input :

num is 0d759h

Output:

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

;no. in data segment

16

THIS PROGRAM FINDS WHETHER GIVEN NUMBER IS PRIME OR NOT

Turbo urbo Ass Assemble mblerr prime.asm

Versi ersion on 2.51 .51

/*The data segment in num is prime the same data will be displayed at res otherwise zero will be displayed*/ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

assume cs: code,ds: data 0000 0000 0000 0003 0005 0008 000A 000A 000C

B8 0000s 0000s start: start: mov ax,dat ax,data a 8E D8 mov ds,ax BE 0000r mov si,offset num 8B 1C mov bx,[si] ;get the number   8B 04 loop loop1 1 :mov :mov ax,[ ax,[si si]] ;if no.is no.is 1 B9 0001 mov cx,0001h

000F 00 0 012 0013 0015 0017 0017

BA 0000 4B 3B D9 74 0B F7 F3

17 0019 18 001C 19 001E 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34

code segment

0020 0020

mov dx,0000h ;no.is prime dec bx cmp bx,cx jz ahead2 ;otherwise perform div div div bx ;if rema remain inde derr 0 then then no.is not prime 83 83 FA 00 cmp dx,0000h 74 02 jz ahead1 EB EA jmp loop1 ;no remainder no. is prime 8B C2 ahead ahead1: 1: mov ax,dx ax,dx ;perfo ;perform rm div from from -1to1 -1to1

0022 BE 0002r ahead2: ahead2: mov si,offset si,offset res 0025 89 04 mov [si],ax 0027 CC 0028

int 03

;stop

code ends

0000 0000 0012 0002 ???? 0004

data segment num dw 0012h ;give the input no. res dw ? ;store result here data ends end start

Input :

num=0012h

Output:

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

17

THIS PROGRAM SOLVES THE EQUATION (P+(Q*R)/S)

Turbo urbo Ass Assemble mblerr equ.asm

Versi ersion on 2.51 .51

/*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 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28

assume cs: 0000 0000 0003 0005 0008 000C 000E 0012 0014 0018 001A 001D 001F 0020

code segment B8 B8 0000s start: mov ax,data 8E D8 mov ds,ax B8 0012 mov ax,q ;get no.q BB 0005 90 mov bx,r   F7 E3 mul bx ;multiply with r   B9 0009 90 mov cx,s F7 F1 div cx ;div the res by s BA 0023 90 mov dx,p ;add it to p 03 C2 add ax,dx BF BF 0000r mov di,offset res ;store the result 89 05 mov [di],ax CC int 03 code ends

0000 = = = = 0000

code,ds: data

data segment 0023 0012 0005 0009 ????

0002

p equ 0023h q equ 0012h r equ 0005h s equ 0009h res dw ? data ends end start

;no.s in datasegment

;result in data segment ;stop

Input :

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

Output:

ax=002Dh

18

3.LOGICAL OPERATIONS  Conversion

of ASCII no. to packed BCD

 Conversion

of packed BCD no. to ASCII

 Conversion

of BCD no. into binary

19

THIS PROGRAM CONVERTS ASCII NOS INTO PACKED BCD

Turbo Assembler equa.asm

Version 2.51

10/11/07 14:11:42

Page 1

/*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 2 3 4 5 6 7 8 9 10 11 12

Input:

0000 0000 0002 0004 0007 0009 000B 000D 000F 0010

B3 32 B0 34 80 80 E3 0F 24 0F B1 04 D2 C3 0A C3 CC

assume cs:code code segment start: mov bl,'2' mov al,'4' and bl,0fh and al,0fh mov cl,04h rol bl,cl or al,bl int 03h code ends end start

bl=02h al=04h

Output: BCD value is 24h in al register.

;GET 1ST ASCII no. ;get 2nd ASCII no. ;mask the upper nibble ;of 2 ASCII nos ;pack the 2 nos. ;BCD result in reg.AL.

20

THIS PROGRAM CONVERTS PACKED BCD TO ITS I TS EQUIVALENT ASCII NO.

Turbo urbo Ass Assemble mblerr bcd_asc.asm

Versi ersion on 2.51 .51

/*The packed BCD number 0095h is converted into its equivalent ASCII number and result will stored in res1 and res2*/ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

assume cs: code,ds: data 0000 0000 0003 0005 0007 000A 000C 000E 0010 0013 0015 0017 001A 001D 001D 00 0 021 0022

code segment B8 0000s start: mov ax,data 8E D8 mov ds,ax 32 E4 xor ah,ah B0 95 90 mov al,bcd ;get the no. 8A E0 mov ah,al ;convert into unpacked bcd 24 0F and al,0fh 0C 30 or al,30h ;find res1 ascii 80 E4 F0 and ah,0f0h B1 04 mov cl,04h D2 C4 rol ah,cl 80 CC 30 and ah,30h ;find res2 ascii A2 0000r mov res1,al ;st ;store result 88 26 0001 0001rr mov mov res2 res2,a ,ah h CC int 03 code ends

0000 data segment = 0095 bcd equ 0095h ;BCD INPUT 0000 ?? res1 db ? ;result display 0001 ?? res2 db ? 0002 data ends end start

Input :

0095h

Output:

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

21

THIS PROGRAM IS FOR THE CONVERSION OF BCD TO BINARY

Turbo urbo Ass Assemble mblerr Versi ersion on 2.51 .51 bcd2bin.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 0000 B8 0000s 0000s start: start:mov mov ax,dat ax,data a 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_inp input ;get bcd inp input 12 0013 E8 0004 call bcd_bin ;call bin procedure 13 0016 A2 0001r mov bin_value,a ;store resultl ltl 14 0019 CC int 03 ;stop 15 001A bcd_bin proc near ;save main program status 16 00 0 01A 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 00 0 02E 59 pop cx 28 002F 5B pop bx ;back to main program 29 00 0030 9D popf   30 00 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

22

4.STRING OPERATIONS AND INSTRUCTION PREFIX  String

transfer 

 Ascending  Inserting  Deleting  String

order 

character and spell checking

character 

comparision

23

THIS PROGRAM TRANSFERS A STRING OF CHARACTERS FROM ONE LOCATION TO ANOTHER

Turbo urbo Ass Assemble mblerr trfr_str.asm

Versi ersion on 2.51 .51

/*The data segment segment in the first_string is transferred to new new location a and in between it leaves 100 locations*/ 1 2 3 4 5 6 7 8

assume cs: code,ds: data,es:data 0000 0000 0003 0005 0007

9 000A 10 000D 11 0010 12 13 14 15 16 17 18

0011 00 0 013 0014

code segment B8 0000s 8E D8 8E C0 BE 0000r

start:mov ax,data mov ds,ax mov es,ax lea si,first_string ;declare source & destination BF 0068r lea di,new_loc ;pointers B9 001E mov cx,30 ;specify string length FC cld ;move the string from source to destination F3> A4 rep movsb CC int 03 code ends ;stop

0000 data segment 0000 0000 72 61 76 69 firs first_ t_st stri ring ng db 'rav 'ravi'i' 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

24

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

Turbo urbo Ass Assemble mblerr bubsrt.asm

Versi ersion on 2.51 .51

/*The data segment in the list are arranged in ascending order */ 1 2 3 4 5 6 7 8 9 10 11 12

assume cs: code,ds: data,es:data 0000

code segment

0000 0003 0005 0005 0009 0009 000B 000B 000E 000E 0010 0013 0013

B8 0000s start: mov ax,data 8E D8 mov ds,ax B2 04 90 90 mov mov dl,c dl,cou ount nt-1 -1 ;init ;initia ialis lise e coun counte ter  r  8A CA agai again1 n1:: mov mov cl,d cl,dll BE 0000r 000r mov mov si,of i,offs fset et lis list ;ge ;get offs offset et addre ddress ss 8A 04 again2 again2:: mov al,[si al,[si]] ;getsm ;getsmall allno. no.in1 in1stl stloc ocati ation on 3A 44 01 cmp al,[si+1] 77 05 jb ahea ahead d ;com ;compa pare res s till till the the end end of  array 13 0015 86 44 01 xchg [si+1],al 14 001 0018 86 04 xchg chg [si] [si],a ,all 15 001A 001A 83 C6 01 ahead head:: add add si,0 i,01 ;bri ;bring ng small mall no.s o.s into 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 00 0005 data ends 29 30 end start Input :

34h,50h,78h,81h,12h

Output:

12h,34h,50h,78h,81h

25

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

Turbo urbo Ass Assemble mblerr Versi ersion on 2.51 .51 miscr.asm /*The data segment in the array1 is compared with data segment array and correct the misspelt word*/ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 Input:

assume cs: code,ds: data 0000 0000 0003 0005 0007 000A 000E 0011 0012 0014 0016 0019 001B 001C 001C 001D 001E 001F 0020 0021 0023 0025 0026 0027 0029 00 0 02B 00 0 02C 00 0 02D 00 002E 002F

code segment B8 0000s start:mov ax,data 8E D8 mov ds,ax 8E C0 mov es,ax BE BE 0000r lea si,array ;get the right word B9 0005 90 mov cx,num BF BF 0005r lea di,array1 ;compare the right word FC l2: cld ;the word to be corrected F3> A6 repe cmpsb E3 05 jcxz l1 E8 0003 call procedure ;call procedure EB F6 jmp l2 ;if mismatch found CC l1: int 03h 57 proced procedure ure:: push push di 51 push cx ;insert the character  56 push si 4E dec si 4F dec di 8A 04 mov al,[si] 86 05 l3: xchg al,[di] 47 inc di 49 dec cx 75 FA jnz l3 88 05 mov byte ptr[di],al ;make final byte 0 5E pop si 59 pop cx 5F pop di C3 ret code ends

0000 data segment 0000 6B 69 72 61 6E array db 'kiran' = 0005 num equ ($-array) 0005 0005 6E 6B 72 69 arra array y1 db 'nkr 'nkri'i' 0009 data ends end start ; stop mispelt word is ‘nkri’ Output: Correct word is ‘kiran’

26

THIS PROGRAM DELETES SPECIFIED CHARACTER FROM STRING

Turbo urbo Ass Assemble mblerr Versi ersion on 2.51 .51 del_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 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,a i,arra rray1 ;get the strin ring 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 3A 04 l2:cmp al,[si] ;find the character to be deleted 12 00 0012 75 06 jne l1 13 0014 E8 0008 call procedure ;call the delete procedure 14 0017 49 dec cx 15 00 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 C6 05 00 mov byte ptr[di],00h ;m ;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 0000 65 6C 65 6D 65 6E 74 arra array1 y1 db 'elem 'element ent'' ;string ;string 36 = 0007 num equ ($-array1) 37 0007 data ends 38 end start Input :

element

Output:

lmnt

27

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

Turbo urbo Ass Assemble mblerr Versi ersion on 2.51 .51 cmpr2str.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 000 0000 B8 0000 0000s s star start: t: mov mov ax,dat ,data a ;in ;initia itiali lise se the the segmen gments ts 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 000D B9 000E 000E 90 mov mov cx,s cx,str tr_l _len engt gth h 11 00 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 00 001D ok: 20 001D B8 00FF mov ax,00ffh ;display 00 if equal 21 0020 CC int 03h 22 0021 code ends 23 24 00 0 000 data segment 25 0000 0000 6D 69 63 72 6F 70 72+ first_s first_strin tring g db'm db'micr icropr oproc ocess essor' or';de ;decla clare2 re2 strings 26 6F 63 65 73 73 6F 72 27 = 000E str_length equ($first_string);specify length of string 28 000E 000E 6D 69 63 72 6F 70 72+ secon second_s d_strin tring g db 'micro 'micropro proces cessor sor'' 29 6F 63 65 73 73 6F 72 30 00 001C data ends 31 end start Input:

first string’ MICROPROCESSOR' second string 'MICROPROCESSOR'

Output:

00FF i.e, string is equal.

28

6.DOS/BIOS PROGRAMMING  Reading

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

29

THIS PROGRAM READS CHARACTER FROM KEY BOARD AND DISPLAYS THE PRESSED KEY

Turbo Assembler cons.asm

Version 2.51

10/11/07 14:09:15

Page 1

/*The data segment in the mesg1rreads the character from the keyboard and the same character displayed on the mesg2*/ 1 assu assume me cs:c cs:cod ode, e,ds ds:d :dat ata a 2 0000 code segment 3 0000 B8 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 00 0 00A CD 21 int 21h 8 000C B4 01 mov ah,01h ;read character   9 00 0 00E 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 B9 FFFF again1:mov cx,0ffffh 13 00 0019 90 again2:nop 14 001A 90 nop 15 001B 49 dec cx 16 00 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 00 0 02E 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 'typ type any key:$';msg msgs in dat data seg. 30 79 20 6B 65 79 3A 24 31 000E 74 79 70 65 64 20 6B+ mes mesg2 db 'typed key 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

30

II.INTERFACING

31

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

a) To disp display lay the the puls pulse e count counter. er. b) To deriv derive e the freq frequen uency cy count counter. er. APPARATUS:

1. ESA 86/8886/88-2 2 Micro Micropro proces cessor sor kit. kit. 2. Func Functi tion on gene genera rato tor. r. 3. Conn Connec ectin ting g wire wires. s. THEORY:

The Processor 8085 had had five hardware interrupt 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 will have to take the care of priorities for the interrupts, simultaneously simultaneously occurring at the interrupt request pins to overcome overcome all this difficults ,we ,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 = FFF4 Data Port Address = FFF6

32

8259INTERFACING

33

PROGRAM:

PULSE COUNTER Main program:

Memor  y address 2000 2006 200C 2012 2015 2017 2018 201B 201D 201E 2020 2021 2023 2024 2025

Op codes C7,06,00,30,00,0 0 C7,06,20,01,50,2 0 C7,06,22,01,00,0 0 BA,F4,FF B0,13 EE BA,F6,FF B0,48 EE B0,03 EE B0,FE EE FB EB,FE

labels Mnemonics Operands

L1:

MOV MOV MOV MOV MOV OUT MOV MOV OUT MOV OUT MOV OUT STI JMP

Comments

[3000],0000H [0120],2050H [0122],0000H DX,FFF4H  AL,13H DX,AL DX,FFF6H  AL,48H DX,AL  AL,03H DX,AL  AL,FEH DX,AL L1

;Initial cnt.0 ; ISR addr .in INT vector  location. ;Initialize 8259 in edge triggered inte interru rrupt pt , 8086 processor, automatic end of   inte interru rrupt pt , interrupt no. 0 ; Keep monitoring the interrupt.

Delay subroutine:

Memory address 2050 2053 2055 2056 2059 205E

Op codes  A1,00,30 04,01 27  A3,00,30 9A,0A,0B,00,FF CF

labels Mnemonics Operands MOV  ADD DAA MOV CALL IRET

 AX,[3000]  AL,01H

Comments ; Inc Increme rement nt the the coun ounter  ter  by 1.

[3000],AX FF00:0B0A ;Display count ; Back main.

to

34

35

FREQUENCY COUNTER Main program:

Memor  y address 2000 2006 200C 2012 2015 2017 2018 201B 201D 201E 2020 2021 2023 2024 2025 2028 202B 202C 202D 202F 2030 2032 2037

Op codes

labels Mnemonics Operands

C7,06,00,30,00,0 0 C7,06,20,01,50,2 0 C7,06,22,01,00,0 0 BA,F4,FF B0,13 EE BA,F6,FF B0,48 EE B0,03 EE B0,FE EE FB BB,0C,00 B9,02,63 90 49 75,FC 4B 75,F6 9A,0A,0B,00,FF EB,FE

L2: L1:

L3:

MOV MOV MOV MOV MOV OUT MOV MOV OUT MOV OUT MOV OUT STI MOV MOV NOP DEC JNZ DEC JNZ CALL JMP

Comments

[3000],0000H [0120],2050H [0122],0000H DX,FFF4H  AL,13H DX,AL DX,FFF6H  AL,48H DX,AL  AL,03H DX,AL  AL,FEH DX,AL BX,000CH CX,6302H CX L1 BX L2 FF00:0B0A L3

;Initial cnt.0 ; ISR adder .in INT vector  location. ;Initialize 8259 in edge triggered inte interru rrupt pt , 8086 processor, automatic end of   inte interru rrupt pt , interrupt no. 0 ;Activate interrupt ; Initi Initial aliz ize e counters for 1 sec delay. ; Wait for  1sec. ; Display the frequency value.

Interrupt service subroutine:

Memory Op codes address 2050  A1,00,30 2053 04,01 2055 27 2056  A3,00,30

labels Mnemonics Operands MOV  ADD DAA MOV

 AX,[3000]  AL,01H [3000],AX

Comments ;Count pulses

the

36

2059

CF

IRET

; Back to main.

RESULT:

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

1. Which Which initiali initialisat sation ion command command word word indica indicates tes whethe whetherr PIC is being being used in single or cascaded mode? 2. What What is meant meant by handsh handshaki aking ng? ? 3. Expla Explain in IRET IRET instru instructi ction? on? 4. In the PIC PIC which which registers registers is is used used to mask mask the interrup interrupts? ts? 5. What are are the total total numbers numbers of interrupts interrupts availa available ble if all the the 8-inputs 8-inputs of PIC are are having slave? 6. What What is MACR MACRO? O? 7. What What are are the the flags flags of 8086? 8086? 8. Which pin is used to distinguish the minimum mode and maximum mode?

37

38

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 Perfor Performed med by the contro controlle llerr in repeti repetitiv tive e fashio fashion n with with out involv involving ing the Cup-Ti Cup-Tie e 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 of  64 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 any FIFO FIFO read read oper operat atio ion n the the over overru run n stat status us is set. set. The The 8279 8279 is norm normal ally ly prov provid ides es maximum of sixteen 7 segment Display interface with CPU. PORT ADDRESSES OF 8279

Control word register = FFEB Data Port Address = FFE9 8279A Interfacing:

8086

8279

7-seg display

39

8279 INTERNAL ARCHITECTURE

PROGRAM: To display string of characters

Memory Op codes address 2000 BA,EB,FF 2003 B0,00 2005 EE 2006 B0,38 2008 EE 2009 B0,90 200B EE 200C BE,00,30 200F B9,LENGTH 2012 BA,E9,FF 2015 8A,04 2017 EE 2018 46 2019 49 201A 75,F9 201C EB,FE

labels Mnemonics Operands

L1:

L2:

MOV MOV OUT MOV OUT MOV OUT MOV MOV MOV MOV OUT INC DEC JNZ JMP

DX,FFEBH  AL,00H DX,AL  AL,38H DX,AL  AL,90H DX,AL SI,3000H CX,LENGTH DX,FFE9H  AL,[SI] DX,AL SI CX L1 L2

Comments ; Initialize 8279 in encoded scan key keypad pad 2key 2key lock out,8char  display left entry. ;Select display position 0 ;Display the string of   characters

40

RESULT:

 A character is displayed at 0 position position of the display.  A string characters is displayed 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 perform input input from keyboard? keyboard? 2. A keyboard keyboard is made made using using 12 keys keys connec connected ted not as as a matrix. matrix. How many pins pins of the I/O port are used? 3. Write Write a 7–seg 7–segmen mentt code code for for ‘B’? ‘B’? 4. In the single single characte characterr display using interru interrupt pt 21H, DL is the the register register contains contains character to display. If DL contains 41H, which character is displayed? 5. What is the difference difference between between CALL CALL and and JMP? JMP? 6. What What is is the the purpos purpose e of of ALE? ALE? 7. What are are the difference difference betwee between n microproces microprocessor sor and micro micro controller? controller?

41

42

3.8255- PROGRAMMABLE PERIPHERAL INTERFACE (PPI) AIM:

To generate sine wave. APPARATUS:

1. ESA 86/8886/88-2 2 Micro Micropro proces cessor sor kit. kit. 2. C.R.O. 3. Stepper motor interface module with stepper motor. 4. F R C Cable. le. 5. Power supply- +15v. THEORY:

The parallel input-output port chip 8255 is also called as Programmable peripheral input-output Port. 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 l ines .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 8bit Port and other sub group of 4 I/O lines are a 4-bit port. Thus GROUP A Contains 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 lines PB0-PB7 and a 4-bit 4-bit port port C with lower bits bits PC0-PC3 .The port C upper and port C lowe lowerr can can be used used in recom recombi bina nati tion on as an 8-bi 8-bitt port port-C -C .Both .Both the the port port Cs are are assigned the same address. Thus one may have either  Three 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 Port A Port B Port AC

= FFE7 = FFE1 = FFE3 = FFE5

Block diagram of 8255 Interfacing

Micro processor 8086

8255 PPI

Stepper motor inter face

43

Block diagram of 8255 programmable peripheral interface:

BIDIRECTIOAL DATA BUS BUFFER 

Group A Port A (8)

+5V

POWER  SUPPLIES

Group A control

GND

I/O PA7-PA0

Group A Port C upper  (4)

8 bit internal bus

I/O PC7-PC4

DATA BUS BUFFER 

D7--D0 Group B Port C lower  (4)

__  RD __  WR 

A0 RESET

Group B Port B (8)

Group B control

A1

Read/ write Control logic

I/O PC3-PC0

I/O PB7-PB0

__  CS

Generation of a Sine Waveform:

8086 MICRO PROCESSOR 

8255 PPI

8-BIT DAC

CRO

44

Program:

Memory address 2000 2002 2005 2006 2009 200C 2010 2012 2013 2014 2015 2017

Op codes

labels

Mnemonics Operands

B0,80 BA,E7,FF EE BA,E1,FF B9, 22,00 8B,36,00,30 8A,04 EE 46 49 75,F9 EB,F0

MOV MOV OUT MOV BACK: MOV MOV L1: MOV OUT INC DEC JNZ JMP

 AL,80H DX,FFE7H DX DX,FFE1H CX,22H SI,[3000H]  AL,[SI] DX SI CX L1 BACK

Comments ;Initialize 8255 all ports o/p ;Keep on writing the sine sine wave wave co ordi ordina nate te data data values to port  A

Lookup table:

Memory address 3000

Corresponding values 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 wave are measured. Stepper motor is rotated. VIVA QUESTIONS:

1. Give Give the the BSR BSR forma format? t? 2. What is the angle of a stepper motor in full step mode? 3. 8255 8255 has has how how man many y pins pins? ? 4. If the Contro Controll word word 09bH 09bH is given given to cont contro roll regi regist ster er of the the 8255 8255 ppi then 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 8255 is is used used for which which of the the I/O method methods? s? 7. 8255 8255 has has how how man many y por ports ts? ? 8. What What are the the applic applicatio ations ns of the the ports? ports? 9. Why we need need inter interfac facing ing devi devices ces? ?

45

46

4.82514.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 transmissi transmission. on. It is able able to receive receive a serial serial stream stream of bits bits and conver convertt in to parallel 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)

Halfalf-d duple uplex x

In simp simplex lex mode mode data data is tran transm smitt itted ed only only in one one dire direct ctio ion n over over a Sing Single le 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 ma y be transmitted only in one direction. PORT ADDRESSES OF 8279

Control word register = FFF2 Data Port Address 8251A Interfacing

= FFF0

47

TRANSMIT BUFFER  (P—S)

D7-D0

TxD

DATA BUS BUFFER  I TxRdy

 N RESET

T

CLK  C/D  __  RD  __  WR   __  CS  ___  DSR   __  DTR   __  CTS  __  RTS

TRANSMIT CONTROL

E READ/ WRITE CONTROL LOGIC

TxEMPT TxC

R   N A L

RECEIVER  BUFFER  (S—P)

RxD

B U MODEM CONTROL

S

RECEIVE CONTROL

FUNCTIONAL FUNCTIONAL BLOCK DIAGRAM DIAGRAM OF 8251 USART

RxRdy  ___  RxC SYNDET/ BRKDET

48

PROGRAM: Transmitter 

Memory Op codes address 2000 BA,F2,FF 2003 B0,00 2005 EE 2006 B9,02,00 2009 E2,FE 200B EE 200C B9,02,00 200F E2,FE 2011 EE 2012 B9,02,00 2015 E2,FE 2017 B0,40 2019 EE 201A B9,02,00 201D E2,FE 201F B0,CE 2021 EE 2022 B9,02,00 2025 E2,FE 2027 B0,37 2029 EE 202A B9,0A,00 202D BE,00,30 2030 BA,F2,FF 2033 EC 2034 24,81 2036 3C,81 2028 75,F9 203A BA,F0,FF 203D 8A,04 203F EE 2040 46 2041 49 2042 75,EC 2044 CC

labels Mnemonics Operands

L1: L2: L3:

L4:

L5:

L7: L6:

MOV MOV OUT MOV LOOP OUT MOV LOOP OUT MOV LOOP MOV OUT MOV LOOP MOV OUT MOV LOOP MOV OUT MOV MOV MOV IN  AND CMP JNZ MOV MOV OUT INC DEC JNZ INT

DX,FFF2H  AL,00H DX,AL CX,0002H L1 DX,AL CX,0002H L2 DX,AL CX,0002H L3  AL,40H DX,AL CX,0002H L4  AL,CEH DX,AL CX,0002H L5  AL,37H EE CX,000AH SI,3000H DX,FFF2H  AL,DX  AL,81H  AL,81H L6 DX,FFF0H  AL,[SI] DX,AL SI CX L7 03

Comments ; Soft ware reset 8251.

;act ;activ ivat ate e both both Txer Txer and and Rxer  Rxer  with communication parameters b.r.f  16,c 16,cha harr leng length th 8,no stop bits,2 start bits, no parity. ;transmitting block length 10, start addr.3000 ;wait for Txer  ready ;transmit the tota totall block lock on polling basis

49

Recei ec eiver  ver 

Memory Op codes address 2000 BA,F2,FF 2003 B0,00 2005 EE 2006 B9,02,00 2009 E2,FE 200B EE 200C B9,02,00 200F E2,FE 2011 EE 2012 B9,02,00 2015 E2,FE 2017 B0,40 2019 EE 201A B9,02,00 201D E2,FE 201F B0,CE 2021 EE 2022 B9,02,00 2025 E2,FE 2027 B0,37 2029 EE 202A B9,0A,00 202D BE,00,30 2030 BA,F2,FF 2033 EC 2034 24,81 2036 75,FB 2038 BA,F0,FF 203B 8A,04 203D EE 203F 46 2040 49 2041 75,EE 2042 CC

labels Mnemonics Operands

L1: L2: L3:

L4:

L5:

L7: L6:

MOV MOV OUT MOV LOOP OUT MOV LOOP OUT MOV LOOP MOV OUT MOV LOOP MOV OUT MOV LOOP MOV OUT MOV MOV MOV IN  AND JNZ MOV MOV OUT INC DEC JNZ INT

DX,FFF2H  AL,00H DX,AL CX,0002H L1 DX,AL CX,0002H L2 DX,AL CX,0002H L3  AL,40H DX,AL CX,0002H L4  AL,CEH DX,AL CX,0002H L5  AL,37H EE CX,000AH SI,3000H DX,FFF2H  AL,DX  AL,02H L6 DX,FFF0H  AL,[SI] DX,AL SI CX L7 03

Comments ;softw ;software are reset reset 8251.

; acti activa vate te both both Txer Txer and and Rxer  Rxer  with communication parameters b.r.f  16, char length 8, no stop bits, 2 start bits, no parity. ;receiving ;receiving block block length 10, start addr.3000 ;wai ;waitt for for Rear  ear  ready ;receive the tota totall block lock on polling basis

50

RESULT:

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

1. What signal signal is is used to receiv receive e serial data data by the the DTE from from the DCE? DCE? 2. What is is device device from which which data origina originate te s or termina terminates? tes? 3. What are the data transmissio transmission n techniq techniques? ues? 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 What is the full full form form of of USART USART? ? 8. Which parameter is set by using bits S1 and S2?

51

52

III.MICRO CONTROLLER 8051

53

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 using the On-chip serial 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. INT INTERRU ERRUP PTS: TS: EXTERN EXTERNAL: AL: INTERNAL:

INT is used used for implem implement enting ing single single stepping stepping and user’s user’s break break switching is available to user. 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 enha enhanc nce e dev develop elopme ment nt work. ork. This This ass assembl embler er supp suppor orts ts the the enti entire re stan standa dard rd 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 displayed on the screen. C Compare a block block of memory with destination block Function: Compare command can be used to compare the contents of one memory block with The 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.

54

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 usef useful ul debu debugg ggin ing g tool tool.. Prov Provis isio ion n has has been been made made for for sing single le step steppi ping ng with ith disassembly. S Single step command with disassembly: Function: This command is used to single step a program with disassembly. The register content Will 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.

55

PORT0 DRIVER 

RAM ADDR  REGISTER 

B REGISTER 

PORT2 DRIVER 

PORT0 LATCH

RAM

ACC

PORT2 LATCH

ROM

PROGRAM ADDR  REGISTER 

STACK  POINTER 

C

TMP1

BUFFER 

TMP2 ALU

PC INCREMENT PSW INTERRUPT, SERIEL PORTAND TIMER BLOCKS

PROGRAM COUNTER 

DPTR  TIMING AND CONTROL

INSTRUCTIO  N REGISTER  PORT1

OSCILLAT OR  PORT1 DRIVERS

DRIVER 

PORT3 LATCH

PORT3 DRIVERS

56

1. ARITH ARITHMA MATIC TIC OPERA OPERATION TIONS S 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 8051 is an 8 bit bit Micr Microc ocon ontro trolle llerr whic which h a Micr Microp oproc roces esso sorr with 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 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. Memor  Op codes y address

labels Mnemonics Operands

8000

12,03,BB

LCALL

03BB

8003

C2,D5

CLR

D5

8005

90,80,0E

MOV

DPTR,#800E

8008

12,03,2A

LCALL

0348h

800B

02,80,0B

LJMP

800E

45,53,41,20,50

8013

56,54,20,4C,54

STG DB ‘ESA PVT LTD’

8018

44,2E,00

800B

Comments

To select the Program memory

Out Out rout routin ine e 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

57

AIM: By using 8051 microcontroller 

a) b) c) d)

To perfo perform rm addit addition ion of of two numb numbers ers To perform perform subtractio subtraction n of two numbers numbers To perfo perform rm multip multiplic licati ation on of two two numbers numbers To perfo perform rm divis division ion of of two numb numbers ers

APPARATUS:

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

The The 8051 8051 is an 8-bi 8-bitt Micr Microc ocon ontr trol olle lerr desi design gned ed by Inte Intel. l. It was 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 desired ADDITION

Memory Op codes address

labels Mnemonics Operands

Comments

8000

90,90,00

MOV

8003

E0

MOVX

8004

E5,0B

MOV

DPTR,#9000H Keep data in 9000h and  A,@DPTR 9001h;data memory B,A

8006

 A3

INC

DPTR

8007

 A0

MOVX

 A,@DPTR

8008

25,0B

 ADD

 A,B

800A

 A3

INC

DPTR

800B

F0

MOVX

@DPTR,A

800C

02,00,00

LJMP

0

INPUT:

9000-05H 9001-02H

OUTPUT:

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

9002-0AH

58

SUBTRACTION

Memory Op codes address

labels Mnemonics Operands

Comments

8000

90,90,00

MOV

8003

E0

MOVX

8004

E5,0B

MOV

DPTR,#9000H Keep data in 9000h and  A,@DPTR 9001h;data memory B,A

8006

 A3

INC

DPTR

8007

 A0

MOVX

 A,@DPTR

8008

95,0B

SUBB

 A,B

800A

 A3

INC

DPTR

800B

F0

MOVX

@DPTR,A

800C

02,00,00

LJMP

0

INPUT:

9000-06H 9001-02H

OUT PUT: 04H

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

59

MULTIPLICATION

Memory Op codes address

labels Mnemonics Operands

Comments

8000

90,90,01

MOV

8003

E0

MOVX

8004

F5,F0

MOV

DPTR,#90001H Keep data in 9000h and  A,@DPTR 9001h;data memory 0F0H,A

8006

90,90,00

MOV

DPTR,#9000H

8009

E0

MOVX

 A,@DPTR

800A

 A4

MUL

 AB

800B

90,90,02

MOV

DPTR,#9002H

800E

F0

MOVX

@DPTR,A

800F

 A3

INC

DPTR

8010

E6,F0

MOV

 A,OFOH

8012

F0

MOVX

@DPTR,A

8013

02,00,00

LJMP

0

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

INPUT:

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

60

DIVISION

Memory Op codes address 8000

labels Mnemonics Operands

Comments

90,90,01

MOV

8003

E0

. MOVX

DPTR,#90001H Keep data in 9000 000h and and 9001h;data  A,@DPTR memory

8004

F5,F0

MOV

0F0H,A

8006

16,82

DEC

82H

8008

E0

MOVX

 A,@DPTR

8009

84

DIV

 AB

800A

90,90,02

MOV

DPTR,#9002H

800D

F0

MOVX

@DPTR,A

800E

 A3

INC

DPTR

800F

E6,F0

MOV

 A,OFOH

8011

F0

MOVX

@DPTR,A

8012

02,00,00

LJMP

0

INPUT:

9000-04H 9001-05H

OUTPUT:

9002-01H

Perform division operation Store the result in 9002 002h and 9003 9003h h of data data memory.

RESULT: Hence arithmetic operations like addition, subtraction, multiplication and

division are performed on 8051 Microcontroller.

61

2. TIMER IN DIFFEREN DIFF ERENT T MODES MODE S AIM: To generate a square wave with frequency using Timer 0 and Interrupts APPARATUS:

1. 2. 3. 4.

Micr Microc ocon ontro trolle llerr kit kit Cathod Cathode e ray oscillo oscillosco scope pe Keyboard CRO pr 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 includ including ing A and B regist registers ers.. There There is total total number number of 21-bit 21-bit addres addressab sable le 8-bit 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

8000

75,89,01

MOV

8003

75,8C,F0

MOV

8004

75,8A,FF

MOV

8006

11,20

labels Mnemonics Operands

 ACALL

Comments

TMOD Initialize timer 0 89,#01 In mode mode 1,16 1,16-bit count TL1 8A,#0F0 reg.mode TH1 8C,#0FF Introduce delay

8007 8008

80,FE 53,41,20

CPL SJMP

8020 95 8003

Keep complimenting port 1,5-bit To get get squa square re wave

62

DELAY PROGRAM:

Memory address

Op codes

8020

D2,8C

labels Mnemonics Operands

800

Comments

SETB

8C

Start the timer 

JNB

8D,8022

Wait Wait for for dela delay y time Reset timer 

8004

C2,8C

CLR

8C

8006

C2, 8D

CLR

8D

8007

22

RET

Reset timer  over flow flag

MAIN PROGRAM:

Memory address

Op codes

labels Mnemonics Operands

8000

75,89,02

MOV

89,#02

800

75,A8,82

MOV

0A8,#82

8004

75,8C,F0

MOV

8C,#0F0

8006

D2,8C

SETB

8C

8007

80,0B

SJMP

800B

Comments Initia Initializ lize e timer  timer  0 in mode 2, Dec Declare lare TF 0 as an interrupt Load timer   count reg.TL1 Start the timer  Keep monitor monitoring ing the interrupt

INTERRUPT SERVICE ROUTINE:

Memory address

Op codes

labels Mnemonics Operands

FFF1

B2,95

CPL

FFF2

32

RETI

95

Comments Generate a square wave ave on interrupt basis

63

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=132 period=1/7.56msec=132Hz Hz 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.

64

EXPERIMENTS OTHER THAN JNTU SYLLABUS

65

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 Perfor Performed med by the contro controlle llerr in repeti repetitiv tive e fashio fashion n with with out involv involving ing the Cup-Ti Cup-Tie e 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 of  64 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 any FIFO FIFO read read oper operat atio ion n the the over overru run n stat status us is set. set. The The 8279 8279 is norm normal ally ly prov provid ides es maximum of sixteen 7 segment Display interface with CPU. PORT ADDRESSES OF 8279

Control word register = FFEB Data Port Address = FFE9

8279A Interfacing:

8086

8279

7-seg display

66

8279 INTERNAL ARCHITECTURE

PROGRAM:

To display single character 

Memory address 2000 2003 2005 2006 2008 2009 200B 200C 200F 2011 2012

Op codes BA,EB,FF B0,00 EE B0,38 EE B0,90 EE BA,E9,FF B0,CHAR EE EB,FE

labels Mnemonics Operands

L1:

MOV MOV OUT MOV OUT MOV OUT MOV MOV OUT JMP

DX,FFEBH  AL,00H DX,AL  AL,38H DX,AL  AL,90H DX,AL DX,FFE9H  AL,CHAR DX,AL L1

Comments ; Initialize 8279 in encoded sca scan keypa eypad d 2key 2key lock lock out, out, 8cha 8charr disp displa lay y left entry. ;Select ;Select display display position 0 ;Display the character 

67

To read the character and display

Memory address 2000 2003 2005 2006 2008 2009 200C 200D 200F 2011 2013 2014 2017 2018 201B 201D 201F 2022 2024 2025 2028 202A 202B

Op codes BA,EB,FF B0,00 EE B0,38 EE BA,EB,FF EC 24,07 74,F8 B0,40 EE BA,E9,FF EC BE,00,40 B4,00 0B,F0 BA,EB,FF B0,90 EE BA,E9,FF 8A,04 EE EB,DC

labels Mnemonics Operands

L1:

MOV MOV OUT MOV OUT MOV IN  AND JZ MOV OUT MOV IN MOV MOV OR MOV MOV OUT MOV MOV OUT JMP

DX,FFEBH  AL,00H DX,AL  AL,38H DX,AL DX,FFEBH  AL,DX  AL,07 L1  AL,40H DX,AL DX,FFE9H EC SI,4000H  AH,00H SI,AX DX,FFEBH  AL,90H DX,AL DX,FFE9H  AL,[SI] DX,AL L1

Comments ;Initialize ;Initialize 8279 in encoded scan can keypa eypad d 2key lock out,8char  display left entry. ; scan the key boar board d for for key key press. ;read the character  ; get the address of the character  code. ;Select ;Select display display position 0 ;Display the key no. pressed ; wait for next key.

RESULT:

 A character is displayed at 0 position position of the display.  A string characters is displayed 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 perform input input from keyboard? keyboard? 9. A keyboard keyboard is made made using using 12 keys keys connec connected ted not as as a matrix. matrix. How many pins 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?

68

69

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-output Port. 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 l ines .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 8bit Port and other sub group of 4 I/O lines are a 4-bit port. Thus GROUP A Contains 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 lines PB0-PB7 and a 4-bit 4-bit port port C with lower bits bits PC0-PC3 .The port C upper and port C lowe lowerr can can be used used in recom recombi bina nati tion on as an 8-bi 8-bitt port port-C -C .Both .Both the the port port Cs are are assigned the same address. Thus one may have either  Three 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 Port A Port B Port AC

= FFE7 = FFE1 = FFE3 = FFE5

Block diagram of 8255 Interfacing

Micro processor 8086

8255 PPI

Stepper motor inter face

70

Block diagram of 8255 programmable peripheral interface:

+5V

POWER  SUPPLIES

BIDIRECTIOAL DATA BUS BUFFER 

GND

Group A control

8 bit internal bus

Group A Port A (8)

Group A Port C upper  (4)

I/O PA7-PA0

I/O PC7-PC4

DATA BUS BUFFER 

D7--D0 Group B Port C lower  (4)

__  RD __  WR  A1 A0 RESET

__  CS

Read/ write Control logic

Group B control

Group B Port B (8)

I/O PC3-PC0

I/O PB7-PB0

71

SQUARE WAVE GENERATION PROGRAM: Main program:

Memory address 2000 2003 2005 2006 2009 200B 200C 200F 2011

Op codes BA,E7,FF B0,80 EE BA,E1,FF B0,FF EE E8,11,00 F6,D0 EB,F8

labels Mnemonics Operands

L1:

MOV MOV OUT MOV MOV OUT CALL NOT JMP

DX,FFE7H  AL,80H DX,AL DX,FFE1H  AL,FFH DX,AL DELAY  AL L1

Comments ;Initia ;Initialize lize 8255 8255 all ports o/p ;Make port a high ;Wait for on/off  Compliment port A continuously

Delay subroutine:

Memory address 2020 2023 2026 2027 2028 202A 202B 202D

Op codes BB,01,00 B9,99,00 90 49 75,FC 4B 75,F6 C3

labels Mnemonics Operands L3: L2:

MOV MOV NOP DEC JNZ DEC JNZ RET

BX,0001H CX,0099H CX L2 BX L3

Comments ;Ini ;Initi tial aliz ize e counters delay

the the for 

;Wai Wait for 0.5 ms.

72

STEPPER MOTOR PROGRAM: Main program:

Memory address 2000 2003 2005 2006 2009 200B 200C

Op codes BA,E7,FF B0,80 EE BA,E1,FF B0,FF EE E8,11,00

200F 2011

D0,C8/C0 EB,F8

labels Mnemonics Operands

L1:

MOV MOV OUT MOV MOV OUT CALL

DX,FFE7H  AL,80H DX,AL DX,FFE1H  AL,88H DX,AL DELAY

ROR/ROL JMP

 AL L1

Comments ;Initialize ;Initialize 8255 all ports o/p ; Start Start steppe stepper  r  motor in half  step mode. ;Wai ;W aitt for for step step time ;Rotate the step steppe perr moto motor  r  continuously

Delay subroutine:

Memory address 2020 2023 2026 2027 2028 202A 202B 202D

Op codes BB,0A,00 B9,02,5D 90 49 75,FC 4B 75,F6 C3

labels Mnemonics Operands L3: L2:

MOV MOV NOP DEC JNZ DEC JNZ RET

BX,000AH CX,5D02H CX L2 BX L3

Comments ;Ini ;Initi tial aliz ize e counters delay

the the for 

;Wait for 1 sec.

RESULT:

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

1. 2. 3. 4. 5. 6. 7. 8. 9.

Give Give the the BSR BSR forma format? t? What is is the angle angle of a stepper stepper motor motor in full full step step mode? mode? 8255 8255 has has how how man many y pins pins? ? If the Contro Controll word word 09bH 09bH is given given to cont contro roll regi regist ster er of the the 8255 8255 ppi then then explain what is the condition of ports? If the 8255 8255 is selected selected for addresse addresses s 0F800H-0F8 0F800H-0F806H 06H what what is the address address of  port C? Mode 1 of 8255 8255 is is used used for which which of the the I/O method methods? s? 8255 8255 has has how how man many y por ports ts? ? What What are the the applic applicatio ations ns of the the ports? ports? Why we need need inter interfac facing ing devi devices ces? ?

73

74

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 2000 2003 2004 2009 200C 200D 200F 2010

Op codes

labels Mnemonics Operands

B8,00,00 50 9A,0A,0B,00,FF E8,14,00 58 04,01 27 EB,F1

MOV L1: PUSH CALL CALL POP  ADD DAA JMP

 AX,0000H  AX FF00:0B0A DELAY  AX  AL,01H L1

Comments ; Get the 1st no. ; Display the no. ; Add 1 to previous no. ;Jump back

Delay subroutine:

Memory address 2020 2023 2026 2027 2028 202A 202B 202D

Op codes BB,0A,00 B9,02,5D 90 49 75,FC 4B 75,F6 C3

labels Mnemonics Operands L3: L2:

MOV MOV NOP DEC JNZ DEC JNZ RET

BX,000AH CX,5D02H CX L2 BX L3

Comments ;Ini ;Initi tial aliz ize e counters delay

the the for 

;Wait for 1 sec.

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

display.

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF