NESASM: Best version? And directive questions!

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
SleepySheep
Posts: 9
Joined: Thu Jan 26, 2023 5:28 pm

NESASM: Best version? And directive questions!

Post by SleepySheep »

Hello all,
I am trying to assemble the demo for FamiStudio, but it is failing for reasons I don't understand. To that end, I am trying to better understand NESASM and its directives. So I have some questions.

1. Is there an accepted "Latest and Greatest" version of NESASM out there that I should definitely be using? I have a version claiming to be v3.1, but I can't remember where I found it. Doing a google search for NESASM reveals a dozen different forks on Github, and I don't know which one is most appropriate to use for contemporary tools like Famistudio.

2. I don't completely understand the .ZP and .BSS directives, which are mentioned in Famistudio config. Is calling '.ZP' equivalent of calling '.rsset $0000'? If so, what is the purpose of .ZP? If not, what is the difference between the two?
Last edited by SleepySheep on Sun Feb 19, 2023 12:25 pm, edited 1 time in total.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: NESASM: Best version? And directive questions!

Post by tokumaru »

Check if the size of the output file is correct. The first bank normally starts at address $8000, but since your first .org is setting the PC to $9000, you might be skipping $1000 (4096) bytes. Emulators can't properly load files when the PRG and CHR ROMs are not sized as real ROM chips or the sizes don't match what the iNES headers says.
SleepySheep
Posts: 9
Joined: Thu Jan 26, 2023 5:28 pm

Re: NESASM: Best version? And directive questions!

Post by SleepySheep »

Thanks Toku. I was actually editing my question while you were replying, after having figured a few things out. Primarily, that calls to .bank 1 and .bank 2 are not optional when creating a functional rom, even if you don't do anything *in* those banks. Incremental progress is being made in my understanding.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: NESASM: Best version? And directive questions!

Post by tokumaru »

This is actually my biggest gripe with NESASM... I can't stand these mandatory .bank directives.
SleepySheep
Posts: 9
Joined: Thu Jan 26, 2023 5:28 pm

Re: NESASM: Best version? And directive questions!

Post by SleepySheep »

This is the only assembler I've ever used, so I don't have much to compare it to. It's been pretty good to me so far, but the documentation could use some examples to back it up. I tried using the .bss command and it appears to do nothing, but I'm sure it has a function.

However, I just discovered that I have a mix of copies of NESASM.exe. Some are v3.0, and others are v3.1. So I made sure to assemble Famistudio's demo using 3.1, and what do you know, it works! I suspect v 3.0 has some kind of character limit on directive lines, among other differences.
User avatar
jeffythedragonslayer
Posts: 344
Joined: Thu Dec 09, 2021 12:29 pm

Re: NESASM: Best version? And directive questions!

Post by jeffythedragonslayer »

SleepySheep wrote: Sun Feb 19, 2023 2:22 pm This is the only assembler I've ever used, so I don't have much to compare it to. It's been pretty good to me so far, but the documentation could use some examples to back it up. I tried using the .bss command and it appears to do nothing, but I'm sure it has a function.
I suspect it does the same thing as https://cc65.github.io/doc/ca65.html#.BSS; you will find more info following the hyperlink to .SEGMENT
User avatar
jeffythedragonslayer
Posts: 344
Joined: Thu Dec 09, 2021 12:29 pm

Re: NESASM: Best version? And directive questions!

Post by jeffythedragonslayer »

BSS stands for "block starting symbol," and typically begins a section of uninitialized memory: https://en.wikipedia.org/wiki/.bss
SleepySheep
Posts: 9
Joined: Thu Jan 26, 2023 5:28 pm

Re: NESASM: Best version? And directive questions!

Post by SleepySheep »

Thanks for the reply. I think I understand that these directives (and segments in general) are used when linking multiple files that might not contain everything "inline". They also seem to serve a purpose for an external memory management program to deal with them. Does that sound right? So far I've only written simple, single-file programs, and those issues haven't really come up.
User avatar
jeffythedragonslayer
Posts: 344
Joined: Thu Dec 09, 2021 12:29 pm

Re: NESASM: Best version? And directive questions!

Post by jeffythedragonslayer »

SleepySheep wrote: Wed Feb 22, 2023 7:50 am Thanks for the reply. I think I understand that these directives (and segments in general) are used when linking multiple files that might not contain everything "inline". They also seem to serve a purpose for an external memory management program to deal with them. Does that sound right? So far I've only written simple, single-file programs, and those issues haven't really come up.
You don't have to create a new .asm file every time you switch segments. I've noticed it's a little more common for people to put all their source code in a single file with assembled languages than it is in C++ for example these days because assemblers are generally a lot faster.

When people talk about "inlining" things they're usually talking about avoiding the overhead of calling and returning from a subroutine.

I noticed NESASM spits out a .nes file directly and is not like other assemblers I'm used to which have a separate linker program, like ca65 has ld65, and WLA-DX has WLALINK. Both of those seems to have a lot more documentation than NESASM.
Post Reply