6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 15, 2024 6:45 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Apr 27, 2005 1:40 pm 
Offline

Joined: Wed Apr 27, 2005 1:33 pm
Posts: 1
I am newbie in EPROM programming, but I have C/C++ experience

I wish try programm something for 65c02 processor..

how look C++ coder for this action? is code same like for DOS C++ programming?

and do i need assembler language after I create C++ program? if yes, explain more

:x


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Apr 27, 2005 4:13 pm 
Offline

Joined: Thu Jan 16, 2003 12:55 pm
Posts: 64
Location: Indianapolis
A C compiler is here: http://www.cc65.org/

I haven't been able to use it though (I'm a C newbie). So I just use the assembler and linker included with it. :)

It's probably not much like DOS, because DOS is an operating system rather than a CPU. There's libraries included with cc65 for specific platforms though, that might help unless you're using a custom system.

edit:

I think it should be possible to write a C program that would compile and work on different platforms. I just don't know what the modifications would generally be (int, long, etc. would be different sizes I think). Contiki seems to be like that, but I haven't been able to compile an NES version of it myself. http://www.sics.se/~adam/contiki/ There's a DOS version of it.


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 28, 2005 3:52 pm 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
gp333 wrote:
how look C++ coder for this action? is code same like for DOS C++ programming?


Unless you use a front-end a la "cfront" (the program that started the whole C++ language fiasco to begin with), you're not likely going to find a 6502 implementation of C++. C++, especially in its modern form, is *entirely* too big, too complex for the 6502. Since a combined JSR/RET combination (the instructions to invoke a function call in C, NOT counting pushing parameters onto the stack) is 12 clock cycles, you can imagine the sheer length of time it'd take to invoke a virtual method: you need to first dereference the first slot of an object to grab the vtable pointer, dereference the appropriate entry in the vtable, THEN invoke it. Modern CPUs make this trivial because they have proper register-based indexing. 65816 needs to do this through much more primitive, and time-consuming, means.

Quote:
and do i need assembler language after I create C++ program? if yes, explain more


That depends on whether you are writing an operating system or not. It sounds like you are, since you're intending to burn to EEPROM. As you're probably already aware, every C or C++ program requires at least some kind of "startup library" (often called crt0, for C Run-Time). This library's purpose in life is to establish the C run-time environment (hence its name), gather parameters from the shell environment, if any, invoke constructors for global objects (C++ only), and invoke main(). This library must be written in assembly language, since C-compiled code is unable to function yet. Note, since you're planning on coding to an EEPROM, most of this code can be dispensed with (e.g., there is no shell environment). OTOH, if you're coding in C++, you DO need to invoke the appropriate constructors on the global objects.

Your best bet, so far as I can tell, is to research using plain-vanilla C, or maybe an alternative programming language all-together (e.g., Forth? Pascal / Oberon? Compiled BASIC?), something that offers the same basic capabilities, but with substantially lighter weight on the 6502/65816.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: