Re: [cc65] Assembler code in C

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2004-03-20 22:59:02
Hi!

On Sat, Mar 20, 2004 at 04:47:43PM -0500, Apple2Stuff wrote:
> The C stack is used for parameter passing between C functions? Correct?

With one exception, yes. The exception are fastcall functions. For these
functions, the rightmost parameter is passed in registers.

> Can I manipulate the hardware stack with out messing up access to the C
> stack?

Yes. But beware: In some cases, the compiler generates code that saves a
register on the hardware stack. When doing things like this, you should always
check the generated assembly.

> I am calling assembler routines (which may or may not have been generated by
> cc65) from C and coming from a background where I wrote one or the other I
> am getting a  little bit confused about what I can touch.

Separation is easier, if you write complete functions in assembler. Using
inline assembly for critical stuff is always problematic, especially since it
will run through the optimizer and may be rearranged, changed or even deleted.

> I noticed in the debug window the C stack is always displayed two bytes wide
> ... is the C stack always accessed 2 bytes at a time?

No, access to the C stack depends on the width of the data type stored there.
I don't remember why I used a width of 2 for the C stack, maybe because I
thought that this is the most common case (an int or ptr on the stack).

Regards


     	Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sat Mar 20 22:59:08 2004

This archive was generated by hypermail 2.1.8 : 2004-03-20 22:59:14 CET