[Info-vax] Native compilers

chris chris-nospam at tridac.net
Wed Mar 9 07:05:54 EST 2022


On 03/09/22 10:25, Johnny Billquist wrote:
> On 2022-03-09 01:53, chris wrote:
>> Here's an example of our function exit code idiom in macro 11:
>>
>> error: cmp (pc)+, pc;
>> ok:    clc;
>>        rts pc;
>>
>> Not obvious, but neat non the less...
>
> Yes. And that one is harmless, since it don't really matter when the
> autoincrement happens.
>
> But actually, I would not recommend that code, since it potentially can
> fail. The idea is that on error, you would return with carry set, but
> this is not at all guaranteed in that code. It depends on where in
> memory you'd have it. CLC is 241, so code below that address would get
> it wrong. Admittedly, most code don't live that low, but anyway...
>
> The more common way, in case you want to be "optimal" was/is:
>
> OK: TST (PC)+
> ERROR: SEC
> RTS PC
>
> TST always clear the carry.
>
> Johnny

Right, that was the alternate idiom we used, but never had any trouble
with the former on micropdp11 variants. RT11 single job, or foreground
background. Over 3 decades since any work on pdp11 but could drop back
into it with no trouble and still remember it as the most programmer
friendly architecture to work with. Sic transit gloria, indeed...

Chris



More information about the Info-vax mailing list