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 / AllocMem.i next >
Encoding:
Text File  |  1990-11-16  |  1.7 KB  |  64 lines

  1.      NOLIST
  2. AllocMem    MACRO              ; 15 Jan 88
  3. *------------------------------; Start of AllocMem macro.
  4.      NOLIST
  5.      IFC "\2","D"              ; If \3 uses direct mode, then.
  6.      LIST
  7.                                ; Put the block size in D0.
  8.      MOVE.L #\3,D0
  9.      NOLIST
  10.      ENDC
  11.      IFC "\2","I"              ; If \3 uses indirect mode, then.
  12.      LIST
  13.                                ; Put the block size in D0.
  14.      MOVE.L \3,D0
  15.      NOLIST
  16.      ENDC
  17.      LIST
  18.                                ; Save the block size at <MemBlockName>.Size
  19.      MOVE.L D0,\1.Size
  20.      NOLIST
  21.      IFNE NARG-4               ; If \4 is not given, then
  22.      LIST
  23.      CLR.L D1                  ; Accept any memory.
  24.      NOLIST
  25.      ENDC
  26.      IFEQ NARG-4               ; If \4 is given, then
  27. PUBLIC SET 1
  28. CHIP   SET 2
  29. CLEAR  SET $10000
  30.      LIST
  31.                                ; Set the appropriate bits in D1.
  32.      MOVE.L #\4,D1
  33.      NOLIST
  34.      ENDC
  35.      LIST
  36.      CallLib AllocMem,exec     ; Call AllocMem.
  37.                                ; Save the address of the memory block at
  38.                                ;  <MemBlockName>.Adr
  39.      MOVE.L D0,\1.Adr
  40.      NOLIST
  41.      IFND \1.Adr
  42.      LIST
  43.      SECTION BSS_Section,BSS
  44.      CNOP 0,2
  45. \1.Adr:
  46.      DS.L 1                    ; This is the location of <MemBlockName>.Adr
  47.      SECTION   "",CODE
  48.      NOLIST
  49.      ENDC
  50.      IFND \1.Size
  51.      LIST
  52.      SECTION BSS_Section,BSS
  53.      CNOP 0,2
  54. \1.Size:
  55.      DS.L 1                    ; This is the location of <MemBlockName>.Size
  56.      SECTION   "",CODE
  57.      NOLIST
  58.      ENDC
  59.      LIST
  60.      TST.L D0                  ; Make the zero flag indicate failure.
  61. *------------------------------; End of AllocMem macro.
  62.      ENDM
  63.      LIST
  64.