mirror of
https://github.com/uffejakobsen/acme.git
synced 2025-08-09 11:25:03 +00:00
updated "toacme" sources to version 0.11 from 2012-10-08 (source cleanup)
git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@59 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
|
||||
2012-10-08
|
||||
Release 0.11
|
||||
Beautified source, and added space after ',' in addressing modes.
|
||||
|
||||
2006-10-04
|
||||
Release 0.10
|
||||
Adjusted support for illegals to latest changes in ACME.
|
||||
|
@@ -11,9 +11,9 @@
|
||||
#include "scr2iso.h"
|
||||
|
||||
|
||||
// Constants
|
||||
// constants
|
||||
|
||||
// Generate error/warning messages
|
||||
// generate error/warning messages
|
||||
const char error_unknown_addressing[] = "Conversion failed: AssBlaster file contains unknown addressing mode.\n";
|
||||
const char error_unknown_compression[] = "Conversion failed: AssBlaster file contains unknown number compression.\n";
|
||||
const char warning_unknown_number_format[] = "Warning: AssBlaster file uses unknown number format. Fallback to hexadecimal.\n";
|
||||
@@ -43,8 +43,8 @@ const char warning_unknown_number_format[] = "Warning: AssBlaster file uses unkn
|
||||
// after mnemonic or pseudo opcode, numbers may follow:
|
||||
#define AB_NUMVAL_FLAGBIT 0x80 // indicates packed number
|
||||
|
||||
// Pre- and postfixes for addressing modes
|
||||
// Don't care whether argument is 8, 16 or 24 bits wide
|
||||
// pre- and postfixes for addressing modes
|
||||
// don't care whether argument is 8, 16 or 24 bits wide
|
||||
const char *addressing_modes[][2] = {
|
||||
{"", "" }, // ($00=%.....) implied
|
||||
{" ", "" }, // ($01=%....1) absolute
|
||||
@@ -82,14 +82,16 @@ const char* addressing_modes[][2] = {
|
||||
};
|
||||
|
||||
|
||||
// Variables
|
||||
struct ab_t* conf;
|
||||
// variables
|
||||
struct ab *conf;
|
||||
|
||||
|
||||
// Functions
|
||||
// functions
|
||||
|
||||
|
||||
//
|
||||
static void generate_errors(int err_bits) {
|
||||
static void generate_errors(int err_bits)
|
||||
{
|
||||
if (err_bits & AB_ERRBIT_UNKNOWN_ADDRMODE) {
|
||||
fputs(error_unknown_addressing, stderr);
|
||||
fprintf(global_output_stream, "; ToACME: %s", error_unknown_addressing);
|
||||
@@ -104,28 +106,32 @@ static void generate_errors(int err_bits) {
|
||||
}
|
||||
}
|
||||
|
||||
// Convert macro/label name character.
|
||||
|
||||
// convert macro/label name character.
|
||||
// AssBlaster allows '^', '[' and ']' in names, so replace these chars.
|
||||
static char conv_name_char(char byte) {
|
||||
static char conv_name_char(char byte)
|
||||
{
|
||||
byte = SCR2ISO(byte);
|
||||
switch (byte) {
|
||||
case 0x40:
|
||||
return(AB_LABELSPECIAL_NUL);
|
||||
return AB_LABELSPECIAL_NUL;
|
||||
case '[':
|
||||
return(AB_LABELSPECIAL_LEFT);
|
||||
return AB_LABELSPECIAL_LEFT;
|
||||
case '\\':
|
||||
return(AB_LABELSPECIAL_BACK);
|
||||
return AB_LABELSPECIAL_BACK;
|
||||
case ']':
|
||||
return(AB_LABELSPECIAL_RIGHT);
|
||||
return AB_LABELSPECIAL_RIGHT;
|
||||
case '^':
|
||||
return(AB_LABELSPECIAL_UP);
|
||||
return AB_LABELSPECIAL_UP;
|
||||
default:
|
||||
return(byte);
|
||||
return byte;
|
||||
}
|
||||
}
|
||||
|
||||
// Output binary representation of value
|
||||
void AB_output_binary(unsigned long int value) {
|
||||
|
||||
// output binary representation of value
|
||||
void AB_output_binary(unsigned long int value)
|
||||
{
|
||||
int mask = 128;
|
||||
|
||||
if (value > 0xff)
|
||||
@@ -137,24 +143,30 @@ void AB_output_binary(unsigned long int value) {
|
||||
}
|
||||
}
|
||||
|
||||
// Output hex representation of value
|
||||
void AB_output_hexadecimal(unsigned long int value) {
|
||||
|
||||
// output hex representation of value
|
||||
void AB_output_hexadecimal(unsigned long int value)
|
||||
{
|
||||
if (value > 0xff)
|
||||
AB_output_hexadecimal(value >> 8);
|
||||
IO_put_low_byte_hex(value);
|
||||
}
|
||||
|
||||
// Convert and send macro/label name (until illegal character comes along)
|
||||
static void pipe_global_name(void) {
|
||||
|
||||
// convert and send macro/label name (until illegal character comes along)
|
||||
static void pipe_global_name(void)
|
||||
{
|
||||
while ((GotByte < 0x20) || ((GotByte >= '0') && (GotByte <= '9'))) {
|
||||
IO_put_byte(conv_name_char(GotByte));
|
||||
IO_get_byte();
|
||||
}
|
||||
}
|
||||
|
||||
// Convert and send label name (until illegal character comes along)
|
||||
// Level 1
|
||||
static void pipe_name(void) {
|
||||
|
||||
// convert and send label name (until illegal character comes along)
|
||||
// level 1
|
||||
static void pipe_name(void)
|
||||
{
|
||||
// Dieser kleine Hack macht alle lokalen ABL-Labels
|
||||
// Auch unter ACME lokal. nur mit '^' global markierte
|
||||
// Labels werden auch global <20>bernommen ...
|
||||
@@ -165,8 +177,10 @@ static void pipe_name(void) {
|
||||
pipe_global_name(); // this does exactly what is needed
|
||||
}
|
||||
|
||||
// Parse quoted strings
|
||||
static void parse_quoted(void) {// now GotByte = unhandled opening quote
|
||||
|
||||
// parse quoted strings
|
||||
static void parse_quoted(void) // now GotByte = unhandled opening quote
|
||||
{
|
||||
IO_put_byte('"');
|
||||
IO_get_byte();
|
||||
while ((GotByte != AB_ENDOFLINE) && (GotByte != '"')) {
|
||||
@@ -174,19 +188,21 @@ static void parse_quoted(void) {// now GotByte = unhandled opening quote
|
||||
IO_get_byte();
|
||||
}
|
||||
IO_put_byte('"');
|
||||
// Closing quote is handled, but EndOfLine must remain unhandled
|
||||
// closing quote is handled, but EndOfLine must remain unhandled
|
||||
if (GotByte == '"')
|
||||
IO_get_byte();
|
||||
}
|
||||
|
||||
// Parse label names, quoted strings, operators, literal values etc.
|
||||
// Read until AB_ENDOFLINE or AB_COMMENT. Returns error bits.
|
||||
// Level 1
|
||||
|
||||
// parse label names, quoted strings, operators, literal values etc.
|
||||
// read until AB_ENDOFLINE or AB_COMMENT. Returns error bits.
|
||||
// level 1
|
||||
// AB uses a full stop character ('.') in some inconvenient places, for example
|
||||
// after macro names (at definitions and calls) and in the MVP/MVN addressing
|
||||
// mode. The kluge variable "dot_replacement" is used to replace the '.'
|
||||
// character with the correct character for ACME.
|
||||
static int parse_unspecified(char dot_replacement) {
|
||||
static int parse_unspecified(char dot_replacement)
|
||||
{
|
||||
int err_bits = 0;
|
||||
|
||||
while ((GotByte != AB_ENDOFLINE) && (GotByte != AB_COMMENT)) {
|
||||
@@ -196,36 +212,40 @@ static int parse_unspecified(char dot_replacement) {
|
||||
GotByte = dot_replacement; // use replacement
|
||||
dot_replacement = '.'; // in future, keep
|
||||
}
|
||||
if(GotByte & AB_NUMVAL_FLAGBIT)
|
||||
if (GotByte & AB_NUMVAL_FLAGBIT) {
|
||||
err_bits |= conf->number_parser();
|
||||
else {
|
||||
if(GotByte < 0x20)
|
||||
continue;
|
||||
}
|
||||
if (GotByte < 0x20) {
|
||||
pipe_name();
|
||||
else {
|
||||
if(GotByte == '"')
|
||||
continue;
|
||||
}
|
||||
if (GotByte == '"') {
|
||||
parse_quoted();
|
||||
else {
|
||||
continue;
|
||||
}
|
||||
IO_put_byte(SCR2ISO(GotByte));
|
||||
IO_get_byte();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return(err_bits);
|
||||
return err_bits;
|
||||
}
|
||||
|
||||
// Parse macro call or start of definition (beware of full stops).
|
||||
// Returns error bits.
|
||||
static int parse_macro_stuff(void) { // now GotByte = unhandled byte
|
||||
|
||||
// parse macro call or start of definition (beware of full stops).
|
||||
// returns error bits.
|
||||
static int parse_macro_stuff(void) // now GotByte = unhandled byte
|
||||
{
|
||||
// I guess local macros are useless, so don't
|
||||
// do the scope fixing as for macro names!
|
||||
pipe_global_name();
|
||||
return(parse_unspecified(SPACE)); // output macro arguments
|
||||
return parse_unspecified(SPACE); // output macro arguments
|
||||
}
|
||||
|
||||
// Process mnemonics (real opcodes). Returns error bits.
|
||||
// Level 1
|
||||
static int parse_mnemo(int mnemonic_offset) {
|
||||
|
||||
// process mnemonics (real opcodes). returns error bits.
|
||||
// level 1
|
||||
static int parse_mnemo(int mnemonic_offset)
|
||||
{
|
||||
const char *mnemonic,
|
||||
*pre,
|
||||
*post;
|
||||
@@ -262,15 +282,16 @@ static int parse_mnemo(int mnemonic_offset) {
|
||||
else
|
||||
IO_put_byte(SPACE);
|
||||
err_bits |= parse_unspecified(dot_replacement); // output arg
|
||||
if(post) {
|
||||
if (post)
|
||||
IO_put_string(post);
|
||||
}
|
||||
return(err_bits);
|
||||
return err_bits;
|
||||
}
|
||||
|
||||
// Process pseudo opcodes. Returns error bits.
|
||||
// Level 1
|
||||
static int parse_pseudo_opcode(int pseudo_offset) {
|
||||
|
||||
// process pseudo opcodes. returns error bits.
|
||||
// level 1
|
||||
static int parse_pseudo_opcode(int pseudo_offset)
|
||||
{
|
||||
const char *pseudo_opcode;
|
||||
int err_bits = 0;
|
||||
|
||||
@@ -281,24 +302,20 @@ static int parse_pseudo_opcode(int pseudo_offset) {
|
||||
IO_put_string(pseudo_opcode);
|
||||
// check for special cases
|
||||
switch (pseudo_offset) {
|
||||
|
||||
case AB_PSEUDOOFFSET_MACROCALL: // (in ACME: '+')
|
||||
// ACME does not like spaces after the macro call char
|
||||
err_bits |= parse_macro_stuff();
|
||||
break;
|
||||
|
||||
case AB_PSEUDOOFFSET_MACRODEF: // macro definition
|
||||
IO_put_byte(SPACE); // but here a space looks good :)
|
||||
err_bits |= parse_macro_stuff();
|
||||
IO_put_string(" {");
|
||||
break;
|
||||
|
||||
case AB_PSEUDOOFFSET_OUTFILE: // outfile selection
|
||||
IO_put_byte(SPACE); // but here a space looks good :)
|
||||
err_bits |= parse_unspecified('.'); // output arg(s)
|
||||
IO_put_string(ACME_cbmformat);
|
||||
break;
|
||||
|
||||
default: // all other pseudo opcodes
|
||||
if ((pseudo_opcode)
|
||||
&& (GotByte != AB_ENDOFLINE)
|
||||
@@ -306,12 +323,14 @@ static int parse_pseudo_opcode(int pseudo_offset) {
|
||||
IO_put_byte(SPACE); // but here a space looks good :)
|
||||
err_bits |= parse_unspecified('.'); // output pseudo opcode's arg(s)
|
||||
}
|
||||
return(err_bits);
|
||||
return err_bits;
|
||||
}
|
||||
|
||||
// Main routine for AssBlaster conversion (works for both AB3 and F8AB).
|
||||
// Call with first byte of first line pre-read (in GotByte)!
|
||||
void AB_main(struct ab_t* client_config) {
|
||||
|
||||
// main routine for AssBlaster conversion (works for both AB3 and F8AB).
|
||||
// call with first byte of first line pre-read (in GotByte)!
|
||||
void AB_main(struct ab *client_config)
|
||||
{
|
||||
int err_bits;
|
||||
const char *comment_indent;
|
||||
|
||||
@@ -323,22 +342,18 @@ void AB_main(struct ab_t* client_config) {
|
||||
comment_indent = "\t";
|
||||
if (GotByte < AB_FIRST_MNEMONIC) {
|
||||
switch (GotByte) {
|
||||
|
||||
case 0: // empty line
|
||||
IO_get_byte(); // skip this byte
|
||||
break;
|
||||
|
||||
case AB_COMMENT: // early comment
|
||||
comment_indent = "";
|
||||
break; // ignore now, act later
|
||||
|
||||
case AB_SPACE: // empty line or late comment
|
||||
comment_indent = "\t\t\t\t";
|
||||
IO_get_byte(); // skip this space
|
||||
// output whatever found
|
||||
err_bits |= parse_unspecified('.');
|
||||
break;
|
||||
|
||||
default: // implied label definition
|
||||
pipe_name();
|
||||
}
|
||||
@@ -371,9 +386,9 @@ void AB_main(struct ab_t* client_config) {
|
||||
|
||||
// if not at end-of-line, something's fishy
|
||||
if (GotByte != AB_ENDOFLINE) {
|
||||
if(GotByte == '\0')
|
||||
if (GotByte == '\0') {
|
||||
IO_put_string("; ToACME: found $00 - looks like end-of-file marker.");
|
||||
else {
|
||||
} else {
|
||||
fputs("Found data instead of end-of-line indicator!?.\n", stderr);
|
||||
IO_put_string("; ToACME: Garbage at end-of-line:");
|
||||
do
|
||||
|
@@ -6,11 +6,12 @@
|
||||
#ifndef ab_H
|
||||
#define ab_H
|
||||
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
||||
// Definition of "Type of AssBlaster" structure
|
||||
struct ab_t {
|
||||
struct ab {
|
||||
int (*number_parser) (void);
|
||||
const char **pseudo_opcodes;
|
||||
const char **mnemonics;
|
||||
@@ -25,7 +26,7 @@ struct ab_t {
|
||||
// meaning of internal error word. errors are collected until *after* a line
|
||||
// has been finished so the warning messages don't interfere with the generated
|
||||
// source code.
|
||||
#define AB_ERRBIT_UNKNOWN_ADDRMODE (1u)
|
||||
#define AB_ERRBIT_UNKNOWN_ADDRMODE (1u << 0)
|
||||
#define AB_ERRBIT_UNKNOWN_NUMBER_COMPRESSION (1u << 1) // SIZEMASK invalid
|
||||
#define AB_ERRBIT_UNKNOWN_NUMBER_FORMAT (1u << 2) // FORMATMASK invalid
|
||||
|
||||
@@ -33,6 +34,7 @@ struct ab_t {
|
||||
// Prototypes
|
||||
extern void AB_output_binary(unsigned long int value);
|
||||
extern void AB_output_hexadecimal(unsigned long int value);
|
||||
extern void AB_main(struct ab_t* client_config);
|
||||
extern void AB_main(struct ab *client_config);
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -14,7 +14,7 @@
|
||||
#include "scr2iso.h"
|
||||
|
||||
|
||||
// Constants
|
||||
// constants
|
||||
|
||||
#define AB3_ADDRESSING_MODES 12
|
||||
|
||||
@@ -72,6 +72,7 @@ static const char* mnemonic_table[] = {
|
||||
MnemonicTXA, MnemonicTXS, MnemonicTYA, // $c5-$c7
|
||||
};
|
||||
|
||||
|
||||
// PseudoOpcode table in AssBlaster 3.x order
|
||||
static const char *pseudo_opcode_table[] = {
|
||||
#define AB3_FIRST_PSEUDO_OPCODE 0xc8
|
||||
@@ -94,19 +95,21 @@ static const char* pseudo_opcode_table[] = {
|
||||
// 0xd5-0xfe are unused in AB3
|
||||
};
|
||||
|
||||
// Parse AssBlaster's packed number format. Returns error bits.
|
||||
|
||||
// parse AssBlaster's packed number format. returns error bits.
|
||||
//#define AB_NUMVAL_FLAGBIT 0x80 // 10000000 indicates packed number
|
||||
#define AB3_NUMVAL_ADD_1 0x40 // 01000000
|
||||
#define AB3_NUMVAL_ADD_256 0x20 // 00100000
|
||||
#define AB3_NUMVAL_FORMATMASK 0x1a // 00011010
|
||||
#define AB3_NUMVAL__FORMAT_HEX 0x10 // 00010000=16 (oh my god, the base is
|
||||
#define AB3_NUMVAL__FORMAT_HEX 0x10 // 00010000=16 (oh bob, the base is
|
||||
#define AB3_NUMVAL__FORMAT_DEC 0x0a // 00001010=10 given directly, without
|
||||
#define AB3_NUMVAL__FORMAT_BIN 0x02 // 00000010= 2 any encoding... :))
|
||||
#define AB3_NUMVAL_SIZEMASK 0x05 // 00000101
|
||||
#define AB3_NUMVAL__SIZE_0 0x01 // 00000001
|
||||
#define AB3_NUMVAL__SIZE_1 0x04 // 00000100
|
||||
#define AB3_NUMVAL__SIZE_2 0x00 // 00000000
|
||||
static int parse_number(void) { // now GotByte = first byte of packed number
|
||||
static int parse_number(void) // now GotByte = first byte of packed number
|
||||
{
|
||||
int flags = GotByte,
|
||||
err_bits = 0;
|
||||
unsigned long int value = 0,
|
||||
@@ -118,19 +121,15 @@ static int parse_number(void) { // now GotByte = first byte of packed number
|
||||
if (flags & AB3_NUMVAL_ADD_256)
|
||||
add += 256;
|
||||
switch (flags & AB3_NUMVAL_SIZEMASK) {
|
||||
|
||||
case AB3_NUMVAL__SIZE_0: // no bytes follow (0, 1, 256, 257)
|
||||
value = add;
|
||||
break;
|
||||
|
||||
case AB3_NUMVAL__SIZE_1: // one byte follows (2 to 511)
|
||||
value = add + IO_get_byte();
|
||||
break;
|
||||
|
||||
case AB3_NUMVAL__SIZE_2: // two bytes follow (512 to 65535)
|
||||
value = add + IO_get_le16();
|
||||
break;
|
||||
|
||||
default: // unknown number compression
|
||||
// remember to generate error
|
||||
err_bits |= AB_ERRBIT_UNKNOWN_NUMBER_COMPRESSION;
|
||||
@@ -140,31 +139,28 @@ static int parse_number(void) { // now GotByte = first byte of packed number
|
||||
|
||||
// decode output format
|
||||
switch (flags & AB3_NUMVAL_FORMATMASK) {
|
||||
|
||||
case AB3_NUMVAL__FORMAT_BIN:
|
||||
IO_put_byte('%');
|
||||
AB_output_binary(value);
|
||||
break;
|
||||
|
||||
case AB3_NUMVAL__FORMAT_DEC:
|
||||
fprintf(global_output_stream, "%lu", value);
|
||||
break;
|
||||
|
||||
case AB3_NUMVAL__FORMAT_HEX:
|
||||
hex_fallback: IO_put_byte('$');
|
||||
AB_output_hexadecimal(value);
|
||||
break;
|
||||
|
||||
default: // unknown output format
|
||||
// remember to warn
|
||||
err_bits |= AB_ERRBIT_UNKNOWN_NUMBER_FORMAT;
|
||||
goto hex_fallback;
|
||||
}
|
||||
return(err_bits);
|
||||
return err_bits;
|
||||
}
|
||||
|
||||
|
||||
// config struct for shared ab code
|
||||
struct ab_t ab3_conf = {
|
||||
struct ab ab3_conf = {
|
||||
parse_number,
|
||||
pseudo_opcode_table,
|
||||
mnemonic_table,
|
||||
@@ -174,8 +170,10 @@ struct ab_t ab3_conf = {
|
||||
AB3_FIRST_UNUSED_CODE,
|
||||
};
|
||||
|
||||
|
||||
// main
|
||||
void ab3_main(void) {
|
||||
void ab3_main(void)
|
||||
{
|
||||
IO_set_input_padding(AB_ENDOFLINE);
|
||||
IO_put_string(
|
||||
"; ToACME: Adding pseudo opcode to enable undocumented (\"illegal\") opcodes:\n"
|
||||
@@ -192,7 +190,8 @@ void ab3_main(void) {
|
||||
if (IO_get_byte() == AB_ENDOFLINE) {
|
||||
IO_get_byte(); // skip it and pre-read first valid byte
|
||||
fputs("Input has AB3 header.\n", stderr);
|
||||
} else
|
||||
} else {
|
||||
fputs("Input does not have any known AB3 header.\n", stderr);
|
||||
}
|
||||
AB_main(&ab3_conf);
|
||||
}
|
||||
|
@@ -8,9 +8,9 @@
|
||||
#include "io.h"
|
||||
|
||||
|
||||
// Constants
|
||||
// constants
|
||||
|
||||
// Pseudo opcodes
|
||||
// pseudo opcodes
|
||||
const char ACME_po_to[] = "!to";
|
||||
const char ACME_cbmformat[] = ", cbm";
|
||||
const char ACME_po_sl[] = "!sl";
|
||||
@@ -28,17 +28,18 @@ const char ACME_po_if[] = "!if";
|
||||
const char ACME_else[] = "} else {";
|
||||
const char ACME_endif[] = "}; (end of conditional assembly)\n";
|
||||
const char ACME_po_eof[] = "!eof";
|
||||
// Pseudo opcodes for 65816 (used by Flash8-AssBlaster)
|
||||
// pseudo opcodes for 65816 (used by Flash8-AssBlaster)
|
||||
const char ACME_po_al[] = "!al";
|
||||
const char ACME_po_as[] = "!as";
|
||||
const char ACME_po_rl[] = "!rl";
|
||||
const char ACME_po_rs[] = "!rs";
|
||||
|
||||
|
||||
// Functions
|
||||
// functions
|
||||
|
||||
// Output pseudo opcode to make ACME use PetSCII encoding
|
||||
void ACME_switch_to_pet(void) {
|
||||
// output pseudo opcode to make ACME use PetSCII encoding
|
||||
void ACME_switch_to_pet(void)
|
||||
{
|
||||
IO_put_string(
|
||||
"; ToACME: Adding pseudo opcode to use PetSCII encoding by default:\n"
|
||||
"!convtab pet\n"
|
||||
|
@@ -7,7 +7,7 @@
|
||||
#define acme_H
|
||||
|
||||
|
||||
// Constants
|
||||
// constants
|
||||
|
||||
// pseudo opcodes and related keywords
|
||||
extern const char ACME_po_to[];
|
||||
@@ -34,7 +34,7 @@ extern const char ACME_po_rl[];
|
||||
extern const char ACME_po_rs[];
|
||||
|
||||
|
||||
// Prototypes
|
||||
// prototypes
|
||||
extern void ACME_switch_to_pet(void);
|
||||
|
||||
|
||||
|
@@ -8,7 +8,7 @@
|
||||
#define config_H
|
||||
|
||||
|
||||
// Constants
|
||||
// constants
|
||||
#define SPACE 0x20
|
||||
#define SHIFTSPACE 0xa0
|
||||
|
||||
@@ -18,4 +18,5 @@ typedef int bool;
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -14,11 +14,11 @@
|
||||
#include "scr2iso.h"
|
||||
|
||||
|
||||
// Constants
|
||||
// constants
|
||||
|
||||
#define F8AB_ADDRESSING_MODES 23 // (FIXME - check back later!)
|
||||
|
||||
// Mnemonic table in Flash8-AssBlaster order (without: JML, WDM)
|
||||
// mnemonic table in Flash8-AssBlaster order (without: JML, WDM)
|
||||
static const char *mnemonic_table[] = {
|
||||
MnemonicADC, // $80 6502
|
||||
MnemonicAND, // $81 6502
|
||||
@@ -116,6 +116,7 @@ static const char* mnemonic_table[] = {
|
||||
MnemonicXCE, // $db 65816
|
||||
};
|
||||
|
||||
|
||||
// PseudoOpcode table in Flash8-AssBlaster order
|
||||
static const char *pseudo_opcode_table[] = {
|
||||
#define F8AB_FIRST_PSEUDO_OPCODE 0xdc
|
||||
@@ -145,7 +146,8 @@ static const char* pseudo_opcode_table[] = {
|
||||
// (FIXME - true? I only checked 0xed)
|
||||
};
|
||||
|
||||
// Parse AssBlaster's packed number format. Returns error bits.
|
||||
|
||||
// parse AssBlaster's packed number format. returns error bits.
|
||||
//#define AB_NUMVAL_FLAGBIT 0x80 // 10000000 indicates packed number
|
||||
#define F8AB_NUMVAL_ADD_65536 0x40 // 01000000
|
||||
#define F8AB_NUMVAL_ADD_256 0x20 // 00100000
|
||||
@@ -160,7 +162,8 @@ static const char* pseudo_opcode_table[] = {
|
||||
#define F8AB_NUMVAL__SIZE_1 0x01 // 00000001
|
||||
#define F8AB_NUMVAL__SIZE_2 0x02 // 00000010
|
||||
#define F8AB_NUMVAL__SIZE_3 0x03 // 00000011
|
||||
static int parse_number(void) { // now GotByte = first byte of packed number
|
||||
static int parse_number(void) // now GotByte = first byte of packed number
|
||||
{
|
||||
int flags = GotByte,
|
||||
err_bits = 0;
|
||||
unsigned long int value = 0,
|
||||
@@ -174,53 +177,45 @@ static int parse_number(void) { // now GotByte = first byte of packed number
|
||||
if (flags & F8AB_NUMVAL_ADD_1)
|
||||
add += 1;
|
||||
switch (flags & F8AB_NUMVAL_SIZEMASK) {
|
||||
|
||||
case F8AB_NUMVAL__SIZE_0: // no bytes follow (0, 1, 256, 257)
|
||||
value = add;
|
||||
break;
|
||||
|
||||
case F8AB_NUMVAL__SIZE_1: // one byte follows (2 to 511)
|
||||
value = add + IO_get_byte();
|
||||
break;
|
||||
|
||||
case F8AB_NUMVAL__SIZE_2: // two bytes follow (512 to 65535)
|
||||
value = add + IO_get_le16();
|
||||
break;
|
||||
|
||||
case F8AB_NUMVAL__SIZE_3: // three bytes follow (anything else)
|
||||
value = add + IO_get_le24();
|
||||
|
||||
}
|
||||
// continue parsing on next byte
|
||||
IO_get_byte();
|
||||
|
||||
// decode output format
|
||||
switch (flags & F8AB_NUMVAL_FORMATMASK) {
|
||||
|
||||
case F8AB_NUMVAL__FORMAT_BIN:
|
||||
IO_put_byte('%');
|
||||
AB_output_binary(value);
|
||||
break;
|
||||
|
||||
case F8AB_NUMVAL__FORMAT_DEC:
|
||||
fprintf(global_output_stream, "%lu", value);
|
||||
break;
|
||||
|
||||
case F8AB_NUMVAL__FORMAT_HEX:
|
||||
hex_fallback: IO_put_byte('$');
|
||||
AB_output_hexadecimal(value);
|
||||
break;
|
||||
|
||||
default: // unknown output format
|
||||
// remember to warn
|
||||
err_bits |= AB_ERRBIT_UNKNOWN_NUMBER_FORMAT;
|
||||
goto hex_fallback;
|
||||
}
|
||||
return(err_bits);
|
||||
return err_bits;
|
||||
}
|
||||
|
||||
|
||||
// config struct for shared ab code
|
||||
struct ab_t f8ab_conf = {
|
||||
struct ab f8ab_conf = {
|
||||
parse_number,
|
||||
pseudo_opcode_table,
|
||||
mnemonic_table,
|
||||
@@ -230,6 +225,7 @@ struct ab_t f8ab_conf = {
|
||||
F8AB_FIRST_UNUSED_CODE,
|
||||
};
|
||||
|
||||
|
||||
// main
|
||||
void f8ab_main(void) {
|
||||
const char *header_message;
|
||||
|
@@ -13,7 +13,7 @@
|
||||
#include "pet2iso.h"
|
||||
|
||||
|
||||
// Constants
|
||||
// constants
|
||||
|
||||
// token-to-(pseudo)opcode conversion table (FIXME)
|
||||
const char *giga_token[] = {
|
||||
@@ -118,15 +118,16 @@ const char* giga_token[] = {
|
||||
};
|
||||
|
||||
|
||||
// Functions
|
||||
// functions
|
||||
|
||||
// I don't know whether it's correct, but I had to start somewhere
|
||||
#define FIRST_TOKEN 0xa0
|
||||
#define MACRO_DEF_TOKEN 0xa1 // ugly kluge to add '{' at end of statement
|
||||
#define MACRO_TEXT 0xa8 // ugly kluge for giga string specialties
|
||||
#define MACRO_OUTFILE 0xa9 // ugly kluge for adding outfile format
|
||||
// Process opcode or pseudo opcode (tokenized)
|
||||
static int process_tokenized(void) {
|
||||
// process opcode or pseudo opcode (tokenized)
|
||||
static int process_tokenized(void)
|
||||
{
|
||||
const char *token;
|
||||
int flags = 0;
|
||||
|
||||
@@ -136,18 +137,14 @@ static int process_tokenized(void) {
|
||||
// fprintf(global_output_stream, "small value:$%x", GotByte);
|
||||
} else {
|
||||
switch (GotByte) {
|
||||
|
||||
case MACRO_DEF_TOKEN:
|
||||
flags |= FLAG_ADD_LEFT_BRACE;
|
||||
break;
|
||||
|
||||
case MACRO_TEXT:
|
||||
flags |= FLAG_ADD_ZERO | FLAG_CHANGE_LEFTARROW;
|
||||
break;
|
||||
|
||||
case MACRO_OUTFILE:
|
||||
flags |= FLAG_ADD_CBM;
|
||||
|
||||
}
|
||||
flags |= FLAG_INSERT_SPACE;
|
||||
token = giga_token[GotByte - FIRST_TOKEN];
|
||||
@@ -155,15 +152,17 @@ static int process_tokenized(void) {
|
||||
IO_put_string(token);
|
||||
IO_get_byte();
|
||||
}
|
||||
return(flags);
|
||||
return flags;
|
||||
}
|
||||
|
||||
|
||||
// When tokens are known, maybe use the PseudoOpcode function from hypra?
|
||||
// ...for now deleted
|
||||
// [...]
|
||||
|
||||
// Main routine for GigaAss conversion
|
||||
void giga_main(void) {
|
||||
// main routine for GigaAss conversion
|
||||
void giga_main(void)
|
||||
{
|
||||
int indent;
|
||||
|
||||
IO_set_input_padding(0);
|
||||
|
@@ -11,7 +11,8 @@
|
||||
|
||||
|
||||
// called with GotByte == ';'
|
||||
void GigaHypra_comment(void) {
|
||||
void GigaHypra_comment(void)
|
||||
{
|
||||
// check whether anything follows (empty comments => empty lines)
|
||||
if (IO_get_byte()) {
|
||||
IO_put_byte(';');
|
||||
@@ -21,38 +22,33 @@ void GigaHypra_comment(void) {
|
||||
}
|
||||
}
|
||||
|
||||
// Process operator
|
||||
void GigaHypra_operator(void) {// '!' was last read
|
||||
|
||||
// process operator
|
||||
void GigaHypra_operator(void) // '!' was last read
|
||||
{
|
||||
char middle = PET2ISO(IO_get_byte());
|
||||
|
||||
if ((middle != ';') && (middle != '\0')) {
|
||||
if (IO_get_byte() == '!') {
|
||||
switch (middle) {
|
||||
|
||||
case 'n':
|
||||
IO_put_byte('!');
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
IO_put_byte('|');
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
IO_put_byte('&');
|
||||
break;
|
||||
|
||||
case '=':
|
||||
IO_put_byte('=');
|
||||
break;
|
||||
|
||||
case '<':
|
||||
IO_put_string(" < ");
|
||||
break;
|
||||
|
||||
case '>':
|
||||
IO_put_string(" > ");
|
||||
break;
|
||||
|
||||
default:
|
||||
IO_put_byte('!');
|
||||
IO_put_byte(middle);
|
||||
@@ -63,20 +59,25 @@ void GigaHypra_operator(void) {// '!' was last read
|
||||
IO_put_byte('!');
|
||||
IO_put_byte(middle);
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
IO_put_byte('!');
|
||||
}
|
||||
// exit with unused byte pre-read
|
||||
}
|
||||
|
||||
|
||||
// output one or two TABs
|
||||
void GigaHypra_indent(int indent) {
|
||||
void GigaHypra_indent(int indent)
|
||||
{
|
||||
if (indent < 8)
|
||||
IO_put_byte('\t');
|
||||
IO_put_byte('\t');
|
||||
}
|
||||
|
||||
|
||||
// Process opcode and arguments
|
||||
void GigaHypra_argument(int flags) {
|
||||
void GigaHypra_argument(int flags)
|
||||
{
|
||||
int paren = 0; // number of open parentheses (to close)
|
||||
|
||||
// if needed, add separating space between opcode and argument
|
||||
@@ -109,7 +110,6 @@ void GigaHypra_argument(int flags) {
|
||||
} else {
|
||||
// most characters go here
|
||||
switch (GotByte) {
|
||||
|
||||
case '(':
|
||||
if (flags & FLAG_SKIP_OPENING) {
|
||||
flags &= ~FLAG_SKIP_OPENING;
|
||||
@@ -119,23 +119,19 @@ void GigaHypra_argument(int flags) {
|
||||
IO_put_byte(PET2ISO(GotByte));
|
||||
}
|
||||
break;
|
||||
|
||||
case ')':
|
||||
if((flags & FLAG_SKIP_CLOSING) && (paren == 0))
|
||||
if ((flags & FLAG_SKIP_CLOSING) && (paren == 0)) {
|
||||
flags &= ~FLAG_SKIP_CLOSING;
|
||||
else {
|
||||
} else {
|
||||
paren--;
|
||||
IO_put_byte(PET2ISO(GotByte));
|
||||
}
|
||||
break;
|
||||
|
||||
case SHIFTSPACE:
|
||||
IO_put_byte(SPACE);
|
||||
break;
|
||||
|
||||
default:
|
||||
IO_put_byte(PET2ISO(GotByte));
|
||||
|
||||
}
|
||||
IO_get_byte();
|
||||
}
|
||||
@@ -146,9 +142,11 @@ void GigaHypra_argument(int flags) {
|
||||
IO_put_byte('{');
|
||||
}
|
||||
|
||||
// Convert and send label name.
|
||||
// Returns length (for proper indentation).
|
||||
int GigaHypra_label_definition(void) {
|
||||
|
||||
// convert and send label name.
|
||||
// returns length (for proper indentation).
|
||||
int GigaHypra_label_definition(void)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
do {
|
||||
@@ -156,5 +154,5 @@ int GigaHypra_label_definition(void) {
|
||||
count++;
|
||||
IO_get_byte();
|
||||
} while ((GotByte != SPACE) && (GotByte != ';') && (GotByte != '\0'));
|
||||
return(count);
|
||||
return count;
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@
|
||||
#ifndef gigahypra_H
|
||||
#define gigahypra_H
|
||||
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
||||
|
@@ -12,10 +12,11 @@
|
||||
#include "pet2iso.h"
|
||||
|
||||
|
||||
// Functions
|
||||
// functions
|
||||
|
||||
// complain about unknown pseudo opcodes
|
||||
static void complain(char a, char b) {
|
||||
static void complain(char a, char b)
|
||||
{
|
||||
IO_put_string("; ToACME: .");
|
||||
if (a)
|
||||
IO_put_byte(a);
|
||||
@@ -24,83 +25,77 @@ static void complain(char a, char b) {
|
||||
IO_put_string(" cannot be converted\n");
|
||||
}
|
||||
|
||||
|
||||
// handle ".ba" and ".by"
|
||||
static int process_po_b(char second) {
|
||||
static int process_po_b(char second)
|
||||
{
|
||||
int flags = 0;
|
||||
|
||||
switch (second) {
|
||||
|
||||
case 'a': // ".ba" = set base address
|
||||
IO_put_string(ACME_set_pc);
|
||||
break;
|
||||
|
||||
case 'y': // ".by" = insert bytes
|
||||
IO_put_string(ACME_po_byte);
|
||||
flags |= FLAG_INSERT_SPACE;
|
||||
break;
|
||||
|
||||
default:
|
||||
complain('b', second);
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
}
|
||||
return(flags);
|
||||
}
|
||||
|
||||
// handle ".ei", ".el", ".en" and ".eq"
|
||||
static int process_po_e(char second) {
|
||||
static int process_po_e(char second)
|
||||
{
|
||||
int flags = 0;
|
||||
|
||||
switch (second) {
|
||||
|
||||
case 'i': // ".ei" = endif
|
||||
IO_put_string(ACME_endif);
|
||||
break;
|
||||
|
||||
case 'l': // ".el" = else
|
||||
IO_put_string(ACME_else);
|
||||
break;
|
||||
|
||||
case 'n': // ".en" = end
|
||||
IO_put_string(ACME_po_eof);
|
||||
flags |= FLAG_INSERT_SPACE;
|
||||
break;
|
||||
|
||||
case 'q': // ".eq" = label def
|
||||
break;
|
||||
|
||||
default:
|
||||
complain('e', second);
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
}
|
||||
return(flags);
|
||||
}
|
||||
|
||||
// handle ".tx" and ".ts"
|
||||
static int process_po_t(char second) {
|
||||
static int process_po_t(char second)
|
||||
{
|
||||
int flags = 0;
|
||||
|
||||
switch (second) {
|
||||
|
||||
case 'x': // ".tx" = insert string
|
||||
IO_put_string(ACME_po_pet);
|
||||
flags |= FLAG_INSERT_SPACE;
|
||||
break;
|
||||
|
||||
case 's': // ".ts" = screen code string
|
||||
IO_put_string(ACME_po_scr);
|
||||
flags |= FLAG_INSERT_SPACE;
|
||||
break;
|
||||
|
||||
default:
|
||||
complain('t', second);
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
}
|
||||
return(flags);
|
||||
}
|
||||
|
||||
#define ARE(a, b) ((first == a) && (second == b))
|
||||
// Process pseudo opcode
|
||||
static int process_pseudo_opcode(void) {// '.' was last read
|
||||
// process pseudo opcode
|
||||
static int process_pseudo_opcode(void) // '.' was last read
|
||||
{
|
||||
int first,
|
||||
second;
|
||||
|
||||
@@ -108,47 +103,50 @@ static int process_pseudo_opcode(void) {// '.' was last read
|
||||
first = PET2ISO(IO_get_byte());
|
||||
if ((first == SPACE) || (first == ';') || (first == '\0')) {
|
||||
complain(first, '\0');
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
// get second byte. if illegal, complain and exit immediately
|
||||
second = PET2ISO(IO_get_byte());
|
||||
if ((second == SPACE) || (second == ';') || (second == '\0')) {
|
||||
complain(first, second);
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
IO_get_byte();// pre-read unused byte
|
||||
// check pseudo opcodes (switch/case was actually harder to read)
|
||||
if (first == 'b') { // handle ".ba" and ".by"
|
||||
process_po_b(second);
|
||||
return(FLAG_INSERT_SPACE);
|
||||
return FLAG_INSERT_SPACE;
|
||||
}
|
||||
if (first == 'e') // handle ".ei", ".el", ".en" and ".eq"
|
||||
return(process_po_e(second));
|
||||
return process_po_e(second);
|
||||
|
||||
if (first == 't') // handle ".tx" and ".ts"
|
||||
return(process_po_t(second));
|
||||
return process_po_t(second);
|
||||
|
||||
if (ARE('.', '.')) { // "..." = macro call
|
||||
IO_put_string(ACME_macro_call);
|
||||
return(FLAG_INSERT_SPACE | FLAG_SKIP_OPENING);
|
||||
return FLAG_INSERT_SPACE | FLAG_SKIP_OPENING;
|
||||
}
|
||||
if (ARE('m', 'a')) { // ".ma" = macro definition
|
||||
IO_put_string(ACME_po_macro);
|
||||
return(FLAG_INSERT_SPACE|FLAG_SKIP_OPENING|FLAG_ADD_LEFT_BRACE);
|
||||
return FLAG_INSERT_SPACE | FLAG_SKIP_OPENING | FLAG_ADD_LEFT_BRACE;
|
||||
}
|
||||
if (ARE('o', 'b')) { // ".ob" = output to file
|
||||
IO_put_string(ACME_po_to);
|
||||
return(FLAG_INSERT_SPACE | FLAG_ADD_CBM);
|
||||
return FLAG_INSERT_SPACE | FLAG_ADD_CBM;
|
||||
}
|
||||
if (ARE('s', 'y')) { // ".sy" = symbol dump
|
||||
IO_put_string(ACME_po_sl);
|
||||
IO_put_string("\"symboldump.txt\";");
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
if (ARE('i', 'f')) { // ".if" = cond. assembly
|
||||
IO_put_string(ACME_po_if);
|
||||
return(FLAG_INSERT_SPACE | FLAG_ADD_LEFT_BRACE);
|
||||
return FLAG_INSERT_SPACE | FLAG_ADD_LEFT_BRACE;
|
||||
}
|
||||
if (ARE('g', 'l')) // ".gl" = global label def
|
||||
return(0);
|
||||
return 0;
|
||||
|
||||
if (ARE('a', 'p')) // ".ap" = append source
|
||||
IO_put_string(ACME_po_source);
|
||||
else if (ARE('r', 't')) // ".rt" = end of macro def
|
||||
@@ -157,26 +155,31 @@ static int process_pseudo_opcode(void) {// '.' was last read
|
||||
IO_put_string(ACME_po_word);
|
||||
else
|
||||
complain(first, second);
|
||||
return(FLAG_INSERT_SPACE);
|
||||
return FLAG_INSERT_SPACE;
|
||||
}
|
||||
|
||||
// Process opcode
|
||||
static void real_opcode(void) {// character was last read
|
||||
|
||||
// process opcode
|
||||
static void real_opcode(void) // character was last read
|
||||
{
|
||||
IO_put_byte(PET2ISO(GotByte));
|
||||
IO_get_byte();
|
||||
if ((GotByte == SPACE) || (GotByte == ';') || (GotByte == '\0'))
|
||||
return;
|
||||
|
||||
IO_put_byte(PET2ISO(GotByte));
|
||||
IO_get_byte();
|
||||
if ((GotByte == SPACE) || (GotByte == ';') || (GotByte == '\0'))
|
||||
return;
|
||||
|
||||
IO_put_byte(PET2ISO(GotByte));
|
||||
IO_get_byte(); // exit with unused byte pre-read
|
||||
return;
|
||||
}
|
||||
|
||||
// Main routine for HypraAss conversion
|
||||
void hypra_main(void) {
|
||||
|
||||
// main routine for HypraAss conversion
|
||||
void hypra_main(void)
|
||||
{
|
||||
int indent;
|
||||
|
||||
IO_set_input_padding(0);
|
||||
@@ -200,9 +203,9 @@ void hypra_main(void) {
|
||||
if ((GotByte != ';') && (GotByte != '\0')) {
|
||||
GigaHypra_indent(indent);
|
||||
// branch to relevant routine
|
||||
if(GotByte == '.')
|
||||
if (GotByte == '.') {
|
||||
GigaHypra_argument(process_pseudo_opcode());
|
||||
else {
|
||||
} else {
|
||||
real_opcode();
|
||||
GigaHypra_argument(FLAG_INSERT_SPACE);
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@
|
||||
#include "io.h"
|
||||
|
||||
|
||||
// Variables
|
||||
// variables
|
||||
int padding_value;
|
||||
FILE *global_input_stream;
|
||||
FILE *global_output_stream;
|
||||
@@ -17,78 +17,98 @@ int GotByte = 0;
|
||||
bool IO_reached_eof = FALSE;
|
||||
|
||||
|
||||
// Input functions
|
||||
// input functions
|
||||
|
||||
// Set byte sent after EOF
|
||||
inline void IO_set_input_padding(int pad) {
|
||||
|
||||
// set byte sent after EOF
|
||||
inline void IO_set_input_padding(int pad)
|
||||
{
|
||||
padding_value = pad;
|
||||
}
|
||||
|
||||
// Fetch and buffer byte
|
||||
int IO_get_byte(void) {
|
||||
|
||||
// fetch and buffer byte
|
||||
int IO_get_byte(void)
|
||||
{
|
||||
int w;
|
||||
|
||||
if(IO_reached_eof)
|
||||
if (IO_reached_eof) {
|
||||
GotByte = padding_value;
|
||||
else {
|
||||
} else {
|
||||
w = getc(global_input_stream);
|
||||
if (w == EOF)
|
||||
IO_reached_eof = TRUE;
|
||||
GotByte = w;
|
||||
}
|
||||
return(GotByte);
|
||||
return GotByte;
|
||||
}
|
||||
|
||||
// Read little-endian 16-bit value
|
||||
unsigned int IO_get_le16(void) {
|
||||
|
||||
// read little-endian 16-bit value
|
||||
unsigned int IO_get_le16(void)
|
||||
{
|
||||
unsigned int result = IO_get_byte();
|
||||
|
||||
// CAUTION! using
|
||||
// return(IO_get_byte() | (IO_get_byte() << 8));
|
||||
// would be compiler-dependent
|
||||
return(result | (IO_get_byte() << 8));
|
||||
return result | (IO_get_byte() << 8);
|
||||
}
|
||||
|
||||
// Read little-endian 24-bit value
|
||||
unsigned int IO_get_le24(void) {
|
||||
|
||||
// read little-endian 24-bit value
|
||||
unsigned int IO_get_le24(void)
|
||||
{
|
||||
unsigned int result = IO_get_le16();
|
||||
|
||||
// CAUTION! see above
|
||||
return(result | (IO_get_byte() << 16));
|
||||
return result | (IO_get_byte() << 16);
|
||||
}
|
||||
|
||||
|
||||
// Output functions
|
||||
// output functions
|
||||
|
||||
|
||||
// output string
|
||||
inline void IO_put_string(const char string[]) {
|
||||
inline void IO_put_string(const char string[])
|
||||
{
|
||||
fputs(string, global_output_stream);
|
||||
}
|
||||
|
||||
// Write byte to output file
|
||||
inline void IO_put_byte(char b) {
|
||||
|
||||
// write byte to output file
|
||||
inline void IO_put_byte(char b)
|
||||
{
|
||||
putc(b, global_output_stream);
|
||||
}
|
||||
|
||||
|
||||
// output low nibble of argument as hexadecimal digit
|
||||
static void put_low_nibble_hex(int v) {
|
||||
static void put_low_nibble_hex(int v)
|
||||
{
|
||||
putc("0123456789abcdef"[v & 15], global_output_stream);
|
||||
}
|
||||
|
||||
|
||||
// output low byte of argument as two hexadecimal digits
|
||||
void IO_put_low_byte_hex(int v) {
|
||||
void IO_put_low_byte_hex(int v)
|
||||
{
|
||||
put_low_nibble_hex(v >> 4);
|
||||
put_low_nibble_hex(v);
|
||||
}
|
||||
|
||||
|
||||
// output low 16 bits of arg as four hexadecimal digits
|
||||
void IO_put_low_16b_hex(int w) {
|
||||
void IO_put_low_16b_hex(int w)
|
||||
{
|
||||
IO_put_low_byte_hex(w >> 8);
|
||||
IO_put_low_byte_hex(w);
|
||||
}
|
||||
|
||||
|
||||
// read load address from input file and write as comment to output file
|
||||
void IO_process_load_address(void) {
|
||||
void IO_process_load_address(void)
|
||||
{
|
||||
int load_address;
|
||||
|
||||
load_address = IO_get_le16();
|
||||
|
@@ -6,18 +6,19 @@
|
||||
#ifndef io_H
|
||||
#define io_H
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include "config.h"
|
||||
|
||||
|
||||
// Variables
|
||||
// variables
|
||||
extern int GotByte;
|
||||
extern bool IO_reached_eof;
|
||||
extern FILE *global_input_stream;
|
||||
extern FILE *global_output_stream;
|
||||
|
||||
|
||||
// Prototypes
|
||||
// prototypes
|
||||
extern void IO_set_input_padding(int);
|
||||
extern int IO_get_byte(void);
|
||||
extern unsigned int IO_get_le16(void); // get little-endian 16-bit value
|
||||
|
@@ -1,5 +1,5 @@
|
||||
// ToACME - converts other source codes to ACME format.
|
||||
// Copyright (C) 1999-2006 Marco Baye
|
||||
// Copyright (C) 1999-2012 Marco Baye
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
@@ -26,8 +26,9 @@
|
||||
#include "version.h"
|
||||
|
||||
|
||||
// Guess what
|
||||
int main(int argc, char *argv[]) {
|
||||
// guess what
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// handle "toacme -h" and "toacme --help" just like "toacme"
|
||||
if (argc == 2) {
|
||||
if ((strcmp(argv[1], "-h") == 0)
|
||||
@@ -37,34 +38,34 @@ int main(int argc, char *argv[]) {
|
||||
// "toacme" without any switches gives info and exits successfully
|
||||
if (argc == 1) {
|
||||
version_show_info(argv[0]);
|
||||
return(EXIT_SUCCESS);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
// check argument count
|
||||
if (argc != 4) {
|
||||
fputs("Wrong number of arguments.\n", stderr);
|
||||
return(EXIT_FAILURE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// check format id
|
||||
if (version_parse_id(argv[1])) {
|
||||
fputs("Unknown format id.\n", stderr);
|
||||
return(EXIT_FAILURE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// be nice and ensure input and output are different
|
||||
if (strcmp(argv[2], argv[3]) == 0) {
|
||||
fputs("Input and output files must be different.\n", stderr);
|
||||
return(EXIT_FAILURE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// try to open input file
|
||||
global_input_stream = fopen(argv[2], "rb");
|
||||
if (global_input_stream == NULL) {
|
||||
fputs("Cannot open input file.\n", stderr);
|
||||
return(EXIT_FAILURE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// try to open output file
|
||||
global_output_stream = fopen(argv[3], "w");
|
||||
if (global_output_stream == NULL) {
|
||||
fputs("Cannot open output file.\n", stderr);
|
||||
return(EXIT_FAILURE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// do the actual work
|
||||
version_main();
|
||||
@@ -72,5 +73,5 @@ int main(int argc, char *argv[]) {
|
||||
fclose(global_output_stream);
|
||||
PLATFORM_SETFILETYPE_TEXT(argv[3]);
|
||||
fclose(global_input_stream);
|
||||
return(EXIT_SUCCESS);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
@@ -4,117 +4,118 @@
|
||||
//
|
||||
// assembler mnemonics
|
||||
|
||||
// Mnemonics of legal 6502 instructions
|
||||
const char MnemonicADC[] = "adc";
|
||||
const char MnemonicAND[] = "and";
|
||||
const char MnemonicASL[] = "asl";
|
||||
const char MnemonicBCC[] = "bcc";
|
||||
const char MnemonicBCS[] = "bcs";
|
||||
const char MnemonicBEQ[] = "beq";
|
||||
const char MnemonicBIT[] = "bit";
|
||||
const char MnemonicBMI[] = "bmi";
|
||||
const char MnemonicBNE[] = "bne";
|
||||
const char MnemonicBPL[] = "bpl";
|
||||
const char MnemonicBRK[] = "brk";
|
||||
const char MnemonicBVC[] = "bvc";
|
||||
const char MnemonicBVS[] = "bvs";
|
||||
const char MnemonicCLC[] = "clc";
|
||||
const char MnemonicCLD[] = "cld";
|
||||
const char MnemonicCLI[] = "cli";
|
||||
const char MnemonicCLV[] = "clv";
|
||||
const char MnemonicCMP[] = "cmp";
|
||||
const char MnemonicCPX[] = "cpx";
|
||||
const char MnemonicCPY[] = "cpy";
|
||||
const char MnemonicDEC[] = "dec";
|
||||
const char MnemonicDEX[] = "dex";
|
||||
const char MnemonicDEY[] = "dey";
|
||||
const char MnemonicEOR[] = "eor";
|
||||
const char MnemonicINC[] = "inc";
|
||||
const char MnemonicINX[] = "inx";
|
||||
const char MnemonicINY[] = "iny";
|
||||
const char MnemonicJMP[] = "jmp";
|
||||
const char MnemonicJSR[] = "jsr";
|
||||
const char MnemonicLDA[] = "lda";
|
||||
const char MnemonicLDX[] = "ldx";
|
||||
const char MnemonicLDY[] = "ldy";
|
||||
const char MnemonicLSR[] = "lsr";
|
||||
const char MnemonicNOP[] = "nop";
|
||||
const char MnemonicORA[] = "ora";
|
||||
const char MnemonicPHA[] = "pha";
|
||||
const char MnemonicPHP[] = "php";
|
||||
const char MnemonicPLA[] = "pla";
|
||||
const char MnemonicPLP[] = "plp";
|
||||
const char MnemonicROL[] = "rol";
|
||||
const char MnemonicROR[] = "ror";
|
||||
const char MnemonicRTI[] = "rti";
|
||||
const char MnemonicRTS[] = "rts";
|
||||
const char MnemonicSBC[] = "sbc";
|
||||
const char MnemonicSEC[] = "sec";
|
||||
const char MnemonicSED[] = "sed";
|
||||
const char MnemonicSEI[] = "sei";
|
||||
const char MnemonicSTA[] = "sta";
|
||||
const char MnemonicSTX[] = "stx";
|
||||
const char MnemonicSTY[] = "sty";
|
||||
const char MnemonicTAX[] = "tax";
|
||||
const char MnemonicTAY[] = "tay";
|
||||
const char MnemonicTSX[] = "tsx";
|
||||
const char MnemonicTXA[] = "txa";
|
||||
const char MnemonicTXS[] = "txs";
|
||||
const char MnemonicTYA[] = "tya";
|
||||
// mnemonics of legal 6502 instructions
|
||||
const char MnemonicADC[] = "adc",
|
||||
MnemonicAND[] = "and",
|
||||
MnemonicASL[] = "asl",
|
||||
MnemonicBCC[] = "bcc",
|
||||
MnemonicBCS[] = "bcs",
|
||||
MnemonicBEQ[] = "beq",
|
||||
MnemonicBIT[] = "bit",
|
||||
MnemonicBMI[] = "bmi",
|
||||
MnemonicBNE[] = "bne",
|
||||
MnemonicBPL[] = "bpl",
|
||||
MnemonicBRK[] = "brk",
|
||||
MnemonicBVC[] = "bvc",
|
||||
MnemonicBVS[] = "bvs",
|
||||
MnemonicCLC[] = "clc",
|
||||
MnemonicCLD[] = "cld",
|
||||
MnemonicCLI[] = "cli",
|
||||
MnemonicCLV[] = "clv",
|
||||
MnemonicCMP[] = "cmp",
|
||||
MnemonicCPX[] = "cpx",
|
||||
MnemonicCPY[] = "cpy",
|
||||
MnemonicDEC[] = "dec",
|
||||
MnemonicDEX[] = "dex",
|
||||
MnemonicDEY[] = "dey",
|
||||
MnemonicEOR[] = "eor",
|
||||
MnemonicINC[] = "inc",
|
||||
MnemonicINX[] = "inx",
|
||||
MnemonicINY[] = "iny",
|
||||
MnemonicJMP[] = "jmp",
|
||||
MnemonicJSR[] = "jsr",
|
||||
MnemonicLDA[] = "lda",
|
||||
MnemonicLDX[] = "ldx",
|
||||
MnemonicLDY[] = "ldy",
|
||||
MnemonicLSR[] = "lsr",
|
||||
MnemonicNOP[] = "nop",
|
||||
MnemonicORA[] = "ora",
|
||||
MnemonicPHA[] = "pha",
|
||||
MnemonicPHP[] = "php",
|
||||
MnemonicPLA[] = "pla",
|
||||
MnemonicPLP[] = "plp",
|
||||
MnemonicROL[] = "rol",
|
||||
MnemonicROR[] = "ror",
|
||||
MnemonicRTI[] = "rti",
|
||||
MnemonicRTS[] = "rts",
|
||||
MnemonicSBC[] = "sbc",
|
||||
MnemonicSEC[] = "sec",
|
||||
MnemonicSED[] = "sed",
|
||||
MnemonicSEI[] = "sei",
|
||||
MnemonicSTA[] = "sta",
|
||||
MnemonicSTX[] = "stx",
|
||||
MnemonicSTY[] = "sty",
|
||||
MnemonicTAX[] = "tax",
|
||||
MnemonicTAY[] = "tay",
|
||||
MnemonicTSX[] = "tsx",
|
||||
MnemonicTXA[] = "txa",
|
||||
MnemonicTXS[] = "txs",
|
||||
MnemonicTYA[] = "tya";
|
||||
|
||||
// Mnemonics of undocumented ("illegal") 6502 instructions
|
||||
const char MnemonicSLO[] = " SLO";
|
||||
const char MnemonicRLA[] = " RLA";
|
||||
const char MnemonicSRE[] = " SRE";
|
||||
const char MnemonicRRA[] = " RRA";
|
||||
const char MnemonicSAX[] = " SAX";
|
||||
const char MnemonicLAX[] = " LAX";
|
||||
const char MnemonicDCP[] = " DCP";
|
||||
const char MnemonicISC[] = " ISC";
|
||||
const char MnemonicANC[] = " ANC";
|
||||
const char MnemonicARR[] = " ARR";
|
||||
const char MnemonicASR[] = " ASR";
|
||||
const char MnemonicSBX[] = " SBX";
|
||||
const char MnemonicDOP[] = " DOP";
|
||||
const char MnemonicTOP[] = " TOP";
|
||||
const char MnemonicJAM[] = " JAM";
|
||||
|
||||
// Mnemonics of 65c02 instructions
|
||||
const char MnemonicBRA[] = "bra";
|
||||
const char MnemonicPHX[] = "phx";
|
||||
const char MnemonicPHY[] = "phy";
|
||||
const char MnemonicPLX[] = "plx";
|
||||
const char MnemonicPLY[] = "ply";
|
||||
const char MnemonicSTZ[] = "stz";
|
||||
const char MnemonicTRB[] = "trb";
|
||||
const char MnemonicTSB[] = "tsb";
|
||||
// mnemonics of undocumented ("illegal") 6502 instructions
|
||||
const char MnemonicSLO[] = " SLO",
|
||||
MnemonicRLA[] = " RLA",
|
||||
MnemonicSRE[] = " SRE",
|
||||
MnemonicRRA[] = " RRA",
|
||||
MnemonicSAX[] = " SAX",
|
||||
MnemonicLAX[] = " LAX",
|
||||
MnemonicDCP[] = " DCP",
|
||||
MnemonicISC[] = " ISC",
|
||||
MnemonicANC[] = " ANC",
|
||||
MnemonicARR[] = " ARR",
|
||||
MnemonicASR[] = " ASR",
|
||||
MnemonicSBX[] = " SBX",
|
||||
MnemonicDOP[] = " DOP",
|
||||
MnemonicTOP[] = " TOP",
|
||||
MnemonicJAM[] = " JAM";
|
||||
|
||||
// Mnemonics of 65816 instructions
|
||||
const char MnemonicJML[] = "jml";
|
||||
const char MnemonicJSL[] = "jsl";
|
||||
const char MnemonicMVN[] = "mvn";
|
||||
const char MnemonicMVP[] = "mvp";
|
||||
const char MnemonicPEI[] = "pei";
|
||||
const char MnemonicBRL[] = "brl";
|
||||
const char MnemonicPER[] = "per";
|
||||
const char MnemonicCOP[] = "cop";
|
||||
const char MnemonicPEA[] = "pea";
|
||||
const char MnemonicREP[] = "rep";
|
||||
const char MnemonicSEP[] = "sep";
|
||||
const char MnemonicPHB[] = "phb";
|
||||
const char MnemonicPHD[] = "phd";
|
||||
const char MnemonicPHK[] = "phk";
|
||||
const char MnemonicPLB[] = "plb";
|
||||
const char MnemonicPLD[] = "pld";
|
||||
const char MnemonicRTL[] = "rtl";
|
||||
const char MnemonicSTP[] = "stp";
|
||||
const char MnemonicTCD[] = "tcd";
|
||||
const char MnemonicTCS[] = "tcs";
|
||||
const char MnemonicTDC[] = "tdc";
|
||||
const char MnemonicTSC[] = "tsc";
|
||||
const char MnemonicTXY[] = "txy";
|
||||
const char MnemonicTYX[] = "tyx";
|
||||
const char MnemonicWAI[] = "wai";
|
||||
const char MnemonicWDM[] = "wdm";
|
||||
const char MnemonicXBA[] = "xba";
|
||||
const char MnemonicXCE[] = "xce";
|
||||
// mnemonics of 65c02 instructions
|
||||
const char MnemonicBRA[] = "bra",
|
||||
MnemonicPHX[] = "phx",
|
||||
MnemonicPHY[] = "phy",
|
||||
MnemonicPLX[] = "plx",
|
||||
MnemonicPLY[] = "ply",
|
||||
MnemonicSTZ[] = "stz",
|
||||
MnemonicTRB[] = "trb",
|
||||
MnemonicTSB[] = "tsb";
|
||||
|
||||
// mnemonics of 65816 instructions
|
||||
const char MnemonicJML[] = "jml",
|
||||
MnemonicJSL[] = "jsl",
|
||||
MnemonicMVN[] = "mvn",
|
||||
MnemonicMVP[] = "mvp",
|
||||
MnemonicPEI[] = "pei",
|
||||
MnemonicBRL[] = "brl",
|
||||
MnemonicPER[] = "per",
|
||||
MnemonicCOP[] = "cop",
|
||||
MnemonicPEA[] = "pea",
|
||||
MnemonicREP[] = "rep",
|
||||
MnemonicSEP[] = "sep",
|
||||
MnemonicPHB[] = "phb",
|
||||
MnemonicPHD[] = "phd",
|
||||
MnemonicPHK[] = "phk",
|
||||
MnemonicPLB[] = "plb",
|
||||
MnemonicPLD[] = "pld",
|
||||
MnemonicRTL[] = "rtl",
|
||||
MnemonicSTP[] = "stp",
|
||||
MnemonicTCD[] = "tcd",
|
||||
MnemonicTCS[] = "tcs",
|
||||
MnemonicTDC[] = "tdc",
|
||||
MnemonicTSC[] = "tsc",
|
||||
MnemonicTXY[] = "txy",
|
||||
MnemonicTYX[] = "tyx",
|
||||
MnemonicWAI[] = "wai",
|
||||
MnemonicWDM[] = "wdm",
|
||||
MnemonicXBA[] = "xba",
|
||||
MnemonicXCE[] = "xce";
|
||||
|
@@ -6,7 +6,8 @@
|
||||
#ifndef mnemo_H
|
||||
#define mnemo_H
|
||||
|
||||
// Mnemonics of legal 6502 instructions
|
||||
|
||||
// mnemonics of legal 6502 instructions
|
||||
extern const char MnemonicADC[], MnemonicSBC[];
|
||||
extern const char MnemonicAND[], MnemonicEOR[], MnemonicORA[];
|
||||
extern const char MnemonicASL[], MnemonicLSR[];
|
||||
@@ -31,21 +32,21 @@ extern const char MnemonicSTA[], MnemonicSTX[], MnemonicSTY[];
|
||||
extern const char MnemonicTSX[], MnemonicTXA[], MnemonicTAY[];
|
||||
extern const char MnemonicTYA[], MnemonicTAX[], MnemonicTXS[];
|
||||
|
||||
// Mnemonics of undocumented ("illegal") 6502 instructions
|
||||
// mnemonics of undocumented ("illegal") 6502 instructions
|
||||
extern const char MnemonicANC[], MnemonicARR[], MnemonicASR[];
|
||||
extern const char MnemonicDCP[], MnemonicDOP[], MnemonicISC[];
|
||||
extern const char MnemonicJAM[], MnemonicLAX[], MnemonicRLA[];
|
||||
extern const char MnemonicRRA[], MnemonicSAX[], MnemonicSBX[];
|
||||
extern const char MnemonicSLO[], MnemonicSRE[], MnemonicTOP[];
|
||||
|
||||
// Mnemonics of 65c02 instructions
|
||||
// mnemonics of 65c02 instructions
|
||||
extern const char MnemonicBRA[];
|
||||
extern const char MnemonicPHX[], MnemonicPHY[];
|
||||
extern const char MnemonicPLX[], MnemonicPLY[];
|
||||
extern const char MnemonicSTZ[];
|
||||
extern const char MnemonicTRB[], MnemonicTSB[];
|
||||
|
||||
// Mnemonics of 65816 instructions
|
||||
// mnemonics of 65816 instructions
|
||||
extern const char MnemonicJML[], MnemonicJSL[];
|
||||
extern const char MnemonicMVN[], MnemonicMVP[];
|
||||
extern const char MnemonicPEI[];
|
||||
@@ -68,4 +69,5 @@ extern const char MnemonicWAI[];
|
||||
extern const char MnemonicWDM[];
|
||||
extern const char MnemonicXBA[], MnemonicXCE[];
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -11,7 +11,7 @@
|
||||
#include "io.h"
|
||||
|
||||
|
||||
// Constants
|
||||
// constants
|
||||
|
||||
// 6502 code table (mnemonics only) *illegals*
|
||||
const char *mnemo_of_code[] = {
|
||||
@@ -81,20 +81,25 @@ MnemonicSED, MnemonicSBC, " NOP;0xfa", MnemonicISC, // $f8-$fb
|
||||
" TOP;0xfc", MnemonicSBC, MnemonicINC, MnemonicISC, // $fc-$ff
|
||||
};
|
||||
|
||||
|
||||
// output 2-digit hex argument with correct addressing mode
|
||||
static void put_argument2(const char pre[], int byte, const char post[]) {
|
||||
static void put_argument2(const char pre[], int byte, const char post[])
|
||||
{
|
||||
IO_put_string(pre);
|
||||
IO_put_low_byte_hex(byte);
|
||||
IO_put_string(post);
|
||||
}
|
||||
|
||||
|
||||
// output 4-digit hex argument with correct addressing mode
|
||||
static void put_argument4(const char pre[], int word, const char post[]) {
|
||||
static void put_argument4(const char pre[], int word, const char post[])
|
||||
{
|
||||
IO_put_string(pre);
|
||||
IO_put_low_16b_hex(word);
|
||||
IO_put_string(post);
|
||||
}
|
||||
|
||||
|
||||
static int pc; // needed by "relative" addressing mode handler
|
||||
|
||||
// addressing mode handler functions
|
||||
@@ -102,11 +107,13 @@ static int pc; // needed by "relative" addressing mode handler
|
||||
// to the program counter
|
||||
|
||||
// addressing mode handler function for 1-byte-instructions
|
||||
static int am_implied(void) {
|
||||
return(1);
|
||||
static int am_implied(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
// addressing mode handler functions for 2-byte-instructions
|
||||
static int am_immediate(void) {
|
||||
static int am_immediate(void)
|
||||
{
|
||||
put_argument2(" #$", IO_get_byte(), "");
|
||||
if (GotByte > 15) {
|
||||
fprintf(global_output_stream, " ; (= %d", GotByte);
|
||||
@@ -114,48 +121,58 @@ static int am_immediate(void) {
|
||||
fprintf(global_output_stream, " = '%c'", GotByte);
|
||||
IO_put_byte(')');
|
||||
}
|
||||
return(2);
|
||||
return 2;
|
||||
}
|
||||
static int am_absolute8(void) {
|
||||
static int am_absolute8(void)
|
||||
{
|
||||
put_argument2(" $", IO_get_byte(), "");
|
||||
return(2);
|
||||
return 2;
|
||||
}
|
||||
static int am_abs_x8(void) {
|
||||
static int am_abs_x8(void)
|
||||
{
|
||||
put_argument2(" $", IO_get_byte(), ", x");
|
||||
return(2);
|
||||
return 2;
|
||||
}
|
||||
static int am_abs_y8(void) {
|
||||
static int am_abs_y8(void)
|
||||
{
|
||||
put_argument2(" $", IO_get_byte(), ", y");
|
||||
return(2);
|
||||
return 2;
|
||||
}
|
||||
static int am_indirect_x(void) {
|
||||
static int am_indirect_x(void)
|
||||
{
|
||||
put_argument2(" ($", IO_get_byte(), ", x)");
|
||||
return(2);
|
||||
return 2;
|
||||
}
|
||||
static int am_indirect_y(void) {
|
||||
static int am_indirect_y(void)
|
||||
{
|
||||
put_argument2(" ($", IO_get_byte(), "), y");
|
||||
return(2);
|
||||
return 2;
|
||||
}
|
||||
static int am_relative(void) {
|
||||
static int am_relative(void)
|
||||
{
|
||||
put_argument4(" L", pc + 2 + (signed char) IO_get_byte(), "");
|
||||
return(2);
|
||||
return 2;
|
||||
}
|
||||
// addressing mode handler functions for 3-byte-instructions
|
||||
static int am_absolute16(void) {
|
||||
static int am_absolute16(void)
|
||||
{
|
||||
put_argument4(" L", IO_get_le16(), "");
|
||||
return(3);
|
||||
return 3;
|
||||
}
|
||||
static int am_abs_x16(void) {
|
||||
static int am_abs_x16(void)
|
||||
{
|
||||
put_argument4(" L", IO_get_le16(), ", x");
|
||||
return(3);
|
||||
return 3;
|
||||
}
|
||||
static int am_abs_y16(void) {
|
||||
static int am_abs_y16(void)
|
||||
{
|
||||
put_argument4(" L", IO_get_le16(), ", y");
|
||||
return(3);
|
||||
return 3;
|
||||
}
|
||||
static int am_indirect16(void) {
|
||||
static int am_indirect16(void)
|
||||
{
|
||||
put_argument4(" (L", IO_get_le16(), ")");
|
||||
return(3);
|
||||
return 3;
|
||||
}
|
||||
|
||||
// 6502 code table (addressing mode handler functions)
|
||||
@@ -227,8 +244,10 @@ am_implied, am_abs_y16, am_implied, am_abs_y16, // $f8-$fb
|
||||
am_implied, am_abs_x16, am_abs_x16, am_abs_x16, // $fc-$ff
|
||||
};
|
||||
|
||||
|
||||
// output mnemonic of given byte
|
||||
static void output_mnemonic(int byte) {
|
||||
static void output_mnemonic(int byte)
|
||||
{
|
||||
const char *mnemo = mnemo_of_code[byte];
|
||||
|
||||
if (mnemo)
|
||||
@@ -237,8 +256,10 @@ static void output_mnemonic(int byte) {
|
||||
put_argument2("$", byte, "");
|
||||
}
|
||||
|
||||
// Main routine for disassembly
|
||||
void obj_main(void) {
|
||||
|
||||
// main routine for disassembly
|
||||
void obj_main(void)
|
||||
{
|
||||
IO_set_input_padding(0);
|
||||
// process load address
|
||||
pc = IO_get_le16();
|
||||
|
@@ -7,9 +7,9 @@
|
||||
#include "pet2iso.h"
|
||||
|
||||
|
||||
// Constants
|
||||
// constants
|
||||
|
||||
// Conversion table
|
||||
// conversion table
|
||||
const char PET2ISO_table[256] = {
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
|
@@ -6,11 +6,12 @@
|
||||
#ifndef pet2iso_H
|
||||
#define pet2iso_H
|
||||
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
||||
// Constants
|
||||
extern const char PET2ISO_table[256]; // Conversion table
|
||||
// constants
|
||||
extern const char PET2ISO_table[256]; // conversion table
|
||||
#define PET2ISO(v) (PET2ISO_table[(unsigned char) v])
|
||||
|
||||
|
||||
|
@@ -14,8 +14,9 @@
|
||||
#include <kernel.h> // defines _kernel_swi_regs
|
||||
#define OS_FILE 0x00008 // constant to call relevant SWI
|
||||
|
||||
// Setting the created files' types
|
||||
void Platform_set_file_type_text(const char *filename) {
|
||||
// setting the created files' types
|
||||
void platform_set_file_type_text(const char *filename)
|
||||
{
|
||||
_kernel_swi_regs register_set;
|
||||
|
||||
register_set.r[0] = 18;// = SetFileType
|
||||
@@ -29,4 +30,5 @@ void Platform_set_file_type_text(const char *filename) {
|
||||
// other OS (not that much here)
|
||||
//
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -10,8 +10,8 @@
|
||||
// check for RISC OS
|
||||
#ifdef __riscos__
|
||||
#define PLATFORM_VERSION "Ported to RISC OS by Marco Baye."
|
||||
#define PLATFORM_SETFILETYPE_TEXT(a) Platform_set_file_type_text(a);
|
||||
extern void Platform_set_file_type_text(const char *filename);
|
||||
#define PLATFORM_SETFILETYPE_TEXT(a) platform_set_file_type_text(a);
|
||||
extern void platform_set_file_type_text(const char *filename);
|
||||
#endif
|
||||
|
||||
// all other platforms
|
||||
|
@@ -7,9 +7,9 @@
|
||||
#include "scr2iso.h"
|
||||
|
||||
|
||||
// Constants
|
||||
// constants
|
||||
|
||||
// Conversion table
|
||||
// conversion table
|
||||
const char SCR2ISO_table[256] = {
|
||||
0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
|
||||
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
|
||||
|
@@ -9,7 +9,7 @@
|
||||
#include "config.h"
|
||||
|
||||
|
||||
// Constants
|
||||
// constants
|
||||
extern const char SCR2ISO_table[256]; // Conversion table
|
||||
#define SCR2ISO(v) (SCR2ISO_table[(unsigned char) v])
|
||||
|
||||
|
@@ -4,11 +4,11 @@
|
||||
//
|
||||
// Version
|
||||
|
||||
#define RELEASE_NUMBER "0.10" // change before release (FIXME)
|
||||
#define CHANGE_DATE "4 Oct" // change before release
|
||||
#define CHANGE_YEAR "2006" // change before release
|
||||
#define RELEASE_NUMBER "0.11" // change before release (FIXME)
|
||||
#define CHANGE_DATE "8 Oct" // change before release
|
||||
#define CHANGE_YEAR "2012" // change before release
|
||||
#define HOME_PAGE "http://home.pages.de/~mac_bacon/smorbrod/acme/"
|
||||
#define FILE_TAG ";ACME 0.93" // check before release
|
||||
#define FILE_TAG ";ACME 0.94.2" // check before release
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -16,11 +16,11 @@
|
||||
#include "platform.h"
|
||||
|
||||
|
||||
// Variables
|
||||
// variables
|
||||
void (*client_main)(void) = NULL;
|
||||
|
||||
|
||||
// Functions
|
||||
// functions
|
||||
|
||||
// show version info and usage
|
||||
void version_show_info(const char program_name[]) {
|
||||
@@ -53,13 +53,17 @@ HOME_PAGE"\n"
|
||||
, program_name);
|
||||
}
|
||||
|
||||
|
||||
extern void ab3_main(void);
|
||||
extern void f8ab_main(void);
|
||||
extern void giga_main(void);
|
||||
extern void hypra_main(void);
|
||||
extern void obj_main(void);
|
||||
// Check id string. Returns whether illegal.
|
||||
int version_parse_id(const char id[]) {
|
||||
|
||||
|
||||
// check id string. returns whether illegal.
|
||||
int version_parse_id(const char id[])
|
||||
{
|
||||
if (strcmp(id, "ab3") == 0)
|
||||
client_main = ab3_main;
|
||||
else if (strcmp(id, "f8ab") == 0)
|
||||
@@ -70,11 +74,13 @@ int version_parse_id(const char id[]) {
|
||||
client_main = hypra_main;
|
||||
else if (strcmp(id, "object") == 0)
|
||||
client_main = obj_main;
|
||||
return(client_main ? 0 : 1);
|
||||
return client_main ? 0 : 1;
|
||||
}
|
||||
|
||||
|
||||
// do the actual work
|
||||
void version_main(void) {
|
||||
void version_main(void)
|
||||
{
|
||||
IO_put_string(
|
||||
FILE_TAG "\n"
|
||||
"; ToACME: Converted by ToACME, release " RELEASE_NUMBER ".\n"
|
||||
|
@@ -7,7 +7,7 @@
|
||||
#define version_H
|
||||
|
||||
|
||||
// Prototypes
|
||||
// prototypes
|
||||
extern void version_show_info(const char[]);
|
||||
extern int version_parse_id(const char[]);
|
||||
extern void version_main(void);
|
||||
|
Reference in New Issue
Block a user