c files interacting in strange ways

Discussion of issues related to writing ZBasic applications for targets other than ZX devices, i.e. generic targets.
Post Reply
rich
Posts: 81
Joined: 19 November 2015, 12:23 PM

c files interacting in strange ways

Post by rich »

This is a strange bug i have created.

I use a 'c' function to calculate an unsigned long value with 64-bit unsigned integers.
There are two functions in two different files.
One file produces the the wrong value so i created another file that produces the correct results.
In order to get the correct results from the function that works i need to call both functions and use the correct results.
Both files are in the project list.
Somehow the the correct functions need the bogus function called, and the results discarded, to get the correct results.
It does not matter which order they are called but they both have to be called to get the correct results.
I guess the functions in two different file with different name interact with each other but i have not been able to find out how.

Any help would be greatly appreciated.

cheers,
rich
rich
Posts: 81
Joined: 19 November 2015, 12:23 PM

Re: c files interacting in strange ways

Post by rich »

I narrowed down the problem.
I put both function in the same .c file.
I started cutting out section of the function that does not need to be there but needs to be called.
It now converts an unsigned long int to an unsigned 64bit int. That's all it does, and does not use the result and returns 0.

This is very strange.

cheers,
Rich
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: c files interacting in strange ways

Post by dkinzer »

Offhand, I suspect that there may be a register usage issue but it is dangerous to speculate from a distance.

I'd be happy to take a look at the code if you would want to send it to me. I'm open to executing an NDA if necessary. Otherwise, it would be best to whittle the code down to the minimum that produces the unexpected result.
- Don Kinzer
rich
Posts: 81
Joined: 19 November 2015, 12:23 PM

Re: c files interacting in strange ways

Post by rich »

Don,
I will zip the files up and email them to you.
No NDA necessary this is hobby work and not original except i am using ZBasic.

cheers,
Rich
Post Reply