Receiving error I am not sure about how to handle

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
Dabi
Posts: 3
Joined: Wed May 04, 2022 12:42 pm

Receiving error I am not sure about how to handle

Post by Dabi »

Hello,

I have just started learning 6502 Assembly and am not yet well versed. I have attempted to run a test program to check my dev environment is set up correctly, however I get an error with a particular program I am not sure what to do about. Code follows:

Code: Select all

.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"
The error I get follows:

Code: Select all

ld65: Warning: C:\cc65\cfg/nes.cfg:18: Segment 'VECTORS' overflows memory area 'ROMV' by 6 bytes
ld65: Error: Cannot generate most of the files due to memory area overflow 
The terminal process "C:\Windows\SysNative\WindowsPowerShell\v1.0\powershell.exe -Command C:\cc65\bin\cl65 "c:\NESDev\ExampleCode\AssemblyCrashCourse-main\examples\Helloworld.asm" --verbose --target nes wrapper.s" terminated with exit code: 1.
Any ideas? I have run numerous other test programs that have worked just fine, so I am curious what the problem is here. I have searched this forum and found other examples of this problem, however none of those solutions worked here.

The program was taken from the Famicom party book found here: https://famicom.party/book/03-gettingstarted/
Drag
Posts: 1615
Joined: Mon Sep 27, 2004 2:57 pm
Contact:

Re: Receiving error I am not sure about how to handle

Post by Drag »

I don't use cc65, but it seems like the contents of segment VECTORS is already defined elsewhere, outside of helloworld.asm, so perhaps in wrapper.s?

It's worth noting that the example given in famicom.party does not include any other source files in the call to ld65, so if both helloworld.asm and your wrapper.s files are trying to put memory addresses into VECTORS, it follows that you wind up with 6 bytes too many.
Dabi
Posts: 3
Joined: Wed May 04, 2022 12:42 pm

Re: Receiving error I am not sure about how to handle

Post by Dabi »

Drag wrote: Fri May 06, 2022 12:05 pm I don't use cc65, but it seems like the contents of segment VECTORS is already defined elsewhere, outside of helloworld.asm, so perhaps in wrapper.s?

It's worth noting that the example given in famicom.party does not include any other source files in the call to ld65, so if both helloworld.asm and your wrapper.s files are trying to put memory addresses into VECTORS, it follows that you wind up with 6 bytes too many.
Yes wrapper.s was exactly it. VECTORS was already defined in the wrapper. Moved it out of the project and created its own space, and it worked first time.

I was being lazy and just copying it into an existing tutorial I had downloaded because it is way more convenient to build it from the IDE than having to open a terminal and use the command line to build and link it.

Thank you so much.
Last edited by Dabi on Tue May 10, 2022 2:47 pm, edited 1 time in total.
Dabi
Posts: 3
Joined: Wed May 04, 2022 12:42 pm

Re: Receiving error I am not sure about how to handle

Post by Dabi »

Interestingly enough, once I had a better look at the wrapper.s, this turns out to be the only code that I needed:

Code: Select all

.export Main
.segment "CODE"

.proc Main

  LDX $2002   
  LDX #$3f
  STX $2006     
  LDX #$00
  STX $2006      
  LDA #$27
  STA $2007       
  LDA #%00011110
  STA $2001  
 
.endproc
Drag
Posts: 1615
Joined: Mon Sep 27, 2004 2:57 pm
Contact:

Re: Receiving error I am not sure about how to handle

Post by Drag »

Oh cool! I'm glad you've got it working. :D
Post Reply