6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 6:39 pm

All times are UTC




Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: 6502 Assembler
PostPosted: Mon Apr 04, 2016 3:05 pm 
Offline

Joined: Mon Apr 04, 2016 2:34 pm
Posts: 10
Hi, Brand new here lol. I know this maybe a stupid and I apologise if it is buy anyways, what program do people use for assembly language? i'm wanting to make a nes game and its basically a toss up between ca65 and asm6 from what ive read but cant even get either of them open. on windows 8 btw, can anybody help with getting one of these running or recommend something else all together? I know I sound ridiculous here when i cant even get the program to open but here we are lol. sorry if thats not very clear, I have a lot of questions and just trying to be brief. any help would be much appreciated.


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Assembler
PostPosted: Mon Apr 04, 2016 7:06 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
Welcome!

I've used Cross-32 (C32) originally from Universal Cross Assemblers, now distributed by Data Sync Engineering, and 2500AD which is now sold by Avocet Systems, plus the simple assembler that's part of the Forth kernel on my 65c02 workbench computer, which I wrote myself. I have never used one of the free assemblers. You can find a ton of them in the assemblers portion of the links page on my website though.

The C32 assembler, at $99, is not free, but a nice thing about it is that you buy one assembler that does lots of different processors. It's a darn good macro assembler too. Whether free or not, I recommend getting a good macro assembler that will do at least the CMOS 65c02 instructions. A couple of our own members here have written assemblers that have structure capability built in so you can have that without having to add the macros to do it (although I show how, here and here). One is Andrew Jacobs ("BitWise") with his As65 assembler, and one is Anton Treuenfels with his HXA 6502 assembler.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Assembler
PostPosted: Mon Apr 04, 2016 7:14 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Indeed, welcome! For the rudiments of 6502 assembly language, I recommend easy6502 which is an online tutorial. For NES development, there's a lot more to know - perhaps start with
http://wiki.nesdev.com/w/index.php/Programming_guide
or something similar.

Much later edit: Because it's relevant to the topic title, and this topic might be found in searches, I'd like to mention also BeebAsm which is a BBC Micro-centric structured assembler.
Quote:
BeebAsm is a 6502 assembler designed specially for developing assembler programs for the BBC Micro. It uses syntax reminiscent of BBC BASIC's built-in assembler, and is able to output its object code directly into emulator-ready DFS disc images.


Last edited by BigEd on Mon Feb 06, 2017 9:38 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Assembler
PostPosted: Mon Apr 04, 2016 10:04 pm 
Offline

Joined: Mon Apr 04, 2016 2:34 pm
Posts: 10
In your opinion do you think its worth getting cross 32? what does it do differently from the free assemblers? if so I probably will get it in a month or so but I would like to try one of the other two you mentioned but again they wont open, the command prompt box thing flashes for a second then closes. cant be certain but I think it says something like no input files, any idea what it could be? im on windows 8 and thinking it could be something like that but were talking like 8 or 9 different assemblers have done the same thing. and that tutorial on easy6502 looks like a great place to start! thanks much appreciated guys


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Assembler
PostPosted: Mon Apr 04, 2016 11:32 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
I like C32, but I know there are other good assemblers, undoubtedly including some free ones. The 2500AD assembler I used in the 80's was great too, but I would recommend against it at this point, because of the super high price and that Avocet apparently gives little or no support—just the software and manuals on CD ROM. Again, one of the nice things about C32 is that you can buy one assembler for $99 and be able to assemble for dozens of different processors, and in fact if you come up with your own processor design and instruction set, you can make the tables for this assembler to work for it. I don't know of any other assemblers that can make that claim. I've found a couple of little bugs in C32, but then, as an intensive user, I find bugs in everything. Most users probably won't catch them, and they may have been fixed since I got my copy many years ago anyway. I use it under DOS, with batch files to eliminate the command-line typing. I never had any trouble with it installing or running.

