100% found this document useful (1 vote)
184 views

MP Lab Observation

The document summarizes an assembly language programming lab experiment on arithmetic operations using 8086 microprocessor. It includes programs to perform various arithmetic operations like addition, subtraction, multiplication and division on 8-bit and 16-bit data. It also describes a program for multibyte addition and subtraction using registers AL, BX and CX. The document provides algorithms, flowcharts and code tables for the programs.

Uploaded by

Bhargav Mushini
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
184 views

MP Lab Observation

The document summarizes an assembly language programming lab experiment on arithmetic operations using 8086 microprocessor. It includes programs to perform various arithmetic operations like addition, subtraction, multiplication and division on 8-bit and 16-bit data. It also describes a program for multibyte addition and subtraction using registers AL, BX and CX. The document provides algorithms, flowcharts and code tables for the programs.

Uploaded by

Bhargav Mushini
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 115

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

CONTENTS
Page no.

1. Microprocessor 8086 Programming 2.1 Introduction to MASM and TASM 2.2 Arithmetic operations a) Arithmetic Operations on 8 bit data b) Arithmetic Operations on 16 bit data c) Multibyte addition and subtraction d) Signed Operations on 8 bit data e) ASCII Arithmetic Operations 6 11 16 21 26 3

2.3 Logic Operations a) BCD to ASCII Conversion b) ASCII to BCD Conversion. c) Positive & negative count in an array d) Even & odd count in an array e) Packed BCD to Unpacked BCD Conversion 31 35 39 44 49

2.4 String Operations a) Move Block of Data b) Reversal of given String c) Sorting of N numbers d) Length of given String e) Comparison of two Strings 52 55 60 66 71

2.5 DOS/BIOS Programming a) Reading Keyboard buffered with echo b) Reading Keyboard buffered with out echo c) Display String by using BIOS Commands 76 79 82

ADITYA ENGINEERING COLLEGE

MICROPROCESSORS LAB OBSERVATION

ECE Dept.
Page no.

3. Interfacing with 8086 3.1. Digital to Analog Converters 3.2. Keyboard Display Interfacing (8279) 85 97

ADDITIONAL PROGRAMS 4. Stepper Motor Interfacing Using 8255 PPI 105

ADITYA ENGINEERING COLLEGE

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

INTRODUCTION TO MASM/TASM
ASSEMBLY LANGUAGE PROGRAMMING USING MASM SOFTWARE:
This software used to write a program (8086, Pentium processors etc.) The programs are written using assembly language in editor then compile it. The complier converts assembly language statements into machine language statements/checks for errors. Then execute the compiled program. There are different soft wares developed by different companies for assembly language programming .They are.

MASM - Microsoft Company. TASM - Bore Land Company.

MERITS OF MASM: 1. produces binary code 2. Referring data items by their names rather than by their address. HOW TO ENTER INTO MASM EDITOR: Click Start on the desktop. Then select Run Then it Shows inbox Then type Command (CMD) which enters you into DOS prompt Path setting Suppose it display path as C:\ DOCUME-\ADMIN> Then type CD\ i.e.; C:\DOCUME\\ADMIN>CD\ Then the path is C :\> Then type CD MASM Then the path is C: MASM> Then type edit i.e.; C: MASM>edit Then you enter into MASM text editor.

ADITYA ENGINEERING COLLEGE

MICROPROCESSORS LAB OBSERVATION


Then enter to FILE and select NEW. And name it and then write the ALP (Assembly Language Program) in this editor. After that save it as filenames Then exit from the editor and go to prompt. Then type MASM filename.ASM I.e. C: MASM>MASM filename.ASM

ECE Dept.

or

C: MASM filename.ASM, , ;

Then link this file using C: MASM>LINK filename.OBJ or C: MASM>LINK filename.OBJ , , ; i.e link the program in assembly with DOS then debug to create exe file

C:MASM>debug filename. EXE


Then it display -- on the screen After that type R displays the registers contents and starting step of the program.

T Tracing at contents of program step by step.


Suppose you need to go for break point debugging. Then type that instruction no where you need to check your register. For example T10 it will display the contents of register after executing 10 instructions. DEBUG: This command utility enables to write and modify simple assembly language programs in an easy fashion. It provides away to run and test any program in a controlled environment. We can change any part of the program and immediately execute the program with an having to resemble it. We can also run machine language(Object files) directly by using DEBUG

DEBUG COMMANDS:
ASSEMBLE COMPARE A [address] C range address ; Assembly the instructions at a particular address ; Compare two memory ranges

ADITYA ENGINEERING COLLEGE

MICROPROCESSORS LAB OBSERVATION DUMP ENTER D [range] E address [list] ; Display contents of memory

ECE Dept.

; Enter new or modifies memory contents beginning

at specific Location FILL GO HEX INPUT LOAD MOVE NAME OUTPUT PROCEED QUIT Q R [register] S range list T [=address] [value] F range list ; Fill in a range of memory

G [=address] [addresses] ; Execute a program in memory H value1 value2 I port L [address] [drive] [first sector] [number] M range address N [pathname] [arg list] O port byte P [=address] [number] ; Add and subtract two Hex values

REGISTER SEARCH TRACE

UNASSEMBLE U [range] WRITE W [address] [drive] [first sector] [number] XA [#pages] XD [handle]

ALLOCATE expanded memory DEALLOCATE expanded memory MAP expanded memory pages

XM [Lpage] [Ppage] [handle]

DISPLAY expanded memory status XS

ADITYA ENGINEERING COLLEGE

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

Exp No: Date:

2.2 a) ARITHMETIC OPERATIONS ON 8- BIT DATA


ABSTRACT: Assembly language program to perform all arithmetic operations on 8-bit data PORTS USED: None REGISTERS USED: AX, BL ALGORITHM: Step1: Start Step2: Initialize data segment Step3: Load the given data to registers AL& BL Step4: Perform addition and Store the result Step 5: Repeat step 3 Step6: Perform subtraction and Store the result Step7: Repeat step 3 Step8: Perform multiplication and Store the result Step9: Repeat step 3 Step10: Perform division and Store the result Step11: stop.
PROGRAM: ASSUME CS: CODE, DS: DATA DATA SEGMENT N1 EQU 04H N2 EQU 06H RESULT DB 06H DUP (00) DATA ENDS CODE SEGMENT START: MOV AX , DATA MOV DS , AX MOV AL , N1 MOV BL, N2 ADD AL, BL MOV [RESULT], AL MOV AL, N1 SUB AL, BL MOV [RESULT+1], AL MOV AL, N1 MUL BL MOV [RESULT+2], AL MOV [RESULT+3], AH MOV AL, N1 MOV AH, 00H DIV BL MOV [RESULT+4], AL MOV [RESULT+5], AH MOV AH, 4CH INT 21H CODE ENDS END START

ADITYA ENGINEERING COLLEGE

MICROPROCESSORS LAB OBSERVATION FLOW CHART: START


Initialize DS AL Data1 BL Data2

ECE Dept.

AL

AL+BL AL

Data Memory

AL

Data1

AL

AL-BL AL

Data Memory

AL

Data1

AX AL*BL Data Memory AX

AL AH

Data1 00H

AX AX / BL Data Memory AX

STOP

ADITYA ENGINEERING COLLEGE

MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand

ECE Dept.

Comments

ADITYA ENGINEERING COLLEGE

MICROPROCESSORS LAB OBSERVATION MANUAL CALCULATIONS:

ECE Dept.

ADITYA ENGINEERING COLLEGE

MICROPROCESSORS LAB OBSERVATION RESULT:

ECE Dept.

ADITYA ENGINEERING COLLEGE

10

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

Exp No: Date:


2.2(b) ARITHMETIC OPERATIONS ON 16BIT DATA ABSTRACT: Assembly language program to perform all arithmetic operations on 16bit data PORTS USED: None REGISTERS USED: AX, BX, SI ALGORITHM: Step1: Start Step2: Initialize data segment Step3: Initialize SI with some memory location Step4: Load the given data to registers AX & BX Step5: Perform addition and Store the result Step6: Repeat step 4 Step7: Perform subtraction and Store the result Step8: Repeat step 4 Step9: Perform multiplication and Store the result Step10: Repeat step 4 Step11: Perform division and Store the result Step12: Stop
PROGRAM: ASSUME CS: CODE, DS: DATA DATA SEGMENT N1 EQU 8888H N2 EQU 4444H DATA ENDS CODE SEGMENT START: MOV AX, DATA MOV DS, AX MOV SI, 5000H MOV AX, N1 MOV BX, N2 ADD AX, BX MOV [SI], AX MOV AX, N1 SUB AX, BX MOV [SI+2], AX MOV AX, N1 MUL BX MOV [SI+4], AX MOV [SI+6], DX MOV AX, N1 MOV DX, 0000 DIV BX MOV [SI+8], AX MOV [SI+0AH], DX MOV AH, 4CH INT 21H CODE ENDS END START

