0% found this document useful (0 votes)
236 views103 pages

Eee MP & MC Lab Manual

The document provides an introduction to assembly language programming using MASM software. It discusses entering the MASM editor, merits of MASM such as producing binary code and using names to refer to data, and includes sample code to perform arithmetic operations on 8-bit and 16-bit data using registers like AX, BX, and SI. It also includes flowcharts and tables with code samples.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
236 views103 pages

Eee MP & MC Lab Manual

The document provides an introduction to assembly language programming using MASM software. It discusses entering the MASM editor, merits of MASM such as producing binary code and using names to refer to data, and includes sample code to perform arithmetic operations on 8-bit and 16-bit data using registers like AX, BX, and SI. It also includes flowcharts and tables with code samples.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 103

MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

INTRODUCTION TO MASM/TASM
ASSEMBLY LANGUAGE PROGRAMMING USING MASM SOFTWARE:

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 DOS BOX icon on the desktop.

 Path setting
Suppose it display path as Z:\>

Then type MOUNT C C:\ MASM then drive c is mounted as local directory C:\MASM\

Then the path is Z:\>


Then type C:
Then the path is C:\>
Then type edit i.e.; C:\>edit

Then you enter into MASM text editor


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 filename’s
Then exit from the editor and go to prompt.

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 1


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

Then type MASM filename.ASM


I.e. C:\> MASM filenamDEBUG COMMANDS:

ASSEMBLE A [address] ; Assembly the instructions at a particular address

COMPARE C range address ; Compare two memory ranges

DUMP D [range] ; Display contents of memory

ENTER E address [list] ; Enter new or modifies memory contents beginning


at specific Location
FILL F range list ; Fill in a range of memory

GO G [=address] [addresses]; Execute a program in memory

HEX H value1 value2 ; Add and subtract two Hex values

INPUT I port

LOAD 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]

DEALLOCATE expanded memory XD [handle]

MAP expanded memory pages XM [Lpage] [Ppage] [handle]

DISPLAY expanded memory status XS

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 2


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

FLOW CHART:
START

Initialize DS
AL Data1
BL Data2

AL AL+BL

Data Memory AL

AL Data1

AL AL-BL

Data Memory AL

AL AL*BL
ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 3
Data Memory AL
MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

AL Data1

AX AL*BL
Data Memory AX

AL Data1
AH 00H

AX AX / BL
Data Memory AX

STOP

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 4


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

Exp No:
Date:

1. 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:
Step 1: Start
Step 2: Initialize data segment
Step 3: Load the given data to registers AL& BL
Step 4: Perform addition and Store the result
Step 5: Repeat step 3
Step 6: Perform subtraction and Store the result
Step 7: Repeat step 3
Step 8: Perform multiplication and Store the result
Step 9: Repeat step 3
Step 10: Perform division and Store the result
Step 11: 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 COLLEGE OF ENGINEERING & TECHNOLOGY Page 5


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 6


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

MANUAL CALCULATIONS:

RESULT:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 7


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

FLOW CHART:

START

Initialize DS
SI 5000H
AX Data1
BX Data2

AX AX+BX

[SI] AX

AX Data1

AX AX-BX

[SI+2] AX

AX Data1

AX, DX AX*BX

[SI+4] AX, DX

AX Data1
DX 0000H

AX, DX DX: AX / BX

[SI+8] AX, DX

STOP

AL AL*BL
ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 8
Data Memory AL
MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

Exp No:
Date:
2. 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:
Step 1: Start
Step 2: Initialize data segment
Step 3: Initialize SI with some memory location
Step 4: Load the given data to registers AX & BX
Step 5: Perform addition and Store the result
Step 6: Repeat step 4
Step 7: Perform subtraction and Store the result
Step 8: Repeat step 4
Step 9: Perform multiplication and Store the result
Step 10: Repeat step 4
Step 11: Perform division and Store the result
Step 12: 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, 0000H
DIV BX
MOV [SI+8], AX
MOV [SI+0AH], DX
MOV AH, 4CH
INT 21H
CODE ENDS
END START

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 9


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 10


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

MANUAL CALCULATIONS:

RESULT:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 11


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD 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 BX-1
CX CX-1

NO

CX=
0 YES

CX COUNT
BX COUNT-1

AL Data1 [BX]

AL Data1 [BX]-Data2 [BX]-CF

Data memory AL

BX BX-1
CX CX-1

NO

CX=
YES
0
STOP

AL Data1[bx]+Data2[bx]
AL AL*BL
ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 12
Data
Datamemory
Memory AL
AL
MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

