Skip to main content

Online C Compiler - Programiz

Experiment - 1 exp1

Write a program to find the GCD and LCM

ORG 0000H
MOV A, 50H
MOV B, 51H
BACK: MOV R1,B
DIV AB
MOV A,B
CJNE A, #00H, L1
L1: JZ LAST
MOV A, R1
SJMP BACK
LAST: MOV A, R1
MOV 52H, A
MOV A, 50H
MOV B, 51H
MUL AB
MOV B, 52H
DIV AB
MOV 53H,A
END

Experiment - 2

Write a program to convert the given BCD number into seven segment

ORG 0000H
MOV P1, #0FFH
MOV P2, #00H
MOV DPTR, #0300H
AGAIN: MOV A, P1
ANL A, #0FH
MOVC A,@A+DPTR
MOV P2, A
SJMP AGAIN
ORG 0300H
DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH
END

Experiment - 3

Toggling of p1.5 with the delay of 5ms without interrupts using timer 1

ORG 0000H
MOV TMOD, #10H
AGAIN: MOV TL1, #066H
MOV TH1, #0FCH
SETB TR1
BACK: JNB TF1, BACK
CLR TR1
CLR TF1
CPL P1.5
SJMP AGAIN
END

Experiment - 4

Toggling of p1.2 with the delay of 5ms with interrupts using timer 0

ORG 0000H
LJMP MAIN
ORG 000BH
CPL P1.2
MOV TL0, #066H
MOV TH0, #0FCH
RETI
ORG 0030H
MAIN: MOV TMOD, #01H
MOV TL0, #066H
MOV TH0, #0FCH
MOV IE, #82H
SETB TR0
HERE: SJMP HERE
END

Experiment - 5

Count no. of pulses without interrupts using counter 0

ORG 0000H
MOV TMOD, #05H
SETB P3.4
MOV TL0, #00H
MOV TH0, #00H
SETB TR0
BACK: MOV A, TL0
MOV P1, A
MOV A, TH0
MOV P2, A
SJMP BACK
END

Experiment - 6

Count no. of pulses with interrupts using counter 1

ORG 0000H
LJMP MAIN
ORG 001BH
MOV A, TL1
MOV P1, A
CLR TF1
RETI
ORG 0030H
MAIN: MOV TMOD, #50H
SETB P3.5
MOV TL1, #00H
MOV TH1, #00H
MOV IE, #88H
SETB TR1
HERE: SJMP HERE
END

Experiment - 7

Program to transfer data serially with baud rate of 9600

ORG 0000H
MOV TMOD, #20H
MOV TH1, #-3
MOV SCON, #50H
SETB TR1
AGAIN: MOV SBUF, #'A'
HERE: JNB TI, HERE
CLR TI
SJMP AGAIN
END

Experiment - 8

Program to receive data serially with baud rate of 9600

ORG 0000H
MOV TMOD, #20H
MOV TH1, #-3
MOV SCON, #50H
SETB TR1
HERE: JNB RI, HERE
MOV A, SBUF
MOV P1, A
CLR RI
SJMP HERE
END

Experiment - 9

Sequence Generator Using Serial Interface in 8051

ORG 0000H
LJMP MAIN
ORG 0030H
MAIN: MOV TMOD, #20H
MOV TH1, #-3
MOV SCON, #50H
SETB TR1
MOV R4, #08
MOV A, #01H
NXT: MOV B, A
ADD A, #30H
MOV SBUF, A
WAIT: JNB TI, WAIT
CLR TI
MOV A, B
ADD A, #01H
DJNZ R4, NXT
SJMP $
END


Comments

Popular posts from this blog

Online C Compiler - Programiz

Codes Experiment 1 exp1 Aim: compute the time and space complexity of basic recursive and iterative functions using Big-O notation. #include <stdio.h> #include <time.h> // Recursive long long factR(int n){     return (n<=1)?1:n*factR(n-1); } int main(){     int n,i;     long long f;     clock_t s,e;     double t;     printf("Enter a number to find factorial: ");     scanf("%d",&n);     // Iterative     f=1;     s=clock();     for(i=1;i<=n;i++) f*=i;     e=clock();     t=(double)(e-s)/CLOCKS_PER_SEC;     printf("\n[Iterative] Factorial of %d = %lld",n,f);     printf("\n[Iterative] Time taken: %f seconds",t);     printf("\n[Iterative] Space Complexity ≈ O(...