Motorola Axiom CMD11E1 Uživatelská příručka Strana 23

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 101
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 22
2.5. OTHER CONDITIONAL BRANCHES 23
DECB
BRA KINGS
CABBAGES
LDAA #$0A
JSR OUTA
JSR OUTA
SWI
2.5 Other Conditional Branches
2.5.1 Signed and unsigned numbers
So far we have only considered comparing two values and branching if they are
equal (BEQ) or not equal (BNE). Designers of HC11 have provided several other
branches. When comparing two numbers, it is important to distinguish between
signed and unsigned quantities. Note that the internal hardware does not deal
with numbers per se bit with binary patterns which are interpreted as numbers.
Conversely, numbers are represented by bit patterns and it up to you to chose the
appropriate interpretation. For example, using binary representations, an 8-bit
quantity can represent any number from 0 to 2
8
1 or 0 to 255. This is the
unsigned representation. What happens if we use an 8-bit counter and starting
at zero and incrementing it by one? The value will go from one to two to three
etc. all the way to 255 and then roll over to zero and start all over again. This
is the unsigned interpretation. Now suppose you start at zero and decrement
by one. The value will go from zero to 255 to 254 etc. But starting from zero
decrementing by one you get -1. Thus 255 really represents -1. This is the signed
interpretation.
5
This dual interpretation is quite natural and does not pose any
problems except when performing comparisons. In the signed interpretations,
numbers 0 to 127 are non-negative, and numbers 128 to 255 are negative, with
128 representing -128, 129 representing -127 ... and 255 representing -1. Note
that the negative numbers come after the positive numbers thus when comparing
two numbers of the opposite sign, the sense of inequality are reversed. Keeping
this in mind, HC11 hardware designers have two sets of branch conditions, one
for signed numbers (where special attention is given if the two numbers that are
5
This dual interpretation is something I use often. It is easy to think of the clock, and say the
minute setting. Starting at zero and incrementing by one, I get one, two, · · · to 59 and back to
zero. When I set the alarm on this clock I cannot go back, only forward. So, if I want to decrease
the minute value by 5, I have to advance it by 55. Thus adding 55 is same as subtracting 5, or
in terms of arithmetic 55 is has the dual interpretation of -5.
Zobrazit stránku 22
1 2 ... 18 19 20 21 22 23 24 25 26 27 28 ... 100 101

Komentáře k této Příručce

Žádné komentáře