1 /* Setjmp and longjmp for mmix.
3 Copyright (C) 2001 Hans-Peter Nilsson
5 Permission to use, copy, modify, and distribute this software is
6 freely granted, provided that the above copyright notice, this notice
7 and the following disclaimer are preserved with no changes.
9 THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
10 IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
11 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 1: rJ (return-address)
18 3: rO *before* the setjmp call.
19 4: temporary storage. Reserved between setjmp and longjmp. */
21 #ifdef __MMIX_ABI_GNU__
33 .section .text.setjmp,"ax",@progbits
36 % Store fp, sp and return address. Recycle the static-chain and
37 % structure-return registers as temporary register, since we need to keep
38 % the jmp_buf (parameter 1) and the return address across a "POP".
46 % Jump through hoops to get the value of rO *before* the setjmp call.
56 .section .text.longjmp,"ax",@progbits
59 % Reset arg2 to 1 if it is 0 (see longjmp(2)) and store it in jmp_buf.
60 % Save arg1 in a global register, since it will be destroyed by the POPs
61 % (in the mmixware ABI).
66 % Loop and "POP 0,0" until rO is the expected value, like
67 % the expansion of nonlocal_goto_receiver, except that we put the return
68 % value in the right register and make sure that the POP causes it to
69 % enter the right return-value register as seen by the caller. For the
70 % GNU ABI, it is unnecessary to do this in the loop and perhaps the memory
71 % access can be hoisted outside the loop, but this is safe and simple and
72 % I see no need to optimize longjmps.
87 .size longjmp,.-longjmp