Canite wrote:
Oh wow, nice catch haha. I didn't even think about that, would've been nicer if it said "Not indented" instead
That would be nicer, but it actually makes less sense when you look at how nesasm works. See below.
3gengames wrote:
Huh? You don't have to indent in NESASM to my knowledge, but I always put 2 spaces before instructions.
As far as I know, any number of spaces or tabs before actual code starts on a line is called indenting in programming. So two spaces before an instruction is indenting.
This code is valid is nesasm:
Code:
lda:;A label
lda lda
This code is valid in nesasm:
Code:
lda;a label doesn't need a colon in nesasm
lda lda;load the value stored at this label
This code is valid in nesasm:
Code:
lda lda lda
All the code above does the exact same thing. So this is what happens when you don't indent an instruction in nesasm.
Code:
STA pointer+1
Is interpreted the same way as:
Code:
STA:
pointer+1
So STA is a label. Pointer+1 is an unknown instruction. That's why it gives "unknown instruction" as an error, and rightly so. One could make the argument that nesasm should reserve the keywords used for an instruction, but as the program is now, an indentation error doesn't make sense. Another solution would be to make the program only accept labels that terminate with a colon, but this would likely not be backwards compatible with some code.
The ability to place an instruction on the same line as a label is actually extremely useful. We indent so the assembler knows the difference between labels and instructions.
Edit: I found something even MORE interesting. At first I thought, "Oh, wait. You should have actually encountered a 'label multiply defined' error if what I said was true." BUT... nesasm actually doesn't give an error for a label defined twice if it points to the same location.
Code:
Pointer:
Pointer:
gives no errors.
Code:
Pointer:
lda #$00;or any other random instruction
Pointer:
gives "label multiply defined".
Since an unknown instruction doesn't increment nesasm's internal counter (after all, how many bytes would it know to increment by?), a string of not indented code just means that all the labels point to the same location, so no "label multiply defined". That's fascinating to me. Even if this behavior were changed, (And I can actually think of a few good uses for this behavior) it would only give you "label multiply defined" if you used the same instruction not indented more than once.
To bring this back on topic, the fact that all your instructions are assembled to the same location ($E000) is the clue that you forgot to indent.