
64 Assembly Language Programming for the 68000 Family
not equal, it is sometimes difficult to remember which value should be
the source and which value should be the destination. The CMP instruc
tion compares the destination with the source. Therefore, if we wish to
determine if DO is less than or equal to D1 we would write
CHP.L DirDO
BLE LABEL
An easy way to remember this is:
destination <inequality> source
The following table shows the conditional branches for signed numbers.
C tA f A
{I < / BLT Branch on less than
f < = /' BLE Branch on less or equal
= BEQ Branch on equal
> = BGE Branch on greater or equal
> BGT Branch on greater than
not = BNE Branch on not equal
When you compare unsigned numbers you should use the following.
< BCS® Branch on carry set
< = BLS Branch on lower or same
= BEQ Branch on equal
> = BCC° Branch on carry clear
> BHI Branch on higher
not = BNE Branch on not equal
0 These mnemonics are not particularly indicative of their function, but they are the
ones to use.
The tests for equal and not equal use the same conditional branches
for both signed and unsigned numbers. The following program finds
the largest unsigned number from an arbitrary number of input values.
Entering a zero value terminates input and outputs the result.
* FIND LARGEST
INPUT VALUE
* ZERO
VALUE TERMINATES INPUT
CLR.L D1
INITIAL VALUE IS ZERO
NEXT:
JSR
INDEC GET NEXT INPUT VAL
TST.L
DO
ZERO?
BEQ FINI
YESr ALL DONE
CMP.L
Dlr DO LARGER?
BLE
NEXT
NO
Kommentare zu diesen Handbüchern