Exp No:
Date:
3. MULTIBYTE ADDITION AND SUBTRACTION

ABSTRACT: Assembly language program to perform multibyte addition and subtraction


PORT USED: None
REGISTERS USED: AL, BX, CX
ALGORITHM:
Step 1: Start
Step 2: Initialize data segment
Step 3: Load CX register with count
Step 4: Load BX register with No. of bytes
Step 5: Copy the contents from the memory location n1 [BX] to AL
Step 6: Perform addition with second number n2 [BX]
Step 7: Store the result to the memory location sum [BX]
Step 8: Decrement BX
Step 9: Decrement CX, if CX not equal to Zero jump to step5
Step 10: Load CX register with count
Step 11: Load BX register with no: of bytes
Step 12: Store the contents from memory location n1 [BX] to AL
Step 13: Perform subtraction with second number n2 [BX]
Step 14: Store the result to the memory location sum [BX]
Step 15: Decrement BX
Step 16: Decrement CX, if CX not equal to Zero jump to step12
Step 17: 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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 13


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 14


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

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

MANUAL CALCULATIONS:

RESULT:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 15


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD 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

AL AL*BL
ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 16
Data Memory AL
MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.
Decrement
Exp No: CX, if CX
Date: not equal
4. SIGNED to OPERATIONS
Zero ON 8 BIT DATA
jump to
ABSTRACT: Assembly language program to perform signed operations
step12
PORT USED: None
REGISTERS USED: AL, BL
ALGORITHM:
Step 1: Start
Step 2: Initialize data segment
Step 3: Load AL with first number
Step 4: Do 2’s compliment of AL
Step 5: Load BL with second number
Step 6: Perform signed Multiplication
Step 7: Store the result in data memory
Step 8: Load AL with first number
Step 9: Repeat step 4
Step 10: Convert AL to AX
Step 11: Perform signed division
Step 12: Store the result in data memory
Step 13: 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
XOR AX, 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 COLLEGE OF ENGINEERING & TECHNOLOGY Page 17


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 18


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

MANUAL CALCULATIONS:

RESULT:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 19


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

FLOW CHART:

START

Initialize DS
AL ASCII 1
BL ASCII 2

AL AL+BL
ASCII Adjustment after addition
Data Memory AX

AL ASCII 1

AL AL-BL
ASCII Adjustment after subtraction
Data Memory AX

AL Data1
BL Data2

AX AL*BL
ASCII Adjustment after Multiplication
Data Memory AX

ASCII Adjustment before division


AX AX / BL
Data Memory AX

STOP

AL AL*BL
ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 20
Data Memory AL
MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

Exp No:
Date:
5. ASCII ARITHMETIC OPERATIONS

ABSTRACT: Assembly language program to perform ASCII arithmetic operations


PORT USED: None
REGISTERS USED: AL, BL, SI
ALGORITHM:
Step 1: Start
Step 2: Initialize data segment
Step 3: Load SI with Memory location
Step 4: Load AL with first number in ASCII form
Step 5: Load BL with Second number in ASCII form
Step 6: Perform addition
Step 7: Perform ASCII adjustment after addition
Step 8: Store the result to the data memory
Step 9: Load AL with first number in ASCII form
Step 10: Perform subtraction
Step 11: Perform ASCII adjustment after subtraction
Step 12: Store the result to the data memory
Step 13: Load AL with first number
Step 14: Perform multiplication
Step 15: Perform ASCII adjustment after multiplication
Step 16: Store the result to the data memory
Step 17: Load AL with first number
Step 18: Perform ASCII adjustment before division
Step 19: Perform division
Step 20: Store the result to the data memory
Step 21: 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
MOV AH, 00
SUB AL, BL

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 21


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 22


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.
Decrement
AAS CX, if CX
MOV [SI+2], AX not equal
MOV AL, 08H to Zero
MOV BL, 04H jump to
MUL BL step12
AAM
MOV [SI+4], AX
AAD
DIV BL
MOV [SI+6], AX
MOV AH, 4CH
INT 21H
CODE ENDS
END START

MANUAL CALCULATIONS:

RESULT:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 23


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

FLOW CHART:

START

Initialize DS
AL BCD Num
CL 04H

AH AL
AL ALAND 0FH
AH AH AND F0H

AH Rotate AH by CL
times

AL AL OR 30H

AH AH OR 30H
Data Memory AX

STOP

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 24


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

Exp No:
Date:
6. BCD TO ASCII CONVERSION

ABSTRACT: Assembly language program to convert BCD number to ASCII number


PORT USED: None
REGISTERS USED: AL, AH, CX
ALGORITHM:
Step 1: Start
Step 2: Initialize data segment
Step 3: Load AL with BCD number
Step 4: Copy the contents from AL to AH
Step 5: Perform AND operation on AL with 0Fh
Step 6: Perform AND operation on AL with F0h
Step 7: Rotate the AH contents by four times
Step 8: Perform OR operation on AL with 30h
Step 9: Perform OR operation on AH with 30h
Step10: Store the result to the memory location
Step11: 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, 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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 25


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 26


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

MANUAL CALCULATIONS:

RESULT:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 27


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

FLOW CHART:

START

Initialize DS
AL ASCII 1
BL ASCII 2
CL 04H

AL AL AND 0FH
BL BL AND 0FH

AL rotate AL by CL times

AL AL OR BL

Data Memory AL

STOP

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 28


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

Exp No:
Date:
7. ASCII TO BCD CONVERSION

ABSTRACT: Assembly language program convert ASCII number to BCD number


PORT USED: None
REGISTERS USED: AL, BL, CX
ALGORITHM:
Step 1: Start
Step 2: Initialize data segment
Step 3: Load AL with ASCII number
Step 4: Copy the contents from AL to BL
Step 5: Perform AND operation on AL with 0Fh
Step 6: Perform AND operation on BL with 0Fh
Step 7: Rotate the AL contents by four times
Step 8: Perform OR operation on AL with BL
Step 9: 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
AND BL, 0FH
ROR AL, CL
OR AL, BL
MOV BCD, AL
MOV AH, 4CH
INT 21H
CODE ENDS
END START

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 29


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 30


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

MANUAL CALCULATIONS:

RESULT:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 31


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

FLOW CHART:

START

Initialize DS
CX COUNT
SI address of LIST
DX 0000H

AL [SI]

AL rotate left AL, 1

YES NO

CF=1

DL DL+1
DH DH+1
SI SI +1
SI SI+1

CX CX-1

NO
CX=0

YES

Data memory DX

STOP

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 32


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

Exp No:
Date:
8. NUMBER 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:
Step 1: Start
Step 2: Initialize data segment
Step 3: Load CX register with count value
Step 4: Initialize DX with 0000h
Step 5: Load SI with offset list
Step 6: Copy the contents from memory location SI to AL
Step 7: Rotate left the content of AL
Step 8: Jump to step13 if carry
Step 9: Increment DL
Step 10: Increment SI
Step 11: Decrement CX and jump to step6 if no zero
Step 12: Jump to step16
Step 13: Increment DH
Step 14: Increment SI
Step 15: Decrement CX and jump to step6 if no zero
Step 16: Store the result to the data memory
Step 17: 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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 33


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 34


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

MOV AH, 4CH


INT 21H
CODE ENDS
END START

MANUAL CALCULATIONS:

RESULT:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 35


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

FLOW CHART:
START

Initialize DS
CX COUNT
SI Offset LIST
DX 0000H

AL [SI]

AL Cir right AL

NO
YES
CF=1

DH DH+1 DL DL+1
SI SI+1 SI SI +1

CX CX-1

NO
CX=0

YES

Data memory DX

STOP

AL Data1[bx]+Data2[bx]
AL AL*BL
ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 36
Data
Datamemory
Memory AL
AL
MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

Exp No:
Date:
9. NUMBER 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:
Step 1: Start
Step 2: Initialize data segment
Step 3: Load CX register with count
Step 4: Initialize DX with 0000
Step 5: Load SI with offset list
Step 6: Copy the contents from memory location SI to AL
Step 7: Rotate right the content of AL
Step 8: Jump to step13 if carry
Step 9: Increment DL
Step 10: Increment SI
Step 11: Decrement CX and jump to step6 if no zero
Step 12: Jump to step16
Step 13: Increment DH
Step 14: Increment SI
Step 15: Decrement CX and jump to step6 if no zero
Step 16: Store the result to the data memory
Step 17: 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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 37


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 38


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

EXIT: MOV [RESULT], DX


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

MANUAL CALCULATIONS:

RESULT:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 39


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

FLOW CHART:

START

Initialize DS
AL Packed BCD
Num
CL 04H

BL AL
AL AL*0FH
BL BL *F0H

BL Cir BL by CL times

Data Memory AL, BL

STOP

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 40


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

