#include <pcx51.inc>
#include <Rc51Regs.inc>
C0Seg     segment code
CodeSeg   segment code
XDataSeg  segment xdata

; --- external and public functions ---
public            _main
public            _pulse

; --- external and public variables ---

                                        ; #line 1 // ------------- READS51 generated header -------------- 
                                        ; #line 2 // module  : C:\Rigel\Reads51\Work\Count\count.c
                                        ; #line 3 // created : 18:26:23, Monday, November 12, 2001
                                        ; #line 4 // ----------------------------------------------------- 
                                        ; #line 5 
                                        ; #line 6 /*"#C:\Rigel\Reads51\Include\sfr51.h"*/
                                        ; #line 7 // --- 8051 registers ---
                                        ; #line 8 sfr ACC (0xE0),
                                        ; #line 9     B   (0xF0),
                                        ; #line 10     DPH (0x83),
                                        ; #line 11     DPL (0x82),
                                        ; #line 12     IE  (0xA8),
                                        ; #line 13     IP  (0xB8),
                                        ; #line 14     P0  (0x80),
                                        ; #line 15     P1  (0x90),
                                        ; #line 16     P2  (0xA0),
                                        ; #line 17     P3  (0xB0),
                                        ; #line 18     PCON(0x87),
                                        ; #line 19     PSW (0xD0),
                                        ; #line 20     SBUF(0x99),
                                        ; #line 21     SCON(0x98),
                                        ; #line 22     SP  (0x81),
                                        ; #line 23     TCON(0x88),
                                        ; #line 24     TH0 (0x8C),
                                        ; #line 25     TH1 (0x8D),
                                        ; #line 26     TL0 (0x8A),
                                        ; #line 27     TL1 (0x8B),
                                        ; #line 28     TMOD(0x89);
                                        ; #line 29 
                                        ; #line 30 // --- 8051 register bit fields ---
                                        ; #line 31 // IE
                                        ; #line 32 sfrbit EA  (0xAF),
                                        ; #line 33        ES  (0xAC),
                                        ; #line 34        ET1 (0xAB),
                                        ; #line 35        EX1 (0xAA),
                                        ; #line 36        ET0 (0xA9),
                                        ; #line 37        EX0 (0xA8),
                                        ; #line 38 // IP 
                                        ; #line 39        PS  (0xBC),
                                        ; #line 40        PT1 (0xBB),
                                        ; #line 41        PX1 (0xBA),
                                        ; #line 42        PT0 (0xB9),
                                        ; #line 43        PX0 (0xB8),
                                        ; #line 44 // P0
                                        ; #line 45        P0_0(0x80),
                                        ; #line 46        P0_1(0x81),
                                        ; #line 47        P0_2(0x82),
                                        ; #line 48        P0_3(0x83),
                                        ; #line 49        P0_4(0x84),
                                        ; #line 50        P0_5(0x85),
                                        ; #line 51        P0_6(0x86),
                                        ; #line 52        P0_7(0x87),
                                        ; #line 53 // P1
                                        ; #line 54        P1_0(0x90),
                                        ; #line 55        P1_1(0x91),
                                        ; #line 56        P1_2(0x92),
                                        ; #line 57        P1_3(0x93),
                                        ; #line 58        P1_4(0x94),
                                        ; #line 59        P1_5(0x95),
                                        ; #line 60        P1_6(0x96),
                                        ; #line 61        P1_7(0x97),
                                        ; #line 62 // P2
                                        ; #line 63        P2_0(0xA0),
                                        ; #line 64        P2_1(0xA1),
                                        ; #line 65        P2_2(0xA2),
                                        ; #line 66        P2_3(0xA3),
                                        ; #line 67        P2_4(0xA4),
                                        ; #line 68        P2_5(0xA5),
                                        ; #line 69        P2_6(0xA6),
                                        ; #line 70        P2_7(0xA7),
                                        ; #line 71 // P3
                                        ; #line 72        P3_0(0xB0),
                                        ; #line 73        P3_1(0xB1),
                                        ; #line 74        P3_2(0xB2),
                                        ; #line 75        P3_3(0xB3),
                                        ; #line 76        P3_4(0xB4),
                                        ; #line 77        P3_5(0xB5),
                                        ; #line 78        P3_6(0xB6),
                                        ; #line 79        P3_7(0xB7),
                                        ; #line 80 // P3 alternate function pin names
                                        ; #line 81        RD  (0xB7),
                                        ; #line 82        WR  (0xB6),
                                        ; #line 83        T1  (0xB5),
                                        ; #line 84        T0  (0xB4),
                                        ; #line 85        INT1(0xB3),
                                        ; #line 86        INT0(0xB2),
                                        ; #line 87        TXD (0xB1),
                                        ; #line 88        RXD (0xB0),
                                        ; #line 89 // PSW
                                        ; #line 90        CY  (0xD7),
                                        ; #line 91        AC  (0xD6),
                                        ; #line 92        F0  (0xD5),
                                        ; #line 93        RS1 (0xD4),
                                        ; #line 94        RS0 (0xD3),
                                        ; #line 95        OV  (0xD2),
                                        ; #line 96        P   (0xD0),
                                        ; #line 97 // TCON
                                        ; #line 98        TF1 (0x8F),
                                        ; #line 99        TR1 (0x8E),
                                        ; #line 100        TF0 (0x8D),
                                        ; #line 101        TR0 (0x8C),
                                        ; #line 102        IE1 (0x8B),
                                        ; #line 103        IT1 (0x8A),
                                        ; #line 104        IE0 (0x89),
                                        ; #line 105        IT0 (0x88),
                                        ; #line 106 // SCON
                                        ; #line 107        SM0 (0x9F),
                                        ; #line 108        SM1 (0x9E),
                                        ; #line 109        SM2 (0x9D),
                                        ; #line 110        REN (0x9C),
                                        ; #line 111        TB8 (0x9B),
                                        ; #line 112        RB8 (0x9A),
                                        ; #line 113        TI  (0x99),
                                        ; #line 114        RI  (0x98);
                                        ; #line 115 
                                        ; #line 116  
                                        ; #line 117 void pulse(void){
                                        ; -----------------------------------------------
          rseg    CodeSeg               ; CHGSEG(2)
