8000 Mega65 target by mrdudz · Pull Request #2730 · cc65/cc65 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Mega65 target #2730

New issue 8000

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions cfg/c65-asm.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FEATURES {
STARTADDRESS: default = $2001;
}
SYMBOLS {
__LOADADDR__: type = import;
}
MEMORY {
ZP: file = "", start = $0002, size = $00FE, define = yes;
LOADADDR: file = %O, start = %S - 2, size = $0002;
MAIN: file = %O, start = %S, size = $D000 - %S;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp, optional = yes;
LOADADDR: load = LOADADDR, type = ro;
EXEHDR: load = MAIN, type = ro, optional = yes;
CODE: load = MAIN, type = rw;
RODATA: load = MAIN, type = ro, optional = yes;
DATA: load = MAIN, type = rw, optional = yes;
BSS: load = MAIN, type = bss, optional = yes, define = yes;
}
20 changes: 20 additions & 0 deletions cfg/mega65-asm.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FEATURES {
STARTADDRESS: default = $2001;
}
SYMBOLS {
__LOADADDR__: type = import;
}
MEMORY {
ZP: file = "", start = $0002, size = $00FE, define = yes;
LOADADDR: file = %O, start = %S - 2, size = $0002;
MAIN: file = %O, start = %S, size = $D000 - %S;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp, optional = yes;
LOADADDR: load = LOADADDR, type = ro;
EXEHDR: load = MAIN, type = ro, optional = yes;
CODE: load = MAIN, type = rw;
RODATA: load = MAIN, type = ro, optional = yes;
DATA: load = MAIN, type = rw, optional = yes;
BSS: load = MAIN, type = bss, optional = yes, define = yes;
}
2 changes: 1 addition & 1 deletion doc/ca65.sgml
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ Here is a description of all the command line options:
character constants into the character set of the target platform. The
default for the target system is "none", which means that no translation
will take place. The assembler supports the same target systems as the
compiler, see there for a list.
compiler, see <htmlurl url="ca65.html#option-t" name="there for a list">.

Depending on the target, the default CPU type is also set. This can be
overridden by using the <tt/<ref id="option--cpu" name="--cpu">/ option.
Expand Down
15 changes: 15 additions & 0 deletions doc/cc65.sgml
Original file line number Diff line number Diff line change
Expand Up @@ -610,27 +610,42 @@ Here is a description of all the command line options:

<itemize>
<item>none
<item>agat (a russian apple2 like computer)
<item>apple2
<item>apple2enh
<item>atari
<item>atari2600
<item>atari5200
<item>atari7800
<item>atarixl
<item>atmos
<item>bbc
<item>c16 (works also for the c116 with memory up to 32K)
<item>c64
<item>c65
<item>c128
<item>cbm510 (CBM-II series with 40 column video)
<item>cbm610 (all CBM-II II computers with 80 column video)
<item>creativision
<item>cx16
<item>gamate
<item>geos-apple
<item>geos-cbm
<item>geos (alias for geos-cbm)
<item>kim1
<item>lunix
<item>lynx
<item>mega65
<item>nes
<item>osic1p
<item>pce (PC engine)
<item>pet (all CBM PET systems except the 2001)
<item>plus4
<item>p6502
<item>sim6502
<item>sim65c02
<item>supervision
<item>sym1
<item>telestrat
<item>vic20
</itemize>
Expand Down
11 changes: 10 additions & 1 deletion libsrc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ CBMS = c128 \
GEOS = geos-apple \
geos-cbm

# FIXME: c65 (and perhaps mega65?) should be moved up to CBMS maybe
TARGETS = agat \
apple2 \
apple2enh \
Expand All @@ -30,6 +31,7 @@ TARGETS = agat \
atari5200 \
atari7800 \
atmos \
c65 \
creativision \
$(CBMS) \
$(GEOS) \
Expand All @@ -45,7 +47,8 @@ TARGETS = agat \
sim65c02 \
supervision \
sym1 \
telestrat
telestrat \
mega65