Exp No:
Date:
10. 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:
Step 1: Start
Step 2: Initialize the data segment
Step 3: Copy packed number into AL register
Step 4: Copy packed number into BL register
Step 5: Initialize the count CX with 04h
Step 6: Perform AND operation on AL with 0Fh
Step 7: Perform AND operation on BL with 0F0h
Step 8: Rotate right without carry operation on BL by CL times
Step 9: Move the result data memory
Step 10: 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 COLLEGE OF ENGINEERING & TECHNOLOGY Page 41


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 42


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

MANUAL CALCULATIONS:

RESULT:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 43


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

FLOW CHART:

START

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

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

NO

CX=
0
YES

STOP

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 44


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

Exp No
Date:
11. TRANSFER BLOCK OF DATA

ABSTRACT: Assembly language program to transfer a block of data.


PORT USED: None.
REGISTERS USED: AX, BL.
ALGORITHM:
Step 1: Start
Step 2: Initialize data segment & extra segment
Step 3: Define the String
Step 4: Load CX register with length of the String
Step 5: Initialize DI with memory location
Step 6: Load SI with offset list
Step 7: Repeat the process of moving string byte from SI to DI until CX equals to zero
Step 8: Stop

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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 45


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 46


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

MANUAL CALCULATIONS:

RESULT:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 47


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

FLOWCHART:

START

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

CX AX
AX AX/BL
CX AX

AL [SI]
AL [DI]
NO [SI] AL

SI SI+1
DI DI+1
CX CX-1

NO

CX=
0 YES

STOP

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 48


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

Exp No:
Date:
12. REVERSAL OF GIVEN STRING
ABSTRACT: Assembly language program to reverse a given string
PORT USED: None
REGISTERS USED: AX, BL
ALGORITHM:
Step 1: Start
Step 2: Initialize data segment & extra segment
Step 3: Load CX register with count
Step 4: Copy the contents from CX to AX
Step 5: Load SI with offset list
Step 6: Initialize DI with (count-1)
Step 7: Initialize BL with 02
Step 8: Perform division with BL
Step 9: Copy the contents from AX to CX
Step 10: Move the contents from memory location SI to AL
Step 11: Exchange the contents of AL with [DI]
Step 12: Move the contents from memory location AL to SI
Step 13: Increment SI
Step 14: Decrement DI
Step 15: Decrement CX and jump to step10 if no zero
Step 16: 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 CX, COUNT
MOV AX, CX
MOV SI, OFFSET LIST
MOV DI, (COUNT-1)
MOV BL, 02H
DIV BL
MOV AH, 00H
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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 49


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

END START

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 50


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 51


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

MANUAL CALCULATIONS:

RESULT:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 52


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

FLOW CHART:

START

Initialize DS
CX Count
DX Count

SI Offset list

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

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

CX CX-1

NO

CX=
0 YES
DX DX-1

NO

DX=
0 YES

STOP

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 53


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

Exp No:
Date:
13. 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:
Step 1: Start
Step 2: Initialize data segment
Step 3: Load CX register with count
Step 4: Copy the contents from CX to DX
Step 5: Load SI with offset list
Step 6: Copy the contents from DX to CX
Step 7: Move the contents from memory location SI to AL
Step 8: Increment SI
Step 9: Compare AL contents with [SI]
Step 10: Jump to step15 if carry
Step 11: Exchange the contents of AL with [SI]
Step 12: Decrement SI
Step 13: Move the contents from AL to memory location SI
Step 14: Increment SI
Step 15: Decrement CX and jump to step7 if no zero
Step 16: Decrement DX and jump to step5 if no zero
Step 17: Stop

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: 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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 54


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 55


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

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

MANUAL CALCULATIONS:

RESULT:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 56


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

FLOW CHART:

START

Initialize DS, ES
DI Offset string
DX 0000H
AL NULL
Character

Compare AL, ES: [DI]

YES

ZF=
NO
0

DX DX+1
DI DI+1

Data memory DX

STOP

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 57


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

Exp No:
Date:

14. LENGTH OF THE GIVEN STRING


ABSTRACT: Assembly language program to find the Length of a string
PORT USED: None
REGISTERS USED: AX, BL
ALGORITHM:
Step 1: Start
Step 2: Initialize data segment & extra segment
Step 3: Load AL with ‘$’
Step 4: Load SI with offset list
Step 5: Initialize DX with 0000
Step 6: Scan string byte from DI memory location until AL =ES: DI
Step 7: Jump to step10 if equal
Step 8: Increment DX
Step 9: Jump to step6
Step 10: Store the result to the memory location
Step 11: Stop

