demo1 DEMO 2 11/29/1182 PAGE 1 1 ; MCU 8051 IDE - Demonstration code 2 ; Macro instructions, conditional compilation and constants 3 ; Try tab "Graph" on bottom panel 4 5 ; Press F2 and F6 to run the program (start simulator and animate) 6 7 $TITLE('DEMO 2') ; Set title for code listing 8 $DATE(11/29/1182) ; Set date for code listing (the 29th of November 1182, welcome back to the M 9 10 ; Constant definitions 11 ; -------------------- 000F 12 counter idata 00Fh ; Counter of Px shifts 0064 13 x set 100 ; Some variable 0001 14 inc_dec equ 100 / X ; Flag: Increment/Decrement counter 15 16 cseg at 1FFh ; Code segment starts at 0x1FF 01FF 04 17 something: db 4d ; Reserve 4 bytes in this segment 18 19 ; Macro instructions 20 ; -------------------- 21 22 ;; Shift the given registers 23 shift macro reg0, reg1 24 25 ; Increment / Decrement counter 26 mov A, counter 27 if inc_dec <> 0 28 inc A 29 else 30 dec A 31 endif 33 mov counter, A 34 $list ; <- Enable code listing 35 36 ; Shift 37 mov reg1, reg0 38 mov reg0, reg1 39 setb C 40 mov A, reg0 41 rl A 42 mov reg0, A 43 endm 44 45 ; Program initialization 46 ; -------------------- 47 org 0h ****WARNING:ThisORGhaslowervaluethanthepreviousone 0000 8000 48 sjmp start 49 50 ; Program start 51 ; -------------------- 0002 75900F 52 start: mov P1, #00Fh 0005 75B01E 53 mov P3, #01Eh 0008 8000 54 sjmp main 55 56 ; Main loop 57 ; -------------------- 58 +1 main: shift P1, P3 59 +1 000A E50F 60 +1 mov a , counter 61 +1 if inc_dec <> 0 000C 04 62 +1 inc a 63 +1 else 64 +1 dec a 65 +1 endif 000D F50F 66 +1 mov counter , a 67 +1 000F 8590B0 68 +1 mov P3 , P1 0012 85B090 69 +1 mov P1 , P3 0015 D3 70 +1 setb c 0016 E590 71 +1 mov a , P1 0018 23 72 +1 rl a 0019 F590 73 +1 mov P1 , a 001B 80ED 74 sjmp main 75 76 ; Program end 77 ; -------------------- 78 end ASSEMBLY COMPLETE, NO ERRORS FOUND, 1 WARNING ERROR SUMMARY: Line 49, WARNING:ThisORGhaslowervaluethanthepreviousone SYMBOL TABLE: ??MCU_8051_IDE . . . . . . . . . . . N NUMB 8051H NOT USED ??VERSION. . . . . . . . . . . . . . N NUMB 0149H NOT USED AC . . . . . . . . . . . . . . . . . B ADDR 00D6H NOT USED ACC. . . . . . . . . . . . . . . . . D ADDR 00E0H NOT USED ACSR . . . . . . . . . . . . . . . . D ADDR 0097H NOT USED ADCF . . . . . . . . . . . . . . . . D ADDR 00F6H NOT USED ADCLK. . . . . . . . . . . . . . . . D ADDR 00F2H NOT USED ADCON. . . . . . . . . . . . . . . . D ADDR 00F3H NOT USED ADDH . . . . . . . . . . . . . . . . D ADDR 00F5H NOT USED ADDL . . . . . . . . . . . . . . . . D ADDR 00F4H NOT USED AUXR . . . . . . . . . . . . . . . . D ADDR 008EH NOT USED AUXR1. . . . . . . . . . . . . . . . D ADDR 00A2H NOT USED B. . . . . . . . . . . . . . . . . . D ADDR 00F0H NOT USED BDRCON . . . . . . . . . . . . . . . D ADDR 009BH NOT USED BDRCON_1 . . . . . . . . . . . . . . D ADDR 009CH NOT USED BRL. . . . . . . . . . . . . . . . . D ADDR 009AH NOT USED CCAP0H . . . . . . . . . . . . . . . D ADDR 00FAH NOT USED CCAP0L . . . . . . . . . . . . . . . D ADDR 00EAH NOT USED CCAP1H . . . . . . . . . . . . . . . D ADDR 00FBH NOT USED CCAP1L . . . . . . . . . . . . . . . D ADDR 00EBH NOT USED CCAP2H . . . . . . . . . . . . . . . D ADDR 00FCH NOT USED CCAP3H . . . . . . . . . . . . . . . D ADDR 00FDH NOT USED CCAP4H . . . . . . . . . . . . . . . D ADDR 00FEH NOT USED CCAPL2H. . . . . . . . . . . . . . . D ADDR 00FCH NOT USED CCAPL2L. . . . . . . . . . . . . . . D ADDR 00ECH NOT USED CCAPL3H. . . . . . . . . . . . . . . D ADDR 00FDH NOT USED CCAPL3L. . . . . . . . . . . . . . . D ADDR 00EDH NOT USED CCAPL4H. . . . . . . . . . . . . . . D ADDR 00FEH NOT USED CCAPL4L. . . . . . . . . . . . . . . D ADDR 00EEH NOT USED CCAPM0 . . . . . . . . . . . . . . . D ADDR 00DAH NOT USED CCAPM1 . . . . . . . . . . . . . . . D ADDR 00DBH NOT USED CCAPM2 . . . . . . . . . . . . . . . D ADDR 00DCH NOT USED CCAPM3 . . . . . . . . . . . . . . . D ADDR 00DDH NOT USED CCAPM4 . . . . . . . . . . . . . . . D ADDR 00DEH NOT USED CCF0 . . . . . . . . . . . . . . . . B ADDR 00D8H NOT USED CCF1 . . . . . . . . . . . . . . . . B ADDR 00D9H NOT USED CCF2 . . . . . . . . . . . . . . . . B ADDR 00DAH NOT USED CCF3 . . . . . . . . . . . . . . . . B ADDR 00DBH NOT USED CCF4 . . . . . . . . . . . . . . . . B ADDR 00DCH NOT USED CCON . . . . . . . . . . . . . . . . D ADDR 00D8H NOT USED CFINT. . . . . . . . . . . . . . . . C ADDR 0033H NOT USED CH . . . . . . . . . . . . . . . . . D ADDR 00F9H NOT USED CKCON. . . . . . . . . . . . . . . . D ADDR 008FH NOT USED CKCON0 . . . . . . . . . . . . . . . D ADDR 008FH NOT USED CKRL . . . . . . . . . . . . . . . . D ADDR 0097H NOT USED CKSEL. . . . . . . . . . . . . . . . D ADDR 0085H NOT USED CL . . . . . . . . . . . . . . . . . D ADDR 00E9H NOT USED CLKREG . . . . . . . . . . . . . . . D ADDR 008FH NOT USED CMOD . . . . . . . . . . . . . . . . D ADDR 00D9H NOT USED COUNTER. . . . . . . . . . . . . . . I ADDR 000FH CPRL2. . . . . . . . . . . . . . . . B ADDR 00C8H NOT USED CR . . . . . . . . . . . . . . . . . B ADDR 00DEH NOT USED CT2. . . . . . . . . . . . . . . . . B ADDR 00C9H NOT USED CY . . . . . . . . . . . . . . . . . B ADDR 00D7H NOT USED DP0H . . . . . . . . . . . . . . . . D ADDR 0083H NOT USED DP0L . . . . . . . . . . . . . . . . D ADDR 0082H NOT USED DP1H . . . . . . . . . . . . . . . . D ADDR 0085H NOT USED DP1L . . . . . . . . . . . . . . . . D ADDR 0084H NOT USED DPH. . . . . . . . . . . . . . . . . D ADDR 0083H NOT USED DPL. . . . . . . . . . . . . . . . . D ADDR 0082H NOT USED EA . . . . . . . . . . . . . . . . . B ADDR 00AFH NOT USED EC . . . . . . . . . . . . . . . . . B ADDR 00AEH NOT USED EECON. . . . . . . . . . . . . . . . D ADDR 0096H NOT USED ES . . . . . . . . . . . . . . . . . B ADDR 00ACH NOT USED ET0. . . . . . . . . . . . . . . . . B ADDR 00A9H NOT USED ET1. . . . . . . . . . . . . . . . . B ADDR 00ABH NOT USED ET2. . . . . . . . . . . . . . . . . B ADDR 00ADH NOT USED EX0. . . . . . . . . . . . . . . . . B ADDR 00A8H NOT USED EX1. . . . . . . . . . . . . . . . . B ADDR 00AAH NOT USED EXEN2. . . . . . . . . . . . . . . . B ADDR 00CBH NOT USED EXF2 . . . . . . . . . . . . . . . . B ADDR 00CEH NOT USED EXTI0. . . . . . . . . . . . . . . . C ADDR 0003H NOT USED EXTI1. . . . . . . . . . . . . . . . C ADDR 0013H NOT USED F0 . . . . . . . . . . . . . . . . . B ADDR 00D5H NOT USED FE . . . . . . . . . . . . . . . . . B ADDR 009FH NOT USED IE . . . . . . . . . . . . . . . . . D ADDR 00A8H NOT USED IE0. . . . . . . . . . . . . . . . . B ADDR 0089H NOT USED IE1. . . . . . . . . . . . . . . . . B ADDR 008BH NOT USED INC_DEC. . . . . . . . . . . . . . . N NUMB 0001H NOT USED INT0 . . . . . . . . . . . . . . . . B ADDR 00B2H NOT USED INT1 . . . . . . . . . . . . . . . . B ADDR 00B3H NOT USED IP . . . . . . . . . . . . . . . . . D ADDR 00B8H NOT USED IPH. . . . . . . . . . . . . . . . . D ADDR 00B7H NOT USED IPH0 . . . . . . . . . . . . . . . . D ADDR 00B7H NOT USED IPH1 . . . . . . . . . . . . . . . . D ADDR 00B3H NOT USED IPL0 . . . . . . . . . . . . . . . . D ADDR 00B8H NOT USED IPL1 . . . . . . . . . . . . . . . . D ADDR 00B2H NOT USED IT0. . . . . . . . . . . . . . . . . B ADDR 0088H NOT USED IT1. . . . . . . . . . . . . . . . . B ADDR 008AH NOT USED KBE. . . . . . . . . . . . . . . . . D ADDR 009DH NOT USED KBF. . . . . . . . . . . . . . . . . D ADDR 009EH NOT USED KBLS . . . . . . . . . . . . . . . . D ADDR 009CH NOT USED MAIN . . . . . . . . . . . . . . . . C ADDR 000AH OSCCON . . . . . . . . . . . . . . . D ADDR 0086H NOT USED OV . . . . . . . . . . . . . . . . . B ADDR 00D2H NOT USED P. . . . . . . . . . . . . . . . . . B ADDR 00D0H NOT USED P0 . . . . . . . . . . . . . . . . . D ADDR 0080H NOT USED P1 . . . . . . . . . . . . . . . . . D ADDR 0090H P1M1 . . . . . . . . . . . . . . . . D ADDR 00D4H NOT USED P1M2 . . . . . . . . . . . . . . . . D ADDR 00E2H NOT USED P2 . . . . . . . . . . . . . . . . . D ADDR 00A0H NOT USED P3 . . . . . . . . . . . . . . . . . D ADDR 00B0H P3M1 . . . . . . . . . . . . . . . . D ADDR 00D5H NOT USED P3M2 . . . . . . . . . . . . . . . . D ADDR 00E3H NOT USED P4 . . . . . . . . . . . . . . . . . D ADDR 00C0H NOT USED P4M1 . . . . . . . . . . . . . . . . D ADDR 00D6H NOT USED P4M2 . . . . . . . . . . . . . . . . D ADDR 00E4H NOT USED P5 . . . . . . . . . . . . . . . . . D ADDR 00E8H NOT USED PC . . . . . . . . . . . . . . . . . B ADDR 00BEH NOT USED PCON . . . . . . . . . . . . . . . . D ADDR 0087H NOT USED PPCL . . . . . . . . . . . . . . . . B ADDR 00BEH NOT USED PS . . . . . . . . . . . . . . . . . B ADDR 00BCH NOT USED PSL. . . . . . . . . . . . . . . . . B ADDR 00BCH NOT USED PSW. . . . . . . . . . . . . . . . . D ADDR 00D0H NOT USED PT0. . . . . . . . . . . . . . . . . B ADDR 00B9H NOT USED PT0L . . . . . . . . . . . . . . . . B ADDR 00B9H NOT USED PT1. . . . . . . . . . . . . . . . . B ADDR 00BBH NOT USED PT1L . . . . . . . . . . . . . . . . B ADDR 00BBH NOT USED PT2. . . . . . . . . . . . . . . . . B ADDR 00BDH NOT USED PT2L . . . . . . . . . . . . . . . . B ADDR 00BDH NOT USED PX0. . . . . . . . . . . . . . . . . B ADDR 00B8H NOT USED PX0L . . . . . . . . . . . . . . . . B ADDR 00B8H NOT USED PX1. . . . . . . . . . . . . . . . . B ADDR 00BAH NOT USED PX1L . . . . . . . . . . . . . . . . B ADDR 00BAH NOT USED RB8. . . . . . . . . . . . . . . . . B ADDR 009AH NOT USED RCAP2H . . . . . . . . . . . . . . . D ADDR 00CBH NOT USED RCAP2L . . . . . . . . . . . . . . . D ADDR 00CAH NOT USED RCLK . . . . . . . . . . . . . . . . B ADDR 00CDH NOT USED RD . . . . . . . . . . . . . . . . . B ADDR 00B7H NOT USED REN. . . . . . . . . . . . . . . . . B ADDR 009CH NOT USED RESET. . . . . . . . . . . . . . . . C ADDR 0000H NOT USED RI . . . . . . . . . . . . . . . . . B ADDR 0098H NOT USED RS0. . . . . . . . . . . . . . . . . B ADDR 00D3H NOT USED RS1. . . . . . . . . . . . . . . . . B ADDR 00D4H NOT USED RXD. . . . . . . . . . . . . . . . . B ADDR 00B0H NOT USED SADDR. . . . . . . . . . . . . . . . D ADDR 00A9H NOT USED SADDR_0. . . . . . . . . . . . . . . D ADDR 00A9H NOT USED SADDR_1. . . . . . . . . . . . . . . D ADDR 00AAH NOT USED SADEN. . . . . . . . . . . . . . . . D ADDR 00B9H NOT USED SADEN_0. . . . . . . . . . . . . . . D ADDR 00B9H NOT USED SADEN_1. . . . . . . . . . . . . . . D ADDR 00BAH NOT USED SBUF . . . . . . . . . . . . . . . . D ADDR 0099H NOT USED SCON . . . . . . . . . . . . . . . . D ADDR 0098H NOT USED SINT . . . . . . . . . . . . . . . . C ADDR 0023H NOT USED SM0. . . . . . . . . . . . . . . . . B ADDR 009FH NOT USED SM1. . . . . . . . . . . . . . . . . B ADDR 009EH NOT USED SM2. . . . . . . . . . . . . . . . . B ADDR 009DH NOT USED SOMETHING. . . . . . . . . . . . . . C ADDR 01FFH NOT USED SP . . . . . . . . . . . . . . . . . D ADDR 0081H NOT USED SPCON. . . . . . . . . . . . . . . . D ADDR 00C3H NOT USED SPCR . . . . . . . . . . . . . . . . D ADDR 00D5H NOT USED SPDAT. . . . . . . . . . . . . . . . D ADDR 00C5H NOT USED SPDR . . . . . . . . . . . . . . . . D ADDR 0086H NOT USED SPSR . . . . . . . . . . . . . . . . D ADDR 00AAH NOT USED SPSTA. . . . . . . . . . . . . . . . D ADDR 00C4H NOT USED START. . . . . . . . . . . . . . . . C ADDR 0002H T0 . . . . . . . . . . . . . . . . . B ADDR 00B4H NOT USED T1 . . . . . . . . . . . . . . . . . B ADDR 00B5H NOT USED T2CON. . . . . . . . . . . . . . . . D ADDR 00C8H NOT USED T2MOD. . . . . . . . . . . . . . . . D ADDR 00C9H NOT USED TB8. . . . . . . . . . . . . . . . . B ADDR 009BH NOT USED TCLK . . . . . . . . . . . . . . . . B ADDR 00CCH NOT USED TCON . . . . . . . . . . . . . . . . D ADDR 0088H NOT USED TF0. . . . . . . . . . . . . . . . . B ADDR 008DH NOT USED TF1. . . . . . . . . . . . . . . . . B ADDR 008FH NOT USED TF2. . . . . . . . . . . . . . . . . B ADDR 00CFH NOT USED TH0. . . . . . . . . . . . . . . . . D ADDR 008CH NOT USED TH1. . . . . . . . . . . . . . . . . D ADDR 008DH NOT USED TH2. . . . . . . . . . . . . . . . . D ADDR 00CDH NOT USED TI . . . . . . . . . . . . . . . . . B ADDR 0099H NOT USED TIMER0 . . . . . . . . . . . . . . . C ADDR 000BH NOT USED TIMER1 . . . . . . . . . . . . . . . C ADDR 001BH NOT USED TIMER2 . . . . . . . . . . . . . . . C ADDR 002BH NOT USED TL0. . . . . . . . . . . . . . . . . D ADDR 008AH NOT USED TL1. . . . . . . . . . . . . . . . . D ADDR 008BH NOT USED TL2. . . . . . . . . . . . . . . . . D ADDR 00CCH NOT USED TMOD . . . . . . . . . . . . . . . . D ADDR 0089H NOT USED TR0. . . . . . . . . . . . . . . . . B ADDR 008CH NOT USED TR1. . . . . . . . . . . . . . . . . B ADDR 008EH NOT USED TR2. . . . . . . . . . . . . . . . . B ADDR 00CAH NOT USED TXD. . . . . . . . . . . . . . . . . B ADDR 00B1H NOT USED WDTCON . . . . . . . . . . . . . . . D ADDR 00A7H NOT USED WDTPRG . . . . . . . . . . . . . . . D ADDR 00A7H NOT USED WDTRST . . . . . . . . . . . . . . . D ADDR 00A6H NOT USED WR . . . . . . . . . . . . . . . . . B ADDR 00B6H NOT USED X. . . . . . . . . . . . . . . . . . NUMB 0064H NOT USED REDEFINABLE