C++ problem (was Question about DAT variables)
David Betz
Posts: 14,516
Should this code work? In particular, is this statement okay for referencing the "mailbox" variable in the DAT section? The value of that variable gets patched to the address of the mailbox before I load this code so it should have a valid address by the time this code runs.
This is the code I'm wondering about. Will it fetch the 32 bits that are pointed to by "mailbox" and assign it to "params"? The reason I'm asking is that I seem to be getting the wrong value in "params".
Here is the full code:
Edit: Added @ in front of the mailbox references. That didn't fix the problem though.
This is the code I'm wondering about. Will it fetch the 32 bits that are pointed to by "mailbox" and assign it to "params"? The reason I'm asking is that I seem to be getting the wrong value in "params".
repeat while (params := long[mailbox]) == 0
Here is the full code:
' This file was generated by spinwrap. Do not edit! OBJ x : "test" PUB dispatch | params, object, index, arg1, arg2, arg3, arg4 repeat repeat while (params := long[@mailbox]) == 0 longmove(@object, params, 6) case index 0: result := x.set_pin({pin} arg1) 1: result := x.set_pins({pin1} arg1, {pin2} arg2) 2: result := x.swap_pins 3: result := x.show_pins 4: result := x.blink other: result := -1 long[params] := result long[@mailbox] := 0 DAT mailbox long 0
Edit: Added @ in front of the mailbox references. That didn't fix the problem though.
Comments
I'm working on a sign controller that holds patterns and their addresses in a table; here's a portion:
The operational code that fetches starting location of a specific pattern (I use p_ to preface pointer variables):
Finally, the bits from a step in the pattern are retrieved with:
The variable p_pats gets incremented (by 4) for every step.
Enjoy!
Mike
This code seems to work correctly:
But this fails by passing a bad value in params[1]: Adding the printf seems to make the program work. I'm not sure why. Here is the declaration of the class containing this method:
The code was compiled with the following command line: