You are on page 1of 90

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

CONTENTS
Page no. List of Experiments (as per JNTU) Microprocessor 8086 Programming Introduction to MASM and TASM Arithmetic operations: 1) Arithmetic Operations on 8 bit data 2) 3) 4) 5) Arithmetic Operations on 16 bit data 9 Multibyte addition and subtraction 13 Signed Operations on 8 bit data 17 ASCII Arithmetic Operations 19 Logic Operations: 6) BCD to ASCII Conversion 7) ASCII to BCD Conversion 8) No. of Positive nos & Negative nos. 9) No. of Odd nos & Even nos. 10) Packed BCD to Unpacked BCD Conversion String Operations: 11) Transfer Block of Data 12) Reversal of given String 13) Sorting of N numbers 14) Length of the given String 15) Comparison of two Strings DOS/BIOS Programming: 16) Reading Keyboard buffered with echo 17) Reading Keyboard buffered with out echo SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 1 53 55 37 39 43 47 49 23 25 27 31 35 3,4 5 1, 2

MICROPROCESSORS LAB MANUAL 18) Display String by using DOS Commands

DEPT OF ECE 57

Page no.

Interfacing with (8086) programs: 19) To generate triangle wave by using DAC with 8086 20) To generate square wave by using DAC with 8086 21) Keyboard Display Interfacing (8279) Microcontroller (8051) programs: 22) Reading & writing data by 8051 23) Square wave generator using Timer in different modes 24) Serial communication ADDITIONAL PROGRAMS: 1) Arithmetic operations on 8 bit data by using 8051 2) Stepper Motor Interfacing Using 8255 PPI 75 79 67 69 71 59 61 63

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

INTRODUCITION TO MASM/TASM
ASSEMBLY LANGUAGE PROGRAMMING USING MASM SOFTWARE:
This software is used to write a program (8086, Pentium processors etc.).The programs are written using assembly language in editor and then compile it. The complier converts assembly language statements into machine language statements/checks for errors. Then execute the compiled program. Programs for different processor instructions (Pentium, 8086) programming manner differ for each model. There are different soft wares developed by different companies for assembly language programming which 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.

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

MICROPROCESSORS LAB MANUAL DEPT OF ECE 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 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 to debug to create exe file

C:MASM>debug filename. EXE


Then it display -- on the screen After that type R displays the registers contents steps 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 A [address] COMPARE C range address DUMP D [range] ENTER E address [list] FILL GO HEX INPUT LOAD ; Assembly the instructions at a particular address ; Compare two memory ranges ; Display contents of memory ; Enter new or modifies memory contents beginning at specific Location F range list ; Fill in a range of memory G [=address] [addresses] ; Execute a program in memory H value1 value2 ; Add and subtract two Hex values I port L [address] [drive] [first sector] [number]

