What can I do when ld65 prompts a memory and configuration error? It just closes

202 views Asked by At

I'm using cc65 for developing my first NES game, among other tools. I created a raw code for a quick test for it in Assembly. managed to make an object of it but using ld65 as a linker, a message saying "memory and configuration error" and it just closes. This is the code I'm using:

.segment "HEADER"
.byte $4e, $45, $53, $1a, $02, $01, $00, $00
.segment "CODE"
.proc irq_handler
  RTI
.endproc
.proc nmi_handler
RTI
.endproc
.proc reset_handler
  SEI
  CLD
  LDX #$00
  STX $2000
  STX $2001
vblankwait:
  BIT $2002
  BPL vblankwait
  JMP main
.endproc
.proc main
  LDX $2002
  LDX #$3f
  STX $2006
  LDX #$00
  STX $2006
  LDA #$29
  STA $2007
  LDA #%00011110
  STA $2001
forever:
  JMP forever
  .endproc
  .segment "VECTORS"
  .addr nmi_handler, reset_handler, irq_handler
  .segment "CHARS"
  .res 8192
  .segment "STARTUP"

Does anyone have any ideas of what's wrong with it?

1

There are 1 answers

0
AudioBubble On

The problem is not in your assembly code, but with what you are giving the linker.

The linker's job is to take your object files and lay out their data according to a memory configuration.

You can choose a pre-existing platform configuration with -t, e.g. -t nes.

Alternatively you can make a custom configuration and supply it with -C.

For NES projects I think most people use a custom configuration, because the one supplied with cc65 is mostly suited for writing C programs with text output. A game oriented program may need specific memory customizations, especially if you want to use one of the cartridge mapper types that expands a cartridge's memory size and capabilities.

Your ld65 command line should look something like:

ld65 -o game.nes -C nrom.cfg myassembly.o

Here is an example program, including is linker configuration: NES ca65 example

If you'd like reference, the official documentation is here: ld65 documentation