Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/18/07 13:36
Read: times


 
#139486 - b) buffer at 256 byte boundary
Responding to: ???'s previous message
Erik Malund said:
b) by example: you locate a 200 character buffer accessed by the above method a a 256 byte boundary and just ignore testing for 'low address overflow' which no compiler would ignore.

Usually addresses for variables are only known after the linking stage. - Too late for the compiler to notice and generate more efficient code for aligned access.

If instead the address of a variable is known at compile time (here by the use of the 'at' keyword) the compiler is given a chance to obmit testing the 'low address overflow':

#include <8052.h>

unsigned char xdata at 0xfe00 buffer[200];

void f(void)
{
  unsigned char i;
  for(i=0; i!=sizeof buffer; i++)
     P3 = buffer[i];
}

should compile to something like:

   0000                     338 _f:
                            347 ;       buffer.c:8: for(i=0; i!=sizeof buffer; i++)
   0000 7A 00               348         mov     r2,#0x00
   0002                     349 00101$:
   0002 BA C8 01            350         cjne    r2,#0xC8,00110$
   0005 22                  351         ret
   0006                     352 00110$:
                            353 ;       buffer.c:9: P3 = buffer[i];
   0006 8A 82               354         mov     dpl,r2
   0008 75 83 FE            355         mov     dph,#(_buffer >> 8)
   000B E0                  356         movx    a,@dptr
   000C F5 B0               357         mov     _P3,a
   000E 0A                  359         inc     r2
   000F 80 F1               360         sjmp    00101$

with SDCC more recent than december 2003.


List of 43 messages in thread
TopicAuthorDate
How to speed code?            01/01/70 00:00      
   How did you come to that bizarre idea...            01/01/70 00:00      
      bizarre!?            01/01/70 00:00      
         I am a C-hater, remember...            01/01/70 00:00      
      Smaller, Faster            01/01/70 00:00      
   Is that true??            01/01/70 00:00      
   Often mutually exclusive...            01/01/70 00:00      
   Take my contribution with a grain of salt.            01/01/70 00:00      
      http://www.8052.com/users/disasm/            01/01/70 00:00      
   what compiler?            01/01/70 00:00      
   Data types            01/01/70 00:00      
   Getting the least            01/01/70 00:00      
   My Two Cents            01/01/70 00:00      
      Turn in your Programmer's ID Card.            01/01/70 00:00      
         heheh...yeah            01/01/70 00:00      
         SJMP            01/01/70 00:00      
   Comments            01/01/70 00:00      
   How to speed code?            01/01/70 00:00      
   a couple of \'rules\'            01/01/70 00:00      
      More on Erik's Rules            01/01/70 00:00      
         a comment            01/01/70 00:00      
         PDATA            01/01/70 00:00      
            don't forget about @DPTR access to CDATA            01/01/70 00:00      
               but            01/01/70 00:00      
                  WHAT??? You mean I have it too? Dystypia?            01/01/70 00:00      
                     Enginnering is all about the tradeoffs            01/01/70 00:00      
                        two places where you REALLY can make an impact            01/01/70 00:00      
                           b) buffer at 256 byte boundary            01/01/70 00:00      
                              Alignment            01/01/70 00:00      
                              you did'nt hear ?            01/01/70 00:00      
               Another \"but\"            01/01/70 00:00      
                  it is, after all, quicker            01/01/70 00:00      
                     Errr...            01/01/70 00:00      
                        perhaps, but it has to "live" somewhere.            01/01/70 00:00      
                           You\'re assuming...            01/01/70 00:00      
                              confirming Andys statement            01/01/70 00:00      
                                 We WERE discusisng 805x ...            01/01/70 00:00      
                                    well, does it not?            01/01/70 00:00      
                                       Tables in code space vs data space            01/01/70 00:00      
                                          Philps XA, the best "16 bit '51"            01/01/70 00:00      
                                             Maxim/Dallas DS89C450            01/01/70 00:00      
   most compilers            01/01/70 00:00      
      Thanks            01/01/70 00:00      

Back to Subject List