home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 10: Diskmags / nf_archive_10.iso / MAGS / ST_USER / 1990 / USERMR90.MSA / LISTINGS_DIRLIST.S < prev    next >
Text File  |  1990-01-07  |  3KB  |  81 lines

  1. ***************************************
  2. *       Display a directory listing   *
  3. *       By R.A.Waddilove              *
  4. *       (c) Atari ST User             *
  5. ***************************************
  6.  
  7. * Get the current DTA pointer and save it
  8.         MOVE #47,-(A7)          f_getdta - get old DTA
  9.         TRAP #1                 GEMDOS
  10.         ADDQ.L #2,A7            tidy stack
  11.         LEA olddta(PC),A0       A0 points to olddta
  12.         MOVE.L D0,(A0)          save old DTA pointer
  13.  
  14. * Set the DTA pointer to my buffer
  15.         PEA dta(PC)             set my DTA buffer
  16.         MOVE #26,-(A7)          f_setdta
  17.         TRAP #1                 GEMDOS
  18.         ADDQ.L #6,A7            tidy stack
  19.  
  20. * Read the first file in the directory
  21.         MOVE #0,-(A7)           normal read/write files
  22.         PEA fname(PC)           filespec - "*.*"
  23.         MOVE #78,-(A7)          f_sfirst
  24.         TRAP #1                 GEMDOS
  25.         ADDQ.L #8,A7            tidy stack
  26.         BSR print               print filename
  27.  
  28. * Repeatedly read the next one until no more left
  29. loop    MOVE #79,-(A7)          f_snext - get next file
  30.         TRAP #1                 GEMDOS
  31.         ADDQ.L #2,A7            tidy stack
  32.         TST D0                  D0<>0 means no more files
  33.         BNE exit                exit if no more
  34.         BSR print               print filename
  35.         BRA loop                loop round again
  36.  
  37. * Restore the original DTA pointer
  38. exit    MOVE.L dta(PC),-(A7)    restore old DTA pointer
  39.         MOVE #26,-(A7)          f_setdta
  40.         TRAP #1                 GEMDOS
  41.         ADDQ.L #6,A7            tidy stack
  42.  
  43. * Wait for a key to be pressed
  44.         MOVE #8,-(A7)           wait for keypress
  45.         TRAP #1                 GEMDOS
  46.         ADDQ.L #2,A7            tidy stack
  47.  
  48. * Return to the desktop
  49.         CLR -(A7)               p_term0 - exit to desktop
  50.         TRAP #1                 GEMDOS
  51.  
  52. ***************************************
  53. * Subroutine to print filename in DTA *
  54. *     buffer starting at byte 30      *
  55. ***************************************
  56. print   LEA dta(PC),A6          A6 --> my DTA buffer
  57.         ADDA.L #30,A6           A6 --> to filename
  58.         CLR D7
  59. ploop   MOVE.B (A6)+,D7         get character
  60.         BEQ crlf                0 = end of name marker
  61.         MOVE D7,-(A7)           print it
  62.         MOVE #2,-(A7)           c_conout
  63.         TRAP #1                 GEMDOS
  64.         ADDQ.L #4,A7            tidy stack
  65.         BRA ploop               another letter?
  66. crlf    MOVE #13,-(A7)          print CR
  67.         MOVE #2,-(A7)
  68.         TRAP #1
  69.         ADDQ.L #4,A7
  70.         MOVE #10,-(A7)          print LF
  71.         MOVE #2,-(A7)
  72.         TRAP #1
  73.         ADDQ.L #4,A7
  74.         RTS
  75.  
  76. olddta  DC.L 0                  store old DTA pointer
  77. dta     DS.B 46                 DTA buffer
  78. fname   DC.B '*.*',0            filespec to search for
  79.         EVEN
  80.  
  81.