ADITYA ENGINEERING COLLEGE

11

MICROPROCESSORS LAB OBSERVATION FLOW CHART: START


Initialize DS SI 1000H AX Data1 BX Data2

ECE Dept.

AX [SI]

AX+BX AX

AX

Data1

AX [SI+2]

AX-BX AX

AX

Data1

AX, DX [SI+4]

AX*BX AX, DX

AX DX

Data1 0000H

AX, DX [SI+8]

DX AX / BX AX,DX

STOP

ADITYA ENGINEERING COLLEGE

12

MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand

ECE Dept.

Comments

ADITYA ENGINEERING COLLEGE

13

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

MANUAL CALCULATIONS:

ADITYA ENGINEERING COLLEGE

14

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

RESULT:

ADITYA ENGINEERING COLLEGE

15

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

Exp No: Date:


2.2 (C) MULTIBYTE ADDITIONS AND SUBTRACTION
ABSTRACT: Assembly language program to perform multibyte addition and subtraction PORT USED: None REGISTERS USED: AL, BX, CX ALGORITHM: Step1: Start Step2: Initialize data segment Step3: Load CX register with count Step4: Load BX register with No. of bytes Step5: Copy the contents from the memory location n1 [BX] to AL Step6: Perform addition with second number n2 [BX] Step7: Store the result to the memory location sum [BX] Step8: Decrement BX Step9: Decrement CX, if CX not equal to Zero jump to step5 Step10: Load CX register with count Step11: Load BX register with no: of bytes Step12: Store the contents from memory location n1 [BX] to AL Step13: Perform subtraction with second number n2 [BX] Step14: Store the result to the memory location sum [BX] Step15: Decrement BX Step16: Decrement CX, if CX not equal to Zero jump to step12 Step17: Stop

PROGRAM:
ASSUME CS: CODE, DS: DATA DATA SEGMENT N1 DB 33H, 33H, 33H N2 DB 11H, 11H, 11H COUNT EQU 0003H SUM DB 03H DUP (00) DIFF DB 03H DUP (00) DATA ENDS CODE SEGMENT ORG 1000H START: MOV AX, DATA MOV DS, AX MOV CX, COUNT MOV BX, 0002H CLC BACK: MOV AL, N1 [BX] ADC AL, N2 [BX] MOV SUM [BX], AL DEC BX LOOP BACK MOV CX, COUNT MOV BX, 0002H CLC BACK1: MOV AL, N1 [BX] SBB AL, N2 [BX] MOV DIFF [BX], AL DEC BX LOOP BACK1 MOV AH, 4CH INT 21H CODE ENDS END START

ADITYA ENGINEERING COLLEGE

16

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

FLOW CHART:

START
Initialize DS Initialize Data1, Data2 CX COUNT BX COUNT-1

AL

Data1 [bx]

AL

Data1 [bx] +Data2 [bx]+CF Data memory AL

BX CX NO

BX-1 CX-1

CX=0
YES CX BX AL COUNT COUNT-1 Data1 [bx]

AL

Data1 [bx]-Data2 [bx]-CF Data memory

AL

BX CX

BX-1 CX-1

NO

CX=0
YES

STOP

ADITYA ENGINEERING COLLEGE

17

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand Comments

ADITYA ENGINEERING COLLEGE

18

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

MANUAL CALCULATIONS:

ADITYA ENGINEERING COLLEGE

19

MICROPROCESSORS LAB OBSERVATION RESULT:

ECE Dept.

ADITYA ENGINEERING COLLEGE

20

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

Exp No: Date:


2.2 d) SIGNED OPERATIONS ON 8 BIT DATA ABSTRACT: Assembly language program to perform signed operations PORT USED: None REGISTERS USED: AL, BL ALGORITHM: Step1: Start Step2: Initialize data segment Step3: Load AL with first number Step4: Do 2s compliment of AL Step5: Load BL with second number Step6: Perform signed Multiplication Step7: Store the result in data memory Step8: Load AL with first number Step9: Repeat step 4 Step10: Convert AL to AX Step11: Perform signed division Step12: Store the result in data memory Step13: Stop PROGRAM:
ASSUME CS: CODE , DS: DATA DATA SEGMENT N1 DB 08H N2 DB 04H RESULT DW 02 DUP (00) DATA ENDS CODE SEGMENT START: MOV AX, DATA MOV DS, AX MOV AL, N1 NEG AL MOV BL, N2 IMUL BL MOV [RESULT], AX MOV AL, N1 NEG AL CBW IDIV BL MOV [RESULT+2], AX MOV AH, 4CH INT 21H CODE ENDS END START

ADITYA ENGINEERING COLLEGE

21

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

FLOW CHART: START

Initialize DS AL Data1 BL Data2

AL

2`S Complement of AL AX AL*BL Data memory AX

AL

Data1

AL

2`S Complement of AL AX signed AL AX AX/BL Data memory AX

STOP

ADITYA ENGINEERING COLLEGE

22

MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand

ECE Dept.

Comments

ADITYA ENGINEERING COLLEGE

23

MICROPROCESSORS LAB OBSERVATION MANUAL CALCULATIONS:

ECE Dept.

ADITYA ENGINEERING COLLEGE

24

MICROPROCESSORS LAB OBSERVATION RESULT:

ECE Dept.

ADITYA ENGINEERING COLLEGE

25

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

Exp No: Date:


2.2 e) ASCII ARITHMETIC OPERATIONS ABSTRACT: Assembly language program to perform ASCII arithmetic operations PORT USED: None REGISTERS USED: AL, BL, SI ALGORITHM: Step1: Start Step2: Initialize data segment Step3: Load SI with Memory location Step4: Load AL with first number in ASCII form Step5: Load BL with Second number in ASCII form Step6: Perform addition Step7: Perform ASCII adjustment after addition Step8: Store the result to the data memory Step9: Load AL with first number in ASCII form Step10: Perform subtraction Step11: Perform ASCII adjustment after subtraction Step12: Store the result to the data memory Step13: Load AL with first number Step14: Perform multiplication Step15: Perform ASCII adjustment after multiplication Step16: Store the result to the data memory Step17: Load AL with first number Step18: Perform ASCII adjustment before division Step19: Perform division Step20: Store the result to the data memory Step21: Stop FLOW CHART: START

Initialize DS AL ASCII 1 BL ASCII 2

AL AL+BL Ascii Adjustment after addition Data Memory AX AL C Ascii 1

ADITYA ENGINEERING COLLEGE

26

MICROPROCESSORS LAB OBSERVATION


C

ECE Dept.

AL AL-BL Ascii Adjustment after subtraction Data Memory AX

AL BL

Data1 Data2

AX AL*BL Ascii Adjustment after Multiplication Data Memory AX

Ascii Adjustment before division AX AL / BL Data Memory AX

STOP PROGRAM: ASSUME CS: CODE, DS: DATA DATA SEGMENT N1 DB 8 N2 DB 4 DATA ENDS CODE SEGMENT ORG 1000H START: MOV AX, DATA MOV DS, AX MOV SI, 5000H XOR AX, AX MOV AL,N1 MOV BL,N2 ADD AL ,BL AAA MOV[ SI], AX MOV AL, N1 SUB AL, BL AAS MOV [SI+2], AX MOV AL, 08H

ADITYA ENGINEERING COLLEGE

27

MICROPROCESSORS LAB OBSERVATION MOV BL, 04H MUL BL AAM MOV [SI+4], AX AAD DIV BL MOV [SI+6], AX MOV AH, 4CH INT 21H CODE ENDS END START

ECE Dept.

CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand Comments

ADITYA ENGINEERING COLLEGE

28

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

MANUAL CALCULATIONS:

ADITYA ENGINEERING COLLEGE

29

MICROPROCESSORS LAB OBSERVATION RESULT:

ECE Dept.

ADITYA ENGINEERING COLLEGE

30

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

Exp No: Date:


2.3 a) BCD TO ASCII CONVERSION ABSTRACT: Assembly language program to convert BCD number to ASCII number PORT USED: None REGISTERS USED: AL, AH, CX ALGORITHM: Step1: Start Step2: Initialize data segment Step3: Load AL with BCD number Step4: Copy the contents from AL to AH Step5: Perform AND operation on AL with 0Fh Step6: Perform AND operation on AL with F0h Step7: Rotate the AH contents by four times Step8: Perform OR operation on AL with 30h Step10: Perform OR operation on AH with 30h Step11: Store the result to the memory location Step12: Stop FLOW CHART: START
Initialize DS AL BCD Num CL 04H

