6437
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 1 /* `alloca' standard 4.2 subroutine for 68000's and 16000's and others.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 2 Also has _setjmp and _longjmp for pyramids.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 3 Copyright (C) 1985, 1986, 1988 Free Software Foundation, Inc.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 4
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 5 This program is free software; you can redistribute it and/or modify it
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 6 under the terms of the GNU General Public License as published by the
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 7 Free Software Foundation; either version 2, or (at your option) any
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 8 later version.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 9
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 10 This program is distributed in the hope that it will be useful,
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 13 GNU General Public License for more details.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 14
14414
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 15 You should have received a copy of the GNU General Public License along
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 16 with this program; if not, write to the Free Software Foundation, Inc.,
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 17 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
6437
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 18
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 19 /* Both 68000 systems I have run this on have had broken versions of alloca.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 20 Also, I am told that non-berkeley systems do not have it at all.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 21 So replace whatever system-provided alloca there may be
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 22 on all 68000 systems. */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 23
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 24 #define NOT_C_CODE
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 25 #ifdef emacs
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 26 #include <config.h>
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 27 #else
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 28 #include "config.h"
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 29 #endif
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 30
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 31 #ifndef HAVE_ALLOCA /* define this to use system's alloca */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 32
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 33 #ifndef hp9000s300
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 34 #ifndef m68k
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 35 #ifndef m68000
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 36 #ifndef WICAT
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 37 #ifndef ns32000
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 38 #ifndef ns16000
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 39 #ifndef sequent
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 40 #ifndef pyramid
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 41 #ifndef ATT3B5
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 42 #ifndef XENIX
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 43 you
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 44 lose!!
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 45 #endif /* XENIX */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 46 #endif /* ATT3B5 */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 47 #endif /* pyramid */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 48 #endif /* sequent */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 49 #endif /* ns16000 */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 50 #endif /* ns32000 */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 51 #endif /* WICAT */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 52 #endif /* m68000 */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 53 #endif /* m68k */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 54 #endif /* hp9000s300 */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 55
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 56
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 57 #ifdef hp9000s300
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 58 #ifdef OLD_HP_ASSEMBLER
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 59 data
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 60 text
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 61 globl _alloca
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 62 _alloca
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 63 move.l (sp)+,a0 ; pop return addr from top of stack
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 64 move.l (sp)+,d0 ; pop size in bytes from top of stack
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 65 add.l #ROUND,d0 ; round size up to long word
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 66 and.l #MASK,d0 ; mask out lower two bits of size
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 67 sub.l d0,sp ; allocate by moving stack pointer
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 68 tst.b PROBE(sp) ; stack probe to allocate pages
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 69 move.l sp,d0 ; return pointer
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 70 add.l #-4,sp ; new top of stack
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 71 jmp (a0) ; not a normal return
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 72 MASK equ -4 ; Longword alignment
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 73 ROUND equ 3 ; ditto
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 74 PROBE equ -128 ; safety buffer for C compiler scratch
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 75 data
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 76 #else /* new hp assembler syntax */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 77 /*
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 78 The new compiler does "move.m <registers> (%sp)" to save registers,
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 79 so we must copy the saved registers when we mung the sp.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 80 The old compiler did "move.m <register> <offset>(%a6)", which
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 81 gave us no trouble
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 82 */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 83 text
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 84 set PROBE,-128 # safety for C frame temporaries
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 85 set MAXREG,22 # d2-d7, a2-a5, fp2-fp7 may have been saved
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 86 global _alloca
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 87 _alloca:
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 88 mov.l (%sp)+,%a0 # return address
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 89 mov.l (%sp)+,%d0 # number of bytes to allocate
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 90 mov.l %sp,%a1 # save old sp for register copy
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 91 mov.l %sp,%d1 # compute new sp
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 92 sub.l %d0,%d1 # space requested
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 93 and.l &-4,%d1 # round down to longword
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 94 sub.l &MAXREG*4,%d1 # space for saving registers
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 95 mov.l %d1,%sp # save new value of sp
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 96 tst.b PROBE(%sp) # create pages (sigh)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 97 mov.l %a2,%d1 # save reg a2
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 98 mov.l %sp,%a2
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 99 move.w &MAXREG-1,%d0
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 100 copy_regs_loop: /* save caller's saved registers */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 101 mov.l (%a1)+,(%a2)+
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 102 dbra %d0,copy_regs_loop
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 103 mov.l %a2,%d0 # return value
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 104 mov.l %d1,%a2 # restore a2
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 105 add.l &-4,%sp # adjust tos
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 106 jmp (%a0) # rts
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 107 #endif /* new hp assembler */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 108 #else
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 109 #ifdef m68k /* SGS assembler totally different */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 110 file "alloca.s"
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 111 global alloca
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 112 alloca:
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 113 #ifdef MOTOROLA_DELTA
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 114 /* slightly modified version of alloca to motorola sysV/68 pcc - based
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 115 compiler.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 116 this compiler saves used registers relative to %sp instead of %fp.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 117 alright, just make new copy of saved register set whenever we allocate
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 118 new space from stack..
6815
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 119 this is true at last until SVR3V7 . bug has reported to Motorola. */
6437
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 120 set MAXREG,10 # max no of registers to save (d2-d7, a2-a5)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 121 mov.l (%sp)+,%a1 # pop return addr from top of stack
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 122 mov.l (%sp)+,%d0 # pop size in bytes from top of stack
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 123 mov.l %sp,%a0 # save stack pointer for register copy
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 124 addq.l &3,%d0 # round size up to long word
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 125 andi.l &-4,%d0 # mask out lower two bits of size
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 126 mov.l %sp,%d1 # compute new value of sp to d1
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 127 sub.l %d0,%d1 # pseudo-allocate by moving stack pointer
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 128 sub.l &MAXREG*4,%d1 # allocate more space for saved regs.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 129 mov.l %d1,%sp # actual allocation.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 130 move.w &MAXREG-1,%d0 # d0 counts saved regs.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 131 mov.l %a2,%d1 # preserve a2.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 132 mov.l %sp,%a2 # make pointer to new reg save area.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 133 copy_regs_loop: # copy stuff from old save area.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 134 mov.l (%a0)+,(%a2)+ # save saved register
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 135 dbra %d0,copy_regs_loop
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 136 mov.l %a2,%a0 # now a2 is start of allocated space.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 137 mov.l %a2,%d0 # return it in both a0 and d0 to play safe.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 138 mov.l %d1,%a2 # restore a2.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 139 subq.l &4,%sp # new top of stack
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 140 jmp (%a1) # far below normal return
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 141 #else /* not MOTOROLA_DELTA */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 142 mov.l (%sp)+,%a1 # pop return addr from top of stack
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 143 mov.l (%sp)+,%d0 # pop size in bytes from top of stack
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 144 add.l &R%1,%d0 # round size up to long word
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 145 and.l &-4,%d0 # mask out lower two bits of size
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 146 sub.l %d0,%sp # allocate by moving stack pointer
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 147 tst.b P%1(%sp) # stack probe to allocate pages
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 148 mov.l %sp,%a0 # return pointer as pointer
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 149 mov.l %sp,%d0 # return pointer as int to avoid disaster
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 150 add.l &-4,%sp # new top of stack
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 151 jmp (%a1) # not a normal return
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 152 set S%1,64 # safety factor for C compiler scratch
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 153 set R%1,3+S%1 # add to size for rounding
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 154 set P%1,-132 # probe this far below current top of stack
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 155 #endif /* not MOTOROLA_DELTA */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 156
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 157 #else /* not m68k */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 158
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 159 #ifdef m68000
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 160
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 161 #ifdef WICAT
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 162 /*
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 163 * Registers are saved after the corresponding link so we have to explicitly
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 164 * move them to the top of the stack where they are expected to be.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 165 * Since we do not know how many registers were saved in the calling function
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 166 * we must assume the maximum possible (d2-d7,a2-a5). Hence, we end up
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 167 * wasting some space on the stack.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 168 *
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 169 * The large probe (tst.b) attempts to make up for the fact that we have
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 170 * potentially used up the space that the caller probed for its own needs.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 171 */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 172 .procss m0
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 173 .config "68000 1"
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 174 .module _alloca
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 175 MAXREG: .const 10
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 176 .sect text
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 177 .global _alloca
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 178 _alloca:
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 179 move.l (sp)+,a1 ; pop return address
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 180 move.l (sp)+,d0 ; pop allocation size
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 181 move.l sp,d1 ; get current SP value
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 182 sub.l d0,d1 ; adjust to reflect required size...
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 183 sub.l #MAXREG*4,d1 ; ...and space needed for registers
13691
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 184 and.l #-4,d1 ; backup to longword boundary
6437
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 185 move.l sp,a0 ; save old SP value for register copy
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 186 move.l d1,sp ; set the new SP value
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 187 tst.b -4096(sp) ; grab an extra page (to cover caller)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 188 move.l a2,d1 ; save callers register
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 189 move.l sp,a2
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 190 move.w #MAXREG-1,d0 ; # of longwords to copy
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 191 loop: move.l (a0)+,(a2)+ ; copy registers...
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 192 dbra d0,loop ; ...til there are no more
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 193 move.l a2,d0 ; end of register area is addr for new space
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 194 move.l d1,a2 ; restore saved a2.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 195 addq.l #4,sp ; caller will increment sp by 4 after return.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 196 move.l d0,a0 ; return value in both a0 and d0.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 197 jmp (a1)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 198 .end _alloca
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 199 #else
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 200
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 201 /* Some systems want the _, some do not. Win with both kinds. */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 202 .globl _alloca
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 203 _alloca:
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 204 .globl alloca
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 205 alloca:
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 206 movl sp@+,a0
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 207 movl a7,d0
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 208 subl sp@,d0
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 209 andl #~3,d0
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 210 movl d0,sp
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 211 tstb sp@(0) /* Make stack pages exist */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 212 /* Needed on certain systems
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 213 that lack true demand paging */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 214 addql #4,d0
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 215 jmp a0@
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 216
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 217 #endif /* not WICAT */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 218 #endif /* m68000 */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 219 #endif /* not m68k */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 220 #endif /* not hp9000s300 */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 221
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 222 #if defined (ns16000) || defined (ns32000)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 223
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 224 .text
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 225 .align 2
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 226 /* Some systems want the _, some do not. Win with both kinds. */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 227 .globl _alloca
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 228 _alloca:
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 229 .globl alloca
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 230 alloca:
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 231
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 232 /* Two different assembler syntaxes are used for the same code
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 233 on different systems. */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 234
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 235 #ifdef sequent
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 236 #define IM
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 237 #define REGISTER(x) x
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 238 #else
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 239 #ifdef NS5 /* ns SysV assembler */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 240 #define IM $
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 241 #define REGISTER(x) x
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 242 #else
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 243 #define IM $
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 244 #define REGISTER(x) 0(x)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 245 #endif
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 246 #endif
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 247
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 248 /*
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 249 * The ns16000 is a little more difficult, need to copy regs.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 250 * Also the code assumes direct linkage call sequence (no mod table crap).
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 251 * We have to copy registers, and therefore waste 32 bytes.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 252 *
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 253 * Stack layout:
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 254 * new sp -> junk
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 255 * registers (copy)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 256 * r0 -> new data
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 257 * | (orig retval)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 258 * | (orig arg)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 259 * old sp -> regs (orig)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 260 * local data
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 261 * fp -> old fp
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 262 */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 263
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 264 movd tos,r1 /* pop return addr */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 265 negd tos,r0 /* pop amount to allocate */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 266 sprd sp,r2
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 267 addd r2,r0
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 268 bicb IM/**/3,r0 /* 4-byte align */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 269 lprd sp,r0
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 270 adjspb IM/**/36 /* space for regs, +4 for caller to pop */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 271 movmd 0(r2),4(sp),IM/**/4 /* copy regs */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 272 movmd 0x10(r2),0x14(sp),IM/**/4
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 273 jump REGISTER(r1) /* funky return */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 274 #endif /* ns16000 or ns32000 */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 275
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 276 #ifdef pyramid
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 277
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 278 .globl _alloca
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 279
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 280 _alloca: addw $3,pr0 # add 3 (dec) to first argument
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 281 bicw $3,pr0 # then clear its last 2 bits
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 282 subw pr0,sp # subtract from SP the val in PR0
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 283 andw $-32,sp # keep sp aligned on multiple of 32.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 284 movw sp,pr0 # ret. current SP
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 285 ret
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 286
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 287 #ifdef PYRAMID_OLD /* This isn't needed in system version 4. */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 288 .globl __longjmp
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 289 .globl _longjmp
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 290 .globl __setjmp
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 291 .globl _setjmp
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 292
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 293 __longjmp: jump _longjmp
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 294 __setjmp: jump _setjmp
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 295 #endif
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 296
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 297 #endif /* pyramid */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 298
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 299 #ifdef ATT3B5
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 300
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 301 .align 4
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 302 .globl alloca
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 303
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 304 alloca:
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 305 movw %ap, %r8
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 306 subw2 $9*4, %r8
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 307 movw 0(%r8), %r1 /* pc */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 308 movw 4(%r8), %fp
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 309 movw 8(%r8), %sp
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 310 addw2 %r0, %sp /* make room */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 311 movw %sp, %r0 /* return value */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 312 jmp (%r1) /* continue... */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 313
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 314 #endif /* ATT3B5 */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 315
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 316 #ifdef XENIX
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 317
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 318 .386
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 319
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 320 _TEXT segment dword use32 public 'CODE'
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 321 assume cs:_TEXT
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 322
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 323 ;-------------------------------------------------------------------------
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 324
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 325 public _alloca
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 326 _alloca proc near
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 327
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 328 pop ecx ; return address
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 329 pop eax ; amount to alloc
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 330 add eax,3 ; round it to 32-bit boundary
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 331 and al,11111100B ;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 332 mov edx,esp ; current sp in edx
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 333 sub edx,eax ; lower the stack
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 334 xchg esp,edx ; start of allocation in esp, old sp in edx
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 335 mov eax,esp ; return ptr to base in eax
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 336 push [edx+8] ; save poss. stored reg. values (esi,edi,ebx)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 337 push [edx+4] ; on lowered stack
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 338 push [edx] ;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 339 sub esp,4 ; allow for 'add esp, 4'
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 340 jmp ecx ; jump to return address
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 341
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 342 _alloca endp
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 343
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 344 _TEXT ends
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 345
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 346 end
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 347
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 348 #endif /* XENIX */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 349
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 350 #endif /* not HAVE_ALLOCA */