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#include "setarch.h" 20 21 .file "setjmp.S" 22 23 .section .text 24 .align 2 25 .global _setjmp 26_setjmp: 27#if defined(__H8300SX__) 28 mov.l er7,@er0+ 29 mov.l er6,@er0+ 30 mov.l er5,@er0+ 31 mov.l er4,@er0+ 32 mov.l @sp,@er0 33 sub.l er0,er0 34#elif defined(__H8300H__) || defined(__H8300S__) 35 mov.l er7,@er0 36 mov.l er6,@(4,er0) 37 mov.l er5,@(8,er0) 38 mov.l er4,@(12,er0) 39 mov.l @sp,er1 40 mov.l er1,@(16,er0) 41 sub.l er0,er0 42#else 43 mov.w r7,@r0 44 mov.w r6,@(2,r0) 45 mov.w r5,@(4,r0) 46 mov.w r4,@(6,r0) 47 mov.w @sp,r1 48 mov.w r1,@(8,r0) 49 sub.w r0,r0 50#endif 51 rts 52 53 .global _longjmp 54_longjmp: 55#if defined(__H8300H__) || defined (__H8300S__) || defined (__H8300SX__) 56 mov.l @er0+,er7 57 mov.l @er0+,er6 58 mov.l @er0+,er5 59 mov.l @er0+,er4 60#if defined(__H8300SX__) 61 mov.l @er0,@sp 62#else 63 mov.l @er0,er2 64 mov.l er2,@sp 65#endif 66#if (__INT_MAX__ <= 32767) 67 mov.w r1,r0 68#else 69 mov.l er1,er0 70#endif 71 bne .L1 72 sub er0,er0 73 adds #1,er0 74#else 75 mov.w @r0+,r7 76 mov.w @r0+,r6 77 mov.w @r0+,r5 78 mov.w @r0+,r4 79 mov.w @r0,r2 80 mov.w r2,@sp 81 mov.w r1,r0 82 bne .L1 83 mov.w #1,r0 84#endif 85.L1: 86 rts 87