! rc-absolute-cell is just CONSTANT: 0
: jit-call ( name -- )
- ! 0 X0 MOVwi64
+ 0 X0 MOVwi64
f rc-absolute-cell rel-dlsym
X0 BR ;
! RAX 0 MOV f rc-absolute-cell rel-dlsym
! ## Entry points
{ c-to-factor [
+ ! dst src MOV
! arg2 arg1 MOV
! vm-reg "begin_callback" jit-call-1arg
! vm-reg "end_callback" jit-call-1arg
- BL
+ [
+ ! Rn Rd MOVr64
+ arg1 arg2 MOVr64
+ vm-reg "begin_callback" jit-call-1arg
+
+ return-reg arg1 MOVr64 ! arg1 is return
+ jit-call-quot
+
+ vm-reg "end_callback" jit-call-1arg
+
+ ] assemble-arm %
] }
! { unwind-native-frames [ ] }
! Copyright (C) 2020 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors combinators cpu.arm.assembler.opcodes kernel
-math math.bitwise namespaces sequences ;
+USING: accessors combinators cpu.arm.assembler.opcodes io.binary
+kernel math math.bitwise namespaces sequences ;
IN: cpu.arm.assembler
! pre-index mode: computed addres is the base-register + offset
: LSRi32 ( imm6 Rn Rd -- ) LSRi32-encode >out ;
: LSRi64 ( imm6 Rn Rd -- ) LSRi64-encode >out ;
+: SVC ( imm16 -- ) SVC-encode >out ;
+
: with-output-variable ( value variable quot -- value )
over [ get ] curry compose with-variable ; inline
: with-new-arm64 ( quot -- arm64-assembler )
[ 0 <arm64-assembler> \ arm64-assembler ] dip with-output-variable ; inline
+: assemble-arm ( quot -- bytes )
+ with-new-arm64 out>> [ 4 >le ] map concat ; inline
+
: offset-test-arm64 ( offset quot -- instuctions )
with-new-arm64-offset out>> ; inline
// Allocates memory
cell begin_callback(factor_vm* parent, cell quot) {
+ cout << "begin_callback called" << endl;
return parent->begin_callback(quot);
}