Ex. No: 1
a) ADDITION
ALGORITHM:
I.
II.
III.
IV.
V.
VI.
VII.
VIII.
IX.
X.
Program:
Address
Label
STORE:
Mnemonics
Machine Code
Comments
OUTPUT VERIFIACTION:
INPUT
2000H
2001H
2002H
2003H
OUTPUT
3000H
3001H
3002H
DATA 1
34
12
78
56
AC
68
00
b) SUBTRACTION
DATA 2
DATA 2
ALGORITHM:
I.
II.
III.
IV.
V.
VI.
VII.
VIII.
IX.
X.
XI.
Program:
Address
Label
STORE:
Mnemonics
Machine Code
Comments
OUTPUT VERIFIACTION:
INPUT
2000H
2001H
2002H
2003H
OUTPUT
3000H
3001H
3002H
DATA 1
88
44
33
22
55
22
00
C) MULTIPLICATION
ALGORITHM:
DATA 2
DATA 2
I.
II.
III.
IV.
V.
VI.
Program:
Address
Label
Mnemonics
MOV
MOV
MUL
MOV
MOV
INT 3
Machine Code
Comments
AX, [2000H]
BX, [2002H]
BX
[3000], AX
[3002], DX
OUTPUT VERIFIACTION:
INPUT
2000H
2001H
2002H
2003H
OUTPUT
3000H
3001H
3002H
3003H
DATA 1
DATA 2
0A
00
0A
00
64
00
00
00
D)DIVISION
I.
II.
III.
IV.
V.
VI.
Program:
DATA 2
Address
Label
Mnemonics
MOV
MOV
DIV
MOV
MOV
INT 3
Machine Code
Comments
AX, [2000H]
BX, [2002H]
BX
[3000], AX
[3002], DX
OUTPUT VERIFIACTION:
INPUT
2000H
2001H
2002H
2003H
OUTPUT
3000H
3001H
3002H
3003H
Ex.No: 2
a)
DATA 1
DATA 2
68
00
0A
00
0A
00
04
00
Algorithm:
i.
ii.
iii.
iv.
v.
vi.
vii.
viii.
DATA 2
ix.
x.
xi.
Program:
Address
Label
Mnemonics
Machine Code
Comments
INC SI
MOV AL, [SI]
DEC CL
INC SI
CMP AL, [SI]
JNB SKIP/ JB SKIP
MOV AL, [SI]
SKIP:
DEC CL
JNZ NEXT
MOV [DI], AL
INT 3
OUTPUT VERIFIACTION:
INPUT
DATA 1
2000H(COUNT)
05
2001H
AA
2002H
BB
2003H
CC
2004H
55
2005H
77
DATA 2
DATA 2
OUTPUT
3000H
LARGEST : CC
SMALLEST: 55
b)
Algorithm:
i.
ii.
iii.
iv.
v.
vi.
vii.
viii.
ix.
x.
xi.
xii.
xiii.
Load starting address of array in to SI reg. and initialize DI reg for result.
Load the byte to be searched in DL reg. & initialize BH reg for position as 01
Get the 1st element into Accumulator
AGAIN : Compare Accumulator with DL reg
Check zero flag, if set goto AVAIL
Update SI and Increment BL
Get next element into Accumulator and compare with EOA
If not zero, goto AGAIN.
Initialize CX reg to zero
Store result for Not Available and goto END
AVAIL: Get word for available in to BL reg.
Store position, address and status of serach.
END: Halt
Program:
Address
Label
Mnemonics
CMP AL, DL
JZ AVAIL
Machine Code
Comments
INC SI
INC BL
MOV AL, [SI]
CMP AL, E0
JNZ AGAIN
NOTAVL
AVAIL:
MOV BL, FF
MOV [DI+1], BX
MOV [DI+3], SI
END:
INT 3
OUTPUT VERIFIACTION:
INPUT
DATA 1
3000H(BYTE)
05
2000H
AA
2001H
BB
2002H
CC
2003H
55
2004H
77
DATA 2
DATA 2
2018H
05
2032H
EO
OUTPUT
c)
3000H
05
3001H
FF
3002H
19
3003H
18
3004H
20
Ascending/Descending order
Algorithm:
i.
Load SI reg with pointer to array
ii.
Load array length to CL & CH for two counters (CL for repetitions & CH for comparisons)
iii.
REPEAT : Get an element into accumulator
iv.
NEXT: Compare with next element
v.
Check carry flag, if set goto SKIP
vi.
Swap elements of array
vii.
SKIP: Decrement CH and if not zero go to NEXT
viii. Decrement CL , if not zero go to REPEAT
ix.
Halt
Program:
Address
Label
Mnemonics
Machine Code
Comments
NEXT:
SKIP:
DEC CH
JNZ NEXT
DEC CL
JNZ REPEAT
INT 3
OUTPUT VERIFIACTION:
INPUT
DATA 1
1500(COUNT)
07
1501
AA
1502
BB
1503
CC
1504
55
1505
77
1506
11
1507
99
DATA 2
DATA 2
OUTPUT
1501
11
1502
55
1503
77
1504
99
1505
AA
1506
BB
1507
CC
EX.NO: 3
STRING MANUPULATION
a) Block Transfer
Algorithm:
i.
ii.
iii.
iv.
v.
vi.
Program:
Address
Label
Mnemonics
Machine Code
Comments
TRANSFER
:
OUTPUT VERIFIACTION:
INPUT
2000H (Block
Size)
2001H
2002H
2003H
2004H
2005H
OUTPUT
3000H
3001H
3002H
3003H
3004H
DATA 1
DATA 2
DATA 2
05
12
34
56
78
9A
12
34
56
78
9A
b) Table search
Algorithm:
i.
Initialize BX reg with table size
ii.
Get address of table and symbol in DI & SI reg.
iii.
Clear direction flag.
iv.
Load counter with 08(length)
v.
Compare bytes if successful goto FOUND
vi.
Point to the next symbol
vii.
Decrement BX, if not zero repeat the steps
viii. Show not found
ix.
FOUND: Show found status.
x.
Halt
Program:
Address
Label
Mnemonics
Machine Code
Comments
LOOP1
NOTFOUND:
FOUND:
END:
OUTPUT VERIFIACTION:
INPUT
3000H
3001H
3002H
3003
00
30
00
00
2000H
2001H
2002H
2003H
00
12
00
00
Note: The table has to be loaded from memory location 3000H & the search string in 1200H.
Table size can be any 16 bit number
c) Code Conversion
Algorithm
i.
ii.
iii.
iv.
v.
vi.
vii.
viii.
ix.
x.
Address
Label
Mnemonics
Machine Code
Comments
DATA 1
DATA 2
DATA 2
03
05
4F
6D
7
segment
code
3F
06
5B
4F
66
6D
7D
07
7F
6F
i.
ii.
iii.
iv.
v.
vi.
vii.
viii.
ix.
Program:
Address
Label
Mnemonics
Machine Code
Comments
LOOP1:
DONE:
OUTPUT VERIFIACTION:
INPUT
2000H
(COUNT)
2001H
2002H
DATA 1
DATA 2
DATA 2
05
CC
AA
3000H
3001H
3002H
3003H
3004H
OUTPUT
11
CC
22
CC
33
3000H
3001H
3002H
3003H
3004H
11
AA
22
AA
33
Ex.No: 4
a) DAC Interfacing
Square wave:
i.
Initialize 8255 by sending Control Word to Control Reg.
ii.
Get High into accumulator; send to DAC through output port
iii.
Call delay sub routine
iv.
Get Low into accumulator; send to DAC through output port
v.
Continue cycle
Program:
Address
Label
Mnemonics
Machine Code
Comments
MOV DX,FF56H
MOV AL,80H
OUT DX,AL
MOV DX,FF52H
MOV AL,FFH
OUT DX,AL
CALL DELAY
MOV AL,00H
OUT DX,AL
CALL DELAY
JMP START
Continue cycle
DELAY:
MOV CX,07FFH
Delay count
CONT:
NOP
Wait state
START:
Port B address
NOP
DEC CX
Decrement count
JNZ CONT
RET
Count value
07HH
Amplitude
(V)
2V
Label
Mnemonics
Machine Code
Comments
DELAY:
CONT:
NOP
NOP
DEC CX
JNZ CONT
RET
b) ADC
Algorithm:
i.
ii.
iii.
Close measurement.
iv.
Call delay.
v.
vi.
Halt
Procedure:
i.
ii.
iii.
Load program
iv.
Set input voltage by Adjusting POT resister in ADC Kit and measure using Multimeter.
v.
Execute program and read the digital output from the VIK 86 kit.
Program:
Address
Label
Mnemonics
Machine Code
Comments
MOV
DX, FF56H
MOV
AL, 90H
OUT
DX, AL
MOV
DX, FF54H
Port C address
MOV
AL, FFH
OUT
DX, AL
MOV
AL, 00
OUT
DX, AL
MOV
AL, FFH
OUT
DX, AL
Send to ADC
CALL DELAY
CALL DELAY
MOV
IN
DX, FF50H
AL, DX
INT
Port A address
Read Port A which has Output of ADC
Break point
DELAY:
Delay count
CONT:
NOP
Wait state
NOP
DEC CX
Decrement count
JNZ CONT
RET
OUTPUT VERIFICATION:
Analog Input (V)
Digital Output
5V
FFH
2.5 V
7AH
Ex. No: 5
Transmitter:
PARALLEL COMMUNICATION
Algorithm:
i.
ii.
iii.
iv.
v.
vi.
Halt
Program:
Address
Label
Mnemonics
Machine Code
MOV
DX, FF26H
MOV
AL,82H
OUT
DX,AL
MOV
DX, FF24H
MOV
AL,00H
Clear signal
OUT
DX,AL
MOV
DX, FF20H
MOV AL,55H(Byte)
OUT
DX,AL
MOV
DX, FF24H
MOV
AL, FFH
Enable signal
OUT
DX,AL
INT 3
Receiver:
Algorithm:
i.
Comments
8255 Control Reg
Transmit byte
Break point
ii.
iii.
iv.
v.
vi.
Halt
Program:
Address
Label
CHECK:
Mnemonics
MOV
DX,FF26H
MOV
AL,99H
OUT
DX,AL
MOV
DX,FF24H
Machine Code
Comments
Control Reg. of 8255
Control word for initializing ports as
I/P
Port C for Enable signal
IN AL,DX
Read Port C
JZ
CHECK
MOV
DX,FF20H
IN AL,DX
INT 3H
Break Point
Procedure:
i.
ii.
Load Transmitter program in One kit and Receiver in the other kit
iii.
iv.
Ex.No: 6
8279:
Keyboard Interfacing:
Algorithm:
i.
ii.
iii.
iv.
v.
Else read Data code from input port and suppress unwanted bits(b7&b6)
vi.
Break point
Address
Label
Mnemonics
Wait:
MOV
AL,12h
MOV
DX,FF52h
OUT
DX,AL
MOV
AL,3Eh
OUT
DX,AL
MOV
AL,A0h
OUT
DX,AL
IN
IN
display/write inhibit
Wait
DX,FF50h
Data register
AL,DX
AND
INT
AL,07h
MOV
Comments
AL,DX
AND
JZ
Machine Code
AL,3Fh
Break point
Row/Column
24
23
22
21
1c
1b
1a
19
14
13
12
10
0c
0b
0a
09
Display interfacing:
Algorithm:
i.
ii.
iii.
Load display write inhibit word and count for clearing display
iv.
v.
Get the input code from table and send to display through output port
vi.
Break point
Program:
Address
Label
Clear:
Mnemonics
MOV
AL,12h
Machine Code
Comments
Control word to define 8279 in 8 bit
8 character display
MOV
DX,FF52h
OUT
DX,AL
MOV
AL,3Eh
OUT
DX,AL
MOV
AL,A0h
OUT
DX,AL
display/write inhibit
send to control reg
MOV
AH,08h
MOV
DX,0FF50h
MOV
AL,00h
data =0
OUT
DX,AL
DEC
AH
JNZ
Clear
MOV
MOV
DX,FF50h
CL,06
MOV
BX,2000h
MOV
AL,[BX]
OUT
DX, AL
Back:
INC
BX
DEC
CL
JNZ
Loop back
Back
DIGIT
7
SEGMENT FC
CODE
60
BA F2
66
D6 DE
70
FE
76
7E CE 9C EA 9E
8259:
a) Return Interrupt number
Algorithm:
i.
ii.
F
1E
iii.
iv.
v.
vi.
vii.
viii.
Program:
Address
Label
MOV
Mnemonics
DX, FF50h
MOV
AL, 1Fh
OUT
DX,AL
MOV
DX, FF52h
MOV
AL, 10h
OUT
DX,AL
MOV
DX, FF52h
MOV
AL, 03h
OUT
DX,AL
MOV
DX, FF52h
MOV
AL, 80h
OUT
DX,AL
MOV
DX, FF50h
JMP
Comments
ICW1
ICW2
ICW4
OCW1
Enable interrupt
STI
WAIT:
Machine Code
WAIT
(ISR to be loaded in
vector location of
interrupt)
2000H
IN AL,DX
Break point
INT 3
Interrupt No
Vector location
IRQ0
0040H
0000H
2000H
IRQ1
0044H
0000H
2000H
IRQ2
0048H
0000H
2000H
IRQ3
004CH
0000H
2000H
IRQ4
0050H
0000H
2000H
IRQ5
0054H
0000H
2000H
IRQ6
0058H
0000H
2000H
IRQ7
005CH
0000H
2000H
OUTPUT: AL will contain the Interrupt value (The respective bit will be set with respect to interrupt No.)
IRQ0
IRQ1
IRQ2
IRQ3
IRQ4
IRQ5
IRQ6
IRQ7
01
02
04
08
10
20
40
80
Label
Mnemonics
Machine Code
Comments
IRQ0:
IRQ1:
MOV AX. Data1
MOV BX, data2
SUB AX, BX
IRET
IRQ2:
MOV AX. Data1
MOV BX, data2
MUL BX
IRET
Interrupt No
Vector location
IRQ0
0040H
0000H
2000H
IRQ1
0044H
0000H
3000H
IRQ2
0048H
0000H
4000H
8253:
Algorithm:
i.
ii.
iii.
iv.
v.
Program:
Address
Label
Mnemonics
Machine Code
Comments
MOV
AX,0050H
MOV
CX,AX
MOV
AL,36H
MOV
DX, FF56H
OUT
DX,AL
MOV
AL,CL
Count Lsb
MOV
DX, FF50H
Counter 0 Reg
OUT
DX,AL
MOV
AL,CH
OUT
DX,AL
Counter0 Is Selected
Control Reg
Count Msb
NOP
INT
Division Factor
3H
Ex.No: 7
SERIAL COMMUNICATION
Transmitter:
Algorithm:
i.
ii.
iii.
iv.
v.
vi.
TXBYTE:
i. Call delay routine
ii. Save the byte to another Reg from AL
iii. Load status reg address
iv. Read status word of 8251 and check ready bit(B0)
v. If zero continue checking
vi. Load mode reg address and get the Byte into AL
vii. Transmit the Byte
viii. Return to main program
BAUDINIT:
i.
ii.
iii.
iv.
v.
vi.
vii.
viii.
ix.
x.
DELAY:
i.
ii.
iii.
iv.
v.
Push BX in to stack
Load Count in to Stack
Wait and Decrement count
If count not zero then continue
Else Pop Bx form stack and return to main Program
Program:
Address
Label
Mnemonics
Machine Code
Comments
TXLOOP:
MOV
AX,0050H
MOV
BL,42H
CALL BAUDINIT
MOV
AL,BL
CALL TXBYTE
TXBYTE:
LOOOP:
JMP
TXLOOP
INT
CALL DELAY
MOV
BL,AL
MOV
DX,FF52H
Status Reg
IN
AL,DX
AND
JZ
AL,01H
LOOOP
MOV
AL,BL
MOV
DX,FF50H
MODE REG
OUT
DX,AL
TX THE BYTE
RET
BAUDINIT:
RETURN
MOV
CX,AX
MOV
AL,36H
Counter0 is selected
MOV
DX,FF06H
OUT
DX,AL
MOV
AL,CL
Count LSB
MOV
DX,FF00H
COUNTER 0 REG
OUT
DX,AL
MOV
AL,CH
OUT
DX,AL
NOP
Count MSB
Wait
NOP
MOV
DX,FF52H
Status Register
MOV
AL,00H
OUT
DX,AL
OUT
DX,AL
OUT
DX,AL
MOV
AL,40H
OUT
DX,AL
Reset Word
CALL DELAY
MOV
AL,4EH
OUT
DX,AL
NOP
NOP
MOV
AL,27H
OUT
DX,AL
ENABLE TX
NOP
NOP
RET
DELAY:
PUSH BX
MOV BX,04FFH
D1:
NOP
NOP
DEC BX
JNZ D1
POP BX
RET
Receiver:
Algorithm:
Delay Routine
i.
ii.
iii.
iv.
RXBYTE:
Address
Label
Mnemonics
MOV
AX,0050H
CALL BAUDINIT
Machine Code
Comments
Division Factor For Baud Count
AX Contain Timer Count
CALL RXBYTE
INT
RXBYTE:
MOV
IN
CHECK :
DX,FF52H
AL,DX
AND
JZ
MOV
BAUDINIT:
AL,02H
CHECK
DX,FF50H
Status Reg
Get the status word
check the Receiver Buffer bit
IN DX,AL
RET
RETURN
MOV
CX,AX
MOV
AL,036H
Counter0 is selected
MOV
DX,FF06H
OUT
DX,AL
MOV
AL,CL
MOV
DX,FF00H
OUT
DX,AL
MOV
AL,CH
Count LSB
COUNTER 0 REG
Count MSB
OUT
DX,AL
NOP
Wait
NOP
MOV
DX,FF52H
Status Register
MOV
AL,00H
OUT
DX,AL
OUT
DX,AL
OUT
DX,AL
MOV
AL,40H
OUT
DX,AL
Reset Word
CALL DELAY
MOV
AL,4EH
OUT
DX,AL
NOP
NOP
MOV
AL,27H
OUT
DX,AL
ENABLE TX
NOP
NOP
RET
DELAY:
PUSH BX
MOV BX,04FFH
D1:
NOP
NOP
DEC BX
JNZ D1
POP BX
RET
Procedure:
i.
Delay Routine
ii.
Load Transmitter program in One kit and Receiver in the other kit
iii.
iv.
Ex.No: 08
STEPPER MOTOR & DC MOTOR CONTROL
Stepper Motor
Algorithm:
Load control port address of 8255
Get Control word to initialize 8255 ports as Output ports
Send to control reg
Load 8255 Port C Address
STEP: Get initial phase position, Send to port C; Call delay routine
Get 2nd phase position, Send to port C; Call delay routine
Get 3rd phase position, Send to port C; Call delay routine
Get Final phase position, Send to port C; Call delay routine
Go back to STEP
Program:
Address
Label
STEP:
Mnemonics
Machine Code
Comments
MOV
DX, FF26H
MOV
AL,80H
OUT
DX,AL
MOV
DX, FF20H
Port C Address
MOV
AL,PH1
OUT
DX,AL
CALL DELAY
MOV
AL,PH2
OUT
DX,AL
CALL DELAY
MOV
AL,PH3
OUT
DX,AL
CALL DELAY
MOV
AL,PH4
OUT
DX,AL
CALL DELAY
DELAY:
DEL0:
DEL1:
JMP STEP
MOV
BX,0010H
Count 1
MOV
AX,00FFH
Count 2
NOP
NOP
NOP
NOP
DEC
AX
JNZ
DEL1
DEC
BX
JNZ
DEL0
Return to program
RET
Procedure:
i) Connect Stepper motor interface with VIK-86 through data bus and connect motor with interface.
ii) Give power supply to interface kit
iii) Load program and execute to run motor
iv) Change delay Count to control Speed
v) Change phase sequence to change direction of rotation.
Phase sequence:
Direction of rotation
PH1
PH2
PH3
PH4
Clock Wise
A0H
E0H
C0H
80H
80H
C0H
E0H
A0H
DC Motor:
Algorithm:
i.
ii.
Get control word so as to program 8255 ports as O/P port & send to control reg
iii.
iv.
v.
vi.
Call delaylow
vii.
Continue cycle
Program:
Address
Label
CONT:
Mnemonics
Machine Code
Comments
MOV DX , FF26H
MOV AL ,80H
OUT DX ,AL
MOV AL ,01H
Start Pulse
MOV DX , FF20H
Port C Address
OUT DX ,AL
CALL DELAYHIGH
MOV AL,00H
Stop Pulse
OUT DX,AL
CALL DELAYLOW
JMP CONT
Continue Cycle
DELAYHIGH:
MOV AH,01H
LOOP1:
NOP
NOP
NOP
DEC AH
JNZ
LOOP1
RET
DELAYLOW:
LOOP2:
MOV AL,01H
NOP
NOP
DEC AL
JNZ LOOP2
RET
Procedure:
i) Connect DC motor interface with VIK-86 through data bus and connect DC motor with interface.
ii) Give power supply to interface kit
iii) Load program and execute to run motor
iv) Change delay Count to control Speed
Ex.no: 10
a) Timer
Aim:
To program 8051 internal Timer0 to generate square waves of duty cycle 50% and 66% and output that
using IO pin P1. 2.
Algorithm:
i.
Initialize TMOD SFR for Timer0 on Mode 1 timer. ( 16 bit).
ii.
Load Count values to TL0 & TH0.
iii.
Toggle IO pin. (P1.2)
iv.
Call delay
v.
Continue cycle
Delay: start Timer
Moniter timer0 flag(TF0) until it rolls over.
Stop timer
Clear flag and return.
Program: 50% DUTY CYCLE ( Ton = Toff=D)
Address
Label
HERE:
DELAY:
CHECK:
Mnemonics
Machine Code
Comments
MOV
TMOD, #10
MOV
TL1, #F2H
Low byte
MOV
TH1, #FFH
High byte
CPL
P1.2
ACALL DALAY
SJMP
HERE
SETB TR1
Start timer 0
Check TF1 flag until it sets
CLR TF1
RET
Return to program.
SFR ADDRESSES : TMOD 89; TL1- 8B; TH1- 8D; TR1-8E; TF1 - 8F.
TL0- 8A; TH0- 8C; TR0- 8C; TF0 - 8D.
Program: 66% DUTY CYCLE ( Ton = 2D &Toff = D)
Address
Label
HERE:
Mnemonics
Machine Code
Comments
MOV
TMOD, #10
MOV
TL1, #F2H
Low byte
MOV
TH1, #FFH
High byte
SETB
P1.2
ACALL DALAY
ACALL DALAY
CLR P1.2 (Any pin in P1)
ACALL DALAY
SJMP
DELAY:
CHECK:
HERE
SETB TR1
Start timer 0
CLR TR1
CLR TF1
RET
CALCULATIONS:
XTAL = 10 MHz
Timer frequency, f = 10 /12 = 0.833 MHz
Time period , T = 1/0.833 = 1.2 s.
Delay, D = Count T
Count = FFFF FFF2 = 0Dh(13) + 1( for Roll over)
Now, D = 14 1.2 s = 16.8 s for 1 delay.
For 50 % duty cycle: T = Ton + T off = 2D = 33.6 s & Frequency of square wave, f = 1/T = 297.6 kHz
For 66 % duty cycle: T = Ton + T off = 3D = 54.9 s & Frequency of square wave, f = 1/T = 182.1 kHz
b) Interrupt Programming
Aim: To toggle P1.5 every second.
Address
Label
Mnemonics
MOV
TMOD, #10
001B:
TIMER1
ISR
Comments
Timer1 mode 1
MOV
TL1, #00H
Count value
MOV
TH1, #00H
Count value
SETB TR1
HERE:
Machine Code
SJMP
Start timer1
HERE
Check R0
Toggle IO pin
CPL
P1.5
Reload register value
TL1, #00H
MOV
TH1, #00H
RETI
EX.NO: 11
Aim:
To establish communication between two 8051 Kits.
Serial Communication:
Transmitter:
Address
Label
CHECK:
Mnemonics
Machine Code
Comments
MOV
IE, #00
Disable interrupts
MOV
TMOD, #20
Timer1 in mode2
MOV
TH1, #F5H
SETB TR1
Start timer1
JNB TI , CHECK
CLR T1
LCALL 00BB
Break point.
Receiver:
Address
Label
Mnemonics
Comments
IE, #00
Disable interrupts
MOV
TMOD, #20
Timer1 in mode2
MOV
TH1, #F5H
Machine Code
MOV
JNB
RI , CHECK
MOV A, SBUF
LCALL 00BB
Break point.
Parallel Communication:
Transmitter:
Address
Label
Mnemonics
MOV
A, #80
MOV
DPTR, #4003
MOVX
Comments
Machine Code
Comments
@DPTR, A
MOV
DPTR, #4000
MOV
A, #DATA
MOVX
Machine Code
@DPTR, A
NOP
NOP
LCALL 00BB
Receiver:
Address
Label
Mnemonics
MOV
A, #90
MOV
DPTR, #4003
MOVX
MOV
MOVX
@DPTR, A
DPTR, #4000
A, @DPTR
LCALL 00BB
Ex.No: 09
Aim:
To program 8051 using its Arithmetic and Logical and Bit Manipulation instructions.
a) Arithmetic operations
Address
Label
Mnemonics
MOV
DPTR, #8500
MOVX A, @DPTR
MOV
B, A
MOV R0, A
INC DPTR
MOVX
A, @DPTR
MOV R1, A
ADD A, B
INC DPTR
MOVX @DPTR, A
MOV R2, A
MOV A, R1
SUBB A, B
INC DPTR
MOVX @DPTR, A
MOV R3, A
MOV B, R2
MUL AB
INC DPTR
MOVX @DPTR, A
MOV A, R2
MOV B, R3
Machine Code
Comments
DIV AB
INC DPTR
MOVX @DPTR, A
LCALL 00BB
Input: M8500 - a
M8501 - b
Output: M8502 : sum (a+b)
M8503: difference (a-b)
M8504: Product ((a+b)(a-b))
M8505: Quotient ((a+b)/(a-b))
b) 32 bit subtraction
Address
Label
Mnemonics
CLR C
MOV
A, 43
SUBB A, 53
MOV 63, A
MOV
A, 42
SUBB A, 52
MOV 62, A
MOV
A, 41
SUBB A, 51
MOV 61, A
MOV
A, 40
SUBB A, 50
MOV 60, A
LCALL 00BB
Machine Code
Comments
C) Fibonacci series
Address
Label
Mnemonics
MOV
R0, 60
MOVX @DPTR, A
INC DPTR
RPT:
MOV R2, A
ADD A, R1
MOV 01, 02
MOVX @DPTR, A
INC DPTR
DJNZ R0, RPT
EXIT:
LCALL 00BB
so on
Machine Code
Comments