_pulse:                                 ; DECLPUBm(pulse)
          pop     b                     ; ENTER
          pop     acc
          lcall   __enter
                                        ; #line 118   while(P1_0);
                                        ; -----------------------------------------------
_1:                                     ; LABm(_1:)
          mov     PRH, #0               ; GETsfrbit1(144)
          clr     a
          mov     C, 0x90
          mov     acc.0, C
          mov     PRL, a
          mov     a, PRL                ; EQ10(_2)
          orl     a, PRH
          jnz     $+5
          ljmp    _2
                                        ; #line 119   while(!(P1_0));
                                        ; -----------------------------------------------
          ljmp    _1                    ; JMPn(_1)
_2:                                     ; LABm(_2:)
                                        ; -----------------------------------------------
_3:                                     ; LABm(_3:)
          mov     PRH, #0               ; GETsfrbit1(144)
          clr     a
          mov     C, 0x90
          mov     acc.0, C
          mov     PRL, a
          lcall   __lneg1               ; LNEG1
          mov     a, PRL                ; EQ10(_4)
          orl     a, PRH
          jnz     $+5
          ljmp    _4
                                        ; #line 120 }
                                        ; -----------------------------------------------
          ljmp    _3                    ; JMPn(_3)
_4:                                     ; LABm(_4:)
                                        ; -----------------------------------------------
          lcall   __return              ; RETURN(0)
                                        ; #line 121 
                                        ; #line 122 
                                        ; #line 123 main(){
                                        ; -----------------------------------------------
_main:                                  ; DECLPUBm(main)
          mov     SPH, #0x40            ; ENTERMAIN(16384)
          mov     SPL, #0x00
          mov     BPH, SPH
          mov     BPL, SPL
                                        ; #line 124   int n;
                                        ; #line 125   n=0;
                                        ; -----------------------------------------------
          mov     a, #0x02              ; ADDSP(2)
          mov     b, #0x00
          lcall   __addsp
          mov     SRL, BPL              ; POINT2s(0)
          mov     SRH, BPH
          mov     PRL, #0x00            ; GETw1n(0)
          mov     PRH, #0x00
          lcall   __putwp1              ; PUTwp1
                                        ; #line 126   while(1)
                                        ; -----------------------------------------------
