home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
mbug
/
mbug016.arc
/
DIRECTRY.MAC
< prev
next >
Wrap
Text File
|
1979-12-31
|
3KB
|
93 lines
v
Press ^X to abort, L to advance a line, cr to advance a page.
title Pass Directory List to BASIC
; Program to pass a directory listing to BASIC. The directory
; listing is used to create a BASIC Menu program.
;
; Program Execution.
; The default FCB contains the ambiguous file reference. This is used
; with CP/M call numbers 17 and 18 to get the file names of all files
; matching the ambiguous reference. The filenames so collected are
; returned to the BASIC calling program. Deleted files are not returned.
; The filename is placed in the first string variable defined. It
; is assumed that this variable has already been set up as a string
; of the right length.
; It is also assumed that the BASIC program has placed the ambiguous
; filename at address 5ch.
.z80
main:
push af
push de
push hl
push bc
push bc ;save BDOS call number
; clear rest of FCB
ld de,ftype+3
push de ;de
pop hl
inc de
ld bc,22
ld (hl),0
ldir
; set up buffer address
ld de,buffer
ld c,26
call bdos
pop bc ;retrieve bdos call #
jr main3
; get directory entry
main2:
ld c,17 ;get next entry
main3:
ld de,fcb
call bdos
or a ;does file exist?
jp p,found ;yes
pop bc
ld bc,-1 ;no, file doesn't exist
jr basretn ;return to caller
found:
; move entry to basic string
ld hl,buffer ;point to fle buffer
rlca ;multiply A by 32
rlca
rlca
rlca
rlca
ld c,a
ld b,0
add hl,bc ;point to entry in buffer
ld de,7f00h ;move to table next entry
ld a,0e5h ;check if file deleted
cp (hl)
jr z,main2 ;yes, try next entry
inc hl ;skip user byte
ld b,11
stack1:
ld a,(hl)
ld (de),a
inc hl
dec de
djnz stack1
pop bc
ld bc,0 ;valid file found
basretn:
pop hl
pop de
pop af
ret
ftype equ 5ch+1+8
fcb equ 5ch
bdos equ 5
buffer equ $
end
111. A3: DIRECTRY.MAC 4K :#06 #╦\(≡╔ └ÜòÖ=ÜrÜ¡ÜÆÆ▐æ°Ä⌡Ä≈