Menu

#4070 sfr32 MSB instruction address is wrong

open
nobody
sfr32 (1)
MCS51
5
17 hours ago
2 days ago
RvD
No

__sfr32 causes instruction destication register to be wrong for the MSB.

Assembly output of main.c compile sdcc -mmcs51 main.c.

             000000 E4               [12]  192     clr a                                                                       
  193        000001 F5 A7            [12]  193     mov ((_SFR_DATA_U32 >> 0) & 0xFF),a                                         
  194        000003 F5 A6            [12]  194     mov ((_SFR_DATA_U32 >> 8) & 0xFF),a                                         
  195        000005 F5 A5            [12]  195     mov ((_SFR_DATA_U32 >> 16) & 0xFF),a                                        
  196        000007 F5 FF            [12]  196     mov ((_SFR_DATA_U32 >> 24) & 0xFF),a                                        
  197                                      197 ;   ../../main.c:6: while(1);    

mov ((_SFR_DATA_U32 >> 24) & 0xFF),a generate F5 FF but is should generate F5 A4.

Seen on

  • sdcc 4.5.0 on debian 13
  • sdcc 4.6.0 from the website also shows this issue.
  • sdcc 4.6.2 #16825 (Linux), lastest snapshot
1 Attachments

Discussion

  • RvD

    RvD - 2 days ago

    I see that the main.c has changed A4 into A3 but still the same issue. It keeps generating F5 FF.

     
  • RvD

    RvD - 17 hours ago

    I also see it in reverse mov a, (SFR_DATA_U32), E5 FF. FF location should A4

    4359:      029675 E5 A7            [12] 4359    mov     a,((_SFR_DATA_U32 >> 0) & 0xFF)
    4361:      029678 E5 A6            [12] 4361    mov     a,((_SFR_DATA_U32 >> 8) & 0xFF)
    4364:      02967C E5 A5            [12] 4364    mov     a,((_SFR_DATA_U32 >> 16) & 0xFF)
    4367:      029680 E5 FF            [12] 4367    mov     a,((_SFR_DATA_U32 >> 24) & 0xFF)
    

    and in the lst-file it get this notation

                                      106 ;--------------------------------------------------------                     
       107                                      107 ; special function registers                                                  
       108                                      108 ;--------------------------------------------------------                     
       109                                      109     .area RSEG    (ABS,DATA)                                                  
       110        000000                        110     .org 0x0000                                                               
       111                             0000A0   111 _SFR_EXEC_GO    =   0x00a0                                                    
       112                             0000A1   112 _SFR_EXEC_STATUS    =   0x00a1                                                
       113                             00A2A3   113 _SFR_REG_ADDR_U16   =   0xa2a3                                                
       114                             0000A2   114 _SFR_REG_ADDRH  =   0x00a2                                                    
       115                             0000A3   115 _SFR_REG_ADDRL  =   0x00a3                                                    
       116                             00A6A7   116 _SFR_DATA_U16   =   0xa6a7                                                    
       117                             FFA5A6A7   117 _SFR_DATA_U32 =   0xa4a5a6a7      
    
     

Log in to post a comment.