Discussion:
First cut of m68k support.
Anders Magnusson
2014-03-23 14:48:17 UTC
Permalink
Hi,

I have just added the beginning of 68k support.
It can generate enough code to put out "Hello world", which means that
the remaining to add it almost only instructions :-)

Took about 8 hours to get this far from scratch :-)

-- Ragge
Thorsten Glaser
2014-03-23 21:59:24 UTC
Permalink
Post by Anders Magnusson
I have just added the beginning of 68k support.
I have just added Linux/m68k support to it (initial, untested),
done on a Debian unstable/m68k system ;)
Post by Anders Magnusson
It can generate enough code to put out "Hello world", which means that the
remaining to add it almost only instructions :-)
Not for me:

***@ara4:~ # cat hw.c
#include <sys/types.h>
#include <unistd.h>

static const char msg[] = "Hello, World!\n";

int
main(void)
{
write(1, msg, 14);
return (0);
}
***@ara4:~ # /opt/pcc/bin/pcc -c hw.c
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 81: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 81: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 81: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 81: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 81: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 81: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 81: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 81: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 83: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 83: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 83: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 83: warning: shift larger than type
hw.c, line 9: compiler error: Cannot generate code, node 0x80062c54 op FUNARG
/opt/pcc/libexec/ccom terminated with status 1


Please share your testcase, so I can test better ☻

bye,
//mirabilos
--
22:20⎜<asarch> The crazy that persists in his craziness becomes a master
22:21⎜<asarch> And the distance between the craziness and geniality is
only measured by the success 18:35⎜<asarch> "Psychotics are consistently
inconsistent. The essence of sanity is to be inconsistently inconsistent
Anders Magnusson
2014-03-26 17:30:36 UTC
Permalink
Post by Thorsten Glaser
Post by Anders Magnusson
It can generate enough code to put out "Hello world", which means that the
remaining to add it almost only instructions :-)
#include <sys/types.h>
#include <unistd.h>
static const char msg[] = "Hello, World!\n";
int
main(void)
{
write(1, msg, 14);
return (0);
}
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 81: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 81: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 81: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 81: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 81: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 81: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 81: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 81: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 83: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 83: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 83: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 83: warning: shift larger than type
hw.c, line 9: compiler error: Cannot generate code, node 0x80062c54 op FUNARG
/opt/pcc/libexec/ccom terminated with status 1
Please share your testcase, so I can test better ☻
sun3$ uname -a
NetBSD sun3 6.1 NetBSD 6.1 (GENERIC)
sun3% echo 'main(){printf("Hello World\n"); }' > x.c
sun3% pcc -S x.c
sun3% gcc x.s
sun3% ./a.out
Hello World
Thorsten Glaser
2014-03-26 19:51:57 UTC
Permalink
Post by Anders Magnusson
Post by Thorsten Glaser
Please share your testcase, so I can test better ☻
sun3$ uname -a
NetBSD sun3 6.1 NetBSD 6.1 (GENERIC)
sun3% echo 'main(){printf("Hello World\n"); }' > x.c
sun3% pcc -S x.c
sun3% gcc x.s
sun3% ./a.out
Hello World
Okay, this translates to (with mksh as user shell):

***@ara4:~ # print -r -- 'main() { printf("Hello World\n"); return (0); }' >x.c
***@ara4:~ # /opt/pcc/bin/pcc x.c && ./a.out
Hello World
***@ara4:~ # size a.out ; file a.out
text data bss dec hex filename
794 244 8 1046 416 a.out
a.out: ELF 32-bit MSB executable, Motorola 68020, version 1 (SYSV), dynamically linked (uses shared libs), not stripped

So, working so far, on GNU/Linux and with my patch.
Still need to be able to use more/different test cases,
so I can test whether the csu files do what they’re
supposed to (I normally hack BSD, not Linux).

