60 CHAPTER 5. TABLES
ORG $3000 *data section
...
...
primes fcb 2,3,5, 7, 11, 13, 17, 19, 23, 29 *table of some primes
nprimes equ 10 *number of entries in the table
If you want to set up a table of ascii code for digits, you would write
...
ORG $3000 *data section
...
...
digits1 fcb $30, $31, $32, $33, $34, $35, $36, $37, $38, $39
ndigits1 equ 10 *number of entries in the table
A better way to do the same is to write
...
ORG $3000 *data section ..$
...
...
digits fcc /0123456789/
ndigits equ 10 *number of entries in the table
Assembler will convert FCC to a sequence of FCB.
Exercise: Write an ASM file with the two versions of the digits tables, assemble
the file and look at the LST file. Verify that the two tables are identical.
5.5 Working with tables
We will write functions to perform some basic tasks with the tables. In all these
functions, we will use the following convention:
1. The starting address will be passed to the function in the X register.
2. The size of the table will be passed to the function in the B register.
5.5.1 Table lookup
This is the simplest and the most useful function. We want to know if an element
is in the table. For now, we will work with a table of 8-bit quantities. The value
to be looked up will be passed in the A register. The function will have to return
Comentarios a estos manuales