avx: can be run without elf code now; implement vcvtsi2sd and vcvtsd2si; fix ymm@ and ymm!
4 files changed, 36 insertions(+), 16 deletions(-)

M avx.fox
M avx.sh
M playground.asm
M system.fox
M avx.fox +17 -5
@@ 22,11 22,21 @@ vmovapd ymm14,ymm0
 vmovapd ymm15,ymm0
 )
 
-\ convert int64 to float64: cvtsi2sd
 : ret, ^ ;; ;
 
+\ convert int64 to float64
+\ vcvtsi2sd xmm0, xmm0, rax
+: >f64 c4 ,1 c02afbe1 ,4 ;
+
+\ convert float64 to int64
+\ vcvtsd2si rax, xmm0
+: f64> c4 ,1 c02dfbe1 ,4 ;
+
+( n -- n )
+: ttt # >f64 f64> ret,
+
 			\ todo: we have valign
-			\ align to 0x10
+			\ align to 0x20
 			( addr --  addr )
 : align		# -1  20 1-  xor # lit over and =? nip
 			if 20 + then ;

          
@@ 40,18 50,20 @@ avx-align  20 buffer ytmp
 
 		\ vmovapd ymm?,YMMWORD PTR [rax]
 		( c: n -- ; r: addr -- )
-: ymm@	^ dup  0 vmovapd ;
+: ymm!	0 vmovapd ^ drop ;
 
 		\ vmovapd YMMWORD PTR [rax], ymm?
 		( c: n -- ; r: addr -- )
-: ymm!	1 vmovapd  ^ drop ;
+: ymm@	1 vmovapd  ^ drop ;
 
+: ymm0@		# 0 ymm@ ret,
 : ymm1@		# 1 ymm@ ret,
 : ymm2@		# 2 ymm@ ret,
 : ymm7@		# 7 ymm@ ret,
 : ymm8@		# 8 ymm@ ret,
 : ymm15@	# f ymm@ ret,
 
+: ymm0!		# 0 ymm! ret,
 : ymm1!		# 1 ymm! ret,
 : ymm8!		# 8 ymm! ret,
 : ymm15!	# f ymm! ret,

          
@@ 74,7 86,7 @@ a:  c4 62 7d 19 38          vbroadcastsd
 \ VEX.256.66.0F.WIG 5C /r		VSUBPD ymm1, ymm2, ymm3/m256
 \ VEX.256.66.0F.WIG C2 /r ib	VCMPPD ymm1, ymm2, ymm3/m256, imm8
 
-: run initmain bye ;
+: run initmain ytmp ymm0! bye ;
 
 end-app   start-with run   " avx.o" write-obj
 

          
M avx.sh +3 -6
@@ 1,6 1,3 @@ 
-#!/bin/sh
-# don't source this file, execute it!
-sp=$(dirname "$(readlink -f "$0")")
-
-cat system.fox fileio.fox elf64.fox avx.fox - | ./fox
-
+make fox
+# cat system.fox fileio.fox elf64.fox bootstrap2.fox avx.fox - | ./fox
+cat system.fox fileio.fox bootstrap2.fox avx.fox - | ./fox

          
M playground.asm +5 -1
@@ 8,7 8,9 @@ section .bss exec
 codeStart: resb 1024*64
 
 section .data
-
+limits:		dq -2.5, 1.5, 0.0
+db "12345678"
+ dq 0,0
  dq 0,0
 var dq 0
 

          
@@ 148,3 150,5 @@ lodsq
 pop rdi
 pop rcx
 
+
+

          
M system.fox +11 -4
@@ 271,10 271,11 @@ m: cpush	lit4 ;	( elf )
 : v, 	#
 : v,8 	8 vp (,)  ;
 
+: valloc	( n -- ) vp +! ;
+: bhere #	\ elf
+: vhere		( -- n ) vp @ ;
 
-			
-: valloc	( n -- ) vp +! ;
-: vhere		( -- n ) vp @ ;
+: bp	vp ;	( elf )
 
 		\ keep in sync with elf.fox/var
 		\ create a variable and set value to tos

          
@@ 287,7 288,10 @@ m: cpush	lit4 ;	( elf )
 		( n -- )
 : string # ( elf )
 : blabel # ( elf )
-: vlabel # ( elf )
+\ todo: use vhere IN vlabel, we do this all the time, and
+\ this is what vlabel refers to: the current vaddress, see
+\ labels in nasm
+: vlabel # ( elf ) 
 : const	fcreate ^ lit ^ ;; ;
 
 

          
@@ 417,6 421,9 @@ dcols
 \ 
 \ placeholder for elf words, so we can run the code in interpreter mode
 \ \
+: relo,b #
+: relo,v drop drop ;
+: start-app ;
 : end-app ;
 : start-with word drop ;
 : write-obj drop ;