home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol125 / systest2.mqc / SYSTEST2.MAC
Encoding:
Text File  |  1985-02-10  |  3.8 KB  |  152 lines

  1. ;
  2. ;  PROGRAM:  SYSTEST2
  3. ;  AUTHOR:  Richard Conn
  4. ;  PURPOSE:  To demonstrate the SYSLIB routines for directory manipulation.
  5. ;  NOTE:  This program loads the disk directory and selects and prints files
  6. ;        which are non-system in the user area given by the user; it
  7. ;        may be used to test and compare DIRF and DIRFS
  8. ;
  9.  
  10. ;
  11. ;  Externals
  12. ;
  13.     ext    bbline    ; Input Line Editor
  14.     ext    eval10    ; String to Binary Conversion
  15.     ext    dirf    ; Fast Directory Load/Select/Alphabetize/Pack
  16.     ext    dirfs    ; DIRF with File Sizing
  17.     ext    print    ; Print String
  18.     ext    cin    ; Char in
  19.     ext    caps    ; Capitalize
  20.     ext    cout    ; Char out
  21.     ext    crlf    ; New Line
  22.     ext    retud    ; Return User and Disk
  23.     ext    codend    ; End of Code/Beginning of Buffer
  24.  
  25. ;
  26. ;  CP/M Equates
  27. ;
  28. fcb    equ    5ch    ; address of FCB loaded by CP/M
  29. cr    equ    0dh
  30. lf    equ    0ah
  31.  
  32. ;
  33. ;  I would normally look at the FCB to see if any file was specified and
  34. ;  make it wild (all ?'s) if so, but I won't do this so we can get right
  35. ;  to the problem at hand.  Hence, if the user simply types SYSTEST2 as
  36. ;  his command, the FCB will be all spaces and no file will match it.
  37. ;
  38.     lxi    h,fcb+1    ; clear FCB to ? chars
  39.     mvi    b,11    ; 11 bytes
  40.     mvi    a,'?'    ; wild card
  41. fill:
  42.     mov    m,a    ; copy into FCB
  43.     inx    h
  44.     dcr    b
  45.     jnz    fill
  46. ;
  47. ;  Main Loop
  48. ;
  49. test:
  50.     call    print
  51.     db    cr,lf,'SYSTEST2 - Demo of Directory Routines in SYSLIB',cr,lf
  52.     db    'Use DIRF (Y), DIRFS (N), or Quit (Q)? ',0
  53.     call    cin    ; get and save response
  54.     call    caps
  55.     call    cout
  56.     cpi    'Q'
  57.     rz
  58.     sta    routine
  59.     call    print
  60.     db    cr,lf,'User Number? ',0
  61.     call    bbline    ; get line from user
  62.     call    crlf    ; new line
  63.     call    eval10    ; get user number in A
  64.     mov    c,a    ; save user number
  65.     call    codend    ; get buffer address in HL
  66.     lxi    d,fcb    ; pt to fcb in DE
  67.     mov    a,c    ; user number in A
  68.     ori    10000000b    ; Mask in MSB so only Non-System files selected
  69.     mov    c,a    ; result in C
  70.     lda    routine    ; get routine selection
  71.     cpi    'Y'    ; use DIRF?
  72.     mov    a,c    ; restore flag
  73.     jnz    usefs
  74.     call    dirf    ; load dir/select files/alphabetize/pack
  75.     jmp    usef
  76. usefs:
  77.     call    dirfs
  78. usef:
  79.  
  80. ;
  81. ;  We now have a set of fixed-length records in memory, the first one being
  82. ;  pointed to by HL.  The number of records is in BC, and the length of each
  83. ;  record is 16 bytes.  These are the first 16 bytes of the FCBs of all files
  84. ;  which matched the files we were looking for.
  85. ;
  86. ;  I will now print out these file names horizontally across the screen.
  87. ;
  88.     mvi    d,0    ; set 4 count (new line every 4 entries)
  89.     mov    a,b    ; any file names?
  90.     ora    c    ; zero if so
  91.     jnz    loop    ; continue if any names
  92.     call    print
  93.     db    cr,lf,'No Files Match Ambiguous File Name',0
  94.     jmp    test    ; return to OS
  95.  
  96. ;
  97. ;  This is the main loop to print the matching file names.
  98. ;
  99. loop:
  100.     push    d    ; save 4-count in D
  101.     call    prfile    ; print file name (HL, BC not affected)
  102.     lxi    d,16    ; point to next file name by adding 16 to HL
  103.     dad    d
  104.     pop    d    ; get 4-count in D
  105.     inr    d    ; add 1 to 4-count
  106.     mov    a,d    ; check to see if it is a 4 multiple
  107.     ani    3    ; zero if so
  108.     cz    crlf    ; ... and new line
  109.     dcx    b    ; count down
  110.     mov    a,b
  111.     ora    c
  112.     jnz    loop
  113.     jmp    test    ; return to Operating System when done
  114.  
  115. ;
  116. ;  Print file name whose FCB is pointed to by HL.  Do not affect HL or BC.
  117. ;
  118. prfile:
  119.     push    b    ; save regs
  120.     push    h
  121.     inx    h    ; pt to first char of file name
  122.     mvi    b,8    ; print 8 bytes
  123.     call    prch    ; my routine to do this (not in SYSLIB)
  124.     mvi    a,'.'    ; print dot
  125.     call    cout
  126.     mvi    b,3    ; print 3 bytes
  127.     call    prch
  128.     call    print
  129.     db    '  !  ',0    ; print name separator
  130.     pop    h    ; restore regs
  131.     pop    b
  132.     ret
  133.  
  134. ;
  135. ;  Print B chars pointed to by HL
  136. ;
  137. prch:
  138.     mov    a,m    ; get char
  139.     inx    h    ; pt to next
  140.     call    cout    ; print char
  141.     dcr    b    ; count down
  142.     jnz    prch
  143.     ret
  144.  
  145. ;
  146. ;  Buffer
  147. ;
  148. routine:
  149.     ds    1    ; routine select flag
  150.  
  151.     end
  152.