MOVE M range address NAME N [pathname] [arg list] OUTPUT O port byte PROCEED P [=address] [number] QUIT Q REGISTER R [register] SEARCH S range list TRACE T [=address] [value] UNASSEMBLE U [range] WRITE W [address] [drive] [first sector] [number] ALLOCATE expanded memory XA [#pages] SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 4

MICROPROCESSORS LAB MANUAL DEALLOCATE expanded memory XD [handle] MAP expanded memory pages XM [Lpage] [Ppage] [handle] DISPLAY expanded memory status XS

DEPT OF ECE

EXP. NO : 1

DATE:

ARITHMETIC OPERATIONS ON 8 BIT DATA


ABSTRACT: Assembly language program to perform all arithmetic operations on 8bit data PORTS USED: None REGISTERS USED: AX, BL ALGORITHM: Step1: Start Step2: Initialize data segment Step3: Copy the contents from memory location [0000] to AL Step4: Copy the contents from memory location [0001] to BL Step 5: Perform addition Step6: Move the result to the memory location [0002] Step7: Copy the contents from memory location [0000] to AL Step8: Perform subtraction Step9: Move the result to the memory location [0003] Step10: Copy the contents from memory location [0000] to AL Step11: Perform multiplication Step12: Move the result to the memory location [0004] Step13: Copy the contents from memory location [0000] to AL Step14: Perform division Step15: Move the result to the memory location [0006] Step16: stop. PROGRAM: ASSUME CS: CODE, DS: DATA DATA SEGMENT N1 DB 04H N2 DB 06H RESULT DB 06H DATA ENDS

DUP (00)

CODE SEGMENT START: MOV AX, DATA MOV DS, AX SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 5

MICROPROCESSORS LAB MANUAL MOV AL, N1 MOV BL,N2 ADD AL,BL MOV [RESULT], AL MOV AL, N1 SUB AL, BL MOV [RESULT+1], AL MOV AH,00H 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

DEPT OF ECE

CODE TABLE:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

MICROPROCESSORS LAB MANUAL Physical address Mnemonics Hex code Segment Effective Opcode Operand address address

DEPT OF ECE Comments

CALCULATIONS:

MOV

AH, 4CH 7

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

MICROPROCESSORS LAB MANUAL INT 21H CODE ENDS END START

DEPT OF ECE

RESULT:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

MICROPROCESSORS LAB MANUAL CODE TABLE: Physical address Segment Effective address address Hex code Mnemonics Opcode Operand

DEPT OF ECE

Comments

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

EXP. NO : 2

DATE:

ARITHMETIC OPERATIONS ON 16 BIT 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: Load SI with memory location 5000 Step4: Move the contents from memory location [0000] to AX Step5: Move the contents from memory location [0001] to BX Step6: Perform addition Step7: Move the result to the memory location specified Step8: Copy the contents from the memory location [0000] to AX Step9: Perform subtraction Step10: Move the result to the memory location [SI+02] Step11: Copy the contents from the memory location [0000] to AX Step12: Perform multiplication Step13: Move the result to the memory location [SI+04] & [SI+06] Step14: Copy the contents from the memory location [0000] to AX Step15: Perform division Step16: Move the result to the memory location [SI+08] & [SI+0A] Step17: 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 DX, 0000H MOV AX, N1 MUL BX MOV [SI+4], AX MOV [SI+6], DX MOV AX, N1 SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 10

MICROPROCESSORS LAB MANUAL MOV DX, 0000H DIV BX MOV [SI+8], AH MOV [SI+0AH], DX

DEPT OF ECE

CALCULATIONS:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

11

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

MOV AH, 4CH INT 21H CODE ENDS END START

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

12

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

RESULT:

\
CODE TABLE: Physical address Segment Effective address address Hex code Mnemonics Opcode Operand Comments

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

13

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

EXP. NO : 3

DATE:

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 the CX register with count Step4: Load the 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: Move 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 the BX register with no: of bytes Step12: Move the contents from memory location n1 [bx] to AL Step13: Perform subtraction with second number n2 [bx] Step14: Move 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 MOV MOV MOV

AX, DATA DS, AX CX, COUNT BX, 0002H 14

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

MICROPROCESSORS LAB MANUAL CLC BACK: MOV AL, N1 [BX] ADC AL, N2 [BX] MOV SUM [BX], AL DEC BX LOOP BACK MOV CX, COUNT MOV BX, 0002H BACK1: MOV AL, N1 [BX] SBB AL, N2 [BX]

DEPT OF ECE

CALCULATIONS:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

15

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

MOV DIFF [BX], AL DEC BX LOOP BACK1 MOV AH, 4CH INT 21H CODE ENDS END START

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

16

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

RESULT:

CODE TABLE: Physical address Segment Effective address address Hex code Mnemonics Opcode Operand Comments

CALCULATIONS:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

17

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

EXP. NO : 4

DATE:

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: Negate the contents of AL Step5: Load BL with second number Step6: Perform signed Multiplication Step7: Move the result to the memory location [0000] Step8: Load AL with first number Step9: Negate the contents of AL Step11: Perform signed division Step12: Move the result to the memory location [0002] Step13: Stop
PROGRAM: ASSUME CS: CODE, DS: DATA DATA SEGMENT N1 DB 08H N2 DB 04H RESULT DW 02H DUP (00) DATA ENDS CODE SEGMENT START: MOV AX, DATA MOV DS, AX MOV AL, N1 NEG AL

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

18

MICROPROCESSORS LAB MANUAL


CBW MOV IMUL MOV MOV NEG CBW IDIV MOV MOV INT CODE ENDS END START BL, N2 BL [RESULT], AX AL, N1 AL BL [RESULT+2], AX AH, 4CH 21H

DEPT OF ECE

RESULT:

CODE TABLE:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

19

MICROPROCESSORS LAB MANUAL Physical address Hex code Segment Effective address address

Mnemonics Opcode Operand

DEPT OF ECE Comments

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

20

MICROPROCESSORS LAB MANUAL EXP. NO : 5

DEPT OF ECE DATE:

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 Step5: Load BL with Second number Step6: Perform addition Step7: Perform ASCII adjustment after addition Step8: Copy the result to the memory location [SI] Step9: Load AL with first number Step10: Perform subtraction Step11: Perform ASCII adjustment after subtraction Step12: Copy the result to the memory location [SI+01] Step13: Load AL with first number Step14: Perform multiplication Step15: Perform ASCII adjustment after multiplication Step16: Copy the result to the memory location [SI+02] Step17: Load AL with first number Step18: Perform division Step19: Perform ASCII adjustment before division Step20: Copy the result to the memory location [SI+03] Step21: Stop

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

21

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

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, 2000H XOR AX, AX XOR BX, BX MOV AL, N1 MOV BL, N2 ADD AX, BX AAA MOV [SI], AX MOV AL, N1 MOV AH,00 SUB AL, BL AAS MOV [SI+2], AX MOV AL, 08H 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

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

22

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

CALCULATIONS:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

23

MICROPROCESSORS LAB MANUAL RESULT:

DEPT OF ECE

CODE TABLE: Physical address Segment Effective address address Hex code Mnemonics Opcode Operand Comments

CALCULATIONS:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

24

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

EXP. NO : 6

DATE:

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: Load CX register with count 04H Step5: Copy the contents from AL to AH Step6: Perform AND operation AL with 0FH Step7: Perform AND operation AL with F0H Step8: Rotate the AH contents Step9: Perform OR operation AL with 30H Step10: Perform OR operation AH with 30H Step11: Move the result to the memory location Step12: Stop 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, 04H MOV AH, AL AND AL, 0FH AND AH, 0F0H ROR AH, CL OR AL, 30H OR AH, 30H MOV ASCII, AX MOV AH, 4CH 25

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

MICROPROCESSORS LAB MANUAL INT 21H CODE ENDS END START

DEPT OF ECE

RESULT:

CODE TABLE: Physical address Segment Effective address address Hex code Mnemonics Opcode Operand Comments

CALCULATIONS:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

26

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

EXP. NO : 7

DATE:

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 first ASCII number Step4: Load CX register with count 04H Step5: Load BL with second ASCII number Step6: Perform AND operation AL with 0FH Step7: Perform AND operation BL with 0FH Step8: Rotate the contents of AL with CL count Step9: Perform OR operation AL with BL Step10: Move the result to the memory location Step11: Stop
PROGRAM: ASSUME CS: CODE, DS: DATA 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

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

27

MICROPROCESSORS LAB MANUAL


AND BL, 0FH ROR AL, CL OR AL, BL MOV BCD, AL MOV AH, 4CH INT 21H CODE ENDS END START

DEPT OF ECE

RESULT:

CODE TABLE:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

28

MICROPROCESSORS LAB MANUAL Physical address Mnemonics Hex code Segment Effective Opcode Operand address address

DEPT OF ECE Comments

EXP. NO : 8 SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

DATE: 29

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

NO OF POSITIVE AND NEGATIVE 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 Step4: Initialize DX with 0000 Step5: Load SI with offset list Step6: Move the contents from memory location SI to AL Step7: Rotate left the contents 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: Move the result to the memory location Step17: Stop

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

30

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

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 END START

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

31

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

CALCULATIONS:

RESULT: SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 32

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

CODE TABLE: Physical address Segment Effective address address Hex code Mnemonics Opcode Operand Comments

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

33

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

EXP. NO : 9

DATE:

NO OF ODD AND EVEN 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: Move the contents from memory location SI to AL Step7: Rotate right the contents 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: Move the result to the memory location Step17: Stop

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

34

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

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 35

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

MICROPROCESSORS LAB MANUAL MOV AH, 4CH INT 21H CODE ENDS END START

DEPT OF ECE

CALCULATIONS:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

36

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

RESULT:

CODE TABLE: Physical address Segment Effective address address Hex code Mnemonics Opcode Operand Comments

CALCULATIONS:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 37

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

EXP. NO : 10

DATE:

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: Move packed number into AL register Step4: Move packed number into BL register Step5: Initialize the count CX with 04H. Step6: AND operation AL with 0FH. Step7: AND operation BL with 0F0H. Step8: Rotate right without carry operation on BL by CL times. Step9: Move the result into location 0000 and 0001. Step10: Stop. PROGRAM:
ASSUME CS: CODE, DS: DATA DATA SEGMENT N EQU 29H RESULT DB 02H DUP (00) 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 SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 38

MICROPROCESSORS LAB MANUAL AND BL, 0F0H ROR BL, CL MOV [RESULT], BL MOV [RESULT+1], AL MOV AH, 4CH INT 21H
CODE ENDS END START

DEPT OF ECE

RESULT:

CODE TABLE:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

39

MICROPROCESSORS LAB MANUAL Physical address Hex code Segment Effective address address

Mnemonics Opcode Operand

DEPT OF ECE Comments

EXP. NO : 11 SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

DATE: 40

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

TRANSFER 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: Load CX register with count Step4: Initialize DI with memory location Step5: Load SI with offset list Step6: Repeat the process of moving string byte from SI to DI until count equals to zero Step7: Stop
PROGRAM: ASSUME CS: CODE, DS: DATA, ES: DATA DATA SEGMENT LIST DB SRI SAI ADITYA COUNT EQU 14H DATA ENDS CODE SEGMENT ORG 1 000H MOV AX, DATA MOV DS, AX MOV ES, AX MOV CX, COUNT MOV DI, 5000H LEA SI, LIST REP MOVSB MOV AH, 4CH INT 21H

START:

CODE ENDS END START

RESULT:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

41

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

CALCULATIONS:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

42

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

EXP. NO : 12

DATE:

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 02H 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

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

43

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

CODE TABLE: Physical address Segment Effective address address Hex code Mnemonics Opcode Operand Comments

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

44

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

PROGRAM: ASSUME CS: CODE, DS: DATA

DATA SEGMENT LIST DB MICRO PROCESSOR SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 45

MICROPROCESSORS LAB MANUAL 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, 02H 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

DEPT OF ECE

RESULT:

CODE TABLE:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

46

MICROPROCESSORS LAB MANUAL Physical address Hex code Segment Effective address address

Mnemonics Opcode Operand

DEPT OF ECE Comments

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

47

MICROPROCESSORS LAB MANUAL EXP. NO : 13

DEPT OF ECE DATE:

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

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

48

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

49

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

PROGRAM: ASSUME CS: CODE, DS: DATA DATA SEGMENT LIST DB 56H, 12H, 72H,32H COUNT EQU 0003H DATA ENDS CODE SEGMENT ORG 1000H START: MOV AX, DATA MOV DS, AX MOV CX, COUNT MOV DX, CX AGAIN: BACK: MOV SI, OFFSET LIST MOV CX, DX 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

RESULT:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

50

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

CODE TABLE: Physical address Segment Effective address address Hex code Mnemonics Opcode Operand Comments

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

51

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

\
EXP. NO : 14 DATE:

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: Move the result to the memory location Step11: Stop PROGRAM:
ASSUME CS: CODE, DS: DATA, ES: DATA DATA SEGMENT LIST DB SRI SAI ADITYA$ LEN DW ? DATA ENDS CODE SEGMENT ORG 1000H START: MOV AX, DATA MOV DS, AX MOV ES, AX MOV AL,$ LEA SI, LIST MOV DX, 0000H BACK: SCASB JE EXIT INC DX JMP BACK EXIT: MOV LEN, DX MOV AH, 4CH INT 21H CODE ENDS END START

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

52

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

RESULT:

CODE TABLE:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

53

MICROPROCESSORS LAB MANUAL Physical address Hex code Segment Effective address address

Mnemonics Opcode Operand

DEPT OF ECE Comments

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

54

MICROPROCESSORS LAB MANUAL EXP. NO :15

DEPT OF ECE DATE:

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 length1 Step4: Load BX with length2 Step5: Compare AX with BX Step6: Jump step14 if not equal Step7: Copy the contents from AX to CX Step8: Load SI with first string Step9: Load DI with second string Step10: Repeat comparing string byte until count equals to zero Step11: jump to step 14 if not equal Step12: Move the result to the memory location Step13: Jump to step 15 Step14: Move another result to the memory location Step15: Stop

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

55

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

56

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

PROGRAM: ASSUME CS: CODE, DS: DATA, ES: DATA LIST1 DB SRI SAI ADITYA LEN1 EQU ($-LIST1) LIST2 DB SRI SAI 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 REP CMPSB JNE EXIT MOV RESULT, 5555H JMP NEXT EXIT: MOV RESULT, 0FFFFH NEXT: MOV AH, 4CH INT 21H CODE ENDS END START

RESULT:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

57

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

CODE TABLE: Physical address Segment Effective address address Hex code Mnemonics Opcode Operand Comments

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

58

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

EXP. NO :16

DATE:

READING KEYBOARD (WITH Echo)


ABSTRACT: To Reading 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 00 Step4: Key board Interrupt Step5: Initialize the AL register with 00 Step6: Key board Interrupt Step7: Compare the data in AL register and 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 registers. Step13: Stop.
PROGRAM: ASSUME CS: CODE CODE SEGMENT ORG 1000H MOV AL, 13H MOV AH, 00H INT 10H MOV AH, 00H INT 16H CMP AL, q JE EXIT MOV BL, 0FH MOV AH, 14 INT 10H JMP BACK MOV AH, 4CH INT 21H

START:

BACK:

EXIT:

CODE ENDS END START

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

59

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

RESULT:

CODE TABLE:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

60

MICROPROCESSORS LAB MANUAL Physical address Hex code Segment Effective address address

Mnemonics Opcode Operand

DEPT OF ECE Comments

EXP. NO : 17 SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

DATE: 61

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

READING KEYBOARD (without echo)


ABSTRACT: To Display the string or character (without ECHO) by using DOS Command REGISTERS USED: AH, AL, SI PORTS USED: None. ALGORITHM: Step1: Start Step2: Initialize SI with Offset Result. Step3: Initialize AH with 00H Step4: Set the wait for KEY press.. Step5: Compare AL with q. Step6: Copy the contents AL into SI register. Step7: If equal to zero go to step 10 Step8: Increment the value of 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 (00) DATA ENDS CODE SEGMENT ORG 1000h MOV SI, OFFSET RESULT MOV AH, 00h INT 16h CMP AL, q MOV [SI], AL JE EXIT INC SI JMP BACK MOV AH, 4Ch INT 21h CODE ENDS END START

START: BACK:

EXIT:

RESULT:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

62

MICROPROCESSORS LAB MANUAL CODE TABLE: Physical address Segment Effective address address Hex code Mnemonics Opcode Operand

DEPT OF ECE

Comments

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

63

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

EXP. NO : 18

DATE:

DISPLAY STRING BY USING DOS COMMANDS


ABSTRACT: To display the string character by using DOS 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 14H 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 SRI SAI ADITYA MICROPROCESSORS LAB!' DATA ENDS CODE SEGMENT ORG 1000H MOV AX, DATA MOV DS, AX MOV AL, 13H MOV AH, 00 INT 10H MOV SI, 00H MOV AL, TEXT [SI] CMP AL,'!' JE EXIT MOV AH, 14 MOV BL, 05H INT 10H INC SI JMP BACK MOV AH, 4CH INT 21H CODE ENDS END START

START:

BACK:

EXIT:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

64

MICROPROCESSORS LAB MANUAL RESULT:

DEPT OF ECE

CODE TABLE: Physical address Segment Effective address address Hex code Mnemonics Opcode Operand Comments

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

65

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

EXP. NO : 19

DATE:

To generate square waveform by DAC interfacing with 8086


AIM: To generate square waveform by DAC interfacing with 8086 kit REGISTERS USED: general purpose registers: AL, CX PORTS USED: PORT A. ALGORITHM : Step 1: Start Step 2: Load AL with 80H. Step 3: Write AL onto the address 26H. Step 4: Load AL with 00. Step 5: Write AL onto the address 20H. Step 6: Jump to step 11. Step 7: Load AL with 0FFH. Step 8: Write AL onto the address 20H Step 9: Jump to step 11. Step 10: Jump to step 4. Step 11: Load CX with 93H Step 12:. If CX not equal to zero,jump to step 12 . otherwise goto step 13. Step 13: Return to main program. Step 14: Stop. PROGRAM:
MOV AL,80H OUT 26H,AL AGAIN: MOV AL,00H OUT 20H,AL CALL DELAY MOV AL,0FFH OUT 20H,AL CALL DALAY JMP AGAIN DELAY: BACK: MOV CX,093H LOOP BACK RET

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

66

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

RESULT:

CODE TABLE:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

67

MICROPROCESSORS LAB MANUAL Physical address Hex code Segment Effective address address

Mnemonics Opcode Operand

DEPT OF ECE Comments

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

68

MICROPROCESSORS LAB MANUAL EXP. NO : 20

DEPT OF ECE DATE:

To generate triangular waveform by DAC interfacing with 8086


AIM: To generate triangular waveform by DAC interfacing with 8086 kit. REGISTERS USED: general purpose registers: AL, CX PORTS USED: PORT A ALGORITHM: Step 1: Start Step 2: Load AL with 80H. Step 3: Write AL onto the address 26H. Step 4: Load AL with 00. Step 5: Load register CX with 0FFH Step 6: Write AL onto the address 20H. Step 7: Increment value of AL. Step 8: Decrement CX. Step 9: If CX not equal to zero,jump to step 6. Step 10:Load CX with 0FFH Step 11:Write AL onto the address 20H. Step 12:Decrement AL. Step 13:Decrement CX. Step 14:.If CX not equal to zero,jump to step 10. Step 15: Jump to step 12. Step 16: Stop.
Program: MOV AL,80H OUT 26H,AL AGAIN: BACK: MOV AL,00H MOV CX,0FFH OUT 20H,AL INC AL DEC CX JNZ BACK MOV CX,0FFH BACK1: OUT 20H,AL DEC AL DEC CX JNZ BACK1 JMP AGAIN

RESULT:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

69

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

CODE TABLE: Physical address Segment Effective address address Hex code Mnemonics Opcode Operand Comments

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

70

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

EXP. NO : 21

DATE:

KEYBOARD INTERFACING
AIM: To display a string through interfacing 8279 by using 8086. REGISTERS USED: AX, BX, CX, DX, SI PORTS USED: command port, data port
ALGORITHM: Step1: Start Step2: Load SI with 1200H. Step3: Load CX with 000FH. Step4: Load al with 10H Step5: Write al onto address C2H Step6: Load al with CCH Step7: Write al onto address C2H Step8: Load al with 90H Step9: Write al onto address C2H Step10: Load al with contents of SI Step11: Write al onto address C0H Step12: Jump to step 16 Step13: Increment SI Step14: Decrement CX if not equal to zero. Step 15: Jump to step 12 Step 16: Load DX with 0A0FFH Step 17:.Decrement DX Step18: If DX not equal to zero jump to step 17 otherwise jump to step 18. Step 19:Return to main program Step 20: Stop

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

71

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

72

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

PROGRAM: START: MOV MOV MOV OUT MOV OUT MOV OUT NEXT: SI,1200H CX, 000FH AL, 10H 0C2, AL AL, 0CCH 0C2, AL AL,90H 0C2,AL

MOV AL,[SI] OUT 0C0,AL CALL DELAY INC LOOP SI NEXT

JMP START DELAY: LOOP: MOV DX,0A0FFH DEC DX JNZ LOOP RET

RESULT: SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 73

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

CODE TABLE: Physical address Segment Effectiv address e address Hex code Mnemonics Opcode Operand Comments

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

74

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

CODE TABLE: Physical address Segment Effectiv address e address Hex code Mnemonics Opcode Operan d Comments

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

75

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

EXP. NO : 22

DATE:

Reading & Writing data from parallel port by using 8051 kit
Aim : To perform reading & writing data from parallel port by using 8051 kit Ports used: none Registers used: A,DPTR Algorithm: Step 1: Start Step 2: Move FFH into the port 1 Step 3: Move contents into port1 into register A Step 4: Move 4150H into register DPTR Step 5: Move contents of register a into contents of DPTR Step 6: Jump to step 6 Step 7: Move 55 into register A Step 8: Move contents of register A into the port1 Step 9: Jump to step 9 Step 10:Stop PROGRAM FOR READING : MOV MOV MOV HLT: P1,#0FFH A, P1 DPTR,#4150H

MOVX @DPTR,A SJMP HLT

PROGRAM FOR WRITING : MOV MOV HLT: A,#55H P1,A

SJMP HLT

RESULT:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

76

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

CODE TABLE: Physical address Segment Effective address address Hex code Mnemonics Opcode Operand Comments

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

77

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

EXP. NO : 23

DATE:

Write a program to generate square wave using timer in different modes by using 8051
AIM: To generate square wave using timer in different modes by using 8051 REGISTERS USED: general purpose registers: AL, CX PORTS USED: PORT A ALGORITHM: Step 1: Start Step 2: Move 01 into the register tmod Step 3: Move 3e into the register tl0 Step 4: Move 3b into the register th0 Step 5: Compliment part1 Step 6: Setbit the register bits tcon.4 Step 7: Compare the value of tf0 and 4100 jump if not below Step 8: Clear the 5th bit of register tcon.4 Step 9: Clear the 6th bit of register tcon.5 Step 10: Jump to step2 Step 11: Stop

Program:
AGAIN: MOV TMOD,#01 MOV TL0,#3E MOV TH0,#3B CPL P1(90) SETB TCON.4(8C) JNB TF0(8D),HERE CLR TCON.4(8C) CLR TCON.5(8D) SJMP AGAIN

HERE:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

78

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

RESULT:

CODE TABLE:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

79

MICROPROCESSORS LAB MANUAL Physical address Hex code Segment Effective address address

Mnemonics Opcode Operand

DEPT OF ECE Comments

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

80

MICROPROCESSORS LAB MANUAL EXP. NO : 24

DEPT OF ECE DATE:

Serial communication
AIM: To transmit data serially to the pc at baud rate 9600 REGISTERS USED: General purpose registers: AL, CX PORTS USED: PORT A ALGORITHM: Step1: Start Step2: Load R0 with 06H Step3: Load DPTR with 4150H Step4: Load SCON with 50H Step5: Load TMOD with 20H Step6: Load TH1 with FD Step7: Set bit TR1 Step8: Load A with contents of DPTR Step9: Load SBUF with contents of A Step10: Repeat the step 10 until TI=1 i.e check whether TI=1 if TI=1 go to step 8 Step11: Clear TI Step12: Increment DPTR Step13: Decrement R0, if R0#0,goto step 8 Step14: Jump to step2 Step15: Stop

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

81

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

82

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

PROGRAM: AGAIN: MOV R0,#06H MOV DPTR,#4150H MOV SCON,#50H MOV TMOD,#20H MOV TH1,#0FDH SETB NEXT: HERE: MOV JNB CLR INC 8EH SBUF,A 99H,HERE TI DPTR MOVX A,@DPTR

DJNZ R0,NEXT SJMP AGAIN

RESULT:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

83

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

CODE TABLE: Physical address Segment Effective address address Mnemonics Opcode Operand

Hex code

Comments

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

84

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

EXP. NO : 25

DATE:

Arithmetic operations on 8bit data by using 8051 kit


Aim: to perform arithmetic operation on 8bit data using 8051 kit Ports used: none Registers used: a,b,dptr Algorithm:

Step1: Start Step2: Move 20 into the register A. Step3: Add the contents of register A with 30, along with carry. Step4: Move 4150 to register DPTR Step5: Move the contents of register A into contents of data pointer. Step6: Move 6 into register A Step7: Subtract the contents of register A from 3 with borrow. Step8: Increment DPTR Step9: Move the contents of register A into contents of data pointer. Step10: Move 6 into register A. Step11: Move 2 into register B. Step12: Perform multiplication on contents of register A,B. Step13: Increment DPTR Step14: Move the contents of register A into contents of data pointer. Step15: Move 8 into register A. Step16: Move 4 into register B. Step17: Perform division on contents of register A,B. Step18: Increment DPTR Step19: Move the contents of register A into contents of data pointer. Step20: Stop

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

85

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

86

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

PROGRAM: MOV A,#20H ADDC A,#30H MOV DPTR,#4150H MOVX @DPTR,A MOV A,#06H SUBB A,#03H INC DPTR MOVX @DPTR,A MOV A,#06H MOV B,#02H MUL AB INC DPTR MOVX @DPTR,A MOV A,#08H MOV B,#04H DIV AB INC DPTR MOVX @DPTR,A HLT: SJMP HLT

RESULT: SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 87

MICROPROCESSORS LAB MANUAL

DEPT OF ECE

CODE TABLE:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

88

MICROPROCESSORS LAB MANUAL Physical address Mnemonics Hex code Segment Effectiv Opcode Operand address e address

DEPT OF ECE Comments

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

89

MICROPROCESSORS LAB MANUAL EXP. NO : 26

DEPT OF ECE DATE:

STEPPER MOTOR INTERFACING


AIM: Program to design a stepper motor to rotate shaft of a 4 phase stepper motor in clockwise rotations. REGISTERS USED: General purpose registers: AL , DX , CX PORTS USED: Port B, port C (out) ALGORITHM: Step 1: Start Step 2: Load dx with 0026 Step 3: Load AX with 80h. Step 4: Write AX onto the DX register. Step 5: Load DX with 20h Step 6: Load AX with 00h Step 7: Write DX onto the AX register Step 8: Load BX with 2300 Step 9: Decrement BX Step 10: If BX not equal to zero jump to step 9 otherwise jump to step 11. Step 11: Load CL with 01h Step 12: Rotate AL left CL no.of times Step 13: Goto step 7 Step 14: Stop. PROGRAM: MOV MOV OUT MOV MOV OUT MOV DEC JNZ MOV ROL JMP DX, 0026H AX, 80H DX, AX DX,20H AX, 0011 DX, AX BX, 0300 BX DELAY CL,01H AL, CL RPT

RPT: DELAY:

RESULT:

SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY

90

You might also like