#comment This file is part of Z80 Scheme Interpreter Z80 Scheme Interpreter is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Copyright 2007, Spencer Putt #endcomment symbols = appbackupscreen symbols_size = 768 symbol_size = 16 symbols_count = symbols_size/symbol_size symbols_initialize: ld hl,symbols ld de,symbols+1 ld (hl),0 ld bc,symbols_size-1 ldir ret ; input ; - work should have the symbol text ; output ; hl - symbol symbol_make: make_symbol: ld hl,work ; if the input starts with #, it's not a symbol ld a,(hl) cp $23 ; # jp z,evaluate ; could potentially lead to an infinite loop push de call symbol_find pop de ret z cp symbols_count jp nc,err_symbol push de ld h,0 ld l,a push af mul_hl,bc(symbol_size) ld bc,symbols add hl,bc ex de,hl ld hl,work call strcpy pop af ld h,a ld l,tag_symbol pop de ret ; input ; work - symbol to find ; output ; z = symbol found ; hl - symbol ; nz = symbol not found ; a - index of next symbol symbol_find: push de call symbol_find_raw pop de ret symbol_find_raw: ld hl,symbols xor a symbol_find_loop: push af ld a,(hl) or a jr z,symbol_not_found push hl call work_strcmp pop hl jr z,symbol_found pop af ld bc,symbol_size ; advance to next symbol add hl,bc inc a ; increase symbol index cp symbols_count jr nz,symbol_find_loop or a ; reset z ret symbol_not_found: pop af inc h ; reset z ret symbol_found: pop af ld h,a ld l,tag_symbol cp a ; set z ret ; input ; hl - symbol1 ; de - symbol2 ; output ; hl - true or false ; z if equal ; nz if not equal symbol_equal?: strip_tag(hl) strip_tag(de) sbc hl,de jp nz_to_bool