⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.lis

📁 A very good POCSAG Paging Protocol Decoder.
💻 LIS
📖 第 1 页 / 共 5 页
字号:
 00BF 5307              mov [byte_cnt], A
 00C1 5306              mov [data], A
 00C3 550101            mov [start], 1              ;set start flag    
 00C6 5109              mov A, [sampling_rate]      ;rate for sampling
 00C8 9000              call Timer8_1_WritePeriod   ;write timer period
 00CA 7101          or    F, FlagGlobalIE
 00CC               
 00CC              
 00CC 40        lp_sample:  nop                                     ;wait until counter reaches
 00CD 3C0809                            cmp [sample_cnt], SAMPLE_NUM            ;number SAMPLE_NUM
 00D0 CFFB                              jc lp_sample                            
 00D2 70FE          and   F, ~FlagGlobalIE
 00D4 5104                              mov A, [hi_cnt]
 00D6 3A05                              cmp A, [lo_cnt]                                                 ;if hi_cnt < lo_cnt
 00D8 C004                              jc .brn_temp                                                    ;do nothing
 00DA 2E0601                            or [data], 1                            ;else, LSB bit of data set to 1  
 00DD           .brn_temp:      		
 00DD 5000                  mov A, 0                                
 00DF 5304                  mov [hi_cnt], A                         ;reset hi_cnt
 00E1 5305                  mov [lo_cnt], A                         ;reset lo_cnt
 00E3 5308                  mov [sample_cnt], A                     ;reset sampling counter
 00E5 7101          or    F, FlagGlobalIE
 00E7 5103                  mov A, [bit_ptr]
 00E9 3907                  cmp A, MSB_NUM                          
 00EB A008                  jz lp_next_byte                         ;if bit_ptr != MSB_NUM
 00ED 74                    inc A                                   ;inc. bit_ptr
 00EE 5303                  mov [bit_ptr], A
 00F0 6506                  asl [data]                              ;shift data to the left
 00F2 8FD9                  jmp lp_sample                           ;start sampling again
 00F4                       
 00F4           lp_next_byte:
 00F4                       ;if bit_ptr == MSB_NUM
 00F4 5107                  mov A, [byte_cnt]
 00F6 B034                  jnz lp_not_first_byte                   ;if byte_cnt == 0
 00F8 510C                  mov A, [batch_cnt]                      
 00FA B022                  jnz lp_not_first_batch                  ;and if batch_cnt == 0
 00FC 5106                  mov A, [data]
 00FE 5C                    mov X, A
 00FF 3954                  cmp A, 0x54                             ;if data != 0x54
 0101 A00A                  jz lp_first_byte                                       
 0103 73                    cpl A                                   ;invert data
 0104 3954                  cmp A, 0x54                             ;check again, if data != 0x54
 0106 A005                  jz lp_first_byte                        
 0108 6506                  asl [data]                              ;shift data to the left
 010A 8FC1                  jmp lp_sample                           ;start sampling again
 010C                       
 010C           lp_first_byte:
 010C                       ;if data or inverted data == 0x54
 010C 5B                    mov A, X
 010D 39AB                  cmp A, 0xAB                             ;if data is inverted
 010F B004                  jnz .temp
 0111 550B01                mov [inverse], 1                        ;set inverse flag
 0114           .temp:      
 0114 6506                              asl [data]                              ;shift data to the left
 0116 550301                            mov [bit_ptr], 1                        ;set bit_ptr to 1 (first bit after preambule)
 0119 7607                              inc [byte_cnt]                          ;inc. byte_cnt
 011B 8FB0                              jmp lp_sample                           ;start sampling again
 011D                                   
 011D           lp_not_first_batch:
 011D                       ;if byte_cnt == 0 and batch_cnt != 0
 011D 5106                  mov A, [data]
 011F 3C0B01                cmp [inverse], 1                        ;if inverse == 1
 0122 B002                  jnz .temp
 0124 73                    cpl A                                   ;inverse data
 0125           .temp:      
 0125 397C                  cmp A, 0x7C                             ;if data != begining of the next batch
 0127 B024                  jnz lp_end                              ;end receving
 0129 7607                  inc [byte_cnt]                                      ;else inc. byte_cnt
 012B                                   
 012B           lp_not_first_byte:
 012B                       ;if byte_cnt != 0
 012B 550300                mov [bit_ptr], 0                        ;reset bit_ptr
 012E 5106                  mov A, [data]                                       
 0130 3C0B01                cmp [inverse], 1                        ;if inverse == 1
 0133 B002                  jnz .temp
 0135 73                    cpl A                                   ;inverse data
 0136           .temp:
 0136 9000                  call  TX8_1_SendData                                        ;send data into UART
 0138 5107                  mov A, [byte_cnt]
 013A 3944                  cmp A, BYTE_NUM                         
 013C A004                  jz  lp_next_batch                       ;if byte_cnt != BYTE_NUM
 013E 74                    inc A                                   ;inc. byte_cnt
 013F 8005                  jmp lp_save_cnt
 0141           lp_next_batch:
 0141 760C                  inc [batch_cnt]                         ;else inc. batch_cnt
 0143 5000                  mov A, 0                                ;reset byte_cnt
 0145           lp_save_cnt:                                        
 0145 5307                  mov [byte_cnt], A
 0147 550600                mov [data], 0                           ;reset data
 014A 8F81                  jmp lp_sample                           ;start sampling again
 014C                       
 014C           lp_end:
 014C                       ;end receiving 
 014C 620800                mov REG[PRT2DR], 00h                                ;turn rate LEDs OFF
 014F 550B00                mov [inverse], 0                        ;reset inverse
 0152 550C00                mov [batch_cnt], 0                      ;reset batch_cnt
 0155 550100                            mov [start], 0                          ;reset start flag
 0158 50FF                  mov A, FFh                              ;timer period 2ms                 
 015A 9000                  call Timer8_1_WritePeriod               ;write timer period
                if DISABLE_INT_FIX
 015C 5DFF          mov   A, reg[CPU_SCR]           ; save the current Global interrupt state
 015E 70FE          and   F, ~FlagGlobalIE
                endif
 0160 41E0FD        and   reg[INT_MSK0], ~INT_MSK0_AColumn0              ; disable specified interrupt enable bit
                if DISABLE_INT_FIX
 0163 2180          and   A, CPUSCR_GIEMask         ; determine if global interrupt was set
 0165 A003          jz    . + 4                     ; jump if global interrupt disabled
 0167 7101          or    F, FlagGlobalIE
                endif
 0169 43E020        or    reg[INT_MSK0], INT_MSK0_GPIO              
 016C 8EDE                  jmp l_start                             ;start over
 016E                       
 016E 7F                    ret                 
 016F              
 016F           ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::   
 016F           ; Name      : TIMER8_1_ISR
 016F           ; Desc.     : Interrupt Service Routine for the timer
 016F           ; Input     : None
 016F           ; Output    : None
 016F           ; Operation : Serves Digital0 interrupt used by Timer. It will test comparator 
 016F           ;             output and increment corresponding counter. It will also increment
 016F           ;             sampling counter 
 016F           ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::         
 016F           TIMER8_1_ISR:                       
 016F 496410                tst REG[CMP_CR], 0x10                   ;mask comp 0
 0172 A005                  jz brn_isr_bit0                         ;if comp != 0
 0174 7604                  inc [hi_cnt]                            ;inc. hi_cnt
 0176 8003                  jmp brn_isr_end
 0178           brn_isr_bit0:
 0178 7605                  inc [lo_cnt]                            ;else inc. lo_cnt
 017A           brn_isr_end:
 017A 7608                  inc [sample_cnt]                        ;inc. sample_cnt
 017C                       
 017C 7E                    reti        
 017D            
 017D           ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::   
 017D           ; Name      : GPIO_ISR
 017D           ; Desc.     : Interrupt Service Routine for GPIO
 017D           ; Input     : None
 017D           ; Output    : None
 017D           ; Operation : Serves GPIO interrupt enabled on P1[7] as "change of state" type.
 017D           ;             If start flag is 0, it will read timer count, restart timer with 
 017D           ;             2msec. period and set ready flag. If start flag is set, it will 
 017D           ;             restart counter, enable comparator interrupt and disable GPIO.
 017D           ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::           
 017D           GPIO_ISR:                          
 017D 08                    push A
 017E 5D04                  mov A, REG[PRT1DR]                      ;read input port
 0180 5101                  mov A, [start]                          ;if start == 0
 0182 B016                  jnz .brn_isr_start
 0184 550001                mov [ready], 1                          ;set ready flag
 0187 9000                  call bTimer8_1_ReadTimer                ;read timer count
 0189 5302                  mov [rate], A                           ;save timer count as rate
 018B 9000                  call Timer8_1_Stop                      ;stop timer 
 018D 50FF                  mov A, FFh
 018F 9000                  call Timer8_1_WritePeriod               ;write timer period
 0191 5000                  mov A, 00h
 0193 9000                  call Timer8_1_WriteCompareValue         ;write timer compare value
 0195 9000                  call Timer8_1_Start                     ;start timer  
 0197 8015                  jmp .brn_isr_end
 0199           .brn_isr_start:
 0199                       ;statr == 1
 0199 9000                  call Timer8_1_Stop
 019B 9000                  call Timer8_1_Start
                if DISABLE_INT_FIX
 019D 5DFF          mov   A, reg[CPU_SCR]           ; save the current Global interrupt state
 019F 70FE          and   F, ~FlagGlobalIE
                endif
 01A1 41E0DF        and   reg[INT_MSK0], ~INT_MSK0_GPIO              ; disable specified interrupt enable bit
                if DISABLE_INT_FIX
 01A4 2180          and   A, CPUSCR_GIEMask         ; determine if global interrupt was set
 01A6 A003          jz    . + 4                     ; jump if global interrupt disabled
 01A8 7101          or    F, FlagGlobalIE
                endif
 01AA 43E002        or    reg[INT_MSK0], INT_MSK0_AColumn0              
 01AD           .brn_isr_end:         
 01AD 18                    pop A
 01AE 7E                    reti             
 01AF            
 01AF           ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::   
 01AF           ; Name      : GPIO_ISR
 01AF           ; Desc.     : Interrupt Service Routine for Comparator
 01AF           ; Input     : None
 01AF           ; Output    : None
 01AF           ; Operation : Serves Analog0 interrupt used by comparator. On the rising edge it
 01AF           ;           ; will synchronize sampling count to the begining of new bit
 01AF           ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::           
 01AF           COMP_ISR:                         
 01AF 3C0805                            cmp [sample_cnt], 5                                             
 01B2 C006                              jc .brn_isr_left                        ;if sample_cnt. > SAMPLE_NUM/2
 01B4 550809                            mov [sample_cnt], SAMPLE_NUM            ;set sample_cnt = SAMPLE_NUM
 01B7 800A                              jmp .brn_isr_right
 01B9           .brn_isr_left:
 01B9 550800                mov [sample_cnt], 0                     ;esle sample_cnt = 0
 01BC 550400                mov [hi_cnt], 0                         ;reset hi_cnt
 01BF 550500                mov [lo_cnt], 0                         ;reset lo_cnt
 01C2           .brn_isr_right:
 01C2 7E                    reti                                                                        

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -