Mix C&Assembly with Keil C51/A51

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
I am having a difficult time combining C and assembly in the Kiel
development environment.
I have a progtram which is mainly in C. I have assembly modules which are
inline code.
The assembly modules have to access variables which are defined in the main
C area.
I am using the EXTRN command in my inline ASM area for at least one char
variable.
ex:
EXTRN DATA(curSector)

I now have an unsigned long which was being passed to the inline assembly in
the Registers. That works, of course. But I wanted to directly address the
long variable in my assembly code to eliminate the need to prep the
registers prior to the call.

so I have

unsigned long burnAddress    ; defined in the C code

in the inline assembly I have:

EXTRN DATA (burnAddress)

and I access it like this:

mov a,burnAddress    ; MSB
..
mov a,burnAddress +1
..
mov a,burnAddress +2
..
mov a,burnAddress +3    LSB



Is this correct?

Thanks

eng



Re: Mix C&Assembly with Keil C51/A51
Quoted text here. Click to load it

Yes.

A long needs four bytes, but the accumulator fits only
one at a time, so you need four fetches.

--

Tauno Voipio
tauno voipio (at) iki fi

Re: Mix C&Assembly with Keil C51/A51

Quoted text here. Click to load it
are
main
assembly in
the


:)

Yes. I was asking about the proper connection for the linker. As it seems I
am not getting the proper values in the assembly.

Thanks.







Quoted text here. Click to load it



Re: Mix C&Assembly with Keil C51/A51
Quoted text here. Click to load it
which
the
char
address
I


Check if Keil realy use big endian for storing long variables. May be yo
need to exchnge MSB with LSB.




Re: Mix C&Assembly with Keil C51/A51
Quoted text here. Click to load it

Try:

 unsigned long data burnAddress;

unless you are already compiling in the SMALL model.


Quoted text here. Click to load it

Re: Mix C&Assembly with Keil C51/A51
or you can use unsigned long idata burnAddress;
what are the errors or problems you are getting? i mean can you plz be
more specific bout them. so that i can help you in a better way ;-)
reagards,
ajay bhargav
www.rickeyworld.tk


Re: Mix C&Assembly with Keil C51/A51
 >
Quoted text here. Click to load it

Google is not Usenet, nor is their broken Usenet interface in any
way representative of the view others have.  In order to make your
posts intelligible you MUST include context.  See below for means
of so doing even on Google

In addition you should avoid silly spelling mistakes and
abbreviations, such as the use of i (in place of I) and plz.  This
greatly improves readability.

--
"If you want to post a followup via groups.google.com, don't use
  the broken "Reply" link at the bottom of the article.  Click on
We've slightly trimmed the long signature. Click to see the full one.
Re: Mix C&Assembly with Keil C51/A51

Quoted text here. Click to load it

Oh Please Chuck..




Re: Mix C&Assembly with Keil C51/A51

Quoted text here. Click to load it

oh plz chk. what a petty wrthls pst.



Re: Mix C&Assembly with Keil C51/A51

Quoted text here. Click to load it

I am trying to milk every nanosecond of speed out of a design and I have a
routine which is currently being passed a LONG in registers. And I was
looking to remove the time it took to load them prior to the call. So I am
attempting to access the long in the routine as:

mov a,burnAddress
..
mov a,burnAddress+1

etc.

But I am getting the wrong data.

When using inline assembly with uVision I can not get the CODE in the
listings so suppose I have to inspect the opcodes in the hex file..

The default data area for this variable would be DATA.



Re: Mix C&Assembly with Keil C51/A51



Quoted text here. Click to load it

Rule of thumb with Keil.
Write the sub in C and look at the asm. ( Or at least the data access parts)
if the var is define in C you may get that Underscore thing (_burnAddress ???)

Try it with an int first I  THINK Keil calls internal libs for long, but does
ints in place.
That varies by compiler version I guess.



Re: Mix C&Assembly with Keil C51/A51

Quoted text here. Click to load it
parts)
Quoted text here. Click to load it
???)
Quoted text here. Click to load it
does

Thank you Neil.



Site Timeline