Al AL AH

AH AL .0FH AH .F0H

AH

Cir AH by CL times

AL AH Data Memory

AL+30h AH+30h AX

STOP

ADITYA ENGINEERING COLLEGE

31

MICROPROCESSORS LAB OBSERVATION PROGRAM:


ASSUME CS: CODE,DS: DATA DATA SEGMENT BCD DB 17H ASCII DW ? DATA ENDS CODE SEGMENT ORG 1000H START: MOV AX, DATA MOV DS, AX MOV AL, BCD MOV CL, 04 MOV AH, AL AND AL, 0FH AND AH, 0F0H ROR AH, CL OR AL, 30H OR AH, 30H MOV ASCII, AX MOV AH, 4CH INT 21H CODE ENDS END START

ECE Dept.

CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand Comments

ADITYA ENGINEERING COLLEGE

32

MICROPROCESSORS LAB OBSERVATION MANUAL CALCULATIONS:

ECE Dept.

ADITYA ENGINEERING COLLEGE

33

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

RESULT:

ADITYA ENGINEERING COLLEGE

34

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

Exp No: Date:


2.3 b) ASCII TO BCD CONVERSION ABSTRACT: Assembly language program convert ASCII number to BCD number PORT USED: None REGISTERS USED: AL, BL, CX ALGORITHM: Step1: Start Step2: Initialize data segment Step3: Load AL with ASCII number Step4: Copy the contents from AL to BL Step5: Perform AND operation on AL with 0Fh Step6: Perform AND operation on BL with 0Fh Step7: Rotate the AL contents by four times Step8: Perform OR operation on AL with BL Step9: Stop FLOW CHART: START

Initialize DS AL Ascii 1 BL Ascii 2 CL 04H

AL BL

AL .0FH BL .0FH

AL AL

Cir AL by CL times AL+BL AL

Data Memory

STOP

ADITYA ENGINEERING COLLEGE

35

MICROPROCESSORS LAB OBSERVATION


PROGRAM: ASSUME CS: CODE, DATA SEGMENT ASCII1 DB 1 ASCII2 DB 7 BCD DB ? DATA ENDS CODE SEGMENT ORG 1000H START:MOV AX, DATA MOV DS, AX MOV CL, 04H MOV AL, ASCII1 MOV BL, ASCII2 AND AL, 0FH AND BL, 0FH ROR AL, CL OR AL, BL MOV BCD, AL MOV AH, 4CH INT 21H CODE ENDS END START

ECE Dept.

DS: DATA

CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand Comments

ADITYA ENGINEERING COLLEGE

36

MICROPROCESSORS LAB OBSERVATION MANUAL CALCULATIONS:

ECE Dept.

ADITYA ENGINEERING COLLEGE

37

MICROPROCESSORS LAB OBSERVATION RESULT:

ECE Dept.

ADITYA ENGINEERING COLLEGE

38

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

Exp No: Date:


2.3 c) POSITIVE AND NEGATIVE COUNT IN AN ARRAY NUMBERS
ABSTRACT: Assembly language program to count number of positive and negative numbers PORT USED: None REGISTERS USED: SI, DX, CX, AL ALGORITHM: Step1: Start Step2: Initialize data segment Step3: Load CX register with count value Step4: Initialize DX with 0000h Step5: Load SI with offset list Step6: Copy the contents from memory location SI to AL Step7: Rotate left the content of AL Step8: Jump to step13 if carry Step9: Increment DL Step10: Increment SI Step11: Decrement CX and jump to step6 if no zero Step12: Jump to step16 Step13: Increment DH Step14: Increment SI Step15: Decrement CX and jump to step6 if no zero Step16: Store the result to the data memory Step17: Stop

PROGRAM:
ASSUME CS: CODE, DS: DATA DATA SEGMENT LIST DB 0FFH, 0DDH, 04H, 05H, 98H RESULT DW ? DATA ENDS CODE SEGMENT ORG 1000H START:MOV AX, DATA MOV DS, AX LEA SI, LIST MOV CX, 0005H MOV DX, 0000H BACK:MOV AL, [SI] ROL AL, 01H JC NEGATIVE INC DL INC SI LOOP BACK JMP EXIT NEGATIVE: INC DH INC SI LOOP BACK EXIT: MOV [RESULT], DX MOV AH, 4CH INT 21H CODE ENDS

ADITYA ENGINEERING COLLEGE

39

MICROPROCESSORS LAB OBSERVATION


END START

ECE Dept.

FLOW CHART: START


Initialize DS CX COUNT SI Offset LIST DX 0000h

AL

[SI]

AL

Cir left AL NO

YES

CF=1

DH SI

DH+1 SI+1

DL SI

DL+1 SI +1

CX

CX-1

NO

CX=0
YES YES Data memory DX

STOP

ADITYA ENGINEERING COLLEGE

40

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand Comments

ADITYA ENGINEERING COLLEGE

41

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

MANUAL CALCULATIONS:

ADITYA ENGINEERING COLLEGE

42

MICROPROCESSORS LAB OBSERVATION RESULT:

ECE Dept.

ADITYA ENGINEERING COLLEGE

43

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

Exp No: Date:


2.3 d) ODD AND EVEN COUNT IN AN ARRAY NUMBERS
ABSTRACT: Assembly language program to count number of odd and even numbers PORT USED: None REGISTERS USED: AL, CX, DL, DH, SI ALGORITHM: Step1: Start Step2: Initialize data segment Step3: Load CX register with count Step4: Initialize DX with 0000 Step5: Load SI with offset list Step6: Copy the contents from memory location SI to AL Step7: Rotate right the content of AL Step8: Jump to step13 if carry Step9: Increment DL Step10: Increment SI Step11: Decrement CX and jump to step6 if no zero Step12: Jump to step16 Step13: Increment DH Step14: Increment SI Step15: Decrement CX and jump to step6 if no zero Step16: Store the result to the data memory Step17: Stop

PROGRAM:
ASSUME CS: CODE, DS: DATA DATA SEGMENT LIST DB 05H,01H,03H,04H,08H,02H COUNT DW 0006H RESULT DW? DATA ENDS CODE SEGMENT ORG 1000H START:MOV AX, DATA MOV DS, AX MOV CX, COUNT MOV DX, 0000H MOV SI, OFFSET LIST BACK: MOV AL, [SI] ROR AL, 01H JC ODD INC DL INC SI LOOP BACK JMP EXIT ODD: INC DH INC SI LOOP BACK EXIT: MOV [RESULT], DX MOV AH, 4CH INT 21H CODE ENDS END START

ADITYA ENGINEERING COLLEGE

44

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

FLOW CHART:

START

Initialize DS CX COUNT SI Offset LIST DX 0000h

AL

[SI]

AL YES

Cir right AL NO

CF=1

DH SI

DH+1 SI+1

DL SI

DL+1 SI +1

CX NO

CX-1

CX=0
YES Data memory DX

STOP

ADITYA ENGINEERING COLLEGE

45

MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand

ECE Dept.

Comments

ADITYA ENGINEERING COLLEGE

46

MICROPROCESSORS LAB OBSERVATION MANUAL CALCULATIONS:

ECE Dept.

ADITYA ENGINEERING COLLEGE

47

MICROPROCESSORS LAB OBSERVATION RESULT:

ECE Dept.

ADITYA ENGINEERING COLLEGE

48

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

Exp No: Date:


2.3 e) PACKED BCD TO UNPACKED BCD CONVERSION ABSTRACT: Write a program to convert packed BCD number into Unpacked BCD number. REGISTERS USED: AL, BL PORTS USED: None. ALOGARITHM: Step1: Start Step2: Initialize the data segment Step3: Copy packed number into AL register Step4: Copy packed number into BL register Step5: Initialize the count CX with 04h Step6: Perform AND operation on AL with 0Fh Step7: Perform AND operation on BL with 0F0h Step8: Rotate right without carry operation on BL by CL times Step9: Move the result data memory Step10: Stop PROGRAM: ASSUME CS: CODE, DS: DATA DATA SEGMENT N EQU 29H RESULT DB 02H DUP (0) DATA ENDS CODE SEGMENT ORG 2000h START:MOV AX, DATA MOV DS, AX MOV AL, N MOV BL, N MOV CL, 04H AND AL, 0Fh AND BL, 0F0h ROR BL, CL MOV [RESULT], BL MOV [RESULT+1], AL MOV AH, 4Ch INT 21h CODE ENDS END START