PROGRAM:
ASSUME CS: CODE, ES: DATA
DATA SEGMENT
LIST DB ‘ADITYA$’
LEN DW ?
DATA ENDS
CODE SEGMENT
ORG 1000H
START:
MOV AX, DATA
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 COLLEGE OF ENGINEERING & TECHNOLOGY Page 58


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 59


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

MANUAL CALCULATIONS:

RESULT:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 60


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

FLOW CHART:

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 COLLEGE OF ENGINEERING & TECHNOLOGY Page 61


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

Exp No:
Date:
15. COMPARISON OF TWO STRINGS
ABSTRACT: Assembly language program to compare two strings.
PORT USED: None
REGISTERS USED: AX, BL
ALGORITHM:
Step 1: Start
Step 2: Initialize data segment & extra segment
Step 3: Load AX with length of String 1
Step 4: Load BX with length of String 2
Step 5: Compare AX with BX
Step 6: Jump step14 if not equal
Step 7: Copy the contents from AX to CX
Step 8: Load SI with first location of string 1
Step 9: Load DI with first location of string 2
Step 10: Repeat comparing string byte until count equals to zero
Step 11: jump to step 14 if not equal
Step 12: Store the result to the data memory
Step 13: Jump to step 15
Step 14: Store another result to the data memory
Step 15: 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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 62


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 63


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

JMP NEXT
EXIT: MOV RESULT, 0FFFFH
NEXT: MOV AH, 4CH
INT 21H
CODE ENDS
END START

MANUAL CALCULATIONS:

RESULT:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 64


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

FLOW CHART:

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 COLLEGE OF ENGINEERING & TECHNOLOGY Page 65


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

Exp No:
Date:
16. READING KEYBOARD BUFFERED WITH ECHO
ABSTRACT: To Read the Keyboard Buffered with Echo.
REGISTERS USED: AH, AL, SI
PORTS USED: None.
ALGORITHM:
Step 1: Start.
Step 2: Load the number 13h into AL register
Step 3: Initialize the AH register with 00h
Step 4: Display interrupt
Step 5: Initialize the AH register with 00h
Step 6: Key board Interrupt
Step 7: Compare the data in AL register with character ‘q’
Step 8: If equal to zero go to step 12
Step 9: Move the number 0Fh into BL register
Step 10: Move the number 14 into AH register
Step 11: Keyboard Interrupt
Step 12: Load the number 4C in AH register.
Step 13: Stop

PROGRAM:
ASSUME CS: CODE
CODE SEGMENT
ORG 1000H
START: MOV AH, 00H
MOV Al, 13H
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 COLLEGE OF ENGINEERING & TECHNOLOGY Page 66


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 67


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

MANUAL CALCLATIONS;

RESULT:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 68


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

FLOW CHART:

START

Initialize DS, CS
SI 2000H

AH 00H
Interrupt 16H

Compare AL, ‘q’

YES

ZF=
0 NO

[SI] AL
[SI] [SI+1]

STOP

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 69


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

Exp No:
Date:
17. 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:
Step 1: Start
Step 2: Initialize SI with Offset Result.
Step 3: Initialize AH with 00h
Step 4: Keyboard Interrupt
Step 5: Compare AL with character q
Step 6: Copy the contents AL into SI register
Step 7: If equal to zero go to step 10
Step 8: Increment SI
Step 9: Go to step 3 without condition
Step 10: Terminate the program
Step 11: 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 COLLEGE OF ENGINEERING & TECHNOLOGY Page 70


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 71


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

MANUAL CALCULATIONS:

RESULT:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 72


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

FLOW CHART:

START

Initialize DS
SI 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 COLLEGE OF ENGINEERING & TECHNOLOGY Page 73


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

Exp No:
Date:
18. DISPLAY STRING BY USING DOS & BIOS COMMANDS
ABSTRACT: To display the string character by using BIOS commands.
REGISTER USED: AL, AH, SI.
PORTS USED: None
ALGORITHM:
Step 1: Start
Step 2: Set the screen in Graphic mode
Step 3: Initialize AH with 00h
Step 4: Set the keyboard display mode.
Step 5: Initialize SI with 0000h.
Step 6: Copy the contents SI into AL register.
Step 7: Compare AL register with null character ‘!’
Step 8: If equal go to step 11.
Step 9: Move the number 14 into AH register.
Step 10: Move the number 05h into BL register.
Step 11: Set keyboard display mode.
Step 12: Go to step 6.
Step 13: Terminate the program.
Step 14: Stop.

PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
TEXT DB ‘ADITYA MICROPROCESSORS LAB!'
DATA ENDS
CODE SEGMENT
ORG 1000H
START: MOV AX, DATA
MOV DS, AX
MOV AH, 00H
MOV AL, 13H
INT 10H
MOV SI, 00H
BACK: MOV AL, TEXT [SI]
CMP AL, ‘!'
JE EXIT
MOV BL, 05H
MOV AH, 14
INT 10H
INC SI
JMP BACK
EXIT: MOV AH, 4CH
INT 21H
CODE ENDS
END START

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 74


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 75


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

MANUAL CALCULATIONS:

RESULT:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 76


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

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

MANUAL CALCULATIONS:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 77


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

Exp No:
Date:

19. A) TO GENERATE SINUSOIDAL WAVE BY USING PPI WITH 8086


AIM: To generate sinusoidal wave by using PPI with 8086.
REGISTERS USED: AX
PORTS USED: A8
ALGORITHM:
Step 1: Start
Step 2: Load BX with 1100H
Step 3: Load CL with 46.
Step 4: Copy the content in BX to AL register.
Step 5: Write AL onto address C0.
Step 6: Increment BX.
Step 7: Jump to step4.
Step 8: Go to step2
.
PROGRAM:
ASSUME CS: CODE
CODE SEGMENT
START:
AGAIN: MOV BX, 1100H
MOV CL, 46
BACK: MOV AL, [BX]
OUT C0, AL
INC BX
LOOP BACK
JMP AGAIN

RESULT:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 78


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 79


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

19. B) TO GENERATE SQUARE WAVE BY USING PPI WITH 8086


AIM: To generate square wave by using PPI with 8086.
REGISTERS USED: AL,CX
PORTS USED: PORT A
ALGORITHM:
Step 1: Start
Step 2: Load AL with 00H.
Step 3: Load C0 with AL.
Step 4: Go to step 9.
Step 5: Load AL with 0FFH.
Step 6: Load C0 with AL.
Step 7: Go to step 9.
Step 8: Go to step2.
Step 9: Load CX with 00FF.
Step 10: If CX not equal to zero jump to step 10..
Step 11: Go to steps that called it for return.
.
PROGRAM:

AGAIN: MOV AL, 00H


OUT C0, AL
CALL DELAY
MOV AL, 0FFH
OUT C0, AL
CALL DELAY
JMP AGAIN
DELAY: MOV CX, 00FFH
BACK : LOOP BACK
RET

RESULT:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 80


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 81


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

19. C) TO GENERATE TRIANGULAR WAVE BY USING PPI WITH


8086
AIM: To Generate Triangular wave by using PPI with 8086.
REGISTERS USED: AL,CX

PORTS USED: PORT A

ALGORITHM:
Step 1: Start
Step 2: Initialize the BL register as 00H.
Step 3: Move the contents of BL to AL.
Step 4: Write the AL value in Port.
Step 5: Increment the BL value and check if it is not zero go to step 2.
Step 6: Initialize the BL register as 0FFH.
Step 7: Move the contents of BL to AL.
Step 8: Write the AL value in Port.
Step 9: Decrement the BL register and check if it is not zero go to step 6.
Step 10: Go to step 2.
.
PROGRAM:

AGAIN: MOV BL, 00H


BACK: MOV AL, BL
OUT C0, AL
INC BL
JNZ BACK
MOV BL, 0FFH
BACK1: MOV AL, BL
OUT C0, AL
DEC BL
JNZ BACK1
JMP AGAIN

RESULT:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 82


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 83


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

Exp No:
Date:
20. 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.
ALGORITHM:
Step 1: Start
Step 2: Initialize keyboard and display mode in display mode by transferring 10H.
Step 3: Initialize clear display RAM with 0CCH.
Step 4: Initialize write display RAM with 90H
Step 5: Initialize CX with 10H.
Step 6: .Load SI with 1000H.
Step 7:.Move the content of SI to AL.
Step 8: Write AL onto C0H address location.
Step 9: Increment SI.
Step 10: Go to step 13.
Step 11: Go to step 7 if CX is not equal to 0.
Step 12: Jump to step 2.
Step 13: Load DX with 0A0FFH.
Step 14: .Decrement DX.
Step 15: If DX is not equal to zero then goto step 14. .
Step 16: Return to main program.
Step 17: Stop.

ALGORITHM FOR DELAY


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

