-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cau_1.asm
58 lines (45 loc) · 1.62 KB
/
Cau_1.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
;===================== Main and Interrupt Start ==================
ORG 00h ;Start from address 00h
LJMP MAIN ;Jump to Main program
ORG 03h ;External 0 interrupt start
NOP ;No code
RETI ;Return from interrupt
ORG 0Bh ;Timer 0 overflow interrupt start
NOP ;No code
RETI ;Return from interrupt
ORG 13h ;External 1 interrupt start
NOP ;No code
RETI ;Return from interrupt
ORG 1Bh ;Timer 1 overflow interrupt start
NOP ;No code
RETI ;Return from interrupt
ORG 23h ;Serial port interrupt start
NOP ;No code
RETI ;Return from interrupt
ORG 2Bh ;Timer 2 overflow interrupt start
NOP ;No code
RETI ;Return from interrupt
;====================Define Variable and Constant=================
;=================================================================
; MAIN PROGRAM
;=================================================================
ORG 50H ;Start Main program at 50H in ROM
Main:
MOV R0, #50 ;Set R0 to Count Number
MOV R1, #38H ;Set R1 to Start Count Address
MOV R2, #00H ;Set R2 to Store Count
LCALL Count_Pos ;Start Count
here:
SJMP here ;Stop here
;=====================Define Function Program=====================
Count_Pos:
MOV A, @R1 ;Move variant from @R1 to A
ANL A, #80H ;Set A to 80H if A<0 , 00H if A>0
CJNE A, #00H, Skip_Count ;Skip count if A<0
INC R2 ;Count R2 += 1
Skip_Count:
INC R1 ;Increase R1
DJNZ R0, Count_Pos ;If R0>0, loop again
RET ;Return to Main
;====================Define Interrupt Handler=====================
END