Está en la página 1de 2

Programacin estructurada

IF operando1 COMPARISON operando2 MOVF operando1,w


... SUBWF operando2,w
ELSE BTFSC STATUS,bit ;o, alternativamente, BTFSS
... GOTO bloque2
END bloque1 ...
GOTO fin
bloque2 ...
fin
WHILE operando1 COMPARISON operando2 bucle MOVF operando1,w
... SUBWF operando2,w
END BTFSC STATUS,bit ;o, alternativamente, BTFSS
GOTO fin
...
GOTO bucle
fin
REPEAT bloque ...
... MOVF operando1,w
UNTIL operando1 COMPARISON operando2 SUBWF operando2,w
BTFSC STATUS,bit ;o, alternativamente, BTFSS
GOTO bloque

FOR indice FROM inicial TO final WITH incremento MOVLW (final-inicial)/incremento+1


... MOVWF registro
End bucle: ... ;indice=(registro1)incremento+inicial
DECFSZ registro,registro ;o, alternativamente, INCFSZ
GOTO bucle

Obsrvese que otras instrucciones, siempre que muevan banderas, pueden ser utilizadas para realizar la comparacin de los operandos, por
ejemplo, en lugar de SUBWF, podra hacerse utilizando ADDWF, IORWF, XORWF, ADDLW
Saltos condicionales en funcin de las banderas
SUBLW k k-(w) (w) C DC - Z
SUBWF f,d (f) - (w) (destino) C DC Z
En general M-S
BRINCA SI NO BRINCA SI
BTFSS STATUS,Z M=S MS
BTFSC STATUS,Z MS M=S
BTFSS STATUS,C SM M<S
BTFSC STATUS,C M<S SM

También podría gustarte