[Info-vax] Native compilers
Johnny Billquist
bqt at softjar.se
Wed Mar 9 05:25:11 EST 2022
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
More information about the Info-vax
mailing list