• Updated 2023-07-12: Hello, Guest! Welcome back, and be sure to check out this follow-up post about our outage a week or so ago.

C Compiler & 68k asm

megabyte

Well-known member
Does anyone knows a good assembler (with 020-030 support) and C compiler for classic Mac OS? I want to code at both languages simultaneously.

 

cheesestraws

Well-known member
Pretty sure both THINK C and CodeWarrior will do what you want here.  THINK C probably better on older/smaller machines, CodeWarrior on newer ones.

 

megabyte

Well-known member
As I read, Think C doesn't has a full assembler compiler. It is only supports an inline "asm" inserts in C code.

Retro68 is a very interesting project. But I am a newbie at 68k Mac development, so I cannot understand how to use (and where to get) classic Mac OS C-headers and libraries (object files?)

 

megabyte

Well-known member
My target is to try to code a simple 3D-engine with C-code framework, but all math routines should be written on 68k-asm.

 
Last edited by a moderator:

Crutch

Well-known member
As I read, Think C doesn't has a full assembler compiler. It is only supports an inline "asm" inserts in C code.
Well, that’s true.  But the asm{} blocks can be a whole function.  Your math routines could be written entirely in assembler with easy access to your C variables, struct offsets, etc. It’s really quite a good approach and is possibly the optimal approach for what I understand your use case to be, if you want your assembly functions readily callable from C anyway.  Details on THINK C asm blocks are on p. 250-ish of the THINK C 5 (white cover/red stripe, 1991) manual which I believe is available on vintageapple or similar.

If for some reason that’s not adequate (i.e. you absolutely need to write entire files of uninterrupted assembly code) then the standard (only?) Mac-native solution of the 020/030 era would be MPW, which has a steep learning curve.  In practice almost nobody was doing this by the early-mid ‘90s, though I’m sure there were exceptions.  In the ‘80s, of course, hand-coding 68k assembler in MDS or MacAsm was routine and awesome, or so I understand.

Retro68 is a very interesting project. But I am a newbie at 68k Mac development, so I cannot understand how to use (and where to get) classic Mac OS C-headers and libraries (object files?)
I haven’t used Retro68 but the C headers and libraries are of course included with any THINK C distribution and they may be linkable with Retro68?

 

cheesestraws

Well-known member
As I read, Think C doesn't has a full assembler compiler. It is only supports an inline "asm" inserts in C code. 
I mean, as @Crutch says, you can write whole functions in an ASM block, at which point the only "C" being compiled will result in the function prologues and epilogues.  If you want to call your ASM from the C, you will have to write this code yourself anyway so you may as well get the compiler to do it.  Even on routine boundaries in the assembler, you'll either need to use prologues/epilogues a la C functions or you'll need to come up with your own calling convention.  Do not fetishise assembler; there is nothing inherently good about it, especially for the boring code at the beginnings and ends of functions.

As someone who is coming to the end of a hybrid C/68k ASM project where I couldn't mingle C and ASM (because of the limitations of the compiler suite; see the GEMDOS thread in the Lisa subforum), I can assure you that being able to delegate that kind of thing to the C compiler is a good thing.  Having whole files of assembly routines looks cool but is an invitation to bugs.

Also: this gives you the ability to draft out your algorithms in C, and when they are correct but too slow, you can then translate them into ASM and optimise them by hand.

 

megabyte

Well-known member
Thanks all for the replies!

I had an experience (15 years ago) for coding gouraud shaded 3d engine for Amiga AGA with 030 and 060 processors. Yes, I did it on a similar way - drafting algos on C and optimizing that on 68k asm.

Does anybody knows if Think C supports 020-030 opcodes in its assembler compiler?

 

cheesestraws

Well-known member
Does anybody knows if Think C supports 020-030 opcodes in its assembler compiler?
I think it does.  I don't have the docs to check here, though. THINK C 5.0 is 1990, and that's 030 territory in terms of time, so I'd be quite surprised if it didn't.

 

Crutch

Well-known member
THINK C 5 supports 020 and 68881 instructions. Did the 030 add new opcodes? If so, they are not supported at least in version 5. They may be supported in newer versions or Symantec C++. 
 

This is on p. 254 of the manual btw :)  I just looked it up for you. 

 
Last edited by a moderator:
Top