FAQ: Why won’t my game compile?

So, you’ve been hacking away at loads of assembly code to create the NES game of your life, only to be greeted with an error message when you’re ready to compile and run it. NESmaker can’t find your game.nes file. What’s wrong?

After compiling your game, you might be greeted with the following screen, which at first glance may seem like it’s not of great help:

Reading the error message actually hints you at what to do:

NESmaker can not find the game.nes file. This means that the compiler encountered errors. Please try compiling again and review the errors that are shown in the previous window. If you need help from the community, you might screenshot those errors.

Reading and fixing compiler errors

The “previous window” this message is referencing, is the white-on-black DOS-like screen, on which the actual compiling of the game takes place. Luckily, the compiler shows quite a lot of information about what went wrong, and where the error happens inside your code. For example, it might say the following:

This screen tells me three important things:

  1. The name of the file in which the error occurs: Routines\Moooooo\inputScripts\mooveLeft.asm
  2. The line number where the error occurs: line number 7
  3. The type of error that occurs: Unknown label

Opening the file mooveLeft.asm and looking at line number 7, the code does the following:

In my case, I tried to jump to a subroutine that doesn’t exist. It was a typo (Moooove instead of Mooooove) – fixing this resolved all my issues.

Common errors

Of course it’s hard to tell what exactly is wrong in your specific case. Here are the most common errors that occur, and what you might try to solve them.

Unknown label – you are trying to reference a variable, constant, subroutine or label that doesn’t exist in your code. This may be a typo, or perhaps you forgot to add a variable or constant in the NESmaker UI. Also, missing sound effects are a well known cause for this error.

Label already defined – You are using a named label in your code more than once. Either rename one of the labels and its reference points, or check if you didn’t accidentally import the same assembly file more than once.

Illegal instruction – You are trying to use an opcode that doesn’t exist. Check the 6502 assembly reference list to find the correct instruction.
If you’re getting more than a few Illegal instruction errors, your script files probably got corrupted. This usually happens when moving scripts cross-platform, i.e. from a Mac to a Windows PC.

Can’t open file – You are trying to include a file that does not exist. Check if the filename is correct. If you’re using a SCR_ constant to reference a file, check if the referenced file exists.
If you’re getting more than a few Can’t open file errors, you probably moved around a script folder on your hard drive. Move it back where it came from, or update all references to said folder in your scripts and settings.

PC out of range / Value out of range – One of your banks – most likely the static bank $1F or one of the graphics banks – has too much data. If it’s the static bank, try optimizing your code by moving code over to a different bank, removing code you don’t need or moving repeated code to a subroutine. If it’s the graphics, make sure your BMP files have the correct dimensions.

Branch out of range – You are trying to branch out to a location that’s unreachable from there. A branch instruction can only branch out a maximum of 127 compiled bytes down, or 128 bytes up in the code. Using a “reverse logic jump” construction will most likely fix this. So, instead of:

BEQ +
	ALotOfCodeHere
+

Try:

BNE +
	JMP ++
+
ALotOfCodeHere
++

Can’t determine address – You’re probably referencing a constant which is not defined in your script. Add the missing constant, or include the script containing these constants into your project settings, to fix these kind of errors.

Still got errors you can’t get rid of? Feel free to ask the community for help! Just remember to either copy-paste or screenshot the error message, and include it in your question.