1/* A setjmp.c for Moxie 2 Copyright (C) 2009, 2019 Anthony Green 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#include <picolibc.h> 15 16# setjmp/longjmp for moxie. The jmpbuf looks like this: 17# 18# Register jmpbuf offset 19# $r6 0x00 20# $r7 0x04 21# $r8 0x08 22# $r9 0x0c 23# $r10 0x10 24# $fp 0x14 25# $sp 0x18 26# stack frame fp 0x1c 27# stack frame ra 0x20 28# stack frame sc 0x25 29 30 .text 31 .global setjmp 32 .type setjmp,@function 33setjmp: 34 st.l ($r0), $r6 35 sto.l 0x04($r0), $r7 36 sto.l 0x08($r0), $r8 37 sto.l 0x0c($r0), $r9 38 sto.l 0x10($r0), $r10 39 sto.l 0x14($r0), $sp 40 sto.l 0x18($r0), $fp 41 ldo.l $r1, 0x00($fp) 42 sto.l 0x1c($r0), $r1 43 ldo.l $r1, 0x04($fp) 44 sto.l 0x20($r0), $r1 45 ldo.l $r1, 0x08($fp) 46 sto.l 0x24($r0), $r1 47 xor $r0, $r0 48 ret 49.Lend1: 50 .size setjmp,.Lend1-setjmp 51 52 .global longjmp 53 .type longjmp,@function 54longjmp: 55 ldo.l $r6, 0x00($r0) 56 ldo.l $r7, 0x04($r0) 57 ldo.l $r8, 0x08($r0) 58 ldo.l $r9, 0x0c($r0) 59 ldo.l $r10, 0x10($r0) 60 ldo.l $sp, 0x14($r0) 61 ldo.l $fp, 0x18($r0) 62 ldo.l $r2, 0x1c($r0) 63 sto.l 0x0($fp), $r2 64 ldo.l $r2, 0x20($r0) 65 sto.l 0x4($fp), $r2 66 ldo.l $r2, 0x24($r0) 67 sto.l 0x8($fp), $r2 68 ldo.l $r2, 0x08($r0) 69 mov $r0, $r1 70 xor $r2, $r2 71 cmp $r0, $r2 72 beq .Lreturn1 73 ret 74.Lreturn1: 75 inc $r0, 1 76 ret 77.Lend2: 78 .size longjmp,.Lend2-longjmp 79