comparison src/alloca.s @ 380:8626e4521993 r21-2-5

Import from CVS: tag r21-2-5
author cvs
date Mon, 13 Aug 2007 11:07:10 +0200
parents 376386a54a3c
children
comparison
equal deleted inserted replaced
379:76b7d63099ad 380:8626e4521993
62 #ifdef hp9000s300 62 #ifdef hp9000s300
63 #ifdef OLD_HP_ASSEMBLER 63 #ifdef OLD_HP_ASSEMBLER
64 data 64 data
65 text 65 text
66 globl _alloca 66 globl _alloca
67 _alloca 67 _alloca
68 move.l (sp)+,a0 ; pop return addr from top of stack 68 move.l (sp)+,a0 ; pop return addr from top of stack
69 move.l (sp)+,d0 ; pop size in bytes from top of stack 69 move.l (sp)+,d0 ; pop size in bytes from top of stack
70 add.l #ROUND,d0 ; round size up to long word 70 add.l #ROUND,d0 ; round size up to long word
71 and.l #MASK,d0 ; mask out lower two bits of size 71 and.l #MASK,d0 ; mask out lower two bits of size
72 sub.l d0,sp ; allocate by moving stack pointer 72 sub.l d0,sp ; allocate by moving stack pointer
115 file "alloca.s" 115 file "alloca.s"
116 global alloca 116 global alloca
117 alloca: 117 alloca:
118 #ifdef MOTOROLA_DELTA 118 #ifdef MOTOROLA_DELTA
119 /* slightly modified version of alloca to motorola sysV/68 pcc - based 119 /* slightly modified version of alloca to motorola sysV/68 pcc - based
120 compiler. 120 compiler.
121 this compiler saves used registers relative to %sp instead of %fp. 121 this compiler saves used registers relative to %sp instead of %fp.
122 alright, just make new copy of saved register set whenever we allocate 122 alright, just make new copy of saved register set whenever we allocate
123 new space from stack.. 123 new space from stack..
124 this is true at last until SVR3V7 . bug has reported to Motorola. */ 124 this is true at last until SVR3V7 . bug has reported to Motorola. */
125 set MAXREG,10 # max no of registers to save (d2-d7, a2-a5) 125 set MAXREG,10 # max no of registers to save (d2-d7, a2-a5)
184 move.l (sp)+,a1 ; pop return address 184 move.l (sp)+,a1 ; pop return address
185 move.l (sp)+,d0 ; pop allocation size 185 move.l (sp)+,d0 ; pop allocation size
186 move.l sp,d1 ; get current SP value 186 move.l sp,d1 ; get current SP value
187 sub.l d0,d1 ; adjust to reflect required size... 187 sub.l d0,d1 ; adjust to reflect required size...
188 sub.l #MAXREG*4,d1 ; ...and space needed for registers 188 sub.l #MAXREG*4,d1 ; ...and space needed for registers
189 and.l #-4,d1 ; backup to longword boundry 189 and.l #-4,d1 ; backup to longword boundary
190 move.l sp,a0 ; save old SP value for register copy 190 move.l sp,a0 ; save old SP value for register copy
191 move.l d1,sp ; set the new SP value 191 move.l d1,sp ; set the new SP value
192 tst.b -4096(sp) ; grab an extra page (to cover caller) 192 tst.b -4096(sp) ; grab an extra page (to cover caller)
193 move.l a2,d1 ; save callers register 193 move.l a2,d1 ; save callers register
194 move.l sp,a2 194 move.l sp,a2
254 * The ns16000 is a little more difficult, need to copy regs. 254 * The ns16000 is a little more difficult, need to copy regs.
255 * Also the code assumes direct linkage call sequence (no mod table crap). 255 * Also the code assumes direct linkage call sequence (no mod table crap).
256 * We have to copy registers, and therefore waste 32 bytes. 256 * We have to copy registers, and therefore waste 32 bytes.
257 * 257 *
258 * Stack layout: 258 * Stack layout:
259 * new sp -> junk 259 * new sp -> junk
260 * registers (copy) 260 * registers (copy)
261 * r0 -> new data 261 * r0 -> new data
262 * | (orig retval) 262 * | (orig retval)
263 * | (orig arg) 263 * | (orig arg)
264 * old sp -> regs (orig) 264 * old sp -> regs (orig)
265 * local data 265 * local data
266 * fp -> old fp 266 * fp -> old fp