[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MiNT] how to compile stik/sting stuff with gcc4
Miro Kropacek wrote:
inet.c: In function 'inet_send':
inet.c:137: error: asm-specifier for variable 'retv' conflicts with asm
Oh, this header is huge.
Here are the instructions.
The file mint/osbind.h can be used as a model.
#define trap_1_w(n) \
register long retvalue __asm__("d0"); \
__asm__ volatile \
"movw %1,sp@-\n\t" \
"trap #1\n\t" \
"addql #2,sp\n\t" \
: "=r"(retvalue) /* outputs */ \
: "g"(n) /* inputs */ \
: __CLOBBER_RETURN("d0") "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \
1) Use the __CLOBBER_RETURN("d0") macro in the clobber list when the output
list contain a variable mapped to d0. It is the case here for the retvalue
variable, the compiler is told to allocate it in d0. GCC 2.x requires d0 to
be put in the clobber list, but GCC 4.x is clever enough to see it on
output, then it fails. The macro does the right thing with every compiler.
It is defined in include/compiler.h
Beware, if no output variable is mapped to d0, you must use "d0" alone
without the macro !
2) Look at the end of line character. "\n\t" is the standard, it produces a
perfectly aligned assembler source code when you use gcc -S. Perfect for
debugging. ";" like in your source is valid, too, but everything is put on a
single line, so it is unreadable.
It is usually better to avoid to put "\n\t" on the last line, here it is a
This change is not mandatory, it is only for the readability of the
intermediate assembler code.
3) Look at the multiline strings. In my example, two adjacent strings are
automatically concatened by the compiler, that's good. In your old file, the
string is opened at the beginning, it contains embedded newlines, then it is
closed at the end. This causes problems to something, I don't remember well,
if it is not GCC, it is the binutils. This should be fixed.
4) If you care about ColdFire, you should replace "addqw #8,sp" by "addql
#8,sp", which does exactly the same without performance loss, and which is
5) When the stack correction is >8, you should use "lea sp@(12),sp" instead
of "addw #12,sp", to be both faster and ColdFire compatible.
6) I see "a2" is missing from the clobber lists, is it really guaranteed
that it will never be trashed ?
7) The inline assembler use that horrible MIT syntax, however gas has been
supporting the normal Motorola syntax for ages.
Now, you have some work to do.