?? rank.lst
字號:
RANK PAGE 1
1
2 $mod51
00A0 3 latch equ p2 ;port for providing feedback
0080 4 keys equ p0 ;input stage port
0090 5 dline equ p1 ;8-bit databus for LCD
00B0 6 restart equ p3.0 ;flag for next question/round
00B3 7 rs equ p3.3 ;register select for LCD
00B2 8 rw equ p3.2 ;read/write for LCD
00B1 9 en equ p3.1 ;LCD enable pin
00B4 10 buzzer equ p3.4 ;pin for sounding buzzer
00B6 11 mode equ p3.6 ;'fff' or 'race' selection pin
00B5 12 flag equ p3.5 ;flag to check 'done in time' or 'time out'
13
0000 14 org 0000h
0000 8031 15 sjmp main
16
000B 17 org 000bh ;timer0 interrupt vector address
000B C28C 18 clr tr0 ;clear timer0 run bit
000D 758A00 19 mov tl0,#00h
0010 758C00 20 mov th0,#00h ;reload timer0 with initial count
0013 DD02 21 djnz r5,a1 ;left buzzer on unless r5=0
0015 D2B4 22 setb buzzer ;stop buzzer
0017 DF19 23 a1: djnz r7,return
0019 7F88 24 mov r7,#136
001B DE15 25 djnz r6,return
001D 7E03 26 mov r6,#3
001F 7D14 27 mov r5,#20
0021 C2B4 28 clr buzzer ;make buzzer on
0023 74C0 29 mov a,#0c0h
0025 3157 30 acall command
0027 900245 31 mov dptr,#timeout
002A 313C 32 acall read ;display 'timeout'
002C 318F 33 acall dispdly ;keep on displaying for sometime
002E D2B4 34 setb buzzer ;stop buzzer
0030 D2B5 35 setb flag
0032 32 36 return: reti ;return from interrupt service routine
37
0033 75A800 38 main: mov ie,#00h
0036 D2AF 39 setb ea
0038 D2A9 40 setb et0 ;enable timer0 interrupt
003A 758901 41 mov tmod,#01h ;timer0 configured in mode 1
003D 758800 42 mov tcon,#00h
0040 758A00 43 mov tl0,#00h
0043 758C00 44 mov th0,#00h ;set initial count to 0000H
0046 7F88 45 mov r7,#136
0048 7E03 46 mov r6,#3
004A 7D14 47 mov r5,#20
004C 75A000 48 mov latch,#0 ;initialize input stage
004F 7580FF 49 mov keys,#0ffh ;initialize input stage
0052 317D 50 acall lcdly
0054 3146 51 acall lcd_int ;initialize LCD
0056 9001AC 52 mov dptr,#welcome
0059 313C 53 acall read ;display 'welcome to all'
005B 74C0 54 mov a,#0c0h ;starting address for 2nd line
005D 3157 55 acall command
005F 30B605 56 jnb mode,race1 ;jump to race1 when 'race' mode selected
0062 9001BD 57 mov dptr,#welcome1
0065 8003 58 sjmp fff1
RANK PAGE 2
0067 9001CE 59 race1: mov dptr,#welcome2
006A 313C 60 fff1: acall read
006C 318F 61 acall dispdly
006E 7480 62 mov a,#80h
0070 3157 63 acall command
0072 90019C 64 mov dptr,#plrname
0075 313C 65 acall read ;display player names
0077 74C0 66 mov a,#0c0h
0079 3157 67 acall command
007B 30B605 68 jnb mode,race2
007E 9001DF 69 mov dptr,#firstqtn
0081 8003 70 sjmp fff2
0083 9001F0 71 race2: mov dptr,#firstrnd
0086 313C 72 fff2: acall read
73
0088 C2B5 74 here: clr flag
008A 75A000 75 mov latch,#0 ;initialize input stage
008D 7580FF 76 mov keys,#0ffh ;initialize input stage
0090 317D 77 acall lcdly
0092 750430 78 mov 04h,#48 ;ASCII code of '0' is loaded into r4
0095 7831 79 blankrank: mov r0,#31h ;point the first location of rank table
0097 762D 80 again: mov @r0,#'-' ;initialize rank table by '-'
0099 08 81 inc r0
009A B839FA 82 cjne r0,#39h,again
83
009D E580 84 chk: mov a,keys ;mov status of input into accumulator
009F B4FF02 85 cjne a,#0ffh,first ;check if any switch is pressed
00A2 80F9 86 sjmp chk
87
00A4 C2B4 88 first: clr buzzer ;sound buzzer
89
00A6 0504 90 next_rank: inc 04h ;load r4 with ASCII code of next rank
00A8 7831 91 mov r0,#31h ;point the first location of rank table
00AA 20B55B 92 chk1: jb flag,result1
00AD D28C 93 setb tr0 ;make timer0 run
00AF E580 94 mov a, keys ;mov status of input into accumulator
00B1 F4 95 cpl a
00B2 65A0 96 xrl a,latch
00B4 B40002 97 cjne a,#0,scan ;check for any change in previous status
00B7 80F1 98 sjmp chk1
99
00B9 20E01C 100 scan: jb acc.0,store ;now start scanning for the pressed switch from here
00BC 08 101 inc r0 ;point to next address in rank table (32H)
00BD 20E118 102 jb acc.1,store
00C0 08 103 inc r0 ;point to next address in rank table (33H)
00C1 20E214 104 jb acc.2,store
00C4 08 105 inc r0 ;point to next address in rank table (34H)
00C5 20E310 106 jb acc.3,store
00C8 08 107 inc r0 ;point to next address in rank table (35H)
00C9 20E40C 108 jb acc.4,store
00CC 08 109 inc r0 ;point to next address in rank table (36H)
00CD 20E508 110 jb acc.5,store
00D0 08 111 inc r0 ;point to next address in rank table (37H)
00D1 20E604 112 jb acc.6,store
00D4 08 113 inc r0 ;point to next address in rank table (38H)
00D5 20E700 114 jb acc.7,store
115
00D8 A604 116 store: mov @r0,04h ;move ASCII code of current rank to the pointed location
RANK PAGE 3
00DA 45A0 117 orl a,latch
00DC F5A0 118 mov latch,a
00DE BC38C5 119 cjne r4,#56,next_rank ; 56 is ASCII code for '8'
00E1 8000 120 sjmp result
121
00E3 C28C 122 result: clr tr0
00E5 758A00 123 mov tl0,#00h
00E8 758C00 124 mov th0,#00h ;reload timer0 with initial count
00EB 7F88 125 mov r7,#136
00ED 7E03 126 mov r6,#3
00EF 7D14 127 mov r5,#20
00F1 C2B4 128 clr buzzer ;stop buzzer
00F3 74C0 129 mov a,#0c0h
00F5 3157 130 acall command
00F7 30B605 131 jnb mode,race4
00FA 900223 132 mov dptr,#intime
00FD 8003 133 sjmp fff4
00FF 900234 134 race4: mov dptr,#intime1
0102 313C 135 fff4: acall read
0104 318F 136 acall dispdly
0106 D2B4 137 setb buzzer
0108 C28C 138 result1: clr tr0
010A 7831 139 mov r0,#31h ;reinitialize rank table pointer
010C 74C0 140 mov a,#0c0h
010E 3157 141 acall command
0110 E6 142 show: mov a,@r0
0111 316A 143 acall display ;display the rank below name
0113 7420 144 mov a,#' '
0115 316A 145 acall display ;provide a space between ranks
0117 08 146 inc r0
0118 B839F5 147 cjne r0,#39h,show ;keep on displying upto the rank of 'H'
148
011B 20B0FD 149 stay: jb restart,stay ;now stay here unless a remote-key is pressed
011E 7904 150 mov r1,#4
0120 7AC8 151 s1: mov r2,#200
0122 DAFE 152 djnz r2,$
0124 D9FA 153 djnz r1,s1
0126 20B0F2 154 jb restart,stay ;recheck if p3.0 is high
155
0129 74C0 156 nxt_Ques: mov a,#0c0h
012B 3157 157 acall command
012D 30B605 158 jnb mode,race3
0130 900201 159 mov dptr,#nxtqtn
0133 8003 160 sjmp fff3
0135 900212 161 race3: mov dptr,#nxtrnd
0138 313C 162 fff3: acall read ;display 'next question (or round)'
013A 0188 163 jmp here ;get ready for next question/round
164
013C E4 165 read: clr a
013D 93 166 movc a,@a+dptr
013E 6005 167 jz down
0140 316A 168 acall display
0142 A3 169 inc dptr
0143 80F7 170 sjmp read
0145 22 171 down: ret
172
0146 7438 173 lcd_int: mov a,#38h ;2 line disp, 8bits/ch, 5x7 matrix
0148 3157 174 acall command ;write into the LCD command register
RANK PAGE 4
014A 740C 175 mov a,#0ch ;display on, cursor off
014C 3157 176 acall command
014E 7401 177 mov a,#01h ;clr screen & bring cursor home (80H)
0150 3157 178 acall command
0152 7406 179 mov a,#06h ;right shifting for cursor movement
0154 3157 180 acall command
0156 22 181 ret
182
0157 F590 183 command: mov dline,a
0159 C2B3 184 clr rs ;select command register of LCD
015B 00 185 nop
015C 00 186 nop
015D C2B2 187 clr rw ;select write mode for LCD
015F 00 188 nop
0160 00 189 nop
0161 D2B1 190 setb en
0163 3186 191 acall lcdly1
0165 C2B1 192 clr en ;now write into command register
0167 3186 193 acall lcdly1
0169 22 194 ret
195
016A F590 196 display: mov dline,a
016C D2B3 197 setb rs ;select data register of LCD
016E 00 198 nop
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -