nesdev.com
http://forums.nesdev.com/

What program to use to make Assembly?
http://forums.nesdev.com/viewtopic.php?f=2&t=16094
Page 1 of 2

Author:  MartsINY [ Wed Jun 14, 2017 5:40 pm ]
Post subject:  What program to use to make Assembly?

I'm making assembly code for 6502 that I compile for ASM6.

Is there a program to write this so it is easy to read and is there a proposed structure?

I'm just making it in .txt file, I don't know what kind of structure I should have for when it will become too big... what tools I could use.

Author:  rainwarrior [ Wed Jun 14, 2017 5:46 pm ]
Post subject:  Re: What program to use to make Assembly?

There are several text editors for which you can use 6502 assembly formatting templates.

I use Notepad++ myself, but there's lots of others (Scintilla, etc.)

The usual filename extension is either .s or .asm I think, but what you want to name the files is really up to you.

Author:  MartsINY [ Wed Jun 14, 2017 6:09 pm ]
Post subject:  Re: What program to use to make Assembly?

thanks!!

is there an example of a full game I'd like to see how to structure a document?

Author:  dougeff [ Wed Jun 14, 2017 6:16 pm ]
Post subject:  Re: What program to use to make Assembly?

Code Structure -

You will probably make level specific files. Let's say you make a game with 15 mazes. Each maze will be stored ina separate file. Then 1 big file with shared code, possibly more if it gets too big.

Then music files might be 3 files.
-music engine
-music data
-sound effects data

Then each unique nametable will be a separate file (compressed)...
-title screen
-options screen
-in game screens
-victory screen / end credits

Then, if you are using asm6 or nesasm, a master file that links all these together, with include and incbin statements.

If you are using ca65, then the linker / config file will link them all together.

I also like a separate header file to keep all my variable definitions, and define statements.

Edit - and a file with your CHR ROM (graphics).

Author:  tokumaru [ Wed Jun 14, 2017 7:00 pm ]
Post subject:  Re: What program to use to make Assembly?

I think everyone structures their programs and files differently, since assembly gives us much more freedom than any other kind of programming.

I personally like to have a master file that includes everything else at the correct places. First, I have a handful of declaration files for the different modules of my programs (input, audio, graphics, gameplay, etc.) which contain all the constants, variables and macros for each module. Then comes the NES header, which I build using macros from the "header" module. Next in the main file are the actual PRG and CHR banks, with all the .ORGs, .BASEs, . SEGMENTs and whatever else is necessary to structure a valid ROM file, and inside the banks I include all the all functions, tables, tiles, etc. where I want them to be. Even the interrupt vectors are treated as a regular data table.

You do have to be careful when the same code/data must appear multiple times in the ROM (such as when you're simulating a hardwired PRG bank in a mapper that doesn't have one) to avoid "duplicate label" errors. What I do in ASM6 is declare the global label of a function/table/whatever like DrawSprites = * instead of DrawSprites:, and below that I only use temporary labels. In ca65 I scope everything and only create global symbols for things that aren't defined yet. Either way you have to be extra careful to include the thing at the exact same address every time (you can write code to detect screw ups, though).

I guess this is it... I try to mimic some of the features of high level languages and I have strict consistent ways of declaring everything, in order to make things more organized and easier to debug.

You have to find the structure you're most comfortable working with, and you'll probably be changing little things from protect to project as you progressively see what works and what doesn't for you. I'm still tweaking my "formula" every now and then.

Edit: Oh, and for writing code I use Notepad++ with 6502 syntax highlighting. To build the project I have a batch file I can double click that builds the .nes file and automatically opens it in an emulator.

Author:  tepples [ Wed Jun 14, 2017 8:21 pm ]
Post subject:  Re: What program to use to make Assembly?

I use ca65 instead of ASM6, but there are several NES-related repositories in my GitHub account.

Author:  Oziphantom [ Wed Jun 14, 2017 10:32 pm ]
Post subject:  Re: What program to use to make Assembly?

I use .asm and Reluached64 as it gives me auto-completion, and quick browsing of sections, labels etc. It has a few built in assembler formats, one of them might be compatible enough with ASM6.

