0% found this document useful (0 votes)
52 views

Lab Report

The document describes four experiments conducted using microcontrollers and microprocessor trainers. Experiment 1 loads a sample program into an MDA-8086 trainer and verifies the results. Experiment 2 performs arithmetic operations using an 8086 microprocessor trainer. Experiment 3 solves mathematical problems using an 8086 emulator. Experiment 4 blinks LEDs using an Atmega32 microcontroller in different ways. Experiment 5 designs an up/down counter interfaced with a seven segment display using an Atmega32 microcontroller.

Uploaded by

Aditya Bhowmik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

Lab Report

The document describes four experiments conducted using microcontrollers and microprocessor trainers. Experiment 1 loads a sample program into an MDA-8086 trainer and verifies the results. Experiment 2 performs arithmetic operations using an 8086 microprocessor trainer. Experiment 3 solves mathematical problems using an 8086 emulator. Experiment 4 blinks LEDs using an Atmega32 microcontroller in different ways. Experiment 5 designs an up/down counter interfaced with a seven segment display using an Atmega32 microcontroller.

Uploaded by

Aditya Bhowmik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Expt.

1: To load the machine code of a sample program in MDA-8086


trainer and verification of results including flags.
Sample Program:
MOV AX,8051H
MOV DX,0550H
MOV CL,02H
MOV CH,93H
ADD AX, DX
MOV BX,0050H
SUB AX, BX
INC DL
DEC BX
XCHG CX, BX
HLT
Table: Data for a sample program in MDA-8086 trainer and verifications of results
including flags.

Offset Instruction Hex Code Verification/Flags


1000 MOV AX,8051H B8,51,80 AX=8551
1003 MOV DX,0550H BA,50,05 BX=9302
1006 MOV CL,02H B1,02 CX=004F
1008 MOV CH,93H B5,93 DX=0551
100A ADD AX, DX 03, C2 Flags
100C MOV BX,0050H BB,50,00 CF=0, ZF=0
100F SUB AX, BX 2B, C3 SF=0, OF=0
1011 INC DL FE, C2 PF=0, AF=1
1013 DEC BX 4B IF=1, DF=0
1014 XCHG CX, BX 87, CB
1016 HLT F4
Expt.2: To solve the arithmetic and logical problem using 8086uP
MDA-8086 trainer: i) Addition, ii) Subtraction, iii) Multiplication, iv)
Division.
If A=-8, B=4, then Z=A+B, Z=A-B, Z=A*C, Z=A/B
Here A=-8=F8(hex)
i. Z=A+B

Table: Data for addition program in MDA-8086 trainer and verification


of result including flags.
Offset Instruction Hex Code Verification Flags
1000 MOV AL,00F8H B0, F8 AX=0000 IF=1
1002 MOV BL,0004H B3, 04 AX=00F8 IF=1
1004 ADD AL, BL 02, C3 BX=0004 IF=1
1006 HLT F4 AX=00FC SF=1, PF=1,
IF=1
ii. Z=A-B
Table: Data for Subtraction program in MDA-8086 trainer and
verification of result including flags.

Offset Instruction Hex Code Verification Flags


