View Single Post
  #10   Spotlight this post!  
Unread 22-12-2002, 01:27
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
The basis for this jump is the machine that was in the first BASIC Stamp - the PIC from Microchip. Its only decision is a flag-test followed by a skip over the next instruction to the instruction after that. It has one register you can load, and it is busy ! The on-board RAM is set up in 'files' : 8 bit locations you assembler allows you to name, and they do get cramped.

[compare Alpha to Beta]
MOVF,W Beta 'move contents of 'file' (ram location) I call beta to W (work reg)
SUBWF,W ALPHA 'subtract W contents from 'file' I call Alpha
BTFSS CARRY ' Bit Test flag(here, a carry), Skip if carry is set
GOTO CARCLEAR ' This instruction skipped if carry was set, else jump occurs
MOV..... ' IT was set, Alpha >= Beta
......
CARCLEAR ...... 'It wasn't zero, come to this label Beta > Alpha

-or-

[do..while_not_zero loop]
MOVLW .5 'move 5 (dec) into the tiny 'working register' (W)
MOVWF Index 'move contents of W into a 'file' register I've called Index
GUTS (label)
do something
DECFSZ Index 'decrement Index, skip if dec'ing caused the zero flag to set
GOTO GUTS loops back to guts if not zero
.....

If you don't like jumping if true in PBASIC, you can alway test for a condition you know will *not* occur. You can use preprocessors, high level languages, and other artifice to get you away from the silicon (and don't the people love to), or you can have fun playing in the sand .

Last edited by Lloyd Burns : 22-12-2002 at 01:56.