Mercurial > hg > Members > kono > nitros9-code
view 3rdparty/packages/cc/sources/mem.a @ 1942:b41df77588b0
printer is now scbbp
sio is now scbbt
All references changed in various files
author | boisy |
---|---|
date | Sat, 26 Nov 2005 22:51:50 +0000 |
parents | 0198655f2552 |
children |
line wrap: on
line source
* * Memory request system calls * use ..../defs/os9defs.a psect mem_a,0,0,3,0,0 vsect spare rmb 2 endsect * sbrk(size) get memory from system sbrk: ldd memend,y get hi bound pshs d save it ldd 4,s get the size required cmpd spare,y any spare left? blo sbrk20 * have to get some from the system addd memend,y add current size pshs y save data pointer subd 0,s adjust for base os9 F$MEM re-size memory tfr y,d save high bound puls y restore data ptr bcc sbrk10 bra if no error ldd #-1 return error code leas 2,s junk scratch rts sbrk10 std memend,y save new memory address addd spare,y add in spare bytes subd 0,s less old base std spare,y is new spare value * now spare is big enough sbrk20 leas 2,s junk scratch ldd spare,y get spare count pshs d subd 4,s less size std spare,y updated value ldd memend,y get hi bound subd ,s++ base of free memory pshs d save clra ldx 0,s sbrk30 sta ,x+ clear out the new memory cmpx memend,y blo sbrk30 puls d,pc * ibrk(size) get memory within data allocation ibrk: ldd 2,s get the size required addd _mtop,y add in the current top bcs ibrk20 if it wraps round - error cmpd _stbot,y overlap stack? bhs ibrk20 yes - error pshs d no - save top ldx _mtop,y reset to bottom clra sbloop cmpx 0,s reached the end? bhs ibrk10 yes - done sta ,x+ no - clear and bump bra sbloop ibrk10 ldd _mtop,y return value puls x restore new top stx _mtop,y and save for next time rts ibrk20 ldd #-1 return memory full rts endsect