Motorola M68000 User's Guide Page 79

  • Download
  • Add to my manuals
  • Print
  • Page
    / 256
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 78
Conditional and Arithmetic Instructions 65
FINI: MOVE.L Dl,D0
JSR OUTDEC
JSR NEWLINE
MOVEL D0,D1
BRA NEXT
YES, SAVE AS NEW VAL
BACK FOR NEXT VAL
SET UP FOR OUTPUT
OUTPUT THE VALUE
GO TO NEXT LINE
Two CMP instructions are used. The first CMP tests for the zero termi
nating value. The second determines if a new input value is larger than
the largest value encountered so far. It is important to remember to ini
tialize this value to something meaningful. In this case, a zero value is
smaller than any value we will encounter.
There are several additional versions of the compare instruction. Al
though any addressing mode, including immediate values, can be used as
the source operand, the destination operand can only be a data register.
The general form of the CMP instruction is:
The CMPA instruction allows the use of an address register as the desti
nation operand. Its form is:
While we may often desire to compare a data or address register with an
immediate value, we sometimes desire to compare a constant with the
contents of a memory location. It is not possible to use the CMP or CMPA
instruction in such a manner. We would first have to copy the contents
of memory to a register and then use the CMP instruction. Fortunately, a
special version of the CMP instruction, CMPI, exists to solve our problem.
Its general form is:
The destination operand is restricted in that it can't be an address register
(use CMPA in this case), or an immediate value. (This latter restriction
really isnt a restriction, because it makes no sense to compare one
constant with another, since the outcome is always the same.) Let’s assume
that we want to see if the contents of memory location COUNT, a byte
value, is less than 10. These are the instructions we would use:
CMP[.<size>] <ea>,Dn
CMPA(.<size>] <ea>,An
CMPII.<size>] #<data>,<ea>
CMPI.B #10,COUNT
BLT LESSTHAN
Page view 78
1 2 ... 74 75 76 77 78 79 80 81 82 83 84 ... 255 256

Comments to this Manuals

No comments