1/* setjmp/longjmp routines for M68HC11 & M68HC12. 2 * Copyright (C) 1999, 2000, 2001, 2002 Stephane Carrez (stcarrez@nerim.fr) 3 * 4 * The authors hereby grant permission to use, copy, modify, distribute, 5 * and license this software and its documentation for any purpose, provided 6 * that existing copyright notices are retained in all copies and that this 7 * notice is included verbatim in any distributions. No written agreement, 8 * license, or royalty fee is required for any of the authorized uses. 9 * Modifications to this software may be copyrighted by their authors 10 * and need not follow the licensing terms described here, provided that 11 * the new terms are clearly indicated on the first page of each file where 12 * they apply. 13 */ 14 15#include <picolibc.h> 16 17#if __INT__ == 32 18# define val 4 19# define INT32(X) X 20#else 21# define val 2 22# define INT32(X) 23#endif 24 25#ifdef mc6811 26# define REG(X) *X 27#else 28# define REG(X) X 29#endif 30 31 .sect .text 32 .global setjmp 33 .global longjmp 34 35#ifdef mc6811 36setjmp: 37 xgdx 38 tsy 39 ldd 0,y 40 std 0,x 41 sty 2,x 42 ldd REG(_.frame) 43 std 4,x 44 ldd REG(_.d1) 45 std 6,x 46 ldd REG(_.d2) 47 std 8,x 48 ldd REG(_.d3) 49 std 10,x 50 ldd REG(_.d4) 51 std 12,x 52 ldd REG(_.d5) 53 std 14,x 54 ldd REG(_.d6) 55 std 16,x 56 ldd REG(_.d7) 57 std 18,x 58 ldd REG(_.d8) 59 std 20,x 60INT32( ldx #0) 61 clra 62 clrb 63 rts 64#else 65setjmp: 66 xgdx 67 movw 0,sp,2,x+ 68 sts 2,x+ 69 movw _.frame,2,x+ 70 movw _.d1,2,x+ 71 movw _.d2,2,x+ 72 movw _.d3,2,x+ 73 movw _.d4,2,x+ 74 movw _.d5,2,x+ 75 movw _.d6,2,x+ 76 movw _.d7,2,x+ 77 movw _.d8,2,x+ 78INT32( ldx #0) 79 clra 80 clrb 81 rts 82#endif 83 84#ifdef mc6811 85longjmp: 86 xgdx 87 tsy 88 ldd val,y 89 bne do_jump 90 ldd #1 91do_jump: 92 xgdy 93 ldd 4,x 94 std REG(_.frame) 95 ldd 6,x 96 std REG(_.d1) 97 ldd 8,x 98 std REG(_.d2) 99 ldd 10,x 100 std REG(_.d3) 101 ldd 12,x 102 std REG(_.d4) 103 ldd 14,x 104 std REG(_.d5) 105 ldd 16,x 106 std REG(_.d6) 107 ldd 18,x 108 std REG(_.d7) 109 ldd 20,x 110 std REG(_.d8) 111 ldd 0,x 112 ldx 2,x 113 txs 114 std 0,x 115INT32( ldx #0) 116 xgdy 117 rts 118#else 119 120longjmp: 121 xgdx 122 ldy val,sp 123 bne do_jump 124 ldy #1 125do_jump: 126 ldd 4,x+ 127 movw 2,x+,_.frame 128 movw 0,x,_.d1 129 movw 2,x,_.d2 130 movw 4,x,_.d3 131 movw 6,x,_.d4 132 movw 8,x,_.d5 133 movw 10,x,_.d6 134 movw 12,x,_.d7 135 movw 14,x,_.d8 136 ldx -4,x 137 txs 138 std 0,x 139INT32( ldx #0) 140 xgdy 141 rts 142#endif 143 144