[Info-vax] Native compilers
Johnny Billquist
bqt at softjar.se
Wed Mar 9 10:27:58 EST 2022
On 2022-03-09 13:05, chris wrote:
> 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...
On a system where you ran on bare metal, it was rather safe, since such
low addresses is where interrupt vectors live. You don't want to put
much executable code down there.
But if you have an OS with an MMU, and so on, then all addresses from 0
and up are fair targets. I know, RT-11 wasn't in that class, but for
others, it might matter more... ;-)
And yes, I still program on PDP-11s whenever I have a spare moment.
There is nothing more fun...
Johnny
More information about the Info-vax
mailing list