• Hello, Guest! Welcome back, and be sure to check out this post for more info about the recent service interruption and migration.

Why and How to build your own Chooser Extension

Crutch

Well-known member
Yes, I’ve also never used Symantec C 8 but as it includes a 68k compiler I would strongly expect it to include the capabilities cheesestraws mentions.

Any professional grade vintage Mac compiler that cold produce 68k code included this capability,.
 

ymk

Well-known member
Thanks for the reply. I think I understand now; each THINK C 5 project makes at most one code resource. It was easy enough to compile a code resource I could load and execute from another project.

Symantec C(++) 8 works differently. A code resource project is a template of nested projects rather than a discrete project type. The child project produces an application and the parent project uses a couple .r files to pull the instructions from it and build a fat code resource based on a resource template.
 

cheesestraws

Well-known member
The child project produces an application and the parent project uses a couple .r files to pull the instructions from it and build a fat code resource based on a resource template.

Wow, that sounds extraordinarily complicated for quite a simple job.
 

ymk

Well-known member
I'm figuring out the SetUpA4.h stuff which seems to be exclusive to THINK C. Looks like any non-application project will set up an "A4 world", where code resource globals are addressed relative to A4.

I assume any functions I call must be set up the same way, so I'm linking against ANSI-A4.

The naming of the __GetA4() function doesn't make sense to me, since it's just moving the address of a long in code space, to A1.

There are RememberA4() and RememberA0() macros in SetUpA4.h. What is the significance of A0? Is it specific to Pascal?

I found this in the THINK C manual. Is the "move function" supposed to be "jsr function"?

1651712902107.png
 

Crutch

Well-known member
SetUpA4.h is awesome. It lets you write code resources using global data with no fuss, no muss in code resources, across Toolbox callbacks and trap patches.

__GetA4() indeed moves the address of a long in code space to A1 ... but that is the address where RememberA4() will stick A4! Think of that function name as meaning "get the place where A4 is/will be stored and stick it into A1".

Remember to include SetUpA4.h separately in each file where it is needed, and to call RememberA4() once separately from each such file at a time when A4 is known to be good.

RememberA4() is for drivers (the THINK C driver glue initializes A4 for you) and RememberA0() is for other types of code resources (on entry, A0 points to the code resource). You use SetUpA4() and RestoreA4() either way, once you've noted either A0 or A4 appropriately for later recall. This is explained in the THINK C manual (look up "RememberA0" in the index).

And yes, looks like you found a typo in that assembly code fragment.
 

ymk

Well-known member
`Thanks for the reply. There was much fuss and muss until I set A0 correctly...

1651973007552.png
Since I'm not using the standard header, I needed this at 0x10:

Code:
LEA header, A0
JMP main

Is there a way to get printfs working with ANSI-A4?
 
Last edited:

ymk

Well-known member
LEA header, A0

To avoid confusing others, the above is for a non-chooser code resource. If I'm derailing this thread, I can start another.

Trying THINK C 5,6 and (Symantec C++) 8 for this purpose, 6 is the sweet spot, taking all the good points of 5 and adding wider object compatibility.

8 is slow, insists on generating PPC/fat code, even for 68K projects, creates a separate code resource for each source, doesn't allow manual segment assignment and relies on Rez scripts which make custom headers difficult.
 
Last edited:

Crutch

Well-known member
Why aren’t you using the standard header, just curious? I have never not used the standard header. I think.
 

ymk

Well-known member
Why aren’t you using the standard header, just curious? I have never not used the standard header. I think.

I wasn't sure what the standard header was doing with A0, so I switched to custom.

Standard is probably fine and I may revert to it later.
 
Top