summaryrefslogtreecommitdiff
path: root/riscv/trunk/rtl/riscv64/setjump.inc
blob: 2bdbe0a39037da9f0436a6b8c6c41253c269fdca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{

    This file is part of the Free Pascal run time library.
    Copyright (c) 2008 by the Free Pascal development team.

    SetJmp and LongJmp implementation for exception handling

    See the file COPYING.FPC, included in this distribution,
    for details about the copyright.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 **********************************************************************}

function fpc_setjmp(var S : jmp_buf) : longint;assembler;nostackframe;[Public, alias : 'FPC_SETJMP'];nostackframe;compilerproc;
  asm
    sd ra,   0*8(a0)
    sd s0,   1*8(a0)
    sd s1,   2*8(a0)
    sd s2,   3*8(a0)
    sd s3,   4*8(a0)
    sd s4,   5*8(a0)
    sd s5,   6*8(a0)
    sd s6,   7*8(a0)
    sd s7,   8*8(a0)
    sd s8,   9*8(a0)
    sd s9,  10*8(a0)
    sd s10, 11*8(a0)
    sd s11, 12*8(a0)
    sd sp,  13*8(a0)

    addi x10, x0, 0
  end;


procedure fpc_longjmp(var S : jmp_buf;value : longint);assembler;nostackframe;[Public, alias : 'FPC_LONGJMP'];compilerproc;
  asm
    ld ra,  0*8(a0)
    ld s0,  1*8(a0)
    ld s1,  2*8(a0)
    ld s2,  3*8(a0)
    ld s3,  4*8(a0)
    ld s4,  5*8(a0)
    ld s5,  6*8(a0)
    ld s6,  7*8(a0)
    ld s7,  8*8(a0)
    ld s8,  9*8(a0)
    ld s9, 10*8(a0)
    ld s10,11*8(a0)
    ld s11,12*8(a0)
    ld sp, 13*8(a0)

    sltiu a0, a1, 1
    add a0, a0, a1
  end;