5.5. WORKING WITH TABLES 61
a Yes/No value. A convenient way to return a Yes/No value is to use a hardware
flag. Let us use the Carry flag. The function will set the flag if the answer is yes;
or else it will clear the carry.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; lookup: Function to lookup a value in a table
; Checks if the value in A register is in the table
;
; Entry: Starting address in X, size in B, value in A
; Exit: Carry set if the value in A is in the table;
; cleared if not in the table
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
lookup
lkploop
tstb
beq notthere *this is the basic counting loop
cmpa 0,x
beq foundit
inx
decb
bra lkploop
notthere
clc
rts
foundit
sec
rts
Here is a program that uses the function:
;Name:
;email:
;date:
;
; Standard buffalo equates
; Make sure you have ALL the equates in the file.
;
ucase equ $ffa0
wchek equ $ffa3
dchek equ $ffa6
Kommentare zu diesen Handbüchern