Writing bytes, words, etc. directly to memory?
In Gambit, what should I use to write 8-bit, 16-bit, and 32-bit values directly to memory in host byte order? Thanks, -a
Afficher les réponses par date
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 13-Nov-06, at 7:21 PM, Andrew Lentvorski wrote:
In Gambit, what should I use to write 8-bit, 16-bit, and 32-bit values directly to memory in host byte order?
You mean arbitrary peek/poke to an address? Marc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (Darwin) iD8DBQFFWQy3//V9Zc2T/v4RAkr3AJ9E2ythFpb/6umwEFuzyNW5VPbzsQCfXHJg dZxSPkd1tkyqWFE11vHHfPY= =vqaa -----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 13-Nov-06, at 7:27 PM, Andrew Lentvorski wrote:
Marc Feeley wrote:
You mean arbitrary peek/poke to an address?
Yes.
Some of the DS memory areas have restrictions on how they are used. Video memory cannot be accessed by byte operations, for example. It must be accessed by 16-bit or better.
Thanks, -a
Not fully tested: (define peek-u8 (c-lambda (unsigned-int32) unsigned-int8 "___result = *___CAST(___U8*,___arg1);")) (define poke-u8 (c-lambda (unsigned-int32 unsigned-int8) void "*___CAST(___U8*,___arg1) = ___arg2;")) (define peek-u16 (c-lambda (unsigned-int32) unsigned-int16 "___result = *___CAST(___U16*,___arg1);")) (define poke-u16 (c-lambda (unsigned-int32 unsigned-int16) void "*___CAST(___U16*,___arg1) = ___arg2;")) (define peek-u32 (c-lambda (unsigned-int32) unsigned-int32 "___result = *___CAST(___U32*,___arg1);")) (define poke-u32 (c-lambda (unsigned-int32 unsigned-int32) void "*___CAST(___U32*,___arg1) = ___arg2;")) (define vec '#(1 2 3)) (define enc (##object->encoding vec)) (define (hex n) (pp (number->string n 16))) (hex enc) (hex (modulo enc 4)) ; will be 1 (hex (peek-u32 (+ enc -1 4))) (hex (peek-u32 (+ enc -1 8))) (hex (peek-u32 (+ enc -1 12))) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (Darwin) iD8DBQFFWRFb//V9Zc2T/v4RAtSDAJ913RY8asmaedhsqAkZjOBNiFiEQACgjhEW 4AefJ4RMhqQUYe3G3OA1sD8= =IJhX -----END PGP SIGNATURE-----
participants (2)
-
Andrew Lentvorski -
Marc Feeley