[gambit-list] Using the tcc compiler
Christian Jaeger
christian at pflanze.mine.nu
Sat Jul 28 00:20:27 EDT 2007
Marc Feeley wrote:
> Are you sure TCC implements floating point?
Well, this code works:
(define (functor:vector-* length make ref vset!)
(lambda (v fact)
(let* ((len (length v))
(out (make len)))
(let lp ((i 0))
(if (< i len)
(begin
(let ()
(declare (flonum) (not safe))
(vset! out i (* fact (ref v i))))
(lp (inc i)))))
out)))
(define f64vector-*
(functor:vector-* f64vector-length make-f64vector f64vector-ref
f64vector-set!))
(define f32vector-*
(functor:vector-* f32vector-length make-f32vector f32vector-ref
f32vector-set!))
(TEST ;;(<- syntax from unreleased cj-test module)
> (f64vector-* '#f64(1.2 3.2 0.4) 2.3123123124213153251253)
#f64(2.7747747749055782 7.3993993997482095 .9249249249685262)
> (f32vector-* '#f32(1.2 3.2 0.4) 2.3123123124213153251253)
#f32(2.7747747898101807 7.399399280548096 .924924910068512)
)
There is one "mul" opcode in the disassembly:
...
2868: dd d9 fstp %st(1)
286a: dd 45 b8 fldl 0xffffffb8(%ebp)
286d: dc 4d b0 fmull 0xffffffb0(%ebp)
2870: dd 55 a8 fstl 0xffffffa8(%ebp)
2873: dd d9 fstp %st(1)
2875: 8b 45 d4 mov 0xffffffd4(%ebp),%eax
2878: 83 c0 10 add $0x10,%eax
...
I'm surprised that there's only one occurrence of an opcode containing
"mul" in it's name, when both 32 and 64 bit operations are being
performed. But I don't really know x86 assembly.
I'll look into my problematic code more closely, it may actually be the
included foreign C code (written by me and others) which is at fault.
Christian.
More information about the Gambit-list
mailing list