View Single Post
  #1   Spotlight this post!  
Unread 07-11-2001, 08:18
Lloyd Burns Lloyd Burns is offline
Registered User
FRC #1246 (Agincourt Robotics)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Toronto
Posts: 292
Lloyd Burns is an unknown quantity at this point
Why not a CASE x OF statement ?

The structure of the PIC code (was this what Microchip and Scenix were sqabbling over) would make it easy to construct a CASE statement.

CASE x OF
~~0 : y = 3;
~~6 : y = 7
~~1..5 : y = 4
ELSE y = 0;

~~~~~~~~MOVF X,f
~~~~~~~~BTFSC ZERO
~~~~~~~~GOTO YIS3
~~~~~~~~MOVLW .6
~~~~~~~~SUBWF X,w
~~~~~~~~BTFSC ZERO
~~~~~~~~GOTO YIS7
~~~~~~~~BTFSC CARRY 'PIC CODES NOT ~~~~~~~~~~~~~~~~~~~~~~~~' HANDY:BTFSS?
~~~~~~~~GOTO YIS0
~~~~~~~~MOVLW .4
~~~~~~~~MOVWF Y
~~~~~~~~GOTO ENDCASE
YIS3 MOVLW .3
~~~~~~~~MOVWF Y
~~~~~~~~GOTO ENDCASE
YIS7 MOVLW .7
~~~~~~~~MOVWF Y
~~~~~~~~GOTO ENDCASE
YIS0 MOVLW .0
~~~~~~~~MOVWF Y
ENDCASE

And yes, a special case could zero Y differently.
Another alternate would be the table of RETLWs, as in the PBASIC lookup/down instructions.

BTW is there an option available to NOT delete leading spaces when this BB program edits a post ?