ADITYA ENGINEERING COLLEGE

49

MICROPROCESSORS LAB OBSERVATION START FLOW CHART:


AL Initialize DS Packed BCD Num CL 04H

ECE Dept.

BL AL BL

AL AL .0FH BL .F0H

BL

Cir BL by CL times

Data Memory

AL, BL

CODE TABLE: Physical Address Segment Address Offset Address Label

STOP Hex Code Mnemonic operand Comments

ADITYA ENGINEERING COLLEGE

50

MICROPROCESSORS LAB OBSERVATION MANUAL CALCULATIONS:

ECE Dept.

RESULT:

ADITYA ENGINEERING COLLEGE

51

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

Exp No: Date:


2.4 a) MOVE BLOCK OF DATA ABSTRACT: Assembly language program to transfer a block of data. PORT USED: None. REGISTERS USED: AX, BL. ALGORITHM: Step1: Start Step2: Initialize data segment & extra segment Step3: Define the String Step4: Load CX register with length of the String Step5: Initialize DI with memory location Step6: Load SI with offset list Step7: Repeat the process of moving string byte from SI to DI until CX equals to zero Step8: Stop

FLOW CHART:

START

Initialize DS, ES Offset string DI Memory location CX Count SI

ES: DI CX SI DI

DS: SI CX-1 SI+1 DI+1

NO

CX=0

YES

STOP

ADITYA ENGINEERING COLLEGE

52

MICROPROCESSORS LAB OBSERVATION PROGRAM: ASSUME CS: CODE, DS: DATA, ES: DATA DATA SEGMENT LIST DB ADITYA COUNT EQU 06H DATA ENDS CODE SEGMENT ORG 1000H START: MOV AX, DATA MOV DS, AX MOV ES, AX MOV CX, COUNT MOV DI, 5000H LEA SI, LIST CLD REP MOVSB MOV AH, 4CH INT 21H CODE ENDS END START CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand

ECE Dept.

Comments

ADITYA ENGINEERING COLLEGE

53

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

MANUAL CALCULATIONS:

RESULT:

ADITYA ENGINEERING COLLEGE

54

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

Exp No: Date:


2.4 b) REVERSAL OF GIVEN STRING
ABSTRACT: Assembly language program to reverse a given string PORT USED: None REGISTERS USED: AX, BL ALGORITHM: Step1: Start Step2: Initialize data segment & extra segment Step3: Load CX register with count Step4: Copy the contents from CX to AX Step5: Load SI with offset list Step6: Initialize DI with (count-1) Step7: Initialize BX with 02 Step8: Perform division with BX Step9: Copy the contents from AX to CX Step10: Move the contents from memory location SI to AL Step11: Exchange the contents of AL with [DI] Step12: Move the contents from memory location AL to SI Step13: Increment SI Step14: Decrement DI Step15: Decrement CX and jump to step10 if no zero Step16: Stop PROGRAM: ASSUME CS: CODE, DS: DATA DATA SEGMENT LIST DB MICRO PROCESSOR COUNT EQU ($-LIST) DATA ENDS CODE SEGMENT ORG 1000H START: MOV AX, DATA MOV DS, AX MOV ES, AX MOV CX, COUNT MOV AX, CX MOV SI, OFFSET LIST MOV DI, (COUNT-1) MOV BX, 02 DIV BX MOV CX, AX BACK: MOV AL,[SI] XCHG AL,[DI] MOV [SI], AL INC SI DEC DI LOOP BACK MOV AH, 4CH INT 21H CODE ENDS END START

ADITYA ENGINEERING COLLEGE

55

MICROPROCESSORS LAB OBSERVATION FLOWCHART:

ECE Dept.

START

Initialize DS, ES SI Offset string BX 0002h CX Count DI Count-1

CX AX, DX CX

AX AX/BX AX

AL AL NO [SI]

[SI] [DI] AL

SI DI CX

SI+1 DI+1 CX-1

NO

CX=0
YES

STOP

ADITYA ENGINEERING COLLEGE

56

MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand

ECE Dept.

Comments

ADITYA ENGINEERING COLLEGE

57

MICROPROCESSORS LAB OBSERVATION MANUAL CALCULATIONS:

ECE Dept.

ADITYA ENGINEERING COLLEGE

58

MICROPROCESSORS LAB OBSERVATION RESULT:

ECE Dept.

ADITYA ENGINEERING COLLEGE

59

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

Exp No: Date:


2.4 C) SORTING OF N NUMBERS
ABSTRACT: Assembly language program to do sorting of numbers in a given series PORT USED: None REGISTERS USED: CX, DX, AL, SI ALGORITHM: Step1: Start Step2: Initialize data segment Step3: Load CX register with count Step4: Copy the contents from CX to DX Step5: Load SI with offset list Step6: Copy the contents from DX to CX Step7: Move the contents from memory location SI to AL Step8: Increment SI Step9: Compare AL contents with [SI] Step10: Jump to step15 if carry Step11: Exchange the contents of AL with [SI] Step12: Decrement SI Step13: Move the contents from AL to memory location SI Step14: Increment SI Step15: Decrement CX and jump to step7 if no zero Step16: Decrement DX and jump to step5 if no zero Step17: Stop

PROGRAM:
ASSUME CS: CODE, DS: DATA DATA SEGMENT LIST DB 56H, 12H, 72,32H COUNT EQU 0003H DATA ENDS CODE SEGMENT ORG 1000H START: MOV AX, DATA MOV DS, AX MOV CX, COUNT MOV DX, CX AGAIN: MOV SI, OFFSET LIST MOV CX, DX BACK: MOV AL, [SI] INC SI CMP AL, [SI] JC NEXT XCHG [SI], AL DEC SI MOV [SI], AL INC SI NEXT: LOOP BACK DEC DX JNZ AGAIN MOV AH, 4CH INT 21H CODE ENDS END START

ADITYA ENGINEERING COLLEGE

60

MICROPROCESSORS LAB OBSERVATION FLOW CHART: START

ECE Dept.

Initialize DS CX Count DX Count SI CX Offset list DX

AL [SI] SI SI+1 Compare AL, [SI]

CF=1
YES NO [SI ] SI [SI] AL SI-1 AL

CX

CX-1

NO

CX=0 YES DX DX-1

NO

DX=0 YES

STOP

ADITYA ENGINEERING COLLEGE

61

MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Label Segment Address Offset Address Hex Code Mnemonic operand

ECE Dept.

Comments

ADITYA ENGINEERING COLLEGE

62

MICROPROCESSORS LAB OBSERVATION MANUAL CALCULATIONS:

ECE Dept.

ADITYA ENGINEERING COLLEGE

63

MICROPROCESSORS LAB OBSERVATION MANUAL CALCULATIONS:

ECE Dept.

ADITYA ENGINEERING COLLEGE

64

MICROPROCESSORS LAB OBSERVATION RESULT:

ECE Dept.

ADITYA ENGINEERING COLLEGE

65

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

Exp No: Date:


2.4 d) LENGTH OF THE GIVEN STRING
ABSTRACT: Assembly language program to find the Length of a string PORT USED: None REGISTERS USED: AX, BL ALGORITHM: Step1: Start Step2: Initialize data segment & extra segment Step3: Load AL with $ Step4: Load SI with offset list Step5: Initialize DX with 0000 Step6: Scan string byte from DI memory location until AL =ES: DI Step7: Jump to step10 if equal Step8: Increment DX Step9: Jump to step6 Step10: Store the result to the memory location Step11: Stop

PROGRAM: ASSUME CS: CODE, DS: DATA, ES: DATA DATA SEGMENT LIST DB ADITYA$ LEN DB ? DATA ENDS CODE SEGMENT ORG 1000H START: MOV AX, DATA MOV DS, AX MOV ES, AX MOV AL,$ LEA DI, LIST MOV DX, 0000H CLD BACK: SCASB JE EXIT INC DX JMP BACK EXIT: MOV LEN, DX MOV AH, 4CH INT 21H CODE ENDS END START

ADITYA ENGINEERING COLLEGE

66

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

FLOW CHART:

START

DI DX AL

Initialize DS, ES Offset string 0000h NULL Character

Compare AL, ES:[DI]

YES

ZF=0
NO DX DI Data memory DX+1 DI+1 DX

STOP

ADITYA ENGINEERING COLLEGE

67

MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand

ECE Dept.

Comments

ADITYA ENGINEERING COLLEGE

68

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

MANUAL CALCULATIONS:

ADITYA ENGINEERING COLLEGE

69

MICROPROCESSORS LAB OBSERVATION RESULT:

ECE Dept.