TARGETTEST = none \
sim6502 \
Expand Down Expand Up @@ -193,6 +196,11 @@ ifeq ($(TARGET),$(filter $(TARGET),$(GEOS)))
SRCDIRS += $(addprefix geos-common/,$(GEOSDIRS))
endif

ifeq ($(TARGET),c65)
# FIXME: this does not work because of the SP vs C_SP clash
else ifeq ($(TARGET),mega65)
# FIXME: this does not work because of the SP vs C_SP clash
else
SRCDIRS += common \
conio \
dbg \
Expand All @@ -203,6 +211,7 @@ SRCDIRS += common \
serial \
tgi \
zlib
endif

vpath %.s $(SRCDIRS)
vpath %.c $(SRCDIRS)
Expand Down
32 changes: 32 additions & 0 deletions libsrc/c65/exehdr.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
;
; Ullrich von Bassewitz, 2010-11-14
;
; This module supplies a small BASIC stub program that jumps to the machine
; language code that follows it using SYS.
;

; The following symbol is used by linker config to force the module
; to get included into the output file
.export __EXEHDR__: absolute = 1

.segment "EXEHDR"

.addr Next
.word .version ; Line number
.byte $fe, $02, "0:" ; BANK 0
.byte $9e ; SYS
; .byte <(((Start / 10000) .mod 10) + '0')
.byte <(((Start / 1000) .mod 10) + '0')
.byte <(((Start / 100) .mod 10) + '0')
.byte <(((Start / 10) .mod 10) + '0')
.byte <(((Start / 1) .mod 10) + '0')
.byte $00 ; End of BASIC line
Next: .word 0 ; BASIC end marker
Start:

; If the start address is larger than 4 digits, the header generated above
; will not contain the highest digit. Instead of wasting one more digit that
; is almost never used, check it at link time and generate an error so the
; user knows something is wrong.

.assert (Start < 10000), error, "Start address too large for generated BASIC stub"
16 changes: 16 additions & 0 deletions libsrc/c65/loadaddr.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
;
; Ullrich von Bassewitz, 2010-11-13
;
; This module supplies the load address that is expected by Commodore
; machines in the first two bytes of an excutable disk file.
;


; The following symbol is used by linker config to force the module
; to get included into the output file
.export __LOADADDR__: absolute = 1

.segment "LOADADDR"

.addr *+2

32 changes: 32 additions & 0 deletions libsrc/mega65/exehdr.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
;
; Ullrich von Bassewitz, 2010-11-14
;
; This module supplies a small BASIC stub program that jumps to the machine
; language code that follows it using SYS.
;

; The following symbol is used by linker config to force the module
; to get included into the output file
.export __EXEHDR__: absolute = 1

.segment "EXEHDR"

.addr Next
.word .version ; Line number
.byte $fe, $02, "0:" ; BANK 0
.byte $9e ; SYS
; .byte <(((Start / 10000) .mod 10) + '0')
.byte <(((Start / 1000) .mod 10) + '0')
.byte <(((Start / 100) .mod 10) + '0')
.byte <(((Start / 10) .mod 10) + '0')
.byte <(((Start / 1) .mod 10) + '0')
.byte $00 ; End of BASIC line
Next: .word 0 ; BASIC end marker
Start:

; If the start address is larger than 4 digits, the header generated above
; will not contain the highest digit. Instead of wasting one more digit that
; is almost never used, check it at link time and generate an error so the
; user knows something is wrong.

.assert (Start < 10000), error, "Start address too large for generated BASIC stub"
16 changes: 16 additions & 0 deletions libsrc/mega65/loadaddr.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
;
; Ullrich von Bassewitz, 2010-11-13
;
; This module supplies the load address that is expected by Commodore
; machines in the first two bytes of an excutable disk file.
;


; The following symbol is used by linker config to force the module
; to get included into the output file
.export __LOADADDR__: absolute = 1

.segment "LOADADDR"

.addr *+2

4 changes: 4 additions & 0 deletions src/ca65/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ static void SetSys (const char* Sys)
NewSymbol ("__SYM1__", 1);
break;

case TGT_MEGA65:
CBMSystem ("__MEGA65__");
break;

