home *** CD-ROM | disk | FTP | other *** search
File List | 1979-12-31 | 6.9 KB | 204 lines |
- The Cybernetic Micro Systems 8051 Family Assembler, Version 3.03 Page 1
- 01-01-80
-
-
- ; Copyright 1985 Cybernetic Micro Systems, Inc.
-
- ; Demo51.ASM 8051 Source Code
-
- 0000 Bseg ; Bit Segment directive
- 000A = MFlag BIT 0Ah ; Bit address 10 decimal
- 000E = DisB BIT 0Eh ; Bit address 14 decimal
- 0010 = RB2 = 10h ; Pattern to select Reg Bank 2
- 0002 Ends
-
- 0000 Dseg ; Data Segment directive
- 0000 = REGbuffer DATA 0 ; dummy to show Data Type
- 0001 Ends
-
- 0000 Xseg ; External Memory Segment
- 0020 = DummyBuf Data 20h ; dummy to show Data Type
- 0001 Ends
-
- 0000 Cseg ; Code Segment Directive
-
- 0000 ORG 0h
-
- ;%S Copyright 1985 Cybernetic Micro Systems, Inc.
-
- Begin:
- 0000 012C ajmp ReStart
-
- 0003 ORG 3h ; External Interrupt 0 Vector
- 0003 00 nop
- Ext0Int: ;:Pin 12 LOW
- 0004 32 reti ; do nothing for Ext 0
-
-
- 000B ORG 0Bh ; Timer/Counter 0 Vector
- 000B 0182 ajmp T0Int ; if Timer 0 Interrupt
-
-
- 0013 ORG 13h ; External Interrupt 1 Vector
- 0013 32 reti ; do nothing for Ext 1
-
-
- 001B ORG 1Bh ; Timer/Counter 1 Vector
- ; ; Should NOT be enabled,
- 001B 32 reti ; T1 is used for Serial clock
-
-
- 0023 ORG 23h ; Serial Interrupt Vector
- 0023 0185 ajmp SerialInt ; if Serial Interrupt
-
-
- 002B ORG 2Bh ; Timer/Counter 2 Vector
- ; ; not used in this program,
- 002B 32 reti ; T2 only exists in the 8052
-
-
- The Cybernetic Micro Systems 8051 Family Assembler, Version 3.03 Page 2
- 01-01-80
-
-
- ReStart: ;:Hdw Reset
- 002C 758920 mov TMOD,#20h ; T0 prescaler mode, T1 auto reload
- 002F 758DFD mov TH1,#0FDh ; reload value for serial communications
- 0032 758BFD mov TL1,#0FDh ; also initial count value
- 0035 D28E setb TR1 ; turn on timer 1
- 0037 D28C setb TR0 ; and timer 0
- 0039 0E inc R6 ; count # of reset cycles
- 003A 120078 lcall InitSer ; turn on serial interface
- 003D 75A897 mov IE,#97h ; enable all interrupts except T1 & T2
- ;
- MainLoop: ;: Init Regs
- 0040 7C0F mov R4,#15 ; loop counter
- 0042 09 inc R1
- ;
- zeroVAL: ;:Value <- 0
- 0043 E4 clr A
- 0044 7A00 mov R2,#0 ; also clear R2
- 0046 C20A clr Mflag ; control bit
- ;
- doLoop: ;: Count Loop
- 0048 CA xch A,R2
- 0049 2403 add A,#3 ;change increment value
- 004B CA xch A,R2
- 004C 200A0F jb MFlag,ValMax ;?A = Max
- ;
- OutP1: ;: P1 <- AC
- 004F 2A add A,R2
- 0050 F590 mov P1,A
- ;
- 0052 200E03 jb DisB,NotStore ;? DisB=1
- ;
- 0055 1168 acall StoreVal ;record value in external memory
- 0057 0D inc R5
- ;
- NotStore: ;:Test Value
- 0058 D3 setb C
- 0059 30E704 jnb ACC.7,NotMAX ;?Not Max Yet
- 005C D20A setb Mflag ; disable counting
- ;
- VALMax: ;: Have MAX
- 005E 116E acall SwitchBanks
- ;
- NotMax: ;:Repeat Loop
- 0060 B3 cpl C
- 0061 DCE5 djnz R4,DoLoop ;?R4 > 0
- ;
- 0063 7590FF mov P1,#0FFh ; set Port 1 all high again
- 0066 0140 ajmp MainLoop
-
- StoreVAL: ;: record Value
- 0068 C0D0 push psw
- 006A F3 movx @R1,A ; save in external memory
- 006B D0D0 pop psw
- 006D 22 ret
-
- The Cybernetic Micro Systems 8051 Family Assembler, Version 3.03 Page 3
- 01-01-80
-
-
- SwitchBanks:
- 006E 1174 acall SelRB2
- ;
- SelRB0: ;: BS -> 0
- 0070 53D0E7 anl PSW,#0E7h
- 0073 22 ret
- ;
- SelRB2: ;: BS -> 2
- 0074 43D010 orl PSW,#RB2
- 0077 22 ret
-
- InitSer: ;: UART on
- 0078 759852 mov SCON,#052h ; mode 1, REN on, TI on
- 007B 1174 acall SelRB2
- 007D 7B55 mov R3,#55h ; data to transmit
- 007F 1170 acall SelRB0
- 0081 22 ret
-
- T0Int: ;:T0 Interrupt
- 0082 B20E cpl DisB ; complement control bit
- 0084 32 reti
-
- SerialInt: ;:UART Routine
- 0085 0F inc R7
- 0086 109909 jbc TI,SerialTx ;?Tx Ready
- 0089 C298 clr RI ; else clear receiver
- 008B 1174 acall SelRB2
- 008D AC99 mov R4,SBUF ; read received data to R4
- 008F 1170 acall SelRB0
- 0091 32 reti
- ;
- SerialTx:
- 0092 1174 acall SelRB2
- 0094 CB xch A,R3
- 0095 23 rl A ; rotate data to transmit
- 0096 F599 mov SBUF,A ; write to transmitter
- 0098 CB xch A,R3 ; save new data
- 0099 1170 acall SelRB0
- 009B 32 reti
-
- 009C 00 nop
-
- ;%E Copyright 1985 Cybernetic Micro Systems, Inc.
-
- 009D Ends ; end of Code segment
-
- 0000 END Begin
- The Cybernetic Micro Systems 8051 Family Assembler, Version 3.03 Page 4
- 01-01-80
-
-
-
- ;%T Symbol Name Type Value
-
- BEGIN . . . . . . . . . . . . . L 0000
- DISB. . . . . . . . . . . . . . B 000E
- DOLOOP. . . . . . . . . . . . . L 0048
- DUMMYBUF. . . . . . . . . . . . X 0020
- EXT0INT . . . . . . . . . . . . L 0004
- INITSER . . . . . . . . . . . . L 0078
- MAINLOOP. . . . . . . . . . . . L 0040
- MFLAG . . . . . . . . . . . . . B 000A
- NOTMAX. . . . . . . . . . . . . L 0060
- NOTSTORE. . . . . . . . . . . . L 0058
- OUTP1 . . . . . . . . . . . . . L 004F
- RB2 . . . . . . . . . . . . . . I 0010
- REGBUFFER . . . . . . . . . . . D 0000
- RESTART . . . . . . . . . . . . L 002C
- SELRB0. . . . . . . . . . . . . L 0070
- SELRB2. . . . . . . . . . . . . L 0074
- SERIALINT . . . . . . . . . . . L 0085
- SERIALTX. . . . . . . . . . . . L 0092
- STOREVAL. . . . . . . . . . . . L 0068
- SWITCHBANKS . . . . . . . . . . L 006E
- T0INT . . . . . . . . . . . . . L 0082
- VALMAX. . . . . . . . . . . . . L 005E
- ZEROVAL . . . . . . . . . . . . L 0043
-
- ;%Z
-
- 00 Errors (0000)
-