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