# HG changeset patch # User telesto # Date 1682694497 -7200 # Fri Apr 28 17:08:17 2023 +0200 # Node ID ec880d21b8accb116438f15840e138a7cbaa8e6d # Parent 7571c2b55fecbc9778e24dcc62557fc06e9ecc44 avx: can be run without elf code now; implement vcvtsi2sd and vcvtsd2si; fix ymm@ and ymm! diff --git a/avx.fox b/avx.fox --- a/avx.fox +++ b/avx.fox @@ -22,11 +22,21 @@ 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 @@ \ 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 @@ \ 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 diff --git a/avx.sh b/avx.sh --- a/avx.sh +++ b/avx.sh @@ -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 diff --git a/playground.asm b/playground.asm --- a/playground.asm +++ b/playground.asm @@ -8,7 +8,9 @@ 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 @@ pop rdi pop rcx + + diff --git a/system.fox b/system.fox --- a/system.fox +++ b/system.fox @@ -271,10 +271,11 @@ : 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 @@ ( 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 @@ \ \ 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 ;