Skip to content

Commit

Permalink
disable native calls
Browse files Browse the repository at this point in the history
  • Loading branch information
sayon committed Mar 2, 2019
1 parent a3939e2 commit 6e0f96e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 60 deletions.
9 changes: 0 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,11 @@ ASM = nasm
ASMFLAGS = -felf64 -g -Isrc/


NATIVE_CALLS_SUPPORT=1

# This feature allows you to call functions from libc and other shared libraries.
# You get support for native calls by address and dlsym.
ifdef NATIVE_CALLS_SUPPORT
LINKERFLAGS = -nostdlib
LIBS = -ldl
LINKER = gcc
ASMFLAGS += -DNATIVE_CALLS
else
LINKER = ld
LINKERFLAGS =
LIBS =
endif


all: bin/forthress
Expand Down
51 changes: 0 additions & 51 deletions src/words.inc
Original file line number Diff line number Diff line change
Expand Up @@ -382,57 +382,6 @@ native "syscall", syscall
push rdx
jmp next

%ifdef NATIVE_CALLS

extern dlsym
native "p_dlsym", p_dlsym
push dlsym
jmp next


; Experimental feature: native call
; The stack should hold these values, in this order
; ( function* rdi rsi rdx rcx r8 r9 rax xmm0 xmm1 xmm2 xmm3 xmm4 xmm5 xmm6 xmm7 )
; After that, the stack will hold these values:
; ( rax rdx xmm0 xmm1 )
; This way you can call everything even functions with variable arguments count.
; Notice, that you can pass additional integer/pointer arguments on stack, as
; Forthress data stack corresponds to the hardware stack!
native "ncall", ncall
pop rax,
movq xmm7, rax
pop rax
movq xmm6, rax
pop rax
movq xmm5, rax
pop rax
movq xmm4, rax
pop rax
movq xmm3, rax
pop rax
movq xmm2, rax
pop rax
movq xmm1, rax
pop rax
movq xmm0, rax
pop rax
pop r9
pop r8
pop rcx
pop rdx
pop rsi
pop rdi
add rsp, 8
call [rsp-8]
push rax
push rdx
movq rcx, xmm0
push rcx
movq rcx, xmm1
push rcx
jmp next

%endif

; Jump to a location. Location is an absolute address
; Branch is a compile-only word.
Expand Down

0 comments on commit 6e0f96e

Please sign in to comment.