Article View: comp.sys.atari.st
Article #26919Megamax WON'T compile .... structures passed to functions
From: gert
Date: Wed, 20 May 1987 10:43
Date: Wed, 20 May 1987 10:43
73 lines
2086 bytes
2086 bytes
In response to the denial of a few persons that Megamax won't accept
passing of structures to functions: The Megamax compiler will accept the C
code. It will not issue any warning, but the code it generates it
totally wrong!
This is the test program:
typedef struct {
int t1;
int t2;
} test;
main ()
{
test test;
ftest ( test );
}
ftest ( t )
test t;
{
t.t1 = 1;
t.t2 = 2;
}
Megamax disassembler V1.0, Copyright (C) 1986 by Megamax Inc.
CODE SEG "main"
main:/* global */
LINK A6,L$0
PEA -4(A6) !!! here main pushes the ADDRESS of the structure
test, when it should push the contents of it.
JSR ftest(PC)
ADDQ.L #4,A7
L1:
UNLK A6
RTS
L$0: .EQU #-4
_initargcv:/* global */
RTS
ftest:/* global */
LINK A6,L$2
MOVE #1,8(A6) !!! this would be t.t1 = 1, the ftest function
apparantly expects the structure to be on
stack, unfortunately only the address of the
structure is on the stack. (Bomb!!)
MOVE #2,10(A6)
L3:
UNLK A6
RTS
L$2: .EQU #0
This example was compiled with version 1.1 of the Megamax compiler.
I hope this makes clear that Megamax does not 'allow' structure passing.
In one of my previous message I said that Megamax would also not allow
declaration of variables somewhere in a function (not neccesarily at the
top). In that case I was wrong, sorry. I still think I remember reading
something to that extend in one of the manuals, but it may very well have
been for another C compiler.
Gert Poletiek.
Technical Details
Message-ID:
<280@nikhefh.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!rutgers!ames!hao!gatech!seismo!mcvax!nikhefh!gertShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!rutgers!ames!hao!gatech!seismo!mcvax!nikhefh!gert From: gert@nikhefh.UUCP Newsgroups: comp.sys.atari.st Subject: Megamax WON'T compile .... structures passed to functions Message-ID: <280@nikhefh.UUCP> Date: Wed, 20-May-87 06:43:06 EDT Article-I.D.: nikhefh.280 Posted: Wed May 20 06:43:06 1987 Date-Received: Thu, 21-May-87 07:15:37 EDT Organization: Nikhef-H, Amsterdam (the Netherlands). Lines: 73 Keywords: megamax