from spin to C , how to translate this address ?
laurent974
Posts: 77
I'm trying to convert the code for the OLED 128 from spin to C.
the function Fxn takes only 3 parameters:
- nb of arg
- command
- first adress of argument
With that it can be called with higher function with several parameter. see code below with function Drawcircle
How can it be translated correctly to C ?
this line cause me some problem :
the function Fxn takes only 3 parameters:
- nb of arg
- command
- first adress of argument
With that it can be called with higher function with several parameter. see code below with function Drawcircle
How can it be translated correctly to C ?
this line cause me some problem :
SendData(long[ArgAddress][index++])
pri Fxn(argCount,Command,ArgAddress)|index SendData(Command) index := 0 repeat argCount SendData(long[ArgAddress][index++]) ''Main Function to communicate with various methods result := ser.CharIn ''associated with the uOLED display pub DrawCircle(X,Y,R,Co) {{ Description: draws a circle with center at X,Y with radius R using the specified color }} _Ack := Fxn(4,Cmd_gfx_Circle,@X) pri SendData(Data) ''Send Word variable to the uOLED display ser.char(Data.byte[1]) ser.char(Data.byte[0])
Comments
which used the 'spin2cpp' executable to produce the following output from your code fragment:
To simplify the above output I removed references to the 'ser' object and the content of the SendData routine in the Spin code before conversion, so you can see more clearly the answer to your specific question regarding the 'SendData' statement.
The Spin Converter is a great tool to convert Spin code into either PASM or C, even if you just want to see how the resulting code looks for your own understanding/knowledge. Give the converter a try...
i gave a try of this tool, and it's really impressive. there's still left a lot of rework after the first pass. But it helps a lot for pointer conversion.
[EDIT]: The accurate translation in C is with VA_Arg.