Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: Mixing assembly and C...

2004-02-21 by entell0

I am not 100% sure about how GNU compiler and assembler handle
things, but in general, if you don't mind using global variables,
then you can declare them in your C environment and reference them in 
your assembly code. This will allow you to access these global 
variables from both worlds.

Alternatively, if you are going to use local variables instead of 
global ones, you can call your assembly routine from your C code and 
pass the local variables through the function arguments. If you pass 
the variables by reference, you should be able to modify their values 
as well which would allow you to copy the values of your labels in 
the assembly world into these arguments and pass them back to the C 
world.

Lastly, if you are planning to use inline assembly, I am afraid
I am not too sure what you can and can't do. You might be able
to just put the name of the variable with an underscore in front 
of it in your inline assembly code and access it that way.

Hope this helps a little.


Emrah


--- In lpc2000@yahoogroups.com, "Musharraf Hanif" 
<musharraf_hanif@h...> wrote:
> Hello all,
> 
> I am using Keil with a GNU compiler in an attempt to develop some 
code.
> 
> I have been trying to determine some method by which I can obtain 
the value 
> of the addresses of some lables (in assembly) to use them in my C 
code. Can 
> anyone help me?
> 
> Also, how can I use some constants defined in some c/h file in an 
assembly 
> file. Similarly for a reversed situation.
> 
> Any help will be appreciated.
> 
> Regards,
> 
> Musharraf Hanif
> 
> _________________________________________________________________
> Tired of spam? Get advanced junk mail protection with MSN 8. 
> http://join.msn.com/?page=features/junkmail

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.