-
Notifications
You must be signed in to change notification settings - Fork 0
/
fluidlevelcontroller.asm
108 lines (95 loc) · 2.25 KB
/
fluidlevelcontroller.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
;variable declaration
status equ 03h
porta equ 05h
portb equ 06h
cblock 0ch
full
threequater
medium
exchange
vlow
zero
endc
bsf status,5 ;moves to bank1
clrf portb ;sets portb as output port
movlw 0ffh ;moves 0ffh into working register
movwf porta ;sets porta as input port
bcf status,5 ;returns to bank0
;initialization of variables
movlw b'00001111'
movwf full
movlw b'00001110'
movwf threequater
movlw b'00001100'
movwf medium
movlw b'00001000'
movwf vlow
clrf portb
clrf zero
;program starts
start:
bcf status,2 ;clears zero flag
movf porta,0 ;moves d state of porta into working register
xorwf full,0 ;xors the value of working reg with full
btfsc status,2 ;performs a bitcheck on the zero flag
call on1 ;calls the on1 subroutine
bcf status,2 ;clears zero flag
movf porta,0 ;moves d state of porta into working register
xorwf threequater,0 ;xors the value of working reg with threequater
btfsc status,2 ;performs a bitcheck on the zero flag
call on2 ;calls the on2 subroutine
bcf status,2 ;clears zero flag
movf porta,0 ;moves d state of porta into working register
xorwf medium,0 ;xors the value of working reg with medium
btfsc status,2 ;performs a bitcheck on the zero flag
call on3 ;calls the on3 subroutine
bcf status,2 ;clears zero flag
movf porta,0 ;moves d state of porta into working register
xorwf vlow,0 ;xors the value of working reg with vlow
btfsc status,2 ;performs a bitcheck on the zero flag
call on4 ;calls the on4 subroutine
bcf status,2 ;clears zero flag
movf porta,0 ;moves d state of porta into working register
xorwf zero,0 ;xors the value of working reg with zero
btfsc status,2 ;performs a bitcheck on the zero flag
call on5 ;calls the on5 subroutine
goto start ;jumps back to start label
on1:
;switches the necessary pins
bcf portb,4
bcf portb,3
bcf portb,2
bcf portb,1
bsf portb,0
return
on2:
;switches the necessary pins
bcf portb,3
bcf portb,2
bsf portb,1
bcf portb,0
return
on3:
;switches the necessary pins
bcf portb,3
bsf portb,2
bcf portb,1
bcf portb,0
return
on4:
;switches the necessary pins
bsf portb,4
bsf portb,3
bcf portb,2
bcf portb,1
bcf portb,0
return
on5:
;switches the necessary pins
bsf portb,4
bsf portb,3
bcf portb,2
bcf portb,1
bcf portb,0
return
end