1/* 2Copyright (c) 1990 The Regents of the University of California. 3All rights reserved. 4 5Redistribution and use in source and binary forms are permitted 6provided that the above copyright notice and this paragraph are 7duplicated in all such forms and that any documentation, 8and/or other materials related to such 9distribution and use acknowledge that the software was developed 10by the University of California, Berkeley. The name of the 11University may not be used to endorse or promote products derived 12from this software without specific prior written permission. 13THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 */ 17#include <picolibc.h> 18 19; setjmp/longjmp for D30V. 20 21 .text 22 .globl setjmp 23 .type setjmp,@function 24 .stabs "setjmp.S",100,0,0,setjmp 25 .stabs "int:t(0,1)=r(0,1);-2147483648;2147483647;",128,0,0,0 26 .stabs "setjmp:F(0,1)",36,0,1,setjmp 27 28setjmp: 29; Address of jmpbuf is passed in R2. Save the appropriate registers. 30 st2w r26, @(r2+,r0) 31 st2w r28, @(r2+,r0) 32 st2w r30, @(r2+,r0) 33 st2w r32, @(r2+,r0) 34 st2w r34, @(r2+,r0) 35 st2w r36, @(r2+,r0) 36 st2w r38, @(r2+,r0) 37 st2w r40, @(r2+,r0) 38 st2w r42, @(r2+,r0) 39 st2w r44, @(r2+,r0) 40 st2w r46, @(r2+,r0) 41 st2w r48, @(r2+,r0) 42 st2w r50, @(r2+,r0) 43 st2w r52, @(r2+,r0) 44 st2w r54, @(r2+,r0) 45 st2w r56, @(r2+,r0) 46 st2w r58, @(r2+,r0) 47 st2w r60, @(r2+,r0) 48 st2w r62, @(r2+,r0) 49 50 mvfacc r4, a1, 16 51 mvfacc r5, a1, 0 52 st2w r4, @(r2+,r0) 53 54 mvfsys r4, psw 55 mvfsys r5, rpt_c 56 st2w r4, @(r2+,r0) 57 58 mvfsys r4, rpt_s 59 mvfsys r5, rpt_e 60 st2w r4, @(r2+,r0) 61 62 mvfsys r4, mod_s 63 mvfsys r5, mod_e 64 st2w r4, @(r2+,r0) 65 66; Return 0 to caller 67 add r2, r0, r0 68 jmp link 69.Lsetjmp: 70 .size setjmp,.Lsetjmp-setjmp 71 .stabs "",36,0,0,.Lsetjmp-setjmp 72 73 .globl longjmp 74 .type longjmp,@function 75 .stabs "longjmp:F(0,1)",36,0,1,longjmp 76longjmp: 77; Address of jmpbuf is in R2. Restore the registers. 78 ld2w r26, @(r2+,r0) 79 ld2w r28, @(r2+,r0) 80 ld2w r30, @(r2+,r0) 81 ld2w r32, @(r2+,r0) 82 ld2w r34, @(r2+,r0) 83 ld2w r36, @(r2+,r0) 84 ld2w r38, @(r2+,r0) 85 ld2w r40, @(r2+,r0) 86 ld2w r42, @(r2+,r0) 87 ld2w r44, @(r2+,r0) 88 ld2w r46, @(r2+,r0) 89 ld2w r48, @(r2+,r0) 90 ld2w r50, @(r2+,r0) 91 ld2w r52, @(r2+,r0) 92 ld2w r54, @(r2+,r0) 93 ld2w r56, @(r2+,r0) 94 ld2w r58, @(r2+,r0) 95 ld2w r60, @(r2+,r0) 96 ld2w r62, @(r2+,r0) 97 98 ld2w r4, @(r2+,r0) 99 mvtacc a1, r4, r5 100 101 mvfsys r6, psw 102 ld2w r4, @(r2+,r0) /* psw, rpt_c */ 103 and r6, r6, 0xfcff /* set rp, md bits from setjmp, leave */ 104 and r4, r4, 0x0300 /* all other psw bits the same */ 105 or r4, r4, r6 106 mvtsys psw, r4 107 mvtsys rpt_c, r5 108 109 ld2w r4, @(r2+,r0) 110 mvtsys rpt_s, r4 111 mvtsys rpt_e, r5 112 113 ld2w r4, @(r2+,r0) 114 mvtsys mod_s, r4 115 mvtsys mod_e, r5 116 117; Value to return to caller is in R3. If caller attemped to return 0, 118; return 1 instead. 119 120 cmpeq f0, r3, 0 || add r2, r3, r0 121 jmp link || add/tx r2, r2, 1 122.Llongjmp: 123 .size longjmp,.Llongjmp-longjmp 124 .stabs "",36,0,0,.Llongjmp-longjmp 125