<div dir="ltr">Man, you should've asked. "Check the compiler flags" would've been the first thing I thought of.</div><br><div class="gmail_quote"><div dir="ltr">On Sat, Dec 29, 2018 at 9:51 PM Elliot Nunn <<a href="mailto:elliotnunn@fastmail.com">elliotnunn@fastmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Like Max, I had a bit of a code-generation problem last night. Thought<br>
I'd share it for your entertainment.<br>
<br>
As a big part of getting a System build to work, I am recreating the<br>
makefiles for the Process Manager. The Process Mgr has a very novel<br>
runtime (it actually gets loaded from 'scod' resources by the Segment<br>
Loader). With not many clues around about how to build it, I decided<br>
that I should take a deep dive at this point and get it round-tripping.<br>
System 7.1 seems to be a good fit.<br>
<br>
For context, the build is currently producing about 1/2 to 2/3 of a<br>
System file, albeit of dubious quality.<br>
<br>
Here is the function in question.<br>
<br>
/* CheckUnitTableEntry. See if the UNITTABLE entry that this driver would occupy<br>
* is acceptable. For now, just checks whether entry is already in use.<br>
*/<br>
OSErr<br>
CheckUnitTableEntry(short resourceID)<br>
{<br>
register DCtlPtr dCtlPtr;<br>
DCtlHandle dCtlHdl;<br>
OSErr result;<br>
<br>
result = noErr;<br>
dCtlHdl = (DCtlHandle) UNITTABLE[resourceID];<br>
if ( (dCtlHdl != nil) && ((dCtlPtr = *dCtlHdl) != nil) && ((dCtlPtr->dCtlFlags & DOpened) != 0) )<br>
result = portInUse;<br>
<br>
return(result);<br>
}<br>
<br>
UNITTABLE is defined as (*(Handle **)(0x11C))<br>
<br>
The unit table access was compiling to "EXT.L D0; MOVE.L $11C,A0; MOVE.L<br>
$0(A0,D0.L*4),A3" when I wanted "EXT.L D0; MOVE.L $11C,A0; ASL #2,D0;<br>
MOVE.L $0(A0,D0.L),A3". I fought with this until 1 am, changing headers,<br>
types and compiler versions to no avail. I found that the same motif<br>
appears in two or three places in that segment, and the ASL persists up<br>
to System 7.1.2, after which it was refactored out of existence.<br>
<br>
This morning I was about to email the list for help, when in a testament<br>
to the "starting really hard at a problem" methodology, the answer came<br>
to me. "MOVE.L $0(A0,D0.L*4),A3" is a very fancy-looking addressing<br>
mode, I thought. It wouldn't work on a vanilla M68k... Oh! System 7.1<br>
*does* run on a 68000, because it supports the Plus and Classic. (I<br>
should know, because I grew up using it on a Classic.) The C compiler<br>
was being run with the -mc68020 argument because I copied the makefile<br>
from the ROM build. Now fixed!<br>
_______________________________________________<br>
cdg5 mailing list<br>
<a href="mailto:cdg5@ucc.asn.au" target="_blank">cdg5@ucc.asn.au</a><br>
<a href="https://lists.ucc.gu.uwa.edu.au/mailman/listinfo/cdg5" rel="noreferrer" target="_blank">https://lists.ucc.gu.uwa.edu.au/mailman/listinfo/cdg5</a><br>
</blockquote></div>