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

📄 exp1.lst

📁 《单片机仿真入门实用教程》实例(包括源代码) 单片机仿真教程。
💻 LST
📖 第 1 页 / 共 2 页
字号:
##############################################################################
#                                                                            #
#                                                      17/Oct/2006  10:44:06 #
# IAR Atmel AVR C/C++ Compiler V4.20A/W32, KickStart Version                 #
# Copyright 1996-2006 IAR Systems. All rights reserved.                      #
#                                                                            #
#    Source file  =  F:\zln\AVR与PROTEUS\IAR AVR应用程序\exp1.c              #
#    Command line =  "F:\zln\AVR与PROTEUS\IAR AVR应用程序\exp1.c"            #
#                    --cpu=8535 -mt -o "F:\zln\AVR与PROTEUS\IAR              #
#                    AVR应用程序\Debug\Obj\" -lCN "F:\zln\AVR与PROTEUS\IAR   #
#                    AVR应用程序\Debug\List\" --initializers_in_flash -z2    #
#                    --no_cse --no_inline --no_code_motion --no_cross_call   #
#                    --no_clustering --no_tbaa --debug -e -I "D:\IAR         #
#                    Systems\Embedded Workbench 4.0 KickStart\avr\INC\" -I   #
#                    "D:\IAR Systems\Embedded Workbench 4.0                  #
#                    KickStart\avr\INC\CLIB\" --eeprom_size 512              #
#    List file    =  F:\zln\AVR与PROTEUS\IAR AVR应用程序\Debug\List\exp1.lst #
#    Object file  =  F:\zln\AVR与PROTEUS\IAR AVR应用程序\Debug\Obj\exp1.r90  #
#                                                                            #
#                                                                            #
##############################################################################

