Jump to content
SlithyMatt

"Hello, World!" with cc65

Recommended Posts

Both videos are great!  I'm looking forward to the follow up CC65 videos.  I've been learning 6502 by doing a project with acme, but I feel like I'm outgrowing it.  Meanwhile, cc65 (or really ca65) feels very intimidating since I've never defined segments before.  With acme, I just have a big `main.asm` where I import other files in the order I want them assembled.  It's very peasant-level, but it's been working so far.  I'd love to hear you explain how you structure your binaries, rather than just trying to divine it by looking at the XCI engine source code.  Keep up the great work!

  • Like 1

Share this post


Link to post
Share on other sites
3 hours ago, Jestin said:

Both videos are great!  I'm looking forward to the follow up CC65 videos.  I've been learning 6502 by doing a project with acme, but I feel like I'm outgrowing it.  Meanwhile, cc65 (or really ca65) feels very intimidating since I've never defined segments before.  With acme, I just have a big `main.asm` where I import other files in the order I want them assembled.  It's very peasant-level, but it's been working so far.  I'd love to hear you explain how you structure your binaries, rather than just trying to divine it by looking at the XCI engine source code.  Keep up the great work!

Actually, most of my projects are just like how you describe, including the XCI engine. You don't have to mess around with segments and linking if you don't want to. Just throw everything in the "CODE" segment and use .include to order it, so you only need to have .segment instructions in the main file, which you can copy verbatim from my all-assembly example here.

Share this post


Link to post
Share on other sites

Hi,

what editor do you use? I am trying to integrate it now in Visual Studio Code.

I am working on Windows - I potentially could switch for the complete development to Ubuntu in a VM, but would like to keep everything in the same place. For now all the stuff is sitting in Files on my Windows part. 

So worked through your instructions and setup the cygwin and the cc65 inside cygwin. I also created a link from my home directory to the working directory. All great.

I have installed Visual Studio Code and were able to create a link to the cygwin shell (works great).

I downloaded the CC65 integration (cc65 for 6502/65816 machines from SharpNinja) from the marketplace. But where I now struggle is to link the cc65 compiled under cygwin to Visual Studio Code. Main reason: I need to call CC65 within the cygwin environment because of the cygwin libraries required. I cannot just run the ca65.exe for instance as it will not find the cygwin libraries if I am not in the cygwin environment.

Any idea how to get this integrated?

/Edit: got one step further - it is important for the CYGWIN environment that you setup the Windows PATH environment variable .. Then the cygwin.dlls could be found and you can run ca65 from a windows cmd window ... Cracking on with the integration into CS Code

Edited by SerErris
  • Like 1

Share this post


Link to post
Share on other sites

Were you able to get make to run from outside the Cygwin terminal? It may depend on being inside the bash shell, I haven't tried it outside. When I'm running on Windows, I keep the Cygwin terminal up for building and Git Bash for running the pre-built emulator and doing any Git command line operations that can't be done in Atom (I avoid the DOS command prompt whenever possible).

But I would generally recommend developing inside Linux. You can use either a VM (VirtualBox with Ubuntu running inside the VM works great!) or using the Windows Subsystem for Linux.

Share this post


Link to post
Share on other sites

I have found out, that you are actually not using VS Code and also do not have any build run integration. You have a manual build and run process (e.g. create a Makefile and than run make command in cygwin). That works - no doubt. But I am looking for the integrated solution.
 

Share this post


Link to post
Share on other sites

You can do it with VS Code or Atom, but it's going to take some more setup. For me personally, I don't care about using multiple terminals. I prefer to have a persistent shells for building and running.

Share this post


Link to post
Share on other sites
1 minute ago, SlithyMatt said:

Were you able to get make to run from outside the Cygwin terminal? It may depend on being inside the bash shell, I haven't tried it outside. When I'm running on Windows, I keep the Cygwin terminal up for building and Git Bash for running the pre-built emulator and doing any Git command line operations that can't be done in Atom (I avoid the DOS command prompt whenever possible).

But I would generally recommend developing inside Linux. You can use either a VM (VirtualBox with Ubuntu running inside the VM works great!) or using the Windows Subsystem for Linux.

Yes, you just need to setup CYGWIN in your Windows PATH variable. 
For me that is D:\Development\cygwin\bin ... after that you can run anything that has been compiled under cygwin just from cmd window.

211255902_Screenshot2020-09-19161223.thumb.jpg.f1ef13a1abb72b8c16f7df6f9df35e5b.jpg

As I said - developing inside Linux would be the last option. It is simply to much back and forth for me.

Also I am not looking for running it manually, I am looking to get it fully integrated into VS Code. There is a plugin for CC65 and also a integration into vice (it just runs the emulator with some commands), so that should work with x16emu as well. However it does not work like that - I could not  get VS Code to compile it with CC65 it is looking for a compiler/assembler to do the work and does not understand the CC65 plugin stuff or does not link it to the workspace 😞

 

 

Share this post


Link to post
Share on other sites

Can't VS Code work with a makefile? That would seem to be a pretty basic feature.

Atom has the atom-make package. VS Code must have something similar.

  • Like 1

Share this post


Link to post
Share on other sites

