Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
titleRST 20H, DEFB $4E
IN:
     A = memory mask arguments (several arguments OR'ed together):

          Destination segment (allocated memory addressed for segment):
          MM_S0 ($00), segment 0
          MM_S1 ($40), segment 1
          MM_S2 ($80), segment 2
          MM_S3 ($C0), segment 3

          Source of memory (to be allocated):
          MM_FIX ($02), fixed workspace (not subject to swapping)
          MM_SLT ($04), explicit slot usage
          MM_EXC ($10), exclusive use of bank
          MM_MUL ($20), use multiple banks

     B = 0, always
     C = bank or slot number if MM_SLT = 1 and MM_MUL = 0
		  MC_AS ($00), find an exclusive bank in any slot
          MC_CI ($10), internal memory
          MC_C1 ($01), card 1
          MC_C2 ($02), card 2
          MC_C3 ($03), card 3
		  or ($20-$ff), explicit bank

OUT, if call successful:
     Fc = 0
     IX = memory pool handle
OUT, if call failed:
     Fc = 1
     A = error code:
          RC_NA ($06), handle not available
          RC_ROOM ($07), no room

Registers changed after return:
     A.FBCDEHL/..IY same
     .F......./IX.. different 

Notes

MM_EXC and MC_CI use the same argument bit. MM_EXC isn't implemented.

If MM_SLT is specified, C holds bank number ($20-$ff) or slot (0-3).

If only destination segment is specified, you get memory from bank with most free space. Pool is limited to one bank.

OS_Mop doesn't allocate any memory, so even the very first OS_Mal can fail.

If you specified MM_MUL, you can force slot 1-3 during first OS_Mal by loading A with slot number.

If you didn't specify MM_MUL, all memory allocated from that pool is guaranteed to be in same bank. Additionally, memory area returned from OS_Mal is guaranteed to be in single page.

If only the memory segment mask are specified, it is probably default'ed to MM_MULMM_FIX is probably an internal usage.

(TODO: explain setup for any slot any offset with OS_Mal / OS_Fma / OS_Axm)  is specified, memory is allocated from all the memory available (pool is not limited to one bank).

If MM_EXC is specified, memory is allocated from free banks in priority, pool is not limited to one bank (OZ 5.0 and newer).

If MM_FIX is specified, only memory not subject to swap is allocated.

If MM_SLT is specified, C holds bank number ($20-$FF) or slot.

If you specified MM_MUL, you can force slot 1-3 during first OS_Mal by loading A with slot number.

Related calls

OS_Bix, Bind in extended address
OS_Box, restore bindings after OS_Bix
OS_Fc, select fast code (fast bank switching)
OS_Mal, allocate memory
OS_Mcl, close memory (free memory pool)
OS_Mfr, free (previously allocated block) memory
OS_Mgb, get current bank binding in segment
OS_Mpb, set new bank binding in segment