Menu

#875 expression

closed-fixed
nobody
5
2005-02-04
2005-02-03
acid77
No

following code doesn't work

---cut---

#include "p16f876.h"

void test(char p) {
unsigned char buff = p;
PORTC = (PORTC & 0xf) | buff;
}

void main(void)
{
test(77);

}
---cut---

the compiler (2.4.0/2.4.8) generates following code:

; PORTC = (PORTC & 0xf) | buff;
MOVLW 0x0f
BCF STATUS,5
BCF STATUS,6
ANDWF _PORTC,W
BANKSEL r0x21
IORWF r0x21,F
BCF STATUS,5
BCF STATUS,6
MOVWF _PORTC
RETURN

W = 0xf (MOVLW 0x0f)
W = PORTC & W (ANDWF _PORTC,W)
buf = W | buff (IORWF r0x21,F)
^^^ the problem
PORTC = W (MOVWF _PORTC)

Discussion

  • Slade Rich

    Slade Rich - 2005-02-04

    Logged In: YES
    user_id=849691

    Fixed in version 2.4.8 #954

     
  • Slade Rich

    Slade Rich - 2005-02-04
    • status: open --> open-fixed
     
  • Slade Rich

    Slade Rich - 2005-02-04

    Logged In: YES
    user_id=849691

    This can't be reproduced in 2.4.3. Can you confirm it still
    exists?

     
  • acid77

    acid77 - 2005-02-04

    Logged In: YES
    user_id=1211507

    thanks. i works now..

    ; Version 2.4.8 #954 (Feb 4 2005)
    ; LCD_PORT = (LCD_PORT & 0x0f) | buff;
    MOVLW 0x0f
    BCF STATUS,5
    BCF STATUS,6
    ANDWF _PORTC,W
    BANKSEL r0xC4
    IORWF r0xC4,W
    BCF STATUS,5
    BCF STATUS,6
    MOVWF _PORTC

    a buffy version:

    ; Version 2.4.8 #950 (Feb 2 2005)
    ; LCD_PORT = (LCD_PORT & 0x0f) | buff;
    MOVLW 0x0f
    BCF STATUS,5
    BCF STATUS,6
    ANDWF _PORTC,W
    BANKSEL r0xC4
    IORWF r0xC4,F
    BCF STATUS,5
    BCF STATUS,6
    MOVWF _PORTC

     
  • acid77

    acid77 - 2005-02-04
    • status: open-fixed --> closed-fixed
     
  • acid77

    acid77 - 2005-02-04

    Logged In: YES
    user_id=1211507

    Can you confirm this still exists in 2.4.3?

     
  • acid77

    acid77 - 2005-02-04

    Logged In: YES
    user_id=1211507

    > a buffy version:

    buggy ;)

     

Log in to post a comment.