[z-machine] Replicating txd subroutine-finding functionality

Matthew T. Russotto mrussotto@speakeasy.net
Fri, 28 May 2004 15:22:24 -0400


On May 28, 2004, at 12:13 AM, Amir Karger wrote:

> Thanks for your informative reply.
>
> --- "Matthew T. Russotto" <mrussotto@speakeasy.net> wrote:

>> On May 20, 2004, at 11:18 PM, Amir Karger wrote:
>>
>> This is txd's approach -- it assumes if you jump ahead to an
>> address, it's within the subroutine.  The other thing it does is
>> examines the low area (below main, above the globals) and the high
>> area (between the highest located subroutine and the strings).
>
> Hm. Do you really mean "above the globals"?


Actually, I meant "above the dictionary".

> Oh wait. I just realized that by "contiguous", you probably mean that
> code *within one subroutine* is contiguous, i.e., they didn't put data
> inside a sub that gets jumped over.

Right.

> Unfortunately, it fares rather less well with Infocom. I've only tried
> it on minizork and zork1. On the former, it finds all the subs, but
> finds one extra "broken" sub, because minizork NEVER calls print_paddr
> with a constant address, only with variables!

Yeah, txd can't figure this out a priori either.  It just, as a last 
step, treats everything above its highest known subroutine as a 
subroutine and if it hits a 'broken' subroutine that's above all the 
known subroutines, it assumes it has hit the strings.

For extra reliability you might want to make it possible to e.g. scan 
known properties (based on a configuration file) for string and 
subroutine addresses.  Another thing you can do, which TXD doesn't, is 
locate non-code blocks based on immediate-mode loads in the code.