[gambit-list] Writing bytes, words, etc. directly to memory?
Marc Feeley
feeley at iro.umontreal.ca
Mon Nov 13 19:44:11 EST 2006
-----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-----
More information about the Gambit-list
mailing list