mirror of https://github.com/cc65/cc65.git
Compare commits
26 Commits
2b1aea79fc
...
94de4cd907
Author | SHA1 | Date |
---|---|---|
Colin Leroy-Mira | 94de4cd907 | |
Bob Andrews | b1e1c13d4b | |
bbbradsmith | 8804dc7a58 | |
bbbradsmith | 4bc726ebe2 | |
bbbradsmith | fa1a426c29 | |
bbbradsmith | 89b709c7f8 | |
bbbradsmith | 79585194e6 | |
mrdudz | b993d88339 | |
Bob Andrews | 25967e65b5 | |
Bob Andrews | a372ead4de | |
Bob Andrews | 081d18f7d7 | |
Bob Andrews | a293920fb3 | |
Bob Andrews | 60c75bdb54 | |
Sven Michael Klose | 1fe12f112e | |
Sven Michael Klose | a887b29ffb | |
acqn | 731f349b24 | |
acqn | 98767741ce | |
acqn | 9b2d27d1e1 | |
acqn | 23aa562094 | |
Bob Andrews | 5c3ff714ae | |
Sven Michael Klose | 294b034920 | |
Stefan | ab0eb4fe58 | |
Stefan | 8d4946b3f4 | |
Sven Michael Klose | 3a7bd53956 | |
Sven Michael Klose | 8173c850fd | |
Carlo Bramini | b04d79b1da |
|
@ -15,7 +15,7 @@ CPU_ISET_4510 = $0400
|
||||||
CPU_NONE = CPU_ISET_NONE
|
CPU_NONE = CPU_ISET_NONE
|
||||||
CPU_6502 = CPU_ISET_6502
|
CPU_6502 = CPU_ISET_6502
|
||||||
CPU_6502X = CPU_ISET_6502|CPU_ISET_6502X
|
CPU_6502X = CPU_ISET_6502|CPU_ISET_6502X
|
||||||
CPU_6502DTV = CPU_ISET_6502|CPU_ISET_6502X|CPU_ISET_6502DTV
|
CPU_6502DTV = CPU_ISET_6502|CPU_ISET_6502DTV
|
||||||
CPU_65SC02 = CPU_ISET_6502|CPU_ISET_65SC02
|
CPU_65SC02 = CPU_ISET_6502|CPU_ISET_65SC02
|
||||||
CPU_65C02 = CPU_ISET_6502|CPU_ISET_65SC02|CPU_ISET_65C02
|
CPU_65C02 = CPU_ISET_6502|CPU_ISET_65SC02|CPU_ISET_65C02
|
||||||
CPU_65816 = CPU_ISET_6502|CPU_ISET_65SC02|CPU_ISET_65816
|
CPU_65816 = CPU_ISET_6502|CPU_ISET_65SC02|CPU_ISET_65816
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
# Assembly program configuration for expanded VICs (>= +8K).
|
||||||
|
|
||||||
|
FEATURES {
|
||||||
|
STARTADDRESS: default = $1201;
|
||||||
|
}
|
||||||
|
SYMBOLS {
|
||||||
|
__LOADADDR__: type = import;
|
||||||
|
}
|
||||||
|
MEMORY {
|
||||||
|
ZP: file = "", start = $0002, size = $001A, define = yes;
|
||||||
|
LOADADDR: file = %O, start = %S - 2, size = $0002;
|
||||||
|
MAIN: file = %O, start = %S, size = $8000 - %S;
|
||||||
|
}
|
||||||
|
SEGMENTS {
|
||||||
|
ZEROPAGE: load = ZP, type = zp, optional = yes;
|
||||||
|
LOADADDR: load = LOADADDR, type = ro;
|
||||||
|
CODE: load = MAIN, type = ro;
|
||||||
|
RODATA: load = MAIN, type = ro;
|
||||||
|
DATA: load = MAIN, type = rw;
|
||||||
|
BSS: load = MAIN, type = bss, optional = yes, define = yes;
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
# Assembly program configuration for expanded VICs (+3K only).
|
||||||
|
|
||||||
|
FEATURES {
|
||||||
|
STARTADDRESS: default = $0401;
|
||||||
|
}
|
||||||
|
SYMBOLS {
|
||||||
|
__LOADADDR__: type = import;
|
||||||
|
}
|
||||||
|
MEMORY {
|
||||||
|
ZP: file = "", start = $0002, size = $001A, define = yes;
|
||||||
|
LOADADDR: file = %O, start = %S - 2, size = $0002;
|
||||||
|
MAIN: file = %O, start = %S, size = $1E00 - %S;
|
||||||
|
}
|
||||||
|
SEGMENTS {
|
||||||
|
ZEROPAGE: load = ZP, type = zp, optional = yes;
|
||||||
|
LOADADDR: load = LOADADDR, type = ro;
|
||||||
|
CODE: load = MAIN, type = ro;
|
||||||
|
RODATA: load = MAIN, type = ro;
|
||||||
|
DATA: load = MAIN, type = rw;
|
||||||
|
BSS: load = MAIN, type = bss, optional = yes, define = yes;
|
||||||
|
}
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Assembly program configuration for unexpanded VICs.
|
||||||
|
|
||||||
FEATURES {
|
FEATURES {
|
||||||
STARTADDRESS: default = $1001;
|
STARTADDRESS: default = $1001;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +9,7 @@ SYMBOLS {
|
||||||
MEMORY {
|
MEMORY {
|
||||||
ZP: file = "", start = $0002, size = $001A, define = yes;
|
ZP: file = "", start = $0002, size = $001A, define = yes;
|
||||||
LOADADDR: file = %O, start = %S - 2, size = $0002;
|
LOADADDR: file = %O, start = %S - 2, size = $0002;
|
||||||
MAIN: file = %O, start = %S, size = $0DF3 - %S;
|
MAIN: file = %O, start = %S, size = $1E00 - %S;
|
||||||
}
|
}
|
||||||
SEGMENTS {
|
SEGMENTS {
|
||||||
ZEROPAGE: load = ZP, type = zp, optional = yes;
|
ZEROPAGE: load = ZP, type = zp, optional = yes;
|
||||||
|
|
|
@ -115,37 +115,78 @@ PVExit ($01)
|
||||||
|
|
||||||
<sect>Creating a Test in C<p>
|
<sect>Creating a Test in C<p>
|
||||||
|
|
||||||
For a C test compiled and linked with <tt/--target sim6502/ the
|
For a C test linked with <tt/--target sim6502/ and the <tt/sim6502.lib/ library,
|
||||||
command line arguments to <tt/sim65/ will be passed to <tt/main/,
|
command line arguments to <tt/sim65/ will be passed to <tt/main/,
|
||||||
and the return value from <tt/main/ will become sim65's exit code.
|
and the return value from <tt/main/ will become sim65's exit code.
|
||||||
The <tt/exit/ function may also be used to terminate with an exit code.
|
The <tt/stdlib.h/ <tt/exit/ function may also be used to terminate with an exit code.
|
||||||
|
|
||||||
Exit codes are limited to 8 bits.
|
Exit codes are limited to an unsigned 8 bit value. (E.g. returning -1 will give an exit code of 255.)
|
||||||
|
|
||||||
The standard C library high level file input and output is functional.
|
The standard C library high level file input and output is functional.
|
||||||
A sim65 application can be written like a command line application,
|
A sim65 application can be written like a command line application,
|
||||||
providing arguments to <tt/main/ and using the <tt/stdio.h/ interfaces.
|
providing command line arguments to <tt/main/ and using the <tt/stdio.h/ interfaces
|
||||||
|
to interact with the console or access files.
|
||||||
|
|
||||||
Internally, file input and output is provided at a lower level by
|
Internally, file input and output is provided at a lower level by
|
||||||
a set of built-in paravirtualization functions (<ref id="paravirt-internal" name="see below">).
|
a set of built-in paravirtualization functions (see <ref id="paravirt-internal" name="below">).
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
<tscreen><verb>
|
||||||
|
#include <stdio.h>
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
printf("Hello!\n");
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build and run:
|
||||||
|
// cl65 -t sim6502 -o example.prg example.c
|
||||||
|
// sim65 example.prg
|
||||||
|
|
||||||
|
// Build and run, separate steps:
|
||||||
|
// cc65 -t sim6502 -o example.s example.c
|
||||||
|
// ca65 -t sim6502 -o example.o example.s
|
||||||
|
// ld65 -t sim6502 -o example.prg example.o sim6502.lib
|
||||||
|
// sim65 example.prg
|
||||||
|
</verb></tscreen>
|
||||||
|
|
||||||
<sect>Creating a Test in Assembly<p>
|
<sect>Creating a Test in Assembly<p>
|
||||||
|
|
||||||
Assembly tests may similarly be assembled and linked with
|
Though a C test may also link with assembly code,
|
||||||
<tt/--target sim6502/ or <tt/--target sim65c02/.
|
a pure assembly test can also be created.
|
||||||
Define and export <tt/_main/ as an entry point,
|
|
||||||
|
Link with <tt/--target sim6502/ or <tt/--target sim65c02/ and the corresponding library,
|
||||||
|
define and export <tt/_main/ as an entry point,
|
||||||
and the sim65 library provides two ways to return an 8-bit exit code:
|
and the sim65 library provides two ways to return an 8-bit exit code:
|
||||||
|
|
||||||
<itemize>
|
<itemize>
|
||||||
|
|
||||||
<item>Return from <tt/_main/ with the exit code in <tt/A/.
|
<item>Return from <tt/_main/ with the exit code in <tt/A/.
|
||||||
|
|
||||||
<item><tt/jmp exit/ with the code in <tt/A/.
|
<item><tt/jmp exit/ with the code in <tt/A/. (<tt/.import exit/ from the sim65 library.)
|
||||||
|
|
||||||
</itemize>
|
</itemize>
|
||||||
|
|
||||||
The binary file has a 12 byte header:
|
Example:
|
||||||
|
|
||||||
|
<tscreen><verb>
|
||||||
|
.export _main
|
||||||
|
_main:
|
||||||
|
lda #5
|
||||||
|
rts
|
||||||
|
|
||||||
|
; Build and run:
|
||||||
|
; cl65 -t sim6502 -o example.prg example.s
|
||||||
|
; sim65 example.prg
|
||||||
|
|
||||||
|
; Build and run, separate steps:
|
||||||
|
; ca65 -t sim6502 -o example.o example.s
|
||||||
|
; ld65 -t sim6502 -o example.prg example.o sim6502.lib
|
||||||
|
; sim65 example.prg
|
||||||
|
</verb></tscreen>
|
||||||
|
|
||||||
|
Internally, the binary program file has a 12 byte header provided by the library:
|
||||||
|
|
||||||
<itemize>
|
<itemize>
|
||||||
|
|
||||||
|
@ -182,6 +223,9 @@ These use cc65 calling conventions, and are intended for use with the sim65 targ
|
||||||
<item><tt/IRQ/ and <tt/NMI/ events will not be generated, though <tt/BRK/
|
<item><tt/IRQ/ and <tt/NMI/ events will not be generated, though <tt/BRK/
|
||||||
can be used if the IRQ vector at <tt/$FFFE/ is manually prepared by the test code.
|
can be used if the IRQ vector at <tt/$FFFE/ is manually prepared by the test code.
|
||||||
|
|
||||||
|
<item>The <tt/sim6502/ or <tt/sim65c02/ targets provide a default configuration,
|
||||||
|
but if customization is needed <tt/sim6502.cfg/ or <tt/sim65c02.cfg/ might be used as a template.
|
||||||
|
|
||||||
</itemize>
|
</itemize>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,21 @@
|
||||||
.import __MAIN_START__
|
.import __MAIN_START__
|
||||||
.import startup
|
.import startup
|
||||||
|
|
||||||
|
.macpack cpu
|
||||||
|
|
||||||
.segment "EXEHDR"
|
.segment "EXEHDR"
|
||||||
|
|
||||||
.byte $73, $69, $6D, $36, $35 ; 'sim65'
|
.byte $73, $69, $6D, $36, $35 ; 'sim65'
|
||||||
.byte 2 ; header version
|
.byte 2 ; header version
|
||||||
.byte .defined(__SIM65C02__) ; CPU type
|
.if (.cpu .bitand ::CPU_ISET_6502X)
|
||||||
|
.byte 2
|
||||||
|
.elseif (.cpu .bitand ::CPU_ISET_65C02)
|
||||||
|
.byte 1
|
||||||
|
.elseif (.cpu .bitand ::CPU_ISET_6502)
|
||||||
|
.byte 0
|
||||||
|
.else
|
||||||
|
.error Unknow CPU type.
|
||||||
|
.endif
|
||||||
.byte sp ; sp address
|
.byte sp ; sp address
|
||||||
.addr __MAIN_START__ ; load address
|
.addr __MAIN_START__ ; load address
|
||||||
.addr startup ; reset address
|
.addr startup ; reset address
|
||||||
|
|
1048
src/cc65/declare.c
1048
src/cc65/declare.c
File diff suppressed because it is too large
Load Diff
|
@ -3272,7 +3272,7 @@ static void parsesub (ExprDesc* Expr)
|
||||||
/* The right hand side is constant. Check left hand side. */
|
/* The right hand side is constant. Check left hand side. */
|
||||||
if (ED_IsQuasiConst (Expr)) {
|
if (ED_IsQuasiConst (Expr)) {
|
||||||
/* We can't do all 'ptr1 - ptr2' constantly at the moment */
|
/* We can't do all 'ptr1 - ptr2' constantly at the moment */
|
||||||
if (Expr->Sym == Expr2.Sym) {
|
if (ED_GetLoc (Expr) == ED_GetLoc (&Expr2) && Expr->Sym == Expr2.Sym) {
|
||||||
Expr->IVal = (Expr->IVal - Expr2.IVal) / rscale;
|
Expr->IVal = (Expr->IVal - Expr2.IVal) / rscale;
|
||||||
/* Get rid of unneeded flags etc. */
|
/* Get rid of unneeded flags etc. */
|
||||||
ED_MakeConstAbsInt (Expr, Expr->IVal);
|
ED_MakeConstAbsInt (Expr, Expr->IVal);
|
||||||
|
|
|
@ -231,9 +231,11 @@ static int findToken (const char * const *tokenTbl, const char *token)
|
||||||
/* takes as input table of tokens and token, returns position in table or -1 if not found */
|
/* takes as input table of tokens and token, returns position in table or -1 if not found */
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; tokenTbl[i][0]; i++) {
|
if (token != NULL) {
|
||||||
if (strcmp (tokenTbl[i], token) == 0) {
|
for (i = 0; tokenTbl[i][0]; i++) {
|
||||||
return i;
|
if (strcmp (tokenTbl[i], token) == 0) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2703
src/sim65/6502.c
2703
src/sim65/6502.c
File diff suppressed because it is too large
Load Diff
|
@ -47,7 +47,8 @@
|
||||||
/* Supported CPUs */
|
/* Supported CPUs */
|
||||||
typedef enum CPUType {
|
typedef enum CPUType {
|
||||||
CPU_6502,
|
CPU_6502,
|
||||||
CPU_65C02
|
CPU_65C02,
|
||||||
|
CPU_6502X
|
||||||
} CPUType;
|
} CPUType;
|
||||||
|
|
||||||
/* Current CPU */
|
/* Current CPU */
|
||||||
|
|
|
@ -177,10 +177,16 @@ static unsigned char ReadProgramFile (void)
|
||||||
|
|
||||||
/* Get the CPU type from the file header */
|
/* Get the CPU type from the file header */
|
||||||
if ((Val = fgetc(F)) != EOF) {
|
if ((Val = fgetc(F)) != EOF) {
|
||||||
if (Val != CPU_6502 && Val != CPU_65C02) {
|
switch (Val) {
|
||||||
|
case CPU_6502:
|
||||||
|
case CPU_65C02:
|
||||||
|
case CPU_6502X:
|
||||||
|
CPU = Val;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
Error ("'%s': Invalid CPU type", ProgramFile);
|
Error ("'%s': Invalid CPU type", ProgramFile);
|
||||||
}
|
}
|
||||||
CPU = Val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the address of sp from the file header */
|
/* Get the address of sp from the file header */
|
||||||
|
|
|
@ -12,23 +12,25 @@ endif
|
||||||
|
|
||||||
WORKDIR = ../testwrk/asm
|
WORKDIR = ../testwrk/asm
|
||||||
|
|
||||||
SUBDIRS = cpudetect opcodes listing val err misc
|
|
||||||
|
|
||||||
.PHONY: all continue mostlyclean clean
|
.PHONY: all continue mostlyclean clean
|
||||||
|
|
||||||
all: mostlyclean continue
|
all: mostlyclean continue
|
||||||
|
|
||||||
define CALL_template
|
continue: mostlyclean
|
||||||
|
@$(MAKE) -C cpudetect all
|
||||||
|
@$(MAKE) -C opcodes all
|
||||||
|
@$(MAKE) -C listing all
|
||||||
|
@$(MAKE) -C val all
|
||||||
|
@$(MAKE) -C err all
|
||||||
|
@$(MAKE) -C misc all
|
||||||
|
|
||||||
continue::
|
mostlyclean:
|
||||||
@$(MAKE) -C $1 all
|
@$(MAKE) -C cpudetect clean
|
||||||
|
@$(MAKE) -C opcodes clean
|
||||||
mostlyclean::
|
@$(MAKE) -C listing clean
|
||||||
@$(MAKE) -C $1 clean
|
@$(MAKE) -C val clean
|
||||||
|
@$(MAKE) -C err clean
|
||||||
endef
|
@$(MAKE) -C misc clean
|
||||||
|
|
||||||
$(foreach subdir,$(SUBDIRS),$(eval $(call CALL_template,$(subdir))))
|
|
||||||
|
|
||||||
clean: mostlyclean
|
clean: mostlyclean
|
||||||
@$(call RMDIR,$(WORKDIR))
|
@$(call RMDIR,$(WORKDIR))
|
||||||
|
|
Loading…
Reference in New Issue