PROGRAM:
AGAIN: MOV AL, 10H
OUT 0C2, AL
MOV AL, 0CCH
OUT 0C2, AL
MOV AL, 90H
OUT 0C2, AL
MOV CX, 10H
MOV SI, 1000H
NEXT: MOV AL, [SI]
OUT 0C0, AL
INC SI
CALL DELAY
LOOP NEXT
JMP AGAIN

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 84


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

MANUAL CALCULATIONS:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 85


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

DELAY: MOV DX, 0A0FFH


BACK: DEC DX
JNZ BACK
RET

RESULT:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 86


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 87


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

Exp No:
Date:

21. 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: P1
REGISTERS USED: A, DPTR
ALGORITHM:
Step 1: Start
Step 2: Move FF into port 1.
Step 3: Move the contents of A to P1.
Step 4: Move 4150H into DTPR.
Step 5: Move contents of A into contents of DTPR.
Step 6: Jump to step 5.
Step 7: Load A with 55H.
Step 8: Move the contents of A to P1.
Step 9: Jump to step 8.
Step 10: Stop.
PROGRAM FOR READING:

MOV P1, #0FFH


MOV A, P1
MOV DPTR, #4150H
MOVX @DPTR, A
HLT: SJMP HLT

PROGRAM FOR WRITING:

MOV A, #55H
MOV P1, A
HLT: SJMP HLT

RESULT:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 88


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

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

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 89


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

Exp No:
Date:
22. 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:
Step 1: Start
Step 2: Load R0 with 06H.
Step 3: Load DTPR with 4150H.
Step 4: Load SCON with 50H.
Step 5: Load TMOD with 20H.
Step 6: Load TH1 with FDH.
Step 7: Set bit TR1.
Step 8: Load A with content of DTPR.
Step 9: Load SBUF with contents of A.
Step 10: Repeat step 10 until T1=1, if check whether if T1=1, goto step8.
Step 11: Clear T1.
Step 12: Increment DTPR.
Step 13: Decrement R0, if R0≠0 goto step 8.
Step 14: Jump to step 2.
Step 15: Stop

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

RESULT:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 90


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

MANUAL CALCULATIONS:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 91


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

Introduction to Keil Simulation


1. Open the Keil Vision3 on desktop.

2.Go to file & open new file,type the program & save as file name.c.Go to Project – Open
Project and browse for saved file and open it.

3.Go to Project – Select Device for Target ‘Target1’.

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 92


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

4.Select ATMEL family microcontroller AT89S52 and click OK.

5. Go to project – Options for Target ‘Target1’.

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 93


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

6.Make sure that the oscillator frequency is 12MHz. Put tick mark on “use on chip ROM”. Go
to output, put tick mark on “create HEX file”. Click ok.

7.Build the target as illustrated in the figure below,check whether HEX file is created or not.

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 94


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

8.Running the Simulation

Having successfully built the target, we are now ready to start the debug session and run the
simulator.
First start a debug session.

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 95


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

PROLOAD:

Proload is a software which accepts only hex files. Once the machine code is
converted into hex code, that hex code has to be dumped into the microcontroller placed in
the programmer kit and this is done by the Proload. Programmer kit contains a
microcontroller on it other than the one which is to be programmed. This microcontroller has
a program in it written in such a way that it accepts the hex file from the keil compiler and
dumps this hex file into the microcontroller which is to be programmed. As this programmer
kit requires power supply to be operated, this power supply is given from the power supply
circuit designed above. It should be noted that this programmer kit contains a power supply
section in the board itself but in order to switch on that power supply, a source is required.
Thus this is accomplished from the power supply board with an output of 12volts or from an
adapter connected to 230 V AC.

1. Install the Proload Software in the PC.


2. Now connect the Programmer kit to the PC (CPU) through serial cable.

3. Power up the programmer kit from the ac supply through adapter.

4. Now place the microcontroller in the GIF socket provided in the programmer kit.

5. Click on the Proload icon in the PC. A window appears providing the information like
Hardware model, com port, device type, Flash size etc. Click on browse option to
select the hex file to be dumped into the microcontroller and then click on “Auto
program” to program the microcontroller with that particular hex file.

6. The status of the microcontroller can be seen in the small status window in the bottom
of the page.

7. After this process is completed, remove the microcontroller from the programmer kit
and place it in your system board. Now the system board behaves according to the
program written in the microcontroller.

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 96


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 97


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

Exp No:
Date:

23. SINUSOIDAL WAVE GENERATION BY DAC INTERFACING


