-
Notifications
You must be signed in to change notification settings - Fork 0
/
arquivo_base.asm
125 lines (117 loc) · 1.88 KB
/
arquivo_base.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
; ------------------------------------------
; IESB - Sistemas Computacionais: Hardware
; (Prova Substitutiva) Projeto Sirene
; Orientador / Avaliador:
; Luis Carvalho
; Alunos:
; Leonardo Contri / Matricula: 1712082029
; Nadio Dib / Matricula: 1322081004
;
; Brasilia, 2 de julho de 2017
; ------------------------------------------
#INCLUDE P16F628A.INC
__CONFIG _BOREN_ON & _CP_OFF & _PWRTE_ON & _WDT_OFF & _LVP_OFF & _MCLRE_ON & _XT_OSC
#DEFINE BANK0 BCF STATUS,RP0
#DEFINE BANK1 BSF STATUS,RP0
#DEFINE CHAVE1 PORTA,0
#DEFINE CHAVE2 PORTA,1
#DEFINE CHAVE3 PORTA,2
#DEFINE L1_OFF BSF PORTB,1
#DEFINE L1_ON BCF PORTB,1
#DEFINE L2_OFF BSF PORTB,2
#DEFINE L2_ON BCF PORTB,2
#DEFINE SIRENE PORTB,3
#DEFINE TA_CFG B'00000111'
#DEFINE TB_CFG B'00000000'
#DEFINE OR_CFG B'10000001'
#DEFINE IC_CFG B'00100000'
FREQ EQU 20H
DL0 EQU 21H
DL1 EQU 22H
DL2 EQU 23H
SAVE_W EQU 24H
SAVE_S EQU 25H
ORG 000H
GOTO INICIO
ORG 004H
MOVWF SAVE_W
SWAPF STATUS,W
MOVWF SAVE_S
; BTFSC CHAVE3
; GOTO END_INT
; L1_OFF
; L2_OFF
; BTFSS INTCON,T0IE
; GOTO END_INT
; BCF INTCON,T0IE
; MOVLW FREQ
; MOVWF TMR0
; MOVLW B'00001000'
; XORWF PORTB,F
END_INT:
SWAPF SAVE_S,W
MOVWF STATUS
SWAPF SAVE_W,F
SWAPF SAVE_W,W
RETFIE
DELAY:
MOVLW .2
MOVWF DL2
LOOP_250MS:
MOVLW .250
MOVWF DL1
LOOP_1MS:
MOVLW .200
MOVWF DL0
LOOP:
NOP
DECFSZ DL0,F
GOTO LOOP
DECFSZ DL1,F
GOTO LOOP_1MS
DECFSZ DL2,F
GOTO LOOP_250MS
RETURN
INICIO:
CLRF PORTA
CLRF PORTB
BANK1
MOVLW TA_CFG
MOVWF TRISA
MOVLW TB_CFG
MOVWF TRISB
MOVLW OR_CFG
MOVWF OPTION_REG
MOVLW IC_CFG
MOVWF INTCON
BANK0
MOVLW 7
MOVWF CMCON
BGNNG:
L1_OFF
L2_OFF
BTFSC CHAVE2
GOTO BGNNG
BSF INTCON,T0IE
BSF SIRENE
MAIN:
L1_OFF
L2_ON
MOVLW .3
MOVWF FREQ
BTFSS CHAVE3
GOTO SHTDWN
CALL DELAY
L1_ON
L2_OFF
MOVLW .43
MOVWF FREQ
BTFSS CHAVE3
GOTO SHTDWN
CALL DELAY
GOTO MAIN
SHTDWN:
L1_OFF
L2_OFF
GOTO BGNNG
END