I must recommend the outstanding 6502/65816 programmer's manual "Programming the 65816-Including the 6502, 65C02 and 65802," by Eyes & Liechty, from Western Design Center. Note: There were many problems with the earlier .pdf version that were not in the original paper manual; but in late March 2015, WDC scanned and OCR'ed the paper manual and now supplies the new, repaired .pdf. If you're just starting out, I might also recommend that you go for the CMOS 65c02 right away, in your hardware (if you're building your own), manuals, and any software tools, and don't waste your time with the more limited NMOS 6502 unless you specifically want to program for Commodore 64 or other vintage computer that used a version that was never available in CMOS. (The C64 used the 6510, which is a 6502 with an onboard port used for managing memory.) There are major benefits to the CMOS version, including more instructions and addressing modes. Edit, 4/7/16: Since you mention NES and SNES below, I just looked them up on Wikipedia. It appears that the early ones had the NMOS 6502, and later ones used the '816, but I don't see any mention of the 65c02 in between.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Assembler
PostPosted: Tue Apr 05, 2016 3:07 am 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1949
Location: Sacramento, CA, USA
GARTHWILSON wrote:
... Again, one of the nice things about C32 is that you can buy one assembler for $99 and be able to assemble for dozens of different processors, and in fact if you come up with your own processor design and instruction set, you can make the tables for this assembler to work for it. I don't know of any other assemblers that can make that claim ...

San Bergman's sbasm can be extended with cross overlays to assemble for almost any binary (2's complement, 32-bit or narrower) microprocessor, but you have to know Python to do it in version 3, and version 2 only runs in a DOS box. San has already provided dozens of overlays for you to use ... no Python knowledge required:

http://www.sbprojects.net/sbasm/crosses.php

San is a very smart and friendly guy, and I have enjoyed using his free version 2 and trading a couple of e-mails with him. I haven't completely explored his (also free) version 3 yet, but I predict that I won't be disappointed when I finally do:

http://www.sbprojects.net/sbasm/index.php

Mike B.


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Assembler
PostPosted: Tue Apr 05, 2016 7:28 am 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
I think there are a few NES specific assemblers that generate the file header needed to identify the type of cartridge memory mapper being used. A standard 6502 assembler won't generate that part of the file.

Are you writing for an emulator or real hardware?

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Assembler
PostPosted: Tue Apr 05, 2016 7:58 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Disgruntled0wll wrote:
... they wont open, the command prompt box thing flashes for a second then closes.

What might be happening here is that you're launching a command-line program as if it were a GUI program. If instead you start a windows command line and invoke the program from that (by typing) it might work out better. (If windows-key+R puts up a launching dialog, then CMD or COMMAND might well start a command line window. At the C> prompt you'll need to CD to your working directory and then launch the tool by typing the full path. I don't have a windows machine to help me with this... I hope you can work it out.)


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Assembler
PostPosted: Tue Apr 05, 2016 9:14 am 
Offline

Joined: Mon Apr 04, 2016 2:34 pm
Posts: 10
BigEd wrote:
What might be happening here is that you're launching a command-line program as if it were a GUI program. If instead you start a windows command line and invoke the program from that (by typing) it might work out better.

Thats exactly what it was lol, thanks.

BitWise wrote:
Are you writing for an emulator or real hardware?

Was wanting to make it for real hardware but test it in an emulator

barrym95838 wrote:
San Bergman's sbasm can be extended with cross overlays to assemble for almost any binary (2's complement, 32-bit or narrower) microprocessor, but you have to know Python to do it in version 3, and version 2 only runs in a DOS box. San has already provided dozens of overlays for you to use ... no Python knowledge required:

http://www.sbprojects.net/sbasm/crosses.php

I could only find the apple computer cross, where would the nes one be?

GARTHWILSON wrote:

I must recommend the outstanding 6502/65816 programmer's manual "Programming the 65816-Including the 6502, 65C02 and 65802," by Eyes & Liechty, from Western Design Center. Note: There were many problems with the earlier .pdf version that were not in the original paper manual; but in late March 2015, WDC scanned and OCR'ed the paper manual and now supplies the new, repaired .pdf. If you're just starting out, I might also recommend that you go for the CMOS 65c02 right away, in your hardware (if you're building your own), manuals, and any software tools, and don't waste your time with the more limited NMOS 6502 unless you specifically want to program for Commodore 64 or other vintage computer that used a version that was never available in CMOS. (The C64 used the 6510, which is a 6502 with an onboard port used for managing memory.) There are major benefits to the CMOS version, including more instructions and addressing modes.

