Talha MP Lab 04

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

SPRING FALL 2023

DEPARTMENT OF TELECOMMUNICATION ENGINEERING

NAME: TALHA UMAR

REGISTRATION NO: 22MDTLE249

SUBJECT: MP AND MC

SEMESTER: 4th SEMESTER

LAB NO : 04

SUBMITTED BY : TALHA UMAR

SUBMITTED TO: SIR WALLED SHEHZAD


(LAB # 04)
QUESTION 1

Develop a C program for showing outputs of multiplication division subtraction and addition at
PORTC of ATMega 16 by providing input signal at PORTB and PORTD.

Inputs at PORT Inputs at PORT Outputs at PORT D


A B
Numbe S1 S0 S1 S0 S3 S2 S1 S0
rs
0 0 0 0 0 ? ? ? ?
1 0 1 0 1 ? ? ? ?
2 1 0 1 0 ? ? ? ?
3 1 1 1 1 ? ? ? ?

SO WE HAVE A CODE
DDRC=0xff;

PORTC=0x00;

While (1)

PORTC=PINB/PIND; // for division

PORTC=PINB*PIND; // for multiplication


PORTC=PINB+PIND; // for addition

PORTC=PINB-PIND; // for subtraction

}
PROGRAM 1 :
For division: For Multiplication:

FOR ADDITION: FOR SUBTRACTION:

OUTPUT 2:

FOR DIVISION:

Inputs at PORT Inputs at PORT Outputs at PORT D


A B
Numbe S1 S0 S1 S0 S3 S2 S1 S0
rs
0 0 0 0 0 0 0 0 0
1 0 1 0 1 0 0 0 1
2 1 0 1 0 0 0 0 1
3 1 1 1 1 0 0 0 1
FOR MULTIPLICATION:

Inputs at PORT Inputs at PORT Outputs at PORT D


A B
Numbe S1 S0 S1 S0 S3 S2 S1 S0
rs
0 0 0 0 0 0 0 0 0
1 0 1 0 1 0 0 0 1
2 1 0 1 0 0 1 0 0
3 1 1 1 1 1 0 0 1

FOR ADDITION:

Inputs at PORT Inputs at PORT Outputs at PORT D


A B
Numbe S1 S0 S1 S0 S3 S2 S1 S0
rs
0 0 0 0 0 0 0 0 0
1 0 1 0 1 0 0 1 0
2 1 0 1 0 0 1 0 1
3 1 1 1 1 0 1 1 0

FOR SUBTRACTION:

Inputs at PORT Inputs at PORT Outputs at PORT D


A B
Numbe S1 S0 S1 S0 S3 S2 S1 S0
rs
0 0 0 0 0 0 0 0 0
1 0 1 0 1 0 0 0 1
2 1 0 1 0 0 0 1 0
3 1 1 1 1 0 0 0 1
QUESTION 2 :
Prove (a+b+c)2=a2+b2+ b2+2ab+2bc+2ac with the help of 8086 microprocessor and 8051
microcontroller by using assemble language commands.

PROGRAM 2:
CODE FOR (A+B+C)2:

OUTPUT 2:
CODE FOR A2+B2+ B2+2AB+2BC+2AC :
PROGRAM 3:

OUTPUT 3:
(THE END)

You might also like