improved error handling of "--cpu" and "--format" switches. started putting m65 in docs.

git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@222 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
marcobaye 2020-06-09 15:58:48 +00:00
parent 1f74a6b8fd
commit 0588f0fffe
3 changed files with 68 additions and 25 deletions

View File

@ -13,8 +13,8 @@ ACME supports the following cpu types:
*** 6502
This is the instruction set of the original NMOS 6502 designed by MOS
(later CSG).
This is the official instruction set of the original NMOS 6502 CPU
designed by MOS (later CSG).
There are 151 documented opcodes.
ACME does not use "A" to indicate "accumulator addressing"; just write
the mnemonic without any argument: "LSR" will work, "LSR A" won't.
@ -65,10 +65,10 @@ There are 178 documented opcodes.
This is a superset of 65c02, probably originally by Rockwell. It adds
bit manipulation instructions:
BBR0 $12, near_target branch on bit reset in zp
BBS0 $12, near_target branch on bit set in zp
RMB0 $12 reset memory bit in zp
SMB0 $12 set memory bit in zp
BBR4 $12, near_target branch on bit reset in zp
BBS5 $12, near_target branch on bit set in zp
RMB6 $12 reset memory bit in zp
SMB7 $12 set memory bit in zp
The digit in the mnemonic is the bit number, therefore it must be in
the 0..7 range.
Chips with this instruction set seem to have been available from
@ -131,6 +131,34 @@ There are 256 documented opcodes.
*** m65
This is a superset of 4502 specified by the MEGA65 project. It uses
NOP and NEG:NEG as prefix bytes to extend the instruction set.
Features:
- new "long indirect z-indexed" addressing mode with four-byte-pointer
for existing instructions:
LDA/STA/ADC/SBC [$12], z ; contents of $12/$13/$14/$15
AND/ORA/EOR/CMP [$12], z ; plus z form the address
- 32-bit data operations indicated via 'Q' ("quad"):
LDQ/STQ/CPQ like LDA/STA/CMP
ADCQ/SBCQ like ADC/SBC
ANDQ/EORQ/ORQ like AND/EOR/ORA
ASLQ/LSRQ/ROLQ/RORQ like ASL/LSR/ROL/ROR
INQ/DEQ like INC/DEC
The new mnemonics support all the addressing modes of the original
mnemonics, except there are no 32-bit immediate arguments.
CAUTION: The STQ mnemonic clobbers the N and Z flags!
There is no "real" Q register, instead A/X/Y/Z are combined to form
the Q register (A holds lsb, Z holds msb), except for read-modify-
write instructions, where the 32-bit operation is performed without
using A/X/Y/Z.
- The NOP mnemonic is disabled for this instruction set because its
opcode is re-used internally as a prefix byte.
CAUTION: The !align pseudo opcode still inserts NOPs.
*** c64dtv2
This is the cpu in version 2 of the C64DTV. It uses a superset of the
@ -150,7 +178,7 @@ Here's a family tree:
|
|\_6510 (+ undocumented opcodes of nmos6502)
|
|\_c64dtv2 (+ bra/sac/sir and some illegals)
|\_c64dtv2 (+ bra/sac/sir and some undocumented)
|
\_65c02 (+ bra/phx/phy/plx/ply/stz/trb/tsb, ...)
|
@ -163,3 +191,5 @@ Here's a family tree:
\_65ce02 (+ Z reg, long branches, ...)
|
\_4502 (+ map/eom)
|
\_m65 (+ 32-bit pointers, 32-bit data)

View File

@ -336,30 +336,43 @@ static void keyword_to_dynabuf(const char keyword[])
}
// check output format (the output format tree must be set up at this point!)
static void set_output_format(void)
// set output format (the output format tree must be set up at this point!)
static void set_output_format(const char format_name[])
{
keyword_to_dynabuf(cliargs_safe_get_next("output format"));
if (outputfile_set_format()) {
fprintf(stderr, "%sUnknown output format (known formats are: %s).\n", cliargs_error, outputfile_formats);
exit(EXIT_FAILURE);
// caution, name may be NULL!
if (format_name) {
keyword_to_dynabuf(format_name);
if (!outputfile_set_format())
return; // ok
fputs("Error: Unknown output format.\n", stderr);
} else {
fputs("Error: No output format specified.\n", stderr);
}
fprintf(stderr, "Supported formats are:\n\n\t%s\n\n", outputfile_formats);
exit(EXIT_FAILURE);
}
// check CPU type (the cpu type tree must be set up at this point!)
static void set_starting_cpu(const char expression[])
// set CPU type (the cpu type tree must be set up at this point!)
static void set_starting_cpu(const char cpu_name[])
{
const struct cpu_type *new_cpu_type;
keyword_to_dynabuf(expression);
new_cpu_type = cputype_find();
if (new_cpu_type) {
default_cpu = new_cpu_type;
// caution, name may be NULL!
if (cpu_name) {
keyword_to_dynabuf(cpu_name);
new_cpu_type = cputype_find();
if (new_cpu_type) {
default_cpu = new_cpu_type;
return; // ok
}
fputs("Error: Unknown CPU type.\n", stderr);
} else {
fprintf(stderr, "%sUnknown CPU type (known types are: %s).\n", cliargs_error, cputype_names);
exit(EXIT_FAILURE);
fputs("Error: No CPU type specified.\n", stderr);
}
fprintf(stderr, "Supported types are:\n\n\t%s\n\n", cputype_names);
exit(EXIT_FAILURE);
}
@ -498,7 +511,7 @@ static const char *long_option(const char *string)
if (strcmp(string, OPTION_HELP) == 0)
show_help_and_exit();
else if (strcmp(string, OPTION_FORMAT) == 0)
set_output_format();
set_output_format(cliargs_get_next()); // NULL is ok (handled like unknown)
else if (strcmp(string, OPTION_OUTFILE) == 0)
output_filename = cliargs_safe_get_next(name_outfile);
else if (strcmp(string, OPTION_LABELDUMP) == 0) // old
@ -512,7 +525,7 @@ static const char *long_option(const char *string)
else if (strcmp(string, OPTION_SETPC) == 0)
set_starting_pc(cliargs_safe_get_next("program counter"));
else if (strcmp(string, OPTION_CPU) == 0)
set_starting_cpu(cliargs_safe_get_next("CPU type"));
set_starting_cpu(cliargs_get_next()); // NULL is ok (handled like unknown)
else if (strcmp(string, OPTION_INITMEM) == 0)
set_mem_contents(cliargs_safe_get_next("initmem value"));
else if (strcmp(string, OPTION_MAXERRORS) == 0)
@ -557,7 +570,7 @@ static char short_option(const char *argument)
define_symbol(argument + 1);
goto done;
case 'f': // "-f" selects output format
set_output_format();
set_output_format(cliargs_get_next()); // NULL is ok (handled like unknown)
break;
case 'h': // "-h" shows help
show_help_and_exit();

View File

@ -9,7 +9,7 @@
#define RELEASE "0.96.5" // update before release FIXME
#define CODENAME "Fenchurch" // update before release
#define CHANGE_DATE "8 June" // update before release FIXME
#define CHANGE_DATE "9 June" // update before release FIXME
#define CHANGE_YEAR "2020" // update before release
//#define HOME_PAGE "http://home.pages.de/~mac_bacon/smorbrod/acme/"
#define HOME_PAGE "http://sourceforge.net/p/acme-crossass/" // FIXME