ADITYA ENGINEERING COLLEGE

70

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

Exp No: Date:


2.4 e) COMPARISON OF TWO STRINGS ABSTRACT: Assembly language program to compare two strings. PORT USED: None REGISTERS USED: AX, BL ALGORITHM: Step1: Start Step2: Initialize data segment & extra segment Step3: Load AX with length of String 1 Step4: Load BX with length of String 2 Step5: Compare AX with BX Step6: Jump step14 if not equal Step7: Copy the contents from AX to CX Step8: Load SI with first location of string 1 Step9: Load DI with first location of string 2 Step10: Repeat comparing string byte until count equals to zero Step11: jump to step 14 if not equal Step12: Store the result to the data memory Step13: Jump to step 15 Step14: Store another result to the data memory Step15: Stop PROGRAM:
ASSUME CS: CODE, DS: DATA, ES: DATA DATA SEGMENT LIST1 DB ADITYA LEN1 EQU ($-LIST1) LIST2 DB ADITYA LEN2 EQU ($-LIST2) RESULT DW ? DATA ENDS CODE SEGMENT ORG 1000H START: MOV AX, DATA MOV DS, AX MOV ES, AX MOV AX.LEN1 MOV BX, LEN2 CMP AX, BX JNE EXIT MOV CX, AX MOV SI, OFFSET LIST1 MOV DI, OFFSET LIST2 CLD REP CMPSB JNE EXIT MOV RESULT, 5555H JMP NEXT EXIT: MOV RESULT, 0FFFFH NEXT: MOV AH, 4CH INT 21H CODE ENDS END START

ADITYA ENGINEERING COLLEGE

71

MICROPROCESSORS LAB OBSERVATION FLOW CHART:

ECE Dept.

START

Initialize DS, ES SI Offset string1 DI Offset String2 AX Length1 BX Length2

Compare AX, BX

NO

ZF=0
YES CX AX

Repeat Compare ES: DI,DS:SI NO

ZF=0 YES

Data memory

Yes

Data memory

NO

STOP

ADITYA ENGINEERING COLLEGE

72

MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand

ECE Dept.

Comments

ADITYA ENGINEERING COLLEGE

73

MICROPROCESSORS LAB OBSERVATION MANUAL CALCULATIONS:

ECE Dept.

ADITYA ENGINEERING COLLEGE

74

MICROPROCESSORS LAB OBSERVATION RESULT:

ECE Dept.

ADITYA ENGINEERING COLLEGE

75

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

Exp No: Date:


2.5 a) READING KEYBOARD BUFFERED WITH ECHO ABSTRACT: To Read the Keyboard Buffered with Echo. REGISTERS USED: AH, AL, SI. PORTS USED: None. ALGORITHM: Step1: Start. Step2: Load the number 13h into AL register. Step3: Initialize the AH register with 00h Step4: Display interrupt Step5: Initialize the AH register with 00h Step6: Key board Interrupt Step7: Compare the data in AL register with character q. Step8: If equal to zero go to step 12. Step9: Move the number 0Fh into BL register. Step10: Move the number 14 into AH register. Step11: Keyboard Interrupt. Step12: Load the number 4C in AH register. Step13: Stop. PROGRAM: ASSUME CS: CODE, DS: DATA CODE SEGMENT ORG 1000h START: MOV AL, 13h MOV AH, 00 INT 10h BACK: MOV AH, 00h INT 16h CMP AL, q JE EXIT MOV BL, 0Fh MOV AH, 14 INT 10h JMP BACK EXIT: MOV AH, 4Ch INT 21h CODE ENDS END START

ADITYA ENGINEERING COLLEGE

76

MICROPROCESSORS LAB OBSERVATION FLOW CHART:

ECE Dept.

START

AL 13h AH 00H Interrupt 10H

AH 00H Interrupt 10H Compare AL, q

YES ZF=0 NO BL 0Fh AH 14 Interrupt 10H

STOP

ADITYA ENGINEERING COLLEGE

77

MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand

ECE Dept.

Comments

RESULT:

ADITYA ENGINEERING COLLEGE

78

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

Exp No: Date:


2.5 b) READING KEYBOARD BUFFERED WITHOUT ECHO ABSTRACT: To read the string or character from keyboard without ECHO by using BIOS Commands. REGISTERS USED: AH, AL, SI PORTS USED: None. ALGORITHM: Step1: Start Step2: Initialize SI with Offset Result. Step3: Initialize AH with 00h Step4: Keyboard Interrupt Step5: Compare AL with character q. Step6: Copy the contents AL into SI register. Step7: If equal to zero go to step 10 Step8: Increment SI. Step9: Go to step 3 without condition. Step10: Terminate the program. Step11: Stop. PROGRAM: ASSUME CS: CODE, DS: DATA DATA SEGMENT ORG 3000h RESULT DB 50h DUP (0) DATA ENDS CODE SEGMENT ORG 1000h START: MOV SI, OFFSET RESULT BACK: MOV AH, 00h INT 16h CMP AL, q MOV [SI], AL JE EXIT INC SI JMP BACK EXIT: MOV AH, 4Ch INT 21h CODE ENDS END START

ADITYA ENGINEERING COLLEGE

79

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

FLOW CHART: START

Initialize DS, CS SI 2000H

AH 00H Interrupt 16H Compare AL, q

YES ZF=0 NO [SI] SI AL SI+1

STOP CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand Comments

ADITYA ENGINEERING COLLEGE

80

MICROPROCESSORS LAB OBSERVATION RESULT:

ECE Dept.

ADITYA ENGINEERING COLLEGE

81

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

Exp No: Date:


2.5 c) DISPLAY STRING BY USING BIOS COMMANDS
ABSTRACT: To display the string character by using BIOS commands. REGISTER USED: AL, AH, SI. PORTS USED: None ALGORITHM:

Step1: Start Step2: Set the screen in Graphic mode Step3: Initialize AH with 00h Step4: Set the keyboard display mode. Step5: Initialize SI with 0000h. Step6: Copy the contents SI into AL register. Step7: Compare AL register with null character ! Step8: If equal go to step 11. Step9: Move the number 14 into AH register. Step10: Move the number 05h into BL register. Step11: Set keyboard display mode. Step12: Go to step 6. Step 13: Terminate the program. Step14: Stop. PROGRAM:
ASSUME CS: CODE, DS: DATA DATA SEGMENT TEXT DB ADITYA MICROPROCESSORS LAB!' DATA ENDS CODE SEGMENT ORG 1000H START: AX, DATA MOV DS, AX MOV AL, 13H; SET the screen in graphics mode MOV AH, 00 INT 10H MOV SI, 00H BACK: MOV AL, TEXT [SI] CMP AL,'!' JE EXIT MOV AH, 14 MOV BL, 05H INT 10H INC SI JMP BACK EXIT: MOV AH, 4CH INT 21H CODE ENDS END START

ADITYA ENGINEERING COLLEGE

82

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

FLOW CHART:

START

SI

Initialize DS Offset Text AL 13h AH 00H Interrupt 10H AL Text [SI] Compare AL, q

YES ZF=0 NO BL 0Fh AH 14 Interrupt 10H SI SI+1

STOP

ADITYA ENGINEERING COLLEGE

83

MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand

ECE Dept.

Comments

RESULT:

ADITYA ENGINEERING COLLEGE

84

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

Exp No: Date:


3.1 DIGITAL TO ANALOG CONVERTER GENERATION OF WAVE FORMS: AIM: program to generate the following wave forms: Triangular wave forms Saw tooth wave forms Square wave REGISTERS USED: general purpose registers: AL, DX, and CX PORTS USED: Out (port-B) CONNECTION: J4 of ESA 86/88 to J1 DAC interface. DESCRIPTIONS: As can be from the circuit only 17 lines from the connector are used totally. The port A and port B of 8255 programmable peripheral interface are used as output ports. The digital inputs to the DACs are provided through the port A and port B of 8255.the analog outputs of the DACs are connected to the inverting inputs of op-amps A741 which acts as current to voltage converters. The out puts from the op- amps are connected to points marked Xout and Yout at which the wave forms are observed on a CRO. (port A is used to control Xout port B is used to control Yout).the difference voltage for the DACs is derived from an on-board voltage regulator A 723 .it generates a voltage of about 8V.the offset balancing of the op-amps is done by making use of the two 10k pots provided. The output wave forms are observed at Xout and Yout on an oscillator. THEORY: BASIC DAC TECHNIQUE: Vo = K VFS (d1 .2-1 + d2 . 2-2 + . . . . . . . .+dn . 2-n ) Where d1 = MSB, d2 = LSB VFS = Full scale reading / out put voltage K --- Conversion factor is adjusted to unity. D/A converters consist of n bit binary word Dand is combined with a reference voltage VR to give an analog output. The out put can be either voltage or current Out put voltage Vo = K VFS (d1 .2-1 + d2. 2-2 + . . . . . . . . +dn. 2-n) MSB weight = VFS if d1 = 1 and all are zeros, K = 1. LSB weight = VFS/2n if dn = 1 and all are zeros, K = 1 DUAL DAC INTERFACE: This program generates a square wave or a Triangular wave at points Xout or Yout of interface. The waveforms may be observed on an oscilloscope.

