Logical Operation
Logical Operation
Logical Operation
To write ALP for performing Arithmetic, Logical , Bit manipulation operations in 8051
Apparatus:
1. ADS-SDA-51-STA kit
2. Microprocessor Power Supply
3. RS 232 Cable
5. Adapter, Keyboard, Cables, Connecting Wires Etc.
org 9000h
;addition without carry
mov a, #06h
mov b, #09h
add a, b
mov r0, a
;Substraction with carry
mov a, #08h
subbc a, #03h
mov r1, a
;multiplication
mov a, #03h
mov b, #06h
mul ab
mov r2, a
;division
mov a, #08h
mov b, #03h
div ab
mov r3, a
mov r4, b
;increment operation
mov a, #03h
inc a
mov r5, a
;decrement operation
mov r6, #07h
dec r6
lcall 0003h
end
Logical operation
org 8000h
mov r0, #0fh
mov r1, #foh
mov r2, #66h
; And operation
mov a, #ffh
anl a, r0
mov r3, a
; Or operation
mov a, #ffh
orl a, r1
mov r4, a
; Xor operation
mov a, 03h
mov a, #ffh
xrl a, r2
mov r5, a
lcall 0003h
end
Bit Manipulation
org 9000h
mov a, #ffh
clr c
;clear the carry flag
anl c, acc.7
mov r0, a
setb c
;set the carry flag
mov a, #00h
orl c, acc.5
mov r1, a
mov a, #ffh
cpl acc, 3
mov r2, a
lcall 0003h
end