Re: [cc65] C++ compiler for the 6502/6510 (CC66)?

Date view Thread view Subject view

From: David Holz (davidh_at_otterspace.com)
Date: 2003-03-06 17:22:01


Nothing was added to C++ that would make it slower than its counterpart in
C.  This design goal was strictly adhered to in the design of C++.

From: "Christian Krüger" <christian.krueger_at_pace.de>
> all member-functions will get slower (ok,ok static members not.. ;-) ).
> The compiler have allways to supply the 'this'-pointer and every access
> to class functions & members is indirect. (Bigger & slower... as I said.)

All functions that act on structures in C require passing the "this" pointer
manually:  void bounceBall(struct Ball* ball, float someParam).  Having the
compiler knowledgable of the "this" pointer makes it much faster than a
normal stack-passed pointer.  For instance, there can be zero-page pointers
set up for specific "this" pointers for various classes.

> I'm not talking about the virtual function table here - this would
> increase the program-size additionally...

Enabling virtual functions would add 1 pointer to each class that uses them.
Compiled virtual function calls are just a call through a function pointer
in a table and are a whole lot faster than doing "if" trees or switch/case,
and a lot easier and safer than managing your own function pointer tables in
C.

> It would also be 'funny' to return class-objects - Remember: cc65 doesn't
> support even 'struct' returns. (And as we all like fast programs, this is
> not a limitation to be worry about... ;-) )

This would be no different than returning a struct, except the option of
overriding how the copy is done with your own routine.  If you don't take
the option, the compiled code is exactly the same as C's struct returning
code.

> >Actually, I think I'd be happy with doubles for now :)
>
> It would be of course interessting how much memory is left when IEEE is
> fully supported... (with <math.h>)

Doesn't the linker only pull in those functions which are actually
referenced?  If so, it shouldn't have to pull in everything, and something
like Woz's floating point routines are only a couple of hundred bytes of 650
2.

However, all of this is pretty [OT].  I'm also all for a 6502 C++ compiler,
but that'd be a different project altogether, and I fully agree with
Christian Krueger's notions of "better code through a smarter compiler".

--
White Flame (aka David Holz)
http://www.white-flame.com/


----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2003-03-06 17:17:51 CET