Start of adding code word support.
This commit is contained in:
@ -25,6 +25,9 @@ typedef cell_t (CALLTYPE *call_t)();
|
||||
#define ct0 ((call_t) n0)
|
||||
|
||||
#define CALLING_OPCODE_LIST \
|
||||
YV(internals, CALLCODE, float *t_fp = fp; DUP; \
|
||||
sp = (cell_t *) (*(call_t*) (w + sizeof(cell_t)))(sp, &t_fp); \
|
||||
fp = t_fp; DROP) \
|
||||
YV(internals, CALL0, n0 = ct0()) \
|
||||
YV(internals, CALL1, n0 = ct0(n1); --sp) \
|
||||
YV(internals, CALL2, n0 = ct0(n2, n1); sp -= 2) \
|
||||
|
||||
58
common/code.fs
Normal file
58
common/code.fs
Normal file
@ -0,0 +1,58 @@
|
||||
\ Copyright 2022 Bradley D. Nelson
|
||||
\
|
||||
\ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
\ you may not use this file except in compliance with the License.
|
||||
\ You may obtain a copy of the License at
|
||||
\
|
||||
\ http://www.apache.org/licenses/LICENSE-2.0
|
||||
\
|
||||
\ Unless required by applicable law or agreed to in writing, software
|
||||
\ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
\ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
\ See the License for the specific language governing permissions and
|
||||
\ limitations under the License.
|
||||
|
||||
( Lazy loaded code words )
|
||||
: asm r|
|
||||
|
||||
also forth definitions
|
||||
vocabulary asm asm definitions
|
||||
also internals
|
||||
|
||||
variable code-start
|
||||
variable code-at
|
||||
|
||||
DEFINED? posix [IF]
|
||||
also posix
|
||||
: reserve ( n -- )
|
||||
0 swap PROT_READ PROT_WRITE PROT_EXEC or or MAP_ANONYMOUS -1 0 mmap code-start ! ;
|
||||
previous
|
||||
4096 reserve
|
||||
[THEN]
|
||||
|
||||
DEFINED? esp [IF]
|
||||
also esp
|
||||
: reserve ( n -- ) MALLOC_CAP_EXEC heap_caps_malloc code-start ! ;
|
||||
previous
|
||||
1024 reserve
|
||||
[THEN]
|
||||
|
||||
code-start code-at !
|
||||
|
||||
: chere ( -- a ) code-at @ ;
|
||||
: callot ( n -- ) code-at +! ;
|
||||
: code, ( n -- ) chere ! cell callot ;
|
||||
: code1, ( n -- ) chere c! 1 callot ;
|
||||
: code2, ( n -- ) chere w! 2 callot ;
|
||||
: code4, ( n -- ) chere l! 4 callot ;
|
||||
: end-code previous ;
|
||||
|
||||
also forth definitions
|
||||
|
||||
: code ( "name" ) create ['] callcode @ latestxt !
|
||||
code-at @ latestxt cell+ ! also asm ;
|
||||
|
||||
previous previous previous
|
||||
asm
|
||||
|
||||
| evaluate ;
|
||||
@ -479,8 +479,13 @@ e: check-filetools
|
||||
check-tasks
|
||||
;e
|
||||
|
||||
e: check-asm
|
||||
out: asm
|
||||
;e
|
||||
|
||||
e: check-phase2
|
||||
check-locals
|
||||
check-asm
|
||||
check-utils
|
||||
;e
|
||||
|
||||
|
||||
Reference in New Issue
Block a user