1/* 2 * Copyright (c) 2008 Jon Beniston <jon@beniston.com> 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 * SUCH DAMAGE. 24 */ 25/* setjmp/longjmp for LatticeMico32. */ 26 27 .section .text 28 .align 4 29 30 .globl setjmp 31 .type setjmp,@function 32 .globl longjmp 33 .type longjmp,@function 34 35/* setjmp: save all callee saves into jmp_buf 36 r1 - Address of jmp_buf 37*/ 38 39setjmp: 40 sw (r1+0), r11 41 sw (r1+4), r12 42 sw (r1+8), r13 43 sw (r1+12), r14 44 sw (r1+16), r15 45 sw (r1+20), r16 46 sw (r1+24), r17 47 sw (r1+28), r18 48 sw (r1+32), r19 49 sw (r1+36), r20 50 sw (r1+40), r21 51 sw (r1+44), r22 52 sw (r1+48), r23 53 sw (r1+52), r24 54 sw (r1+56), r25 55 sw (r1+60), gp 56 sw (r1+64), fp 57 sw (r1+68), sp 58 sw (r1+72), ra 59 mvi r1, 0 60 ret 61 62/* longjmp: restore all callee saves from jmp_buf 63 r1 - Address of jmb_buf 64 r2 - Value to return with 65*/ 66 67 .global longjmp 68 .type longjmp,@function 69 .align 4 70 71longjmp: 72 lw r11, (r1+0) 73 lw r12, (r1+4) 74 lw r13, (r1+8) 75 lw r14, (r1+12) 76 lw r15, (r1+16) 77 lw r16, (r1+20) 78 lw r17, (r1+24) 79 lw r18, (r1+28) 80 lw r19, (r1+32) 81 lw r20, (r1+36) 82 lw r21, (r1+40) 83 lw r22, (r1+44) 84 lw r23, (r1+48) 85 lw r24, (r1+52) 86 lw r25, (r1+56) 87 lw gp, (r1+60) 88 lw fp, (r1+64) 89 lw sp, (r1+68) 90 lw ra, (r1+72) 91 mv r1, r2 92 ret 93 94 95