Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!seismo!mcvax!nikhefh!gert From: gert@nikhefh.UUCP Newsgroups: comp.sys.atari.st Subject: Re: Megamax inline assembly woes (solution) Message-ID: <270@nikhefh.UUCP> Date: Wed, 6-May-87 05:41:36 EDT Article-I.D.: nikhefh.270 Posted: Wed May 6 05:41:36 1987 Date-Received: Fri, 8-May-87 01:35:36 EDT References: <8705030519.AA18707@ucbvax.Berkeley.EDU> <1058@bath63.ux63.bath.ac.uk> Reply-To: gert@nikhefh.UUCP (Gert Poletiek) Distribution: world Organization: Nikhef-H, Amsterdam (the Netherlands). Lines: 70 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