Hello,
I want to check if there is an equivalent instruction of the MOVX at the C language.
I tried doing in-line assembly with no luck.
Any assistance is appreciated
unsigned char xdata Ralph
whatever = Ralph;
will do a movx
Erik
XBYTE[0x1234] = 0x55;
will produce: mov dptr,#0x1234 mov a,#55 movx @dptr,a
and will move 55 into absolute location 0x1234 in xdata.
Let's try this again:
will produce:
mov dptr,#0x1234 mov a,#55 movx @dptr,a
unless you have a very good reason to be hacking with absolute addresses, don't do it.
simply define a 'C' variable, and use the xdata keyword, as Erik showed. you can also use the _at_ keyword, if you need as specific address.
this way, the tools know what you're up to; XBYTE circumvents this, so you have to ensure that the tools won't use the address for something else...
There's an old saying that goes, "a Real Programmer can write FORTRAN in any language" - the OP seems to be trying to write assembler in 'C'...
a very good reason to be hacking with absolute addresses
One of the most common good reasons is if you have hardware memory-mapped into the external data space. So, to write to a particular address, you must write to a particular xdata address.
In this case, you could use the _at_ directive to locate a variable. Or, you could use a C pointer.
volatile U8 xdata myReg _at_ 0xF000;
#define XdataReg(addr) (*((volatile xdata U8*)(addr))) #define myReg XdataReg(0xF000)
myReg = 0; myReg |= 1;
"One of the most common good reasons is if you have hardware memory-mapped into the external data space."
Of course.
XBYTE is effectively just a "magic number" address - hence I prefer using _at_.
Using _at_ automatically informs the tools that there is something at the specified location; using "magic number" addresses - whether via XBYTE or a pointer - hides this from the tools, so they have no reason to know that the address is "reserved"!
Thanks for your help, but the thing is that I intend to interface IDE HDD and it deals with 16-bits. How can I do that? because as far as I know xbyte is for 8-bit data. Many Thanks
"as far as I know xbyte is for 8-bit data"
The 8051 is an 8-bit procesor - that means it can only ever handle 8 bits at a time!
16 bits is just 8 bits - twice!
I'm using AT89C51SND1C chip which is 8051 archeticture. It has a feature to interface the IDE after enabling this option it uses DAT16H register for transferring the higher byte. your assistance is appreciated
You asked, "... I intend to interface IDE HDD and it deals with 16-bits. How can I do that? because as far as I know xbyte is for 8-bit data."
Then you said, "AT89C51SND1C ... has a feature to interface the IDE after enabling this option it uses DAT16H register for transferring the higher byte."
Doesn't that answer your own question?
Doesn't the Atmel documentation show you how to use these things?
yes, but in the assembly language. I'm trying to find the equivalent of such instruction in the C language. Many Thanks
Don't Atmel and/or Keil provide a C51 header file?
What is your specific difficulty in 'C'? Have you looked in the C51 Manual?
http://www.keil.com/support/man/docs/c51/c51_le_memtypes.htm
http://www.keil.com/support/man/docs/c51/c51_le_sfrs.htm
http://www.keil.com/support/man/docs/c51/c51_le_absvarloc.htm