KIMMEL@ecs.umass.EDU (Matt Kimmel) (05/03/87)
I am writing a program in Megamax C, and I have a couple of functions that are written in machine language. Since the Megamax linker won't link normal .o files (and I don't have AS68, anyway), I am using the Megamax in-line assembler. However, it chokes on the following perfectly legal instructions which I use to save and restore the registers in the functions that are all machine language: movem.l d0-d7/a0-a6,-(sp) movem.l (sp)+,d0-d7/a0-a6 I got some weird error message like "Illegal constant expression" or some such. Anyway, this assembles fine under AssemPro. I've tried changing the d0-d7/a0-a6 to d0-a6, and the sp to a7, but to no avail. Could some- one tell me either how to do this under the Megamax assembler, or an alternate (fast) method of saving the registers? Thanks in advance. -Matt Kimmel KIMMEL@UMAECS <---BITNet KIMMEL@ECS.UMASS.EDU <---CSNet KIMMEL%ECS.UMASS.EDU@RELAY.CS.NET <---Internet
sc_dra@bath63.UUCP (05/05/87)
The registers have to be in upper case, i.e. A0, D3 etc. Also SP is not recognised so use A7 or put a #define SP A7 in your program. From memory the Megamax manual does mention the upper case requirement.
gert@nikhefh.UUCP (05/06/87)
In article <1058@bath63.ux63.bath.ac.uk> sc_dra@ux63.bath.ac.uk (Dave Allum) writes: > >The registers have to be in upper case, i.e. A0, D3 etc. Also SP is not >recognised so use A7 or put a #define SP A7 in your program. From memory >the Megamax manual does mention the upper case requirement. The registers must indeed be in upper case (and it says so in the manual). To make the assembler/compiler accept 'normal' assembly language use definitions like: #define sp A7 #define a0 A0 etc. Since the preprocessor, compiler, and assembler are one program this works perfectly. Using the same method you can also change the opcodes, like #define dbra dbf Something that is not (fully) covered in the manual is the way you can use assembler routines with C declarations: copy ( from, to, size ) char *from, *to; int size; { asm { movea.l from(a6),a0 movea.l to(a6),a1 move.w size(a6),d0 bra.s cpend cploop: move.b (a0)+,(a1)+ cpend: dbra cploop,d0 } } Or the same routine can be written as: copy ( from, to, size ) register char *from, *to; register int size; { asm { bra.s cpend cploop: move.b (from)+,(to)+ cpend: dbra cploop,size } } The inline assembly implementation is really the best part of the Megamax package. All the other parts contain one or more bugs. The Mark Williams package is far better, it implements K&R to the full, and the extensions like struct assignment, structs as function arguments, functions returning structs, enumerated type. The only thing it lacks is an in line assembly implementation like Megamax. Gert Poletiek
nowlin@ihuxy.ATT.COM (Jerry Nowlin) (05/07/87)
In article <270@nikhefh.UUCP>, gert@nikhefh.UUCP (Gert Poletiek) writes: > > The Mark Williams package is far better, it implements K&R to the full, > and the extensions like struct assignment, structs as function arguments, > functions returning structs, enumerated type. The only thing it lacks is > an in line assembly implementation like Megamax. > > > Gert Poletiek I have Megamax and while I haven't tried it yet the manual says that structure assignment and passing by value are supported. What else did you think was left out of Megamax? I have the devkit, Lattice and Megamax and wouldn't trade Megamax for both of the others put together. Jerry Nowlin (...!ihnp4!ihuxy!@o The
m5d@bobkat.UUCP (Mike McNally ) (05/08/87)
In article <8705030519.AA18707@ucbvax.Berkeley.EDU> KIMMEL@ecs.umass.EDU (Matt Kimmel) writes: > >movem.l d0-d7/a0-a6,-(sp) >movem.l (sp)+,d0-d7/a0-a6 > >-Matt Kimmel Register names have to be in upper case. Also, SP is not defined -- use A6. -- Mike McNally, mercifully employed at Digital Lynx --- Where Plano Road the Mighty Flood of Forest Lane doth meet, And Garland fair, whose perfumed air flows soft about my feet... uucp: {texsun,killer,infotel}!pollux!bobkat!m5d (214) 238-7474
braner@batcomputer.tn.cornell.edu (braner) (05/08/87)
[] I _love_ the Megamax in-line assembly, but look out for some bugs. (I found these in v1.0, I'm not sure if 1.1 still has them.) - Bcc.S sometimes generates code with the wrong displacement (i.e. branches to the wrong place). Especially when you use Bcc.S -#(PC) where # is an explicit number (why would you do that? - if you're patching code that came from a disassembler...) - DC.L # does not work: the constant # is interpreted as word-size. - Moshe Braner PS: wish they had a DS directive.
gert@nikhefh.UUCP (Gert Poletiek) (05/11/87)
In article <1959@ihuxy.ATT.COM> nowlin@ihuxy.ATT.COM (Jerry Nowlin) writes: >In article <270@nikhefh.UUCP>, gert@nikhefh.UUCP (Gert Poletiek) writes: >> >> The Mark Williams package is far better, it implements K&R to the full, >> and the extensions like struct assignment, structs as function arguments, >> functions returning structs, enumerated type. The only thing it lacks is >> an in line assembly implementation like Megamax. >> >> >> Gert Poletiek > >I have Megamax and while I haven't tried it yet the manual says that >structure assignment and passing by value are supported. What else did >you think was left out of Megamax? I have the devkit, Lattice and Megamax >and wouldn't trade Megamax for both of the others put together. > >Jerry Nowlin >(...!ihnp4!ihuxy!nowlin) I own the Lattice and Megamax compilers, used the devkit at work, and copied Mark Williams 2.01 from a friend to try it out. Now I'm looking for the fastest way to get MWC officially (if that's the word). Some of the things that Mark Williams will compile and Megamax will not: Passing a structure to a function: function ( var ) struct x var; /* notice the absence of the '*var' !! */ { ... } Function returning a structure: struct x function ( ... ) { struct x x; .... return ( x ); /* return a structure !! */ } Declaring variables both at the top of a function and in a loop: function ( ... ) { int x, y, z; .... while ( condition ) { register char *cp; /* <<< megamax won't allow this */ } } All of these things are not in the 'C programming language' by K&R, but they are additions made to the C language by K&R and are (as far as I know) documented for the first time in the Unix Programmer's Manual for version 7 Unix from Bell. It may be that these things are not really needed, but they make life a lot easier (sometimes). Now for the bugs in the Megamax package: - the optimizer will crash if you reference a label in assembly (inside a C function) but forget to declare it - sometimes the linker garbles a module taken from a library. - the librarian will crash if you try to create a library with more than about 115 modules in it. - the megamax guys don't know what initialized data is. - the resource generator crashes on complex object trees. - the resource generator does not allow you to create 'UserProc' objects These bugs in Megamax, and the fact that the Mark Williams package is very complete, make me choose for Mark Williams-C. Gert Poletiek
dillon@CORY.BERKELEY.EDU (Matt Dillon) (05/11/87)
:> :>movem.l d0-d7/a0-a6,-(sp) :>movem.l (sp)+,d0-d7/a0-a6 :> :>-Matt Kimmel : :Register names have to be in upper case. Also, SP is not defined -- :use A6. Don't you mean A7?? The above to items are a deficiency in the megamax assembler then. using SP to mean the stack pointer is standard, and motorola's assembler spec for the 68000 series says nothing about register names having to be in upper case. Somebody should get on Megamax's back to fix this. -Matt
peter@megamax.UUCP (Peter Taliancich) (05/12/87)
The problem that you are having with the move multiple instruction is due to the fact that register names must be capitalized. If you capitalize the register names your problem will go away. (i.e. asm { movem.l D0-D7/A0-A3, -(A7) } ) If you want to use the mnemonic `sp' for the stack pointer then all you have to do is to #define sp A7 asm { movem.l D0-D7/A0-A3, -(sp) } peter@megamax uucp: {texsun,killer,infotel}!pollux!megamax!peter voice: (214) 987-4931
dillon@CORY.BERKELEY.EDU.UUCP (05/12/87)
:Declaring variables both at the top of a function and in a loop: : :function ( ... ) :{ : int x, y, z; : : .... : while ( condition ) { : register char *cp; /* <<< megamax won't allow this */ : } :} This is standard C. If megamax doesn't allow it, megamax shouldn't be on the shelves. Every major programmer I know uses this construction. -Matt
john@viper.UUCP (05/12/87)
In article <940@bobkat.UUCP> m5d@bobkat.UUCP (Mike McNally (Man Insane)) writes: >In article <8705030519.AA18707@ucbvax.Berkeley.EDU> KIMMEL@ecs.umass.EDU (Matt Kimmel) writes: >> >>movem.l d0-d7/a0-a6,-(sp) >>movem.l (sp)+,d0-d7/a0-a6 >> >>-Matt Kimmel > >Register names have to be in upper case. Also, SP is not defined -- >use A6. Sorry Mike... Last time I looked, SP was A7, -not- A6... If Matt does what you told him to do, his programs will be toast... --- John Stanley (john@viper.UUCP) Software Consultant - DynaSoft Systems UUCP: ...{amdahl,ihnp4,rutgers}!{meccts,dayton}!viper!john
m5@bobkat.UUCP (05/14/87)
In article <272@nikhefh.UUCP> gert@nikhefh.UUCP (Gert Poletiek) writes: >Some of the things that Mark Williams will compile and Megamax will not: > >Passing a structure to a function: > >function ( var ) >struct x var; /* notice the absence of the '*var' !! */ >{ > ... >} False. It works. > >Function returning a structure: > >struct x >function ( ... ) >{ > struct x x; > .... > return ( x ); /* return a structure !! */ >} > False. It works. >Declaring variables both at the top of a function and in a loop: > >function ( ... ) >{ > int x, y, z; > > .... > while ( condition ) { > register char *cp; /* <<< megamax won't allow this */ > } >} > False. It works. >Gert Poletiek What version were you using? I have (in the past five minutes) tried all of these things, and they do work. Honest. I'm using a recent version, NOT the pre-release. -- Mike McNally, mercifully employed at Digital Lynx --- Where Plano Road the Mighty Flood of Forest Lane doth meet, And Garland fair, whose perfumed air flows soft about my feet... uucp: {texsun,killer,infotel}!pollux!bobkat!m5 (214) 238-7474
m5@bobkat.UUCP (05/15/87)
In article <966@viper.UUCP> john@viper.UUCP (John Stanley) writes: >In article <940@bobkat.UUCP> m5d@bobkat.UUCP (Mike McNally (Man Insane)) writes: > >Register names have to be in upper case. Also, SP is not defined -- > >use A6. > > Sorry Mike... Last time I looked, SP was A7, -not- A6... > > If Matt does what you told him to do, his programs will be toast... > >--- >John Stanley (john@viper.UUCP) Sorry about that. I had a headache. -- Mike McNally, mercifully employed at Digital Lynx --- Where Plano Road the Mighty Flood of Forest Lane doth meet, And Garland fair, whose perfumed air flows soft about my feet... uucp: {texsun,killer,infotel}!pollux!bobkat!m5 (214) 238-7474
sc_dra@bath63.UUCP (05/15/87)
In article <940@bobkat.UUCP> m5d@bobkat.UUCP (Mike McNally (Man Insane)) writes: >In article <8705030519.AA18707@ucbvax.Berkeley.EDU> KIMMEL@ecs.umass.EDU (Matt Kimmel) writes: >> >>movem.l d0-d7/a0-a6,-(sp) >>movem.l (sp)+,d0-d7/a0-a6 >> >>-Matt Kimmel > >Register names have to be in upper case. Also, SP is not defined -- >use A6. > The stack pointer is register A7.
sc_dra@ux63.bath.ac.uk (Dave Allum) (05/18/87)
In article <8705120723.AA17281@cory.Berkeley.EDU> dillon@CORY.BERKELEY.EDU (Matt Dillon) writes: >:Declaring variables both at the top of a function and in a loop: >: while ( condition ) { >: register char *cp; /* <<< megamax won't allow this */ >: } > This is standard C. If megamax doesn't allow it, megamax shouldn't >be on the shelves. Every major programmer I know uses this construction. Megemax _does_ allow this - just checked it out (must confess I didn't realise it was standard C until now). I have V1.1 so I guess it could have been a problem with the earlier release. Anyone still on V1 care to check it? Dave Allum.
greg@xios.XIOS.UUCP (Greg Franks) (05/20/87)
In article <963@bobkat.UUCP> m5@bobkat.UUCP (Mike McNally (Man from Mars)) writes: |In article <966@viper.UUCP> john@viper.UUCP (John Stanley) writes: | >In article <940@bobkat.UUCP> m5d@bobkat.UUCP (Mike McNally (Man Insane)) writes: | > >Register names have to be in upper case. Also, SP is not defined -- | > >use A6. | > | > Sorry Mike... Last time I looked, SP was A7, -not- A6... | > | > If Matt does what you told him to do, his programs will be toast... | > | >--- | >John Stanley (john@viper.UUCP) | |Sorry about that. I had a headache. | Perhaps you have a PDP-11 ??? -- Greg Franks (613) 725-5411 "Vermont ain't flat" {net-land}!utzoo!dciem!nrcaer!xios!greg (Other paths will undoubtably work too - your mileage will vary)