If I compile the following code with the 3/06/12 update the word variables get converted to longs.
#chip 18F27J13, 8
#config OSC = INTOSC, WDTEN = OFF, ADCSEL = BIT12
'dim ADresult as word alias ADRESH, ADRESL
dim resistor, ref10k, ref100k, ref1M as word
dim thermistor, testResistance as long
This is a section of the assembly file with all the word variables taking up 4 locations.
;Set aside memory locations for variables
REF100K EQU 1
REF100K_H EQU 2
REF100K_U EQU 3
REF100K_E EQU 4
REF10K EQU 5
REF10K_H EQU 6
REF10K_U EQU 7
REF10K_E EQU 8
REF1M EQU 9
REF1M_H EQU 10
REF1M_U EQU 11
REF1M_E EQU 12
RESISTOR EQU 13
RESISTOR_H EQU 14
RESISTOR_U EQU 15
RESISTOR_E EQU 16
TESTRESISTANCE EQU 17
TESTRESISTANCE_H EQU 18
TESTRESISTANCE_U EQU 19
TESTRESISTANCE_E EQU 20
THERMISTOR EQU 21
THERMISTOR_H EQU 22
THERMISTOR_U EQU 23
THERMISTOR_E EQU 24
The problem goes away if you dimension all the long variables on individual lines or dim the words after the longs. Aliased word variables are also affected - they don't get an alias in the assembly file and an error is generated if its assigned to another variable.
Can someone else confirm this behaviour?
That's definitely a bug! I've uploaded a slightly changed update.zip that should fix it.
The problem occured when reading the Dim command. When there are multiple variables on a line, GCBASIC splits up the list at the commas, stores each name in an array, and then adds them individually. The only problem is it wasn't clearing the list properly, so each Dim command was adding not only the variables from that command, but the variables from any lines before it.
Alias variables won't be listed in the assembly file unless they are accessed somewhere in the code. If you add something to the program that uses the alias, the aliases should appear in the assembly. (This is something I'll probably add for normal variables in the future. For aliases it's pretty pointless, but for other variables it's a way to save RAM in the event of a variable being declared but not used.)
There is one more difficult problem though, and that is the chip data file for the 18F27j13. It seems to be missing the information on what config words are present on the chip. I haven't quite got time now, but I'll try to fix those up some time in the next few days. Until then you'll need to either set the configuration manually with the programmer or look for a similar PIC and copy over the relevant section of the chip data. Sorry about that!
Thanks Hugh. That was a mighty quick fix.
I'd cobbled together a config section for the 18F27J13 but then forgot about it not being a good choice for the code example.