assemblers hate me

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
Six
Posts: 10
Joined: Wed Jul 10, 2013 3:27 pm

assemblers hate me

Post by Six »

I've always been interested in NES development. Around last year, I learned about 6502 assembly language, and all the homebrew games people have made. I wanted to try and make my own.

However, no assemblers seem to work. The same thing always happens. It shows the command prompt for a split second, and then it disappears. Nothing happens after that.

Are there any 6502 assemblers that actually work? Or am I just doing something wrong?
CrowleyBluegrass
Posts: 42
Joined: Sun Jun 30, 2013 7:59 am

Re: assemblers hate me

Post by CrowleyBluegrass »

Forgive me for making assumptions, but are you expecting the assembler to open into some kind of workspace environment? I believe Nesicide is that sort of deal, but I've never used it myself.

To work most other assemblers, you write your code in a text processing program (I use ConTEXT, but even notepad will work) and give it the .asm extension. When you want to assemble your code, you usually access the assembler via command prompt, for example with ASM6:

Code: Select all

Command line
--------------------------------------------------------------
Usage:
         asm6 [-options] sourcefile [outputfile]
Or you can do it the "easier" way (who likes using CMD nowadays right?) you can create a batch file which does this for you. Once again for ASM6 the batch file would contain

Code: Select all

asm6 yourfile.asm output.nes
with yourfile.asm being your code and output.nes being the name of the outputted .nes file, of course. This correlates with what you would otherwise type into command prompt.

If my assumptions are wrong (in which case I apologize) then the reason your code is not outputting a .nes file is because there are errors in it. In some instances CMD will close instantly, without giving you the opportunity to see any errors that were reported. In that case, I suggest you download ConTEXT and setup the macros which allow you to assemble within the program, thereby allowing you to see any problems that may have occurred in assembling your code. If you go this page viewtopic.php?t=3783 and scroll down there's a tutorial on how to do this. I'm not sure which assemblers it works with exactly, but I did everything as described in the above thread and it worked fine for ASM6.

Good luck!
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: assemblers hate me

Post by tokumaru »

People these days are used to double-clicking programs expecting some sort of graphical interface to show up. Well, in the old days, a lot of programs didn't have graphical interfaces, and even today, a lot of programs simply don't need one. An assembler is a simple program to interface with: you give it a text file containing source code and it spits out a binary ROM... do you really need a graphical interface for that? The answer is no.

You either have to use the command line or a batch file, in order to call the program with text commands instead of mouse clicks. The simpler assemblers (ASM6, NESASM, etc.) only require the name of the text file containing the source code in order to produce a binary file (and optionally, the name of the output file). In this case, the simplest solution is the following:

