FYI:
when using Codewarrior 6.1 and a target cpu of 568357, the "rules from
the manual" work as advertised.
in a "C" file I put the following code:
extern long myFunc(long a, int b, int c); ...
long temp32; ...
temp32 = myFunc(1000,10,20);
In another "C" file I put the following:
asm long myFunc(long a, int b, int c) {
//return (a + (L_mult(b,c)); mpy y1,y0,b ADD
b,a rts
After execution the value of 1400 was in the temp32
variable.
Dissassembly of the call yielded:
*** EXECUTABLE CODE (.text) ***
Address ObjectCode
Label Opcode
Operands
Comment
0x00000000
Fmain: 0x00000000
0xE40003E8
move.l #1000,A 0x00000002
0xE58A
move.w #10,Y0 0x00000003
0xE794
move.w #20,Y1 0x00000004
0xE2540000
jsr
0x000000
; FmyFunc 0x00000006
0xD07D0000
move.l
A10,X:0x000000
; Ftemp32 ...
...
*** RELOCATIONS (.rela.text)
***
no
type
offset addend
symbol
1
R_56800E_CODE19 0x00000008
0x00000000 FmyFunc 2
R_56800E_LONG16 0x0000000B
0x00000000 Ftemp32 ...
hope this helps!!!
Jerry.
The answer will most likely be very obvious when looking at the actual
generated assember code. I'd rely on the real thing over the "rules
from the manual" any day of the week. That is not to say that those rules are
not followed or are inaccurate.
Howard
Thanks for
that, still seem to be having a problem..
Ok.. in my
header I have
extern long
myfunc(long a, short b, short c);
then in my
assembly file
SECTION
rtlib
GLOBAL
Fmyfunc
ORG P:
Fmyfunc:
clr A
rts
ENDSEC
END
That should
logically return a zero everytime, but instead I'm getting some random
number which is the number 5198, since a long is a 32bit number, so
clearing A and returning it should be giving me back
zero.
Is there
something I'm missing?
From: help56800 [mailto:h...@yahoo.com] Sent:
Thursday, 22 July 2004 12:55 PM To:
m...@yahoogroups.com Subject: [motoroladsp] Re: Slight
dilemma
CodeWarrior
"Targeting 56800E" manul covers calling conventions. This is
what it says:
Calling
Conventions and Stack Frames
Passing Values to Functions
The compiler uses registers A,B, R1, R2, R3, R4, Y0, and Y1 to pass
parameter values to functions. Upon a function call, the
compiler scans the parameter list
from left to right, using
registers for these values: * The
first two 16-bit integer values - Y0 and Y1. * The first two 32-bit integer or float values - A and
B. * The first four pointer
parameter values - R2, R3, R4, and R1 (in that order). *
The third and fourth 16-bit integer values - A and B (provided that the compiler does not use these registers for 32-bit parameter
values). * The third 16-bit
integer value - B (provided that the compiler does not use this register for a 32-bit parameter value). The compiler passes the remaining parameter values on the
stack. The system increments the stack by the total amount of space
required for memory
parameters. This incrementing must
be an even number of words, as the stack pointer (SP) must be continuously long-aligned. The system moves parameter values to the
stack from left to right, beginning with the stack location
closest to the SP. Because a long
parameter must begin at an even
address, the compiler introduces one-word gaps before long parameter values, as appropriate.
Returning Values From Functions The compiler returns function results in registers A, R0, R2,
and Y0: * 16-bit integer values -
Y0. * 32-bit integer or float
values - A. * All pointer values -
R2. * Structure results - R0
contains a pointer to a temporary space allocated by the caller. (The pointer is a hidden parameter value.) Additionally, the compiler: * Reserves R5 for the stack frame pointer when a
function makes a dynamic allocation. (This is
the original stack pointer before allocations.) Otherwise, the compiler saves R5 across function calls. * Saves registers C10 and D10 across function
calls. * Does not save registers
C2 and D2 across function calls.
_____________________________________ Note: If you do a simple "reply" with your email client, only
the author of this message will receive your answer. You need to do a
"reply all" if you want your answer to be distributed to the entire
group.
_____________________________________ About this discussion group:
To Join: m...@yahoogroups.com
To Post:
m...@yahoogroups.com
To
Leave: m...@yahoogroups.com
Archives: http://www.yahoogroups.com/group/motoroladsp
More Groups:
http://www.dsprelated.com/groups.php3
_____________________________________ Note: If
you do a simple "reply" with your email client, only the author of this message
will receive your answer. You need to do a "reply all" if you want your
answer to be distributed to the entire group.
_____________________________________ About this discussion group:
To Join: m...@yahoogroups.com
To Post:
m...@yahoogroups.com
To Leave: m...@yahoogroups.com
Archives: http://www.yahoogroups.com/group/motoroladsp
More Groups:
http://www.dsprelated.com/groups.php3
_____________________________________ Note: If you do a simple
"reply" with your email client, only the author of this message will receive
your answer. You need to do a "reply all" if you want your answer to be
distributed to the entire group.
_____________________________________ About this discussion group:
To Join: m...@yahoogroups.com
To Post:
m...@yahoogroups.com
To Leave: m...@yahoogroups.com
Archives: http://www.yahoogroups.com/group/motoroladsp
More Groups:
http://www.dsprelated.com/groups.php3
________________________________________________________________________ This email has been scanned for all viruses by the MessageLabs SkyScan service. For more information visit http://www.messagelabs.com ________________________________________________________________________
________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information visit http://www.messagelabs.com
________________________________________________________________________ |