_5:                                     ; LABm(_5:)
          mov     PRL, #0x01            ; GETw1n(1)
          mov     PRH, #0x00
                                        ; #line 127     {
                                        ; #line 128      while (n<10)
                                        ; -----------------------------------------------
_7:                                     ; LABm(_7:)
          mov     a, #0x00              ; GETw1s(0)
          mov     b, #0x00
          lcall   __getw1s
          mov     SRL, #0x0A            ; GETw2n(10)
          mov     SRH, #0x00
          lcall   __lt12                ; LT12
          mov     a, PRL                ; EQ10(_8)
          orl     a, PRH
          jnz     $+5
          ljmp    _8
                                        ; #line 129      {
                                        ; #line 130        pulse();
                                        ; -----------------------------------------------
          mov     ARGCNT, #0x00         ; ARGCNTn(0)
          lcall   _pulse                ; CALLm(_pulse)
                                        ; #line 131        n=n+1;
                                        ; -----------------------------------------------
          mov     a, #0x00              ; GETw1s(0)
          mov     b, #0x00
          lcall   __getw1s
          mov     a, #0x01              ; rINC1(1)
          lcall   __rinc1
          mov     SRL, BPL              ; POINT2s(0)
          mov     SRH, BPH
          lcall   __putwp1              ; PUTwp1
                                        ; #line 132      }
                                        ; #line 133      P1_1=1;
                                        ; -----------------------------------------------
          ljmp    _7                    ; JMPn(_7)
_8:                                     ; LABm(_8:)
                                        ; -----------------------------------------------
          setb    0x91                  ; SETbitn(145)
                                        ; #line 134      while (n<20)
                                        ; -----------------------------------------------
_9:                                     ; LABm(_9:)
          mov     a, #0x00              ; GETw1s(0)
          mov     b, #0x00
          lcall   __getw1s
          mov     SRL, #0x14            ; GETw2n(20)
          mov     SRH, #0x00
          lcall   __lt12                ; LT12
          mov     a, PRL                ; EQ10(_10)
          orl     a, PRH
          jnz     $+5
          ljmp    _10
                                        ; #line 135      {
                                        ; #line 136        pulse();
                                        ; -----------------------------------------------
          mov     ARGCNT, #0x00         ; ARGCNTn(0)
          lcall   _pulse                ; CALLm(_pulse)
                                        ; #line 137        n=n+1;
                                        ; -----------------------------------------------
          mov     a, #0x00              ; GETw1s(0)
          mov     b, #0x00
          lcall   __getw1s
          mov     a, #0x01              ; rINC1(1)
          lcall   __rinc1
          mov     SRL, BPL              ; POINT2s(0)
          mov     SRH, BPH
          lcall   __putwp1              ; PUTwp1
                                        ; #line 138      }
                                        ; #line 139      P1_1=0;
                                        ; -----------------------------------------------
          ljmp    _9                    ; JMPn(_9)
_10:                                    ; LABm(_10:)
                                        ; -----------------------------------------------
          clr     0x91                  ; CLRbitn(145)
                                        ; #line 140      n=0;
                                        ; -----------------------------------------------
          mov     SRL, BPL              ; POINT2s(0)
          mov     SRH, BPH
          mov     PRL, #0x00            ; GETw1n(0)
          mov     PRH, #0x00
          lcall   __putwp1              ; PUTwp1
                                        ; #line 141     }
                                        ; #line 142 }
                                        ; -----------------------------------------------
          ljmp    _5                    ; JMPn(_5)
_6:                                     ; LABm(_6:)
          mov     a, #0xFE              ; ADDSP(-2)
          mov     b, #0xFF
          lcall   __addsp
                                        ; -----------------------------------------------
          ljmp    _main                 ; RETMAIN
                                        ; #line 143 
                                        ; #line 144 
                                        ; -----------------------------------------------
          end                           ; ENDSEG(2)
