Re: Embedding machine code
On Thu, 26 Feb 2004 08:31:20 +0000, Derek Parnell
<ddparnell at bigpond.com> wrote:
> SHIFT_LEFT = define_c_func("", SHL_SPACE, {C_INT, C_INT}, C_INT)
>
>but that gives the error message ...
>
>c:\euphoria\include\dll.e:50 in function define_c_func()
>type_check failure, lib is {}
>
>
>Any ideas about how I should actually call these machine code routines?
You need to use 2.4. Check that define_c_func in dll.e begins with
object lib not atom lib.
>What I really need is when I have an atom that exceeds a 32-bit format I
>want to chop off the excess bits and only keep the low 32 bits.
If speed isn't critical, this might show how, up to a point:
include machine.e
atom i
i=#0FFFFFFF
for j=1 to 40 do
i=i*2+1
? i
? int_to_bits(i,32)
? bits_to_int(int_to_bits(i,32))
if getc(0) then end if
end for
It seems to work up to 54 bits, I guess it depends on where you are
getting these atoms from. You may need to change the sign of the
result from bits_to_int if it is over 2^31-1.
Regards,
Pete
|
Not Categorized, Please Help
|
|