summaryrefslogtreecommitdiff
path: root/base10.asm
diff options
context:
space:
mode:
Diffstat (limited to 'base10.asm')
-rw-r--r--base10.asm65
1 files changed, 65 insertions, 0 deletions
diff --git a/base10.asm b/base10.asm
new file mode 100644
index 0000000..0a9ce89
--- /dev/null
+++ b/base10.asm
@@ -0,0 +1,65 @@
+processor PIC16F873A
+#include <p16f873a.inc>
+ __CONFIG _XT_OSC & _WDT_OFF & _PWRTE_OFF & _BOREN_OFF & _LVP_OFF & _CP_OFF & _CPD_OFF
+
+cblock 0x20 ;definir variaveis
+
+ aux
+ unidade
+ dezena
+ centena
+endc
+ org 0x0
+ ;errorlevel -302 ;desabilitar mensagens de avisos na compilacao
+ goto INICIO
+;;;;;;;;INICIO DO TIMER;;;;;;;;;;;;;;;;
+ org 0x004
+
+ retfie
+
+INICIO:
+ movlw d'222'
+ call BASE10
+LOOP:
+ goto LOOP
+
+BASE10:
+ movwf aux
+ clrf centena
+ clrf dezena
+ clrf unidade
+
+ movf aux, w
+ addlw d'0'
+ btfsc STATUS, Z ; aux = 0
+ goto RETURN10
+
+INC_UNI:
+ incf unidade, F ; nao, unidade ++;
+ movf unidade, W ; W = unidade
+ xorlw d'10' ; unidade = 10
+ btfsc STATUS, Z
+ goto INC_DEZ ; sim
+ goto SUB_AUX ; nao
+
+INC_DEZ:
+ clrf unidade ; unidade = 0
+ incf dezena, F ; dezena += 1;
+ movf dezena, W ; W = dezena
+ xorlw d'10' ; dezena = 10
+ btfsc STATUS, Z
+ goto INC_CEN ; sim
+ goto SUB_AUX ; nao
+
+INC_CEN:
+ clrf dezena
+ incf centena
+
+SUB_AUX:
+ decfsz aux, F ; aux--
+ goto INC_UNI
+
+RETURN10:
+ retlw d'0'
+
+ end \ No newline at end of file