home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.3b1
- Path: sparky!uunet!digibd!steve
- From: steve@digibd.com (Steve Wahl)
- Subject: Re: Lack of libPW.a module
- Organization: DigiBoard Incorporated, Eden Prairie, MN
- Date: Thu, 27 Aug 1992 21:38:51 GMT
- Message-ID: <1992Aug27.213851.20578@digibd.com>
- Keywords: libPW PW alloca xmalloc
- References: <1992Aug22.004946.20370@pbhyf.PacBell.COM> <1992Aug25.235036.28469@colnet.cmhnet.org>
- Lines: 28
-
- In article <1992Aug25.235036.28469@colnet.cmhnet.org> res@colnet.cmhnet.org (Rob Stampfli) writes:
- ...
- >===============================================================================
- ># This is optimized for the Unix PC, it won't work on some other 68k systems.
- ># The "and.l &-4" could be changed to "and.l &-2" if you're only running the
- ># code on the Unix PC. I use this same code when cross-compiling to a 68020
- ># system, thus the longword alignment.
- >
- > global alloca
- >alloca:
- > mov.l (%sp)+,%a0 # pop return addr
- > mov.l (%sp),%d0 # get size argument
- > and.l &-4,%d0 # round size down to long word
- > sub.l %d0,%sp # allocate by moving stack pointer
- > mov.l %sp,%d0 # return pointer in d0
- > lea -4(%sp),%sp # allow caller to pop the arg
- > jmp (%a0) # return
-
- Rob's post mentions that you can't call this alloca() when there's
- something on the stack. But beware: I believe this aproach also fails
- if you use register variables in your functions: think about how the
- compiler saves and restores the registers.
-
- --> Steve
- --
- Steve Wahl steve@digibd.com
- Digi International, Inc.
- Eden Prairie, MN (612) 943-5387
-