EtchedPixels / CC6303

A C compiler for the 6800 series processors
Other
37 stars 7 forks source link

[bug] Probably wrong arithmetic or cast #4

Closed Fabrizio-Caruso closed 3 years ago

Fabrizio-Caruso commented 3 years ago

I am compiling a simple program that is supposed to fill the screen with screen code 67 ('C' on many systems include the MC-10):

#if defined(__MC10__)
    #define SCREEN 0x4000
    #define YSize 16
    #define XSize 32
#elif defined(__C64__)
    #define SCREEN 0x0400
    #define YSize 25
    #define XSize 40
#elif defined(__VIC20__)
    #define SCREEN 7680
    #define YSize 23
    #define XSize 22
#endif
#define POKE(addr,val) (*(unsigned char*) (addr) = (val))
#include <stdint.h>

int main(void)
{
    uint8_t i;
    uint8_t j;
    for(i=0;i<YSize;++i)
    {
        for(j=0;j<XSize;++j)
        {
            POKE((uint16_t) SCREEN+((uint16_t)i)*XSize+j,67);
        }
    }
    while(1){};
    return 0;
}

I compile it with CC65 and CC6303 with something like:

mc10_test:
    cc68 -tmc10 -D__MC10__ $(SOURCE_PATH)/../../test/mc10_test1.c -o $(BUILD_PATH)/$@

vic20_test: 
    cl65 -tvic20 -D__VIC20__ $(SOURCE_PATH)/../../test/mc10_test1.c -o$(BUILD_PATH)/$@.prg

c64_test: 
    cl65  -D__C64__ $(SOURCE_PATH)/../../test/mc10_test1.c -o$(BUILD_PATH)/$@.prg

It works fine on both the C64 and VIC20 but on the MC10, it just fills half the screen as if there were some sort of overflow: image

I have attached the MC10 binary and the .c10 file build.zip

EtchedPixels commented 3 years ago

Had me puzzled for a bit as it ran perfectly well on my RC2014 6803 box (albeit without video at that address)

Turns out to be a mix of environment and set up problems not the compiler itself

With those two fixed it seems to behave nicely. I've also updated the setup so the MC10 has its own crt0 (initial pre C code)

jggames commented 3 years ago

Dear Fabrizio,

Sorry I’m just a Basic coder. Your question is above my pay grade. The only thing I’d note is the MC-10 has a 6803 (not 6303). I was under the impression there is no working C compiler for it. I’d ask Greg Dionne or James Tamer on the MC-10 facebook group. They’re the machine code gurus.

Jim

Sent from Mail for Windows 10

