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 FR30. The jmpbuf looks like this: 20# 21# Register jmpbuf offset 22# R8 0x00 23# R9 0x04 24# R10 0x08 25# R11 0x0c 26# R12 0x10 27# R13 0x14 28# R14 (FP) 0x18 29# R15 (SP) 0x1c 30# RP 0x20 31 32.macro save reg 33 st \reg,@r4 34 add #4,r4 35.endm 36 37.macro restore reg 38 ld @r4,\reg 39 add #4,r4 40.endm 41 42 43 .text 44 .global setjmp 45setjmp: 46 save r8 47 save r9 48 save r10 49 save r11 50 save r12 51 save r13 52 save r14 53 save r15 54 mov RP,r5 55 st r5,@r4 56 57# Return 0 to caller. 58 ldi:8 #0,r4 59 ret 60 61 .global longjmp 62longjmp: 63 restore r8 64 restore r9 65 restore r10 66 restore r11 67 restore r12 68 restore r13 69 restore r14 70 restore r15 71 ld @r4,r4 72 mov r4,RP 73 74# If caller attempted to return 0, return 1 instead. 75 76 mov r5,r4 77 or r4,r4 78 bne 1f 79 ldi:8 #1,r4 80 1: 81 ret 82 83