bye,
//mirabilos
--
Post by Anders Magnusson
Wish I had pine to hand :-( I'll give lynx a try, thanks.
Michael Schmitz on nntp://news.gmane.org/gmane.linux.debian.ports.68k
a.k.a. {news.gmane.org/nntp}#news.gmane.linux.debian.ports.68k in pine
Rob Landley
2014-03-24 03:21:25 UTC
Permalink
Post by Anders Magnusson
Hi,
I have just added the beginning of 68k support.
It can generate enough code to put out "Hello world", which means that
the remaining to add it almost only instructions :-)
Took about 8 hours to get this far from scratch :-)
What are you using to test this? (Laurent Vivier was working to get qemu
to emulate a mac q800 at one point, but it's been years since I've heard
from that. Alas, coldfire != full m68k...)

Rob
Thorsten Glaser
2014-03-24 08:22:07 UTC
Permalink
Post by Rob Landley
What are you using to test this?
Not Ragge, but: ARAnyM works decently.

https://wiki.debian.org/Aranym/Quick

Runs Debian/m68k, and probably NetBSD/atari.

bye,
//mirabilos
--
(gnutls can also be used, but if you are compiling lynx for your own use,
there is no reason to consider using that package)
-- Thomas E. Dickey on the Lynx mailing list, about OpenSSL
Anders Magnusson
2014-03-26 17:31:57 UTC
Permalink
Post by Rob Landley
Post by Anders Magnusson
Hi,
I have just added the beginning of 68k support.
It can generate enough code to put out "Hello world", which means that
the remaining to add it almost only instructions :-)
Took about 8 hours to get this far from scratch :-)
What are you using to test this? (Laurent Vivier was working to get qemu
to emulate a mac q800 at one point, but it's been years since I've heard
from that. Alas, coldfire != full m68k...)
I'm using TME with a fresh NetBSD install.

-- Ragge
David Given
2014-03-24 21:32:52 UTC
Permalink
On 3/23/14, 2:48 PM, Anders Magnusson wrote:
[...]
Post by Anders Magnusson
I have just added the beginning of 68k support.
It can generate enough code to put out "Hello world", which means that
the remaining to add it almost only instructions :-)
Took about 8 hours to get this far from scratch :-)
What's the emitted code quality like?

(I'm interested because I'm currently fighting LLVM trying to produce a
backend for a register-centric architecture I've got, and LLVM is
winning. At least it's not gcc, though.)
--
┌───  ───── http://www.cowlark.com ─────
│
│ "You cannot truly appreciate _Atlas Shrugged_ until you have read it
│ in the original Klingon." --- Sea Wasp on r.a.sf.w
Janne Johansson
2014-03-25 08:39:43 UTC
Permalink
Post by David Given
Post by Anders Magnusson
I have just added the beginning of 68k support.
Took about 8 hours to get this far from scratch :-)
What's the emitted code quality like?
Only on the internet... ;)
--
May the most significant bit of your life be positive.
Janne Johansson
2014-03-31 07:59:08 UTC
Permalink
Two openbsd m68k things and one reduce-nag-while-compiling-on-openbsd

Dunno what the snprintf availability expectation is everywhere, but it
seemed like it is used without #ifdefs on lots of other places.


Index: configure
===================================================================
RCS file: /cvsroot/pcc/configure,v
retrieving revision 1.106
diff -u -r1.106 configure
--- configure 28 Mar 2014 19:49:07 -0000 1.106
+++ configure 31 Mar 2014 07:52:54 -0000
@@ -2487,6 +2487,7 @@
vax) targmach=vax ;;
powerpc) targmach=powerpc endian=big ;;
sparc64) targmach=sparc64 endian=big ;;
+ m68k*) targmach=m68k endian=big ;;
x86_64) targmach=amd64 ;;
esac
;;
Index: cc/cxxcom/pftn.c
===================================================================
RCS file: /cvsroot/pcc/cc/cxxcom/pftn.c,v
retrieving revision 1.8
diff -u -r1.8 pftn.c
--- cc/cxxcom/pftn.c 22 Oct 2012 09:25:40 -0000 1.8
+++ cc/cxxcom/pftn.c 31 Mar 2014 07:52:54 -0000
@@ -842,7 +842,7 @@

if (name == NULL) {
static int ancnt;
- sprintf(nbuf, "__%%ANON%d", ancnt++);
+ snprintf(nbuf, sizeof(nbuf),"__%%ANON%d", ancnt++);
name = addname(nbuf);
}

