Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.apple2.programmer > #5647

Re: calling tool version function outside the the normal calling

From Stephen Heumann <stephen.heumann@gmail.com>
Newsgroups comp.sys.apple2.programmer
Subject Re: calling tool version function outside the the normal calling
Date 2020-07-17 19:08 -0500
Organization A noiseless patient Spider
Message-ID <retehv$je$1@dont-email.me> (permalink)
References <b9da5922-d50f-4259-91f8-6f39dc156d44o@googlegroups.com>

Show all headers | View raw


On 2020-07-17 16:41:47 +0000, Chris Vavruska said:

> I am trying to load up a tool outside of LoadOneTool/ToolStartUp to get 
> the version of the tool.  The following code always returns zero. put a 
> BRK in it to trace into the function call and it appears it is calling 
> the right function but something on the return stack is being messed up 
> and the value is set to zero. My assembly skills are non existent so if 
> anyone has some pointers I'd appreciate it.

Your code is trying to call the tool's version call using the ORCA 
calling convention, which is different from the calling convention for 
tool calls.  I think you'll need to use at least some assembly language 
to call it properly.  Here's a version using inline assembly that I 
think should work:

word getToolVersion(GSString255Ptr path) {
    InitialLoadOutputRec loadInfo;
    word userID;
    WordProcPtr getVerMinus1;
    ptr *funcs;
    word toolVersion = 0;

    userID = GetNewID(0x5000);
    loadInfo = InitialLoad2(userID, (ptr) path, 1, 1);
    funcs = (ptr*) (loadInfo.startAddr);
    getVerMinus1 = (WordProcPtr*) (funcs[4]);

    asm {
        pea 0x0000          //result space
        phk                 //extra return address space (not used)
        pea ret-1
        phk                 //return address
        pea ret-1
        sep #0x20           //address to call (minus 1)
        lda getVerMinus1+2
        pha
        rep #0x20
        pei getVerMinus1
        rtl                 //call it
ret:    phk                 //clean up stack
        pla
        pla
        pla                 //get return value
        sta toolVersion
    }

    DisposeAll(userID);
    DeleteID(userID);

    return toolVersion;
}

-- 
Stephen Heumann

Back to comp.sys.apple2.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

calling tool version function outside the the normal calling Chris Vavruska <vavruska@gmail.com> - 2020-07-17 09:41 -0700
  Re: calling tool version function outside the the normal calling Steven Hirsch <snhirsch@gmail.com> - 2020-07-17 13:34 -0400
    Re: calling tool version function outside the the normal calling Chris Vavruska <vavruska@gmail.com> - 2020-07-17 11:04 -0700
      Re: calling tool version function outside the the normal calling Steven Hirsch <snhirsch@gmail.com> - 2020-07-17 14:46 -0400
        Re: calling tool version function outside the the normal calling "vavr...@gmail.com" <vavruska@gmail.com> - 2020-07-17 12:15 -0700
  Re: calling tool version function outside the the normal calling Stephen Heumann <stephen.heumann@gmail.com> - 2020-07-17 19:08 -0500
  Re: calling tool version function outside the the normal calling Chris Vavruska <vavruska@gmail.com> - 2020-07-17 17:45 -0700
    Re: calling tool version function outside the the normal calling Stephen Heumann <stephen.heumann@gmail.com> - 2020-07-17 20:07 -0500
  Re: calling tool version function outside the the normal calling Chris Vavruska <vavruska@gmail.com> - 2020-07-17 19:16 -0700
  Re: calling tool version function outside the the normal calling kelvin@pro-kegs.uucp (Kelvin Sherlock) - 2020-07-18 02:19 -0500
    Re: calling tool version function outside the the normal calling Stephen Heumann <stephen.heumann@gmail.com> - 2020-07-17 22:14 -0500
      Re: calling tool version function outside the the normal calling Chris Vavruska <vavruska@gmail.com> - 2020-07-18 05:19 -0700

csiph-web