Microprocessors Lab Manual Original
Microprocessors Lab Manual Original
: : : :
Microprocessors and Interfacing Lab Ist Computer Science & Engineering. ________________________________ ________________________________
PROGRAMMERS
________________________________ ________________________________
Head CSE
Contents
Page No I II III
INDEX
SI.NO EXPERIME NT NO. NAME OF THE EXPERIMENT (CYCLE-1)
1. 1
PAGE NO
b) Subtraction of Two 16-bit Numbers c) Multiplication of Two 16-bit Numbers d) Division of Two 16-bit Numbers
Signed operations
7 7 a) Multiplication of Signed Numbers b) Division of Signed numbers
Logical operations
8 8 a) Conversion of packed BCD to unpacked BCD b) Conversion of packed BCD to ASCII sorting operations
Sorting Of Numbers
9 9 a) order b) order 10 10 a) b) To sort array in Ascending To sort array in Descending
String Operations
To Copy given String To Compare Two Strings
e) To insert new string into the given String f) To delete String from the given 6
Using DOS-BIOS Interrupts 11 11 a) b) To read aString from DOS Prompt To display String on the DOS Prompt
INTERFACING PROGRAMS
(CYCLE-2) 12 13 14 12 13 14 Interfacing with 8259 PIC Interfacing with 8255 PPI Interfacing with 8251 USART
Students can execute their assembly language programs using MASM. MASM is very useful students because when they execute their programs they can see contents of Processor Registers and how each instruction is being executed in the CPU. 1 Rational Rose Software is installed in some systems Using this software, students can depict UML diagrams of their projects. 2 Software installed : C, C++, JDK1.5, MASM, OFFICE-XP, J2EE and DOT NET, Rational Rose. 3 Systems are provided for students in the 1:1 ratio. 4 Systems are assigned numbers and same system is allotted for students when they do the lab.
10
To create and sustain an agile community which is highly professional with due consideration
for ethical, ecological and economical issues.
To impart quality education that serves the needs of present and to energize the technological
world. To forge mutually beneficial commitments with government, industry society and alumni. Commitment to learn, adopt and change as a means to perpetual development. To purse research and disseminate innovations to the society.
11
Introduction To Tasm
Steps for entering and proceed by using 8086 in TASM simulator 1: switch on your system 2: go for command prompt Check start menu in your desk top and select run then type command or cmd to go to the command prompt 3: type cd<space>TASM 4:c:\TASM >will be appeared on your screen 5: now type edit <space > filename.asm Eg:edit addition.asm 6:edit window will be appearing on the screen and type the whole program in that editior 7:save the program in the tasm directory or in any directory created by you ( file name should not be more than 8 characters) 8: press alt+f and x to exit from the editor 9: c:\tasm >will be appeared on screen .now type tasm<space>filename.asm(if there are any errors check the program correct then errors and then switch to the next command) C:\tasm>tlink<space>filename.obj C:\tasm>td<space>filename 10: finally output object file will be observed 11: now press f8 to compile the program and note down the required data
12
8-Bit Addition
Aim: To perform the addition of two 8 bit numbers Apparatus: Tasm software, pc Algorithm
Step1 : start Step2: initialize data segment Step3: move one variable data into al and move one variable data into bl Step4: add the contents of al and bl Step5: store the result in d3 variable Step6: stop
Source code
data segment d1 db 15h d2 db 82h d3 db ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov al,d1 mov bl,d2 add al,bl mov d3,al mov ah,4ch int 21h code ends end start
Result
The addition of two 8 bit numbers is completed successfully
13
8 Bit Subtraction
Aim: To perform the subtraction of two 8 bit numbers Apparatus: Tasm software, pc Algorithm
Step1 : start Step2: initialize data segment Step3: move one variable data into al and move one variable data into bl Step4: subtract the contents of bl and al Step5: store the result in d3 variable Step6: stop
Source code
data segment d1 db 02h d2 db 05h d3 db ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov al,d1 mov bl,d2 sub al,bl mov d3,al mov ah,4ch int 21h code ends end start
Result
The subtraction of two 8 bit numbers is completed successfully
14
8 Bit Multiplication
Aim: To perform the multiplication of two 8 bit numbers
Apparatus: Tasm software, pc
Algorithm
Step1 : start Step2: initialize data segment Step3: move one variable data into al and move one variable data into bl Step4: multiply the contents of al and bl Step5: store the result in d3 variable Step6: stop
Source code
data segment d1 db 02h d2 db 03h d3 dw ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov al,d1 mov bl,d2 mul bl mov d3,ax mov ah,4ch int 21h code ends end start
Result
Multiplication of two 8 bit numbers is completed successfully
15
8 Bit Division
Aim: To perform the division of two 8 bit numbers Apparatus: Tasm software, pc Algorithm
Step1 : start Step2: initialize data segment Step3: move one variable data into al and move one variable data into bl Step4:divide the contents of al by bl Step5: store the qutioent in d3 variable Step6: store the remainder in fourth variable Step7: stop
Source code
data segment d1 db 09h d2 db 02h quotient db ? remainder db ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov al,d1 mov bl,d2 mov ah,00h div bl mov quotient,al mov remainder,ah mov ah,4ch int 21h code ends end start
Result
The division of two 8 bit numbers is completed successfully
16
16-Bit Addition
Aim: To perform the addition of two 16 bit numbers Apparatus: Tasm software Algorithm
Step1 : start Step2: initialize data segment Step3: move one variable data into ax and move one variable data into bx Step4: add the contents of ax and bx Step5: store the result in d3 variable step6:stop
Source code
datasegment d1 dw 8000h d2 dw 8000h d3 dw ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov ax,d1 mov bx,d2 add ax,bx mov d3,ax adc ah,00h mov byte ptr d3+2,ah mov ah,4ch int 21h code ends end start
Result
The addition of two 16 bit numbers is completed successfully
17
16-Bit Subtraction
Aim: To perform the subtraction of two 16 bit numbers Apparatus: Tasm software Algorithm
Step1 : start Step2: initialize data segment Step3: move one variable data into ax and move one variable data into bx Step4: subtract the contents of bx from ax Step5: store the result in d3 variable step6:stop
Source code
data segment d1 dw 7000h d2 dw 8000h d3 dw ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov ax,d1 mov bx,d2 sub ax,bx mov d3,ax sbb ah,00h mov byte ptr d3+2,ah mov ah,4ch int 21h code ends end start
Result
The subtraction of two 16 bit numbers is completed successfully
18
16-Bit Multiplication
Aim : To perform the multiplication of two 16 bit numbers Apparatus: Tasm software Algorithm
Step1 : start Step2: initialize data segment Step3: move one variable data into ax and move one variable data into bx Step4: multiply the contents of ax and bx Step5: store the result in d3 and d3+2 locations step6:stop
Source code
data segment d1 dw 4000h d2 dw 2000h d3 dw ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov ax,d1 mov bx,d2 mul bx mov d3,ax mov d3+2,dx mov ah,4ch int 21h code ends end start
Result
The multiplication of two 16 bit numbers is completed successfully
19
16-Bit Division
Aim: To perform the division of two 16 bit numbers Apparatus: Tasm software Algorithm
Step1 : start Step2: initialize data segment Step3: move one variable data into ax and move one variable data into bx Step4: divide the contents of ax by bx Step5: store the qutioent in d3 variable step6:store the remainder in d4 variable step7: stop
Source code
data segment d1 dw 4000h d2 dw 2500h quotient dw ? remainder dw ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov ax,d1 mov bx,d2 div bx mov quotient,ax mov remainder,dx mov ah,4ch int 21h code ends end start
Result
The division of two 16 bit numbers is completed successfully
20
32-Bit Addition
AIM: To find the addition of two 32-bit numbers. APPARATUS: Tasm software ALGORITHM:
Step1: start Step2: Initialize the data segment Step3: load the effective address of d1 into si register and load the effective address of d2 at di register. Step4: Move the contents in si register to ax register and the contents of di register to bx register. Step5: Add the contents of ax and bx. Step6: Increment the contents of si register and di register two times. Step7: Move the contents in si register to cx register and move the contents in di register to dx register. Step8: Add the contents of cx and dx with carry. Step9: Load the effective address of d3 into si. Step10: move the contents of ax and cx register into si. Step11: Stop.
Source code
Data segment d1 dd 23416708h d2 dd 78912345h d3 dd ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax lea si,d1 lea di,d2 mov ax,[si] mov bx,[di] add ax,bx inc si inc si inc di inc di mov cx,[si] mov dx,[di] adc cx,dx lea si,d3 mov [si],ax inc si inc si
21
Microprocessors and Interfacing Lab mov [si],cx mov ah,4ch int 21h code ends end start
RESULT:
The addition of two 32-bit numbers is completed successfully.
22
32-Bit Subtraction
AIM: To find the SUBTRACTION of two 32-bit numbers. APPARATUS: Tasm software ALGORITHM:
Step1: start Step2: Initialize the data segment Step3: load the effective address of d1 into si register and load the effective address of d2 at di register. Step4: Move the contents in si register to ax register and the contents of di register to bx register. Step5: Subtract the contents of bx from ax. Step6: Increment the contents of si register and di register two times. Step7: Move the contents in si register to cx register and move the contents in di register to dx register. Step8: Subtract the contents of bx from ax with barrow. Step9: Load the effective address of d3 into si. Step10: move the contents of ax and cx register into si. Step11: Stop.
SOURCE CODE:
Data segment d1 dd 12344321h d2 dd 56788765h d3 dd ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax lea si,d1 lea di,d2 mov ax,[si] mov bx,[di] sub ax,bx inc si inc si inc di inc di mov cx,[si] mov dx,[di] sbb cx,dx lea si,d3 mov [si],ax inc si inc si
23
Microprocessors and Interfacing Lab mov [si],cx mov ah,4ch int 21h code ends end start
RESULT:
The subtraction of two 32-bit numbers is completed successfully.
24
Multibyte Addition
AIM: To perform multibyte addition operation APPARATUS: Tasm software ALGORITHM:
Step1: start Step2: Initialize the data segment Step3: load the effective address for the input variables and output variables with the help of si, di and bp respectively. Step4: clear the count. Step5: Assign a lable go Step6: Move contents of si into al step7: Increment si. Step8: Move the contents of di into bl. Step9: Increment di. Step10: add the contents al,bl along with carry. Step11: Move the result into bp. Step12: Increment bp Step13: Decrement count Step14: The loop will repeat until count=0. Step15: Stop.
SOURCE CODE:
Data segment d1 dq 2341670823416708h d2 dq 7891234578912345h d3 dq ? count equ 08h data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov cl,count lea si,d1 lea di,d2 lea bp,d3 clc go: mov al,[si] inc si mov bl,[di] inc di adc al,bl mov [bp],al inc bp
25
Microprocessors and Interfacing Lab dec cl jnz go mov ah,4ch int 21h code ends end start
RESULT:
The multibyte addition is completed successfully.
26
Average Fo N Numbers
AIM: To find the average of n numbers. APPARATUS: Tasm software ALGORITHM:
Step1: start Step2: Initialize the data segment Step3: load the effective address of si to array Step4: Assign a lable l. Step5: Add the contents of al and si register. Step6: jump to label l2 if carry is not generated. Step7: Increment ah and assign a lable l2. Step8: Increment the si and decrement the cl register. Step9: repeat from step4 until cl not equal to zero. Step10: divide the components of dx by a. Step11: Store the result in allocated memory location. Step12: Stop.
SOURCE CODE:
data segment array db 01h,11h,12h,99h,96h,02h,02h,02h count equ 08h avg dw ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax lea si,array mov cl,count mov bl,count xor ax,ax l1: add al,[si] jnc l2 inc ah l2: inc si dec cl jnz l1 div bl mov avg,ax mov ah,4ch int 21h code ends end start
27
RESULT:
The average of n numbers is completed successfully.
28
29
30
31
32
33
34
35
36
37
Microprocessors and Interfacing Lab RESULT: My output is same as the object file output. Therefore sorting of array in ascending order is successfully completed.
38
39
Microprocessors and Interfacing Lab RESULT: My output is same as the object file output. Therefore sorting of array in descending order is successfully completed.
40
41
Comparison Of Strings
AIM: To perform the comparison of two strings. APPARATUS: TASM Software,PC ALGORITHM: Step-1: Start Step-2: Initialize the data segment Step-3: Initialize two string variables in data segment Step-4:Calculate the length of the two strings. Step-5: Load the effective address of variables to SI,DI Step-6: Compare the lengths of two strings (a)if equal goto step-7. (b)if not equal goto step-7(b). Step-7: Repeatedly compare strings byte-by-byte until count reaches zero. (a) if equal store the result as 1111H (b) if not equal store result as 0FFFFH Step-8: Stop SOURCE CODE: data segment str1 db MPI$ strlen1 equ ($-str1) str2 db MPI$ strlen2 equ ($-str2) data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax lea si,str1 lea di,str2 mov cx,strlen1 mov dx,strlen2 cmp cx,dx jne NOTEQUAL cld rep cmpsb jne NOTEQUAL mov res,1111H jmp QUIT NOTEQUAL: mov res,0FFFFH QUIT: mov ah,4ch int 21h code ends end start RESULT: Thus two strings are compared .
42
Length Of String
AIM: To calculate the length of string. APPARATUS: TASM Software , PC ALGORITHM: Step-1: Start Step-2: Initialize the data segment Step-3: Initialize a string variable in data segment whose length is to be calculated. Step-4: Load the effective address of variables to SI,DI Step-5:Clear AX and BX registers. Step-6:Load the string to AX and checks for $. (a) If finds goto step-7 (b) If not increment BL register and take it as required length of string Step-7: Stop SOURCE CODE: data segment str1 db MPI$ length db ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax lea si,str1 xor ax,ax xor bx,bx BACK: lods str1 cmp al,$ je GO inc bl jmp BACK GO: mov length,bl mov ah,4ch int 21H code ends end start RESULT: Thus length of string is calculated .
43
Reverse Of String
AIM: To reverse the string. APPARATUS: TASM Software , PC ALGORITHM: Step-1: Start Step-2: Initialize the data segment Step-3: Initialize a string variable in data segment whose calculate its length. Step-4: Load the effective address of variable to SI. Step-5: Add string length to DI. Step-5:Clear AX register and move contents to AL. Step-6:Exchange the values of SI and DI and increment SI and decrement DI. Step-7: Repeat Step-6 until DI value should above or equal to SI. Step-8:Stop SOURCE CODE: data segment str1 db MPI$ strlen1 equ ($-str1) data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax xor ax,ax lea si,str1 add di,(strlen1-1) L1: mov al,[si] Xchg [di],al mov [si],al inc si dec di cmp di,si jae L1 mov ah,4ch int 21H code ends end start RESULT: Thus the given string is reversed.
44
String Insertion
AIM: To insert a sub string into the main string. APPARATUS: TASM Software , PC ALGORITHM: Step-1: Start Step-2: Initialize the data segment Step-3: Initialize a string variable str1 in data segment and calculate its length. Step-4: Initialize another string variable str2 Step-6: Load effective address of strt1 to SI and str2 to DI. Step-7:Move the length of string in str1 to CX until from where the insertion starts . Step-8:Move length of sub string which is to be inserted to DX Step-9:Read the sub string from DOS by using DOS-BIOS Interrupts. Step-10:Store the string in str2. Step-11:Move the remaining string from str1 to str2 Step-12:Stop SOURCE CODE: data segment str1 db MICROPROCESSORS$ strlen1 equ ($-str1) str2 db str1+20 data ends code segment assume cs:code,ds:data,es:data start: mov ax,data mov ds,ax mov es,ax lea si,str1 lea di,str2 mov cx,15 rep movsb mov dx,20 L1: mov ah,01h int 21H stos str2 dec dx jnz L1 mov cx,01h rep movsb mov ah,4ch int 21H code ends end start RESULT: Thus the string is inserted.
45
String Deletion
AIM: To delete a sub string into the main string. APPARATUS: TASM Software , PC ALGORITHM: Step-1: Start Step-2: Initialize the data segment Step-3: Initialize a string variables str1 and str2 in data segment and calculate its length. Step-4: Load effective address of strt1 to SI and str2 to DI. Step-5:Move the some length of string in str1 to CX . Step-6:Take count value to DX (which is the deleted string count) Step-7: Increment SI until DX becomes zero. Step-8: Move the remaining string from str1 to str2 Step-9:Stop SOURCE CODE: data segment str1 db MICROPROCESSORS AND INTERFACING $ strlen1 equ ($-str1) str2 db 35 dup(0) data ends code segment assume cs:code,ds:data,es:data start: mov ax,data mov ds,ax mov es,ax lea si,str1 lea di,str2 mov cx,15 rep movsb mov dx,04 L1: inc si dec dx jnz L1 mov cx,13 rep movsb mov ah,4ch int 21H code ends end start RESULT: Thus the string is deleted
46
47
48
Interfacing Programs
(CYCLE NO-2)
Experiment No:12
49
msg1
DB
msg2
DB
msg3
DB
msg4
DB
msg5
DB
msg6
DB
msg7
DB
50
3088 20 20 49 20 47 4F 308E 54 20 49 4E 54 52 3094 20 37 20 20 00 4000 4000 4001 4002 4007 400A 400C 400F 4012 4016 4019 401B 401E 401F 4023 4025 4028 4029 402D 402F 4032 4033 4037 4039 403C 403D 4041 4043 4046 4047 404B 404D 4050 4051 4055 4057 405A 405B 405F 4061 4064 4065 4069 406B 406E 4071 4073 4074
msg8
DB
START: 0E 07 9A B1 4B 00 F8 B8 00 00 8E D8 BB 02 02 B9 08 00 C7 07 00 00 83 C3 04 E2 F7 BB 00 02 2E 8D 06 00 60 89 07 83 C3 04 2E 8D 06 08 60 89 07 83 C3 04 2E 8D 06 10 60 89 07 83 C3 04 2E 8D 06 18 60 89 07 83 C3 04 2E 8D 06 20 60 89 07 83 C3 04 2E 8D 06 28 60 89 07 83 C3 04 2E 8D 06 30 60 89 07 83 C3 04 2E CS 8D 06 38 60 89 07 83 C3 04 BA 00 30 B0 13 EF BA 02 30
PUSH CS POP ES CALLS 4BB1, F800 ; MOV AX,0000 MOV DS,AX MOV BX, 0202 MOV CX, 08 MOV WPTR [BX], 00H ADD BX,4 LOOP 4012 MOV BX,0200 CS LEA AX,6000 MOV [BX],AX ADD BX,4 CS LEA AX,6008 MOV [BX],AX ADD BX,4 CS LEA AX,6010 MOV [BX],AX ADD BX,4 CS LEA AX, 6018 MOV [BX], AX ADD BX,4 CS LEA AX, 6020 MOV [BX], AX ADD BX,4 CS LEA AX, 6028 MOV [BX], AX ADD BX, 4 CS LEA AX,6030 MOV [BX], AX ADD BX, 4 LEA AX, 6038 MOV [BX],AX ADD BX,4 MOV DX,03000 MOV AL, 13 OUT DX MOV DX,03002
51
Microprocessors and Interfacing Lab 4077 4079 407A 407C 407D 407F 4080 4083 4086 408B 408C 6000 6003 6006 600B 600C 6008 600B 600E 6013 6014 6010 6013 6016 601B 601C 6018 601B 601E 6023 6024 6020 6023 6026 602B 602C 6028 602B 602E 6033 6034 6030 6033 6036 603B 603C B0 60 EF B0 0F EF B0 00 EF BF 80 00 BE 00 30 9A 00 10 00 F0 FB E9 FD FF BF C0 00 BE 11 30 9A 00 10 00 F0 FB CF BF C0 00 BE 22 30 9A 00 10 00 F0 FB CF BF C0 00 BE 33 30 9A 00 10 00 F0 FB CF BF C0 00 BE 44 30 9A 00 10 00 F0 FB CF BF C0 00 BE 55 30 9A 00 10 00 F0 FB CF BF C0 00 BE 66 30 9A 00 10 00 F0 FB CF BF C0 00 BE 77 30 9A 00 10 00 F0 FB CF MOV AL, 60 OUT DX MOV AL, 0F OUT DX MOV AL,00 OUT DX MOV DI,80 MOV SI, 3000 CALLS 1000, 0F000 STI BCK: JMP BCK SERV1: MOV DI,0C0H MOV SI, 3011 CALLS 1000, 0F000 STI IRET SERV2: MOV DI,0C0H MOV SI, OFFSET MSG2 CALLS 1000, 0F000 STI IRET SERV3: MOV DI,0C0H MOV SI, OFFSET MSG3 CALLS 1000, 0F000 STI IRET SERV4: MOV DI,0C0H MOV SI, OFFSET MSG4 CALLS 1000, 0F000 STI IRET SERV5: MOV DI,0C0H MOV SI, OFFSET MSG5 CALLS 1000, 0F000 STI IRET SERV6: MOV DI,0C0H MOV SI, OFFSET MSG6 CALLS 1000, 0F000 STI IRET SERV7: MOV DI,0C0H MOV SI, OFFSET MSG7 CALLS 1000, 0F000 STI IRET
52
Microprocessors and Interfacing Lab 6038 603B 603E 6043 6044 BF C0 00 BE 88 30 9A 00 10 00 F0 FB CF SERV8: MOV DI,0C0H MOV SI, OFFSET MSG8 CALLS 1000, 0F000 STI IRET
Result: Hence we observe the interrupts (IN 0-IN 06) by using 8259 kit.
Experiment No:13
53
8255 INTERFACING
AIM: To test 8255 in different modes (mode0, mode1, mode2) by using the interfacing kit Apparatus: personnel computer 8255 kit--1nos Power supply connections: no power is needed Procedure: connect the bus from interface kit (nifc 15) to 8086 ALS trainer of 8255 connector (CN1). Care should be taken such that pin1 of cn1 coincides with pin1 of the cable 1. Mode0: 1. EPROM address: GO (PRESS ENTER) E000 (enter SHIFT button):19b0 Mode 0: any read or write For read operation 1&3 short by using jumpers For write operation 3&5 short Jumper connections: Jp1---2&3 Jp2---2&3 Jp7---1&2 Jp8---1&2 For PORT A the given data is complimentary data in PORT B. that is the concept of mode 0. 2. Mode 1(strobed i/p &o/p) Strobed i/p:-RD mode: Jp1---2&3; jp22&3; jp71&2; jp8: 1&2; jp51&2; jp6: 1&2 EPROM address E000:1700 3. Mode 2: When the data is given in the port a ,as the press the strobe pulse then the same data reads on port b. Strobed o/p:-Modewrite mode Jp1---2&3; jp22&3; jp71&2; jp8: 1&2; jp52&3; jp6: 3&4. EPROM address: E000:1640 It takes data from keyboard i.e. Enter aa then port b displayed that value. Mode2: strobed bidirectional i/p & o/p:-Mode: read mode Jp1---2&3; jp22&3; jp71&2; jp8: 1&2; jp51&2; jp6: 1&2, jp6:5&6.
54
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 96
; ; ; ; ; 0000:4021 0000:4021 0000:4021 0000:4024 0000:4025 0000:4027 0000:402A 0000:402B 0000:402B 0000:402D 0000:4030 0000:4031 0000:4034 0000:4036 0000:4039 0000:403A 0000:403D 0000:403F 0000:4042 0000:4043 0000:4046 0000:4048 0000:404B 0000:404C 0000:404F 0000:4051 0000:4054 0000:4055 0000:4058 0000:405A 0000:405D 0000:405E 0000:4061 0000:4064 0000:4064 0000:4067 0000:4069 0000:0000 0000:0000 BA 00 30 EC F6 D0 BA 02 30 EE B0 02 BA 06 30 EE E8 30 00 B0 03 BA 06 30 EE E8 27 00 B0 0A BA 06 30 EE E8 1E 00 B0 0B BA 06 30 EE E8 15 00 B0 0E BA 06 30 EE E8 0C 00 B0 0F BA 06 30 EE E8 03 00 E9 BD FF B9 FF 7F E2 FE C3
Read data from portA, this data depends on input switch settings. Complement the data and output it portB. PortC port can be operated in bit set reset mode. Observe portC bits on LED (PC1,PC5 & PC7) portC bits must be outputted to control port of 8255. LOOP1: MOV DX, PORTA IN AL, DX NOT AL MOV DX, PORTB OUT DX, AL MOV AL, 02H ;reset pc1 bit MOV DX, CTLP_55 OUT DX, AL CALL DELAY MOV AL,03H ;set pc1 bit MOV DX,CTLP_55 OUT DX,AL CALL DELAY MOV AL,0AH ;reset pc5 bit MOV DX,CTLP_55 OUT DX,AL CALL DELAY MOV AL,0BH ;set pc5 bit MOV DX,CTLP_55 OUT DX,AL CALL DELAY MOV AL,0EH ;reset pc7 bit MOV DX,CTLP_55 OUT DX,AL CALL DELAY MOV AL,0FH ;set pc7 bit MOV DX,CTLP_55 OUT DX,AL CALL DELAY
;This program can be executed for JMP LOOP1 ;different switch settings DELAY:MOV CX,7FFFH NEXT:LOOP NEXT ;loop for delay RET CSEG ENDS END END
56
46 0000:401B pointer 47 0000:401E 48 0000:4020 49 0000:4023 50 0000:4023 51 0000:4024 52 0000:4025 53 0000:4025 initialisation 54 0000:4028 55 56 0000:402A vector 57 0000:402D 58 0000:402E 59 0000:402F 60 0000:4031 61 0000:4034 62 0000:4039 63 64 0000:403B 65 0000:403E 66 0000:4040 67 68 0000:4041 address) 69 0000:4044 70 0000:4046 71 72 0000:4047 73 0000:4049 74 75 0000:404A 76 0000:404C 77 0000:404D 78 0000:404D mode1 79 0000:404F 80 0000:4052 81 82 0000:4053 which is 83 0000:4055 pc4 84 85 0000:4056 86 0000:4058 87 88 0000:4059 89 0000:405B 90 91 0000:405C 92 0000:405E 93 94 95 0000:405F
B8 00 00 8E D0 BC 00 20 FA FC B8 00 00 8E D8 BB 02 02 CLI CLD
;data segment
;initalisation of interrupt
0E PUSH CS 58 POP AX 89 07 MOV [BX],AX BB 00 02 MOV BX,200H 2E 8D 06 63 40 LEA AX,CS:SERVICE 89 07 MOV [BX],AX BA D8 FF B0 13 EE BA DA FF B0 80 EE B0 0F EE B0 FE EE B0 B4 BA 06 30 EE B0 09 EE B0 03 EE B0 0A EE B0 0F EE FB MOV DX,0FFD8H MOV AL,13H OUT DX,AL ;ICW1
MOV DX,0FFDAH ;ICW2(interrupt vector MOV AL,80H OUT DX,AL MOV AL,0FH OUT DX,AL ;ICW4 MOV AL,0FEH OUT DX,AL ;OCW1(IR0 mask reset) MOV AL,0B4H ;initialisation of 8255 for
MOV DX,CTLP_55 ;input operation OUT DX,AL MOV AL,09H OUT DX,AL ;to enable INTE flip flop
MOV AL,03H OUT DX,AL MOV AL,0AH OUT DX,AL MOV AL,0FH OUT DX,AL STI 58
96 97 0000:4060 E9 FD FF BACK: JMP BACK 98 99 ;INTR1 bit will be set when strobe pulse is given, 100 ;pulse can be given by user by pressing push button. 101 ;As soon as user presses the switch STB* line goes low, ;When the STB* line goes low,IBF goes high to indicate that 103 ;the data has been loaded in to input latch.This sets INTR & 104 ;controls transforms to service subroutine. 105 ;In service routine data is read from port A and the result 106 ;is displayed on portB 107 0000:4063 108 0000:4063 SERVICE: 109 0000:4063 110 0000:4063 BA 00 30 MOV DX,PORTA 111 0000:4066 EC IN AL,DX 112 0000:4067 BA 02 30 MOV DX,PORTB 113 0000:406A EE OUT DX,AL 114 115 0000:406B FB STI 116 0000:406C CF IRET 117 118 CSEG ENDS 118 CSEG ENDS 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 .OUTPUT 2500AD ********************************************* 8255 OPERATING IN STROBED OUTPUT MODE (MODE 1) ********************************************** ;Output mode is controlled by bits ACK*(PC2),OBF*(PC1) ;and INTR(PC0).In this mode accept data from keyboard ;display it on portB 0000:0000 3000 PORTA EQU 3000H 3002 PORTB EQU 3002H 3004 PORTC EQU 3004H 3006 CTLP_55 EQU 3006H 4ECC KBDT EQU 0F800:4ECCH
0000:0000 DSEG SEGMENT 0000:3000 ORG 0000:3000H 0000:3000 20 38 32 35 35 20 MSG DB ' 8255 in md1 O/P',0h 0000:3006 69 6E 20 6D 64 31 0000:300C 20 4F 2F 50 00 20 DSEG ENDS 21 22 0000:0000 CSEG SEGMENT 23 0000:4000 ORG 0000:4000H 24 59
25 26 27 0000:4000 28 29 30 0000:4000 display 31 0000:4005 line 32 0000:4008 33 0000:400B 34 0000:4010 35 0000:4013 initialisation 36 0000:4015 37 38 0000:4018 39 0000:4019 40 0000:401A 41 0000:401A initialisation 42 0000:401D 43 44 0000:401F 45 0000:4022 46 0000:4023 47 0000:4024 48 0000:4026 49 0000:4029 50 0000:402E 51 52 0000:4030 53 0000:4033 54 0000:4035 55 0000:4036 56 0000:4039 8259A 57 0000:403B 58 0000:403C 59 0000:403E 60 0000:403F 61 0000:4041 62 0000:4042 63 0000:4042 mode1. 64 0000:4045 65 0000:4047 66 67 0000:4048 which is 68 0000:404A 69 0000:404D 70 71 0000:404E 72 0000:4050 73 0000:4051 74 0000:4053
ASSUME CS:CSEG,DS:DSEG
START: ;displaying message on LCD ;-----------------------------------------9A B1 4B 00 F8 CALL far f800:4bb1h BF 80 00 BE 00 30 9A C0 4F 00 F8 B8 00 00 8E D0 BC 00 20 FA FC B8 00 00 8E D8 CLI CLD MOV AX,00H MOV DS,AX MOV di,80h
;clear
;display in upper
MOV SI,offset MSG ; CALL FAR f800:4FC0h;display o/p routine MOV AX,00H MOV SS,AX ;Stack segment MOV SP,2000H
;data segment
BB 02 02 MOV BX,202H 0E PUSH CS 58 POP AX ;initialisation of interrupt vector 89 07 MOV [BX],AX BB 00 02 MOV BX,200H 2E 8D 06 67 40 LEA AX,CS:SERVICE 89 07 MOV [BX],AX BA D8 FF B0 13 EE BA DA FF B0 80 EE B0 0F EE B0 FE EE BA 06 30 B0 B4 EE B0 05 BA 06 30 EE B0 0A EE B0 0F EE MOV MOV OUT DX,AL MOV MOV DX,FFD8H AL,13H DX,FFDAH AL,80H ;initialisation of PIC
OUT DX,AL MOV AL,0FH OUT DX,AL MOV AL,FEH OUT DX,AL MOV DX,CTLP_55 MOV AL,B4H OUT DX,AL MOV AL, 05H ;initialise 8255 in ;portA i/p and portB o/p ;enable INTE flip flop
MOV DX,CTLP_55 ;controlled by bit PC2 OUT DX,AL MOV AL,0AH OUT DX,AL ;IBF(PC5) taken low MOV AL,0FH OUT DX,AL ;OBF2*(PC7) taken high 60
75 0000:4054 76 0000:4054 data 77 0000:4059 in AL 78 0000:405B 79 80 0000:405D portB 81 0000:4060 82 0000:4062 83 84 0000:4063 85 86 0000:4064 87 88 when user 89 data 90 91 92 complemented 93 ACK* 94 95 96 0000:4067 97 0000:4067 input. 98 0000:4069 and 99 0000:406B 100 0000:406D 101 0000:4070 102 0000:4071 103 0000:4072 104 105 105
;When the user presses the key,OBF* line goes low & ;presses push button,ACK* line goes low indicating that is received by peripheral.This sets INTR(PC0) to cause an ;interrupt to the CPU & interrupt jumps to interrupt service ;routine, where the data written to portB & then ;& displayed on portB,next interrupt occurs only when ;is given. 8A C1 F6 D0 8A C8 BA 02 30 EE FB CF SERVICE: MOV AL,CL NOT AL ;CL contains keyboard ;Complement the value
MOV CL,AL ;output it to portB MOV DX,PORTB OUT DX,AL RETURN:STI IRET CSEG ENDS CSEG ENDS
1 .OUTPUT 2500AD 2 3 4 ********************************************************************* 5 PROGRAM TO TEST 8255 IN MODE 2 (BIDIRECTIONAL INPUT MODE). ********************************************************************* 7 ;In mode2, PORTA is used for both transmitting and 8 ;receiving data and has 5 bit control port(PORTC) for control 9 ;and status for the 8-bit,bidirectional bus port(PORTA) 10 ;The input is controlled by three bits STB*(PC4) & IBF*(PC5) 11 ;and INTR.INTR pin is common for both input and output. 61
12 ;NOTE :Make sure that DPDT switch is on RD side. 13 0000:0000 14 3000 PORTA EQU 3000H ;8255 PORTA address 15 3002 PORTB EQU 3002H ;8255 PORTB address 16 3004 PORTC EQU 3004H ;8255 PORTC address 17 3006 CTLP_55 EQU 3006H ;8255 CONTROL PORT address 18 4F1F DBDT EQU 0F800:4F1FH ;routine to display 19 20 0000:0000 DSEG SEGMENT 21 0000:3000 ORG 0000:3000H 22 0000:3000 38 32 35 35 20 69 MSG DB '8255 in md2 I/P ',0h 0000:3006 6E 20 6D 64 32 20 0000:300C 49 2F 50 20 00 23 DSEG ENDS 24 25 0000:0000 CSEG SEGMENT 26 0000:4000 ORG 0000:4000H 27 ASSUME CS:CSEG,DS:DSEG 28 29 0000:4000 START: 30 ;displaying message on LCD 31 ;-----------------------------------------32 0000:4000 9A B1 4B 00 F8 CALL far f800:4bb1h ;clear display 33 0000:4005 BF 80 00 MOV DI,80H ;display in upper line 34 0000:4008 BE 00 30 MOV SI,offset MSG ; 35 0000:400B 9A C0 4F 00 F8 CALL FAR f800:4FC0h ;display output routine 36 0000:4010 B8 00 00 MOV AX,00H 37 0000:4013 8E D0 MOV SS,AX ;stack segment initialisation 38 0000:4015 BC 00 20 MOV SP,2000H 39 40 0000:4018 41 0000:4018 FA CLI 42 0000:4019 FC CLD 43 0000:401A 44 0000:401A B8 00 00 MOV AX,00H ;data segment initialisation 45 0000:401D 8E D8 MOV DS,AX 46 0000:401F BB 02 02 MOV BX,202H 48 0000:4022 0E PUSH CS 49 0000:4023 58 POP AX 50 0000:4024 89 07 MOV [BX],AX ;interrupt vector initialisation 51 0000:4026 BB 00 02 MOV BX,200H 52 0000:4029 2E 8D 06 52 40 LEA AX,CS:SERVICE 53 0000:402E 89 07 MOV [BX],AX 54 55 0000:4030 BA D8 FF MOV DX,FFD8H 56 0000:4033 B0 13 MOV AL,13H 57 0000:4035 EE OUT DX,AL 58 0000:4036 BA DA FF MOV DX,FFDAH 59 0000:4039 B0 80 MOV AL,80H ;initialisation of PIC 8259A 60 0000:403B EE OUT DX,AL 62
61 0000:403C B0 0F MOV AL,0FH 62 0000:403E EE OUT DX,AL 63 0000:403F B0 FE MOV AL,FEH 64 0000:4041 EE OUT DX,AL 65 0000:4042 66 0000:4042 B0 C1 MOV AL,C1H ;initialise 8255 in mode 2 67 0000:4044 BA 06 30 MOV DX,CTLP_55 ;portA i/p & o/p,portC lower i/p. 68 0000:4047 EE OUT DX,AL 69 0000:4048 70 0000:4048 B0 09 MOV AL,09H ;enable INTE2 flip flop which is 71 0000:404A BA 06 30 MOV DX,CTLP_55 ;controlled by bit set/reset of pc4 72 0000:404D EE OUT DX,AL 73 74 0000:404E FB STI ;enable interrupt 75 76 0000:404F E9 FD FF BACK: JMP BACK 77 78 ;When STB* pulse is given by pressing the switch,STB* line 79 ;goes low & IBF goes high & INTR line goes high and data is 80 ;read by 8255.Then control jumps to interrupt service routine 81 ;to perform read operation.O/P the same on portB and display. 82 83 0000:4052 SERVICE: 84 0000:4052 BA 00 30 MOV DX,PORTA 85 0000:4055 EC IN AL,DX 86 0000:4056 8A C8 MOV CL,AL 87 0000:4058 BA 02 30 MOV DX,PORTB 88 0000:405B EE OUT DX,AL 89 90 0000:405C B5 00 MOV CH,00H 91 0000:405E 8B F1 MOV SI,CX 92 0000:4060 9A 1F 4F 00 F8 CALL FAR DBDT 93 0000:4065 94 0000:4065 FB STI 95 0000:4066 CF IRET 96 97 CSEG ENDS 97 CSEG ENDS 1 2 3 4 5 6 7 8 9 .OUTPUT 2500AD ********************************************************** PROGRAM TO TEST 8255 IN MODE 2 (BIDIRECTIONAL O/P MODE). ********************************************************** ;Output is controlled by bits ACK*(PC6) & OBF*(PC7). ;NOTE:Make sure that the DPDT switch is on the WR side 63
10 3000 PORTA EQU 3000H 11 3002 PORTB EQU 3002H 12 3004 PORTC EQU 3004H 13 3006 CTLP_55 EQU 3006H 14 4ECC KBDT EQU 0F800:4ECCH 15 16 0000:0000 DSEG SEGMENT 17 0000:3000 ORG 0000:3000H 18 0000:3000 38 32 35 35 20 69 MSG DB '8255 in md2 O/P ',0h 0000:3006 6E 20 6D 64 32 20 0000:300C 4F 2F 50 20 00 19 DSEG ENDS 20 21 0000:0000 CSEG SEGMENT 22 0000:4000 ORG 0000:4000H 23 ASSUME CS:CSEG,DS:DSEG 24 25 0000:4000 START: 26 ;displaying message on LCD 27 ;-----------------------------------------28 0000:4000 9A B1 4B 00 F8 CALL FAR F800:4bb1h ;clear display 29 0000:4005 BF 80 00 MOV DI,80H ;display in upper line 30 0000:4008 BE 00 30 MOV SI,offset MSG ; 31 0000:400B 9A C0 4F 00 F8 CALL FAR f800:4FC0h;display output routine 32 0000:4010 B8 00 00 MOV AX,00H 33 0000:4013 8E D0 MOV SS,AX ;stack segment initialisation 34 0000:4015 BC 00 20 MOV SP,2000H 35 36 0000:4018 37 0000:4018 FA CLI 38 0000:4019 FC CLD 39 0000:401A 40 0000:401A B8 00 00 MOV AX,00H ;data segment initialisation 41 0000:401D 8E D8 MOV DS,AX 43 0000:401F BB 02 02 MOV BX,202H 44 0000:4022 0E PUSH CS 45 0000:4023 58 POP AX 46 0000:4024 89 07 MOV [BX],AX ;interrupt vector initialisation 47 0000:4026 BB 00 02 MOV BX,200H 48 0000:4029 2E 8D 06 55 40 LEA AX,CS:SERVICE 49 0000:402E 89 07 MOV [BX],AX 50 51 0000:4030 BA D8 FF MOV DX,FFD8H 52 0000:4033 B0 13 MOV AL,13H 53 0000:4035 EE OUT DX,AL 54 0000:4036 BA DA FF MOV DX,FFDAH 55 0000:4039 B0 80 MOV AL,80H ;initialisation of PIC 8259A 56 0000:403B EE OUT DX,AL 57 0000:403C B0 0F MOV AL,0FH 58 0000:403E EE OUT DX,AL 64
59 60 61 62 2
63 0000:4044 C lower i/p 64 0000:4047 65 66 0000:4048 67 0000:404A 68 0000:404D 69 70 0000:404E 71 0000:4050 72 73 0000:4051 74 75 0000:4052 76 77 78 goes high 79 latched 80 received. 81 PORTA 82 83 0000:4055 84 0000:4055 85 0000:4055 86 0000:405A 87 0000:405C 88 0000:405F 89 0000:4060 90 0000:4061 91 0000:4062 92 92
MOV AL,0DH ;enable INTE flip flop MOV DX,CTLP_55 OUT DX,AL MOV AL,03H OUT DX,AL STI ;OBF1* taken high
;enable interrupt
;When CPU writes data on output latch OBF* line goes low. ;As soon as user presses switch,ACK* goes low & INTR ;and control jumps to service routine and the data is ;on PORTA and OBF* line gets cleared when ACK* is ;This data can also be observed on LED connected to
SERVICE: 9A CC 4E 00 F8 CALL FAR KBDT 8B C6 MOV AX,SI BA 00 30 MOV DX,PORTA EE OUT DX,AL FB STI CF IRET CSEG ENDS CSEG ENDS
Experiment No:14
Jumper connections: Jp 6: 1&2; Jp 7: 1&2; Jp17: 1&2; Jp 18: 1&2; Jp 1: 3&2; Jp 2: 3&2; Jp 4,jp5,jp13: 1&2: Jp 9 :5&6;jp 10 :5&6;jp 16:3&2; Eprom address : E000:34D0 Procedure for transmitting part: Connect the cable of RS 232 One end to kit (nifc 21) to other end is connected to personnel computer parallel port. And then run the communication package for 86drv.exe for 8086kit, b30drv.exe for 51lcd kit. execute the program in keyboard mode using go command Then the message TESTING 8251 TRANSMITTING PART will be displayed in the Kit. Suppose we may enter the data from the key board the data will see in the memory location of 0:ff00. Procedure for receving part: Jp 6: 1&2; Jp 7: 1&2; Jp17: 1&2; Jp 18: 1&2; Jp 1: 3&2; Jp 2: 3&2; Jp 4,jp5,jp13: 1&2: Jp 9 :1&2;jp 10 :5&6;jp 16:3&2; Eprom address : E000:35C0 And then run the communication package for 86drv.exe for 8086kit, b30drv.exe for 51lcd kit. execute the program in keyboard mode using go command Then the message 8251-RECEVING MODEwill be displayed on the lcd kit Then enter the characters from keyboard ,when user does not want to enter the characters any more then press the enter key. when it is pressed the char OD appears on the data The user can see the characters transmiited to the 8251A in RAM location 0:ff00 for 86 series kit AIM:To test 8251 in transmitting and receiving parts by using the interfacing kit Apparatus: personnel computer Transmitting &receving kit1nos Program: 1 2 3 4 5 frequency 6 address 7 address 8 9 address 10 11 data field 12 13 14 15 16 .OUTPUT 2500AD ;PROGRAM TO TEST 8251 7000 3402 3400 3002 3006 FF00 4F1F 000A 0140 0028 0014 CLOCK_FREQ EQU 1536000 CTL_8251 EQU 3402H DATA_8251 EQU 3400H TMR1_8253 EQU 3002H CTL_8253 EQU 3006H ;8253 clock ;8251 control port ;8251 data port ;8253 timer1 address ;8253 control port
EXT_RAM_LC EQU 0:FF00H ;RAM location DBDT EQU F800:4F1FH ;routine for display on CNT_BAUD_9600_MODE16 CNT_BAUD_4000_MODE01 CNT_BAUD_2400_MODE16 CNT_BAUD_1200_MODE64 66 EQU EQU EQU EQU 000AH 0140H 0028H 0014H
17 18 19 20 21 22 23 is
CNT_BAUD_0300_MODE64 EQU 0050H MODE_WORD16 EQU CEH MODE_WORD1 EQU CDH MODE_WORD64 EQU CFH
24 ;written to test receiver part of 8251 using RS_232 standard. 25 ;Data characters can be received from keyboard & sent to 8251 26 ;on an interrupt basis.RxRDY pin of the 8251 is connected to 27 ;an interrupt input through PIC 8259. 28 29 ;************************************ 30 ;PROGRAM TO TEST 8251 RECEIVING PART. 31 ;************************************ 32 33 0000:0000 DSEG SEGMENT 34 0000:3000 ORG 0000:3000H 35 0000:3000 38 32 35 31 2D 52 MSG2 DB '8251-Receiv mode',0H 0000:3006 65 63 65 69 76 20 0000:300C 6D 6F 64 65 00 36 DSEG ENDS 37 38 0000:0000 CSEG SEGMENT 39 0000:4000 ORG 0000:4000H 40 ASSUME CS:CSEG,DS:DSEG 41 42 0000:4000 START: 43 44 ;displaying message on LCD 45 ;-----------------------------------------46 0000:4000 9A B1 4B 00 F8 CALL FAR F800:4BB1H ;clear display 47 0000:4005 BF 80 00 MOV DI,80H ;display in upper line 48 0000:4008 BE 00 30 MOV SI,offset MSG2 ; 49 0000:400B 9A C0 4F 00 F8 CALL FAR f800:4FC0h;display output routine 50 51 52 0000:4010 B8 00 00 MOV AX,00H ;initialisation of stack pointer 53 0000:4013 8E D0 MOV SS,AX 54 0000:4015 BC 00 20 MOV SP,2000H 55 56 0000:4018 8E D8 MOV DS,AX 57 0000:401A 58 0000:401A FA CLI 59 0000:401B FC CLD 60 0000:401C 61 0000:401C BB 02 02 MOV BX,0202H ;initalisation of interrupt vector 62 0000:401F 0E PUSH CS 63 0000:4020 58 POP AX 64 0000:4021 89 07 MOV [BX],AX 67
65 0000:4023 BB 00 02 MOV BX,200H 66 0000:4026 2E 8D 06 80 40 LEA AX,CS:SRVC2 67 0000:402B 89 07 MOV [BX],AX 68 69 0000:402D BA D8 FF MOV DX,0FFD8H ;ICW1 70 0000:4030 B0 13 MOV AL,13H 71 0000:4032 EE OUT DX,AL 72 73 0000:4033 BA DA FF MOV DX,0FFDAH ;ICW2(intrrpt vector address) 74 0000:4036 B0 80 MOV AL,80H 75 0000:4038 EE OUT DX,AL 76 77 0000:4039 B0 0F MOV AL,0FH 78 0000:403B EE OUT DX,AL ;ICW4 79 80 0000:403C B0 FE MOV AL,0FEH 81 0000:403E EE OUT DX,AL ;OCW1(IR0 mask reset) 82 83 0000:403F BB 00 FF MOV BX,EXT_RAM_LC ;BX points to RAM location where the 84 ;character read from 8251 are stored 85 86 0000:4042 BA 06 30 MOV DX,CTL_8253 ;initialise timer1 in mode2 87 0000:4045 B0 76 MOV AL,76H 88 0000:4047 EE OUT DX,AL 89 90 0000:4048 BA 02 30 MOV DX,TMR1_8253 91 0000:404B B0 0A MOV AL,<CNT_BAUD_9600_MODE16 ;load LSB in count reg 92 0000:404D EE OUT DX,AL 93 0000:404E B0 00 MOV AL,>CNT_BAUD_9600_MODE16 ;load MSB in count reg 94 0000:4050 EE OUT DX,AL 95 96 0000:4051 FB STI ;enable interrupt 97 98 0000:4052 BA 02 34 MOV DX,CTL_8251 ;send 0's to guarantee,device is in 99 0000:4055 B0 00 MOV AL,00H ;command instruction format before 100 0000:4057 EE OUT DX,AL ;the RESET command is issued. 101 102 0000:4058 90 NOP 103 0000:4059 90 NOP 104 0000:405A 90 NOP 105 0000:405B 90 NOP 106 0000:405C EE OUT DX,AL 107 108 0000:405D 90 NOP 109 0000:405E 90 NOP 110 0000:405F 90 NOP 111 0000:4060 90 NOP 112 0000:4061 EE OUT DX,AL 113 68
114 0000:4062 command to 115 0000:4065 state 116 0000:4067 117 0000:4068 118 0000:4069 119 0000:406A 120 0000:406B 121 0000:406C 122 0000:406C word 123 0000:406F 124 0000:4071 125 0000:4072 126 0000:4073 127 0000:4074 128 0000:4075 129 130 0000:4076 word 131 0000:4079 132 0000:407B 133 8251,and the 134 read,RxRDY pin 135 is set 136 routine 137 138 139 140 0000:407C 141 0000:407D 142 143 144 0000:4080 145 0000:4080 146 0000:4083 data is 147 0000:4084 whether typed 148 0000:4085 indicates 149 0000:4086 displayed 150 0000:4087 display and 151 0000:4088 starting 152 0000:4089 location. 153 0000:408B 154 155 0000:408D
BA 02 34 B0 40 EE 90 90 90 90 BA 02 34 B0 CE EE 90 90 90 90 BA 02 34 B0 36 EE
MOV DX,CTL_8251 ;send internal RESET MOV AL,40H OUT DX,AL NOP NOP NOP NOP MOV DX,CTL_8251 ;load mode control ;return device to idle
MOV AL,MODE_WORD16 OUT DX,AL NOP NOP NOP NOP MOV DX,CTL_8251 ;load command
MOV AL,36H OUT DX,AL ;when the character typed has been shifted into ;character is in receiver buffer ready to be ;is connected to the interrupt pin,as soon as RxRDY ;interrupt is enabled & process jumps to service
90 E9 FC FF
BA 00 34 EC EC 90 90 90 90 3C 0D 75 0F B4 00
MOV DX,DATA_8251 IN AL,DX ;In the service routine IN AL,DX NOP NOP NOP NOP CMP AL,0DH JNZ AHEAD2 MOV AH,00 69 ;read from 8251,check ;character is 0DH.If yes it ;it is the last char and is ;in the data field of the ;reinitialise pointer to the ;address of RAM
156 0000:408F 157 0000:4091 158 0000:4096 159 0000:4099 160 0000:409C other than 0DH 162 0000:409E RAM loc. 163 0000:409F 164 0000:40A0 165 to reset 166 service 167 be read. 168 169 170 0000:0000 170 0000:0000 1 2 3 4 5 frequency 6 address 7 address 8 9 address 10 11 data field 12 13 14 15 16 17 18 19 20 21 22 23 is 24 standard 25 basis.So 26 27
8B F0 9A 1F 4F 00 F8 BB 00 FF E9 03 00 88 07 43 FB CF
MOV SI,AX CALL FAR DBDT MOV BX,EXT_RAM_LC JMP TERM AHEAD2:MOV [BX],AL ;If typed char is INC BX ;then store the char in
TERM: STI IRET ;Reading a data char from 8251 data port causes it ;the RxRDY output signal.The process returns from ;routine & waits until another character is ready to CSEG ENDS END END .OUTPUT 2500AD PROGRAM TO TEST 8251
7000 3402 3400 3002 3006 FF00 4F1F 000A 0140 0028 0014 0050 00CE 00CD 00CF
CLOCK_FREQ EQU 1536000 CTL_8251 EQU 3402H DATA_8251 EQU 3400H TMR1_8253 EQU 3002H CTL_8253 EQU 3006H
;8253 clock ;8251 control port ;8251 data port ;8253 timer1 address ;8253 control port
EXT_RAM_LC EQU 0000:FF00H ;RAM location DBDT EQU F800:4F1FH ;routine for display on CNT_BAUD_9600_MODE16 CNT_BAUD_4000_MODE01 CNT_BAUD_2400_MODE16 CNT_BAUD_1200_MODE64 CNT_BAUD_0300_MODE64 MODE_WORD16 EQU CEH MODE_WORD1 EQU CDH MODE_WORD64 EQU CFH ;With the count calculated for various baud rates program ;written to test transmission part of 8251 using RS_232 ;Data characters can be sent to 8251 on an interrupt ;to send characters on interrupt basis the TxRDY pin of the ;8251 is connected to an interrupt input through PIC 8259. 70 EQU EQU EQU EQU EQU 000AH 0140H 0028H 0014H 0050H
28 29
30 ;*************************************** 31 ;PROGRAM TO TEST 8251 TRANSMITTING PART. 32 ;*************************************** 33 34 0000:0000 DSEG SEGMENT 35 0000:3000 ORG 0000:3000H 36 0000:3000 20 20 54 65 73 74 MSG2 DB ' Testing 8251 ',0h 0000:3006 69 6E 67 20 38 32 0000:300C 35 31 20 20 00 37 0000:3011 54 72 61 6E 73 6D MSG1 DB 'Transmiting part',0h 0000:3017 69 74 69 6E 67 20 0000:301D 70 61 72 74 00 38 0000:3022 54 45 53 54 49 4E MSG DB 'TESTING 8251 IN ASYNCHRONOUS MODE',0DH,0AH,1BH 0000:3028 47 20 38 32 35 31 0000:302E 20 49 4E 20 41 53 0000:3034 59 4E 43 48 52 4F 0000:303A 4E 4F 55 53 20 4D 0000:3040 4F 44 45 0D 0A 1B 39 DSEG ENDS 40 41 0000:0000 CSEG SEGMENT 42 0000:4000 ORG 0000:4000H 43 ASSUME CS:CSEG,DS:DSEG 44 ;displaying message on LCD 45 ;-----------------------------------------46 0000:4000 9A B1 4B 00 F8 CALL FAR F800:4BB1H ;clear display 47 0000:4005 BF 80 00 MOV DI,80H ;display in upper line 48 0000:4008 BE 00 30 MOV SI,offset MSG2 ; 49 0000:400B 9A C0 4F 00 F8 CALL FAR f800:4FC0h ;display output routine 50 0000:4010 BF C0 00 MOV DI,C0H ;display in lower line 51 0000:4013 BE 11 30 MOV SI,OFFSET MSG1 52 0000:4016 9A C0 4F 00 F8 CALL FAR F800:4FC0H ;display output routine 53 54 0000:401B START: 55 56 0000:401B B8 00 00 MOV AX,00H ;initialisation of stack pointer 57 0000:401E 8E D0 MOV SS,AX 58 0000:4020 BC 00 20 MOV SP,2000H 59 60 0000:4023 B8 00 00 MOV AX,00H 61 0000:4026 8E D8 MOV DS,AX 62 63 0000:4028 FA CLI 64 0000:4029 FC CLD 65 0000:402A 66 0000:402A BB 02 02 MOV BX,0202H ;initalisation of interrupt vector 71
67 0000:402D 0E PUSH CS 68 0000:402E 58 POP AX 69 0000:402F 89 07 MOV [BX],AX 70 0000:4031 BB 00 02 MOV BX,0200H 71 0000:4034 2E 8D 06 91 40 LEA AX,CS:SRVC1 72 0000:4039 89 07 MOV [BX],AX 73 74 0000:403B BA D8 50 MOV DX,050D8H ;ICW1 75 0000:403E B0 13 MOV AL,13H 76 0000:4040 EE OUT DX,AL 77 78 0000:4041 BA DA 50 MOV DX,050DAH ;ICW2(interrupt vector address) 79 0000:4044 B0 80 MOV AL,80H 80 0000:4046 EE OUT DX,AL 81 82 0000:4047 B0 0F MOV AL,0FH 83 0000:4049 EE OUT DX,AL ;ICW4 84 85 0000:404A B0 FE MOV AL,0FEH 86 0000:404C EE OUT DX,AL ;OCW1(IR0 mask reset) 87 88 89 0000:404D BB 22 30 MOV BX,OFFSET MSG ;BX points to message 90 0000:4050 BE 00 FF MOV SI,EXT_RAM_LC ;SI points to RAM Locations 91 ;where the characters written to 8251 are stored 92 93 0000:4053 BA 06 30 MOV DX,CTL_8253 ;initialise timer1 in mode2 94 0000:4056 B0 76 MOV AL,76H 95 0000:4058 EE OUT DX,AL 97 0000:4059 BA 02 30 MOV DX,TMR1_8253 98 0000:405C B0 0A MOV AL,<CNT_BAUD_9600_MODE16 ;load the LSB count in 99 0000:405E EE OUT DX,AL ;timer1 count reg 100 0000:405F B0 00 MOV AL,>CNT_BAUD_9600_MODE16 ;load the MSB count in 101 0000:4061 EE OUT DX,AL ;timer1 count reg 102 103 0000:4062 FB STI ;enable interrupt 104 105 0000:4063 BA 02 34 MOV DX,CTL_8251 ;8251 control port address.Send 106 0000:4066 B0 00 MOV AL,00H ;0's to guarantee,device is in 107 0000:4068 EE OUT DX,AL ;the command instruction format. 108 ;Repeat the same four times 109 0000:4069 90 NOP 110 0000:406A 90 NOP 111 0000:406B 90 NOP 112 0000:406C 90 NOP 113 0000:406D EE OUT DX,AL 114 0000:406E 90 NOP 115 0000:406F 90 NOP 72
116 0000:4070 117 0000:4071 118 0000:4072 119 120 0000:4073 command 121 0000:4076 idle state 122 0000:4078 123 0000:4079 124 0000:407A 125 0000:407B 126 0000:407C 127 0000:407D 128 0000:407D control word 129 0000:4080 130 0000:4082 131 0000:4083 132 0000:4084
90 90 EE BA 02 34 B0 40 EE 90 90 90 90 BA 02 34 B0 CE EE 90 90
MOV DX,CTL_8251 ;send internal reset MOV AL,40H OUT DX,AL NOP NOP NOP NOP MOV DX,CTL_8251 ;load the mode ;to return device to
134 0000:4085 BA 02 34 MOV DX,CTL_8251 ;load the command word 135 0000:4088 B0 33 MOV AL,33H ;when CTS* input of 8251 is 136 0000:408A EE OUT DX,AL ;asserted low and the 8251 buffer 137 0000:408B 90 NOP ;is ready for a character,the TxRDY 138 0000:408C 90 NOP ;pin will go high.Since TxRDY pin 139 ;is connected to the interrupt pin,as soon as TxRDY is set INTR 140 ;is enabled and the process jumps to service routine. 141 0000:408D 142 0000:408D 90 BACK: NOP 143 0000:408E E9 FC FF JMP BACK 146 0000:4091 SRVC1: 147 0000:4091 B8 00 00 MOV AX,0000H 148 0000:4094 8E D8 MOV DS,AX 149 0000:4096 8A 07 MOV AL,[BX] message address stored in reg BX 150 0000:4098 83 C3 01 ADD BX,01H ;read the message byte by byte 151 0000:409B 3C 1B CMP AL,1BH ;check if the byte is a last byte 152 0000:409D 75 09 JNZ AHEAD 153 0000:409F 154 0000:409F 155 0000:409F BB 22 30 MOV BX,OFFSET MSG ;if yes reinitialise the pointer 156 0000:40A2 BE 00 FF MOV SI,EXT_RAM_LC ;to message and RAM location 157 0000:40A5 E9 E9 FF JMP SRVC1 73
158 0000:40A8 BA 00 34 the char to data port 159 0000:40AB EE location 160 0000:40AC 8A C8 161 0000:40AE B8 00 00 162 0000:40B1 8E D8 163 0000:40B3 8A C1 164 0000:40B5 88 04 165 0000:40B7 83 C6 01 166 0000:40BA FB 167 0000:40BB CF 168 port the 8251 169 to receive 170 routine after 171 ready in 172 174 175 0000:0000 176 0000:0000
OUT DX,AL;of 8251 & also save in ram MOV CL,AL MOV AX,00H MOV DS,AX MOV AL,CL MOV [SI],AL ADD SI,01H STI IRET ;When the data character is written to 8251 data ;resets its TxRDY o/p until the buffer is again ready ;a character.The process returns from interrupt ;writing data to 8251 and waits until 8251 buffer is ;in the main loop. CSEG ENDS END
Result: Hence we observed the transmitting &receiving part of the kit of 8251.
74
Experiment No:15
75
Experiment No:16
Experiment No:17
Power supply +5v Source code: MOV A, 6F ADD A,6B MOV BE, A LCALL 0003H
Result: Thus we understand the 3rd memory area of 8051 micro controller (30-7F).
Experiment No:18
MOV d0, #75 MOV E0, #25 ADD A, D0 MOV F0, A LCALL 0003H
Result: Thus we understand the memory area of 80-FF in 8051 micro controller.
Experiment No:19
SWAP OPERATION
Aim: To perform swap operation in 8051 micro controller. Apparatus: ALS-SDA-51-STA KIT Key board Power supply Source code: 79
Experiment No:20
SET-RESET
Aim: To perform the set reset operation of 8051 micro controller Apparatus: ALS-SDA-51-STA KIT Key board Power supply +5v Source code: SET B, D4 CLR D3 80
81