Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sdd.hp.com!decwrl!shelby!neon!lucid.com!fy From: fy@lucid.com (Frank Yellin) Newsgroups: comp.sys.mips Subject: Re: Desperately Seeking Bltzal and Bgezal. Summary: Lisp's use of bgezal. Avoiding standing on your head. Keywords: bltzal bgezal Message-ID: <2281@heavens-gate.lucid.com> Date: 7 Sep 90 21:54:37 GMT References: <1179@cluster.cs.su.oz> <2509@rossignol.Princeton.EDU> Organization: Lucid, Inc. Menlo Park, CA Lines: 44 In article <2509@rossignol.Princeton.EDU>, appel@cs.Princeton.EDU (Andrew Appel) writes: > The "Standard ML of New Jersey" compiler generates position-independent > code (useful, because code is moved around by the garbage collector). > To do this, it is sometimes necessary to get the PC into a register. > A failing bltzal (BLTZAL r0,anywhere) is a convenient way to do this. Lucid Common Lisp has a similar problem. To handle catch frames and unwind-protect code, we need to store the address of code on the stack. The easiest way to do this is bgezal %0, label ; always branch and link move %31, label It seems, though, that no one has yet come up with a case in which bgezal or bltzal is ever used with any register other than %0, so that the branch is either always taken or never taken, respectively. > On the SPARC, which has no such instruction, we must stand on our heads > to do it. Sure it does: my-address call label ;; go to label. Put address of my-address into %o7 ...... label Any place in the code can now be reached by jumping to an offset from %o7 There doesn't have to be any code between the delay slot instruction and the label. And unlike the MIPS, the delay slot instruction can even be a branch, since the preceding instruction is an unconditional branch. -- Frank Yellin fy@lucid.com ...!decwrl!edsel!fy ...!sun!edsel!fy -- -- Frank