ADITYA ENGINEERING COLLEGE

85

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

This program can be executed in STAND-ALONE MODE or SERIAL MODE of operation. The program starts at memory location 3000H ALGORITHM: (FOR TRIANGULAR WAVE): Step 1: Start Step 2: Initialize the control word register with all ports as simple I/O mode Step 3: Load Maximum Amplitude value to CX register. Step 4: Load 00 to AL register. Step 5: Initialize the port A address. Step 6 : Locate the contents of AL to DX register. Step 7: Increment the value in AL by one. Step 8: Locate AL contents to DX register. Step 9: Decrement the value of CX register by one and go to step 6 if CX not equal to zero. Step 10: Load 00FF to CX register. Step 11: Decrement the value of AL by one. Step 12: Locate the contents in AL register to DX register. Step 13: Decrement the value of CX by one and go to step 12 if CX not equal to zero. Step 14: Otherwise move to step 3 Step 15: Stop. PROGRAM (FOR TRIANGULAR WAVE): MOV DX, 0FFE6 MOV AL, 80 OUT DX, AL MOV DX, 0FFE0 MOV AL, 00 RPT: MOV CX, 0FF L1 : OUT DX, AL INC AL LOOP L1 MOV CX, 0FF L2 : OUT DX,AL DEC AL LOOP L2 JMP RPT

ADITYA ENGINEERING COLLEGE

86

MICROPROCESSORS LAB OBSERVATION FLOW CHART:

ECE Dept.

START

DX AL [DX] DX AL CX [DX] AL CX

Addr. Of CWR 80 AL

Addr. Of Port-A 00 FFH AL AL+1 CX-1

CX=0
NO YES CX FFH

[DX] AL CX

AL AL-1 CX-1

NO

CX=0 YES

ADITYA ENGINEERING COLLEGE

87

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand Comments

RESULT:

ADITYA ENGINEERING COLLEGE

88

MICROPROCESSORS LAB OBSERVATION ALGORITHM (FOR SAW TOOTH WAVE):

ECE Dept.

Step 1: Start Step 2: Initialize the control word register with all ports as simple I/O mode Step 3: Load Maximum Amplitude value to CX register. Step 4: Load 00 to AL register. Step 5: Initialize the port A address. Step 6 : Locate the contents of AL to DX register. Step 7: Increment the value in AL by one. Step 8: Locate AL contents to DX register. Step 9: Decrement the value of CX register by one and go to step 6 if CX not equal to zero.

Step 10: Go to step 4 and Repeat


PROGRAM (FOR SAW TOOTH WAVE):
MOV DX, 0FFE6 MOV AL, 80 OUT DX,AL MOV DX, 0FFE0 MOV AX, 00 RPT: MOV CX, 0FF L1: OUT DX, AX INC AX LOOP L1 MOV AX, 00 OUT DX, AX JMP RPT

FLOW CHART: START

DX AL [DX] DX AL CX [DX] AL CX

Addr. Of CWR 80 AL

Addr. Of Port-A 00 FFH AL AL+1 CX-1

CX=0
NO YES

ADITYA ENGINEERING COLLEGE

89

MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand

ECE Dept.

Comments

RESULT:

ADITYA ENGINEERING COLLEGE

90

MICROPROCESSORS LAB OBSERVATION ALGORITHM (FOR SQUARE WAVE): Step 1: Start Step 2: Initialize the control word register with all ports as simple I/O mode Step 3: Load Maximum Amplitude value to AX register. Step4: Initialize the port A address. Step 6 : Transmit the contents of AX to port A Step 7: Create Delay Step 8: Load Minimum Amplitude value to AX register. Step 9: Transmit the contents of AX to port A Step 10: Create Delay Step 11: Go to Step 3 and Repeat ALGORITHM FOR DELAY Step 1: Load the CX register with 93h Step 2: Decrement CX Step 3: Repeat Step 2 till CX is zero Step4: Return to main program PROGRAM (FOR SQUARE WAVE): MOV DX, 0FFE6 MOV AL, 80 OUT DX, AL MOV DX, 0FFE0 RPT: MOV AX, 0FF OUT DX, AX CALL DELAY MOV AX, 00 OUT DX, AX CALL DELAY JMP RPT DELAY PROGRAM: MOV CX, 1E L1: NOP NOP LOOP L1 RET

ECE Dept.

ADITYA ENGINEERING COLLEGE

91

MICROPROCESSORS LAB OBSERVATION FLOW CHART: START

ECE Dept.

DX AL [DX] DX AL CX [DX] CX

Addr. Of CWR 80 AL

Addr. Of Port-A 00 COUNT AL CX-1

CX=0
NO YES CX AL [DX] CX COUNT FFH AL CX-1

NO

CX=0 YES

ADITYA ENGINEERING COLLEGE

92

MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand

ECE Dept.

Comments

RESULT:

ADITYA ENGINEERING COLLEGE

93

MICROPROCESSORS LAB OBSERVATION ALGORITHM (FOR SINE WAVE): Step 1: Start Step 2: Move the control word address 0FFE6 to register DX Step 3: Move 80 to AL register. Step 4: Locate the contents in AL register to DX register using port out. Step 5: Initialize the SI with 4000h location. Step 6: Move the number 46 into the counter CX register. Step 7: Initialize the Port A address ie. 0FFE0 Step 8: Move the contents SI into AL register. Step 9: Locate the contents in AL register to DX register using port out.. Step 10: Increment the value of SI. Step 11: Decrement the counter and go to Step 8 until CX =0 Step 12: Jump to location step 5. Step 13: Stop. PROGRAM FOR SINE WAVE: MOV DX, 0FFE6 MOV AL, 80 OUT DX, AL RPT: MOV SI, 4000 MOV CL, 46 MOV DX, 0FFE0 L1: MOV AL, [SI] OUT DX, AL INC SI LOOP L1 JMP RPT

ECE Dept.

ADITYA ENGINEERING COLLEGE

94

MICROPROCESSORS LAB OBSERVATION FLOW CHART: START


EFFECTIVE ADDRESS 4000 4004 4008 400C 4010 4014 4018 401C 4020 4024 4028 402C 4030 4034 4038 403C 4040 4044

ECE Dept.

HEX CODES 7F AA D1 ED FC FC ED D1 AA 7F 53 2D 10 01 07 1D 3F 8A B5 D9 F2 FE FA E7 C8 A0 74 49 25 0B 00 0B 25 49 69 95 BF E0 F7 FF F7 E0 BF 95 69 3F 1D 07 01 10 2D 53 74 A0 C8 E7 FA FE F2 D9 B5 8A 5F 36 17 04 04 17 36 5F

DX AL [DX] DX SI

Addr. Of CWR 80 AL

Addr. Of Port-A Memory location CX Count AL [DX] SI CX [SI] AL SI+1 CX-1

NO

CX=0
YES

ADITYA ENGINEERING COLLEGE

95

MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand

ECE Dept.

Comments

RESULT:

ADITYA ENGINEERING COLLEGE

96

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

Exp No: Date:


3.2. KEYBOARD INTERFACING AIM: To display a string through interfacing 8279. REGISTERS USED: AX, BX, CX, DX, SI PORTS USED: command port, data port CONNECTIONS: 8279 study card P1 to J2 of ESA 86/88 study card adapter. DESCRIPTION:8279 study card provides keyboard as well as display section. The display section features size 8 digit seven segment displays while the keyboard connections comprises a 4x 4 matrix hex key pad and associated circuitry. The options for using shift and controls keys during key scanning are also provided. The interface has 3 connectors, P1, J1, & J4 to interface the card with ESA 86/88E trainers. Connect the 50 pin FRC connectors P1 to connector J2 to ESA 86/88E study card adapter. INTRODUCTION: In many microprocessors-based systems, calculator keypad is used as an input device. A calculator keypad can be interfaced to a microprocessor using a dedicated peripheral controller like INTEL 8279Akeyboard/display controller. In this case, the controller can handle the interface problems like key debounce, 2-key lock-out, N-key roll-over etc,. Further such an alternative approach, the calculator keypad interface is passive and software is used for encoding the key positions and for handling problems like key debounce, roll-over etc. The present interface module provides a calculator style calculator keypad consisting of the key 0 to 9 , + ,- , ,= ,% , . , C, CE and two spare keys. These 20 keys are arranged in a 38 matrix (the third row has only four keys). The row lines can be driven through port C and the status of column lines can be read through port A. this interface allows the user to study a number of techniques generally used in calculator keypad interfacing. User can write programs for software debouncing of key closures, two key understanding of keyboard interface. Further , user can become familiar with the arithmetic group of processor instructions by implementing the calculator functions like addition, subtraction, multiplication , diversion, percentage etc.. THEORY: A programmable keyboard and display interfacing chip. o Scans and encodes up to a 64-key keyboard. o Controls up to a 16-digit numerical display. Keyboard has a built-in FIFO 8 character buffer The display is controlled from an internal 16x8 RAM that stores the coded display information

