c++

You need an actual VIC.

Moderator: Moderators

User avatar
beamrider
Vic 20 Nerd
Posts: 872
Joined: Sun Oct 17, 2010 2:28 pm
Location: UK

c++

Postby beamrider » Wed Oct 05, 2016 12:00 pm

https://www.youtube.com/watch?v=zBkNBP00wJE

Interesting presentation. Could equally apply to the Vic-20. Certainly seems to generate leaner code than CC65.

groepaz
Vic 20 Nerd
Posts: 635
Joined: Wed Aug 25, 2010 5:30 pm

Re: c++

Postby groepaz » Wed Oct 05, 2016 12:40 pm

Certainly seems to generate leaner code than CC65

actually, no it doesnt

User avatar
beamrider
Vic 20 Nerd
Posts: 872
Joined: Sun Oct 17, 2010 2:28 pm
Location: UK

Re: c++

Postby beamrider » Wed Oct 05, 2016 2:50 pm

so does CC65 support in-lining now?

groepaz
Vic 20 Nerd
Posts: 635
Joined: Wed Aug 25, 2010 5:30 pm

Re: c++

Postby groepaz » Wed Oct 05, 2016 3:07 pm

not really (*) - however what you saw in that video can easily be done in cc65, and it will result in better code than what is shown in that video. remember what they are doing is using a x86 compiler, and then translating x86 code to 6502 - which doesnt work well or efficient at all. actually the whole "lets use 6502 as an example" is pretty misleading, the techniques shown are useful for targets for which an actual c++ compiler backend exists - but their x86-to-6502 translator thing isnt really usable for anything (it even chokes on some simple stuff in the video at some point).

(*) some sort of inlining happens by wrapping function calls into macros, and using eg the VIC structs for accessing registers in a similar way as in that video will result in the same "perfect" lda/sta code.

Linzino
Vic 20 Amateur
Posts: 53
Joined: Fri Nov 06, 2015 4:13 pm
Website: http://retrocomputingarchive.blogspot.fr/
Location: France

Re: c++

Postby Linzino » Thu Feb 15, 2018 3:39 am

Hi

Why would one use C++ to generate 6502 code other than as a proof of concept?

ANSI C allows object-oriented programming in a more efficient way (though, slightly less elegant), through:
- composition + pointer to structs -> inheritance
- pointer to functions -> virtual methods (sub-type polymorphism)

I use object-oriented programming in my massively 8-bit cross-platform game CROSS CHASE
https://github.com/Fabrizio-Caruso/CROSS-CHASE
You can look at src/item.h and see how I achieve some object-oriented design in a not too complicated fashion.

Fabrizio

User avatar
beamrider
Vic 20 Nerd
Posts: 872
Joined: Sun Oct 17, 2010 2:28 pm
Location: UK

Re: c++

Postby beamrider » Thu Feb 15, 2018 4:09 am

I never got on with the pseudo OO approach in C. I find the syntactic clutter difficult to read so just stick to shared state and functional decomposition. When in Rome...

Edit: Mike - note the correct usage of C :wink:

Linzino
Vic 20 Amateur
Posts: 53
Joined: Fri Nov 06, 2015 4:13 pm
Website: http://retrocomputingarchive.blogspot.fr/
Location: France

Re: c++

Postby Linzino » Thu Feb 15, 2018 4:25 am

If you look at my code, you won't see much clutter.
Currently I use very little object-oriented programming. My future code may use more.

Object-oriented programming is a pattern and not something enabled by a language.
Some languages provide syntactic sugar for it (usually at a little cost).
The cost may be too high in some cases (e.g., 8-bit CPUs).

Gnome is written in ANSI C and uses object-oriented programming.

An interesting read:
https://www.amazon.co.uk/Object-Oriente ... B00930I6TK

User avatar
beamrider
Vic 20 Nerd
Posts: 872
Joined: Sun Oct 17, 2010 2:28 pm
Location: UK

Re: c++

Postby beamrider » Thu Feb 15, 2018 6:45 am

Will take a look when I get chance, but I would suggest that your syntactic clutter will increase along with your use of 'OO' '.

I briefly used C in the 90s to implement objects under Microsoft's COM 'interface' based OO platform where C++ came as a welcome relief.

[That book looks to be out of print by the way]


Return to “Emulation and Cross Development”

Who is online

Users browsing this forum: No registered users and 1 guest