News:

;) This forum is the property of Proton software developers

Main Menu

Assembler errors with arrays of Longs

Started by kcsl, Feb 09, 2025, 01:04 PM

Previous topic - Next topic

kcsl

I'm getting assembler errors when I try and use an element of a LONG or DWORD array in an IF statement.

I've an array "Dim gx[6] As Long" near the top of the program.

If I try the line:
 IF gx[1] = 1 then stop

I get assembler error: Symbol not previously defined (PBS_VAR0HH)
This is the block of assembly:

F1_000637 EQU $ ; IN [E-PLUS V1.1.BAS] IF GX[RNBUF] = 1 THEN STOP
    MOVLB 0X06
RAM_BANK = 6
    MOVF RX_126208RNBUF,W
    MULLW 3
    MOVFF PRODL,FSR0L
    MOVFF PRODH,FSR0H
    MOVLW 0X91
    ADDWF FSR0L,F
    MOVLW 0X05
    ADDWFC FSR0H,F
    MOVFF INDF0,PBS_VAR0
    MOVFF PREINC0,PBS_VAR0H
    MOVFF PREINC0,PBS_VAR0HH    <<<<<<< HERE
    DECF PBS_VAR0,W
    IORWF PBS_VAR0H,W
    IORWF PBS_VAR0HH,W   <<<<<<<<< AND HERE
    MOVLB 0X05
RAM_BANK = 5
    BTFSS STATUS,2
    _MGOTO _LBL__58
_PBLB__59
    BRA _PBLB__59

If I change the array to byte or word, it's fine, and it only seems to be a problem in an IF statement. If I copy the element into a suitable variable and test that, everything's fine.

This is happening with the new and previous version of the compiler.
It's running on a PIC 18F27Q83 and currently using 9800 bytes of program space and 3141 bytes of RAM.

I did try writing a small program just to test and the compiler was perfectly happy with using longs in IF statements, so it looks like it's something to do specifically with my program.

Regards,
Joe


There's no room for optimism in software or hardware engineering.

trastikata

Hi kcsl,

"then stop" is missing an argument like "then stop = 50" or if Procedure "then stop()".

kcsl

Stop is a recognised BASIC instruction from the manual (page 357). It even gives the example of "If A > 12 Then Stop"

However, this will also give the same error:
IF gx[1] = 1 then x = x + 2

There's no room for optimism in software or hardware engineering.

trastikata

#3
Quote from: kcsl on Feb 09, 2025, 01:51 PMStop is a recognised BASIC instruction from the manual (page 357). It even gives the example of "If A > 12 Then Stop"

However, this will also give the same error:
IF gx[1] = 1 then x = x + 2

I see, I forgot about the Stop command, I get no error compiling this example:
Device = 18F27Q83
Declare  Xtal = 4
            
Dim gx[6] As Long
Dim x As Long

If gx[1] = 1 Then Stop
If gx[1] = 1 Then x = x + 2

Sometimes the error is somewhere else but the compiler gives the closest loop command as erroneous?

Edit. I have to wake up, missed a lot of information in your post, ignore what I've written.

trastikata

#4
Check in the beginning of your assembler code if PBS_VAR0 is declared as Word or Dword

P.s. Add this line to the program declares:

Dim PBS_VAR0 As Dword System

Not sure if it will work.

kcsl

There is only one occurrence: PBS_VAR0 EQU 0X504

The line is in this section:
; COMPILER SYSTEM VARIABLES
BPF EQU 0X500
BPFH EQU 0X501
GEN4 EQU 0X502
GEN4H EQU 0X503
PBS_VAR0 EQU 0X504
PBS_VAR0H EQU 0X505
PBS_VAR1 EQU 0X506
PBS_VAR1H EQU 0X507
PBS_VAR2 EQU 0X508
PP0 EQU 0X509

There's no room for optimism in software or hardware engineering.

trastikata

#6
It is created as word, add this line to the program declares:

Dim PBS_VAR0 As Dword System

Not sure if it will work.

Edit: It seems the compiler is trying to use a 2-byte variable in 3-byte Sub, something for Les I think.

kcsl

Actually it did work :)
Well, it compiles ok now... I will have to test if the program actually works.


There's no room for optimism in software or hardware engineering.

trastikata

Hope it worked as a temporary workaround.

kcsl, can you move this topic to the anomaly reports?

kcsl

I don't see a "move" button or anything like that
There's no room for optimism in software or hardware engineering.

trastikata

Don't know why but I thought you have admin privileges.

Do you mind if I open a new topic there?

kcsl

Please do.

Thanks for your help.

Joe
There's no room for optimism in software or hardware engineering.