Thread View: gnu.gcc.bug
1 messages
1 total messages
Started by Mark Wagner
Tue, 27 Oct 1992 02:59
m68k vs. asm (bug?)
Author: Mark Wagner
Date: Tue, 27 Oct 1992 02:59
Date: Tue, 27 Oct 1992 02:59
31 lines
1247 bytes
1247 bytes
Given the following code on a 68k NeXT:
int getA() { return 5; }
int b = 10;
int p = 3;
int r;
main() {
int a = getA();
r = 0;
asm("movel %2,d0;mulsl %1,%0:d0;divsl %3,%0:d0":
"=d"(r): "dmsK"(a), "d"(b), "dmsK"(p), "0"(r): "d0");
printf("%d\n", r);
}
The "wrong" answer is produced when optimization is turned on.
The compile line is "cc -O foo.c -o foo".
The configuration is m68k-next-mach.
Version: ss-921018 (as well as straight 2.2.2)
Specifically, the result of the call to getA() is left in register
d0. It is immediately clobbered by the first instruction in the asm
("movel %2, d0") and then used in the second instruction of the asm
("mulsl %1, %0: d0"). Note that the register d0 is listed as being
clobbered by the asm statement.
The correct output is 2.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads