MM_ALCHP/MEM_ACHP - Vector $C0
This vector allocates memory on the common heap. It should only be called in supervisor mode. The vector call is atomic.
Call Parameters | Return Parameters | ||
---|---|---|---|
D0.L | Unused | D0.L | Error code. |
D1.L | Number of bytes required. | D1.L | Number of bytes allocated. |
D2.L | Unused | D2.L | Corrupted. |
D3.L | Unused | D3.L | Corrupted. |
A0.L | Unused | A0.L | Address of allocated area. |
A1.L | Unused | A1.L | Corrupted. |
A2.L | Unused | A2.L | Corrupted. |
A3.L | Unused | A3.L | Corrupted. |
A6.L | System variables address | A6.L | Preserved. |
Errors
ERR_OM | Out of memory. |
Notes
- All registers not shown above are not used on entry and are preserved on exit.
- Must be called in supervisor mode only.
- Mainly used in device driver 'open' routines to allocate space for channel definition blocks and so on.
- The area allocated is filled with $00. (Zeroised.)
- This vector call is atomic.
Example
The example below shows the use of this vector to allocate an area of 16 bytes for use by the routine.
Get_hp move.w MM_ALCHP,A2 ; MM_ALCHP vector address. moveq #16,d1 ; Number of bytes required. ; Assume A6 is correct already jsr (a2) ; Make the call bne.s Error_handler ; Oops! All_ok cmpi.b #16,d1 ; Did we get 16 bytes? bne.s Error_handler ; No, oops! Got_hp ... ; Do something here.