source: branches/arm/lisp-kernel/arm-subprims.s @ 13801

Last change on this file since 13801 was 13801, checked in by gb, 9 years ago

Don't assume that nfn is preserved by _SPmkcatch1v.

File size: 2.9 KB
Line 
1/*   Copyright (C) 2010 Clozure Associates */
2/*   This file is part of Clozure CL.  */
3
4/*   Clozure CL is licensed under the terms of the Lisp Lesser GNU Public */
5/*   License , known as the LLGPL and distributed with Clozure CL as the */
6/*   file "LICENSE".  The LLGPL consists of a preamble and the LGPL, */
7/*   which is distributed with Clozure CL as the file "LGPL".  Where these */
8/*   conflict, the preamble takes precedence.   */
9
10/*   Clozure CL is referenced in the preamble as the "LIBRARY." */
11
12/*   The LLGPL is also available online at */
13/*   http://opensource.franz.com/preamble.html */
14
15
16        .syntax unified
17        .arm
18       
19        include(lisp.s)
20        _beginfile
21
22        .globl _SPmkcatch1v
23        .globl _SPnthrow1value
24
25
26/* This is called from a lisp-style context and calls a lisp function. */
27/* This does the moral equivalent of */
28/*   (loop  */
29/*      (let* ((fn (%function_on_top_of_lisp_stack))) */
30/*        (if fn */
31/*           (catch %toplevel-catch% */
32/*             (funcall fn)) */
33/*            (return nil)))) */
34
35_exportfn(toplevel_loop)
36        __(build_lisp_frame(imm0))
37        __(b local_label(test))
38local_label(loop):
39        __(ref_nrs_value(arg_z,toplcatch))
40        __(bl _SPmkcatch1v)     /* preserves nfn, at the moment */
41        __(b local_label(test)) /* cleanup address, not really a branch */
42        __(ldr nfn,[vsp,#0])
43        __(set_nargs(0))
44        __(funcall_nfn())
45        __(mov arg_z,#nil_value)
46        __(mov imm0,fixnum_one)
47        __(bl _SPnthrow1value)
48local_label(test):
49        __(ldr nfn,[vsp,#0])
50        __(cmp nfn,#nil_value)
51        __(bne local_label(loop))
52        __(return_lisp_frame(imm0))
53        _endfn
54
55
56/* This gets called with R3 pointing to the current TCR. */
57/* r4 is 0 if we want to start the whole thing rolling, */
58/* non-zero if we want to reset the current process */
59/* by throwing to toplevel */
60
61        .globl _SPreset
62_exportfn(C(start_lisp))
63        __(stmdb sp!,{r4,r5,r6,r7,r8,r9,r10,r11,r12,lr})
64        __(mov rcontext,r0)
65        __(mov arg_z,#0)
66        __(mov arg_y,#0)
67        __(mov arg_x,#0)
68        __(mov temp0,#0)
69        __(mov temp1,#0)
70        __(mov temp2,#0)
71        __(mov allocptr,#VOID_ALLOCPTR)
72        __(mov fn,#0)
73        __(ldr vsp,[rcontext,#tcr.save_vsp])
74        __(ldr imm2,[rcontext,#tcr.last_lisp_frame])
75        __(sub imm0,imm2,sp)
76        __(add imm0,imm0,#node_size)
77        __(mov imm0,imm0,lsl #num_subtag_bits-word_shift)
78        __(orr imm0,imm0,#subtag_u32_vector)
79        __(stmdb sp!,{imm0,imm2})
80        __(mov imm0,#TCR_STATE_LISP)
81        __(str imm0,[rcontext,#tcr.valence])
82        __(ldr allocptr,[rcontext,#tcr.save_allocptr])
83        __(bl toplevel_loop)
84        __(ldmia sp!,{imm0,imm1})
85        __(mov imm0,#TCR_STATE_FOREIGN)
86        __(str imm1,[rcontext,#tcr.last_lisp_frame])
87        __(str imm0,[rcontext,#tcr.valence])
88        __(mov imm0,#nil_value)
89        __(ldmia sp!,{r4,r5,r6,r7,r8,r9,r10,r11,r12,lr})
90        __(bx lr)
91
92_exportfn(_SPsp_end)
93        __(nop)
94        _endfile
95
Note: See TracBrowser for help on using the repository browser.