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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/07/09 16:17
Read: times


 
#164463 - Use XBYTE macro
Responding to: ???'s previous message
Gopal Amlekar said:
Hello all,
I have an 8051 based circuit, in which an 8255 is connected as memory mapped device. I have not been able to figure out the code to control this IC in C using SDCC.
For e.g. to set all 8255 ports in output mode, I need to write 0x80 in the control word register of 8255. In assembly, I can do it with the following code:
CONTROL_ADDR_8255 equ 280BH  ; This is address of 8255 control word

mov  A,    #80H	             ;8255 control word to set all ports as O/P, mode 0
mov  DPTR, #CONTROL_ADDR_8255 ;Load 8255 address (Control word reg.) in DPTR
movx @DPTR, A		     ;Send control word to 8255

 

I need some hints on how to do it in C using SDCC compiler?
Thanks in advance to all.
Regards,


#define XBYTE ((unsigned char volatile xdata *) 0)
...
#define pio_ctl    XBYTE(0x280B)
...

pio_ctl = 123;
...
variable = pio_ctl;
...

 


The pre-processor is your friend.

David.

// you may be happier with a function like macro:
#define XBYTE(ads)     ((unsigned char volatile xdata *) 0)(ads)

 



List of 25 messages in thread
TopicAuthorDate
How to access memory mapped 8255 with SDCC?            01/01/70 00:00      
   also asked here:            01/01/70 00:00      
   8255 with SDCC            01/01/70 00:00      
   Wrong question?            01/01/70 00:00      
      It's C            01/01/70 00:00      
         not on the 8051            01/01/70 00:00      
            Oh yes it is!            01/01/70 00:00      
   Use XBYTE macro            01/01/70 00:00      
      Isn't there a problem with that?            01/01/70 00:00      
         Oops. I used a wrong example            01/01/70 00:00      
            Portability            01/01/70 00:00      
               like this...            01/01/70 00:00      
   How about a macro in ASM, callable from 'C'?            01/01/70 00:00      
      This is HOW I will Prefer            01/01/70 00:00      
         LST output of my previously posted code            01/01/70 00:00      
            Try the comparison            01/01/70 00:00      
         Unnecessarily complicated!            01/01/70 00:00      
            NOT UNNECESSARILY            01/01/70 00:00      
               You are mistaken            01/01/70 00:00      
               Array or pointer similar            01/01/70 00:00      
      That should not be necessary            01/01/70 00:00      
         SFRX(...,. ..) worked            01/01/70 00:00      
            SFRX - presumably, that's an SDCC extension?            01/01/70 00:00      
               Found it!            01/01/70 00:00      
                  RE: Found it!            01/01/70 00:00      

Back to Subject List