1000 MOV AL,00F8H B0, F8 AX=0000 IF=1
1002 MOV BL,0004H B3, 04 AX=00F8 IF=1
1004 SUB AL, BL 2A, C3 BX=0004 IF=1
1006 HLT F4 AX=00F4 SF=1, IF=1
iii. Z=A*B
Table: Data for Multiplication program in MDA-8086 trainer and
verification of result including flags.
Offset Instruction Hex Code Verification Flags
1000 MOV AL,00F8H B0, F8 AX=0000 IF=1
1002 MOV BL,0004H B3, 04 AX=00F8 IF=1
1004 MUL BL F6, E3 BX=0004 IF=1
1006 HLT F4 AX=03E0 CF=1,
OF=1,
IF=1
iv. Z=A/B, Here A=8, B=4.
Table: Data for Division program in MDA-8086 trainer and verification
of result including flags.
Offset Instruction Hex Code Verification Flags
1000 MOV AL,00F8H B0, 08 AX=0000 IF=1
1002 MOV BL,0004H B3, 04 AX=0008 IF=1
1004 DIV BL BX=0004 IF=1
1006 HLT F4 AX=00FC IF=1
Expt3. To solve mathematical problem using 8086
microprocessor emulator.
a) Find the sum of series of N numbers.
Here, 1+2+3+4+5+6+7+8+9=45.
Program:
MOV AX,0000H
MOV CX,0009H
L:
ADD AX, CX
LOOP L
HLT
b) Calculate factorial of a number.
Here, 5! = 120
Program:
MOV AX,0001H
MOV CX,0005H
L:
MUL CX
LOOP L
HLT
c) Find the square of a number.
Here 9^2=81.

Program:
MOV AX,0000H
MOV CX,0009H
MOV AX, CX
MUL CX
HLT
d) Find the average of n numbers.
Here, (1+2+3+4+5)/5=3.
Program:
MOV AX,0000H
MOV CX,0005H
MOV BX,0005
L:
ADD AX, CX
LOOP L
DIV BX
HLT
Expt.4(a): Blinking LED using Atmega32 microcontroller (all at once).
Program:
#include <avr/io.h>
#define F_CPU 1000000UL
#include <util/delay.h>
int main(void)
{
DDRD=0xff;
while (1)
{
PORTD=0xff;
_delay_ms(1000);
PORTD=0x00;
_delay_ms(1000);
}

Figure: Circuit diagram for Blinking LED.


Expt.4(b): Blinking LED using Atmega32 microcontroller (up and down
counter).
Up counter Down Counter
#define F_CPU 1000000UL #define F_CPU 1000000UL
#include <avr/io.h> #include <avr/io.h>
#include <util/delay.h> #include <util/delay.h>

int main(void) int main(void)


{ {
DDRD=0xff; DDRD=0xff;
while (1) while (1)
{ {
PORTD=0x01; PORTD=0x80;
_delay_ms(500); _delay_ms(500);
PORTD=0x02; PORTD=0x40;
_delay_ms(500); _delay_ms(500);
PORTD=0x04; PORTD=0x20;
_delay_ms(500); _delay_ms(500);
PORTD=0x08; PORTD=0x10;
_delay_ms(500); _delay_ms(500);
PORTD=0x10; PORTD=0x08;
_delay_ms(500); _delay_ms(500);
PORTD=0x20; PORTD=0x04;
_delay_ms(500); _delay_ms(500);
PORTD=0x40; PORTD=0x02;
_delay_ms(500); _delay_ms(500);
PORTD=0x80; PORTD=0x01;
_delay_ms(500); _delay_ms(500);
} }
} }

Figure: Circuit diagram for Blinking LED.


Expt. 5 To Design a Up/Down Counter using Atmega32 Microcontroller and Interface
with Seven segment display

Up Counter: Down Counter:


#include <avr/io.h> #include <avr/io.h>
#define F_CPU 16000000UL #define F_CPU 16000000UL
#include <util/delay.h> #include <util/delay.h>
int main(void) int main(void)
{ {
int i; int i;
DDRD=0xff; DDRD=0xff;
char char
seg[]={0x3f,0x06,0x5b,0x4f,0x66,0x seg[]={0x3f,0x06,0x5b,0x4f,0x66,0x
6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0 6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0
x39,0x5e,0x79,0x71}; x39,0x5e,0x79,0x71};
while (1) while (1)
{ {
for(i=0;i<=15;i++) for(i=15;i>=0;i--)
{ {
PORTD=seg[i]; PORTD=seg[i];
_delay_ms(50); _delay_ms(50);
} }
} }

Figure: Circuit diagram for Up and Down Counter using


7 segment display.

You might also like