Log in

View Full Version : Can't send a Reserved Word to math coprocessor



bluesmoke
- 5th October 2009, 18:04
I am sending instructions from my 16f887 to a uM-FPU V3 32-bit floating point coprocessor. All works well until I try to do trig and must send commands that use the words SIN or COS. Since these are reserved words the program refuses to compile.

The details:

The instruction set I am trying to send from Pic to coprocessor:
SHIFTOUT FpuOut, FpuClk, MSBFIRST, [SELECTA, p1, LEFT, FSET, Lon2, FSUB, Lon1, SIN, RIGHT, FSET0, LEFT, FSET, Lat2, COS, RIGHT, FMUL0]


The problem is that the FPU chip needs "SIN" and "COS" as part of its instructions. Microcode studio gives me error 239 when compiling because these are reserved words.

Does anyone see a workaround for this problem?

Thanks.

HenrikOlsson
- 5th October 2009, 18:25
Aren't all the commands just OPCodes, ie each command "name" is assigned a constant value at the beginning of the program, like:


SIN CON $47
COS CON $48

A workaround would be to simply rename the SIN and COS to SINUS and COSINUS and assign the correct OPCode to that name instead, like:

SINUS CON $47
COSINUS CON $48
Then you use SINUS and COSINUS in the Shiftout statment instead of SIN and COS

Another workaround is to simply replace the the constants SIN and COS in the Shiftout statement with their respective OPCodes.

/Henrik.

bluesmoke
- 5th October 2009, 19:15
Well, when you put it that way it just sounds so simple....

Thanks for your help Henrik. I'm sure that'll work.

camtmicromega
- 5th October 2009, 23:44
The support files for using the uM-FPU V3.1 chip with PicBasic Pro already have definitions for all the opcodes. Any opcode that conflicts with a reserved word has an F_ prefix. e.g. SIN is F_SIN, COS is F_COS, etc.

See any of the support files for a full list of the opcode definitions.
e.g. template-spi.bas or template-i2c.bas

The PBP support files are at:
http://www.micromegacorp.com/downloads.html