ADITYA ENGINEERING COLLEGE

97

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

PIN OUT DEFINITION 8279 A0: Selects data (0) or control/status (1) for reads and writes between micro and 8279. BD: Output that blanks the displays. CLK: Used internally for timing. Max is 3 MHz. CN/ST: Control/strobe, connected to the control key on the keyboard. CS: Chip select that enables programming, reading the keyboard, etc. DB7-DB0: Consists of bidirectional pins that connect to data bus on micro. IRQ: Interrupt request, becomes 1 when a key is pressed, data is available. OUT A3-A0/B3-B0: Outputs that sends data to the most significant/least significant nibble of display. RD (WR): Connects to micros IORC or RD signal, reads data/status registers. RESET: Connects to system RESET. RL7-RL0: Return lines are inputs used to sense key depression in the keyboard matrix. Shift: Shift connects to Shift key on keyboard. SL3-SL0: Scan line outputs scan both the keyboard and displays.

ADITYA ENGINEERING COLLEGE

98

MICROPROCESSORS LAB OBSERVATION 8279 Interfaced to the 8088

ECE Dept.

Keyboard Interface of 8279

KEYBOARD INTERFACE OF 8279: The keyboard matrix can be any size from 2x2 to 8x8. Pins SL2-SL0 sequentially scan each column through a counting operation. o The 74LS138 drives 0s on one line at a time. o The 8279 scans RL pins synchronously with the scan. o RL pins incorporate internal pull-ups, no need for external resistor pull-ups. Unlike the 82C55, the 8279 must be programmed first.

ADITYA ENGINEERING COLLEGE

99

MICROPROCESSORS LAB OBSERVATION D7 D6 D5 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1


o

ECE Dept. Purpose

Function Mode set Clock Read FIFO Read Display Write Display Display write inhibit Clear End interrupt

0 1 0 1 0 1 0 1

Selects the number of display positions, type of key scan Programs internal clk, sets scan and debounce times. Selects type of FIFO read and address of the read. Selects type of display read and address of the read. Selects type of write and the address of the write. Allows half-bytes to be blanked. Clears the display or FIFO Clears the IRQ signal to the microprocessor.

The first 3 bits of # sent to control port selects one of 8 control words. Keyboard Interface of 8279 First three bits given below select one of 8 control registers (opcode). 000DDMMM o Mode set: Opcode 000. DD sets displays mode. MMM sets keyboard mode. DD field selects either: 8- or 16-digit display Whether new data are entered to the rightmost or leftmost display position. DD Function 00 8-digit display with left entry 01 16-digit display with left entry 10 8-digit display with right entry 11 16-digit display with right entry Keyboard Interface of 8279 o MMM field: DD Function 000 Encoded keyboard with 2-key lockout 001 Decoded keyboard with 2-key lockout 010 Encoded keyboard with N-key rollover 011 Decoded keyboard with N-key rollover 100 Encoded sensor matrix 101 Decoded sensor matrix 110 Strobed keyboard, encoded display scan
o o

111 Strobed keyboard, decoded display scan Encoded: SL outputs are active-high, follow binary bit pattern 0-7 or 0-15. Decoded: SL outputs are active-low (only one low at any time). Pattern output: 1110, 1101, 1011, 0111.

ADITYA ENGINEERING COLLEGE

100

MICROPROCESSORS LAB OBSERVATION


o

ECE Dept.

Strobed: An active high pulse on the CN/ST input pin strobes data from the RL pins into an internal FIFO for reading by micro later. o 2-key lockout/N-key rollover: Prevents 2 keys from being recognized if pressed simultaneously/Accepts all keys pressed from 1st to last. INTERFACE OF 8279 001PPPPP o The clock command word programs the internal clock driver. o The code PPPPP divides the clock input pin (CLK) to achieve the desired operating frequency, e.g. 100KHz requires 01010 for a 1 MHz CLK input. 010Z0AAA o The read FIFO control word selects the address (AAA) of a keystroke from the FIFO buffer (000 to 111). o Z selects auto-increment for the address. 011ZAAAA o The display read control word selects the read address of one of the display RAM positions for reading through the data port. 100ZAAAA o Selects write address Z selects auto-increment so subsequent writes go to subsequent display positions. INTERFACE OF 8279 1010WWBB o The display write inhibit control word inhibits writing to either the leftmost 4 bits of the display (left W) or rightmost 4 bits. o BB works similarly except that they blank (turn off) half of the output pins. 1100CCFA o The clear control word clears the display, FIFO or both o Bit F clears FIFO and the display RAM status, and sets address pointer to 000. If CC are 00 or 01, all display RAM locations become 00000000. If CC is 10, 00100000, if CC is 11, 11111111. 1110E000 o End of Interrupt control word is issued to clear IRQ pin in sensor matrix mode. 1) Clock must be programmed first. If 3.0 MHz drives CLK input, PPPPP is programmed to 30 or 11110. 2) Keyboard type is programmed next. o The previous example illustrates an encoded keyboard, external decoder used to drive matrix. 3) Program the FIFO. Once done, a procedure is needed to read data from the keyboard. o To determine if a character has been typed, the FIFO status register is checked. o When this control port is addressed by the IN instruction, the contents of the FIFO status word is copied into register AL: Code given in text for reading keyboard. Data returned from 8279 contains raw data that need to be translated to ASCII: o Row and column number are given the rightmost 6 bits (scan/return). o This can be converted to ASCII using the XLAT instruction with an ASCII code lookup table.

ADITYA ENGINEERING COLLEGE

101

MICROPROCESSORS LAB OBSERVATION


o o o

ECE Dept.

The CT and SH indicate whether the control or shift keys were pressed. The Strobed Keyboard code is just the state of the RLx bits at the time a 1 was strobed on the strobed input pin.

ALGORITHM:
Step 1: Start Step 2: Load SI with memory location. Step 3: Move 10 to AL register. Step 4: Load CX with count. Step 5: Initialize the Command word register i.e., 0FF42 Step 6: Locate the contents in AL register to DX register using port out. Step 7: Move D3 to AL register. Step 8: Locate the contents in AL register to DX register using port out. Step 9: Move 90 to AL register. Step 10: Locate the contents in AL register to DX register using port out Step 11: Initialize the Data Register address ie. 0FF40 Step 12: Move the contents SI into AL register. Step 13: Locate the contents in AL register to DX register using port out. Step 14: Create Delay. Step 15: Increment the value of SI. Step 16: Decrement the counter and go to Step 11 until CX =0 Step 17: Jump to location step 5.

ALGORITHM FOR DELAY Step 1: Load the DX register with 0FFFFh Step 2: Decrement DX Step 3: Repeat Step 2 till DX is zero Step4: Return to main program

PROGRAM:
START: MOV SI, 2000H MOV CX, 0008H MOV AL, 10 MOV DX, 0FF42 OUT DX, AL MOV AL, 0D3 OUT DX, AL MOV AL, 90 OUT DX, AL NEXT: MOV DX, 0FF40 MOV AL, [SI] OUT DX, AL CALL DELAY INC SI LOOP NEXT JMP START DELAY PROGRAM: MOV DX, 0FFFFH BACK: DEC DX JNZ BACK RET

INPUT DATA:
Segment address Offset address 2000 DATA INPUT 00 77 F3 60 87 E6 77

ADITYA ENGINEERING COLLEGE

102

MICROPROCESSORS LAB OBSERVATION FLOW CHART: START


SI Memory Location Addr. Of Command word of 8279 CX COUNT, AL 10H [DX] AL D3H AL

ECE Dept.

DX

[DX] AL 90H

AL

[DX]

AL

DX

Addr. Of Data register of 8279

AL SI [DX]

[SI] SI+1 AL

