#ifndef DEF_INC #define DEF_INC #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 #define tag_size 2 #define tag_mask eval(1 << tag_size - 1) #define tag_fixnum 0 #define tag_pair 1 #define tag_escape 2 #define tag_closure 3 #define escape_size 5 #define escape_mask eval(1 << escape_size - 1) #define escape(gg) (gg) << tag_size | tag_escape #define escape_value(gg, mm) (gg) << escape_size | (mm) #define tag_bool escape(0) #define FALSE escape_value(0, tag_bool) #define TRUE escape_value(1, tag_bool) #define tag_symbol escape(1) #define tag_block escape(2) #define tag_vector escape_value(0, tag_block) #define tag_string escape_value(1, tag_block) #define tag_char escape(3) ; Empty list '() #define NULL escape(4) #define VOID escape(5) #define empty escape(6) #define work_size symbol_size #define a 1 #define b 2 #define c 3 #define d 4 #define e 5 #define f 6 #define hl 7 #define de 8 #define bc 9 #define ix 10 #define iy 11 #define zreg 0 #macro assert_type(ztype, zreg) #define ztype concat("tag_",ztype) #if zreg = hl ld a,l #else #if zreg = de ld a,e #else #if zreg = bc ld a,c #endif #endif #endif #if ztype = tag_symbol and escape_mask #else #if ztype = tag_bool and escape_mask #else and tag_mask #endif #endif cp ztype jp nz,err_data_type #endmacro #macro strip_tag(zreg) #if zreg = hl ld a,l and ~tag_mask ld l,a #else #if zreg = de ld a,e and ~tag_mask ld e,a #else #if zreg = bc ld a,c and ~tag_mask ld c,a #endif #endif #endif #endmacro #macro do_mul(bit) #if mfstart = 1 add hl,hl #endif #if num&bit = bit #if mfstart = 0 #if num&(bit-1)>0 ld c,l ld b,h #endif #define mfstart 1 #else add hl,bc #endif #endif #endmacro #define muloop( loop ) #if loop > 0\ do_mul( 1<<(loop-1) )\ muloop( eval( loop-1) )\ #endif #macro mul_hl,bc( num ) #define mfstart 0 muloop(16) #if mfstart=0 \ ld hl,0 \ #endif #endmacro #endif