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

  • 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 66
5.5. WORKING WITH TABLES 67
;;; Add the code for lookup function here
Exercise: Type the above program and run it. Enter the following input and
explain what you see:
Exercise: Type the above program and run it. Enter the following input and
explain what you see: 123-34-1879.
Exercise: Modify the above program so that it accepts exactly 10 digits and
stops with an SWI after reading 10 characters. In other words, convert the main
loop into a counting loop. You should keep the count in the B register. Verify
your program with the input: 823--xx-34-1879.
5.5.3 Translations using tables
Some time we want to translate a value to another value. For example if the user
types the character 8, your program will receive the ascii code for the character.
You now will have to convert it to its value, viz 8. This is easy since you just have
to subtract $30. However, if the user enters data in HEX, then he would expect
the program to translate A and a to 10, B and b to 11 and so on. For problems of
this nature, we first write down the translation table
value translation
$30 or ’0’ 0
$31 or ’1’ 1
$32 or ’2’ 2
etc. etc
$39 or ’9’ 9
$41 or ’A’ 10
$61 or ’a’ 10
$42 or ’B’ 11
$62 or ’b’ 11
etc. etc
etc. etc
In our assembly program we set up two tables. It is extremely important that the
two tables be ordered as follows: The table of values first immediately followed
by the table of translations. For example, to perform the above translation, we
will write
Zobrazit stránku 66
1 2 ... 62 63 64 65 66 67 68 69 70 71 72 ... 100 101

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

Žádné komentáře