diff --git a/basis/math/floats/env/x86/32/32.factor b/basis/math/floats/env/x86/32/32.factor new file mode 100644 index 0000000000..ea3bee424f --- /dev/null +++ b/basis/math/floats/env/x86/32/32.factor @@ -0,0 +1,29 @@ +USING: alien alien.c-types cpu.x86.assembler +cpu.x86.assembler.operands math.floats.env.x86 system ; +IN: math.floats.env.x86.32 + +M: x86.32 get-sse-env + void { void* } "cdecl" [ + EAX ESP [] MOV + EAX [] STMXCSR + ] alien-assembly ; + +M: x86.32 set-sse-env + void { void* } "cdecl" [ + EAX ESP [] MOV + EAX [] LDMXCSR + ] alien-assembly ; + +M: x86.32 get-x87-env + void { void* } "cdecl" [ + EAX ESP [] MOV + EAX [] FNSTSW + EAX 2 [+] FNSTCW + ] alien-assembly ; + +M: x86.32 set-x87-env + void { void* } "cdecl" [ + EAX ESP [] MOV + FNCLEX + EAX 2 [+] FLDCW + ] alien-assembly ; diff --git a/basis/math/floats/env/x86/32/tags.txt b/basis/math/floats/env/x86/32/tags.txt new file mode 100644 index 0000000000..6bf68304bb --- /dev/null +++ b/basis/math/floats/env/x86/32/tags.txt @@ -0,0 +1 @@ +unportable diff --git a/basis/math/floats/env/x86/64/64.factor b/basis/math/floats/env/x86/64/64.factor new file mode 100644 index 0000000000..b6f8ee151f --- /dev/null +++ b/basis/math/floats/env/x86/64/64.factor @@ -0,0 +1,25 @@ +USING: alien alien.c-types cpu.architecture cpu.x86.assembler +cpu.x86.assembler.operands math.floats.env.x86 sequences system ; +IN: math.floats.env.x86.64 + +M: x86.64 get-sse-env + void { void* } "cdecl" [ + int-regs param-regs first [] STMXCSR + ] alien-assembly ; + +M: x86.64 set-sse-env + void { void* } "cdecl" [ + int-regs param-regs first [] LDMXCSR + ] alien-assembly ; + +M: x86.64 get-x87-env + void { void* } "cdecl" [ + int-regs param-regs first [] FNSTSW + int-regs param-regs first 2 [+] FNSTCW + ] alien-assembly ; + +M: x86.64 set-x87-env + void { void* } "cdecl" [ + FNCLEX + int-regs param-regs first 2 [+] FLDCW + ] alien-assembly ; diff --git a/basis/math/floats/env/x86/64/tags.txt b/basis/math/floats/env/x86/64/tags.txt new file mode 100644 index 0000000000..6bf68304bb --- /dev/null +++ b/basis/math/floats/env/x86/64/tags.txt @@ -0,0 +1 @@ +unportable diff --git a/basis/math/floats/env/x86/x86.factor b/basis/math/floats/env/x86/x86.factor index 9bae382ef6..89dd402378 100644 --- a/basis/math/floats/env/x86/x86.factor +++ b/basis/math/floats/env/x86/x86.factor @@ -1,8 +1,7 @@ -USING: accessors alien alien.c-types alien.syntax arrays assocs -biassocs classes.struct combinators cpu.architecture -cpu.x86.assembler cpu.x86.assembler.operands cpu.x86.features -kernel literals math math.bitwise math.floats.env -math.floats.env.private sequences system ; +USING: accessors alien.c-types arrays assocs biassocs +classes.struct combinators cpu.x86.features kernel literals +math math.bitwise math.floats.env math.floats.env.private +system vocabs.loader ; IN: math.floats.env.x86 STRUCT: sse-env @@ -18,56 +17,6 @@ HOOK: set-sse-env cpu ( sse-env -- ) HOOK: get-x87-env cpu ( x87-env -- ) HOOK: set-x87-env cpu ( x87-env -- ) -! 32-bit -M: x86.32 get-sse-env - void { void* } "cdecl" [ - EAX ESP [] MOV - EAX [] STMXCSR - ] alien-assembly ; - -M: x86.32 set-sse-env - void { void* } "cdecl" [ - EAX ESP [] MOV - EAX [] LDMXCSR - ] alien-assembly ; - -M: x86.32 get-x87-env - void { void* } "cdecl" [ - EAX ESP [] MOV - EAX [] FNSTSW - EAX 2 [+] FNSTCW - ] alien-assembly ; - -M: x86.32 set-x87-env - void { void* } "cdecl" [ - EAX ESP [] MOV - FNCLEX - EAX 2 [+] FLDCW - ] alien-assembly ; - -! 64-bit -M: x86.64 get-sse-env - void { void* } "cdecl" [ - int-regs param-regs first [] STMXCSR - ] alien-assembly ; - -M: x86.64 set-sse-env - void { void* } "cdecl" [ - int-regs param-regs first [] LDMXCSR - ] alien-assembly ; - -M: x86.64 get-x87-env - void { void* } "cdecl" [ - int-regs param-regs first [] FNSTSW - int-regs param-regs first 2 [+] FNSTCW - ] alien-assembly ; - -M: x86.64 set-x87-env - void { void* } "cdecl" [ - FNCLEX - int-regs param-regs first 2 [+] FLDCW - ] alien-assembly ; - : ( -- sse-env ) sse-env (struct) [ get-sse-env ] keep ; @@ -178,3 +127,7 @@ M: x87-env (get-denormal-mode) ( register -- mode ) M: x87-env (set-denormal-mode) ( register mode -- register' ) drop ; +cpu { + { x86.32 [ "math.floats.env.x86.32" ] } + { x86.64 [ "math.floats.env.x86.64" ] } +} case require