70 CHAPTER 5. TABLES
; print 2 spaces so the output looks neat
ldaa #’ ’
jsr outa
jsr outa
pula ; get it back
jsr outa
jsr outcrlf
bra mainloop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;translate: Translates telephone codes.
;Entry: Register A has the value to be translated
;Exit: If A has an upper case letter, then its content is replaced
; by the the translation given on the phone is performed
; ABC -> 2, DEF ->3, etc.
; If A has any other character, it is left alone.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
translate
ldx #alphabet
ldab #nalphabet
jsr lookup
bcc bye ; Not an alphabet. Leave it alone
ldaa nalphabet,x ; This is the key to translation
bye
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 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
Comentarios a estos manuales