;File: Macro.inc ; ;basepage equates : some constants; indicating the positions ;of items of information in the program header (basepage). ; ltpa equ 0 ;Low TPA address htpa equ 4 ;High TPA address lcode equ 8 ;Code segment start codelen equ 12 ;Code segment length ldata equ 16 ;Data segment start datalen equ 20 ;Data segment length lbss equ 24 ;Bss segment start bsslen equ 28 ;Bss segment length freelen equ 32 ;free segment length resvd equ 36 ;Reserved fcb2 equ 56 ;2nd parsed fcb fcb1 equ 92 ;1st parsed fcb command equ 128 ;Command tail ;INITAPP: ;======== ;Initialising a program. The program keeps a few kilobytes for the ;stack. The rest is returned to the operating system. ;The stack pointer is set to the top of the reserved memory location. ; ;Application: INITAPP ; INITAPP stacksize ;Return status: d0 contains error status mshrink call .MACRO INITAPP stack set 32*1024 ;32k default stacksize .IFNE \# ;if different stacksize specified stack set \1 ;use that size instead of default .ENDC movea.l sp,a5 ;fetch start address basepage from stack movea.l 4(a5),a5 move.l codelen(a5),d0 ;apps size = codelength add.l datalen(a5),d0 ; +datalength add.l bsslen(a5),d0 ; +bsslength addi.l #stack+256,d0 ; +space for stack move.l d0,d1 ;calculate top limit for memory block andi.l #-2,d1 ;and justify to word boundary (even address) movea.l d1,sp ;SP starts at top address of stack area Mshrink a5,d0 ;GEMDOS function: return unused memory .ENDM