[Freemint-list] What's wrong with this code?

Miro Kropáček miro.kropacek at gmail.com
Thu Aug 17 16:10:09 MSD 2017


Calling all gcc experts :)

Unfortunately I noticed that this PR fails:
https://github.com/freemint/freemint/pull/65 too late (after Alan merged
it) because I had tested it only on the new gcc-7.1, forgetting the good
old 4.6.4.

The problem is this snippet from sys/xdd/uart/pc16550.c:

static IOVAR *intr_iovar [MAX_INTS];
static void pc16550_int (void);
...
        asm volatile
        (
                "_pc16550_int0:\n\t" \
                 "movem.l %%a0-%%a2/%%d0-%%d2,-(%%sp)\n\t" \
                 "move.l  %0,%%a0\n\t" \
                 "bsr     %1\n\t" \
                 "movem.l (%%sp)+,%%a0-%%a2/%%d0-%%d2\n\t" \
                 "rte"
                :                       /* output register */
                : "m" (intr_iovar), "m" (pc16550_int)   /* input registers
*/
                                        /* clobbered */
        );

For some reason, gcc 4.6.4 complains:

pc16550.c: In function 'pc16550_intx':
pc16550.c:1852:10: error: memory input 0 is not directly addressable
pc16550.c:1852:28: error: memory input 1 is not directly addressable

Before my change it was like this:

asm volatile
(
"_pc16550_int0:\n\t" \
"movem.l %%a0-%%a2/%%d0-%%d2,-(%%sp)\n\t" \
"move.l  _intr_iovar,%%a0\n\t" \
"bsr     _pc16550_int\n\t" \
"movem.l (%%sp)+,%%a0-%%a2/%%d0-%%d2\n\t" \
"rte"
: /* output register */
:   /* input registers */
/* clobbered */
);

but then gcc 7.1 was unhappy (couldn't see the external labels, what seems
to make sense as they are static).

Anyway, can anyone spot an error in the first method? Why 'm' wouldn't be
allowed here? 'g' works for instance but produces totally wrong result
("#_intr_iovar, ...").

-- 
MiKRO / Mystic Bytes
http://mikro.atari.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.atariforge.org/pipermail/freemint-list/attachments/20170817/d9ec0e01/attachment.html 


More information about the Freemint-list mailing list