CallTask parameter errors?

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
Post Reply
pjc30943
Posts: 220
Joined: 01 December 2005, 18:45 PM

CallTask parameter errors?

Post by pjc30943 »

The following code outputs

Code: Select all

ZBasic v2.5.5
param1=400.5366
param2=-60.06506
param3=4.168593E-08
param4=#.#

Anyone have thoughts as to why this may be? The 1k stack is overkill, but just to eliminate any possible stack issues...

Code: Select all

Option TargetCPU zx1280n

public const StackSize as integer = 1000
public Stack(1 to StackSize) as byte


Sub Main()
	sleep 0.5
	calltask Task(400.0, 1400.0, -60.0, 80.1), Stack			
End Sub


sub Task (byval param1 as single, byval param2 as single, byval param3 as single, byval param4 as single)
	debug.print "param1="; param1
	debug.print "param2="; param2
	debug.print "param3="; param3
	debug.print "param4="; param4
end sub
Paul
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: CallTask parameter errors?

Post by dkinzer »

pjc30943 wrote:Anyone have thoughts as to why this may be?
It turns out that there is a problem with the way that code is generated for task invocation with 4-byte constant parameters (e.g. UnsignedLong, Single) that would manifest when the upper two bytes of the parameter value were zero. There isn't any way to work around the problem other than to avoid letting the compiler see the constant values, i.e. by putting the parameter values in module-level variables.

I've posted an experimental version of the compiler that corrects that problem (and the one related to PulseOut). Note, particularly, that the .zip file contains an updated zxlib.h that must be placed in the zxlib subdirectory of the ZBasic installation directory.
- Don Kinzer
pjc30943
Posts: 220
Joined: 01 December 2005, 18:45 PM

Post by pjc30943 »

This fixes the issue. Thanks Don.
Paul
Post Reply