case TGT_KIM1:
NewSymbol ("__KIM1__", 1);
break;
Expand Down
2 changes: 2 additions & 0 deletions src/cc65/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ void g_preamble (void)
case CPU_65C02: AddTextLine ("\t.setcpu\t\t\"65C02\""); break;
case CPU_65816: AddTextLine ("\t.setcpu\t\t\"65816\""); break;
case CPU_HUC6280: AddTextLine ("\t.setcpu\t\t\"HUC6280\""); break;
case CPU_4510: AddTextLine ("\t.setcpu\t\t\"4510\""); break;
case CPU_45GS02: AddTextLine ("\t.setcpu\t\t\"45GS02\""); break;
default: Internal ("Unknown CPU: %d", CPU);
}

Expand Down
19 changes: 18 additions & 1 deletion src/cc65/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,14 @@ static void SetSys (const char* Sys)
DefineNumericMacro ("__SYM1__", 1);
break;

case TGT_C65:
cbmsys ("__C65__");
break;

case TGT_MEGA65:
cbmsys ("__MEGA65__");
break;

case TGT_KIM1:
DefineNumericMacro ("__KIM1__", 1);
break;
Expand Down Expand Up @@ -340,7 +348,6 @@ static void DefineCpuMacros (void)
case CPU_NONE:
case CPU_SWEET16:
case CPU_M740:
case CPU_4510:
case CPU_UNKNOWN:
CPUName = (CPU == CPU_UNKNOWN)? "unknown" : CPUNames[CPU];
Internal ("Invalid CPU \"%s\"", CPUName);
Expand Down Expand Up @@ -374,6 +381,14 @@ static void DefineCpuMacros (void)
DefineNumericMacro ("__CPU_HUC6280__", 1);
break;

case CPU_4510:
DefineNumericMacro ("__CPU_4510__", 1);
break;

case CPU_45GS02:
DefineNumericMacro ("__CPU_45GS02__", 1);
break;

default:
FAIL ("Unexpected value in switch");
break;
Expand All @@ -389,6 +404,8 @@ static void DefineCpuMacros (void)
DefineNumericMacro ("__CPU_ISET_65C02__", CPU_ISET_65C02);
DefineNumericMacro ("__CPU_ISET_65816__", CPU_ISET_65816);
DefineNumericMacro ("__CPU_ISET_HUC6280__", CPU_ISET_HUC6280);
DefineNumericMacro ("__CPU_ISET_4510__", CPU_ISET_4510);
DefineNumericMacro ("__CPU_ISET_45GS02__", CPU_ISET_45GS02);

/* Now define the macro that contains the bit set with the available
** cpu instructions.
Expand Down
2 changes: 2 additions & 0 deletions src/common/target.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ static const TargetEntry TargetMap[] = {
{ "kim1", TGT_KIM1 },
{ "lunix", TGT_LUNIX },
{ "lynx", TGT_LYNX },
{ "mega65", TGT_MEGA65, },
{ "module", TGT_MODULE },
{ "nes", TGT_NES },
{ "none", TGT_NONE },
Expand Down Expand Up @@ -243,6 +244,7 @@ static const TargetProperties PropertyTable[TGT_COUNT] = {
{ "c65", CPU_4510, BINFMT_BINARY, CTPET },
{ "cx16", CPU_65C02, BINFMT_BINARY, CTPET },
{ "sym1", CPU_6502, BINFMT_BINARY, CTNone },
{ "mega65", CPU_45GS02, BINFMT_BINARY, CTPET },
{ "kim1", CPU_6502, BINFMT_BINARY, CTNone },
{ "rp6502", CPU_65C02, BINFMT_BINARY, CTNone },
{ "agat", CPU_6502, BINFMT_BINARY, CTAgat },
Expand Down
1 change: 1 addition & 0 deletions src/common/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ typedef enum {
TGT_C65,
TGT_CX16,
TGT_SYM1,
TGT_MEGA65,
TGT_KIM1,
TGT_RP6502,
TGT_AGAT,
Expand Down
0