Index: os/openbsd/ccconfig.h
===================================================================
RCS file: /cvsroot/pcc/os/openbsd/ccconfig.h,v
retrieving revision 1.11
diff -u -r1.11 ccconfig.h
--- os/openbsd/ccconfig.h 5 Aug 2012 14:35:00 -0000 1.11
+++ os/openbsd/ccconfig.h 31 Mar 2014 07:52:54 -0000
@@ -47,6 +47,9 @@
#define CPPMDADD { "-D__powerpc__", NULL }
#elif defined(mach_sparc64)
#define CPPMDADD { "-D__sparc64__", NULL }
+#elif defined(mach_m68k)
+#define CPPMDADD { "-D__mc68000__", "-D__mc68020__", "-D__m68k__",
NULL, }
+#define STARTLABEL "_start"
#else
#error defines for arch missing
#endif
Post by Anders Magnusson
Hi,
I have just added the beginning of 68k support.
It can generate enough code to put out "Hello world", which means that the
remaining to add it almost only instructions :-)
Took about 8 hours to get this far from scratch :-)
-- Ragge
_______________________________________________
Pcc mailing list
http://lists.ludd.ltu.se/cgi-bin/mailman/listinfo/pcc
--
May the most significant bit of your life be positive.
Iain Hibbert
2014-03-31 20:03:45 UTC
Permalink
Post by Janne Johansson
Two openbsd m68k things and one reduce-nag-while-compiling-on-openbsd
I committed them, thanks
Post by Janne Johansson
Dunno what the snprintf availability expectation is everywhere, but it
seemed like it is used without #ifdefs on lots of other places.
it is provided by compat code in mip/compat.c if not provided by the OS
Post by Janne Johansson
Index: configure
===================================================================
RCS file: /cvsroot/pcc/configure,v
retrieving revision 1.106
diff -u -r1.106 configure
--- configure 28 Mar 2014 19:49:07 -0000 1.106
+++ configure 31 Mar 2014 07:52:54 -0000
@@ -2487,6 +2487,7 @@
vax) targmach=vax ;;
powerpc) targmach=powerpc endian=big ;;
sparc64) targmach=sparc64 endian=big ;;
+ m68k*) targmach=m68k endian=big ;;
x86_64) targmach=amd64 ;;
esac
;;
Index: cc/cxxcom/pftn.c
===================================================================
RCS file: /cvsroot/pcc/cc/cxxcom/pftn.c,v
retrieving revision 1.8
diff -u -r1.8 pftn.c
--- cc/cxxcom/pftn.c 22 Oct 2012 09:25:40 -0000 1.8
+++ cc/cxxcom/pftn.c 31 Mar 2014 07:52:54 -0000
@@ -842,7 +842,7 @@
if (name == NULL) {
static int ancnt;
- sprintf(nbuf, "__%%ANON%d", ancnt++);
+ snprintf(nbuf, sizeof(nbuf),"__%%ANON%d", ancnt++);
name = addname(nbuf);
}
Index: os/openbsd/ccconfig.h
===================================================================
RCS file: /cvsroot/pcc/os/openbsd/ccconfig.h,v
retrieving revision 1.11
diff -u -r1.11 ccconfig.h
--- os/openbsd/ccconfig.h 5 Aug 2012 14:35:00 -0000 1.11
+++ os/openbsd/ccconfig.h 31 Mar 2014 07:52:54 -0000
@@ -47,6 +47,9 @@
#define CPPMDADD { "-D__powerpc__", NULL }
#elif defined(mach_sparc64)
#define CPPMDADD { "-D__sparc64__", NULL }
+#elif defined(mach_m68k)
+#define CPPMDADD { "-D__mc68000__", "-D__mc68020__", "-D__m68k__",
NULL, }
+#define STARTLABEL "_start"
#else
#error defines for arch missing
#endif
Post by Anders Magnusson
Hi,
I have just added the beginning of 68k support.
It can generate enough code to put out "Hello world", which means that the
remaining to add it almost only instructions :-)
Took about 8 hours to get this far from scratch :-)
-- Ragge
_______________________________________________
Pcc mailing list
http://lists.ludd.ltu.se/cgi-bin/mailman/listinfo/pcc
--
May the most significant bit of your life be positive.
iain

Loading...