-read_symfile:\r
- ld de,fcbsym+1\r
- ld a,(de)\r
- cp ' '\r
- jp z,p_max_high\r
-\r
- push hl ; offset\r
- call pstr_inl\r
- db 'SYMBOLS',CR,LF+80h\r
-\r
- dec de\r
- call file_open\r
- ld a,(symattrib)\r
- ld c,a\r
-rs_1:\r
- call read_byte\r
-rs_2:\r
- pop de ; offset\r
- cp 1ah\r
- jp z,p_max_high\r
- push de ; offset\r
- cp '!'\r
- jr c,rs_1\r
- call read_hexbyte0 ; symval H\r
- ld h,a\r
- call read_hexbyte ; symval L\r
- ld l,a\r
- add hl,de\r
- call read_byte\r
- cp ' '\r
- jr z,rs_4\r
-rs_3: call read_byte\r
- cp ' '\r
- jr nc,rs_3\r
- jr rs_2\r
-\r
-rs_4:\r
- push hl ; symval\r
- ld hl,(BDOS+1) ;\r
- ld b,0 ; setup symlen\r
-rs_5:\r
- dec hl ;\r
- call read_byte ; next char of symbol name\r
- call test_sym_char ; valid char?\r
- jr nz,rs_6\r
- bit SYMCASE_CONV,c\r
- jr z,rs_51\r
- call toupper\r
- bit SYMCASE_LOWER,c\r
- call nz,tolower\r
-rs_51:\r
- ld (hl),a ;\r
- inc b ; symlen++\r
- ld a,(symlen_max) ;\r
- cp b ;\r
- jr nc,rs_5 ;\r
-error3:\r
- jp ERROR ;\r
-\r
-rs_6:\r
- call test_symterm_ch\r
- jr nz,error3\r
-\r
- push bc ; symlen\r
- ex de,hl ;\r
- ld hl,(BDOS+1) ;\r
- inc hl ;\r
- ld c,(hl) ;\r
- inc hl ;\r
- ld b,(hl) ;\r
- ex de,hl\r
- ld (hl),b ;\r
- dec hl ;\r
- ld (hl),c ;\r
- dec hl ;\r
- ld (hl),0c3h ;\r
-\r
- ld de,(max_load) ;\r
- call cp_hl_de ;\r
- jr c,error3 ;\r
- ld de,(reg_sp) ;\r
- call cp_hl_de ;\r
- jr nc,rs_61 ;\r
- ld (reg_sp),hl ;\r
-rs_61:\r
- ld de,(BDOS+1) ;\r
- ld (BDOS+1),hl ;\r
- ex de,hl ;\r
- pop bc ; symlen\r
- ld (hl),b ;\r
- inc hl ;\r
- pop de ; symval\r
- ld (hl),e ;\r
- inc hl ;\r
- ld (hl),d ;\r
- ld a,b ;\r
- ld hl,symlen_cur ;\r
- cp (hl) ; new max?\r
- jr c,$+3 ;\r
- ld (hl),a ;\r
- jp rs_1 ;\r
-\r
-\r
-; test for valid character for symbols\r
-; return z if valid\r
-\r
-test_sym_char:\r
- cp '$'\r
- ret z\r
- cp '%'\r
- ret z\r
- cp '.'\r
- ret z\r
- cp '_'\r
- ret z\r
- call test_alphanum\r
- ret c ; cy == 1 --> z == 0\r
- cp a ; return z\r
- ret\r
-\r
-\r
-; check if char is in [0..9,?,@,A..Z,a..z]\r
-; return cy if invalid\r
-; return nc if valid alfanumeric char\r
-\r
-test_alphanum:\r
- cp 'z'\r
- ret z\r
- ccf\r
- ret c\r
- cp 'a'\r
- ret nc\r
- cp 'Z'\r
- ret z\r
- ccf\r
- ret c\r
- cp '?'\r
- ret nc\r
-test_numeral:\r
- cp '9'\r
- ret z\r
- ccf\r
- ret c\r
- cp '0'\r
- ret\r
-\r
-test_symterm_ch:\r
- cp CR\r
- ret z\r
- cp LF\r
- ret z\r