Those of a delicate disposition should avert their eyes from this
post, because I am asking for the best, I hesitate to say official,
way to do a dirty coercive hack with C code.
BBC BASIC conflates addresses with integers. Alas, there is no way
to communicate with RISC OS SWIs without doing this. I tried to do
this in early versions of RiscLua, but eventually found it more
practical to adopt the evil ways of BBC BASIC. Using the Norcroft
C compiler and Objasm my method basically consisted of having
a piece of assembler code
AREA HACK
EXPORT hack
hack MOV PC, R14
END
with a header file containing
extern void *hack(int n);
You get the idea? It means wasting time with an extra call to an identity
function. I have just been reading up on GCC's inline assembler
and I find that its syntax has been designed to thwart this kind of
cavalier behaviour with types. Obviously I should be using a macro to avoid
unnecessary function calls. But what is the pukka way to do the hack?
--
Gavin Wraith (gavin@wra1th.plus.com)
Home page: http://www.wra1th.plus.com/
_______________________________________________
GCCSDK mailing list gcc@gccsdk.riscos.info
Bugzilla: http://www.riscos.info/bugzilla/index.cgi
List Info: http://www.riscos.info/mailman/listinfo/gcc
Main Page: http://www.riscos.info/index.php/GCCSDK
No comments:
Post a Comment