#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 ; input ; de - dest ; hl - source ; output ; hl - dest + length ; a - length strcpy: ld c,0 strcpy_loop: ld a,(hl) ldi or a jr nz,strcpy_loop ld a,c neg dec a ret ; input ; a - 8 bit number ; output ; hl - fixnum of a a_to_fixnum: add a,a\ add a,a ; make it a fixnum ld l,a xor a ; set z ld h,a ret ; input ; hl - char * of char to test ; output ; z - target is numeric ; nz - target is alphabet IsNumeric?: ld a,(hl) cp $2D ; - sign ret z cp '9'+1 ret nc cp '0' ret c cp a ret call_hl: jp (hl) neg_hl: ld a,h\ cpl\ ld h,a ld a,l\ cpl\ ld l,a inc hl ret neg_de: ld a,d\ cpl\ ld d,a ld a,e\ cpl\ ld e,a inc de ret ; input ; hl - string pointer ; output ; nz = there's a next char: ; hl - next char ; z = no next char ; hl - undefined ; a - first non white char next_char: ld a,(hl) or a ret z call white_space? jr z,next_char_skip cp $3B ; is a comment? ret nz inc hl _ ld a,(hl) or a ret z cp $0A inc hl jr nz,-_ jp next_char next_char_skip: inc hl jp next_char ; input ; z - z if true, nz if false ; output ; hl - TRUE or FALSE nz_to_bool: jr nz,_ ld hl,true ret _ ld hl,false ret ; input ; a - character ; output ; a - character ; z - character is a list terminator ; nz - character is not a list terminator #include "fcreate.inc" #macro optionz(zz) clr() wr("_:") wr(" cp ",zz) #if ++_ - $ = 3 wr(" ret z") #else wr(" ret") #endif run() #endmacro #define option optionz( list_terminator?: terminator?: option $29 option $5D .db 0 initiator?: option $28 option $5B .db 0 white_space?: option ' ' option $0D option $0A option $09 .db 0