Using vs code the first time in my life. I agree the make process will most likely work. The run portion also need something that I can call an external program and using a parameter (e.g. what is the PRG file from the makefile? I can potentially create a small ps script and populate it, as it will contain always the same prg file and I always could call it run.ps1 or something. That should do this trick. 
 

What do you use for atom syntax highlighting of the ca65 assembler in Atom?

As VS Code is anyhow just another Atom clone I might want to go the opensource route... 

 

Edited by SerErris

Share this post


Link to post
Share on other sites

You can set the PRG name in the makefile to whatever you want.

The language-cc65 package is what you want for Atom.

 

Share this post


Link to post
Share on other sites

It is just the extension .. it does not really live anymore .. (the github page does not exist anymore) and is pretty much outdated. You even need to download a very old .net integration to get it running at all. And you cannot change the name of the .prg file - it needs to be named as TEST.PRG.

So I will now switch as well to Atom as I hope that it is better customizable (e.g. more open or at least easier).

Share this post


Link to post
Share on other sites

Have you thought about using the WSL? You can install the extension on VSC and use Ubuntu on Windows, so I think you won't need a VM and could directly use that extension for building/compiling.

image.thumb.png.6564fb9ab1ceb3ef404a78a6f8688f20.png

Share this post


Link to post
Share on other sites
24 minutes ago, sebassco said:

Have you thought about using the WSL?

WSL would definitely work, too, pretty much the same as it does on plain old Linux.

Share this post


Link to post
Share on other sites

I do not see any reason why I should need to build for X16 on Linux if I am Using. The whole Toolchain exists on Windows. If you want to use Linux - that is great and everything works there. But if you want to use Windows then WSL is just something to enable you to run Linux - which was not the idea in the first place.

I now have done a setup with Atom as VSCode does not have any proper syntax highlighting I can easily change. I still need to do the build and run integration. I have not done that as I currently working on the source. After I have something to compile I will try to build the integration (which should be really nothing than a caller script to make and CC65).

Share this post


Link to post
Share on other sites
13 hours ago, SerErris said:

But if you want to use Windows then WSL is just something to enable you to run Linux - which was not the idea in the first place.

After fiddling around with Atom and VSCode I reverted back to my trusty old emacs (both Windows and Linux). I did not like installing Cygwin nor Mingw so I installed Debian WSL and got my nice bash with all the useful tools. cc65 is a nice debian package and I can run the X16 emulator from my Windows installation just fine. I use Makefile from within emacs and version control with the old diff & patch tools. Slim and quick.

I also came to an epiphany... I don't actually like cc65 due to its C-stack implementation. It causes inefficient code.

Edited by geek504

Share this post


Link to post
Share on other sites
36 minutes ago, geek504 said:

I use Makefile from within emacs and version control with the old diff & patch tools. Slim and quick.

I recommend this approach, especially if you ever plan on developing with others.  Choose whichever editor you like (I use vim, so am obviously deeply offended by the mention of emacs here), but keeping the building separate from your editor is the key to working well with others.  Makefiles are tried and true, and you can find editor plugins to run them for you, if that's what you want.  This way you can switch out your editor easily if it doesn't suit you, but your build system remains the same.

Share this post


Link to post
Share on other sites
5 minutes ago, Jestin said:

I use vim, so am obviously deeply offended by the mention of emacs here

I use vim too... I don't discriminate 😀 I use nano and pico to edit unix config files when I'm too lazy to install vim. I reserve emacs for *real* development 😆

All I need now is a console-based X16/6502 debugger... I am seriously considering converting my Apple ][ text-only emulator into such debugger... xdb

  • Like 1

Share this post


Link to post
Share on other sites
20 minutes ago, desertfish said:

What do you prefer instead?

Doesn't exist yet... since I don't expect the compiler to be compliant to C-standards, I am thinking about writing my own (yet another) BASIC compiler akin to BASIC Boss but with more improvements. The only difference is that this one will be custom-made for the X16 and its improvements. I'll borrow many ideas from Woz's Integer BASIC, add HTAB/VTAB (or LOCATE) et al. With a BASIC compiler I won't need to bother the X16 devs for C64 BASIC improvements.

Share this post


Link to post
Share on other sites
50 minutes ago, desertfish said:

Sounds similar to what I am doing with Prog8 🙂

Yea, it occurred to me too! Honestly I have never heard of Prog8 and actually I thought it was invented by you! Couldn't find much on Google... anyways I know BASIC quite well and the grammar is already done for C64 BASIC V2. I am also old-school UNIX programmer so I am much more comfortable with Flex/Bison (lex/yacc) and C. I also don't feel like patching up cc65.

We can definitely exchange ideas!

Share this post


Link to post
Share on other sites
7 hours ago, desertfish said:

Prog8 *is* created by me, I'm working on the compiler while trying to create some interesting programs with it at the same time.

That explains the lack of information on the Net! I had first assumed that you created this language which led me to decide to write a compiler based on a true and tested BASIC dialect. I wouldn't need to re-invent anything, just code away the implementations. Analyzing Prog8 I can see how it is a blend of many different ideas so implementing it wouldn't present much problems... but still involve some thinking!

Feel free to add simple Prog8 source along with the generated assembly code in your Prog8 thread... I love analyzing compiled code and see how efficient or how to improve efficiency!

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Please review our Terms of Use