-cmd_R:\r
- ld hl,0\r
- call get_lastarg_def\r
-read_file:\r
- ld de,dfcb1+1\r
- ld a,(de)\r
- cp '?'\r
- jr z,read_symfile\r
- dec de\r
- push hl\r
- ld hl,0\r
- ld (high_load),hl\r
- call file_open\r
- ld hl,dfcb1+9\r
- ld de,str_hex\r
- ld b,3\r
- call strncmp\r
- pop hl\r
- jr z,read_hexfile\r
- ld de,TPA\r
- push hl\r
- add hl,de\r
-l108eh:\r
- call read_sector\r
- jr nz,read_file_nxt\r
- pop hl\r
- jr read_symfile\r
-\r
-read_file_nxt:\r
- ld de,DMA_BUF\r
- ld b,080h\r
-l109ah:\r
- ld a,(de)\r
- call cmdR_storebyte\r
- inc de\r
- inc hl\r
- djnz l109ah\r
- jr l108eh\r
-\r
-read_hexfile:\r
- push hl\r
-l10aeh:\r
- call read_byte ; RECORD MARK\r
- jr z,rdhex_done\r
- cp ':'\r
- jr nz,l10aeh\r
- ld c,0\r
- call read_hexchar ; RECLEN\r
- ld b,a\r
- call read_hexchar ; LOAD ADDR H\r
- ld h,a\r
- call read_hexchar ; LOAD ADDR L\r
- ld l,a\r
- ld a,b\r
- and a\r
- jr z,rdhex_done\r
- call read_hexchar ; RECTYP\r
-l10cch:\r
- call read_hexchar ; DATA\r
- pop de\r
- push de\r
- push hl\r
- add hl,de\r
- call cmdR_storebyte\r
- pop hl\r
- inc hl\r
- djnz l10cch\r
- call read_hexchar ; CHKSUM\r
- ld a,c\r
- and a\r
- jr nz,error9\r
- jr l10aeh\r
-rdhex_done:\r
- pop hl\r
- jr read_symfile\r
-\r
-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
-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
- push hl ; symval\r
- call read_byte\r
- cp ' '\r
- jr z,rs_4\r
- pop hl ; discard symval\r
-rs_3: call read_byte\r
- cp ' '\r
- jr c,rs_2\r
- jr rs_3\r
-\r
-rs_4: ld hl,(BDOS+1) ;\r
- ld e,0 ; setup symlen\r
-rs_5: dec hl ;\r
- call read_byte ; next char of symbol name\r
- cp TAB ; symbol term?\r
- jr z,rs_6 ;\r
- cp CR ;\r
- jr z,rs_6 ;\r
- cp '!' ; TODO: check for valid symbol char instead\r
- jr c,error9 ;\r
- ld (hl),a ;\r
- inc e ; symlen++\r
- ld a,e ;\r
- cp 10h+1 ;\r
- jr c,rs_5 ;\r
-error9:\r
- jp ERROR ;\r
-\r
-rs_6: push de ; symlen\r
- push hl ;\r
- ex de,hl ;\r
- ld hl,(BDOS+1) ;\r
- inc hl ;\r
- ld e,(hl) ;\r
- inc hl ;\r
- ld d,(hl) ;\r
- pop hl ;\r
- ld (hl),d ;\r
- dec hl ;\r
- ld (hl),e ;\r
- dec hl ;\r
- ld (hl),0c3h ;\r
-\r
- ld de,(max_load) ;\r
- call cp_hl_de ;\r
- jr c,error9 ;\r
-\r
- ld de,(reg_sp) ;\r
- call cp_hl_de ;\r
- jr nc,rs_61 ;\r
- ld (reg_sp),hl ;\r
-rs_61:\r
-\r
- ld de,(BDOS+1) ;\r
- ld (BDOS+1),hl ;\r
- ex de,hl ;\r
- pop de ;\r
- ld (hl),e ; symlen\r
- ld a,e\r
- inc hl ;\r
- pop de ; symval\r
- ld (hl),e ;\r
- inc hl ;\r
- ld (hl),d ;\r
- ld hl,symlen_max\r
- cp (hl)\r
- jr c,$+3\r
- ld (hl),a\r
- jp rs_1 ;\r
-\r