@ Terry Manipulating Constants
Hello Terry;
In using SX/B I frequently·need to manipulate some constants at compile time. They are static once the compilation is done.
So my need is to call a function or sub with·a constant, modified by operators as required. Unfortunately the compiler throws an "invalid number of parameters" error when it encounters the constant's manipulation operators.
I know there are work-arounds, but is it possible in the case of constants, to have the compliler pass-on the desired code to the assembler? The assembler is happy to deal with them and calculate the intended value.
Obviously the complier would not want to deal with figuring out what to do with variables subjected to manipulation, but I wondered if it could manage with constants???
Thanks for your consideration.
Cheers,
Peter (pjv)
·
In using SX/B I frequently·need to manipulate some constants at compile time. They are static once the compilation is done.
So my need is to call a function or sub with·a constant, modified by operators as required. Unfortunately the compiler throws an "invalid number of parameters" error when it encounters the constant's manipulation operators.
I know there are work-arounds, but is it possible in the case of constants, to have the compliler pass-on the desired code to the assembler? The assembler is happy to deal with them and calculate the intended value.
Obviously the complier would not want to deal with figuring out what to do with variables subjected to manipulation, but I wondered if it could manage with constants???
Thanks for your consideration.
Cheers,
Peter (pjv)
·
Comments
Can you give an example?
regards peter
Sub ReadFram takes 4 Parameters, variables or constants:
ReadFram (Addr << 2), Page, Dest, Qty
Where for a particular instance, Addr and Page are constants at compile time, and in another instance, all may be variables.
Cheers,
Peter (pjv)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John J. Couture
San Diego Miramar College
No, the only way would be to declare another constant.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There is a fine line between arrogance and confidence. Make sure you don't cross it...
·
Another way to handle this is by loading __param1 yourself,
__param1 = addr << 2
ReadFram __param1, Page, Dest, Qty
sxb will not load __param1 (because __param1 parameter is at the right position.)
I use this construct frequently in my libraries.
regards peter
Cheers,
Peter (pjv)