Join our technical discussions about Freescale Microcontrollers: M68HC12. (Freescale Semiconductor is a Subsidiary of Motorola).
So far in May, you have voted 0 times ou of a total of 20 votes by the community.
Please help us clean the archives from unuseful discussion threads by using the voting system! Details here.
Is this thread worth a thumbs up?
Mixed C and Assemly - Mohammad Khamees - Jun 18 12:31:44 2006
Hi,
I intend to mix some subroutines witten in assembly language into a
main program written in C language to program an EVB9S12NE64 kit
using CodeWarrior software..
could anyone tell me how?
is it only as the following examble:
if (i==0)
asm {
LDAA $2000
STAA $3000
.
.
}
else
asm {
LDAA $3000
STAA $2000
.
.
}
or there's other rules or WHAT?
thanx in Advance
(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )Re: Mixed C and Assemly - BobG...@aol.com - Jun 18 12:41:58 2006
In a message dated 6/18/2006 12:31:42 P.M. Eastern Standard Time,
e...@yahoo.com writes:
could anyone tell me how?
========================I use the imagecraft HC12 compiler, and this is CLEARLY
explained in the
help file. I have heard some complaints about how easy/hard codeworrier is to
use, but SURELY there is some mention of how to do this in the docs... Big
picture is inline in a c file, or add a .s file to the project. Know how to do
an
assembler only program?
(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com ) Re: Mixed C and Assemly - Daniel Friederich - Jun 18 13:04:59 2006
the manual {CodeWarrior}Help\PDF\Compiler_HC12.pdf does contain a
chapter called "High-Level Inline Assembler
for the Freescale HC(S)12" describing the syntax to be used.
The sample provided by the OP does actually compile just fine, so I'm
not sure where the problem is.
Daniel
int i;
void main(void) {
if (i==0)
asm {
LDAA $2000
STAA $3000
}
else
asm {
LDAA $3000
STAA $2000
}
for(;;) {} /* wait forever */
}
PS: In general I would use hex numbers in C syntax (0x2000 instead of
$2000) in C files, but the inline assembler also understands the $ syntax.
B...@aol.com wrote:
>
> In a message dated 6/18/2006 12:31:42 P.M. Eastern Standard Time,
> e...@yahoo.com writes:
>
> could anyone tell me how?
>
> ========================> I use the imagecraft HC12 compiler, and this is
CLEARLY explained in the
> help file. I have heard some complaints about how easy/hard codeworrier is to
> use, but SURELY there is some mention of how to do this in the docs... Big
> picture is inline in a c file, or add a .s file to the project. Know how to do
an
> assembler only program?
>
>
>
(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )Re: Mixed C and Assemly - Mohammad Khamees - Jun 19 14:50:56 2006
That's nice but I wanna know how variables created in C can be accessed
in Assembly
for ex:
int i[5];
asm{
LDD i
ADD #4
STD i
}
Is it valid??
--- In 6..., Daniel Friederich
wrote:
>
> the manual {CodeWarrior}Help\PDF\Compiler_HC12.pdf does contain a
> chapter called "High-Level Inline Assembler
> for the Freescale HC(S)12" describing the syntax to be used.
> The sample provided by the OP does actually compile just fine, so I'm
> not sure where the problem is.
>
> Daniel
>
> int i;
> void main(void) {
>
> if (i==0)
> asm {
> LDAA $2000
> STAA $3000
> }
> else
> asm {
> LDAA $3000
> STAA $2000
> }
> for(;;) {} /* wait forever */
> }
>
> PS: In general I would use hex numbers in C syntax (0x2000 instead of
> $2000) in C files, but the inline assembler also understands the $
syntax.
>
> BobGardner@... wrote:
> >
> > In a message dated 6/18/2006 12:31:42 P.M. Eastern Standard Time,
> > epm_2006@... writes:
> >
> > could anyone tell me how?
> >
> >
> >
> > ========================> > I use the imagecraft HC12 compiler, and this is
CLEARLY explained in
the
> > help file. I have heard some complaints about how
easy/hard
codeworrier is to
> > use, but SURELY there is some mention of how to do
this in the
docs... Big
> > picture is inline in a c file, or add a .s file to
the project. Know
how to do an
> > assembler only program?
> >
> >
> >
> >
> >
> >
> >
> >
> >

(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )Re: Mixed C and Assemly - eqh2 - Jun 19 15:39:27 2006
--- In 6..., "Mohammad Khamees"
wrote:
> That's nice but I wanna know how variables created in
C can be
accessed
> in Assembly
>
This is explained in the High-Level Inline Assembler section of the
Codewarrior docs. Look through your start12.c file for some examples.
It would be nice if there were some more examples included with
Codewarrior.

(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )Re: Mixed C and Assemly - Erich Styger - Jun 20 3:11:54 2006
Hello,
Yes, except that you have to use ADDD. So it would be:
int i[5];
void bar(void) {
asm {
LDD i
ADDD #4
STD i
}
}
Which will give you:
4: asm {
5: LDD i
0000 fc0000 [3] LDD i
6: ADDD #4
0003 c30004 [2] ADDD #4
7: STD i
0006 7c0000 [3] STD i
8: }
9: }
0009 3d [5] RTS
Erich
-----Original Message-----
From: 6... [mailto:6...] On Behalf Of
Mohammad Khamees
Sent: Monday, June 19, 2006 8:48 PM
To: 6...
Subject: [68HC12] Re: Mixed C and Assemly
That's nice but I wanna know how variables created in C can be accessed in
Assembly
for ex:
int i[5];
asm{
LDD i
ADD #4
STD i
}
Is it valid??
--- In 6..., Daniel Friederich
wrote:
>
> the manual {CodeWarrior}Help\PDF\Compiler_HC12.pdf does contain a
> chapter called "High-Level Inline Assembler for the Freescale HC(S)12"
> describing the syntax to be used. The sample provided by the OP does
> actually compile just fine, so I'm not sure where the problem is.
>
> Daniel
>
> int i;
> void main(void) {
>
> if (i==0)
> asm {
> LDAA $2000
> STAA $3000
> }
> else
> asm {
> LDAA $3000
> STAA $2000
> }
> for(;;) {} /* wait forever */
> }
>
> PS: In general I would use hex numbers in C syntax (0x2000 instead of
> $2000) in C files, but the inline assembler also understands the $
syntax.
>
> BobGardner@... wrote:
> >
> > In a message dated 6/18/2006 12:31:42 P.M. Eastern Standard Time,
> > epm_2006@... writes:
> >
> > could anyone tell me how?
> >
> >
> >
> > ========================> > I use the imagecraft HC12 compiler, and this is
CLEARLY explained in
the
> > help file. I have heard some complaints about how
easy/hard
codeworrier is to
> > use, but SURELY there is some mention of how to do
this in the
docs... Big
> > picture is inline in a c file, or add a .s file to
the project. Know
how to do an
> > assembler only program?
> >
> >
> >
> >
> >
> >
> >
> >
> >

(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )