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 D10V. The jmpbuf looks like this: 20; 21; Register jmpbuf offset 22; R6 0x00 23; R7 0x02 24; R8 0x04 25; R9 0x06 26; R10 0x08 27; R11 0x0a 28; R13 (return address) 0x0c 29; R15 (SP) 0x0E 30 31 .text 32 .globl setjmp 33 .type setjmp,@function 34 .stabs "setjmp.S",100,0,0,setjmp 35 .stabs "int:t(0,1)=r(0,1);-65536;65535;",128,0,0,0 36 .stabs "setjmp:F(0,1)",36,0,1,setjmp 37 38setjmp: 39; Address of jmpbuf is passed in R0. Save the appropriate registers. 40 st2w r6, @r0+ 41 st2w r8, @r0+ 42 st2w r10, @r0+ 43 st r13, @r0+ 44 st r15, @r0+ 45 46; Return 0 to caller 47 ldi r0, 0 48 jmp r13 49.Lsetjmp: 50 .size setjmp,.Lsetjmp-setjmp 51 .stabs "",36,0,0,.Lsetjmp-setjmp 52 53 .globl longjmp 54 .type longjmp,@function 55 .stabs "longjmp:F(0,1)",36,0,1,longjmp 56longjmp: 57; Address of jmpbuf is in R0. Restore the registers. 58 ld2w r6, @r0+ 59 ld2w r8, @r0+ 60 ld2w r10, @r0+ 61 ld r13, @r0+ 62 ld r15, @r0+ 63 64; Value to return to caller is in R1. If caller attemped to return 0, 65; return 1 instead. 66 67 mv r0, r1 68 cmpeqi r0, 0 69 exef0t || ldi r0,1 70 jmp r13 71.Llongjmp: 72 .size longjmp,.Llongjmp-longjmp 73 .stabs "",36,0,0,.Llongjmp-longjmp 74