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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/08/07 17:18
Read: times


 
#130441 - Code transform from A51 -> C51 Keil
Hi people,

I am having a problem with a code transformation from Keil A51 to C51.

The reason why am I doing such a craziness is because I want that the source code can be compiled by both Keil and SDCC. And because SDCC assembler does not support macros, defines I want to have all the source code in C.

The mentioned code piece is time critical (that's why It was written in assembler) so I have to be SURE that the C compiled code has the same efficienty as the assembler one. So simple to say I want to be sure that the code piece translated by Keil to assembler is the same as "it was" when it was written in assembler.

So here is the assembler code which I want to translate:
?PR?_APBBR_read_data?APBBR_READ_DATA SEGMENT CODE 
    RSEG ?PR?_APBBR_read_data?APBBR_READ_DATA

_APBBR_read_data :
    ; save the EA bit in C and disable interrupts
    ;PUSH PSW 
    MOV C,EA
    CLR EA
    ; set the address
    MOV APBBR_ADDR_LSB_REG, R7
    MOV APBBR_ADDR_MSB_REG, R6
    ; do the APB access
    MOV APBBR_OPCODE_REG, #APBBR_OP_SINGLE_READ
    NOP
    ; get the resulting data
    MOV R7, APBBR_RDATA_LLSB_REG
    MOV R6, APBBR_RDATA_ILSB_REG
    MOV R5, APBBR_RDATA_IMSB_REG
    MOV R4, APBBR_RDATA_MMSB_REG
    ; restore previous condition for the interrupts
    MOV EA,C
    ;POP PSW
    RET

END


Here is the translation to C51:
#define APBBR_set_address(addr) 
{ APBBR_ADDR_LSB_REG = ( (addr)     & ((uint16)0x00FF) ) ; \
  APBBR_ADDR_MSB_REG = (((addr)>>8) & ((uint16)0x00FF) ) ; } 

uint32 APBBR_read_data(uint16 addr)
{
	
  uint32 *tmp;
  tmp=APBBR_RDATA_MMSB_ADDR;
  //save the EA bit in Carry bit in PSW register and disable interrupts
  CY=EA;
  EA=0;

  //set the address  
  APBBR_set_address(addr);

  //do the APB access
  APBBR_OPCODE_REG=APBBR_OP_SINGLE_READ;
  _nop_ ();
  

  EA=CY;        
  //get the resulting data  
  return *tmp;						
}


When I check the C51 compilation listing, everything is optimal except of the tmp return value translation.

Keil uses it special function called ?C?LLDPTR to transform the return values. But I have no access to this function source code.

My question is:
How can I be sure that the function ?C?LLDPTR does not take more time as the MOV's R7-R4 in my assembler version?

Thank you for any response in advance.
Attila

List of 35 messages in thread
TopicAuthorDate
Code transform from A51 -> C51 Keil            01/01/70 00:00      
   I don't think so, I'm afraid            01/01/70 00:00      
   there is NO WAY you can do that. C does not, in a            01/01/70 00:00      
      You are right I can't be sure            01/01/70 00:00      
         API            01/01/70 00:00      
            The problem is with the API development...            01/01/70 00:00      
               Welcome to the world of cross-platform development            01/01/70 00:00      
                  Use A51 compiled object files in SDCC...            01/01/70 00:00      
                     Did you say what you mean?            01/01/70 00:00      
                        Yes I was actualy meaning GENERATED...            01/01/70 00:00      
                  About inventing time in make...            01/01/70 00:00      
                     Inventing            01/01/70 00:00      
                     well, since you hide your e-mail (the 8052 e-mail            01/01/70 00:00      
                        Please, please could you send it?            01/01/70 00:00      
                     Unix utilities for Windows            01/01/70 00:00      
                        SDCC paths            01/01/70 00:00      
               The 'C' preprocessor            01/01/70 00:00      
               if you use a sensible approach it is easy            01/01/70 00:00      
                  I don't know about 'easy'...            01/01/70 00:00      
         HLL's are for people who are too lazy ...            01/01/70 00:00      
            re: HLLs are for people            01/01/70 00:00      
               what\\\'s He-Man?            01/01/70 00:00      
                  Def: He-Man            01/01/70 00:00      
            ยต-controllers are for people who are too lazy ...            01/01/70 00:00      
               I don't want to discuss about HLL's effyciency            01/01/70 00:00      
               Oops            01/01/70 00:00      
                  dyslexics untie!            01/01/70 00:00      
            30% to 90%?            01/01/70 00:00      
               Neil, I kind of agree            01/01/70 00:00      
   You can be sure it does.            01/01/70 00:00      
   Code transform from A51 -> SDCC            01/01/70 00:00      
      This is also a thing I missed..            01/01/70 00:00      
         similar concept to MAC routines, locking to binary            01/01/70 00:00      
   is it possible ?            01/01/70 00:00      
      yes            01/01/70 00:00      

Back to Subject List