julien lochen
Joined: 16 May 2008 Posts: 14
|
assembler issue with "ANDLW" PIC16F886 |
Posted: Tue May 27, 2008 10:03 am |
|
|
Hello,
Is it correct to use a temp variable as parameter with "ANDLW" ?
My code is:
///////////////
variables UDATA 0x30 ;varibales data stored at locations starting at 0x30.
temp_1 RES 1 ; temp_1 stored at 0x31
temp_2 RES 1 ; temp_1 stored at 0x32
temp_3 RES 1 ; temp_1 stored at 0x33
temp_4 RES 1 ; temp_1 stored at 0x34
temp_5 RES 1 ; temp_1 stored at 0x35
temp_6 RES 1 ; temp_1 stored at 0x36
temp_7 RES 1 ; temp_1 stored at 0x37
temp_8 RES 1 ; temp_1 stored at 0x38
...
CLRW ;W <- 0x00
banksel PORTA
MOVF PORTA,0 ;W <- PORTA
banksel temp_8
MOVWF temp_8 ;temp_8 <- W (= D7_D6_D5_D4_D3_D2_D1_D0)
RLF temp_8,1 ;temp_8 <- d6_d5_d4_d3_d2_d1_d0_c, c=d7
RLF temp_8,1 ;temp_8 <- d5_d4_d3_d2_d1_d0_c_d7, c=d6
MOVLW 0x80 ; W <- x80
ANDLW temp_8 ; W[7:0] <- (temp_8[7:0] & W[7:0]) => W[7:0]= d5_0_0_0_0_0_0_0_0
banksel PORTC
IORWF PORTC,1 ;PORTC[7:0] <- (PORTC[7:0] | W[7:0]) => PORTC[7:0] = d5_x_x_x_x_x_x_x
banksel TRISC
MOVLW 0x00
MOVWF TRISC
///////////////////////
temp_8's value is xBD and W's value is x80 but after the execution of "ANDLW temp_8" I have temp_8 = x00, I was expecting temp_8 = x80
thanks, julien lochen |
|