.title sbreak Allocate memory from operating system .ident "V02.00" ;+ ; Index Allocate memory from operating system ; ; Usage ; ; Internal ; ; char * ; sbreak(amount); ; int amount; ; ; Description ; ; sbreak() allocates the indicated amount of memory from ; the operating system. The allocation is permanent. ; ; Diagnostics ; ; NULL is returned if the memory requested is not available. ; There is no "shortened" return. ; ; sbreak() does not modify its argument. ; ;- ; Edit history ; V02.00 19-Oct-82 TTC Rework of old CS library ; .mcall GPRT$S, EXTK$S .psect c$code sbreak:: jsr r5,csv$ ; Link environments 10$: mov C$PMTR+0(r5),r1 ; Bytes needed inc r1 ; Round it up bic #1,r1 ; to a word value mov $$mtop,r0 ; Current top of free memory mov r0,r2 ; Scratch add r1,r2 ; New top, if successful blo fail ; Die if > 177777 (on vms) cmp r2,$$mend ; Is there room? blo gotcha ; Good ; ; No room just now, get some ; mov r1,r2 ; Save size for later bne 15$ ; If increment is 0 inc r1 ; force a 1 click expansion. 15$: add #377,r1 ; Get grow increment clrb r1 ; Round to next 1/4 K boundary mov r1,r3 ; Save it for now ror r1 ; Convert to Core clicks ror r1 ; ror r1 ; ror r1 ; ror r1 ; ror r1 ; EXTK$S r1 ; Get memory bcs fail ; No memory left mov $$mtop,r0 ; Get base of free memory add r0,r3 ; Get new end of free memory mov r3,$$mend ; And save it add r0,r2 ; Get new free memory start gotcha: mov r2,$$mtop ; save free memory start exit: jmp cret$ ; And exit fail: clr r0 ; Couldn't get memory br exit ; so die already .end