Since it only offers auto complete for a single file, I tend to make giant monolithic asm files, but sections and code folding make it not so bad.

Author:  rikami [ Wed Jun 14, 2017 11:13 pm ]
Post subject:  Re: What program to use to make Assembly?

Being a Java programmer I found using this IDE works best for me - http://www.wudsn.com/index.php/ide
It has asm6 support.
Also it compiles the code and starts your chosen NES emulator with your program in 1 step.

Maybe I'm just too lazy :D

Author:  MartsINY [ Thu Jun 15, 2017 5:01 pm ]
Post subject:  Re: What program to use to make Assembly?

thanks to all for the reply, really helps me!!

If someone has a simple example of using more than one file with ASM6, I'd be curious to see it

Author:  HihiDanni [ Sat Jun 17, 2017 4:35 pm ]
Post subject:  Re: What program to use to make Assembly?

Generally, for a project that has multiple files (which should be anything larger than a "hello world" program), you'll run the assembler on each file separately to generate the object files. Then, you combine those object files together using your linker program. Typically the linker will have the configuration for how to lay everything out in memory. Each separately assembled file has code but no real physical location. The linker determines where in the output file everything should go, and then ties everything together.

If you have any files that are included directly in other assembly sources, you should not run the assembler on those files separately. This is because using the "include" directive will directly insert the contents into the source at assemble time, so they do not need to be linked together.

Usage will probably look something like this:

Code:
myassembler main.asm -o main.o
myassembler title.asm -o title.o
mylinker -o mygame.nes main.o title.o

I don't know ASM6 specifics (I do SNES with ca65), but I imagine the same concepts apply there as well.

Author:  tokumaru [ Sat Jun 17, 2017 8:36 pm ]
Post subject:  Re: What program to use to make Assembly?

ASM6 doesn't ​work like that. You can only use multiple files using .include, as a way to make the source code more organized than a huge ASM file with everything. Ultimately, it's as if ASM6 concatenated all the included files to create a huge ASM file before assembling.

Author:  HihiDanni [ Sun Jun 18, 2017 6:29 am ]
Post subject:  Re: What program to use to make Assembly?

Ah, so it's how my project used to be structured. Be careful on the order of your includes, as you will likely need to introduce symbols before they are used, and try to avoid creating circular dependencies too (file A needs something from file B needs something from file A).

Author:  nicklausw [ Sun Jun 18, 2017 8:24 am ]
Post subject:  Re: What program to use to make Assembly?

In terms of text editors, I recommend Visual Studio Code or atom. I haven't been able to figure out how to make syntax highlighting for VS Code, but it's already there for Atom. Both of them have an integrated terminal which is very useful.

With code structure, the way my most recent project has things structured is single-module and three files: nes.s is hardware defines and functions, game.s is software defines and functions, main.s is the NES "frontend" (NMI and reset vectors and stuff) and it's what is actually given to the assembler.

HihiDanni wrote:
Be careful on the order of your includes, as you will likely need to introduce symbols before they are used

asm6 is a however-many pass assembler, so it doesn't have problems with forward-references.

Author:  rainwarrior [ Sun Jun 18, 2017 10:01 am ]
Post subject:  Re: What program to use to make Assembly?

nicklausw wrote:
HihiDanni wrote:
Be careful on the order of your includes, as you will likely need to introduce symbols before they are used

asm6 is a however-many pass assembler, so it doesn't have problems with forward-references.

I think the only difference this makes in ca65 is with allocations on the zero-page.

If they aren't defined above where they are used, the assembler has to assume 16-bit addressing and you lose the zero-page advantage. Basically just keep your ZP .res stuff at the top of the file and you're fine.

Otherwise, I don't believe it makes a difference. It's a "one-pass" assemble, but it does fill in forward references (unlike C, which requires forward declarations to even compile).

Author:  HihiDanni [ Sun Jun 18, 2017 10:24 am ]
Post subject:  Re: What program to use to make Assembly?

rainwarrior wrote:
It's a "one-pass" assemble, but it does fill in forward references (unlike C, which requires forward declarations to even compile).

Yet another bullet point on the list of reasons why C is not a good language. When even assemblers do a better job at this...

Page 1 of 2 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/