F:\zln\AVR与PROTEUS\IAR AVR应用程序\exp1.c
      1          #include <io8535.h>

   \                                 In segment ABSOLUTE, at 0x37
   \   union <unnamed> volatile __io _A_DDRB
   \                     _A_DDRB:
   \   00000000                      DS 1

   \                                 In segment ABSOLUTE, at 0x38
   \   union <unnamed> volatile __io _A_PORTB
   \                     _A_PORTB:
   \   00000000                      DS 1

   \                                 In segment ABSOLUTE, at 0x39
   \   union <unnamed> volatile __io _A_PINA
   \                     _A_PINA:
   \   00000000                      DS 1

   \                                 In segment ABSOLUTE, at 0x3a
   \   union <unnamed> volatile __io _A_DDRA
   \                     _A_DDRA:
   \   00000000                      DS 1
      2          #include <intrinsics.h>
      3          
      4          #define EW_RED_LITE PORTB_Bit0      /*dedinitions to actual outputs*/
      5          #define EW_YEL_LITE PORTB_Bit1      /*used to control the lights*/
      6          #define EW_GRN_LITE PORTB_Bit2
      7          #define NS_RED_LITE PORTB_Bit3
      8          #define NS_YEL_LITE PORTB_Bit4
      9          #define NS_GRN_LITE PORTB_Bit5
     10          
     11          #define PED_XING_EW PINA_Bit0       /*pedestrian crossing push button*/
     12          #define PED_XING_NS PINA_Bit1       /*used to control the lights*/
     13          #define FOUR_WAY_STOP PINA_Bit3     /*switch input for 4-Way Stop*/
     14          

   \                                 In segment TINY_Z, align 1, keep-with-next
   \   00000000                      REQUIRE `?<Segment init: TINY_Z>`
     15          char  time_left;                    //time in seconds spent in each state
   \                     time_left:
   \   00000000                      DS 1

   \                                 In segment TINY_Z, align 1, keep-with-next
   \   00000000                      REQUIRE `?<Segment init: TINY_Z>`
     16          int   current_state;                //current state of the lights
   \                     current_state:
   \   00000000                      DS 2

   \                                 In segment TINY_Z, align 1, keep-with-next
   \   00000000                      REQUIRE `?<Segment init: TINY_Z>`
     17          char  flash_toggle;                 //toggle used for FLASHER state
   \                     flash_toggle:
   \   00000000                      DS 1
     18                                              //this enumeration creates a simple way to add states to the machine
     19                                              //by name. Enumerations generate an integer value for each name
     20                                              //automatically, making the code easier to maintain.
     21          enum  {EW_MOVING, EW_WARNING, NS_MOVING, NS_WARNING, FLASHER};
     22                                              //The actual state machine is here..

   \                                 In segment CODE, align 2, keep-with-next
     23          void  Do_States(void)
   \                     Do_States:
     24          {
     25            switch(current_state)
   \   00000000   ....               LDI     R30, current_state
   \   00000002   E0F0               LDI     R31, 0
   \   00000004   8100               LD      R16, Z
   \   00000006   8111               LDD     R17, Z+1
   \   00000008   ....               LDI     R30, LOW(`?<Jumptable for Do_States>_0`)
   \   0000000A   ....               LDI     R31, (`?<Jumptable for Do_States>_0`) >> 8
   \   0000000C   ....               RJMP    ?SV_SWITCH_L06
     26            {
     27            case  EW_MOVING:                  //east-west has the green!!
     28                  EW_GRN_LITE=1;
   \                     ??Do_States_0:
   \   0000000E   9AC2               SBI     0x18, 0x02
     29                  NS_GRN_LITE=0;
   \   00000010   98C5               CBI     0x18, 0x05
     30                  NS_RED_LITE=1;              //north-south has the red!!
   \   00000012   9AC3               SBI     0x18, 0x03
     31                  EW_RED_LITE=0;
   \   00000014   98C0               CBI     0x18, 0x00
     32                  EW_YEL_LITE=0;
   \   00000016   98C1               CBI     0x18, 0x01
     33                  NS_YEL_LITE=0;
   \   00000018   98C4               CBI     0x18, 0x04
     34            
     35                  if(PED_XING_EW||FOUR_WAY_STOP)
   \   0000001A   99C8               SBIC    0x19, 0x00
   \   0000001C   C002               RJMP    ??Do_States_1
   \   0000001E   9BCB               SBIS    0x19, 0x03
   \   00000020   C007               RJMP    ??Do_States_2
     36                  {                           //pedestrian wishes to cross, or a 4-Way stop is required
     37                      if(time_left>10)
   \                     ??Do_States_1:
   \   00000022   9100....           LDS     R16, time_left
   \   00000026   300B               CPI     R16, 11
   \   00000028   F018               BRCS    ??Do_States_2
     38                          time_left=10;       //shorten the time
   \   0000002A   E00A               LDI     R16, 10
   \   0000002C   9300....           STS     time_left, R16
     39                  }
     40                  if(time_left!=0)            //count down the time
   \                     ??Do_States_2:
   \   00000030   9100....           LDS     R16, time_left
   \   00000034   2300               TST     R16
   \   00000036   F031               BREQ    ??Do_States_3
     41                  {
     42                      --time_left;
   \   00000038   ....               LDI     R30, time_left
   \   0000003A   E0F0               LDI     R31, 0
   \   0000003C   8100               LD      R16, Z
   \   0000003E   950A               DEC     R16
   \   00000040   8300               ST      Z, R16
     43                      return;                 //return to main
   \   00000042   9508               RET
     44                  }                           //time expired, so..
     45                  time_left=5;                //give 5 seconds to WARNING
   \                     ??Do_States_3:
   \   00000044   E005               LDI     R16, 5
   \   00000046   9300....           STS     time_left, R16
     46                  current_state=EW_WARNING;   //time expired, move
   \   0000004A   E001               LDI     R16, 1
   \   0000004C   E010               LDI     R17, 0
   \   0000004E   ....               LDI     R30, current_state
   \   00000050   E0F0               LDI     R31, 0
   \   00000052   8300               ST      Z, R16
   \   00000054   8311               STD     Z+1, R17
   \   00000056   9508               RET
     47                  break;                      //to the next state
     48            
     49            case  EW_WARNING:                  //east-west has the green!!
     50                  EW_GRN_LITE=0;
   \                     ??Do_States_4:
   \   00000058   98C2               CBI     0x18, 0x02
     51                  NS_GRN_LITE=0;
   \   0000005A   98C5               CBI     0x18, 0x05
     52                  NS_RED_LITE=1;              //north-south has the red!!
   \   0000005C   9AC3               SBI     0x18, 0x03
     53                  EW_RED_LITE=0;
   \   0000005E   98C0               CBI     0x18, 0x00
     54                  EW_YEL_LITE=1;
   \   00000060   9AC1               SBI     0x18, 0x01
     55                  NS_YEL_LITE=0;
   \   00000062   98C4               CBI     0x18, 0x04
     56            
     57                  if(time_left!=0)            //count down the time
   \   00000064   9100....           LDS     R16, time_left
   \   00000068   2300               TST     R16
   \   0000006A   F031               BREQ    ??Do_States_5
     58                  {
     59                      --time_left;
   \   0000006C   ....               LDI     R30, time_left
   \   0000006E   E0F0               LDI     R31, 0
   \   00000070   8100               LD      R16, Z
   \   00000072   950A               DEC     R16
   \   00000074   8300               ST      Z, R16
     60                      return;                 //return to main
   \   00000076   9508               RET
     61                  }                           //time expired, so..
     62                  if(FOUR_WAY_STOP)           //if 4-way requested then start
   \                     ??Do_States_5:
   \   00000078   9BCB               SBIS    0x19, 0x03
   \   0000007A   C007               RJMP    ??Do_States_6
     63                      current_state=FLASHER;  //the flasher
   \   0000007C   E004               LDI     R16, 4
   \   0000007E   E010               LDI     R17, 0
   \   00000080   ....               LDI     R30, current_state
   \   00000082   E0F0               LDI     R31, 0
   \   00000084   8300               ST      Z, R16
   \   00000086   8311               STD     Z+1, R17
   \   00000088   9508               RET
     64                  else                        //otherwise..
     65                  {
     66                      time_left=30;           //give 30 seconds to MOVING
   \                     ??Do_States_6:
   \   0000008A   E10E               LDI     R16, 30
   \   0000008C   9300....           STS     time_left, R16
     67                      current_state=NS_MOVING;
   \   00000090   E002               LDI     R16, 2
   \   00000092   E010               LDI     R17, 0
   \   00000094   ....               LDI     R30, current_state
   \   00000096   E0F0               LDI     R31, 0
   \   00000098   8300               ST      Z, R16
   \   0000009A   8311               STD     Z+1, R17
   \   0000009C   9508               RET
     68                  }                           //time expired, move
     69                  break;                      //to the next state
     70            
     71            case  NS_MOVING:
     72                  EW_GRN_LITE=0;
   \                     ??Do_States_7:
   \   0000009E   98C2               CBI     0x18, 0x02
     73                  NS_GRN_LITE=1;
   \   000000A0   9AC5               SBI     0x18, 0x05
     74                  NS_RED_LITE=0;              //north-south has the green!!
   \   000000A2   98C3               CBI     0x18, 0x03
     75                  EW_RED_LITE=1;              //east-west has the red!!
   \   000000A4   9AC0               SBI     0x18, 0x00
     76                  EW_YEL_LITE=0;
   \   000000A6   98C1               CBI     0x18, 0x01
     77                  NS_YEL_LITE=0;
   \   000000A8   98C4               CBI     0x18, 0x04
     78            
     79                  if(PED_XING_EW||FOUR_WAY_STOP)
   \   000000AA   99C8               SBIC    0x19, 0x00
   \   000000AC   C002               RJMP    ??Do_States_8
   \   000000AE   9BCB               SBIS    0x19, 0x03
   \   000000B0   C007               RJMP    ??Do_States_9
     80                  {                           //pedestrian wishes to cross, or a 4-Way stop is required
     81                      if(time_left>10)
   \                     ??Do_States_8:
   \   000000B2   9100....           LDS     R16, time_left
   \   000000B6   300B               CPI     R16, 11
   \   000000B8   F018               BRCS    ??Do_States_9
     82                          time_left=10;       //shorten the time
   \   000000BA   E00A               LDI     R16, 10
   \   000000BC   9300....           STS     time_left, R16
     83                  }
     84                  if(time_left!=0)            //count down the time
   \                     ??Do_States_9:

⌨️ 快捷键说明

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