#34205 - beelzebub - Sat Jan 15, 2005 12:26 pm
This has nothing to do with the GBA, or the standard question about how to do inline asm - but it seemed like a good place to ask my question...
I'm using GCC on a non-standard embedded CPU, the memory layout of this chip uses segments and offsets (like in the old days of DOS programming) but the version of GCC I've been given does not support "far" pointers.
I've got a macro that uses inline assembler to retreive the segment of my const ROM based resources (graphics, sounds etc..) but I can only use it in code, either in an assignment or as an argument to a function.
But what I would like to be able to do is to make const data tables of the segments and offsets for the resources. But the macro I have now doesn't compile (gcc says "Parse error before asm") when uses in a const unsigned array.
this is my macro that works...
Which can be used thus:
So can anybody suggest how I can
I'm using GCC on a non-standard embedded CPU, the memory layout of this chip uses segments and offsets (like in the old days of DOS programming) but the version of GCC I've been given does not support "far" pointers.
I've got a macro that uses inline assembler to retreive the segment of my const ROM based resources (graphics, sounds etc..) but I can only use it in code, either in an assignment or as an argument to a function.
But what I would like to be able to do is to make const data tables of the segments and offsets for the resources. But the macro I have now doesn't compile (gcc says "Parse error before asm") when uses in a const unsigned array.
this is my macro that works...
Code: |
#define SEGMENT(_symbol) \
( { unsigned tmp; \ asm (" %0 = seg _" #_symbol "\n" \ : "=r"(tmp) \ : /*input*/ \ /* : clobber */ ); \ tmp; } ) |
Which can be used thus:
Code: |
void far_memcpy (unsigned dstseg,void *dstoffset, unsigned srcseg,void *srcoffset, unsigned length); far_memcpy (0,near_memory, SEGMENT (MY_RESOURCE),MY_RESOURCE, 42); |
So can anybody suggest how I can
Code: |
const unsigned resource_table [][2] = { { SEGMENT(MY_RESOURCE), &MY_RESOURCE }, }; |