Files
Digital-Research-Source-Code/CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/clib/salloc.s
Sepp J Morris 31738079c4 Upload
Digital Research
2020-11-06 18:50:37 +01:00

33 lines
757 B
ArmAsm

*
* _salloc function.
*
* This function allocates a data area on the stack.
*
* Calling Sequence:
*
* adr = _salloc(size);
*
* Returns the address of the area allocated.
*
* Pulled out of 'w.s' 1/84 whf
* Fixed 2/84 sw
*
.globl __salloc
__salloc:
move.l (sp)+,a0 * Save return address
clr.l d0 * Zap d0 high word
move.w (sp)+,d0 * Get arg (word size)
addq.l #1+4,d0 * Round
bclr.l #0,d0 * up to word
move.l __break,a1 * a1 -> break area
lea $100(a1),a1 * Add chicken factor
lea 0(a1,d0.l),a1 * And size
cmpa.l a1,sp * OK?
bhi ok *sw Overflow, die
jmp __sovf *sw Jump to error in s.o
ok: sub.l d0,sp * allocate
lea 4(sp),a1 * a1 -> area start
move.l a1,d0 * set return code
jmp (a0) * and "return"
*