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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/09/07 13:58
Read: times


 
Msg Score: +1
 +1 Good Answer/Helpful
#130495 - Code transform from A51 -> SDCC
Responding to: ???'s previous message
SDCC has data types for 16 and 32 bit SFR so translating your assembly code to C is straightforward:

#include <8052.h>

/* It is highly encouraged to have a look into
   the include file compiler.h
   http://svn.sourceforge.net/viewvc/sd...iew=markup
   if you want to share header files between different compilers: */
#include <compiler.h>


/* you did not tell the addresses so
   you have to adapt these to your hardware */
SFR    (APBBR_OPCODE, 0xE6);
SFR16  (APBBR_ADDR,   0xE0);
//SFR16E (APBBR_ADDR,   0xE1E0);
SFR32  (APBBR_RDATA,  0xE2);
//SFR32E (APBBR_RDATA,  0xE5E4E3E2);

#define APBBR_OP_SINGLE_READ (0x0a)


unsigned long APBBR_read_data(unsigned int addr)
{
  bit tmp_EA = EA;

  EA = 0;
  APBBR_ADDR = addr;
  APBBR_OPCODE = APBBR_OP_SINGLE_READ;

  __asm nop __endasm;

  EA = tmp_EA;
  return APBBR_RDATA;
}

compiles to:

   0000                     340 _APBBR_read_data:
   0000 AA 82               350 	mov	r2,dpl
   0002 AB 83               351 	mov	r3,dph
                            352 ;	sfr32.c:21: bit tmp_EA = EA;
   0004 A2 AF               354 	mov	c,_EA
   0006 92*00               355 	mov	_APBBR_read_data_tmp_EA_1_1,c
                            356 ;	sfr32.c:23: EA = 0;
   0008 C2 AF               358 	clr	_EA
                            359 ;	sfr32.c:24: APBBR_ADDR = addr;
   000A 8A E0               361 	mov	_APBBR_ADDR,r2
   000C 8B E1               362 	mov	(_APBBR_ADDR >> 8),r3
                            363 ;	sfr32.c:25: APBBR_OPCODE = APBBR_OP_SINGLE_READ;
   000E 75 E6 0A            365 	mov	_APBBR_OPCODE,#0x0A
                            366 ;	sfr32.c:27: __asm	nop __endasm;
   0011 00                  368 	 nop 
                            369 ;	sfr32.c:29: EA = tmp_EA;
   0012 A2*00               371 	mov	c,_APBBR_read_data_tmp_EA_1_1
   0014 92 AF               372 	mov	_EA,c
                            373 ;	sfr32.c:30: return APBBR_RDATA;
   0016 85 E2 82            375 	mov	dpl,_APBBR_RDATA
   0019 85 E3 83            376 	mov	dph,(_APBBR_RDATA >> 8)
   001C 85 E4 F0            377 	mov	b,(_APBBR_RDATA >> 16)
   001F E5 E5               378 	mov	a,(_APBBR_RDATA >> 24)
   0021 22                  380 	ret


(No library calls involved)

If your code is really time critical please see manual section 3.12 Inline Assembler Code

Happy hacking!

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