This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

getting vriable address

how do i get variable address defined in C inside assembly instructions while writing some assembly instructions between C code.

Ashutosh Tiwari
Bangalore

Parents
  • 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?

Reply
  • 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?

Children
  • 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.