Mix C&Assembly with Keil C51/A51
CASTalk.com Forum Index CASTalk.com
Discussion of DSP, FPGA, storage and embedded system.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web castalk.com
Mix C&Assembly with Keil C51/A51

 
Post new topic   Reply to topic    CASTalk.com Forum Index -> Embedded System
Author Message
Nappy
Guest





Posted: Sun Dec 18, 2005 5:15 pm    Post subject: Mix C&Assembly with Keil C51/A51 Reply with quote

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
Back to top
Tauno Voipio
Guest





Posted: Mon Dec 19, 2005 1:12 am    Post subject: Re: Mix C&Assembly with Keil C51/A51 Reply with quote

Nappy wrote:
Quote:
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?

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
Back to top
Nappy
Guest





Posted: Mon Dec 19, 2005 1:15 am    Post subject: Re: Mix C&Assembly with Keil C51/A51 Reply with quote

"Tauno Voipio" <tauno.voipio@INVALIDiki.fi> wrote in message
news:Awipf.380$2x4.229@read3.inet.fi...
Quote:
Nappy wrote:
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?

Yes.

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

--


:)

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.







Quote:

Tauno Voipio
tauno voipio (at) iki fi
Back to top
Stephen
Guest





Posted: Mon Dec 19, 2005 1:15 am    Post subject: Re: Mix C&Assembly with Keil C51/A51 Reply with quote

In article <Vfgpf.42969$6e1.12108@newssvr14.news.prodigy.com>, Nappy
<noemail@all.com> writes
Quote:
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

Try:

unsigned long data burnAddress;

unless you are already compiling in the SMALL model.


Quote:
in the inline assembly I have:

EXTRN DATA (burnAddress)
Back to top
Rickey
Guest





Posted: Mon Dec 19, 2005 9:15 am    Post subject: Re: Mix C&Assembly with Keil C51/A51 Reply with quote

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
Back to top
Chuck F.
Guest





Posted: Mon Dec 19, 2005 5:15 pm    Post subject: Re: Mix C&Assembly with Keil C51/A51 Reply with quote

Rickey wrote:
Quote:

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 ;-)

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
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Back to top
Nappy
Guest





Posted: Wed Dec 21, 2005 12:32 am    Post subject: Re: Mix C&Assembly with Keil C51/A51 Reply with quote

"Chuck F. " <cbfalconer@yahoo.com> wrote in message
news:Ic2dnZ6Z3N44fDvenZ2dnUVZ_tCdnZ2d@maineline.net...
Quote:
Rickey wrote:

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 ;-)

Oh Please Chuck..
Back to top
Nappy
Guest





Posted: Wed Dec 21, 2005 12:37 am    Post subject: Re: Mix C&Assembly with Keil C51/A51 Reply with quote

"Rickey" <bhargav.ajay@gmail.com> wrote in message
news:1134980669.535574.241810@g49g2000cwa.googlegroups.com...
Quote:
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


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.
Back to top
Nappy
Guest





Posted: Wed Dec 21, 2005 12:37 am    Post subject: Re: Mix C&Assembly with Keil C51/A51 Reply with quote

Quote:
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
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/

oh plz chk. what a petty wrthls pst.
Back to top
Neil Kurzman
Guest





Posted: Wed Dec 21, 2005 9:15 am    Post subject: Re: Mix C&Assembly with Keil C51/A51 Reply with quote

Nappy wrote:

Quote:
"Rickey" <bhargav.ajay@gmail.com> wrote in message
news:1134980669.535574.241810@g49g2000cwa.googlegroups.com...
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


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.

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.
Back to top
Nappy
Guest





Posted: Wed Dec 21, 2005 5:15 pm    Post subject: Re: Mix C&Assembly with Keil C51/A51 Reply with quote

"Neil Kurzman" <nsk@mail.asb.com> wrote in message
news:43A8DB85.7D8F6BC0@mail.asb.com...
Quote:

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.



Thank you Neil.
Back to top
bis
Guest





Posted: Thu Dec 29, 2005 5:15 pm    Post subject: Re: Mix C&Assembly with Keil C51/A51 Reply with quote

Quote:

"Tauno Voipio" <tauno.voipio@INVALIDiki.fi> wrote in message
news:Awipf.380$2x4.229@read3.inet.fi...
Nappy wrote:
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 module
which
are
inline code.
The assembly modules have to access variables which are defined i
the
main
C area.
I am using the EXTRN command in my inline ASM area for at least on
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 directl
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?

Yes.

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

--


:)

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

Thanks.








Tauno Voipio
tauno voipio (at) iki fi





Check if Keil realy use big endian for storing long variables. May be yo
need to exchnge MSB with LSB.
Back to top
 
Post new topic   Reply to topic    CASTalk.com Forum Index -> Embedded System All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




VoIP Electronics Powered by phpBB