#2244 divuchar and moduchar access 0x7f didn't switch bank


I am working on an open source project, an IDE for SDCC. And emulator for mcs51/pic16/pic18.

Here is the github address:

I found divuchar and moduchar access 0x7f didn't switch bank.

Here is the sample code.

include <pic16f628a.h>

void main(void)
unsigned char i;
for (i = 3; i < 16; i++)
PORTA = i % 3;
PORTB = i / 3;

0000D2 1283 bcf STATUS,5 <--- here had switch to bank 2
0000D3 1703 bsf STATUS,6
0000D4 00AC movwf 0x2c
0000D5 087F movf 0x7f,w <--- STK00 is at 0x7f
0000D6 00AD movwf 0x2d
0000D7 01AE clrf 0x2e
0000D8 3001 movlw 0x1
0000D9 00AF movwf 0x2f
0000DA 082D movf 0x2d,w
0000DB 1D03 btfss STATUS,2
0000DC 28DF goto 00107_DS
0000DD 30FF movlw 0xff
0000DE 2902 goto 00115_DS

0000B9 1283 bcf STATUS,5
0000BA 1703 bsf STATUS,6
0000BB 00AC movwf 0x2c
0000BC 087F movf 0x7f,w
0000BD 00AD movwf 0x2d
0000BE 082D movf 0x2d,w
0000BF 1D03 btfss STATUS,2
0000C0 28C3 goto _00119_DS

0000C1 30FF movlw 0xff
0000C2 2902 goto 00115_DS


  • Molnár Károly

    Molnár Károly - 2014-02-04

    For this reason no need to switch bank. The 0x70-0x7F area can be achieved same place in each bank. See it the Complete Mid-Range Reference Manual document on the 103 side.

  • Molnár Károly

    Molnár Károly - 2014-02-04
    • assigned_to: Molnár Károly

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks