Jump to content

C Compiler & 68k asm


Recommended Posts

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?)

Link to post
Share on other sites
  • 68kMLA Supporter
8 hours ago, megabyte said:

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.

Quote

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?

Link to post
Share on other sites
  • 68kMLA Supporter
10 hours ago, megabyte said:

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.

 

Link to post
Share on other sites

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?

Link to post
Share on other sites
  • 68kMLA Supporter
8 hours ago, megabyte said:

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.

Link to post
Share on other sites
  • 68kMLA Supporter

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. 

Edited by Crutch
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...