MPMC Lab Manual 15-11-2016
MPMC Lab Manual 15-11-2016
MPMC Lab Manual 15-11-2016
LABORATORY MANUAL
(R13) III – B. Tech., II-Semester
ECE
Index
1. Introduction to MASM/TASM.
2. Arithmetic operation- Multi byte Addition and
Subtraction, Multiplication and Division- Signed and
unsigned Arithmetic operation, ASCII- Arithmetic
PART-I: operation.
MICROPROCESSOR 3. Logic operations-Shift and rotate- Converting packed
8086 BCD to unpacked BCD, BCD to ASCII conversion.
4. By using string operation and Instruction prefix: Move
Block, Reverse string, Sorting, Inserting, Deleting, Length
of the string, String comparison.
5. DOS/BIOS programming: Reading keyboard
(Buffered with and without echo) - Display characters,
Strings.
1.8259 – Interrupt Controller-Generate an interrupt using
8259 timer.
PART-II: 2.8279 – Keyboard Display- Write a program to display a
INTERFACING WITH string of characters.
MICROPROCESSOR 3.8255 – PPI-Write ALP to generate sinusoidal wave
using PPI.
4.8251 – USART-Write a program in ALP to establish
Communication between two processors.
PART-III: 1. Reading and Writing on a parallel port.
MICROCONTROLLER 2. Timer in different modes.
8051 3. Serial communication implementation.
1. Simple Calculator using 6 digit seven segment display
and Hex Keyboard interface to 8051.
2. Alphanumeric LCD panel and Hex keypad input
PART-IV: interface to 8051.
INTERFACING WITH 3. External ADC and Temperature control interface to
MICROCONTROLLER 8051.
4. Generate different waveforms Sine, Square,
Triangular, and Ramp, etc. using DAC interface to 8051;
change the frequency and Amplitude.
EX: No: 1
1. INTRODUCTION
ESA 86/88-2 is a powerful general purpose micro computer system which can be
operated with 8086 CPU. It is generally supplied with 8086 CPU to 8086 uses has to just
remove 8086 as set 8086 into that socket & set an output switch.8086 & 8088 are 3 rd
generation CPU from Intel that differ primary in thirds external data paths 8086 uses 16 bit
can be generated either 8086 or 8088.
The possible difference would be in the speed of execution in either case the CPU is
operated in the max mode 1.5A: 86/88-2 can be used not only as an industrial, instrumental &
learning aid but also a development tool in R & D labs. It is a versatile system and can be
configured in a number ways as per the user requirements various options the basic system
can be easily expanded through the system bus connection. The built in assembled features
supplies the task. Case of entering assembly language program on board provision for 8087
data process makes ESA 86/88-2 useful for a number of on-board provisions is an added
feature to make a care of the frequent power failure while conducting experiment on the
trainer.
To aid the user further various optional attachments like EARUM programming audio
cassettes interface are available. ESA 86/88-2 is operated from circuit terminals or a
computer system is a connection from a keyboard
1. Examine & optionally modify the contents of memory
2. Examine & optionally modify the contents of process register
3. Assemble & de assemble 8086/88 instruction
4. Perform fast numerical computation using the optional 8087 numerical data
5. Execute the user program at the full speed user program through single step and break
Point facilities.
6. Write/read data to/from input/output parts
7. Move a block of data or program within the memory
8. Download user program into ESA 8086/88-2 from fast counter
9. Transfer code and data to/from audio cassettes is a optional audiocassette interface
10. Read the program verify and branch check EPROM or vice optional PROM
Programmable module
11. Obtain a hard copy via controls complicated parallel printer interface
SPECIFICATIONS:
CONTROL PROCESSOR: 8086 CPU or 8086 operating at 5 MHz with maximum mode
(supplied with 8086 CPU) memory cycles has wait slates and i/o cycles
CO-PROCESSOR: On board 8087 numeric data processor memory EPROM: 4JEDEC
compatible 8 bit EPROM offer the following options: 64k bytes using 27/285 or:128k bytes
using 27/2565 or :256 K bytes using 275/255 System firmware is supplied in 2x27565 the
other two sockets are for user expansion
RAM: 4JEPEC compatible slots after the following 128kb using 622565 64 KB using
2*6022565. The RAM has also a battery backup facility peripherals and controller.
8251A: programmable communications interface for social communication supporting all
standards from 110-19200.
825-3-5: programmable interval time „0‟ is used for generating basic block timer 1 and timer
11 are available for users
8255A: programmable peripherals interface devices provide us programmable I/O devices.
8288: bus controller uses for generating control signal interrupts
EXTERNAL: NMI interrupts for INTR key and keyboard INTR controlled through 8259A
on board interrupts controller provides interrupt vector for B sources complete flexibility for
selecting either off board interrupt source.
8251/JXRD4 and RXRD4
8253/OUT 1 OUT II
8255/PCD and PC3 in hand shake mode
8087/NDDI INT
INTERNAL: Interrupt sector 1-single step &31 break points monitor
CPUSIGNAL: De-multiplexed and fully differentiate signals are available on 2.50 per
ribbon cable connection
PARALLEL I/O: As per programmable I/O line/TTL compatible serial
SERIAL I/O: RS232C on-board b-type formal connection
POWER SUPPLY: +5 V at 3.0A
DEBUG COMMANDS
Assemble A[address]
Compare c[compare]
Dump d[manage]
Enter E[address list]
Fill F[range list]
Ev G[address][address]
Flux H[value][value]
Load L[address]
Input I[port]
Move M[range address]
Proceed N[path name][org list]
Quit Q
Register R[register]
Search S[range list]
True T[address][value]
Unassembled U[range]
Viva Questions
1. What is Microprocessor?
2. Define Compiler
3. Define Interpreter
4. Define Assembler
5. What is Assembly level language?
6. Abbreviate MASM & TASM
7. Differentiate micro & macro
8. Define two pass assembler
9. What are the advantages of modular programming?
10. What is linking and relocation?
11. Explain about .MODEL SMALL?
FLOW CHART:
START
Perform addition on
contents of AX, BX
registers
STOP
RESULT:
GIVEN INPUT: OUTPUT:
AL= AL=
BL= BL=
MANUPLATION:
AL=
BL=
ARITHMETICOPERATIONS
EX: No: 2
ADDITION
AIM: To write an assembly language program to perform addition operation
Starting address:
Ending address:
ALGORITHM:
1. Start the program
2. Move the input value into the specified register.
3. Move the other value into the other specified register.
4. Perform the arithmetic addition between the two registers & store the result in the
register specified
5. Stop
PROGRAM:
Address Hexadecimal code Label Mnemonic Operands Comments
Copy immediate number to
MOV AL,
AL register
Copy immediate number to
MOV BL,
BL register
Add contents of AL and BL
ADD AL,BL
registers
RESULT:
FLOW CHART:
Start
STOP
RESULT:
GIVEN INPUT: OUTPUT:
AL= AL=
BL= BL=
MANUPLATION:
AL=
BL=
SUBTRACTION
AIM: To write an assembly language program to perform subtraction operation.
ALGORITHM:
1. Start the program.
2. Move the specified immediate numbers to AL, BL registers.
3. Subtract the contents of BL from the contents of AL register the result will be stored
in the destination register.
4. Stop the program.
PROGRAM:
Address Hexadecimal code Label Mnemonic Operand Comments
RESULT:
FLOWCHART:
START
STOP
RESULT:
AL= AL=
BL= BL=
MANUPLATION:
AL=
BL=
MULTIPLICTION
AIM: To write an assembly language program to perform multiplication operation.
ALGORITHM:
1. Start the program.
2. Copy the immediate numbers to AL, BL registers.
3. Perform multiplication operation between the contents of AL and BL register the
result will be stored in the destination register specified.
4. Terminate the program.
PROGRAM:
Address Hexadecimal code Label Mnemonic Operand Comments
Copy the immediate number to
MOV AL,
AL register
Copy the immediate number to
MOV BL,
BL register
Multiply content of AL with the
MUL BL
contents of BL register
RESULT:
FLOW CHART:
START
STOP
RESULT:
GIVEN INPUT: OUTPUT:
AL= AL=
BL= BL=
MANUPLATION:
AL=
BL=
SIGNED MULTIPLICTION
AIM: To write an assembly language program to perform signed multiplication operation.
ALGORITHM:
5. Start the program.
6. Copy the immediate numbers to AL, BL registers.
7. Perform multiplication operation between the contents of AL and BL regis ter the
result will be stored in the destination register specified.
8. Terminate the program.
PROGRAM:
Address Hexadecimal code Label Mnemonic Operand Comments
Copy the immediate number to
MOV AX,
AL register
Copy the immediate number to
MOV BX,
BL register
NEG BX
MOV CX,AX
NEG CX
RESULT:
FLOW CHART:
START
STOP
RESULT:
GIVEN INPUT: OUTPUT:
AL= AL=
BL= BL=
MANUPLATION:
AL=
BL=
DIVISION
AIM: To write an assembly language program to perform division operation.
ALGORITHM:
1. Start the program.
2. Copy the immediate numbers to AL, BL registers.
3. Divide the content of AL register with content of BL register & store the result in
specified destination register.
4. Terminate the program.
PROGRAM:
RESULT:
FLOWCHART:
START
CX
=0
=
STOP
SIGNED DIVISION
AIM: To write an assembly language program to perform signed division operation.
ALGORITHM:
5. Start the program.
6. Copy the immediate numbers to AL, BL registers.
7. Divide the content of AL register with content of BL register & store the result in
specified destination register.
8. Terminate the program.
PROGRAM:
NEG AX
MOV CX,AX
NEG CX
RESULT:
FLOWCHART:
START
CX
=0
=
STOP
ALGORITHM:
1. Start the program.
2. Move the immediate number to CX register.
3. Initialize the source index pointer SI and destination index DI with the specified
address value to point out the desired memory locations.
4. Copy the content of SI into AL register.
5. Perform the addition with carry operation between the content of DI and the content
of AL & store the result in specified destination register.
6. Increment the SI and DI address values by 2 times.
7. Decrement the value of CX register by one.
8. Repeat the step5 to step8 until the condition “CX=0” has been satisfied.
9. When “CX=0” then continue the next step of the main program.
10. Terminate the program.
RESULT:
INPUT:
Source index:
Input address Value
Destination index:
Input address Value
OUTPUT:
Destination index:
Output address Value
PROGRAM:
INC SI Increment SI
INC DI Increment DI
INC DI Increment DI
DEC CX Decrement CX
Jump to loop1 address if CX register is
JNZ Loop1
not equal to zero
INT 03 Terminate the program
RESULT:
FLOWCHART:
START
Decrement CX by
once
NO
CX
=0 YES
=
STOP
MULTIBYTE SUBTRACTION
ALGORITHM:
1. Start the program.
2. Move the immediate number to CX register.
3. Initialize the source index pointer SI and destination index DI with the specified
address value to point out the desired memory locations.
4. Copy the content of SI into AX register.
5. Perform the subtraction with borrow operation between the content of DI and the
content of AX & store the result in specified destination register.
6. Increment the SI and DI address values by 2 times.
7. Decrement the value of CX register by one.
8. Repeat the step5 to step8 until the condition “CX=0” has been satisfied.
9. When “CX=0” then continue the next step of the main program.
10. Terminate the program.
RESULT:
INPUT:
Source index:
Input address Value
Destination index:
Input address Value
OUTPUT:
Destination index:
Output address Value
PROGRAM:
INC SI Increment SI
INC DI Increment DI
INC DI Increment DI
DEC CX Decrement CX
Jump to loop1 address if CX register is
JNZ Loop1
not equal to zero
INT 03 Terminate the program
RESULT:
INPUT:
OUT PUT:
RESULT:
FLOWCHART:
START
STOP
RESULT:
GIVEN INPUT: OUTPUT:
AX= AX=
BL= BL=
ALGORITHM:
1. Start the program.
2. Move the input byte to specified register.
3. Move another byte to specified register.
4. Add contents of specified registers.
5. Perform AAA operation and store the result in specified destination register.
6. Stop
PROGRAM:
Hexadecimal
Address Label Mnemonic Operand Comments
Code
Copy immediate number to AL
MOV AL,33h
register.
Copy immediate number to BL
MOV BL,32h
register.
Add contents of AL and BL
ADD AL,BL
registers
Perform the operation ASCII
AAA
adjust after addition
OR AX,3030H
RESULT:
FLOWCHART:
START
STOP
RESULT:
GIVEN INPUT: OUTPUT:
AX= AX=
BL= BL=
ASCII SUBTRACTION
AIM: To write an assembly language program to perform ASCII adjust after subtraction.
Algorithm:
1. Start the program
2. Move the input byte to specified registers.
3. Move another byte to specified register.
4. Subtract the contents of specified register from the content of another register.
5. Perform AAS operation and store the result in specified register.
6. Stop.
PROGRAM:
Hexadecimal
Address Label Mnemonic Operand Comments
Code
Copy immediate number to
MOV AL,39H
AL register.
Copy immediate number to
MOV BL,36H
BL register.
Subtract the content of BL
SUB AL,BL from the content of AL
register.
Perform the operation ASCII
AAS
adjust after subtraction
OR AX,3030H
RESULT:
FLOWCHART:
START
STOP
RESULT:
AX= AX=
BL= BL=
ASCII MULTIPLICATION
AIM: To write an assembly language program to perform ASCII adjust after multiplication.
ALGORITHM:
1. Start the program
2. Move the input byte to specified registers.
3. Move another byte to specified register.
4. Multiply the contents of specified register with the content of another register.
5. Perform AAM operation and store the result in specified register.
6. Stop.
PROGRAM:
Hexadecimal
Address Label Mnemonic Operand Comments
Code
Copy immediate number to AL
MOV AL,36H
register
Copy immediate number to BL
MOV BL,32H
register
SUB AL,30H
SUB BL,30H
Multiply the content of BL
MUL BL
with the content of AL register
Perform the operation ASCII
AAM
adjust after multiplication
OR AX,3030H
RESULT:
FLOWCHART:
START
STOP
RESULT:
AX= AX=
BL= BL=
RESULT:
ASCII DIVISION
AIM: To write an assembly language program to perform ASCII adjust before division.
REQUIRED SOFTWARE: MASM611
Starting address:
Ending address:
ALGORITHM:
1. Start the program
2. Move the input byte to specified registers.
3. Move another byte to specified register.
4. Perform AAD operation.
5. Divide the content of specified register with the content of another register.
6. Stop.
PROGRAM:
Hexadecimal
Address Label Mnemonic Operand Comments
Code
Copy immediate number to
MOV AL,39H
AL register
Copy immediate number to
MOV BL,33H
BL register
SUB AL,30H
SUB BL,30H
Perform the operation ASCII
AAD
adjust before division
Divide the content of AX with
DIV BL
the content of BL
OR AX,3030H
VIVA QUESTIONS
1. What is an extended accumulator?
2. AL and BL are used for multiplying why not AX & BX?
3. Instead of using MOV BL is it not possible to MUL num2?
4. Why AL & BL are not used in signed multiplication?
5. If result exceeds 32 bit where is it stored?
6. What is the name given to the register combination DX: AX?
7. What happens if DX register contains a nonzero value before DIV instruction?
8. In a program instead of DIV BX is it possible to use DIV num2?
9. Describe about MUL, IMUL, DIV, IDIV instructions
10. What is the purpose of ASCII addition?
FLOW CHART:
START
STOP
RESULT:
AX= AX=
BX= BX=
MANUPLATION:
AX=
BX=
LOGICAL OPERATIONS
Ex: No: 3
Logical AND
AIM: To write an assembly language program to perform logical AND operation.
REQUIRED SOFTWARE: MASM611
Starting address:
Ending address:
ALGORITHM:
1. Start the program
2. Move the input byte to specified register
3. Move the other byte to specified register
4. Perform logical AND operation between AX and BX registers and store the result in
specified register
5. Stop
PROGRAM:
Address Hexadecimal code Label Mnemonic Operand Comments
RESULT:
FLOW CHART:
START
STOP
RESULT:
AX= AX=
BX= BX=
MANUPLATION:
AX=
BX=
Logical OR
AIM: To write an assembly language program to perform logical OR operation.
ALGORITHM:
1. Start the program
2. Move the input byte to specified register
3. Move the other byte to specified register
4. Perform logical OR operation between AX and BX registers and store the result in
specified register
5. Stop
PROGRAM:
Address Hexadecimal code Label Mnemonic Operand Comments
RESULT:
FLOW CHART:
START
STOP
RESULT:
AX= AX=
BX= BX=
MANUPLATION:
AX=
BX=
LOGICAL XOR
AIM: To write an assembly language program to perform logical XOR operation.
ALGORITHM:
1. Start the program
2. Move the input byte to specified register
3. Move the other byte to specified register
4. Perform logical OR operation between AX and BX registers and store the result in
specified register
5. Stop
PROGRAM:
Address Hexadecimal code Label Mnemonic Operand Comments
RESULT:
FLOW CHART:
STAR
T
STOP
RESULT:
AX= AX=
MANUPLATION :
AX=
LOGICAL NOT
AIM: To write an assembly language program to perform logical NOT operation.
ALGORITHM:
1. Start the program.
2. Move the input byte to specified register.
3. Perform logical NOT operation on the content of AX register.
4. Stop
PROGRAM:
Hexadecimal
Address Label Mnemonic Operand Comments
code
Copy immediate number to AX
MOV AX,
register
Perform NOT operation on the
NOT AX
content of AX register
INT 03 Terminate the program
RESULT:
FLOW CHART:
START
STOP
RESULT:
AX= AX=
CL= CX=
MANUPLATION:
AX=
CL=
ALGORITHM:
1. Start the program
2. Move the immediate number to AX register.
3. Move the count value to CL register.
4. Perform the shift left operation on the content of AX register.
5. Stop
PROGRAM:
Address Hexadecimal code Label Mnemonic Operand Comments
Copy immediate number to AX
MOV AX,
register
Copy immediate number to CL
MOV CL,
register
Perform shift left operation on
SHL AX,CL
the content of AX register
INT 03 Terminate the program
RESULT:
FLOW CHART:
TART
STOP
RESULT:
AX= AX=
CL= CX=
MANUPLATION:
AX=
CL=
ALGORITHM:
1. Start the program
2. Move the immediate number to AX register.
3. Move the count value to CL register.
4. Perform the shift right operation on the content of AX register.
5. Stop
PROGRAM:
Address Hexadecimal code Label Mnemonic Operand Comments
Copy immediate number to AX
MOV AX,
register
Copy immediate number to CL
MOV CL,
register
Perform shift right operation
SHR AX,CL
on the content of AX register
INT 03 Terminate the program
RESULT:
FLOW CHART:
START
STOP
RESULT:
AX= AX=
CL= CX=
MANUPLATION:
AX=
CL=
ALGORITHM:
1. Start the program
2. Move the immediate number to AX register.
3. Move the count value to CL register.
4. Perform the rotate left operation on the content of AX register.
5. Stop
PROGRAM:
Address Hexadecimal code Label Mnemonic Operand Comments
Copy immediate number to AX
MOV AX,
register
Copy immediate number to CL
MOV CL,
register
Perform rotate left operation
ROL AX,CL
on the content of AX register
INT 03 Terminate the program
RESULT:
FLOW CHART:
START
STOP
RESULT:
AX= AX=
CL= CX=
MANUPLATION:
AX=
CL=
ALGORITHM:
1. Start the program
2. Move the immediate number to AX register.
3. Move the count value to CL register.
4. Perform the rotate right operation on the content of AX register.
5. Stop
PROGRAM:
Address Hexadecimal code Label Mnemonic Operand Comments
Copy immediate number to AX
MOV AX,
register
Copy immediate number to CL
MOV CL,
register
Perform rotate right operation
ROR AX,CL
on the content of AX register
INT 03 Terminate the program
RESULT:
FLOW CHART:
START
STOP
EX:No:3
CONVERSIONS
PACKED BCD TO UNPACKED BCD
AIM:
To write an assembly language program to convert packed BCD to unpacked BCD.
ALGORITHM:
1. Start the program
2. Clear the contents of AX,BX registers
3. Initialize the source index pointer (SI) with the specified address value to point out the
desired memory location.
4. Copy the content specified memory location to AL register
5. Copy the content of AL register to BL register
6. Perform AND operation between the content of AL register and the immediate value
0F.
7. Perform AND operation between the content of BL register and the immediate value
0F0.
8. Initialize the CL register with the desired count value.
9. Perform rotate right operation on the content of BL register.
10. Copy the content of BL register to AH register.
11. Copy the content of AX register to the specified memory location.
12. Stop the program.
RESULT:
GIVEN INPUT:
3000-
OUTPUT:
3000-
3001-
AX=
PROGRAM:
.MODEL SMALL
.286
.DATA
ORG 2000H
MOV AX, 0000H
MOV BX, 0000H
MOV SI,3000H
MOV AL,[SI]
MOV BL,AL
AND AL,0FH
AND BL,0F0H
MOV CL,04H
ROR BL,CL
MOV AH,BL
MOV [SI],AX
INT 03
.EXIT
END
RESULT:
FLOWCHART:
START
STOP
AIM:
To write an assembly language program to convert unpacked BCD format to packed BCD
format.
ALGORITHM:
1. Start the program
2. Clear the contents of AX and BX registers.
3. Initialize the source index pointer (SI) with the specified address value to point out the
desired memory location.
4. Move the value of SI memory location to the specified AL register.
5. Increment the value of SI.
6. Move the value of memory location pointed by SI BL register.
7. Initialize CL register with the required count value.
8. Perform shift left operation on the content of AL register.
9. Add the content of AL register with the content of BL register.
10. Stop the program.
RESULT:
GIVEN INPUT:
4000-
4001-
OUTPUT:
AX=
PROGRAM:
.MODEL SMALL
.286
.DATA
ORG 2000H
MOV AX,0000H
MOV BX,0000H
MOV SI,4000H
MOV AL,[SI]
INC SI
MOV BL,[SI]
MOV CL,04H
SHL AL,CL
ADD AL,BL
INT 03
.EXIT
END
RESULT:
FLOW CHART:
START
STOP
ALGORITHM:
1. Start the program
2. Clear the contents of AX, BX registers.
3. Initialize the source index pointer (SI) with the specified address value to point out the
desired memory location.
4. Initialize CL register with some count value.
5. Copy the content of specified memory location to AL register.
6. Copy the content of AL to BL register.
7. Perform AND operation between the content of AL and immediate number 0F.
8. Shift the content of BL register to left with specified number of bits.
9. Add the content of AL register with the immediate number 30.
10. Add the content of BL register with the immediate number 30.
11. Stop the program.
RESULT:
GIVEN INPUT:
3000-
OUTPUT:
AX=
BX=
PROGRAM:
.MODEL SMALL
.286
.DATA
ORG 3000H
MOV AX,0000H
MOV BX,0000H
MOV CL,04H
MOV SI,3000H
MOV AL,[SI]
MOV BL,AL
AND AL,0FH
SHR BL, CL
ADD AL,30H
ADD BL,30H
INT 03
.EXIT
END
RESULT:
FLOWCHART:
START
Perform OR operation between the contents of AL, BL and store result in specified
register
STOP
ALGORITHM:
1. Start the program
2. Clear the contents of AX,BX registers
3. Initialize CL register with some count value.
4. Initialize the source index pointer (SI) with the specified address value to point out the
desired memory location.
5. Copy the contents of specified memory location to AL and BL register.
6. Perform AND operation between the content BL register and immediate number 0F.
7. Shift left the content of AL register with the specified number of bits.
8. Perform OR operation between the contents AL & BL registers.
9. Stop the program
RESULT:
GIVEN INPUT:
6000-
6002-
OUTPUT:
AX=
PROGRAM:
.MODEL SMALL
.286
.DATA
ORG 2000H
MOV AX,0000H
MOV BX,0000H
MOV CL,04H
MOV SI,6000H
MOV DI,6002H
MOV AL,[SI]
MOV BL,[DI]
AND BL,0FH
SHL AL,CL
OR AL,BL
INT 03
.EXIT
END
RESULT:
VIVA QUESTIONS
1. What is the purpose of the instruction ROR AL, CL?
2. What is the purpose of the instruction AND AL, 0FH & AND AL, 0F0H in the
program?
3. What is the expansion of UPBCD?
4. What is the use of DAA instruction?
5. What is the reason for packing unpacked BCD?
6. What is common between unpacked BCD and ASCII?
7. What is the difference between adding 30h and OR 30H to a BCD number to conversion
to ASCII?
8. Why unpacking is necessary during the conversion?
9. What is the ASCII character for symbol A?
10. What is the ASCII character for symbol zero „0‟?
FLOWCHART:
START
RESULT:
INPUT:
Source Index
Address Values
OUTPUT:
Source index:
Address Values
PROGRAM:
.MODEL SMALL
.286
.CODE
ORG 2000H
MOV SI,0500H
MOV CL,[SI]
DEC CL
LOOP1: MOV SI,0500H
MOV CH,[SI]
DEC CH
INC SI
LOOP2: MOV AL,[SI]
INC SI
CMP AL,[SI]
JB LOOP3
XCHG AL,[SI]
XCHG AL,[SI-01]
LOOP3: DEC CH
JNZ LOOP2
DEC CL
JNZ LOOP1
INT 03
.EXIT
END
RESULT:
FLOWCHART: START
NOof CH by
Decrement the value
one
YES NO
If
CH!=0
DESCENDING ORDER
AIM:
To write an assembly language program to perform descending order on the given string.
REQUIRED SOFTWARE: MASM611
Starting address:
Ending address:
ALGORITHM:
1. Start the program
2. Initialize the source index pointer (SI) with the specified address value to point out the
desired memory location.
3. Copy the content of SI memory location into CL register.
4. Decrement the value of CL register.
5. Copy the content of SI memory location into CH register.
6. Decrement the value of CH register.
7. Increment the value of memory location pointed by SI by once.
8. Now copy the content of SI memory location into AL register.
9. Increment the value of SI.
10. Compare the content of AL with the content specified memory location pointed by SI.
11. If the content of AL is greater than the content of SI jump to step-14 otherwise continue
with the next step.
12. Perform exchange operation between the contents of AL and SI memory location.
13. Perform exchange operation between the contents of AL and [SI-01] memory location.
14. Decrement the content of CH register by one.
15. If the content of CH!=0 then go to step-8.
16. Decrement the content of CL register by one.
17. If the content of CL!=0 then go to step-5.
18. Stop the program
RESULT:
INPUT:
Source Index
Address Values
OUTPUT:
Source index:
Address Values
PROGRAM:
.MODEL SMALL
.286
.CODE
ORG 2000H
MOV SI,0500H
MOV CL,[SI]
DEC CL
LOOP1: MOV SI,0500H
MOV CH,[SI]
DEC CH
INC SI
LOOP2: MOV AL,[SI]
INC SI
CMP AL,[SI]
JNB LOOP3
XCHG AL,[SI]
XCHG AL,[SI-01]
LOOP3: DEC CH
JNZ LOOP2
DEC CL
JNZ LOOP1
INT 03
.EXIT
END
RESULT:
FLOW CHART:
START
T
Initialize CL register by a
count value
If
CL!=0
STOP
AIM:
To write an assembly language program to move a block of data from one memory location
to
another memory location.
ALGORITHM:
1. Start the program.
2. Clear the contents of AX & BX registers.
3. Initialize the source index pointer SI and destination index DI with the specified
address value to point out the desired memory locations.
4. Load the contents in specified memory locations of SI & DI before execution.
5. Copy the immediate number in the CL register.
6. Copy the content of specified memory location [SI] into AL.
7. Copy the content of AL register into specified memory location [DI].
8. Increment the address value of the specified memory locations SI and DI by once.
9. Decrement the value of CL register.
10. If CL!=0 goto step-6 until CL=0.
11. Stop the program.
RESULT:
INPUT:
Source index Values
OUTPUT:
PROGRAM:
.MODEL SMALL
.286
.DATA
ORG 2000H
MOV AX,0000H
MOV BX,0000H
MOV SI,
MOV DI,
MOV CL,
LOOP1: MOV AL,[SI]
MOV [DI],AL
INC SI
INC DI
DEC CL
JNZ LOOP1
INT 03
.EXIT
END
RESULT:
FLOWCHART:
STAR
T
Initialize the AX
register
If
YES AL!=BNO
L
STOP
Copy the immediate
number to AX
register
STOP
STRING COMPARISON
AIM:
To write an assembly language program to compare two strings.
ALGORITHM:
1. Start the program.
2. Initialize the AX register .
3. Initialize the source index pointer SI and destination index DI with the specified
address value to point out the desired memory locations.
4. Load the contents in specified memory locations of SI & DI before execution.
5. Copy the immediate number in the CL register.
6. Copy the content of specified memory location [SI] into AL and [DI] into BL.
7. Compare the contents of AL & BL register.
8. If the content of AL is not equal to the content of BL then go to step-13.
9. Increment the value of SI & DI by once.
10. Decrement the value of CL register.
11. If CL!=0 goto step-6.
12. Copy the immediate number to AX register and terminate the program.
13. Copy the given immediate content to AX register.
14. Stop the program.
RESULT:
INPUT:
Source Index: Destination Index:
Address Values
Address Values
OUTPUT:
When Strings are equal: AX=
When Strings are not equal: AX=
PROGRAM:
.MODEL SMALL
.286
.DATA
ORG 2000H
MOV AX, 0000H
MOV SI,
MOV DI,
MOV CL,
LOOP 2: MOV AL,[SI]
MOV BL,[DI]
CMP AL,BL
JNE LOOP1
INC SI
INC DI
DEC CL
JNZ LOOP2
MOV AX,0000H
INT 03
LOOP1: MOV AX,0001H
INT 03
.EXIT
END
RESULT:
FLOWCHART:
START
If
[SI]<[DI]
YES
NO
STOP
STRING REVERSAL
AIM:
To write an assembly language program to perform string reversal operation
ALGORITHM:
1. Start the program.
2. Initialize the AX & BX register.
3. Initialize the source index pointer SI and destination index DI with the specified
address value to point out the desired memory locations.
4. Copy the content of SI into AL register.
5. Copy the content of DI into BL register.
6. Exchange the contents of AL and BL registers.
7. Copy the contents of AL and BL registers to SI and DI memory locations.
8. Increment the value of SI memory location.
9. Decrement the value of DI memory location.
10. Compare the address values of SI and DI.
11. If [SI]<[DI] goto step-4.
12. Stop the program.
RESULT:
INPUT:
ADDRESS VALUES
OUTPUT:
ADDRESS VALUES
PROGRAM:
.MODEL SMALL
.286
.CODE
ORG 2000H
MOV AX,0000H
MOV BX,0000H
MOV SI,
MOV DI,
LOOP1: MOV AL,[SI]
MOV BL,[DI]
XCHG AL,BL
MOV [SI],AL
MOV [DI],BL
INC SI
DEC DI
CMP SI,DI
JB LOOP1
INT 03
.EXIT
END
RESULT:
VIVA QUESTIONS
1. What is the purpose of string length?
2. What does „equ‟ stands for?
3. What is the purpose of label start after the end directive?
4. What is the operation performed by the instruction cmp al, $?
5. Why SI is not been incremented in the program?
6. What is the significance of CLD?
7. How does CMPSB perform the comparison?
8. After executing the instructions mov ah,02h / int 21h, what are contents of AL ?
9. What are the contents of AH for displaying a sting in the screen?
10. What are the contents of AH for accepting a number from keyboard?
11. Which register contains the address of the string to be displayed on screen?
6) If the Trainer is connected to COM1 port on your Host PC & configured for
9600-baud rate, click No. Click Yesotherwise. If yes, you will see the following
dialog box.
7) Select the Baud Rate as per the dipswitch configuration on ESA 86/88E
Trainer. Select the Com Port where the trainer is connected. Click Apply. You
should then see the following window.
8) Click on the „download’ option in the above window and browse ‘.hex’ file
of the current program and click ok. After downloading the file click on „ cmd‟
option in the above window and then to execute the current program give the
command ‘g 0000:2000’ (i.e., starting address of the program)from
keyboard. Check out the output on the interface or study card kit which has
connected to the 8086 microprocessor kit.
9) In some cases if the communication is not established you will see the
following
Dialog box. In this case please check the Power on ESA 86/88E Trainer. Check
whether Serial cable is connected to the PC &ESA 86/88E Trainer and check
the parameter by clicking Settings.
OUT PUT:
RESULT:
OUTPUT:
RESULT:
AIM: To write an assembly language program to read the string from keyboard without echo
by using DOS functions
OUT PUT
RESULT:
DISPLAY STRING
AIM: To write an assembly language program to display the string by using DOS functions
Starting address:
Ending address
PROGRAM
.MODEL SMALL
.286
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
MESSAGE DB 0DH, 0AH,"STUDY OF MICROPROCESSORS IS INTERFACING",
0DH, 0AH, "$"
DATA ENDS
CODE SEGMENT
ORG 2000H
START : MOV AX,DATA
MOV DS, AX
MOV AH, 09H
MOV DX, OFFSET MESSAGE
INT 21H
MOV AH, 4CH
INT 21H
CODE ENDS
END START
.EXIT
END
VIVA QUESTIONS
1. Abbreviate DOS & BIOS
2. Why INT21H is used in the Program?
3. Why BIOS interrupt is called as video service interrupt?
4. Why INT10H is used in the program?
5. What is the use of BIOS CALLS?
6. In echo program AH register should loaded with which DOS function?
7. In without echo program AH register should loaded with which DOS function?
8. Why INT09H is used in DOS calls?
9. What happened If AH is loaded with 4CH in program
10. Why INT11, INT12 and INT13H are used?
EX: No:
8259 INTERRUPT CONTROLLER
Aim: To write an assembly language program to generate interrupts by using 8259 interrupt
controller which is interfacing with 8086 microprocessor.
Apparatus:Hardware: soft ware
8086 Microprocessor Kit ESA 86
8259 interrupt controller kit
FRC, USB cables
Power adapter
Theory:
INTERRUPT SEQUENCE
The powerful features of the 8259A in a microcomputer system are its programmability and
the interrupt routine addressing capability. The latter allows direct or indirect jumping to the
specific interrupt routine requested without any polling of the interrupting devices. The
normal sequence of events during an interrupt depends on the type of CPU being used.
The events occur as follows in an MCS-80/85 system:
1. One or more of the INTERRUPT REQUEST lines (IR7±0) are raised high, setting the
corresponding IRR bit(s).
2. The 8259A evaluates these requests, and sends an INT to the CPU, if appropriate.
3. The CPU acknowledges the INT and responds with an INTA pulse.
4. Upon receiving an INTA from the CPU group, the highest priority ISR bit is set, and
the corresponding IRR bit is reset. The 8259A will also release a CALL instruction
code (11001101) onto the 8-bit Data Bus through its D7±0 pins.
5. This CALL instruction will initiate two more INTA pulses to be sent to the 8259A
from the CPU group.
6. These two INTA pulses allow the 8259A to release its preprogrammed subroutine
address onto the Data Bus. The lower 8-bit address is released at the first INTA pulse
and the higher 8-bit address is released at the second INTA pulse.
7. This completes the 3-byte CALL instruction released by the 8259A. In the AEOI
mode the ISR bit is reset at the end of the third INTA pulse. Otherwise, the ISR bit
remains set until an appropriate EOI command is issued at the end of the interrupt
sequence.
The events occurring in an 8086 system are the same until step 4.
4. Upon receiving an INTA from the CPU group, the highest priority ISR bit is set and the
corresponding IRR bit is reset. The 8259A does not drive the Data Bus during this cycle.
5. The 8086 will initiate a second INTA pulse. During this pulse, the 8259A releases an 8-bit
pointer onto the Data Bus where it is read by the CPU.
6. This completes the interrupt cycle. In the AEOI mode the ISR bit is reset at the end of the
second INTA pulse. Otherwise, the ISR bit remains set until an appropriate EOI command is
issued at the end of the interrupt subroutine.
If no interrupt request is present at step 4 of either\ sequence (i.e., the request was too
short in duration) the 8259A will issue an interrupt level 7. Both the vectoring bytes and the
CAS lines will look like an interrupt level 7 was requested.
When the 8259A PIC receives an interrupt, INT becomes active and an interrupt
acknowledge cycle is started. If a higher priority interrupt occurs between the two INTA
pulses, the INT line goes inactive immediately afte r the second INTA pulse. After an
unspecified amount of time the INT line is activated again to signify the higher priority
interrupt waiting
for service. This inactive time is not specified and can vary between parts. The designer
should be aware of this consideration when designing a system which uses the 8259A. It is
recommended that proper asynchronous design techniques be followed.
PROGRAM:
DISPM EQU 0B5BH ; DISPLAY ROUTINE ADDRESS TO DISPLAY
; MESSAGE ON SERIAL
ORG 8000H
START: MVI A, 12H ; single, edge triggerd mode,
; call address interval 8.
OUT 90H
MVI A,81H
OUT 91H
MVI A, 20H
OUT 90H
EI
SSS: JMP SSS
UP: RST 3
ORG 8100H
LXI H, MES0
JMP SUBRT
NOP
NOP
LXI H, MES1
JMP SUBRT
NOP
NOP
LXI H, MES2
JMP SUBRT
NOP
NOP
LXI H, MESG3
JMP SUBRT
NOP
NOP
LXI H, MESG4
JMP SUBRT
NOP
NOP
LXI H, MESG5
JMP SUBRT
NOP
NOP
LXI H, MESG6
JMP SUBRT
NOP
NOP
LXI H, MESG7
JMP SUBRT
NOP
NOP
SUBRT: CALL DISPM
JMP UP
RESULT:
VIVA QUESTIONS:
1. What is an Interrupt?
2. What is the need for interrupt controller?
3. List some of the features of INTEL 8259 (Programmable Interrupt Controller)
4. Differentiate software and hardware interrupts
5. What is meant by NMI?
6. Explain all initialization and operational command word format of 8259?
7. With single 8259 how many interrupts are possible?
8. With cascading mode of 8259 how many interrupts are possible?
9. How many 8259 ICs will be required for cascading mode?
10. What is the difference between polled command mode and vectored (interrupt driven)
command mode of 8259?
PROGRAM:
DEMONSTRATION PROGRAM FOR 86/88E TRAINER
; WRITEN BY SIRI 06.08
; PORTA INTPUT 0FFE0
; PORTB OUTPUT 0FFE2
OUTPUT 2500AD
ORG 2000H
MOV AX,0000H ; Clear AX
MOV AL,90H ; Initiasilse 8255 ports as above
MOV DX,0FFE6H
OUT DX,AL
CALL CLR ; Clear LEDs
BACK: CALL KESCN ; Identify the pressed key
MOV AL,BH ; Store ASCII value of pressed key
MOV SI,2100H ; Load MSG address
MOV AH,00H
ADD AX,SI
MOV SI,AX
MOV CL,[SI] ; Get display code
CALL CLR ; Clear LEDs
MOV CH,08H ; No of segments / LED
D0: RCL CL,01H ; Get 1 data bit
JNC D1
MOV AL,02H ; Output the data bit
MOV DX,0FFE4H
OUT DX,AL
MOV AL,03H ; Out put the clock to shift Register
MOV DX,0FFE4H
OUT DX,AL
JMP D2
D1: MOV AL,00H ; Output the data bit
MOV DX,0FFE4H
OUT DX,AL
MOV AL,03H ; Out put the clock to shift Register
MOV DX,0FFE4H
OUT DX,AL
D2: DEC CH ; All bits over?
JNE D0 ; No, continue
JMP BACK ; yes, go to BACK
ORG 2100H
RESULT:
VIVA QUESTIONS:
1. What are the tasks involved in keyboard interface?
2. How a keyboard matrix is formed in keyboard interface using 8279?
3. What is scanning in keyboard and what is scan time?
4. What is scanning in display and what is the scan time?
5. What is meant by De-Bouncing?
6. What is meant by Polling?
7. What is meant by mode set in 8279?
8. What is the data bus size in 8279?
9. What are the display modes supported by the 8279 chip?
10. Give the format of program clock word of 8279 and mention its purpose.
APPARATUS:
1. ESA 86/88-2 Microprocessor kit.
2. C.R.O.
3. F R C Cable.
4. Power supply.
5. Dual DAC kit.
THEORY:
The parallel input-output port chip 8255 is also called as Programmable
peripheral input-output
Port. The Intel’s 8255 are designed for use with Intel’s 8 -bit, 16-bit and higher
capability microprocessors. It has
24 input/output lines which may be individually programmed in 2-groups of 12
lines each, or 3 groups of 8 lines .The two groups of I/O pins are named as GROUP
A and GROUP B. Each of these two groups contain a sub group of 8 I/O lines called
as 8-bit Port and other sub group of 4 I/O lines are a 4-bit port. Thus GROUP A
Contains an 8-bit port A along with a 4-bit port, C upper. Port lines are identified by
symbols PAO-PA7 ,
While the port C lines are identified as PC4 -PC7 .Similarly group B contains an 8-bit
port B, containing lines
PB0 -PB7 and a 4-bit port C with lower bits PC0 -PC3 .The port C upper and port C
lower can be used in recombination as an 8-bit port-C .Both the port Cs are
assigned the same address. Thus one may have either
Three 8-bit I/O ports are two 8-bit and two 4-bit I/O ports from 8255.All of these
ports can function independently either as input or as output ports. This can be
achieved by programming the bits of an internal register of 8255 called as Control
word register. (CWR).
PORT ADDRESSES OF 8255
Control word register = FFE6
Port A = FFE0
Port B = FFE2
Program:
Memory Op codes labels Mnemonics Operands Comments
address
Lookup table:
Memory Corresponding values
address
3000
75,95,AA,BF,D1,E0,ED,F6,FC,FE,FC,F6,ED,E0,D1,BF,AA,95,75
69,54,40,2D,1E,11,08,02,00,02,08,11,1E,2D,40,54,69
VIVA QUESTIONS:
1. Give the BSR format?
2. What is the angle of a stepper motor in full step mode?
3. 8255 has how many pins?
4. If the Control word 09bH is given to control register of the 8255 ppi then
explain what is the condition of ports?
5. If the 8255 is selected for addresses 0F800H-0F806H what is the address of
port C?
6. Mode 1 of 8255 is used for which of the I/O methods?
7. 8255 has how many ports?
8. What are the applications of the ports?
9. Why we need interfacing devices?
Ex: No:
INTERFACING 8051& 8253 USART TO 8086
AIM:
To interface 8251& 8253 Interface board to 8086 p and verify the operation of receiver
stop bits of two continuous characters. The terminal will be reset, if RXD is at high level.
After Reset is active, the terminal will be output at low level.
DSR (Input terminal)
This is an input port for MODEM interface. The input status of the terminal can be
recognized by the CPU reading status words.
DTR (Output terminal)
This is an output port for MODEM interface. It is possible to set the status of DTR by a
command.
CTS (Input terminal)
This is an input terminal for MODEM interface which is used for controlling a transmit
circuit. The terminal controls data transmission if the device is set in "TX Enable" status by a
command. Data is transmitable if the terminal is at low level.
RTS (Output terminal)
This is an output port for MODEM interface. It is possible to set the status RTS by a
command.
PROGRAM:
ORG 8000H
LXI D, 000AH ;TIMER 0 for
;9600 BAUD
MVI A, 36H ; TIMER0 IN
;MODE 3
OUT CMD53
MOV A,E ; LOAD LSB VALUE
OUT 80H
MOV A, D ; LOAD MSB VALUE
OUT 80H
XRA A ; DUMMY MODE
OUT CMD51 ; WRITE DUMMY
; WORD
OUT CMB51 ; IN MODE
; REGISTER
OUT CMD51
OUT CMD51
MVI A,40H ;RESET 8251
OUT CMD51
MVI A,0CEH ;ASYNCHRONOUS
;16XBAUD,
;2 STOP BITS, 8
;DATA
;BITS, NO PARITY
MVI A,27H ;WRITE COMMAND
;WORD
OUT CMD51
VIVA QUESTIONS:
1. What is synchronous data transfer scheme?
2. What is asynchronous data transfer scheme?
3. What is baud rate?
4. What is USART?
5. What are the functions performed by INTEL 8251A?
6. What are the control words of 8251A and what are its functions?
7. What are the information that can be obtained from the status word of 8251?
8. How the microprocessor is synchronized with peripherals?
9. What is parity error?
10. Write applications of 8251?
AIM:
To Execute the Following Embedded C Programs On Kiel Software
1. Reading and Writing on a parallel port.
2. Timer in different modes.
3. Serial communication implementation.
4. Using external interrupts
5. Understanding three memory areas of 00 – FF (Programs using above areas).
THEORY:
The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with 4K bytes
of
Flash programmable and erasable read only memory (PEROM). The device is manufactured
using Atmel‟s high-density nonvolatile memory technology and is compatible with the
industry standard MCS-51 instruction set and pin out. The on-chip Flash allows the program
memory to
be reprogrammed in-system or by a conventional nonvolatile memory programmer. By
combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C51 is a
powerful microcomputer which provides a highly- flexible and cost-effective solution to many
embedded control applications.
INTPUT:
PROCEDURE:
Project creation:
OUTPUT:
#include<reg51.h>
sbit in0=P1^0;
sbit in1=P1^1;
sbit in2=P1^2;
sbit in3=P1^3;
sbit in4=P1^4;
sbit in5=P1^5;
sbit in6=P1^6;
sbit in7=P1^7;
void main()
{
P1=0xff;
P2=0x00;
while(1)
{
P2=P1;
}
}
VIVA QUESTIONS:
1. How many parallel ports are there in 8051?
2. What about special functions of port-3?
3. What are the special functions of port-0 and port-1?
4. What is difference between microprocessor and microcontrolle r?
5. What is the use of volatile keyword?
6. What is IDE?
7. What is the size of parallel port in 8051?
8. Why we need embedded-c? How it will differ from normal „c‟?
OUTPUT:
THEORY:
Thebasic8051hastwo on-chip timers that can be used for timing durations or for
counting external events Interval timing allows the programmer to perform operations at
specific instants in time. Forexample,inour LED flashing program the LED was turned on
for a specific length of time and then turned off for a specific length of time. We achieved
this through the use of time delays. Since the microcontroller operates at aspecific
frequency, we could work out exactly how many iterations of the time delay was needed to
give us the desired delay. However, this is cumberso me and prone to error. And there is
another disadvantage; the CPU is occupied, stepping through the loops. If we use the on-
chip timers, the CPU could be o ff doing so mething more useful while the timers take on
the menial task of keeping track of time
The 8051 has two16-bit timers. The high byte for timer1(TH1) is at address 8DH
while the low byte (TL1) is at 8BH The high byte for timer0 (TH0) is at 8CH while the low
byte (TL0) is at 8AH. Both timers can be used in a number o f different modes. The
programmer sets the timers to a specific mode by loading the appropriate 8-bit number in
to the Timer Mode Register (TMOD) which is at address 89H.
C PROGRAM:
#include<reg51.h>
void T0delay();
sbit out=P1^7;
void main()
{
TMOD=0X21;
TH1=0XFD;
SCON=0X50;
TR1=1;
while(1)
{
out=~out;
T0delay();
}
}
void T0delay() //TO GENERATE 50 m sec delay using timer-0 mode1
{
TL0=0XFD;
TH0=0X4B;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}
VIVA QUESTIONS:
1. What is meant by timer?
2. Differentiate timer and counter?
3. How many timers are there in 8051?
4. What is meant by auto reload mode in timers?
5. Draw the format of TMOD register of 8051
6. List the modes of Timer in 8051
7. What is the significance of C/T bit in TMOD register of 8051?
8. What is the significance of TRx bit in TCON register of 8051?
THEORY:
In Parallel co mmunication, data being transferred between one location and another
(R0 to the accumulator, for example) travel alo ng the 8-bit data bus. Because o f this data
bus, data bytes can be moved about the microcontroller at high speed. However, parallel
communication has the disadvantage of requiring at least eight separate lines (inan8-
bitsystem) and in most cases extra lines to synchronize the data transfer (in the case of the
microcontroller, the control bus).
Serial co mmunication has the advantage of requiring only one line for the data, a
second line for ground and possibly a third line for the clock. Therefore, because seria l
communication requires less physical wires, it is more suitable for transmitting data over
longer distances.
#include<reg51.h>
voidInit_Uart(void);
voidsend_char(unsigned char c);
void MSDELAY(unsigned int time);
voidsend_string(unsigned char *ptr);
unsigned char RX_CHAR();
//---------------------------
//============================================
voidInit_Uart(void)
{
SCON=0x50;
TMOD=0x20;
TH1=0XFD;
TR1=1;
}
//============================================
voidsend_char(unsigned char c)
{
SBUF=c;
while(!TI);
TI=0;
}
//============================================
unsigned char RX_CHAR()
{
unsigned char c;
while(!RI);
c=SBUF;
RI=0;
return SBUF;
}
//=============================================
void MSDELAY(unsigned int time)
{
unsignedinti,j;
for(i=0;i<time;i++)
for(j=0;j<1275;j++);
}
//============================================
voidsend_string(unsigned char *ptr)
{
while(*ptr)
send_char(*ptr++);
}
//==============================================
void main()
{
Init_Uart();
send_char('E');
MSDELAY(100);
send_char('C');
MSDELAY(100);
send_char('E');
MSDELAY(100);
send_char('@E');
MSDELAY(100);
send_string(" RCE, ELURU");
}
VIVA QUESTIONS:
1. What are the types of serial communication?
2. Draw the Frame format of Asynchronous serial communication
3. Draw the format of SCON register of 8051
4. What is the importance of SMOD bit in SCON register?
5. What are the modes of asynchronous serial communication in 8051?
6. Explain how baud rate is calculated for serial data transfer in mode 1?
7. Explain how baud rate is set in 8051 for serial data transfer using timer register?
8. Why we are using START/STOP bit?
OUTPUT:
INPUT:
OUT PUT:
Hardware Interfacing
1. Waveform Generation using Dual DAC
2. 4X4 hexadecimal Keyboard interface
3. simple Calculator using Keyboard and Seven segment display.
4. Temperature sensor.
Features of Embedded C
• C is a simple programming language and so very easy to code.
• Embedded C has most features of C-language with more stress on certain bit
manipulative instructions.
• This feature makes it easy to write program for μC and μP.
• Keil is a versatile software with a cross compiler that will convert the C
program to assembly language and thus the program can be executed on the
desired target (say 8051).
8 CRO
0 Dual
5 P0 Xout
DAC
1 P1
μC
Let initial, amplitude of the square wave be 2.5v(7F) and frequency count 100.
Output the values 00h (0ff) and 7fh (on) Values through P0.
If amplitude key is pressed then increase the voltage in steps of 0.15v (8).
If the frequency key is pressed increment the count in steps of 50. If the count
exceeds 1000 reset it back to 100.
Every time amplitude and frequency changes output the value through P0
and note the waveform on CRO.
#include <REG51xD2.H>
sbit Amp = P3^3; /* Port line to change amplitude */
sbitFre = P3^2; /* Port line to change frequency */
void delay(unsigned int x) /* delay routine */
{
for(;x>0;x--);
}
main()
{
unsigned char on = 0x7f,off=0x00;
unsignedintfre = 100;
while(1)
{
if(!Amp) /* if user choice is to change amplitude */
{
while(!Amp); /* wait for key release */
on+=0x08; /* Increase the amplitude */
}
if(!Fre) /* if user choice is to change frequency */
{
#include <REG51xD2.H>
main()
{
unsigned char i=0;
P0 = 0x00; /* P0 as Output port */
while(1)
{
for(i=0;i<0xff;i++){ /* Generate ON pulse */
P1 = i;
P0 = i;
}
for(i=0xfe;i>0x00;i--) /* Generate OFF pulse */
{P0 = i;
P1 = i;}
}
}
#include <REG51xD2.H>
main ()
{ Unsigned char i=0;
P0 = 0x00; /* P0 as Output port */
while (1)
{
for (i=0;i<0xff;i++) /* Generate ON pulse */
{
P1 = i;
P0 = i; }
}
}
#include <REG51xD2.H>
main()
{
static int a[13]={128,192,238,255,238,192,128,64,17,0,17,64,128};
unsigned char i=0;
P0 = 0x00; /* P0 as Output port */
while (1)
{
for(i=0;i<13;i++) /* Output different values */
{ P0 = a[i]; }
}
}
void main()
{
unsigned char s;
lcd_init();
lcdcmd(0x80);
msgdisplay("WELCOME");
delay(200);
lcdcmd(1);
lcdcmd(0xc0);
while(1)
{
s=keypad();
lcddata(s);
delay(10);
}
}
• Read the numbers n1 and n2 from keyboard and display them on seven
segment.
• Read the operand from the keypad if key pressed is B (+), C(-),D(*),E(/) then
respective operation is performed.
• Result is displayed on 2 digit seven segment display.
• If any time the key pressed value returned as 10h then clear the LCD.
PS
PS
8051µC Keypad
PORT
3
PORT
1 LCD
Display
void main()
{
floata,b;
unsigned char k;
unsignedint temp;
lcd_init();
start:
lcdcmd(0x80);
msgdisplay("Welcome To");
lcdcmd(0xc0);
msgdisplay("Calculator ");
while(1)
{
delay(200);
lcdcmd(1);
lcdcmd(0x80);
msgdisplay("enter val1: ");
lcdcmd(0xc0);
a=b=0;
while(1)
{
temp=keypad();
delay(100);
if(temp=='#')
{
break;
}
else
if(temp=='*')
{
if(a)
{
lcdcmd(0x10);
lcddata(' ');
delay(100);
a=a/10;
lcdcmd(0x10);
}
}
else
{
a=a*10+temp-48;
lcddata(temp);
delay(100);
temp++;
}
}
lcdcmd(1);
lcdcmd(0x80);
msgdisplay("enter val2: ");
lcdcmd(0xc0);
b=0;
while(1)
{
temp=keypad();
delay(100);
if(temp=='#')
{
break;
}
else
if(temp=='*')
{
if(b)
{
lcdcmd(0x10);
lcddata(' ');
delay(100);
lcdcmd(0x10);
b=b/10;
}
}
else
{
b=b*10+temp-48;
lcddata(temp);
delay(100);
temp++;
}
}
lcdcmd(1);
lcdcmd(0x80);
msgdisplay("Select operation");
lcdcmd(1);
msgdisplay("1:ADD 2:SUB");
lcdcmd(0xc0);
msgdisplay("3:MUL 4:DIV");
while(1)
{
k=keypad();
delay(100);
if(k=='1')
{
lcdcmd(1);
lcdcmd(0x80);
msgdisplay("a=");
convert1(a);
lcddata(' ');
lcdcmd(0x87);
msgdisplay("b=");
convert1(b);
lcddata(' ');
lcdcmd(0xc0);
msgdisplay("a+b=");
convert1(a+b);
delay(200);
again1:
k=keypad();
if(k=='#')
{
goto start;
}
else
{
goto again1;
}
}
if(k=='2')
{
lcdcmd(1);
lcdcmd(0x80);
msgdisplay("a=");
convert1(a);
lcddata(' ');
msgdisplay("b=");
convert1(b);
lcddata(' ');
if(a<b)
{
lcdcmd(0xc0);
msgdisplay("a-b=");
lcddata('-');
convert1(b-a);
}
else
{
lcdcmd(0xc0);
msgdisplay("a-b=");
convert1(a-b);
}
delay(300);
again2:
k=keypad();
if(k=='#')
{
goto start;
}
else
{
goto again2;
}
}
if(k=='3')
{
lcdcmd(1);
lcdcmd(0x80);
msgdisplay("a=");
convert1(a);
lcddata(' ');
msgdisplay("b=");
convert1(b);
lcddata(' ');
lcdcmd(0xc0);
msgdisplay("a*b=");
convert1(a*b);
delay(100);
again3:
k=keypad();
if(k=='#')
{
goto start;
}
else
{
goto again3;
}
}
if(k=='4')
{
lcdcmd(1);
lcdcmd(0x80);
msgdisplay("a=");
convert1(a);
lcddata(' ');
msgdisplay("b=");
convert1(b);
lcddata(' ');
lcdcmd(0xc0);
msgdisplay("a/b=");
convert1(a/b);
delay(200);
again4:
k=keypad();
if(k=='#')
{
goto start;
}
else
{
goto again4;
}
}
}
}
}
4. Temperature Sensor
PS
PS
The interface card has a DAC to convert the actual temperature to digital this is
compared with reference temperarture. Realay also a part of interface card will turn
on and off to indicate if the actual temperature is above or below reference.
2. Set up a counter with intial value 0xff send it to dacthro P0 after a delay check if
comparator o/p has gone low.
3. If low, compare with set value if actual greater than set turn on the relay else
turn off.
Program for temperature sensor.
#include<reg51.h>
#include"lcddisplay.h"
#include<intrins.h>
// connection between 8051 and ADC MCP3202
sbit ADC_CS = P2^0;
sbit ADC_CLK = P2^3;
sbit ADC_DO = P2^2;
sbit ADC_DI = P2^1;
voidwrite_adc_byte(char data_byte);
unsignedintReadADC(unsigned char channel);
//void DelayMs(unsigned int count);
void convert(unsigned int value);
void main()
{
unsignedint temperature ;
float x;
// buz=1;
lcd_init(); // LCD Initilize
lcdcmd(0x85);
msgdisplay("WELCOME");
delay(1000);
lcdcmd(0x01);
msgdisplay("TEMPERATURE");
lcdcmd(0xC0);
msgdisplay("MONITOR...");
delay(1000);
delay(1500);
lcdcmd(0x1);
msgdisplay("TEMP:- ");
while(1)
{
delay(100);
temperature=ReadADC(0);
x=(temperature/8);
lcdcmd(0x87);
convert(x);
msgdisplay(" deg");
delay(1000);
}
}
unsignedintReadADC(unsigned char channel)
{
unsigned char i,k;
unsignedintAdcResult; // 12 bit
k++;
k++; // delay about 2 uS
ADC_CLK=1;
//DelayMs(20);
k++;
k++; // delay about 2 uS
ADC_CLK=0;
//DelayMs(20);
k++;
k++; // delay about 2 uS
// delay about 2 uS
AdcResult<<=1;
AdcResult=AdcResult|(ADC_DO);
ADC_CLK=0;
k++;
k++; // delay about 2 uS
}
ADC_CS=1;
return(AdcResult);
}
void convert(unsigned int temp1_value)
{
unsignedint d1,d2,d3;
d3=temp1_value%10;
temp1_value=temp1_value/10;
d2=temp1_value%10;
d1=temp1_value/10;
lcddata(d1+48);
lcddata(d2+48);
lcddata(d3+48);
}