Commonly, data
processing instruction are grouped in to two categories: instructions for
logical operation and arithmetic. Instructions for arithmetic consist of
addition, subtraction, increment, decrement, multiplication, division and
decimal adjustment.
Instructions for logical operation consists of AND, OR, EX-OR, complement,
clear, rotation and swap.
Almost of these
instructions are using register A (accumulator) at every operation (for
multiplication and division are using accumulator . Such instructions add, subb,
mul and div. Where as inc and dec can be hold in every register.
Addition and subtraction operation.
Example code for this
operation is shown below.
org 00h
mov a, #20 ;putting 20 in to
accumulator
add a, #8
;adding accumulator by 8. The result is stored in accumulator (acc=28)
; this is an example for immediate addressing mode
mov 70h, #4 ;putting 4 in to register
that has address 70h
add a, 70h ;adding
accumulator by the contents of register that has address 70h (acc=32)
; this is an example for direct addressing mode
mov 78h, #9 ;putting 9 in to register
that has address 78h
mov r0, #78h ;putting 78h in to register r0
add a, @r0 ;adding acc by
the contents of the register that its address is stored in r0 (acc=41)
mov
a, #100 ;putting 100 in to accumulator
subb
a, #8 ;subtraction acc by 8
(acc=92)
....
....
Increment and decrement operation.
org 00h
mov
a, #10 ;putting 10 in to accumulator
inc a
;adding accumulator by 1
dec a
;subtracting accumulator by 1
mov
r0, #9 ;putting 9 in to register r0
inc
r0
;adding register r0 by 1
dec
r0
;subtracting register r0 by 1
.....
.....
Multiplication and division operation.
org 00h
mov
a, #10 ;putting 10 in to accumulator
mov
b, #2 ;putting 2 in to
register B
mul
ab
;multiply content of accumulator by the content of B,
;The result is stored in A (low byte) and high byte is stored
in B
mov
a, #20 ;putting 20 in to accumulator
mov
b, #4 ;putting 4 in to
register B
div
ab
;dividing the content of accumulator by the content of B
; the result is stored in A, where as the reminder is stored in B
...
...
Decimal adjustment
org 00h
mov
a, #10h ;putting 10h in to accumulator
(acc=10h)
da a
;adjusting the content of accumulator in to decimal
number (acc=80bcd)
...
...
org 00h
mov
a, #0FFh ;putting FFh in to accumulator
anl
a, #0F ;force high nible low
(acc=00001111b)
mov
a, #10101010b ;putting 10101010 in to
accumulator
orl
a, #0F0h
;force high nible high (acc=11111010b)
cpl a
; complement the content of accumulator
(acc=00000101b)
clr a
; clear the content of accumulator
(acc=00000000b)
...
...
