[cc65] Problem with code compiled as overlay.

From: Payton Byrd <plbyrd1gmail.com>
Date: 2012-01-21 19:33:59
Hello!

I've got a very strange problem.  I have a project that Oliver has helped
me with to build an overlay example so I can start a bigger project.

The problem I've run into is that the code compiled for the overlay has a
very serious defect in it.  My overlay is compiling to $C000 and the C
looks like this:

#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>

#pragma code-name (push, "OVL1CODE");


int overlay1()
{
	printf("This is overlay 1.");
	return 1;
}

#pragma code-name (pop);


Now, the disassembled code generated by cc65 looks like this:

** Monitor 012 002
(C:$e5d1) d c000
.C:c000   A2 14      LDX #$14
.C:c002   20 8D 0B   JSR $0B8D
.C:c005   A0 02      LDY #$02
.C:c007   20 68 12   JSR $1268
.C:c00a   A2 00      LDX #$00
.C:c00c   A9 01      LDA #$01
*.C:c00e   4C 13 C0   JMP $C013*
.C:c011   60         RTS
.C:c012   00         BRK
.C:c013   00         BRK
.C:c014   00         BRK
.C:c015   00         BRK
.C:c016   00         BRK
.C:c017   00         BRK
.C:c018   00         BRK
.C:c019   00         BRK
.C:c01a   00         BRK
.C:c01b   00         BRK
.C:c01c   00         BRK
.C:c01d   00         BRK
.C:c01e   00         BRK
.C:c01f   00         BRK
.C:c020   00         BRK
.C:c021   00         BRK
.C:c022   00         BRK
.C:c023   00         BRK
.C:c024   00         BRK
.C:c025   00         BRK
.C:c026   00         BRK
.C:c027   00         BRK
.C:c028   00         BRK
(C:$c029)

Please note the code at $C00E.  It jumps into a BRK statement at $C013.
 This makes no sense to me and appears to be some kind of bug or side
effect.  I'm attaching a zip file with my whole project in it.

Any help is greatly appreciated.

PS.  Another issue I have with this code is that the string literal in the
method is not compiled as part of the overlay.  I may have a lot of text in
each overlay, how do I make sure all the literals are compiled in the
overlays?

-- 
Payton Byrd
<http://www.paytonbyrd.com>
<http://it.toolbox.com/blogs/paytonbyrd>

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sat Jan 21 19:34:42 2012

This archive was generated by hypermail 2.1.8 : 2012-01-21 19:34:46 CET