Positron8 4.0.6.4 / 18F56Q71: "LATD.0 = BitVar" gets no MOVLB (writes RAM 0x543,

Started by okmn, Today at 12:24 PM

Previous topic - Next topic

okmn

Hi Les,

I think I found a small bank-select problem. A 25-line example is attached (BANK_REPRO_56Q71.bas). It compiles OK (172 bytes).



' BANK_REPRO_56Q71 - minimal test for Positron8 4.0.6.4, okmn, 02 Oct 2026
' Compile only and open the .asm. Look at the two marked lines.
    Device = 18F56Q71
    Declare Xtal = 64

    Dim bFlag  As Bit
    Dim bCount As Byte

    ANSELD = 0
    TRISD  = 0
    LATD   = 0
    Do
        Inc bCount                      ' BASIC works in the variables' bank (5)
        If bFlag = 1 Then
            bFlag = 0
        Else
            bFlag = 1
        EndIf
        LATD.2 = bFlag                  ' (A) bit variable -> SFR bit, in-line
        GoSub Copy_Flag
        DelayMS 500
    Loop

Copy_Flag:
    LATD.0 = bFlag                      ' (B) bit variable -> SFR bit, first line after a label
    LATD.1 = 1                          ' (C) constant -> SFR bit (for comparison)
    Return

Positron8 4.0.6.4, Device = 18F56Q71. LATD is at 0x143 (bank 1), the variables are in bank 5.

From the .asm:

    movlb 0x05
    incf  bCount,F
    ...
; LATD.2 = bFlag            (A) bit variable -> port bit
    btfsc _B__VR1,0
    bsf   LATD,2            ; no MOVLB 1: BSR is still 5
    btfss _B__VR1,0
    bcf   LATD,2

Copy_Flag
; LATD.0 = bFlag            (B) same, first line after a label
    btfsc _B__VR1,0
    bsf   LATD,0            ; no MOVLB 1
    btfss _B__VR1,0
    bcf   LATD,0
; LATD.1 = 1                (C) constant -> port bit
    movlb 0x01              ; MOVLB is there
    bsf   LATD,1

With BSR = 5, bsf LATD,0 sets a bit in RAM 0x543, not the pin. I saw it on a real PIC18F56Q71 Curiosity Nano: the LED on RD0 never lit, and a string variable got one bit changed.

Workaround that works: If bFlag = 1 Then : LATD.0 = 1 : Else : LATD.0 = 0 : EndIf

Could you have a look? If it is already fixed in a newer update, sorry for the noise.(i could not buy lates version becaouse the Pay pal)

Thanks.

trastikata


okmn

Quote from: trastikata on Today at 12:26 PMHi,

current version is 4.0.6.5

hi ,
yes know .
but i could not buy it and i can not buy it becaouse we can not use paypal in Turkiye.
i am waiting a solution by Les to buy it.

▲