;program in assembler for Bolt v.Lite system ;Remember that, for the microswitches (SW4..SW3), SW4 is the most significant bit ;and the ON position=0, the OFF position=1. ;after reset, reads SW4..SW1 and forms a pair of numbers n and m: ;SW4 and SW3 (n=0..3). SW2 and SW1 (m=0..3). ;shows in leds, in binary code, the result of multiplication of (n*m) ;if user changes value of microswitches, program automatically modifies result. processor 18F2550 include include "KEYBOLT2.inc" ;auxiliary file J equ H'80' K equ H'81' L equ H'82' CLAVE100 equ H'83' n equ H'84' m equ H'85' suma equ H'86' org 0x800 ;MODIFIQUE A ORG=0 PARA SIMULAR EN MPLAB PUERTOS BOLTSWITCH CLRF suma CLRF PORTB movf CLAVE100,w andlw H'03' ;variable m movwf m movwf PORTB call retrobolt ;observ m in leds movf CLAVE100,w rrncf CLAVE100,f rrncf CLAVE100,f movf CLAVE100,w andlw H'03' ;variable n movwf n movwf PORTB call retrobolt ;observ n in leds incf n malla decfsz n goto sigue goto fin sigue: movf suma,w addwf m,w movwf suma goto malla fin: movf suma,w movwf PORTB ;observ n*m in leds sleep ;SUBRUTINA DE RETRASO APROX DE 1 SEGUNDO.SE PUEDE MODIFICAR A (16.4 x L) MILISEGUNDOS retrobolt: movlw D'61' ;valor de L. Modifique para cambiar el valor del retraso. movwf L lloop movlw D'255' ; w := 200 decimal movwf J ; J := w jloop: movwf K ; K := w kloop: decfsz K,f ; K = K-1, skip next if zero goto kloop decfsz J,f ; J = J-1, skip next if zero goto jloop decfsz L,f goto lloop return end