DX
DX

DELAY
DX-1

NO

DX=0
YES

CX

CX-1

NO

CX=0
YES

ADITYA ENGINEERING COLLEGE

103

MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand

ECE Dept.

Comments

RESULT:

ADITYA ENGINEERING COLLEGE

104

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

Exp No: Date:


ADDITIONAL PROGRAM 4.STEPPER MOTOR INTERFACING AIM: program to design a stepper motor to rotate shaft of a 4 phase stepper motor in clockwise 15 rotations. REGISTERS USED: General purpose registers: AL , DX , CX PORTS USED: Port B, port C (out) CONNECTIONS: J4 of ESA 86/88E to J1 of stepper motor. OPERATING PRINCIPLE OF PERMANENT MAGNET STEPPER MOTOR:

It consists of two stator windings A,B and a motor having two magnetic poles N and S. when a voltage +v is applied to stator winding A, a magnetic field Fa is generated. The rotor positions itself such that its poles lock with corresponding stator poles. With the winding A excited as before ,winding b is now to Fa. the resulting magnetic field F makes an angle of 450. the rotor consequently moves through 450 in anti clockwise direction, again to cause locking of rotor poles with corresponding stator poles. While winding B has voltage +V applied to it, winding A is switched off. The rotor then moves through a further 450 in anti-clockwise direction to aligne itself with stator field Fb. with voltage +V on winding B, a voltage V is applied to winding A. then the stator magnetic field has two components Fa , Fb and their resultant F makes an angle of 1350 position.

ADITYA ENGINEERING COLLEGE

105

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

In this way it can be seen that ,as the pattern of excitation of the state of winding is changed, the rotor moves successively through450 steps. And completes one full revolution in anti clock-wise direction. A practical PM stepper motor will have 1.80 step angle and 50 tooth on its rotor;there are 8 main poles on the stator, each having five tooth in the pole face. The step angle is given by A = 360 / (N * K) degrees Where N = number of rotor tooth. K = execution sequence factor. PM stepper motors have three modes of excitation i,e.. Single phase mode Two phase mode Hybrid mode Single phase mode: in this mode only one of the motor winding is excited at a time. There are four steps in the sequence, the excitation sequence factor K=2 ,so that step angle is 900. Two phase mode: Here both stators phase are excited at a time. There are four steps in the excitation sequence, K = 2 and the step angle is 900. However, the rotor positions in the two phase mode are 450 way from those in single phase mode. Hybrid mode: this is a combination of single and two phase modes. There are 8 steps in excitation sequence=2 and step angle = 450. a voltage +V is applied to a stator winding during some steps, which voltage V is applied during certain other steps. This requires a bipolar regulated power supply capable of yielding +V,-V and zero outputs and a air of SPDT switches, which is quite cumbersome. Consequently each of the two stator windings is split into two sections A1-A2 , B1-B2. these sections are wound differentially. These winding sections can now be excited from a univocal regulated power supply through switcher S1 to S4. this type of construction is called bipolar winding construction. Bipolar windingesults in reduced winding inductance and consequently improved torque stepping rate. Description: the stepper motor interfaces uses four transistor pairs (SL 100 and 2N 3055) in a Darlington pair configuration. Each Darlington pair is used to excite the particular winding of the motor connected to 4 pin connector on the interface. The inputs to these transistors are from the 8255 PPI I/O lines of the microprocessor kit or from digital I/O card plugged in the PC. port A lower nibble PA0 , PA1, PA2 , PA3 are the four lines brought out to the 26 pin FRC male connector(J1) on the interface module. The freewheeling diodes across each winding protect transistors from switching transients. Theory: A motor used for moving things in small increments is known as stepper motor. Stepper motor rotate from one fixed position to next position rather than continuous rotation as in case of other ac or dc motor stepper motors are used in printers to advance the paper from one position to advance the paper from one position to another in steps. They are also used to position the read/write head on the desired track of a floppy disk. To rotate the shaft the stepper motor a sequence of pulses are applied to the windings in a predefined sequence. The number of pulses required for one complete rotation per pulse is given by 3600/NT. where

ADITYA ENGINEERING COLLEGE

106

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

NT is the number of teeth on rotor. Generally the stepper motor is available with 10 to 300 rotation. They are available with two phases and four phase common field connections. Instead of rotating smoothly around and around as most motors, stepper motors rotate or step one fixed position to next. Common step size range from 0.90 to 300. it is stepped from one position to next by changing the currents through the fields in the motor. The two common field connections are referred to as two phase and four phase. The drive circuitry is simpler in 4 phase stepper. The figure shows a circuitry that can interface a small 4 stepper motor to four microcomputer port lines. The 7406 buffers are inverting, so. A high on ah output port pin turns on current to a winding. The purpose of clamp diodes across each winging is to save transistors from inductive kick. Resistors R1 and R2 are current limiting resistors. Typical parameters of stepper motor: 1. Operating voltage 2. Current rating 3. Step angle 12 volts 1.2 Amp 1.80 200(No. of teeth on rotor) 3 kg/cm

4. Step for revolution 5. Torque -

Working of stepper motor: Suppose that SW1 and SW2 are turned ON. Turning OFF SW2 and turning ON SW4 cause the motor to rotate one step of 1.80 clockwise. Changing to SW4 and SW3 ON will cause the motor to rotate 1.80 clockwise another. Changing SW3 and SW2 ON will cause another step. To step the motor in counter clock wise direction simply work through the switch sequence in the reverse direction. The switch pattern for changing from one step to another step in clockwise direction is simply rotated right one position. For counter clockwise direction rotated left one position ALGORITHM: Step 1: Start Step 2: move the control word address 0FFE6 to register DX Step 3: move 80 to AL register. Step 4: locate the contents in AL register to DX register using port out. Step 5:Intialize BX with 07d0 Step 6: move port A address ie.,,0FFE0 to DX register. Step 7: move 11 to AL register. Step 8: locate the contents in AL register to DX register using port out. Step 9: move 300 to CX register. Step 10: repeat step 8 until the content in CX register becomes equal to zero. Step 11: Rotate carry left through bit. Step 12: Decrement BX by one Step 13: repeat steps from 8 until the content in BX register becomes equal to zero. Step 14:Intialize BX with 07d0 Step 15: locate the contents in AL register to DX register using port out. Step 16: move 300 to CX register. Step 17: repeat step 15 until the content in CX register becomes equal to zero.

ADITYA ENGINEERING COLLEGE

107

MICROPROCESSORS LAB OBSERVATION

ECE Dept.

Step 18: Rotate carry left through bit. Step 19: Decrement BX by one Step 20: repeat steps from 15 until the content in BX register becomes equal to zero. Step 21: jump to location / step 8. PROGRAM: MOV MOV OUT RPT: MOV MOV MOV BACK: OUT MOV L1: LOOP ROL DEC JNZ MOV MOV BACK1:OUT MOV L2: LOOP ROR DEC JNZ JMP DX, 0FFE6 AL, 80 DX, AL BX,07D0 DX, 0FFE0 AL, 11 DX, AL CX, 0300 L1 AL, 01H BX BACK BX,07D0 AL, 11 DX, AL CX, 0300 L2 AL, 01H BX BACK1 RPT

ADITYA ENGINEERING COLLEGE

108

MICROPROCESSORS LAB OBSERVATION FLOW CHART


START DX AL [DX]
DX

ECE Dept.

Addr. Of CWR 80 AL

Addr. Of Port-A AL Data BX STEPS AL

[DX]

CX

COUNT

CX

CX-1

NO

CX=0
YES Cir left AL BX-1

AL BX NO

BX=0
YES
STEPS AL COUNT

BX [DX] CX

CX NO

CX-1

CX=0
AL BX YES Cir Right AL BX-1

NO

BX=0

YES

ADITYA ENGINEERING COLLEGE

109

MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand

ECE Dept.

Comments

RESULT:

ADITYA ENGINEERING COLLEGE

110

MICROPROCESSORS LAB OBSERVATION Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand

ECE Dept.

Comments

ADITYA ENGINEERING COLLEGE

111

MICROPROCESSORS LAB OBSERVATION Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand

ECE Dept.

Comments

ADITYA ENGINEERING COLLEGE

112

MICROPROCESSORS LAB OBSERVATION Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand

ECE Dept.

Comments

ADITYA ENGINEERING COLLEGE

113

MICROPROCESSORS LAB OBSERVATION Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand

ECE Dept.

Comments

ADITYA ENGINEERING COLLEGE

114

MICROPROCESSORS LAB OBSERVATION Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand

ECE Dept.

Comments

ADITYA ENGINEERING COLLEGE

115

You might also like