Path: utzoo!attcan!uunet!mcsun!hp4nl!fwi.uva.nl!beemster From: beemster@fwi.uva.nl (Marcel Beemster) Newsgroups: comp.arch Subject: Re: RISC hard to program? Message-ID: <1139@carol.fwi.uva.nl> Date: 13 Jul 90 08:03:27 GMT References: <40088@mips.mips.COM> <2162@opus.cs.mcgill.ca> Sender: news@fwi.uva.nl Lines: 64 peterd@opus.cs.mcgill.ca (Peter Deutsch) writes: >unportable software, etc I would allege that that the SPARC >architecture appears to be inherently less forgiving of the >programmer than the 68k architecture. I keep receiving >reports of software that ran fine on machine 'x' (often >68k machines, Vaxen etc) but that either wont compile or >wont run on the Sun 4's. I have had this explained to me >Now to the question: First, is it true that SPARC is >inherently less forgiving? No, not always. The following program reflects a bug that actually occurred on software developed on a Sun-4. Things ran fine until the software was ported to a Sun-3: --------------- main() { pr3( "Hello" , "world" , "!\n" ) ; pr3( "This" , "is wrong" ) ; } pr3( s1 , s2 , s3 ) char *s1, *s2, *s3 ; { printf( "%s %s %s" , s1 , s2 , s3 ) ; } --------------End of program As you see, the second call to pr3() lacks one parameter. When run on a Sun-4, compiled with either -O or not, the output is: hello world ! This is wrong ! When run on a Sun-3, the output is: hello world ! This is wrong (null) Now you might argue that the Sun-3's answer is more correct than the Sun-4's, but in the abovementioned software the first call had left the correct parameter on the register stack for a subsequent call. Of course all this has more to do with parameter-passing conventions than RISC vs. CISC. Now this is just one counterexample. In general my feelings towards software development are: "If it runs on s SPARC, it runs everywhere", i.e., if you want to send reliable software out to the world, develop on a machine with a highly optimizing compiler, not one of those C-is-just-a-macro-assembler-kind-of-thing. >So, here's the clincher. My collegue claims there are NO C >programs that will: >a) Pass lint on the Sun 3 >b) Pass lint on the Sun 4 >c) Run, giving a "correct" answer on the Sun3, without crashing. >d) Either crash or give the "wrong" answer on the Sun 4. pr3: variable # of args. ts.c(9) :: ts.c(4) printf returns value which is always ignored ++marcel beemster@fwi.uva.nl "So they destroyed their planet, why?", "That was better for the economy..."