From: Fabrizio Caruso Sent: Friday, June 4, 2021 10:39 AM To: EtchedPixels/CC6303 Cc: Subscribed Subject: [EtchedPixels/CC6303] [bug] Probably wrong arithmetic (#4)

I am compiling a simple program that is supposed to fill the screen with screen code 67 ('C' on many systems include the MC-10):

if defined(MC10)

#define SCREEN 0x4000
#define YSize 16
#define XSize 32

elif defined(C64)

#define SCREEN 0x0400
#define YSize 25
#define XSize 40

elif defined(VIC20)

#define SCREEN 7680
#define YSize 23
#define XSize 22

endif

define POKE(addr,val) ((unsigned char) (addr) = (val))

include

include

int main(void) { uint8_t i; uint8_t j; for(i=0;i<YSize;++i) { for(j=0;j<XSize;++j) { POKE((uint16_t) SCREEN+((uint16_t)i)*XSize+j,67); } } while(1){}; return 0; } I compile it with CC65 and CC6303 with something like: mc10_test: cc68 -tmc10 -DMC10 $(SOURCE_PATH)/../../test/mc10_test1.c -o $(BUILD_PATH)/$@

vic20_test: cl65 -tvic20 -DVIC20 $(SOURCE_PATH)/../../test/mc10_test1.c @.***

c64_test: cl65 -DC64 $(SOURCE_PATH)/../../test/mc10_test1.c @.*** It works fine on both the C64 and VIC20 but on the MC10, it just fills half the screen as if there were some sort of overflow:

I have attached the MC10 binary and the .c10 file build.zip — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Fabrizio-Caruso commented 3 years ago

Hi This has just been fixed by Alan Cox. I never said the MC-10 has a 6303. CC6303 is the name of the project.   Fabrizio

Sent from myMail for Android Saturday, 05 June 2021, 01:22AM +02:00 from Jim Gerrie @.*** :

Dear Fabrizio,

Sorry I’m just a Basic coder. Your question is above my pay grade. The only thing I’d note is the MC-10 has a 6803 (not 6303). I was under the impression there is no working C compiler for it. I’d ask Greg Dionne or James Tamer on the MC-10 facebook group. They’re the machine code gurus.

Jim

Sent from Mail for Windows 10

From: Fabrizio Caruso Sent: Friday, June 4, 2021 10:39 AM To: EtchedPixels/CC6303 Cc: Subscribed Subject: [EtchedPixels/CC6303] [bug] Probably wrong arithmetic (#4)

I am compiling a simple program that is supposed to fill the screen with screen code 67 ('C' on many systems include the MC-10):

if defined(MC10)

define SCREEN 0x4000

define YSize 16

define XSize 32

elif defined(C64)

define SCREEN 0x0400

define YSize 25

define XSize 40

elif defined(VIC20)

define SCREEN 7680

define YSize 23

define XSize 22

endif

define POKE(addr,val) ((unsigned char) (addr) = (val))

include

include

int main(void) { uint8_t i; uint8_t j; for(i=0;i { for(j=0;j { POKE((uint16_t) SCREEN+((uint16_t)i)*XSize+j,67); } } while(1){}; return 0; } I compile it with CC65 and CC6303 with something like: mc10_test: cc68 -tmc10 -DMC10 $(SOURCE_PATH)/../../test/mc10_test1.c -o $(BUILD_PATH)/$@

vic20_test: cl65 -tvic20 -DVIC20 $(SOURCE_PATH)/../../test/mc10_test1.c @.***

c64_test: cl65 -DC64 $(SOURCE_PATH)/../../test/mc10_test1.c @.*** It works fine on both the C64 and VIC20 but on the MC10, it just fills half the screen as if there were some sort of overflow:

I have attached the MC10 binary and the .c10 file build.zip — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub , or unsubscribe .

jggames commented 3 years ago

Dear Fabrizio,

Sorry. Just flailing in the dark. Didn’t notice that the message was just a feed from Github (hadn’t seen anything for while from Alan’s compiler repo) until after I had replied. Have read over your threads now. Good to see you’re both making progress. I’ll slip back into the shadows now…

Jim

Sent from Mail for Windows 10

From: Fabrizio Caruso Sent: Friday, June 4, 2021 8:28 PM To: EtchedPixels/CC6303 Cc: Jim Gerrie; Comment Subject: Re: [EtchedPixels/CC6303] [bug] Probably wrong arithmetic or cast (#4)

Hi This has just been fixed by Alan Cox. I never said the MC-10 has a 6303. CC6303 is the name of the project.   Fabrizio

Sent from myMail for Android Saturday, 05 June 2021, 01:22AM +02:00 from Jim Gerrie @.*** :

Dear Fabrizio,

Sorry I’m just a Basic coder. Your question is above my pay grade. The only thing I’d note is the MC-10 has a 6803 (not 6303). I was under the impression there is no working C compiler for it. I’d ask Greg Dionne or James Tamer on the MC-10 facebook group. They’re the machine code gurus.

Jim

Sent from Mail for Windows 10

From: Fabrizio Caruso Sent: Friday, June 4, 2021 10:39 AM To: EtchedPixels/CC6303 Cc: Subscribed Subject: [EtchedPixels/CC6303] [bug] Probably wrong arithmetic (#4)

I am compiling a simple program that is supposed to fill the screen with screen code 67 ('C' on many systems include the MC-10):

if defined(MC10)

define SCREEN 0x4000

define YSize 16

define XSize 32

elif defined(C64)

define SCREEN 0x0400

define YSize 25

define XSize 40

elif defined(VIC20)

define SCREEN 7680

define YSize 23

define XSize 22

endif

define POKE(addr,val) ((unsigned char) (addr) = (val))

include

include

int main(void) { uint8_t i; uint8_t j; for(i=0;i { for(j=0;j { POKE((uint16_t) SCREEN+((uint16_t)i)*XSize+j,67); } } while(1){}; return 0; } I compile it with CC65 and CC6303 with something like: mc10_test: cc68 -tmc10 -DMC10 $(SOURCE_PATH)/../../test/mc10_test1.c -o $(BUILD_PATH)/$@

vic20_test: cl65 -tvic20 -DVIC20 $(SOURCE_PATH)/../../test/mc10_test1.c @.***

c64_test: cl65 -DC64 $(SOURCE_PATH)/../../test/mc10_test1.c @.*** It works fine on both the C64 and VIC20 but on the MC10, it just fills half the screen as if there were some sort of overflow:

I have attached the MC10 binary and the .c10 file build.zip — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub , or unsubscribe . — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.