[abc80] Abc80-fpga: skriva till direktfiler på PRB:
H. Peter Anvin
hpa at zytor.com
Sat Aug 8 15:19:26 PDT 2009
Helt och totalt otestat:
;
; Get a binary block from the file in DE loaded into Q0¤
;
; Usage: Z%=CALL%(address, filenum);
;
; Note: the only position-dependent instruction in this
; entire piece of code is the CALL instruction near the end.
;
org 32768 ; Or whereever...
get_blk:
; DE = file number
; Find Q0¤
push ix
ld hl,(65065) ; Variable list
find_q0:
ld a,l
or h
jr nz,var_not_end
rst 10h
defb 128+0 ; "Ej tillåtet öka DIM"
var_not_end:
ld a,(hl)
inc hl
cp 02h ; ?0¤
ld a,(hl)
inc hl
jr nz,skip
cp 'Q' ; Q..
jr z,found_q0
skip:
ld a,(hl)
inc hl
ld h,(hl)
ld l,a
jr find_q0
found_q0:
ld e,(hl)
inc hl
ld a,(hl)
inc hl
and a
jr nz,okdim
ld a,e
cp 253
jr nc,okdim
rst 10h
defb 128+10 ; "Texten får ej plats i strängen"
okdim:
ld b,(hl)
inc hl
ld c,(hl)
push bc ; String data pointer
ld (hl),253 ; Length <- 253
inc hl
ld (hl),0
; Now we have the string target address on stack, and the
; file number in (D)E. Find the file.
ld ix,(65074)
find_file:
defb 0ddh
ld a,l ; LD A,IXL
defb 0ddh
or h ; OR IXH
jr nz,file_not_end
rst 10h
defb 128+44 ; "Logisk fil ej öppen"
file_not_end:
ld a,(ix+2)
cp e
jr z,found_file
ld c,(ix+0)
ld b,(ix+1)
push bc
pop ix
jr find_file
found_file:
ld l,(ix+3) ; Point to the device list entry
ld h,(ix+4)
inc hl
inc hl
inc hl
inc hl
inc hl
ld e,(hl)
inc hl
ld d,(hl)
ld hl,3*5 ; READ BLOCK
add hl,de
call jp_hl ; Call the read block routine
; Now HL -> filled buffer
pop de
ld bc,253
ldir
pop ix
ret
jp_hl:
jp (hl)
--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
More information about the ABC80
mailing list