-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMCP3002.asm
116 lines (109 loc) · 1.55 KB
/
MCP3002.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
10 ORG 100H
20 JP MAIN
30PUTSTR EQU 0BFF1H
35PWROFF EQU 0C110H
40INKEY EQU 089BEH
50MAIN: CALL CLS
60 LD A, 1
70 OUT (60H), A
80 OUT (61H), A
90MAIN00: LD A,10
100 LD (RC), A
110 LD BC, 0
120 LD (RD), BC
130 LD A,255
140 LD (RI),A
150 LD HL,SPIDAT
160MAIN01: LD A,(HL)
170 CP 99
180 JP Z,THEEND
190 INC HL
200 LD B,A
210 AND 0FEH
220 OUT (62H), A
230 LD A,B
240 AND 1
250 JP Z, MAIN02
260 IN A,(62H)
270 LD B,A
280 LD A,(RC)
290 CP 10
300 JP Z, MAIN02
310 LD A,B
320 AND 1
330 JP Z, MAIN03
340 PUSH IX
350 LD IX,(RD)
360 INC IX
370 LD (RD),IX
380 POP IX
390MAIN03: LD A,(RC)
400 CP 0
410 JP NZ, MAIN02
420 LD A,(RD)
430 SRA
440 SRA
450 SRA
460 AND A,1FH
470 LD B,A
480 LD A,(RD0)
490 AND A,03H
500 SLA
510 SLA
520 SLA
530 SLA
540 SLA
550 AND A,070H
560 ADD A,B
570 ; THAT'S D/8
580 PUSH HL
590 LD HL,RSLT
600 CALL BYTE
610 LD HL,RSLT
620 LD DE,00300H
630 CALL STRLN
640 CALL PUTSTR
645 POP HL
650MAIN02: LD A,(RC)
660 DEC A
670 LD (RC),A
680 JP MAIN01
690THEEND: CALL INKEY
700 CP 0
710 JP Z, MAIN00
730 CP 02H ; 'Q'
740 JP Z, END00
750 CP 51H ; ON
760 JP Z, END00
770 CP 01H ; OFF
780 JP NZ, MAIN00
790 CALL PWROFF
800END00: RET
3000CLS: LD B, 144
3010 LD DE, 0
3020CLS0: LD A, 32
3030 CALL RPTCHR
3040 RET
3050CLLN: LD B,24
3060 LD E,0
3070 JP CLS0
3080STRLN: LD B,0
3090 PUSH HL
3100STRLN0: LD A,(HL)
3110 CP 0
3120 JP Z,STRLN1
3130 INC HL
3140 INC B
3150 JP STRLN0
3160STRLN1: POP HL
3170 RET
3240SPIDAT: DB 0,2,6,2,6,0,4,2
3250 DB 6,0,5,0,5,0,5,0
3260 DB 5,0,5,0,5,0,5,0
3270 DB 5,0,5,0,5,0,5,8,12,99
3280RC: DB 10
3290RD: DB 0
3300RD0: DB 0
3310RI: DB 255
3320RSLT: DB 0,0,0