home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / MBUG / MBUG016.ARC / DIRECTRY.MAC < prev    next >
Text File  |  1979-12-31  |  3KB  |  93 lines

  1. v
  2. Press ^X to abort, L to advance a line, cr to advance a page.
  3.         title    Pass Directory List to BASIC
  4. ;       Program to pass a directory listing to BASIC. The directory
  5. ;       listing is used to create a BASIC Menu program.
  6. ;
  7. ;       Program Execution.
  8. ;       The default FCB contains the ambiguous file reference. This is used
  9. ;       with CP/M call numbers 17 and 18 to get the file names of all files
  10. ;       matching the ambiguous reference. The filenames so collected are
  11. ;       returned to the BASIC calling program. Deleted files are not returned.
  12. ;       The filename is placed in the first string variable defined. It
  13. ;       is assumed that this variable has already been set up as a string
  14. ;       of the right length.
  15. ;       It is also assumed that the BASIC program has placed the ambiguous
  16. ;       filename at address 5ch.
  17.  
  18.         .z80
  19. main:   
  20.         push    af
  21.         push    de
  22.         push    hl
  23.         push    bc
  24.         push    bc      ;save BDOS call number
  25.  
  26. ;                       clear rest of FCB
  27.         ld      de,ftype+3
  28.         push    de              ;de
  29.         pop     hl
  30.         inc     de
  31.         ld      bc,22
  32.         ld      (hl),0
  33.         ldir
  34.  
  35. ;       set up buffer address
  36.         ld      de,buffer
  37.         ld      c,26
  38.         call    bdos
  39.         pop     bc              ;retrieve bdos call #
  40.         jr      main3
  41.  
  42. ;       get directory entry
  43. main2:
  44.         ld      c,17            ;get next entry
  45. main3:
  46.         ld      de,fcb
  47.         call    bdos
  48.         or      a               ;does file exist?
  49.         jp      p,found         ;yes
  50.         pop     bc
  51.         ld      bc,-1           ;no, file doesn't exist
  52.         jr      basretn         ;return to caller
  53.  
  54. found:  
  55. ;                       move entry to basic string
  56.         ld      hl,buffer       ;point to fle buffer
  57.         rlca                    ;multiply A by 32
  58.         rlca
  59.         rlca
  60.         rlca
  61.         rlca
  62.         ld      c,a
  63.         ld      b,0
  64.         add     hl,bc           ;point to entry in buffer
  65.         ld      de,7f00h        ;move to table next entry
  66.         ld      a,0e5h          ;check if file deleted
  67.         cp      (hl)
  68.         jr      z,main2         ;yes, try next entry
  69.         inc     hl              ;skip user byte
  70.         ld      b,11
  71. stack1:
  72.         ld      a,(hl)
  73.         ld      (de),a
  74.         inc     hl
  75.         dec     de
  76.         djnz    stack1
  77.  
  78.         pop     bc
  79.         ld      bc,0            ;valid file found
  80.  
  81. basretn:
  82.         pop     hl
  83.         pop     de
  84.         pop     af
  85.         ret
  86.  
  87. ftype   equ     5ch+1+8
  88. fcb     equ     5ch
  89. bdos    equ     5
  90. buffer  equ     $
  91.         end
  92.  
  93.  111. A3: DIRECTRY.MAC    4K :#06 #╦\(≡╔     └ÜòÖ=ÜrÜ¡ÜÆÆ▐æ°Ä⌡Ä≈