Es FILE Final

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 13

S.NO.

PROGRAM SIGN

1 To add two numbers


2. To subtract two numbers
3. To multiply two numbers
4. To divide two numbers
5. To produce a wave with 50% duty cycle
on pin P1.2
6. To continuously complement contents of
port 1 after definite timer interval
7. To generate a pulse of width 5 ms.
8. To receive the data that has been sent in,
in serial form and sends it out to ports in
parallel form. Use the data at RAM
location 60H
9. To interface stepper motor with
microcontroller 8051

10. To write a program for traffic light control


system
PROGRAM 1

Aim: To add two numbers

Program:

MOV A, #05H
MOV B, #03H
ADD A, B
MOV P1, A

Hex file:

:09000000740575F00325F0F5907C
:00000001FF

Output:

P1=08H
PROGRAM 2

Aim: To subtract two numbers

Program:

MOV A, #05H
SUBB A, #02H
MOV P1, A

Hex file:

0000 7405
0002 9402
0004 F590

Output:

P1=03H
PROGRAM 3

Aim: To multiply two numbers

Program:

MOV A, #01H
MOV B, #02H
MUL AB
MOV P1, A

Hex file:

0000 7401
0002 75F002
0005 A4
0006 F590

Output:

P1=02H
PROGRAM 4

Aim: To divide two numbers

Program:

MOV A, #02H
MOV B, #02H
DIV AB
MOV P1, A

Hex file:

0000 7402
0002 75F002
0005 84
0006 F590

Output:

P1=01H
PROGRAM 5

Aim: To produce a wave with 50% duty cycle on pin P1.2

Program:

MOV TMOD, #01H


HERE: MOV TL0, #FEH
MOV TH0, #FFH
CPL P1.2
ACALL DELAY
SJMP HERE
DELAY: MOV TCON, #10H
AGAIN: JNB TCON.5, AGAIN
CLR TCON.4
CLR TCON.5
SJMP HERE

Hex file:

0000 758901
0003 758AFE
0006 758CFF
0009 B292
000B 110F
000D 80F4
000F 758810
0012 308DFD
0015 C28C
0017 C28D
0019 80E8

Output:
50% duty cycle wave is observed on P1.2
PROGRAM 6

Aim: To continuously complement contents of port 1 after definite timer


interval

Program:

MOV TMOD, #01H


HERE: MOV TL0, #FEH
MOV TH0, #FFH
MOV A, #55H
MOV P1, A
ACALL DELAY
CPL A
MOV P1, A
SJMP HERE
DELAY: MOV TCON, #10H
AGAIN: JNB TCON.5, AGAIN
CLR TCON.4
CLR TCON.5
RET

Hex file:

0000 758901
0003 758AFE
0006 758CFF
0009 7455
000B F590
000D 1114
000F F4
0010 F590
0012 80EF
0014 758810
0017 308DFD
001A C28C
001C C28D
001E 22
Output:
PROGRAM 7

Aim: To generate a pulse of width 5 ms.

Program:

ORG 00H

DELAY: MOV R2, #19

HERE: MOV R3, #255

AGAIN: DJNZ R3, AGAIN

DJZN R2, HERE

RET

CALCULATIONS

FOR 22 MHz crystal each machine cycle lasts for 0.546 us

(2*255) * 0.546 = 278µs

278*19 = 5.29ms

Hex File:
:09000000740575F00325F0F5907C
:00000001FF
PROGRAM 8

Aim: To receive the data that has been sent in, in serial form and sends it out
to ports in parallel form. Use the data at RAM location 60H

Program:

ORG 0000H
MOV TMOD, #20H
MOV TH1, #30H
MOV SCON, # 50H

SET B TR1
CLR RI

RPT: JNB RI, RPT

MOV A, SBUF
MOV P0, A
MOV 60H, A
MOV P1, A

Hex File:

:100000007466F59003110980F97A647BFFDBFEDAF0
:02001000FA22D2
:00000001FF
PROGRAM 9

Aim: To interface stepper motor with microcontroller 8051

Program:

ORG 0000H
MOV A, #66H
BACK: MOV P1, A
RR A
ACALL DELAY
SJMP BACK

DELAY: MOV R2, #100

H1: MOV R3, #255

H2: DJNZ R3, H2


DJNZ R2, H1

RET

HEX FILE :

:10000000800A1100800B1100800C11007480F591A2
:10001000227440F592227420F5922278FF79FF7ABB
:10002000FF7BFFDBFEDAFAD9F6D8D52279FFD9D0EB
:10003000D500CD80D7110080D8110080D91100746F
:1000400080F591227440F592227420F5922278FF77
:1000500079FF7AFF7BFFDBFEDAFAD9F6D8A22279A4
PROGRAM 10

Aim: To write a program for traffic light control system.

Program:

ORG 0000H

SJMP RED
ACALL DELAY1

SJMP ORANGE
ACALL DELAY2

SJMP GREEN
ACALL DELAY1

RED: MOV A, #80H


MOV P1.1, A
RET

ORANGE: MOV A, #40H


MOV P1.2, A
RET

GREEN: MOV A, #20H


MOV P1.2, A
RET

DELAY1: MOV R0, #255


D3: MOV R1, #255
D2: MOV R2, #255
D1: MOV R3, #255

AGAIN: DJNZ R3, AGAIN


DJNZ R2, D1
DJNZ R1, D2
DJNZ R0, D3
RET

DELAY2: MOV R0, #255


D4: MOV R1, #255
AGAIN1: DJNZ R1, AGAIN1
DJNZ R0, D4
RET

HEX FILE:

:10000000800A111B800B112C800C111B7480F59140
:10001000227440F592227420F5922278FF79FF7ABB
:10002000FF7BFFDBFEDAFAD9F6D8F22278FF79FF00
:05003000D9FED8FA2200
:00000001FF

You might also like