I dont know if ive misunderstood this but I feel like I should explain. I am really wanting to make snes games but information from various sites suggested learning 6502 assembly for nes games before moving onto snes games as it would be easier. Am I doing the right thing here by starting with 6502 then moving onto 65816 or should I just go straight into 65816 assembly? again thanks for the help sorry if i'm whirlwinding you guys here lol


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Assembler
PostPosted: Tue Apr 05, 2016 9:50 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
I'd recommend taking it in stages - easy6502 for the assembly language, for getting a hang of the registers, the flags, the addressing modes, and also for a very simple model of I/O. Then, well, quite possibly the NES next would be a good idea. There's every chance that it's a simpler environment to program for. Allow me to indulge a habit by quoting Thomson's Rule for First-Time Telescope Makers: "It is faster to make a four-inch mirror then a six-inch mirror than to make a six-inch mirror"


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Assembler
PostPosted: Tue Apr 05, 2016 11:03 am 
Offline

Joined: Mon Apr 04, 2016 2:34 pm
Posts: 10
Haha yeah will do thanks man


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Assembler
PostPosted: Tue Apr 05, 2016 7:14 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
Yes, I would second that. Learn on the simpler one first. Actually, you can use an '816 as if it were an '02 to begin, just ignoring the extra capabilities; but that would only be if that's the hardware you have. When you move from the NMOS instruction set to the CMOS, you will find it is refreshing that certain programming problems are more easily solved. It will happen again when you go from the CMOS 6502 (65c02) to the 65816.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Assembler
PostPosted: Tue Apr 05, 2016 9:03 pm 
Offline

Joined: Sun Apr 03, 2016 10:51 pm
Posts: 16
Location: Calgary, Canada
There's also the solution of rolling your own assembler for 6502, which may have advantages. Assembling 6502 doesn't require many resouces, and even dynamic languages like Python, Ruby, Perl, and .NET are more than capable. Furthermore, you could easily download a 6502 assembler already built in one of these languages and update the code to make creating NES specific machine code easier, such as building out the banked memory, building spritesheets, etc... There are plenty of advantages in rolling out your own 6502 assembler.

I recently created my own 6502 assembler, and it's about 150 lines of code or so, it's made in Python and uses a OP_CODE table and a regular expression table to make the code very compact, I compared the generated machiine code with code generated by the nicely made http://6502asm.com/ assembler and simulator to confirm my assembly was working correctly.

I also created a 6502 emulator/VM, but that is much much more work, as you need to handle all the op_codes, and make sure that your code executes them reliably. But, I am proud to say, that my implementation here also works nice, it uses a nice class system, and each op-code is coded as a class method... eg:
Code:
class CPU(object):
  def op_0x0c(self):
    p = self.fetch()
    ...
  def run():
    while self.running:
      op = hex(self.fetch())
      try:
        getattr(self, 'op_%s' % op)()
      except:
        ...


This is just some example code I wrote off the top of my head, but shows the basic priniple of how I wrote the emulator code. It makes the code very readable and easy to locate specific op codes, if there are any weird runtime issues. I love Python for doing this sort of introspection on objects. :)

I have a more primitive assembler/VM for a fiction processor on my bitbucket here: https://bitbucket.org/kveroneau/simple-cpu
I also have a very very basic assember/VM for a learning tool called a CARDIAC here: https://bitbucket.org/kveroneau/pythone ... at=default
More info on a CARDIAC: https://www.cs.drexel.edu/~bls96/museum/cardiac.html

In fact, I highly recommend checking out the CARDIAC, as it's a great teaching tool for understanding how microprocessors fundamentally work.


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Assembler
PostPosted: Thu Apr 07, 2016 7:07 pm 
Offline

Joined: Mon Apr 04, 2016 2:34 pm
Posts: 10
kveroneau wrote:
There's also the solution of rolling your own assembler for 6502, which may have advantages.
I've never done anything like that before would it be better to find an assembler specifically intended for NES programming or learn to make my own?


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Assembler
PostPosted: Fri Apr 08, 2016 8:05 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Disgruntled0wll wrote:
kveroneau wrote:
There's also the solution of rolling your own assembler for 6502, which may have advantages.
I've never done anything like that before would it be better to find an assembler specifically intended for NES programming or learn to make my own?

It would certainly be better to use a tool which the NES community use, if your objective is to write NES code.

Of course, writing an assembler is a valid software project, and several people here have done it, but it's by no means the best way to start writing code in assembly.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 8 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: