Multi byte addition
Start
Load Accumulator with 0E7h
Add 08Dh to the contents of Accumulator
Move the result to R6 register
Load Accumulator with 03Ch
Add 03Bh to the contents of A with carry
Copy the higher byte result to R7 register
END
Multi byte Subtraction
Start
Load Accumulator with 043h
Load R0 with 051h
Subtract R0 from A
Copy the lower byte result to R6 register
Load Accumulator with 017h
Copy the higher byte result to R7 register
END
Clear Carry flag
Load R1 with 012h
Subtract R1 from A
2’s Compliment
Start
Load Accumulator with 085h
Compliment the contents of Accumulator
Add 1 to the Acc to get 2’s Compliment
Copy the result to R0 register
END
Largest Number Start
Clear Accumulator
Load R1 with no of values
Decrement R1
Load DPTR with the address of values
Copy first number to Accumulator
Copy the first number to R0 register
END
Clear Accumulator
Increment DPTR to point next location
Copy the next number to Accumulator
Compare the contents of Accumulator with R0 register
Is Acc > R0 ?
Yes
No
Copy the Acc Contents to R0 register
Decrement R1
Is R1 = 0?
Yes
No
Smallest number Start
Clear Accumulator
Load R1 with no of values
Decrement R1
Load DPTR with the address of values
Copy first number to Accumulator
Copy the first number to R0 register
END
Clear Accumulator
Increment DPTR to point next location
Copy the next number to Accumulator
Compare the contents of Accumulator with R0 register
Is Acc < R0 ?
Yes
No
Copy the Acc Contents to R0 register
Decrement R1
Is R1 = 0?
Yes
No
Ascending orderStart
Load R1 with the destination Address
Load R3 with number of values
Load R4 with number of values
Decrement R4
Load R0 with the address of the values
Copy first number to Accumulator
END
Copy first number to R6 register
Increment R0 to point next location
Copy the next number to Accumulator
Compare the contents of Accumulator with R6 register
Is Acc <R6 ?
Yes
No
Copy the Acc Contents to R6 register
Decrement R4
Is R4 = 0?
YesNo
Copy the contents of R6 reg to Acc
Copy the first smallest number to destination address at R1
Copy the contents of R6 reg to Acc
Increment R1
Call Subroutine program
Decrement R3
Is R3 = 0?
Yes
No
Ascending order Subroutine
Start
Load R5 with number of values
Load R0 with address of values
Copy first number to Accumulator
Compare Contents of R6 register with Acc
Return to main program
Increment R0
END
Is Acc =R6 ?
Yes
No
Load 0FFh at the address specified by R0
Decrement R5
Is R5 = 0 ?
Yes
No
Start
Load R1 with the destination Address
Load R3 with number of values
Load R4 with number of values
Decrement R4
Load R0 with the address of the values
Copy first number to Accumulator
END
Copy first number to R6 register
Increment R0 to point next location
Copy the next number to Accumulator
Compare the contents of Accumulator with R6 register
Is Acc > R6 ?
Yes
No
Copy the Acc Contents to R6 register
Decrement R4
Is R4 = 0?
YesNo
Copy the contents of R6 reg to Acc
Copy the first smallest number to destination address at R1
Copy the contents of R6 reg to Acc
Increment R1
Call Subroutine program
Decrement R3
Is R3 = 0?
Yes
No
Descending order
Descending order Subroutine
Start
Load R5 with number of values
Load R0 with address of values
Copy first number to Accumulator
Compare Contents of R6 register with Acc
Return to main program
Increment R0
END
Is Acc =R6 ?
Yes
No
Load 00h at the address specified by R0
Decrement R5
Is R5 = 0 ?
Yes
No
Multiplication of two numbers
Start
Load Accumulator with 08h( multiplicand )
Load B register with 03h( multiplier )
Multiply A and B
Copy lower byte(Acc) result to 50h
Copy higher byte(B reg) result to 51h
END
Division of Two numbers
Start
Load Accumulator with 0ah(dividend)
Load B register with 03h(divisor)
Divide A by B
Copy quotient(Acc) to 50h
Copy remainder(B reg) to 51h
END
Multiplication of two number using counter method
Start
Clear Accumulator
Load R0 with 03h( multiplicand )
Load R1 with 04h( multiplier)
Add contents of R1 reg to Accumulator
Store product in 50h address
END
Is R0 = 0 ?
Yes
No
Decrement R0
division of two number using counter method
Start
Clear Carry flag
Load Accumulator with 40h
Load R0 register with 10h
Clear R0 register
Increment R1
END
Is Acc = 0 ?
Yes
NoSubtract R0 from Accumulator
Is carry set?
Yes
No
No
Stepper motor clock wise
Decrement R0 reg
Load R0 reg with F1h
Yes
No
Start
Load R1 reg with 0Fh
Decrement R1 reg
Is R1 = 0 ?
Return to main program
Yes
No
Is R0 = 0?
Start
Initialize 8255
Load Accumulator with initial pulse word
Load DPTR with the port address of 8255
Send the pulse word to the port
Call Delay Subroutine
Rotate the pulse word towards Right
Stepper motor anti-clock wise
Decrement R0 reg
Load R0 reg with F1h
Yes
No
Start
Load R1 reg with 0Fh
Decrement R1 reg
Is R1 = 0 ?
Return to main program
Yes
No
Is R0 = 0?
Start
Initialize 8255
Load Accumulator with initial pulse word
Load DPTR with the port address of 8255
Send the pulse word to the port
Call Delay Subroutine
Rotate the pulse word towards left
Triangular wave
Start
Initialize 8255
Load the Acc with 0FFh digital data
Load the DPTR with the address of DAC
Send the digital signal data to DAC
Decrement Accumulator
Is Acc = 0?
Yes
No
Increment Accumulator
Is A = 0FFh ?
Yes
No
Load the DPTR with the address of DAC
Send the digital signal data to DAC
Saw-tooth wave
Start
Initialize 8255
Load the Acc with 0FFh digital data
Load the DPTR with the address of DAC
Send the digital signal data to DAC
Decrement Accumulator
Is Acc = 0?
Yes
No
Square wave
Start
Initialize 8255
Load the Acc with 00h digital data
Load the DPTR with the address of DAC
Send the digital signal data to DAC
Call Delay Subroutine
Compliment Accumulator contents
Decrement R0 reg
Load R0 reg with 0FFh
Yes
No
Start
Load R1 reg with 0Fh
Decrement R1 reg
Is R1 = 0 ?
Return to main program
Yes
No
Is R0 = 0?
Largest number
Start
Clear Accumulator
Load R1 with no of values
Decrement R1
Load R0 with the address of values
Increment R0 to point next location
Copy the next number to Accumulator
END
Compare the contents of Accumulator with 50h address
Is Acc > 50h ?
Yes
No
Copy the Acc Contents to 50h address
Decrement R1
Is R1 = 0?
Yes
No
Copy contents of 50h address to accumulator
Smallest number
Start
Clear Accumulator
Load R1 with no of values
Decrement R1
Load R0 with the address of values
Increment R0 to point next location
Copy the next number to Accumulator
END
Compare the contents of Accumulator with 50h address
Is Acc < 50h ?
Yes
No
Copy the Acc Contents to 50h address
Decrement R1
Is R1 = 0?
Yes
No
Copy contents of 50h address to accumulator
Stepper motor
PPI 8
255
Oct
al B
uffer
(inve
rting
)
High
Spe
ed
Switc
hing
tr
ansis
tor
HEX
Buffe
r
Vcc
PC0
- PC7 PC
0 - P
C7
LEDs
to In
dica
te
the
phas
e of
mot
or
Step
per m
otor
8051
DAC
PPI 8
255
Oct
al B
uffer
(inve
rting
)
High
Spe
ed
Switc
hing
tr
ansis
tor
8051
Oct
al B
uffer
(inve
rting
)
Volta
ge
I/P
Volta
ge
O/P
Vref
PA0-
PA7
O/P
0 to
10V
or
-5V
to +
5V
Top Related