###############################################################################
#                                                                             #
# IAR C/C++ Compiler V8.10.3.40338/W32 for 8051         28/Feb/2016  00:40:01 #
# Copyright 2004-2011 IAR Systems AB.                                         #
#                                                                             #
#    Core               =  plain                                              #
#    Code model         =  near                                               #
#    Data model         =  small                                              #
#    Calling convention =  idata reentrant                                    #
#    Constant location  =  data                                               #
#    Dptr setup         =  1,16                                               #
#    Source file        =  E:\IAR_8051\Basti_test\main.c                      #
#    Command line       =  E:\IAR_8051\Basti_test\main.c -lC                  #
#                          E:\IAR_8051\Basti_test\Debug\List\ -lA             #
#                          E:\IAR_8051\Basti_test\Debug\List\ -o              #
#                          E:\IAR_8051\Basti_test\Debug\Obj\ -e --no_unroll   #
#                          --no_inline --no_tbaa --debug --core=plain         #
#                          --dptr=16,1 --data_model=small --code_model=near   #
#                          --calling_convention=idata_reentrant               #
#                          --place_constants=data --nr_virtual_regs 8 -Om     #
#    List file          =  E:\IAR_8051\Basti_test\Debug\List\main.lst         #
#    Object file        =  E:\IAR_8051\Basti_test\Debug\Obj\main.r51          #
#                                                                             #
#                                                                             #
###############################################################################

