Hello, for a program i'm translating from 68k to PPC i have a problem on a varargs function. Or better.. i have a lot of problems..
First of all: The original definition
The function in the old 68k program is called in this way:
Now. let's start with the various problems..
If i print them with a cycle:
my ti_tag values are wrong.. they not are the correct defined in the .h file
And this is the first problem.
My huge doubt is that one.. This function calls another function defined into a .library file that i've translated for ppc use and it calls the function in this way:
in the 68k version it use the tags passed into the stack using the pointer to the first tag:
for the ppc use i've changed them into:
So i think there is another problem. When the external library is called it packs the Tag parameters into TagItem like the previous one, indeed if i use the same cycle to print the ti_Tag, the first 4 values are correct, the TAG_MORE is printed as 2 (and it is correct) but the other parameters are always wrong.
So my question are:
1) Is the pack needed in the first function since i cannot pass the tags like the 68k version?
2) If i pack them can i avoid to repack them when my library receive the parameters?
3) is there a solution??
Hope i'm clear..
Thank you
struct aReq *CreateDummy(ULONG flags, Tag tag1, ...);
i've changed it to use VARARGS68K parameters. so now i have:
struct aReq * VARARGS68K CreateDummy(ULONG flags, Tag tag1, ...);
When i enter into the function as usual i try to pack them as TagItem using the va_start/va_end macro
va_list ap; struct TagItem *tags; va_startlinear(ap, tag1); tags = va_getlinearva(ap, struct TagItem *);
pr = CreateDummy(MYULONGFLAG, A_Title, MyTitle, A_Objects, MyObjects, A_Addresses, MyAddr, TAG_END);
if (tags) { Tag tag; while ((tag=tags->ti_Tag)) { printf("tags->ti_Tag=%lx - %d\n",tags->ti_Tag,tags->ti_Tag); tags++; } } va_end(ap);
pr = CreateLibDummy(A_Tag1, Taga1, A_Tag2, Taga2, A_Tag3, Taga3, A_Tag4, Taga4, TAG_MORE, &tag1); // no TAG_END required
pr = CreateLibDummy(A_Tag1, Taga1, A_Tag2, Taga2, A_Tag3, Taga3, A_Tag4, Taga4, TAG_MORE, tags); // note the tags variable