2009-04-23 03:52:49 +08:00
|
|
|
/* A setjmp.c for Moxie
|
2019-12-14 02:08:06 +08:00
|
|
|
Copyright (C) 2009, 2019 Anthony Green
|
2009-04-23 03:52:49 +08:00
|
|
|
|
|
|
|
The authors hereby grant permission to use, copy, modify, distribute,
|
|
|
|
and license this software and its documentation for any purpose, provided
|
|
|
|
that existing copyright notices are retained in all copies and that this
|
|
|
|
notice is included verbatim in any distributions. No written agreement,
|
|
|
|
license, or royalty fee is required for any of the authorized uses.
|
|
|
|
Modifications to this software may be copyrighted by their authors
|
|
|
|
and need not follow the licensing terms described here, provided that
|
|
|
|
the new terms are clearly indicated on the first page of each file where
|
|
|
|
they apply. */
|
|
|
|
|
|
|
|
# setjmp/longjmp for moxie. The jmpbuf looks like this:
|
2019-12-14 02:08:06 +08:00
|
|
|
#
|
|
|
|
# Register jmpbuf offset
|
2019-12-20 22:00:26 +08:00
|
|
|
# $r6 0x00
|
|
|
|
# $r7 0x04
|
|
|
|
# $r8 0x08
|
|
|
|
# $r9 0x0c
|
|
|
|
# $r10 0x10
|
|
|
|
# $fp 0x14
|
|
|
|
# $sp 0x18
|
|
|
|
# stack frame fp 0x1c
|
|
|
|
# stack frame ra 0x20
|
|
|
|
# stack frame sc 0x25
|
2019-12-14 02:08:06 +08:00
|
|
|
|
|
|
|
.text
|
|
|
|
.global setjmp
|
|
|
|
.type setjmp,@function
|
2009-04-23 03:52:49 +08:00
|
|
|
setjmp:
|
2019-12-20 22:00:26 +08:00
|
|
|
st.l ($r0), $r6
|
|
|
|
sto.l 0x04($r0), $r7
|
|
|
|
sto.l 0x08($r0), $r8
|
|
|
|
sto.l 0x0c($r0), $r9
|
|
|
|
sto.l 0x10($r0), $r10
|
|
|
|
sto.l 0x14($r0), $sp
|
|
|
|
sto.l 0x18($r0), $fp
|
|
|
|
ldo.l $r1, 0x00($fp)
|
|
|
|
sto.l 0x1c($r0), $r1
|
2019-12-14 02:08:06 +08:00
|
|
|
ldo.l $r1, 0x04($fp)
|
2019-12-20 22:00:26 +08:00
|
|
|
sto.l 0x20($r0), $r1
|
2019-12-14 02:08:06 +08:00
|
|
|
ldo.l $r1, 0x08($fp)
|
2019-12-20 22:00:26 +08:00
|
|
|
sto.l 0x24($r0), $r1
|
2012-10-27 23:57:12 +08:00
|
|
|
xor $r0, $r0
|
2009-04-23 03:52:49 +08:00
|
|
|
ret
|
|
|
|
.Lend1:
|
|
|
|
.size setjmp,.Lend1-setjmp
|
|
|
|
|
|
|
|
.global longjmp
|
|
|
|
.type longjmp,@function
|
|
|
|
longjmp:
|
2019-12-20 22:00:26 +08:00
|
|
|
ldo.l $r6, 0x00($r0)
|
|
|
|
ldo.l $r7, 0x04($r0)
|
|
|
|
ldo.l $r8, 0x08($r0)
|
|
|
|
ldo.l $r9, 0x0c($r0)
|
|
|
|
ldo.l $r10, 0x10($r0)
|
|
|
|
ldo.l $sp, 0x14($r0)
|
|
|
|
ldo.l $fp, 0x18($r0)
|
|
|
|
ldo.l $r2, 0x1c($r0)
|
|
|
|
sto.l 0x0($fp), $r2
|
|
|
|
ldo.l $r2, 0x20($r0)
|
|
|
|
sto.l 0x4($fp), $r2
|
|
|
|
ldo.l $r2, 0x24($r0)
|
|
|
|
sto.l 0x8($fp), $r2
|
2009-04-23 03:52:49 +08:00
|
|
|
ldo.l $r2, 0x08($r0)
|
|
|
|
mov $r0, $r1
|
2019-12-20 22:00:26 +08:00
|
|
|
xor $r2, $r2
|
|
|
|
cmp $r0, $r2
|
|
|
|
beq .Lreturn1
|
2009-04-23 03:52:49 +08:00
|
|
|
ret
|
|
|
|
.Lreturn1:
|
2019-12-20 22:00:26 +08:00
|
|
|
inc $r0, 1
|
2009-04-23 03:52:49 +08:00
|
|
|
ret
|
|
|
|
.Lend2:
|
|
|
|
.size longjmp,.Lend2-longjmp
|