E:\IAR_8051\Basti_test\main.c
      1          typedef signed   char   int8;     //!< Signed 8 bit integer
      2          typedef unsigned char   uint8;    //!< Unsigned 8 bit integer
      3          
      4          typedef signed   short  int16;    //!< Signed 16 bit integer
      5          typedef unsigned short  uint16;   //!< Unsigned 16 bit integer
      6          
      7          typedef signed   long   int32;    //!< Signed 32 bit integer
      8          typedef unsigned long   uint32;   //!< Unsigned 32 bit integer
      9          
     10          typedef unsigned char   bool;     //!< Boolean data type
     11          
     12          typedef uint8           halDataAlign_t; //!< Used for byte alignment
     13          
     14          typedef uint8 bStatus_t;
     15          
     16          /**
     17           * GATT Attribute Type format.
     18           */
     19          typedef struct
     20          {
     21            uint8 len;         //!< Length of UUID
     22            const uint8 *uuid; //!< Pointer to UUID
     23          } gattAttrType_t;
     24          
     25          /**
     26           * GATT Attribute format.
     27           */
     28          typedef struct attAttribute_t
     29          {
     30            gattAttrType_t type; //!< Attribute type (2 or 16 octet UUIDs)
     31            uint8 permissions;   //!< Attribute permissions
     32            uint16 handle;       //!< Attribute handle - assigned internally by attribute server
     33            uint8* const pValue; //!< Attribute value - encoding of the octet array is defined in 
     34                                 //!< the applicable profile. The maximum length of an attribute 
     35                                 //!< value shall be 512 octets.
     36          } gattAttribute_t;
     37          

   \                                 In  segment NEAR_CODE, align 1, keep-with-next
     38          static bStatus_t WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
   \                     WriteAttrCB:
     39                                                      uint8 *pValue, uint8 len, uint16 offset,
     40                                                      uint8 method )
     41          {
   \   000000   EE           MOV     A,R6
   \   000001   C0E0         PUSH    A
   \   000003   EF           MOV     A,R7
   \   000004   C0E0         PUSH    A
   \   000006   C0..         PUSH    ?V0 + 0
   \   000008                ; Saved register size: 3
   \   000008                ; Auto size: 0
   \   000008   E9           MOV     A,R1
   \   000009   FE           MOV     R6,A
   \   00000A   E581         MOV     A,SP
   \   00000C   24FA         ADD     A,#-0x6
   \   00000E   F8           MOV     R0,A
   \   00000F   E6           MOV     A,@R0
   \   000010   FA           MOV     R2,A
   \   000011   08           INC     R0
   \   000012   E6           MOV     A,@R0
   \   000013   FB           MOV     R3,A
     42            bStatus_t status = 0x00;
   \   000014   7F00         MOV     R7,#0x0
     43            uint8 notifyApp = 0xFF;
   \   000016   75..FF       MOV     ?V0 + 0,#-0x1
     44            
     45          
     46            if ( ( (pAttr->permissions) & 0x20 ) )
   \   000019   7402         MOV     A,#0x2
   \   00001B   2E           ADD     A,R6
   \   00001C   F8           MOV     R0,A
   \   00001D   E6           MOV     A,@R0
   \   00001E   A2E5         MOV     C,0xE0 /* A   */.5
   \   000020   5004         JNC     ??WriteAttrCB_0
     47            {
     48              return ( 0x08 );
   \   000022   7908         MOV     R1,#0x8
   \   000024   8053         SJMP    ??WriteAttrCB_1
     49            }
     50            
     51            if ( pAttr->type.len == 2 )
   \                     ??WriteAttrCB_0:
   \   000026   18           DEC     R0
   \   000027   18           DEC     R0
   \   000028   E6           MOV     A,@R0
   \   000029   6402         XRL     A,#0x2
   \   00002B   703F         JNZ     ??WriteAttrCB_2
     52            {
     53          
     54              uint16 uuid = ((uint16)(((pAttr->type . uuid[0]) & 0x00FF) + (((pAttr->type . uuid[1]) & 0x00FF) << 8)));
     55              
     56          
     57              if (offset!=0)
   \   00002D   EA           MOV     A,R2
   \   00002E   4B           ORL     A,R3
   \   00002F   6004         JZ      ??WriteAttrCB_3
     58              {
     59                 return 0x0b;
   \   000031   790B         MOV     R1,#0xb
   \   000033   8044         SJMP    ??WriteAttrCB_1
     60              }
     61              switch ( uuid )
   \                     ??WriteAttrCB_3:
   \   000035   09           INC     R1
   \   000036   08           INC     R0
   \   000037   E6           MOV     A,@R0
   \   000038   F8           MOV     R0,A
   \   000039   E6           MOV     A,@R0
   \   00003A   FA           MOV     R2,A
   \   00003B   E9           MOV     A,R1
   \   00003C   F8           MOV     R0,A
   \   00003D   E6           MOV     A,@R0
   \   00003E   04           INC     A
   \   00003F   F8           MOV     R0,A
   \   000040   E6           MOV     A,@R0
   \   000041   F9           MOV     R1,A
   \   000042   EA           MOV     A,R2
   \   000043   F8           MOV     R0,A
   \   000044   74F4         MOV     A,#-0xc
   \   000046   68           XRL     A,R0
   \   000047   7003         JNZ     ??WriteAttrCB_4
   \   000049   74FF         MOV     A,#-0x1
   \   00004B   69           XRL     A,R1
   \                     ??WriteAttrCB_4:
   \   00004C   701A         JNZ     ??WriteAttrCB_5
     62              {
     63                case 0xFFF4:
     64                   if ( len != 1 )
   \   00004E   7401         MOV     A,#0x1
   \   000050   6D           XRL     A,R5
   \   000051   6004         JZ      ??WriteAttrCB_6
     65                   {
     66                     status = 0x0d;
   \   000053   7F0D         MOV     R7,#0xd
   \   000055   8016         SJMP    ??WriteAttrCB_7
     67                   }
     68                   else
     69                   {
     70                     uint8 tx_value = *(uint8*)pValue;
     71                     if( tx_value <= 0x02 ) {
   \                     ??WriteAttrCB_6:
   \   000057   EC           MOV     A,R4
   \   000058   F8           MOV     R0,A
   \   000059   E6           MOV     A,@R0
   \   00005A   C3           CLR     C
   \   00005B   9403         SUBB    A,#0x3
   \   00005D   5005         JNC     ??WriteAttrCB_8
     72                       notifyApp = 3;
   \   00005F   75..03       MOV     ?V0 + 0,#0x3
   \   000062   8009         SJMP    ??WriteAttrCB_7
     73                     }
     74                     else 
     75                     {
     76                       status = 0x80;
   \                     ??WriteAttrCB_8:
   \   000064   7F80         MOV     R7,#-0x80
   \   000066   8005         SJMP    ??WriteAttrCB_7
     77                     }
     78                   }
     79                   break;
     80          
     81                default:
     82                  status = 0x0a;
   \                     ??WriteAttrCB_5:
   \   000068   7F0A         MOV     R7,#0xa
     83                  break;
   \   00006A   8001         SJMP    ??WriteAttrCB_7
     84              }
     85            }
     86            else
     87            {
     88          
     89              status = 0x01;
   \                     ??WriteAttrCB_2:
   \   00006C   0F           INC     R7
     90            }     
     91            
     92              if ( (notifyApp != 0xFF ))
   \                     ??WriteAttrCB_7:
   \   00006D   74FF         MOV     A,#-0x1
   \   00006F   65..         XRL     A,?V0 + 0
   \   000071   6004         JZ      ??WriteAttrCB_9
     93            {
     94              return 1; 
   \   000073   7901         MOV     R1,#0x1
   \   000075   8002         SJMP    ??WriteAttrCB_1
     95            }
     96            return ( status );
   \                     ??WriteAttrCB_9:
   \   000077   EF           MOV     A,R7
   \   000078   F9           MOV     R1,A
   \                     ??WriteAttrCB_1:
   \   000079   D0..         POP     ?V0 + 0
   \   00007B   D0E0         POP     A
   \   00007D   FF           MOV     R7,A
   \   00007E   D0E0         POP     A
   \   000080   FE           MOV     R6,A
   \   000081   22           RET
     97          }
     98          

   \                                 In  segment NEAR_CODE, align 1, keep-with-next
     99          int main(void)
   \                     main:
    100          {
   \   000000                ; Auto size: 9
   \   000000   E581         MOV     A,SP
   \   000002   2409         ADD     A,#0x9
   \   000004   F581         MOV     SP,A
    101            uint16 uuid = 0xFFF1;
   \   000006   24FE         ADD     A,#-0x2
   \   000008   F8           MOV     R0,A
   \   000009   76F1         MOV     @R0,#-0xf
   \   00000B   08           INC     R0
   \   00000C   76FF         MOV     @R0,#-0x1
    102            volatile gattAttribute_t att;
                                            ^
Warning[Pe370]: variable "att" has an uninitialized const field
    103            att.type.len = 2; 
   \   00000E   24FA         ADD     A,#-0x6
   \   000010   F8           MOV     R0,A
   \   000011   7602         MOV     @R0,#0x2
    104            att.type.uuid = (const uint8*)&uuid;
   \   000013   2406         ADD     A,#0x6
   \   000015   08           INC     R0
   \   000016   F6           MOV     @R0,A
    105            att.permissions = 0;
   \   000017   08           INC     R0
   \   000018   7600         MOV     @R0,#0x0
    106            att.handle = 0;
   \   00001A   08           INC     R0
   \   00001B   7600         MOV     @R0,#0x0
   \   00001D   08           INC     R0
   \   00001E   7600         MOV     @R0,#0x0
    107          
    108            volatile uint8 value = 2;
   \   000020   A881         MOV     R0,SP
   \   000022   7602         MOV     @R0,#0x2
    109            uint8 len = 1;
    110            uint16 offset = 0;
    111            uint8 method = 0;
    112           
    113            
    114            value ++;
   \   000024   06           INC     @R0
    115            
    116            while(1) { 
    117             WriteAttrCB( 0, (gattAttribute_t*)&att, (uint8*)&value, len, offset, method );
   \                     ??main_0:
   \   000025                ; Setup parameters for call to function WriteAttrCB
   \   000025   E4           CLR     A
   \   000026   C0E0         PUSH    A
   \   000028   C0E0         PUSH    A
   \   00002A   C0E0         PUSH    A
   \   00002C   7D01         MOV     R5,#0x1
   \   00002E   E581         MOV     A,SP
   \   000030   24FD         ADD     A,#-0x3
   \   000032   FC           MOV     R4,A
   \   000033   24F8         ADD     A,#-0x8
   \   000035   F9           MOV     R1,A
   \   000036   7A00         MOV     R2,#0x0
   \   000038   7B00         MOV     R3,#0x0
   \   00003A   12....       LCALL   WriteAttrCB
   \   00003D   1581         DEC     SP
   \   00003F   1581         DEC     SP
   \   000041   1581         DEC     SP
    118             uuid++;
   \   000043   E581         MOV     A,SP
   \   000045   24FE         ADD     A,#-0x2
   \   000047   F8           MOV     R0,A
   \   000048   E6           MOV     A,@R0
   \   000049   2401         ADD     A,#0x1
   \   00004B   F6           MOV     @R0,A
   \   00004C   08           INC     R0
   \   00004D   E6           MOV     A,@R0
   \   00004E   3400         ADDC    A,#0x0
   \   000050   F6           MOV     @R0,A
   \   000051   80D2         SJMP    ??main_0
    119            }
    120          
    121            return 0;
                   ^
Warning[Pe111]: statement is unreachable
    122          }

   Maximum stack usage in bytes:

     Function         ISTACK PSTACK XSTACK
     --------         ------ ------ ------
     WriteAttrCB         15      0      0
     main                12      0      0
       -> WriteAttrCB    24      0      0


   Segment part sizes:

     Function/Label Bytes
     -------------- -----
     WriteAttrCB     130
     main             83

 
 213 bytes in segment NEAR_CODE
 
 213 bytes of CODE memory

Errors: none
Warnings: 2
