how do i get variable address defined in C inside assembly instructions while writing some assembly instructions between C code.
Ashutosh Tiwari Bangalore
http://www.keil.com/support/man/docs/c51/c51_ap_ctoasm.htm
Ashutosh, As Dan Henry specified, you need a good reason to do what you are trying to do (his link specifies 3, I thought). Why not write it all in C if you can? You can write your code in C, turn off all compiler optimizations and use the generated code as a basis. I wouldn't use assembly intermixed with C, unless you have a good reason to do so! Either way, can't you use your simulator to verify your code? By the way, Bangalore is a nice city. Been there for a wedding a couple of months ago.
If you need to ask, you shouldn't be using inline assembly. Seriously.
Make up your mind on what you're going to program in: C, or assembler. Inline assembly will lose you more of the advantages of either than you're ever likely to win back.
There is an example already in bin folder of your computer. please check out. it may not be exactly what you wanted but it'll give a kick start.
"There is an example already in bin folder ..."
Doh! Of course, the bin folder (slapping forehead with open palm) -- the first place to look for examples!
hello Tamir sir, actualy, i want to reduce the timing reqired to execute a routine which is taking more time while written in C, so i m using in-line assembly to write routine only. so i need it. how do i access address of a variable defined in C & allocated in external memory inside assembly code?
i want to reduce the timing reqired to execute a routine which is taking more time while written in C,
More than ... what?
so i m using in-line assembly to write routine only.
You're deducing incorrectly. Inline assembly is rather more likely to make your routine slower instead of faster, because inline assembly fragments get in the way of what the compiler needs to do to produce fast code. What you're doing there is roughly similar to letting the air out of a car's tires to make it go faster.
"i'm using in-line assembly to write routine only."
What?
Do you mean you're writing the entire routine in inline assembler?! That would be completely pointless!
If the complete routine is assembly, then put it into a proper assembly module - an .A51 file, or whatever.
For an example of how to write a C51-callable function in assembler, see: www.8052.com/.../read.phtml
"i want to reduce the time reqired to execute a routine which is taking more time while written in C"
As Hans-Bernhard Broeker said, this is almost certainly the wrong approach!
The first thing you must do is to determine precisely why your current 'C' routine is taking "too long" - and quantify how much "too long" it is.
If it's taking "too long" simply because your 'C' is badly written and inefficient, then you need to re-write the 'C' - not bodge it with inline assembler See http://www.keil.com/support/man/docs/c51/c51_xc.htm for tips
Remember that Assembly is just another language - it won't magically turn you into a better programmer. You need to be a skilled, experienced Assembly programmer to write tight, fast assembly code - it is more than likely that the C51 compiler can do a better job than a novice Assembly programmer...
On the other hand, if it's taking "too long" because your fucntion is just too complicated - then not even assembler can help you there!
can anybody have the devkit for psp emulation and c51? i think the cool of psp and c will be ace for the scene. do you think dosbochs will help? what about bluray on chip?
Ashutosh, But using inline assembly you are interfering with the work of the compiler optimizer. I would advide against it! For example - your choice of register usage might conflict with the optimal choice at that time, without you knowing it.
does anybody not know the answer?
i look in the bin and not get examples.
i wait with same problem and must have the answer!
Doh! Of course, the bin folder (slapping forehead with open palm) -- the first place to look for examples!"
"does anybody not know the answer?"
When so many people are telling you, this is a Bad Idea, do you not think that it might be a good idea to heed that advice??
But, if you relly want to find examples, do you really think that "bin" would be an appropriate name for a folder containing examples?!
If you've managed to find the 'bin' folder, try looking at the other folders nearby - see if you can't find one with a more appropriate name...
You must have the answer? Then pay someone for doing your work. Or spend some time to teach yourself - with enough knowledge you would know if this is a good or bad idea...