Compiling this code with last update :
dim my_var1 as byte dim my_var2 as word dim my_var3 as word
my_var1 = 100 my_var2 = 200
my_var3 = my_var1 - my_var2
now my_var3 should be -100, for a word variable it should be 35536-100= 35436. That is: my_var3_H=255, my_va3=156
But i have:my_var3_H=1, my_va3r=156 : my_var3 = 412
I think the hight byte calculation is not done correctly:
movf MY_VAR2,W subwf MY_VAR1,W movwf MY_VAR3 movf MY_VAR2_H,W btfss STATUS,C addlw 1 movwf MY_VAR3_H
If i force to do word calcs:
my_var3 = [word]my_var1 - my_var2
I have this error: Error [113] Symbol not previously defined (MY_VAR2_H).
I used this solution:
in gcbasic.bas, FUNCTION CompileCalcAdd(), line 2404->
'Get correct byte of V1
IF IsConst(V1) THEN
CurrLine = StringListInsert(CurrLine, " movlw " + GetByte(V1, 1))
V1H = GetCalcVar("BYTE")
CurrLine = StringListInsert(CurrLine, " movwf " + V1H)
FreeCalcVar V1 ElseIf V1Type = "BYTE" THEN '......................................................THIS OPTION ADDED V1H = GetCalcVar("BYTE") CurrLine = StringListInsert(CurrLine, " clrf " + V1H)
Else
V1H = GetByte(V1, 1)
END IF
If V2 is byte and V1 is word, there is no problem.
Sorry.. copy/paste error, when forcing to word, the error is with MY_VAR1_H not with MY_VAR2_H:
I have this error: Error [113] Symbol not previously defined (MY_VAR1_H).
Thanks for letting me know about that bug, I've uploaded another update which fixes it.
Ok.. working now... thanks.
Log in to post a comment.
Compiling this code with last update :
dim my_var1 as byte
dim my_var2 as word
dim my_var3 as word
my_var1 = 100
my_var2 = 200
my_var3 = my_var1 - my_var2
now my_var3 should be -100, for a word variable it should be 35536-100= 35436.
That is: my_var3_H=255, my_va3=156
But i have:my_var3_H=1, my_va3r=156 : my_var3 = 412
I think the hight byte calculation is not done correctly:
movf MY_VAR2,W
subwf MY_VAR1,W
movwf MY_VAR3
movf MY_VAR2_H,W
btfss STATUS,C
addlw 1
movwf MY_VAR3_H
If i force to do word calcs:
my_var3 = [word]my_var1 - my_var2
I have this error:
Error [113] Symbol not previously defined (MY_VAR2_H).
I used this solution:
in gcbasic.bas, FUNCTION CompileCalcAdd(), line 2404->
'Get correct byte of V1
IF IsConst(V1) THEN
CurrLine = StringListInsert(CurrLine, " movlw " + GetByte(V1, 1))
V1H = GetCalcVar("BYTE")
CurrLine = StringListInsert(CurrLine, " movwf " + V1H)
FreeCalcVar V1
ElseIf V1Type = "BYTE" THEN '......................................................THIS OPTION ADDED
V1H = GetCalcVar("BYTE")
CurrLine = StringListInsert(CurrLine, " clrf " + V1H)
Else
V1H = GetByte(V1, 1)
END IF
If V2 is byte and V1 is word, there is no problem.
Sorry.. copy/paste error, when forcing to word, the error is with MY_VAR1_H not with MY_VAR2_H:
If i force to do word calcs:
my_var3 = [word]my_var1 - my_var2
I have this error:
Error [113] Symbol not previously defined (MY_VAR1_H).
Thanks for letting me know about that bug, I've uploaded another update which fixes it.
Ok.. working now... thanks.