1- create a new folder;
2- put asm6.exe in that folder;
3- put your source code (for example, game.asm) in that folder;
4- create a new text file in this folder called assemble.bat; (make sure there's no .txt in the end)
5- write this inside that file and save: asm6 game.asm game.nes
6- double-click the assemble.bat file and you should get a game.nes file as a result.

If you there's no game.nes file after double-clicking assemble.bat, there were probably errors in your source code. In order to be able to see the error, add a pause command to your assemble.bat file (just type "pause", no quotes in the second line). This will prevent the window from immediately closing, so you have time to see the errors reported by the assembler.
Six
Posts: 10
Joined: Wed Jul 10, 2013 3:27 pm

Re: assemblers hate me

Post by Six »

CrowleyBluegrass wrote:Forgive me for making assumptions, but are you expecting the assembler to open into some kind of workspace environment? I believe Nesicide is that sort of deal, but I've never used it myself.

To work most other assemblers, you write your code in a text processing program (I use ConTEXT, but even notepad will work) and give it the .asm extension. When you want to assemble your code, you usually access the assembler via command prompt, for example with ASM6:

Code: Select all

Command line
--------------------------------------------------------------
Usage:
         asm6 [-options] sourcefile [outputfile]
Or you can do it the "easier" way (who likes using CMD nowadays right?) you can create a batch file which does this for you. Once again for ASM6 the batch file would contain

Code: Select all

asm6 yourfile.asm output.nes
with yourfile.asm being your code and output.nes being the name of the outputted .nes file, of course. This correlates with what you would otherwise type into command prompt.

If my assumptions are wrong (in which case I apologize) then the reason your code is not outputting a .nes file is because there are errors in it. In some instances CMD will close instantly, without giving you the opportunity to see any errors that were reported. In that case, I suggest you download ConTEXT and setup the macros which allow you to assemble within the program, thereby allowing you to see any problems that may have occurred in assembling your code. If you go this page viewtopic.php?t=3783 and scroll down there's a tutorial on how to do this. I'm not sure which assemblers it works with exactly, but I did everything as described in the above thread and it worked fine for ASM6.

Good luck!
I can't find a place to download Nesicide. It looks awesome, but all the download links seem to be removed. I'll try running it from a batch file tomorrow (I have notepad and notepad++, if that works)
tokumaru wrote:People these days are used to double-clicking programs expecting some sort of graphical interface to show up. Well, in the old days, a lot of programs didn't have graphical interfaces, and even today, a lot of programs simply don't need one. An assembler is a simple program to interface with: you give it a text file containing source code and it spits out a binary ROM... do you really need a graphical interface for that? The answer is no.

You either have to use the command line or a batch file, in order to call the program with text commands instead of mouse clicks. The simpler assemblers (ASM6, NESASM, etc.) only require the name of the text file containing the source code in order to produce a binary file (and optionally, the name of the output file). In this case, the simplest solution is the following:

1- create a new folder;
2- put asm6.exe in that folder;
3- put your source code (for example, game.asm) in that folder;
4- create a new text file in this folder called assemble.bat; (make sure there's no .txt in the end)
5- write this inside that file and save: asm6 game.asm game.nes
6- double-click the assemble.bat file and you should get a game.nes file as a result.

If you there's no game.nes file after double-clicking assemble.bat, there were probably errors in your source code. In order to be able to see the error, add a pause command to your assemble.bat file (just type "pause", no quotes in the second line). This will prevent the window from immediately closing, so you have time to see the errors reported by the assembler.
I don't expect Graphical User Interface, but I expect it to at least run. It shows up for a quick second, and then the program ends.
User avatar
Kasumi
Posts: 1293
Joined: Wed Apr 02, 2008 2:09 pm

Re: assemblers hate me

Post by Kasumi »

Six wrote:I don't expect Graphical User Interface, but I expect it to at least run. It shows up for a quick second, and then the program ends.
That means it ran. And it's working as intended. Set up a .bat like Tokumaru suggested, though.
User avatar
Sanchezman
Posts: 14
Joined: Fri Jun 28, 2013 11:15 pm

Re: assemblers hate me

Post by Sanchezman »

Six wrote:I have notepad and notepad++, if that works
Notepad++ has a neat little command line plugin that I use to compile called nppexec. You can find it in the plugin manager, and install it from there. Then, put asm6.exe in the same folder that has your code. Press F6, and a little script editor will pop up that allows you to determine what nppexec will run in the command line. I use:

Code: Select all

cd $(CURRENT_DIRECTORY)
ASM6 $(FILE_NAME) "$(NAME_PART).nes"
What it does it:
1. Go to the current folder
2. Run ASM6. Have it compile our file (eg. game.asm) to a .nes (game.nes)

You can then save that script and can run it whenever you want to compile by pressing F6, and then "OK". A little area will open up on the bottom of notepad++ and will give you the compiler's outputs (like telling you if there was a mistake on line 1147, or that everything is fine).
Why are they called urine cakes if you're NOT supposed to eat them?
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: assemblers hate me

Post by tokumaru »

Six wrote:I don't expect Graphical User Interface, but I expect it to at least run. It shows up for a quick second, and then the program ends.
It did run, but since you didn't give it a source code file to work with it just terminated without doing anything. If you set up the batch file to give the assembler something to work with (the .asm file), and pause afterwards, the window will not close after a split second and you'll be able to see the results. If you haven't configured Windows to always display file extensions yet, I suggest you do it now. It's really annoying when you're working with these less common file types (asm, bat, etc.) and Windows and/or notepad keep adding .txt at the end of the file names and hiding this from you.
Six
Posts: 10
Joined: Wed Jul 10, 2013 3:27 pm

Re: assemblers hate me

Post by Six »

Wow.

Alright, I'll try setting up a batch file when I get a chance. Thanks for your help.

Edit: It works. Finally
User avatar
koitsu
Posts: 4203
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: assemblers hate me

Post by koitsu »

Probably worth reading as well, BTW -- guides on getting familiar with the Windows command prompt (command line) interface known as cmd.exe (but colloquially referred to as "command prompt" or "DOS prompt" from ye olden days):

http://windows.microsoft.com/is-IS/wind ... -questions
http://www.bleepingcomputer.com/tutoria ... roduction/
http://www.cs.princeton.edu/courses/arc ... rompt.html

HTH, and at least makes you feel less queasy. :-)
Post Reply