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 / Read.i < prev    next >
Encoding:
Text File  |  1990-11-16  |  2.2 KB  |  75 lines

  1.      NOLIST
  2. Read        MACRO              ; 14 Jan 88
  3. *------------------------------; Start of Read macro.
  4.                                ; Put the file handle in D1.
  5.      MOVE.L \1,D1
  6.                                ; Make D2 point to the start of the buffer.
  7.      NOLIST
  8.      IFC '\2','D'
  9.      LIST
  10.      MOVE.L #\3,D2
  11.      NOLIST
  12.      ENDC
  13.      IFC '\2','I'
  14.      LIST
  15.      MOVE.L \3.Adr,D2
  16.      NOLIST
  17.      ENDC
  18.      IFEQ NARG-3               ; If there is no fourth argument, and
  19.      IFC '\2','D'              ;  <BufferStartAddr> is specified, then
  20.      LIST
  21.                                ; Calculate the buffer size as
  22.                                ;  <BufferStartAddr>End minus
  23.                                ;  <BufferStartAddr>. Put it in D3.
  24.      MOVE.L #\3End-\3,D3
  25.      NOLIST
  26.      ENDC
  27.      IFC '\2','I'              ; If <MemBlockName> is specified, then
  28.      LIST
  29.                                ; Get the buffer size from <MemBlockName>.Size
  30.      MOVE.L \3.Size,D3
  31.      NOLIST
  32.      ENDC
  33.      ENDC
  34.      IFEQ NARG-4               ; If the fourth argument exists,
  35.      IFNC '\4','D3'            ;  and it is not "D3", then
  36.      LIST
  37.                                ; Use the buffer size of the fourth argument.
  38.      MOVE.L #\4,D3
  39.      NOLIST
  40.      ENDC
  41.      ENDC
  42.      LIST
  43.      CallLib Read,dos          ; Call Read.
  44.      NOLIST
  45.      IFC '\2','D'              ; If <BufferStartAddr> is specified, then
  46.      LIST
  47.                                ; Store the actual length read at
  48.                                ;  <BufferStartAddr>.Len .
  49.      MOVE.L D0,\3.Len
  50.      NOLIST
  51.      ENDC
  52.      IFC '\2','I'              ; If <MemBlockName> is specified, then
  53.      LIST
  54.                                ; Store the actual length read at
  55.                                ;  <MemBlockName>.Len .
  56.      MOVE.L D0,\3.Len
  57.      NOLIST
  58.      ENDC
  59.      NOLIST
  60.      IFND \3.Len               ; If <BufferStartAddr>.Len or
  61.                                ;  <MemBlockName>.Len is not already defined,
  62.      LIST
  63.      SECTION BSS_Section,BSS   ; Define \3.Len .
  64.      CNOP 0,2
  65. \3.Len:
  66.      DS.L 1
  67.      SECTION   "",CODE
  68.      NOLIST
  69.      ENDC
  70.      LIST
  71.      CMPI.L #-1,D0             ; Make the zero flag indicate failure.
  72. *------------------------------; End of Read macro.
  73.      ENDM
  74.      LIST
  75.