Beginner Errors

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
User avatar
nathanpc
Posts: 35
Joined: Fri Mar 12, 2010 4:55 pm
Location: Brazil
Contact:

Beginner Errors

Post by nathanpc »

Hello,
As you can see on my signature, I'm a very experienced Assembly developer, but as every beginner on a Assembly language, we can do some mistakes, then I've written this to test if the compiler works(nesasm):

Code: Select all

.bank 0
.org $8000

ldx #$01
stx #200
But when I was compiling I've got some errors:

Code: Select all

ubuntu@eeepc-laptop:~/dev/nes-learning$ nesasm test.asm
NES Assembler (v3.01)

pass 1
#[1]   test.asm
    1  00:E000            .bank  0
       Local symbol not allowed here!
    2  00:E000            .org $8000
       Local symbol not allowed here!
    4  00:E000            ldx #$01
       Unknown instruction!
    5  00:E000            stx $200
       Unknown instruction!
# 4 error(s)
ubuntu@eeepc-laptop:~/Desktop/nesasmsrc/nesasmsrc/source$
Someone can help me?

Best Regards,
Nathan Paulino Campos
MIPS, x86 and ARM Assembly Developer

Learning 6502 ;)
User avatar
Dwedit
Posts: 4470
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit »

I think the lines may need to be indented.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

What Dwedit means is that some assemblers require a space at the start of the line before every instruction, so as not to confuse labels with instructions.

You can't store immediate ('stx #'); that operation makes no sense.
User avatar
nathanpc
Posts: 35
Joined: Fri Mar 12, 2010 4:55 pm
Location: Brazil
Contact:

Post by nathanpc »

Now when I emulate the ROM file on nesterJ I got a saying this:

Code: Select all

Error Reading ROM Banks
What I need to do?

PS: Nice to see you here too Dwedit, also tepples I think I already saw you on other forum... Did you remember me?
MIPS, x86 and ARM Assembly Developer

Learning 6502 ;)
User avatar
koitsu
Posts: 4203
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Post by koitsu »

You probably need to tell the assembler to set up the iNES header (first 16 bytes of the ROM file) properly when generating the .ROM file, or you get to make one yourself.

Also, why are you using nesterJ? Good grief. Use Nestopia or Nintendulator.
User avatar
nathanpc
Posts: 35
Joined: Fri Mar 12, 2010 4:55 pm
Location: Brazil
Contact:

Post by nathanpc »

Now my code is like this and I still got the same error:

Code: Select all

  .inesprg 1
  .inesmap 0
  .inesmir 0
  .ineschr 0

  .bank  0
  .org $8000

  LDX #$01
  STX $200
Also, I'm going to download another emulator as your suggestion. :)
MIPS, x86 and ARM Assembly Developer

Learning 6502 ;)
User avatar
koitsu
Posts: 4203
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Post by koitsu »

Okay, so you're using mapper 0, which requires at least 1 PRG bank (16KBytes in size) and one CHR bank (8KBytes in size):

http://wiki.nesdev.com/w/index.php/NROM (be sure to see the bottom of the page too).

Yet, in your directives you're stating 0 CHR banks, which obviously won't work.

If you're not using any CHR data, then you should append an 8192 byte file of zeros that represents your CHR bank and use .ineschr 1.

You should also consider not using NESASM. Try asm6 instead. ;-)
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

koitsu wrote:You should also consider not using NESASM. Try asm6 instead. ;-)
If you are interested, I just posted a couple of ASM6 templates you can use.
Drag
Posts: 1350
Joined: Mon Sep 27, 2004 2:57 pm
Contact:

Post by Drag »

koitsu wrote:Okay, so you're using mapper 0, which requires at least 1 PRG bank (16KBytes in size) and one CHR bank (8KBytes in size):

http://wiki.nesdev.com/w/index.php/NROM (be sure to see the bottom of the page too).

Yet, in your directives you're stating 0 CHR banks, which obviously won't work.

If you're not using any CHR data, then you should append an 8192 byte file of zeros that represents your CHR bank and use .ineschr 1.

You should also consider not using NESASM. Try asm6 instead. ;-)
I thought setting 0 CHR banks was just how you specify that you're using CHR-RAM rather than CHR-ROM.
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

Technically you could have a cart with no mapper (mapper 0) and CHR-RAM, but since Nintendo never manufactured one of those, some emulators will refuse to run ROMs with that configuration, which is wrong IMO. If you want to keep it simple and use CHR-RAM maybe you should try UNROM (mapper 2). Some emulators will complain if you have less than 8 banks (128KB), but some will accept 2 or 4.
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

tokumaru wrote:Technically you could have a cart with no mapper (mapper 0) and CHR-RAM, but since Nintendo never manufactured one of those, some emulators will refuse to run ROMs with that configuration
Nintendo never manufactured a game with the Color Dreams or Camerica mapper, instead preferring GNROM or UNROM, yet emulators take them just fine ;-)

(By "Nintendo" you meant "makers of commercial games".)
If you want to keep it simple and use CHR-RAM maybe you should try UNROM (mapper 2).
That would work for 16 KiB PRG. But once you go up to 32 KiB PRG, executing from $8000-$BFFF before setting up the mapper results in undefined behavior. There are two solutions: either make sure your entry point is in $C000-$FFFF and initializes the mapper, or switch to BNROM (mapper 34) or CPROM (mapper 13).
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

tepples wrote:That would work for 16 KiB PRG. But once you go up to 32 KiB PRG, executing from $8000-$BFFF before setting up the mapper results in undefined behavior.
I didn't mean he could simply change the mapper number, of course he'd have to put the reset code above $C000 and properly map the first bank to $8000-$BFFF if using 32KB of PRG-ROM, something that would take 2 lines of code.
Post Reply