home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / assembler / thesource / volume2 / source / system / asmmacros.lha / Open.i < prev    next >
Encoding:
Text File  |  1990-11-16  |  1.9 KB  |  66 lines

  1.      NOLIST
  2. Open        MACRO              ; 14 Jan 88
  3. *------------------------------; Start of Open macro.
  4.      NOLIST
  5.      IFEQ NARG-4               ; If new, read, or r/w is specified, make D2
  6.                                ;  indicate the accessMode accordingly.
  7.      IFC '\4','new'
  8.      LIST
  9.      MOVE.L #1006,D2           ; Make D2 indicate "new" access mode.
  10.      NOLIST
  11.      ENDC
  12.      IFC '\4','read'
  13.      LIST
  14.      MOVE.L #1005,D2           ; Make D2 indicate "read" access mode.
  15.      NOLIST
  16.      ENDC
  17.      IFC '\4','r/w'
  18.      LIST
  19.      MOVE.L #1004,D2           ; Make D2 indicate "r/w" access mode.
  20.      NOLIST
  21.      ENDC
  22.      ENDC
  23.      IFEQ NARG-3               ; If new, read, or r/w is not specified,
  24.      LIST
  25.      MOVE.L #1005,D2           ; Make D2 indicate the old/new accessMode
  26.      TST D0                    ;  based on D0.
  27.      BNE 5$
  28.      SUBQ #1,D2
  29. 5$:
  30.      NOLIST
  31.      ENDC
  32.      IFC '\1','I'              ; If <PointerToFileName> is specified, then
  33.      LIST
  34.                                ; Put <PointerToFileName> in D1.
  35.      MOVE.L #\2,D1
  36.      NOLIST
  37.      ENDC
  38.      IFC '\1','D'              ; If <filename> is specified, then
  39.      LIST
  40.                                ; Make D1 point to the file name string.
  41.      MOVE.L #\2.str,D1
  42.      NOLIST
  43.      IFND \2.str               ; Unless it was previously defined,
  44.      LIST
  45.      SECTION DataSection,DATA  ; The ASCII <filename> string goes here.
  46. \2.str:
  47.      DC.B '\2',0
  48.      CNOP 0,2
  49.      SECTION   "",CODE
  50.      NOLIST
  51.      ENDC
  52.      ENDC
  53.      LIST
  54.      CallLib Open,dos          ; Call Open to open <filename>.
  55.                                ; Put the file handle at <FileHandleName>.
  56.      MOVE.L D0,\3
  57.      SECTION   BSS_Section,BSS
  58.      CNOP 0,2
  59. \3:
  60.      DS.L 1                    ; This is the location of <FileHandleName>.
  61.      SECTION   "",CODE
  62.      TST.L D0                  ; Make the zero flag indicate failure.
  63. *------------------------------; End of Open macro.
  64.      ENDM
  65.      LIST
  66.