 |
Arithmetic
Incrementing
Next we shall learn about simple arithmetic. As usual a little
lab session would help.
The following command incremements ACC by
1. Notice that the SFR ACC is always refered to as
A in assembly language (there does not seem to be any deep
reason behind this convention!).
inc A
Try it out.
You can of course try
inc R4
or
inc 5
The last command is like the C command RAM[5]++.
Lab session
Try the following.
mov R0, #255
inc R0
Notice how R0 "rolls over" to 0. Also notice
that this "rolling over" does not change anything else (for
instance no "carry" bit is set).
Decrementing
The command dec is for decrementing, and is
the opposite of inc. Try out the following to get a
hang of it.
Lab session
Try the following.
mov R0, #2
dec R0
Also try
inc R0
inc R0
dec R0
|