home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s093 / 1.img / DEMO51.LST < prev    next >
Encoding:
File List  |  1980-01-01  |  6.9 KB  |  204 lines

  1. The Cybernetic Micro Systems 8051 Family Assembler, Version 3.03   Page   1
  2.                                                                    01-01-80
  3.  
  4.  
  5.                 ; Copyright 1985 Cybernetic Micro Systems, Inc.
  6.                 
  7.                 ; Demo51.ASM    8051 Source Code
  8.                 
  9.  0000           Bseg        ; Bit Segment directive
  10.  000A =          MFlag    BIT 0Ah ; Bit address 10 decimal
  11.  000E =          DisB    BIT 0Eh ; Bit address 14 decimal
  12.  0010 =          RB2     =  10h ; Pattern to select Reg Bank 2
  13.  0002           Ends
  14.                 
  15.  0000           Dseg          ; Data Segment directive
  16.  0000 =          REGbuffer DATA 0 ; dummy to show Data Type
  17.  0001           Ends
  18.                 
  19.  0000           Xseg           ; External Memory Segment
  20.  0020 =          DummyBuf Data 20h ; dummy to show Data Type
  21.  0001           Ends
  22.                 
  23.  0000           Cseg           ; Code Segment Directive
  24.                 
  25.  0000           ORG 0h
  26.                 
  27.                 ;%S Copyright 1985 Cybernetic Micro Systems, Inc.
  28.                 
  29.                 Begin:
  30.  0000 012C      ajmp ReStart
  31.                 
  32.  0003           ORG 3h        ; External Interrupt 0 Vector
  33.  0003 00        nop
  34.                 Ext0Int:    ;:Pin 12 LOW
  35.  0004 32        reti        ; do nothing for Ext 0
  36.                 
  37.                 
  38.  000B           ORG 0Bh     ; Timer/Counter 0 Vector
  39.  000B 0182      ajmp T0Int    ; if Timer 0 Interrupt
  40.                 
  41.                 
  42.  0013           ORG 13h     ; External Interrupt 1 Vector
  43.  0013 32        reti        ; do nothing for Ext 1
  44.                 
  45.                 
  46.  001B           ORG 1Bh     ; Timer/Counter 1 Vector
  47.                 ;        ; Should NOT be enabled,
  48.  001B 32        reti        ; T1 is used for Serial clock
  49.                 
  50.                 
  51.  0023           ORG 23h     ; Serial Interrupt Vector
  52.  0023 0185      ajmp SerialInt    ; if Serial Interrupt
  53.                 
  54.                 
  55.  002B           ORG 2Bh     ; Timer/Counter 2 Vector
  56.                 ;        ; not used in this program,
  57.  002B 32        reti        ; T2 only exists in the 8052
  58.                 
  59.                 
  60. The Cybernetic Micro Systems 8051 Family Assembler, Version 3.03   Page   2
  61.                                                                    01-01-80
  62.  
  63.  
  64.                 ReStart:    ;:Hdw Reset
  65.  002C 758920    mov TMOD,#20h    ; T0 prescaler mode, T1 auto reload
  66.  002F 758DFD    mov TH1,#0FDh    ; reload value for serial communications
  67.  0032 758BFD    mov TL1,#0FDh    ; also initial count value
  68.  0035 D28E      setb TR1    ; turn on timer 1
  69.  0037 D28C      setb TR0    ; and timer 0
  70.  0039 0E        inc R6        ; count # of reset cycles
  71.  003A 120078    lcall InitSer    ; turn on serial interface
  72.  003D 75A897    mov IE,#97h    ; enable all interrupts except T1 & T2
  73.                 ;
  74.                 MainLoop:    ;: Init Regs
  75.  0040 7C0F      mov R4,#15    ; loop counter
  76.  0042 09        inc R1
  77.                 ;
  78.                 zeroVAL:    ;:Value <- 0
  79.  0043 E4        clr A
  80.  0044 7A00      mov R2,#0    ; also clear R2
  81.  0046 C20A      clr Mflag    ; control bit
  82.                 ;
  83.                 doLoop:     ;: Count Loop
  84.  0048 CA        xch A,R2
  85.  0049 2403      add A,#3    ;change increment value
  86.  004B CA        xch A,R2
  87.  004C 200A0F    jb  MFlag,ValMax ;?A = Max
  88.                 ;
  89.                 OutP1:        ;:  P1 <- AC
  90.  004F 2A        add A,R2
  91.  0050 F590      mov P1,A
  92.                 ;
  93.  0052 200E03    jb DisB,NotStore ;? DisB=1
  94.                 ;
  95.  0055 1168      acall StoreVal    ;record value in external memory
  96.  0057 0D        inc R5
  97.                 ;
  98.                 NotStore:    ;:Test Value
  99.  0058 D3        setb C
  100.  0059 30E704    jnb ACC.7,NotMAX ;?Not Max Yet
  101.  005C D20A      setb Mflag    ; disable counting
  102.                 ;
  103.                 VALMax:     ;: Have MAX
  104.  005E 116E      acall SwitchBanks
  105.                 ;
  106.                 NotMax:     ;:Repeat Loop
  107.  0060 B3        cpl C
  108.  0061 DCE5      djnz R4,DoLoop    ;?R4 > 0
  109.                 ;
  110.  0063 7590FF    mov P1,#0FFh    ; set Port 1 all high again
  111.  0066 0140      ajmp MainLoop
  112.                 
  113.                 StoreVAL:    ;: record Value
  114.  0068 C0D0      push psw
  115.  006A F3        movx @R1,A    ; save in external memory
  116.  006B D0D0      pop psw
  117.  006D 22        ret
  118.                 
  119. The Cybernetic Micro Systems 8051 Family Assembler, Version 3.03   Page   3
  120.                                                                    01-01-80
  121.  
  122.  
  123.                 SwitchBanks:
  124.  006E 1174      acall SelRB2
  125.                 ;
  126.                 SelRB0:     ;: BS -> 0
  127.  0070 53D0E7    anl PSW,#0E7h
  128.  0073 22        ret
  129.                 ;
  130.                 SelRB2:     ;: BS -> 2
  131.  0074 43D010    orl PSW,#RB2
  132.  0077 22        ret
  133.                 
  134.                 InitSer:    ;: UART on
  135.  0078 759852    mov SCON,#052h    ; mode 1, REN on, TI on
  136.  007B 1174      acall SelRB2
  137.  007D 7B55      mov R3,#55h    ; data to transmit
  138.  007F 1170      acall SelRB0
  139.  0081 22        ret
  140.                 
  141.                 T0Int:        ;:T0 Interrupt
  142.  0082 B20E      cpl DisB    ; complement control bit
  143.  0084 32        reti
  144.                 
  145.                 SerialInt:    ;:UART Routine
  146.  0085 0F        inc R7
  147.  0086 109909    jbc TI,SerialTx ;?Tx Ready
  148.  0089 C298      clr RI        ; else clear receiver
  149.  008B 1174      acall SelRB2
  150.  008D AC99      mov R4,SBUF    ; read received data to R4
  151.  008F 1170      acall SelRB0
  152.  0091 32        reti
  153.                 ;
  154.                 SerialTx:
  155.  0092 1174      acall SelRB2
  156.  0094 CB        xch A,R3
  157.  0095 23        rl  A        ; rotate data to transmit
  158.  0096 F599      mov SBUF,A    ; write to transmitter
  159.  0098 CB        xch A,R3    ; save new data
  160.  0099 1170      acall SelRB0
  161.  009B 32        reti
  162.                 
  163.  009C 00        nop
  164.                 
  165.                 ;%E    Copyright 1985 Cybernetic Micro Systems, Inc.
  166.                 
  167.  009D           Ends        ; end of Code segment
  168.                 
  169.  0000           END Begin
  170. The Cybernetic Micro Systems 8051 Family Assembler, Version 3.03   Page   4
  171.                                                                    01-01-80
  172.  
  173.  
  174.  
  175.  ;%T   Symbol Name            Type Value
  176.  
  177.  BEGIN . . . . . . . . . . . . . L 0000
  178.  DISB. . . . . . . . . . . . . . B 000E
  179.  DOLOOP. . . . . . . . . . . . . L 0048
  180.  DUMMYBUF. . . . . . . . . . . . X 0020
  181.  EXT0INT . . . . . . . . . . . . L 0004
  182.  INITSER . . . . . . . . . . . . L 0078
  183.  MAINLOOP. . . . . . . . . . . . L 0040
  184.  MFLAG . . . . . . . . . . . . . B 000A
  185.  NOTMAX. . . . . . . . . . . . . L 0060
  186.  NOTSTORE. . . . . . . . . . . . L 0058
  187.  OUTP1 . . . . . . . . . . . . . L 004F
  188.  RB2 . . . . . . . . . . . . . . I 0010
  189.  REGBUFFER . . . . . . . . . . . D 0000
  190.  RESTART . . . . . . . . . . . . L 002C
  191.  SELRB0. . . . . . . . . . . . . L 0070
  192.  SELRB2. . . . . . . . . . . . . L 0074
  193.  SERIALINT . . . . . . . . . . . L 0085
  194.  SERIALTX. . . . . . . . . . . . L 0092
  195.  STOREVAL. . . . . . . . . . . . L 0068
  196.  SWITCHBANKS . . . . . . . . . . L 006E
  197.  T0INT . . . . . . . . . . . . . L 0082
  198.  VALMAX. . . . . . . . . . . . . L 005E
  199.  ZEROVAL . . . . . . . . . . . . L 0043
  200.  
  201.  ;%Z 
  202.  
  203.  00 Errors  (0000)
  204.