From: "Payton Byrd" ; on Saturday, January 21, 2012; at 01:33 PM -0500 > > 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. You loaded it wrong. You forgot that the overlays don't have load addresses. Therefore, when you loaded it as a program, it lost its first two bytes. $C013 actually is the location of the "rts". > > 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? You must use the "rodata-name" pragma. If you put your overlays in the same C source file as your main code, then you need to use the pragma "local-strings", as well. P.S., If every overlay is written in its own source file, then you don't need to pop their pragmas. ---------------------------------------------------------------------- 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 22:59:38 2012
This archive was generated by hypermail 2.1.8 : 2012-01-21 22:59:41 CET