WITH 8051

AIM: To generate sinusoidal wave using 8051 in C language.


PORTS USED: PORT A, Address 0X90.
ALGORITHM:
Step 1: Start
Step 2: Initialize port A address to special function register DACDATA.
Step 3: Assign the values of the sinusoidal wave (at the output of DAC) to WAVEVALUE
array.
Step 4: Initialize variable X to zero.
Step 5: Assign WAVEVALUE of X to DACDATA.
Step 6: Increment the variable X.
Step 7: Repeat the loop until X reaches to 11.
Step 9: Stop.

PROGRAM:

# include <reg51.h>
Sfr DACDATA = 0X90;
Void main ()
{
Unsigned char WAVEVALUE [12] = {128,192,238,255,238,192,128,64,17,0,17,64}
Unsigned char X;
While(1)
{
for (x=0; x<12;x++)
{
DACDATA = WAVEVALUE[x];
}
}
}

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 98


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

RESULT:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 99


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

Exp No:
Date:

24. Alphanumeric LCD panel and keypad input interface to 8051.

AIM: To read a key from interfaced keypad & display the same on Alphanumeric LCD
panel.
Ports used: PORT 0, PORT 1, PORT 2.

PROGRAM:

include<reg51.h>
#define port P1
#define dataport P2 // Dataport for lcd
#define key P0 // Port for keypad
#define sec 100
sbit rs = port^1;
sbit rw = port^2;
sbit en = port^3;
sbit col1=key^4;
sbit col2=key^5;
sbit col3=key^6;
sbit row1=key^0;
sbit row2=key^1;
sbit row3=key^2;
sbit row4=key^3;

void delay(unsigned int msec) //Time delay function


{
int i,j ;
for(i=0;i<msec;i++)
for(j=0;j<1275;j++);
}

void lcd_cmd(unsigned char item) //Function to send command to LCD


{
dataport = item;
rs= 0;
rw=0;
en=1;
delay(1);
en=0;
return;
}

void lcd_data(unsigned char item) //Funtion to send data on LCD


{
dataport = item;
rs= 1;

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 100


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

rw=0;
en=1;
delay(1);
en=0;
return;
}

void lcd_data_string(unsigned char *str) // Function to send string on LCD


{
int i=0;
while(str[i]!='\0')
{
lcd_data(str[i]);
i++;
delay(10);
}
return;
}

void lcd(unsigned char str[10]) // Funtion to Initialize LCD


{
lcd_cmd(0x38);
lcd_cmd(0x0e);
//delay(sec);
lcd_cmd(0x01);
//delay(sec);
lcd_cmd(0x82);
//delay(sec);
lcd_data_string(str);
}

void display(int a) //Display functon for LCD


{
switch(a)
{
case 1:lcd("1");
break;
case 2:lcd("2");
break;
case 3:lcd("3");
break;
case 4:lcd("4");
break;
case 5:lcd("5");
break;
case 6:lcd("6");
break;
case 7:lcd("7");
break;
case 8:lcd("8");
break;

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 101


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

case 9:lcd("9");
break;
case 0:lcd("0");
break;
case 11:lcd("*");
break;
case 12:lcd("#");
break;
}
}

void check_col1() //Function for checking column one


{
row1=row2=row3=row4=1;
row1=0;
if(col1==0)
display(1);
row1=1;
row2=0;
if(col1==0)
display(4);
row2=1;
row3=0;
if(col1==0)
display(7);
row3=1;
row4=0;
if(col1==0)
display(11);
row4=1;
}

void check_col2() //Function for checking column two


{
row1=row2=row3=row4=1;
row1=0;
if(col2==0)
display(2);
row1=1;
row2=0;
if(col2==0)
display(5);
row2=1;
row3=0;
if(col2==0)
display(8);
row3=1;
row4=0;
if(col2==0)
display(0);
row4=1;

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 102


MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.

void check_col3() //Function for checking column three


{
row1=row2=row3=row4=1;
row1=0;
if(col3==0)
display(3);
row1=1;
row2=0;
if(col3==0)
display(6);
row2=1;
row3=0;
if(col3==0)
display(9);
row3=1;
row4=0;
if(col3==0)
display(12); //For #
row4=1;
}

void main()
{
col1=col2=col3=1; //Input Port
while(1)
{
row1=row2=row3=row4=0;
if(col1==0)
check_col1();
else
if(col2==0)
check_col2();
else
if(col3==0)
check_col3();
}
}

RESULT:

ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 103

You might also like