On 7/17/20 12:41 PM, Chris Vavruska wrote:
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.
word getToolVersion(GSString255Ptr path) { InitialLoadOutputRec loadInfo; word userID; WordProcPtr getVer; ptr *funcs; word toolVersion;
userID = GetNewID(0x5000); loadInfo = InitialLoad2(userID, (ptr) path, 1, 1); funcs = (ptr*) (loadInfo.startAddr); getVer = (WordProcPtr*) (funcs[4]+1); toolVersion = getVer();
DisposeAll(userID); DeleteID(userID);
return toolVersion; }
What happens when you query the version inside the LoadOneTool/ToolStartUp environment?
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.
word getToolVersion(GSString255Ptr path) { InitialLoadOutputRec loadInfo; word userID; WordProcPtr getVer; ptr *funcs; word toolVersion;
userID = GetNewID(0x5000); loadInfo = InitialLoad2(userID, (ptr) path, 1,
1); funcs = (ptr*) (loadInfo.startAddr); getVer = (WordProcPtr*) (funcs[4]+1); toolVersion = getVer();
DisposeAll(userID); DeleteID(userID);
return toolVersion; }
On 7/17/20 2:04 PM, Chris Vavruska wrote:The application may or may not already have another version of the tool already loaded. I want to be able to compare the versions of two tool files.
On Friday, July 17, 2020 at 1:34:19 PM UTC-4, Steven Hirsch wrote:
On 7/17/20 12:41 PM, Chris Vavruska wrote:
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.
word getToolVersion(GSString255Ptr path) { InitialLoadOutputRec loadInfo; >>> word userID; WordProcPtr getVer; ptr *funcs; word toolVersion;
userID = GetNewID(0x5000); loadInfo = InitialLoad2(userID, (ptr) path, 1, >>> 1); funcs = (ptr*) (loadInfo.startAddr); getVer = (WordProcPtr*)
(funcs[4]+1); toolVersion = getVer();
DisposeAll(userID); DeleteID(userID);
return toolVersion; }
What happens when you query the version inside the LoadOneTool/ToolStartUp >> environment?
Good question....quickly verifies...It returns the correct version.Is there any reason you cannot query versions at initial load and cache them if needed later?
On Friday, July 17, 2020 at 1:34:19 PM UTC-4, Steven Hirsch wrote:
On 7/17/20 12:41 PM, Chris Vavruska wrote:
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.
word getToolVersion(GSString255Ptr path) { InitialLoadOutputRec loadInfo; >>> word userID; WordProcPtr getVer; ptr *funcs; word toolVersion;
userID = GetNewID(0x5000); loadInfo = InitialLoad2(userID, (ptr) path, 1, >>> 1); funcs = (ptr*) (loadInfo.startAddr); getVer = (WordProcPtr*)
(funcs[4]+1); toolVersion = getVer();
DisposeAll(userID); DeleteID(userID);
return toolVersion; }
What happens when you query the version inside the LoadOneTool/ToolStartUp >> environment?
Good question....quickly verifies...It returns the correct version.
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.
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 onthe 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.
word getToolVersion(GSString255Ptr path) {Hi Stephen,
InitialLoadOutputRec loadInfo;
word userID;
WordProcPtr getVer;
ptr *funcs;
word toolVersion;
userID = GetNewID(0x5000);
loadInfo = InitialLoad2(userID, (ptr) path, 1, 1);
funcs = (ptr*) (loadInfo.startAddr);
getVer = (WordProcPtr*) (funcs[4]+1);
toolVersion = getVer();
DisposeAll(userID);
DeleteID(userID);
return toolVersion;
}
Hi Stephen,
thanks for the code. Getting the following trying to compile.
134 phk //return address
^ invalid operand
136 sep #0x20 //address to call (minus 1)
^ invalid operand
asm { pha }
getVer();
asm { pla sta toolVersion }
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 onthe 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.
word getToolVersion(GSString255Ptr path) {
InitialLoadOutputRec loadInfo;
word userID;
WordProcPtr getVer;
ptr *funcs;
word toolVersion;
userID = GetNewID(0x5000);
loadInfo = InitialLoad2(userID, (ptr) path, 1, 1);
funcs = (ptr*) (loadInfo.startAddr);
getVer = (WordProcPtr*) (funcs[4]+1);
toolVersion = getVer();
DisposeAll(userID);
DeleteID(userID);
return toolVersion;
}
On 2020-07-18 02:19:51 +0000, Kelvin Sherlock said:
asm { pha }
getVer();
asm { pla sta toolVersion }
I don't think that will quite work, because Chris is trying to call a
tool call without using the tool dispatcher, so it is expecting space
on the stack for an extra return address. If you push/pull three extra
bytes to account for that, this approach may work, but it's a hack.
Chris, I tried the code I posted and it worked, so I'm not sure why
it's giving you problems (maybe issues with line endings?), but an alternative is to replace the "pea ret-1" instructions with:
lda #ret-1 // or "lda #ret", if you changed the label location
pha
--
Stephen Heumann
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 285 |
Nodes: | 16 (2 / 14) |
Uptime: | 64:21:23 |
Calls: | 6,488 |
Calls today: | 1 |
Files: | 12,096 |
Messages: | 5,274,794 |