Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

bit-manipulation and Win32 FFI help needed.

31 views
Skip to first unread message

Andy Reiter

unread,
Oct 18, 2002, 6:45:15 PM10/18/02
to
Hi,

I have two problems with my newbie lisping:

1)(with-open-file (input "C:/windows/intel/file.exe" :direction :input
:element-type 'unsigned-byte)
(do ( .. )
..
(let ((byte (read-byte input)))
(format t "not ~X = ~X" byte (bit-not byte)))))

Gives me an error, saying 'byte' is a fixnum and not a bit array. How do I
convert the read symbol into a bit-vector? COERCE is telling me to make 'byte'
a sequence. Actually, I know how to go about the conversation (thanks to mod,
shift and a carry-flag variable ;-) but there ought to be an standard way.


2) Is there any way to call C from Clisp or vice versa, on Windows? Both the
impnotes and the sample code in $CLISP/modules are documenting the Unix module
facility, and they all use the "clisp-link" utility which is nowhere in Win32.
Also, the examples and the documentation talk about "clisp.a" and "clisp.h"
which are nowhere in my system (I am using Clisp 2.30 on Win98)

If someone can show me an example, I would really appreciate it.

Wade Humeniuk

unread,
Oct 18, 2002, 7:43:40 PM10/18/02
to

"Andy Reiter" <and...@flop.co.uk> wrote in message
news:d4b78695.02101...@posting.google.com...

> Hi,
>
> I have two problems with my newbie lisping:
>
> 1)(with-open-file (input "C:/windows/intel/file.exe" :direction :input
> :element-type 'unsigned-byte)
> (do ( .. )
> ..
> (let ((byte (read-byte input)))
> (format t "not ~X = ~X" byte (bit-not byte)))))
>
> Gives me an error, saying 'byte' is a fixnum and not a bit array. How do I
> convert the read symbol into a bit-vector? COERCE is telling me to make 'byte'
> a sequence. Actually, I know how to go about the conversation (thanks to mod,
> shift and a carry-flag variable ;-) but there ought to be an standard way.
>

Take a look at the function boole

http://www.lispworks.com/reference/HyperSpec/Body/f_boole.htm

something like

CL-USER 5 > (boole boole-xor #xff #xff)
0

CL-USER 6 > (boole boole-xor #x00 #xff)
255

CL-USER 7 >

>
> 2) Is there any way to call C from Clisp or vice versa, on Windows? Both the
> impnotes and the sample code in $CLISP/modules are documenting the Unix module
> facility, and they all use the "clisp-link" utility which is nowhere in Win32.
> Also, the examples and the documentation talk about "clisp.a" and "clisp.h"
> which are nowhere in my system (I am using Clisp 2.30 on Win98)
>
> If someone can show me an example, I would really appreciate it.

Don't know.


--
Wade

Email: (format nil "~A@~A.~A" "whumeniu" "telus" "net")

Frode Vatvedt Fjeld

unread,
Oct 19, 2002, 4:36:23 AM10/19/02
to
and...@flop.co.uk (Andy Reiter) writes:

> [..] Gives me an error, saying 'byte' is a fixnum and not a bit


> array. How do I convert the read symbol into a bit-vector?

Maybe the question whose answer you really seek is "how do I perform
the bit-wise not operation on integers?" If so, the answer is to use
the function lognot.

--
Frode Vatvedt Fjeld

0 new messages