View previous topic :: View next topic |
Author |
Message |
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
|= or || |
Posted: Sun Mar 02, 2003 3:52 pm |
|
|
It appears that |= does not work very well on bits. Double the code and half the speed. Have I just written this incorectly?
.................... go_open |= CMD_go_open;
060C: MOVLW 00
060E: MOVLB 2
0610: BTFSC x69.4
0612: MOVLW 01
0614: MOVWF x7A
0616: MOVLW 00
0618: BTFSC x69.6
061A: MOVLW 01
061C: IORWF x7A,W
061E: XORLW 00
0620: BTFSS FD8.2
0622: GOTO 062C
0626: BCF x69.4
0628: GOTO 062E
062C: BSF x69.4
.................... go_open = go_open || CMD_go_open;
062E: BTFSC x69.4
0630: GOTO 0640
0634: BTFSC x69.6
0636: GOTO 0640
063A: BCF x69.4
063C: GOTO 0642
0640: BSF x69.4
___________________________
This message was ported from CCS's old forum
Original Post ID: 12283 |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
Re: |= or || |
Posted: Sun Mar 02, 2003 6:31 pm |
|
|
|| is logical OR. It should be
go_open = go_open | CMD_go_open
Regards,
Mark
:=It appears that |= does not work very well on bits. Double the code and half the speed. Have I just written this incorectly?
:=
:=.................... go_open |= CMD_go_open;
:=060C: MOVLW 00
:=060E: MOVLB 2
:=0610: BTFSC x69.4
:=0612: MOVLW 01
:=0614: MOVWF x7A
:=0616: MOVLW 00
:=0618: BTFSC x69.6
:=061A: MOVLW 01
:=061C: IORWF x7A,W
:=061E: XORLW 00
:=0620: BTFSS FD8.2
:=0622: GOTO 062C
:=0626: BCF x69.4
:=0628: GOTO 062E
:=062C: BSF x69.4
:=.................... go_open = go_open || CMD_go_open;
:=062E: BTFSC x69.4
:=0630: GOTO 0640
:=0634: BTFSC x69.6
:=0636: GOTO 0640
:=063A: BCF x69.4
:=063C: GOTO 0642
:=0640: BSF x69.4
___________________________
This message was ported from CCS's old forum
Original Post ID: 12293 |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
Re: |= or || |
Posted: Sun Mar 02, 2003 7:07 pm |
|
|
I should have mentioned that these are boolean variables. All three of these expressions seem to work. It seems to be a weakness in the way the compiler optimizes code for boolean variables. I expected a logical OR to be used because these are boolean variables. I guess the way I want to do this does not really conform to ANSI C.
.................... go_close = go_close || CMD_go_close;
07F8: BTFSC x6F.7
07FA: GOTO 080A
07FE: BTFSC x7B.1
0800: GOTO 080A
0804: BCF x6F.7
0806: GOTO 080C
080A: BSF x6F.7
.................... go_close = go_close | CMD_go_close;
080C: MOVLW 00
080E: BTFSC x6F.7
0810: MOVLW 01
0812: MOVWF x81
0814: MOVLW 00
0816: BTFSC x7B.1
0818: MOVLW 01
081A: IORWF x81,W
081C: XORLW 00
081E: BTFSS FD8.2
0820: GOTO 082A
0824: BCF x6F.7
0826: GOTO 082C
082A: BSF x6F.7
.................... go_close |= CMD_go_close;
082C: MOVLW 00
082E: BTFSC x6F.7
0830: MOVLW 01
0832: MOVWF x81
0834: MOVLW 00
0836: BTFSC x7B.1
0838: MOVLW 01
083A: IORWF x81,W
083C: XORLW 00
083E: BTFSS FD8.2
0840: GOTO 084A
0844: BCF x6F.7
0846: GOTO 084C
084A: BSF x6F.7
___________________________
This message was ported from CCS's old forum
Original Post ID: 12295 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: |= or || |
Posted: Mon Mar 03, 2003 12:13 pm |
|
|
:=I should have mentioned that these are boolean variables. All three of these expressions seem to work. It seems to be a weakness in the way the compiler optimizes code for boolean variables. I expected a logical OR to be used because these are boolean variables. I guess the way I want to do this does not really conform to ANSI C.
--------------------------------------------------------------
Instead of declaring the variables as "shorts" (1 bit),
declare them as chars. Then it only uses 2 ROM words
for each line of source code in your example.
___________________________
This message was ported from CCS's old forum
Original Post ID: 12309 |
|
|
Hans Wedemeyer Guest
|
Re: |= or || |
Posted: Tue Mar 04, 2003 9:45 am |
|
|
:=Instead of declaring the variables as "shorts" (1 bit),
:=declare them as chars. Then it only uses 2 ROM words
:=for each line of source code in your example.
Tried that and got gobbs of code... could you please post your example.
___________________________
This message was ported from CCS's old forum
Original Post ID: 12333 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: |= or || |
Posted: Tue Mar 04, 2003 12:55 pm |
|
|
:=:=Instead of declaring the variables as "shorts" (1 bit),
:=:=declare them as chars. Then it only uses 2 ROM words
:=:=for each line of source code in your example.
:=
:=Tried that and got gobbs of code... could you please post your example.
:=
----------------------------------------------------
You're right. For the logical OR, it does produce a lot
of code. I had assumed that his original post had a typo
and that he intended to compare two bitwise operations:
<PRE>
go_open |= CMD_go_open;
and this:
go_open = go_open | CMD_go_open;
<BR>
and not this:
<BR>
go_open |= CMD_go_open;
and this:
go_open = go_open || CMD_go_open;
</PRE>
My test was done after correcting his "typo" :)
<PRE>
0000 00273 .................... go_open |= CMD_go_open;
0014 0822 00274 MOVF 22,W
0015 04A1 00275 IORWF 21,F
0000 00276 ....................
0000 00277 .................... go_open = go_open | CMD_go_open;
0016 0822 00278 MOVF 22,W
0017 04A1 00279 IORWF 21,F
0000 00280 ....................
0000 00281 ....................
0000 00282 ....................
0000 00283 .................... go_open = go_open || CMD_go_open;
0018 08A1 00284 MOVF 21,F
0019 1D03 00285 BTFSS 03.2
001A 2820 00286 GOTO 020
001B 08A2 00287 MOVF 22,F
001C 1D03 00288 BTFSS 03.2
001D 2820 00289 GOTO 020
001E 3000 00290 MOVLW 00
001F 2821 00291 GOTO 021
0020 3001 00292 MOVLW 01
0021 00A1 00293 MOVWF 21
</PRE>
___________________________
This message was ported from CCS's old forum
Original Post ID: 12343 |
|
|
|