Just an update on the procedure mechanism that I'm creating for the standard 8-bit Proton compiler....
Things are going well.... I've just finished updating the expression parser and procedures are now accepted within expressions:
Code:
Device = 16F1937
Declare Xtal = 32
Dim Global_MyFloat as Float
Proc RadToDeg(pRadians as Float), Float
Symbol c180DivPi = 180.0 / 3.14
Result = pRadians * c180DivPi
EndProc
Global_MyFloat = RadToDeg(120) / 2.0
Notice the local Symbol within the procedure. This will not be recognised anywhere else in the program, only within the procedure, but if there is a symbol outside the procedure, the contents will use that, so the code within a procedure can access global types as well. If the same name symbol or variable is used inside and outside (globally) the procedure, the code inside it will use the local symbol or variable, and ignore the global symbol or variable with the same name. i.e. Locals have precedence.
Also, String and Array returns are finished:
Code:
Device = 16F1937
Declare Xtal = 32
Dim Global_MyString as String * 32
Proc TestProc(), String * 32
Result = "Hello World"
EndProc
Global_MyString = TestProc()
I'm now busy adding the ByRef and BycRef code to the parameters, so indirect access of variables and flash memory can be done. It's equivalent to sending the parameter as the address of a variable, so the Ptr8, Ptr16, or Ptr32 commands can be used. Or the cPtr8, cPtr16, or cPtr32 commands if sending the address of Flash memory. i.e. Data tables.
It's been a struggle adding the procedures, and all that comes with them, in the main body of the compiler, without disturbing the compiler as it stands, but it really is starting to look good, and has been a joy to get back into the programming mode! It should be ready in a couple of weeks, so watch out for, future, true libraries for Proton, the same as Proton24 types.