diff --git a/contrib/toacme/docs/CHANGES b/contrib/toacme/docs/CHANGES index b3bc8d2..b0bef06 100644 --- a/contrib/toacme/docs/CHANGES +++ b/contrib/toacme/docs/CHANGES @@ -1,4 +1,9 @@ +2006-03-12 + Release 0.9 + Improved "Giga Assembler" mode. Thanks to Andreas Paul for his help. + Fixed unimportant bug: Attempted to close output file twice. + 2005-06-16 Release 0.8 Merged all converters into one program ("toacme"). diff --git a/contrib/toacme/src/Makefile b/contrib/toacme/src/Makefile index 824c773..3e81b32 100644 --- a/contrib/toacme/src/Makefile +++ b/contrib/toacme/src/Makefile @@ -19,7 +19,7 @@ f8ab.o: config.h ab.h acme.h io.h mnemo.h scr2iso.h f8ab.c giga.o: config.h acme.h gighyp.h io.h mnemo.h pet2iso.h giga.c -gighyp.o: config.h io.h pet2iso.h gighyp.h gighyp.c +gighyp.o: config.h acme.h io.h pet2iso.h gighyp.h gighyp.c hypra.o: config.h acme.h gighyp.h io.h pet2iso.h hypra.c diff --git a/contrib/toacme/src/Makefile.dos b/contrib/toacme/src/Makefile.dos index e6173a7..b474d63 100644 --- a/contrib/toacme/src/Makefile.dos +++ b/contrib/toacme/src/Makefile.dos @@ -19,7 +19,7 @@ f8ab.o: config.h ab.h acme.h io.h mnemo.h scr2iso.h f8ab.c giga.o: config.h acme.h gighyp.h io.h mnemo.h pet2iso.h giga.c -gighyp.o: config.h io.h pet2iso.h gighyp.h gighyp.c +gighyp.o: config.h acme.h io.h pet2iso.h gighyp.h gighyp.c hypra.o: config.h acme.h gighyp.h io.h pet2iso.h hypra.c diff --git a/contrib/toacme/src/Makefile.riscos b/contrib/toacme/src/Makefile.riscos index cb69bc0..12e1c6f 100644 --- a/contrib/toacme/src/Makefile.riscos +++ b/contrib/toacme/src/Makefile.riscos @@ -19,7 +19,7 @@ f8ab.o: config.h ab.h acme.h io.h mnemo.h scr2iso.h f8ab.c giga.o: config.h acme.h gighyp.h io.h mnemo.h pet2iso.h giga.c -gighyp.o: config.h io.h pet2iso.h gighyp.h gighyp.c +gighyp.o: config.h acme.h io.h pet2iso.h gighyp.h gighyp.c hypra.o: config.h acme.h gighyp.h io.h pet2iso.h hypra.c @@ -40,8 +40,8 @@ scr2iso.o: config.h scr2iso.h scr2iso.c version.o: config.h version.c toacme: ab.o ab3.o acme.o f8ab.o giga.o gighyp.o hypra.o io.o main.o mnemo.o obj.o pet2iso.o platform.o scr2iso.o version.o - $(CC) $(LIBS) $(CFLAGS) -o toacme ab.o ab3.o acme.o f8ab.o giga.o gighyp.o hypra.o io.o main.o mnemo.o obj.o pet2iso.o platform.o scr2iso.o version.o - Squeeze -f -v toacme + $(CC) $(LIBS) $(CFLAGS) -o !Unsqueezed ab.o ab3.o acme.o f8ab.o giga.o gighyp.o hypra.o io.o main.o mnemo.o obj.o pet2iso.o platform.o scr2iso.o version.o + Squeeze -f -v !Unsqueezed toacme #clean: # -$(RM) -f *.o $(PROGS) *~ core diff --git a/contrib/toacme/src/ab.c b/contrib/toacme/src/ab.c index 6b4d11e..c2ea6a2 100644 --- a/contrib/toacme/src/ab.c +++ b/contrib/toacme/src/ab.c @@ -36,15 +36,16 @@ // 0x80-0xec differ between AssBlaster 3.x and F8-AssBlaster // 0xed-0xfe unused ? // 0xff end-of-line -#define AB_PSEUDOOFFSET_MACROCALL 7 // index in PO table is equal -#define AB_PSEUDOOFFSET_MACRODEF 5 // in AB3.x and F8-AB +#define AB_PSEUDOOFFSET_MACRODEF 5 // in AB3.x and F8-AB +#define AB_PSEUDOOFFSET_MACROCALL 7 // indices in PO table +#define AB_PSEUDOOFFSET_OUTFILE 10 // are equal // 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 const char* ab_address_modes[][2] = { - {"", "" }, // ($00=%.....) implicit + {"", "" }, // ($00=%.....) implied {" ", "" }, // ($01=%....1) absolute {" ", ",x" }, // ($02=%...1.) absolute,x {" ", ",y" }, // ($03=%...11) absolute,y @@ -112,8 +113,8 @@ void ab_generate_errors(int ErrBits) { // Convert macro/label name character. // AssBlaster allows '^', '[' and ']' in names, so replace these chars. // -byte_t ab_conv_name_char(byte_t b) { - b = Scr2ISO_Table[b]; +char ab_conv_name_char(char b) { + b = SCR2ISO(b); switch(b) { case 0x40: return(AB_LABELSPECIAL_NUL); @@ -181,7 +182,7 @@ void ab_parse_quoted(void) {// now GotByte = unhandled opening quote PutByte('"'); GetByte(); while((GotByte != AB_ENDOFLINE) && (GotByte != '"')) { - PutByte(Scr2ISO_Table[GotByte]); + PutByte(SCR2ISO(GotByte)); GetByte(); } PutByte('"'); @@ -198,7 +199,7 @@ void ab_parse_quoted(void) {// now GotByte = unhandled opening quote // 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. -int ab_parse_unspecified(char dot_replacement) { +int ab_parse_unspecified(int dot_replacement) { int ErrBits = 0; while((GotByte != AB_ENDOFLINE) && (GotByte != AB_COMMENT)) { @@ -217,7 +218,7 @@ int ab_parse_unspecified(char dot_replacement) { if(GotByte == '"') ab_parse_quoted(); else { - PutByte(Scr2ISO_Table[GotByte]); + PutByte(SCR2ISO(GotByte)); GetByte(); } } @@ -239,12 +240,12 @@ int ab_parse_macro_stuff(void) { // now GotByte = unhandled byte // Process mnemonics (real opcodes). Returns error bits. // Level 1 int ab_parse_mnemo(int mnemonic_offset) { - char dot_replacement = '.'; - int ErrBits = 0; - byte_t AddressingMode; const char *mnemonic, *pre, *post; + int AddressingMode, + dot_replacement = '.', + ErrBits = 0; AddressingMode = GetByte(); // get addressing mode GetByte(); // and fetch next (not handled here) @@ -271,12 +272,12 @@ int ab_parse_mnemo(int mnemonic_offset) { fprintf(stderr, "Found an unknown addressing mode bit pattern ($%x). Please tell my programmer.\n", AddressingMode); } if(pre) - fputs(pre, global_output_stream); + PutString(pre); else PutByte(' '); ErrBits |= ab_parse_unspecified(dot_replacement); // output arg if(post) { - fputs(post, global_output_stream); + PutString(post); } return(ErrBits); } @@ -288,11 +289,11 @@ int ab_parse_pseudo_opcode(int pseudo_offset) { int ErrBits = 0; GetByte(); // and fetch next (not handled here) - fputs("\t\t", global_output_stream); + PutString("\t\t"); String = conf->pseudo_opcodes[pseudo_offset]; if(String) - fputs(String, global_output_stream); - // check for macro call/definition (need special handlers) + PutString(String); + // check for special cases switch(pseudo_offset) { case AB_PSEUDOOFFSET_MACROCALL: // (in ACME: '+') @@ -301,10 +302,15 @@ int ab_parse_pseudo_opcode(int pseudo_offset) { break; case AB_PSEUDOOFFSET_MACRODEF: // macro definition - if(String) - PutByte(' ');// but here a space looks good :) + PutByte(' ');// but here a space looks good :) ErrBits |= ab_parse_macro_stuff(); - fputs(" {", global_output_stream); + PutString(" {"); + break; + + case AB_PSEUDOOFFSET_OUTFILE: // outfile selection + PutByte(' ');// but here a space looks good :) + ErrBits |= ab_parse_unspecified('.'); // output arg(s) + PutString(PseudoTrail_ToFile); break; default: // all other pseudo opcodes @@ -348,7 +354,7 @@ void ab_main(struct ab_t* client_config) { ErrBits |= ab_parse_unspecified('.'); break; - default: // implicit label definition + default: // implied label definition ab_pipe_name(); } } else if(GotByte < conf->first_pseudo_opcode) { @@ -366,10 +372,10 @@ void ab_main(struct ab_t* client_config) { // skip empty comments by checking next byte if(GetByte() != AB_ENDOFLINE) { // something's there, so pipe until end of line - fputs(comment_indent, global_output_stream); + PutString(comment_indent); PutByte(';'); do - PutByte(Scr2ISO_Table[GotByte]); + PutByte(SCR2ISO(GotByte)); while(GetByte() != AB_ENDOFLINE); } } @@ -381,12 +387,12 @@ void ab_main(struct ab_t* client_config) { // if not at end-of-line, something's fishy if(GotByte != AB_ENDOFLINE) { if(GotByte == '\0') - fputs("; ToACME: found $00 - looks like end-of-file marker.", global_output_stream); + PutString("; ToACME: found $00 - looks like end-of-file marker."); else { fputs("Found data instead of end-of-line indicator!?.\n", stderr); - fputs("; ToACME: Garbage at end-of-line:", global_output_stream); + PutString("; ToACME: Garbage at end-of-line:"); do - PutByte(Scr2ISO_Table[GotByte]); + PutByte(SCR2ISO(GotByte)); while(GetByte() != AB_ENDOFLINE); } } diff --git a/contrib/toacme/src/ab3.c b/contrib/toacme/src/ab3.c index a7be2f6..bcea856 100644 --- a/contrib/toacme/src/ab3.c +++ b/contrib/toacme/src/ab3.c @@ -30,21 +30,37 @@ const char* ab3_mnemonics[] = { MnemonicLDY, // $84 MnemonicSTX, // $85 MnemonicSTY, // $86 - "!illegal aax", // $87 illegal aax (sta+stx) this is broken in AB3! - "!illegal asr", // $88 illegal asr (?) - "!illegal arr", // $89 illegal arr (?) - "!illegal axs", // $8a illegal axs (x=(a&x)-#) - "!illegal dcp", // $8b illegal dcp (dec+cmp) - "!illegal dop", // $8c illegal dop (double nop, skip next byte) - "!illegal isc", // $8d illegal isc (inc+sbc) aka isb - "!illegal kil", // $8e illegal kil (kill/crash/halt) - "!illegal lar", // $8f illegal lar (allocated, but never used in AB3?) - "!illegal lax", // $90 illegal lax (lda+ldx) - "!illegal rla", // $91 illegal rla (rol+and) - "!illegal rra", // $92 illegal rra (ror+adc) - "!illegal slo", // $93 illegal slo (asl+ora) - "!illegal sre", // $94 illegal sre (lsr+eor) - "!illegal top", // $95 illegal top (triple nop, skip next word) +// start of illegals +// There are no official mnemonics for undocumented opcodes, but f8ab seems +// to confuse its ASR and ARR mnemonics. See below what they do. + MnemonicSAX, // $87 sta + stx totally broken in AB3! aka AAX +// SAX is called AAX in f8ab, but it is totally broken: it generates wrong +// opcodes, one addressing mode actually generates the same opcode as LDX abs8 + "!illegal ASR", // $88 0x6b (asr #8) aka ARR +// opcode 0x6b does an AND, then *rotates* A to the right and sets flags. +// ARR would be a much better name. Possibly confused. + "!illegal ARR", // $89 0x4b (arr #8) aka ASR, ALR +// opcode 0x4b does an AND, then *shifts* A to the right. +// ASR would be a much better name. Possibly confused. + "!illegal AXS", // $8a 0xcb (axs #8) aka SBX, SAX +// opcode 0xcb does X=(A&X)-# + MnemonicDCP, // $8b dec + cmp + "!illegal DOP", // $8c 0x64 (double nop, skip byte) aka SKB +// ...0x04,0x14,0x34,0x44,0x54,0x64,0x74,x80,0x82,0x89,0xc2,0xd4,0xe2,0xf4 + MnemonicISC, // $8d inc + sbc aka ISB + "!illegal KIL", // $8e 0x62 (kill/crash/hal)t aka JAM, CRA, HLT +// ...0x02,0x12,0x22,0x32,0x42,0x52,0x62,0x72,0x92,0xb2,0xd2,0xf2 + "!illegal LAR", // $8f lar never used in AB3? aka LAE, LAS +// in case opcode 0xbb was meant - that's a uselessly complex operation + MnemonicLAX, // $90 lda + ldx partially broken in AB3! +// LAX abs16,y generates opcode 0xbb (useless) instead of 0xbf. + MnemonicRLA, // $91 rol + and + MnemonicRRA, // $92 ror + adc + MnemonicSLO, // $93 asl + ora + MnemonicSRE, // $94 lsr + eor + "!illegal TOP", // $95 0x5c (triple nop, skip word) aka SKW +// ...0x0c, 0x1c, 0x3c, 0x5c, 0x7c, 0xdc, 0xfc +// end of illegals MnemonicADC, // $96 MnemonicAND, // $97 MnemonicASL, // $98 @@ -60,7 +76,7 @@ const char* ab3_mnemonics[] = { MnemonicJMP, MnemonicJSR, // $af-$b0 MnemonicLDA, // $b1 MnemonicLSR, // $b2 - MnemonicNOP, // $b3 + MnemonicNOP,// 0x1a,0x3a,0x5a,0x7a,0xda,0xfa (legal 0xea) $b3 MnemonicORA, // $b4 MnemonicPHA, MnemonicPHP, MnemonicPLA, MnemonicPLP, // $b5-$b8 MnemonicROL, MnemonicROR, // $b9-$ba @@ -80,12 +96,12 @@ const char* ab3_pseudo_opcodes[] = { PseudoOp_Byte, // (by) $ca PseudoOp_Fill, // (br) $cb PseudoOp_PetTxt, // (tx) $cc - PseudoOp_MacroDef, // (md) $cd index 5 in this table + PseudoOp_MacroDef, // (md) $cd (see AB_PSEUDOOFFSET_MACRODEF) PseudoOp_EndMacroDef, // (me) $ce - PseudoOp_MacroCall, // (ma) $cf index 7 in this table + PseudoOp_MacroCall, // (ma) $cf (see AB_PSEUDOOFFSET_MACROCALL) PseudoOp_EOF, // (st) $d0 PseudoOp_ScrTxt, // (ts) $d1 - PseudoOp_ToFile, // (to) $d2 + PseudoOp_ToFile, // (to) $d2 (see AB_PSEUDOOFFSET_OUTFILE) PseudoOp_Word, // (wo) $d3 "; ToACME: Cannot convert \\kc.\n", // (kc) $d4 @@ -178,6 +194,10 @@ struct ab_t ab3_conf = { // void ab3_main(void) { input_set_padding(AB_ENDOFLINE); + PutString( +"; ToACME: Adding pseudo opcode to enable undocumented (\"illegal\") opcodes:\n" +"!cpu 6510\n" + ); io_process_load_address(); // first byte after load address should be AB_ENDOFLINE in AB3 sources if(GetByte() == AB_ENDOFLINE) { diff --git a/contrib/toacme/src/acme.c b/contrib/toacme/src/acme.c index f2220ad..61f5afd 100644 --- a/contrib/toacme/src/acme.c +++ b/contrib/toacme/src/acme.c @@ -30,6 +30,7 @@ const char PseudoOp_ScrTxt[] = "!scr"; const char PseudoOp_SetPC[] = "*="; const char PseudoOp_Source[] = "!src"; const char PseudoOp_ToFile[] = "!to"; +const char PseudoTrail_ToFile[] = ", cbm"; const char PseudoOp_Word[] = "!word"; // Pseudo opcodes for 65816 (used by F8-AssBlaster) const char PseudoOp_al[] = "!al"; @@ -46,8 +47,8 @@ const char PseudoOp_rs[] = "!rs"; // void acme_SwitchToPet(void) { - fputs( + PutString( "; ToACME: Adding pseudo opcode to use PetSCII encoding by default:\n" "!convtab pet\n" - , global_output_stream); + ); } diff --git a/contrib/toacme/src/acme.h b/contrib/toacme/src/acme.h index ff81f0f..2ce83b0 100644 --- a/contrib/toacme/src/acme.h +++ b/contrib/toacme/src/acme.h @@ -27,6 +27,7 @@ extern const char PseudoOp_ScrTxt[]; extern const char PseudoOp_SetPC[]; extern const char PseudoOp_Source[]; extern const char PseudoOp_ToFile[]; +extern const char PseudoTrail_ToFile[]; extern const char PseudoOp_Word[]; // pseudo opcodes for 65816 cpu extern const char PseudoOp_al[]; diff --git a/contrib/toacme/src/config.h b/contrib/toacme/src/config.h index 961a957..239ac95 100644 --- a/contrib/toacme/src/config.h +++ b/contrib/toacme/src/config.h @@ -9,11 +9,6 @@ #define config_H -// Types -// -typedef unsigned char byte_t; - - // Constants // #ifndef FALSE diff --git a/contrib/toacme/src/f8ab.c b/contrib/toacme/src/f8ab.c index ebb7a75..09bee84 100644 --- a/contrib/toacme/src/f8ab.c +++ b/contrib/toacme/src/f8ab.c @@ -127,14 +127,14 @@ const char* f8ab_pseudo_opcodes[] = { PseudoOp_Byte, // (by) $de PseudoOp_Fill, // (br) $df PseudoOp_PetTxt, // (tx) $e0 - PseudoOp_MacroDef, // (md) $e1 index 5 in this table + PseudoOp_MacroDef, // (md) $e1 (see AB_PSEUDOOFFSET_MACRODEF) PseudoOp_EndMacroDef, // (de) $e2 - PseudoOp_MacroCall, // (ma) $e3 index 7 in this table + PseudoOp_MacroCall, // (ma) $e3 (see AB_PSEUDOOFFSET_MACROCALL) PseudoOp_EOF, // (st) $e4 // PseudoOp_ScrTxt is not available in F8AB. Huh?! "; ToACME: Cannot convert \\wa.\n", // (wa) $e5 - PseudoOp_ToFile, // (on) $e6 + PseudoOp_ToFile, // (on) $e6 (see AB_PSEUDOOFFSET_OUTFILE) PseudoOp_Word, // (wo) $e7 "; ToACME: Cannot convert \\kc.\n", // (kc) $e8 @@ -189,13 +189,7 @@ int f8ab_parse_number(void) { // now GotByte = first byte of packed number case F8AB_NUMVAL__SIZE_3:// three bytes follow (anything else) Value = Add + GetByte() + (GetLE16() << 8); - break; - default: // unknown number compression - // this is actually dead code for the F8-AB converter, as - // there are only four possible bit combinations... :) - // remember to generate error - ErrBits |= AB_ERRBIT_UNKNOWN_NUMBER_COMPRESSION; } // continue parsing on next byte GetByte(); @@ -245,7 +239,7 @@ void f8ab_main(void) { header_message = "Input does not have any known F8AB header.\n"; input_set_padding(AB_ENDOFLINE); - fputs( + PutString( "; ToACME: Adding pseudo opcode to enable 65816 opcodes:\n" "!cpu 65816\n" "; ToACME: Adding two macros to fix F8AB's non-standard argument order\n" @@ -254,7 +248,7 @@ void f8ab_main(void) { "; ToACME: source codes, the source bank byte is given first.\n" "!macro F8AB_BROKEN_MVP .dest,.source {mvp .source,.dest}\n" "!macro F8AB_BROKEN_MVN .dest,.source {mvn .source,.dest}\n" - , global_output_stream); + ); io_process_load_address(); // most AB files have this format: // load_address_low, load_address_high, AB_ENDOFLINE, actual content diff --git a/contrib/toacme/src/giga.c b/contrib/toacme/src/giga.c index f0f21ba..070809b 100644 --- a/contrib/toacme/src/giga.c +++ b/contrib/toacme/src/giga.c @@ -23,7 +23,7 @@ // token-to-(pseudo)opcode conversion table (FIXME) const char* giga_token[] = { "FIXME-CALL", // $a0 .CALL - PseudoOp_MacroDef, // $a1 .MACRO + PseudoOp_MacroDef, // $a1 .MACRO (see MACRO_DEF_TOKEN below) PseudoOp_EndMacroDef, // $a2 .ENDMACRO NULL, // $a3 .GLOBAL (ACME does not need a pseudo NULL, // $a4 .EQUATE opcode for label definitions) @@ -32,10 +32,10 @@ const char* giga_token[] = { PseudoOp_Byte, // $a5 .BYTE PseudoOp_Word, // $a6 .WORD PseudoOp_Fill, // $a7 .DS - PseudoOp_PetTxt, // $a8 .TEXT + PseudoOp_PetTxt, // $a8 .TEXT (see MACRO_TEXT below) // bis hier wird eingerückt // ab hier wird nicht eingerückt - PseudoOp_ToFile, // $a9 .OBJECT + PseudoOp_ToFile, // $a9 .OBJECT (see MACRO_OUTFILE below) PseudoOp_SetPC, // $aa .BASE "FIXME-CODE", // $ab .CODE "FIXME-ON", // $ac .ON @@ -135,20 +135,41 @@ const char* giga_token[] = { // 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) // int giga_Tokenized(void) { const char* token; + int flags = 0; - if(GotByte < FIRST_TOKEN) - fprintf(global_output_stream, "small value:$%x", GotByte); - else { - token = giga_token[GotByte-FIRST_TOKEN]; + if(GotByte < FIRST_TOKEN) { + // macro call? + PutByte('+'); // add macro call character + // 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]; if(token != NULL) - fputs(token, global_output_stream); + PutString(token); + GetByte(); } - GetByte(); - return(0); + return(flags); } // When tokens are known, maybe use the PseudoOpcode function from hypra? @@ -167,13 +188,13 @@ void giga_main(void) { while(!ReachedEOF) { // skip link pointer (if it's zero, report as end marker) if(GetLE16() == 0) - fputs("; ToACME: Found BASIC end marker.\n", global_output_stream); + PutString("; ToACME: Found BASIC end marker.\n"); GetLE16(); // skip line number // process line GetByte(); - if((GotByte == ' ') || (GotByte == ';') || (GotByte == '\0') ||(GotByte>0x7f)) + if((GotByte == ' ') || (GotByte == ';') || (GotByte == '\0') || (GotByte > 0x7f)) indent = 0; else indent = gigahypra_LabelDef(); diff --git a/contrib/toacme/src/gighyp.c b/contrib/toacme/src/gighyp.c index 62907db..edf2709 100644 --- a/contrib/toacme/src/gighyp.c +++ b/contrib/toacme/src/gighyp.c @@ -8,6 +8,7 @@ // Includes // +#include "acme.h" #include "gighyp.h" #include "io.h" #include "pet2iso.h" @@ -21,7 +22,7 @@ void gigahypra_ConvComment(void) { if(GetByte()) { PutByte(';'); do - PutByte(Pet2ISO_Table[GotByte]); + PutByte(PET2ISO(GotByte)); while(GetByte()); } } @@ -29,9 +30,9 @@ void gigahypra_ConvComment(void) { // Process operator // void gigahypra_Operator(void) {// '!' was last read - byte_t Middle; + char Middle; - Middle = Pet2ISO_Table[GetByte()]; + Middle = PET2ISO(GetByte()); if((Middle != ';') && (Middle != 0)) { if(GetByte() == '!') { switch(Middle) { @@ -53,11 +54,11 @@ void gigahypra_Operator(void) {// '!' was last read break; case '<': - fputs(" < ", global_output_stream); + PutString(" < "); break; case '>': - fputs(" > ", global_output_stream); + PutString(" > "); break; default: @@ -85,57 +86,72 @@ void gigahypra_Indent(int indent) { // Process opcode and arguments // -void gigahypra_Opcode(int Flags) { - int NowOpen = 0;// number of parentheses to close +void gigahypra_Opcode(int flags) { + int paren = 0; // number of open parentheses (to close) // if needed, add separating space between opcode and argument - if(((Flags & FLAGS_NOSPACE) == 0) && (GotByte != ' ') && (GotByte != ';') && (GotByte != '\0')) + if((flags & FLAG_INSERT_SPACE) && (GotByte != ' ') && (GotByte != ';') && (GotByte != '\0')) PutByte(' '); // character loop - while((GotByte != ';') && (GotByte != 0)) { + while((GotByte != ';') && (GotByte != '\0')) { if(GotByte == '!') gigahypra_Operator(); if(GotByte == '"') { // don't parse inside quotes PutByte(GotByte); GetByte(); - while((GotByte != 0) && (GotByte != '"')) { - PutByte(Pet2ISO_Table[GotByte]); + while((GotByte != '\0') && (GotByte != '"')) { + if((GotByte == 0x5f) + && (flags & FLAG_CHANGE_LEFTARROW)) + PutString("\", 13,\""); + else + PutByte(PET2ISO(GotByte)); GetByte(); } PutByte('"'); - if(GotByte == '"') GetByte(); + if(GotByte == '"') { + GetByte(); + if((GotByte == '\0') + && (flags & FLAG_ADD_ZERO)) + PutString(", 0"); + } } else { // most characters go here switch(GotByte) { case '(': - if(Flags & FLAGS_STRIPOPENING) { - Flags &= ~FLAGS_STRIPOPENING; - Flags |= FLAGS_STRIPCLOSING; + if(flags & FLAG_SKIP_OPENING) { + flags &= ~FLAG_SKIP_OPENING; + flags |= FLAG_SKIP_CLOSING; } else { - NowOpen++; - PutByte(Pet2ISO_Table[GotByte]); + paren++; + PutByte(PET2ISO(GotByte)); } break; case ')': - if((Flags&FLAGS_STRIPCLOSING) && (NowOpen==0)) - Flags &= ~FLAGS_STRIPCLOSING; + if((flags & FLAG_SKIP_CLOSING) && (paren == 0)) + flags &= ~FLAG_SKIP_CLOSING; else { - NowOpen--; - PutByte(Pet2ISO_Table[GotByte]); + paren--; + PutByte(PET2ISO(GotByte)); } break; + case ' ': // shift-space + PutByte(' '); // space + break; + default: - PutByte(Pet2ISO_Table[GotByte]); + PutByte(PET2ISO(GotByte)); } GetByte(); } } - if(Flags & FLAGS_ADDLEFTBRACE) + if(flags & FLAG_ADD_CBM) + PutString(PseudoTrail_ToFile); + if(flags & FLAG_ADD_LEFT_BRACE) PutByte('{'); } @@ -146,7 +162,7 @@ int gigahypra_LabelDef(void) { int count = 0; do { - PutByte(Pet2ISO_Table[GotByte]); + PutByte(PET2ISO(GotByte)); count++; GetByte(); } while((GotByte != ' ') && (GotByte != ';') && (GotByte != 0)); diff --git a/contrib/toacme/src/gighyp.h b/contrib/toacme/src/gighyp.h index d0a862f..7cda911 100644 --- a/contrib/toacme/src/gighyp.h +++ b/contrib/toacme/src/gighyp.h @@ -15,10 +15,15 @@ // Constants // -#define FLAGS_NOSPACE (1u << 0) -#define FLAGS_ADDLEFTBRACE (1u << 1) -#define FLAGS_STRIPOPENING (1u << 2) -#define FLAGS_STRIPCLOSING (1u << 3) +#define FLAG_INSERT_SPACE (1u << 0) // insert space before arg +#define FLAG_ADD_LEFT_BRACE (1u << 1) // add '{' at end of statement +#define FLAG_ADD_CBM (1u << 2) // add file format indicator +#define FLAG_ADD_ZERO (1u << 3) // giga string specialty: + // open quote at end of line is *normal*. Closed quote: add ",0". +#define FLAG_SKIP_OPENING (1u << 4) // strip '(' before args +#define FLAG_SKIP_CLOSING (1u << 5) // strip ')' after args +#define FLAG_CHANGE_LEFTARROW (1u << 6) // giga string specialty: + // '_' (left arrow on C64) is transformed to CR (0x0d). // Prototypes @@ -26,7 +31,7 @@ extern void gigahypra_ConvComment(void); extern void gigahypra_Operator(void); extern void gigahypra_Indent(int indent); -extern void gigahypra_Opcode(int Flags); +extern void gigahypra_Opcode(int flags); extern int gigahypra_LabelDef(void); diff --git a/contrib/toacme/src/hypra.c b/contrib/toacme/src/hypra.c index 0c4da9b..acf3ed5 100644 --- a/contrib/toacme/src/hypra.c +++ b/contrib/toacme/src/hypra.c @@ -23,40 +23,40 @@ // Process pseudo opcode // int hypra_PseudoOpcode(void) {// '.' was last read - byte_t a, - b = '\0'; + int a, + b = '\0', + flags = FLAG_INSERT_SPACE; bool fBlah = TRUE; - int Flags = 0; - a = Pet2ISO_Table[GetByte()]; + a = PET2ISO(GetByte()); if((a != ' ') && (a != ';') && (a != '\0')) { - b = Pet2ISO_Table[GetByte()]; + b = PET2ISO(GetByte()); if((b != ' ') && (b != ';') && (b != '\0')) { switch(a) { case '.': if(b == '.') { // "..." = macro call fBlah = FALSE; - fputs(PseudoOp_MacroCall, global_output_stream); - Flags |= FLAGS_STRIPOPENING; + PutString(PseudoOp_MacroCall); + flags |= FLAG_SKIP_OPENING; } break; case 'a': if(b == 'p') { // ".ap" = append source file fBlah = FALSE; - fputs(PseudoOp_Source, global_output_stream); + PutString(PseudoOp_Source); } break; case 'b': if(b == 'a') { // ".ba" = set base address fBlah = FALSE; - fputs(PseudoOp_SetPC, global_output_stream); + PutString(PseudoOp_SetPC); } if(b == 'y') { // ".by" = insert bytes fBlah = FALSE; - fputs(PseudoOp_Byte, global_output_stream); + PutString(PseudoOp_Byte); } break; @@ -65,22 +65,22 @@ int hypra_PseudoOpcode(void) {// '.' was last read case 'i': // ".ei" = endif fBlah = FALSE; - fputs(PseudoOp_EndIf, global_output_stream); + PutString(PseudoOp_EndIf); break; case 'l': // ".el" = else fBlah = FALSE; - fputs(PseudoOp_Else, global_output_stream); + PutString(PseudoOp_Else); break; case 'n': // ".en" = end fBlah = FALSE; - fputs(PseudoOp_EOF, global_output_stream); + PutString(PseudoOp_EOF); break; case 'q': // ".eq" = label def fBlah = FALSE; - Flags |= FLAGS_NOSPACE; + flags &= ~FLAG_INSERT_SPACE; break; } break; @@ -88,62 +88,63 @@ int hypra_PseudoOpcode(void) {// '.' was last read case 'g': if(b == 'l') // ".gl" = global label def fBlah = FALSE; - Flags |= FLAGS_NOSPACE; + flags &= ~FLAG_INSERT_SPACE; break; case 'i': if(b == 'f') { // ".if" = conditional assembly fBlah = FALSE; - fputs(PseudoOp_If, global_output_stream); - Flags |= FLAGS_ADDLEFTBRACE; + PutString(PseudoOp_If); + flags |= FLAG_ADD_LEFT_BRACE; } break; case 'm': if(b == 'a') { // ".ma" = macro definition fBlah = FALSE; - fputs(PseudoOp_MacroDef, global_output_stream); - Flags |= FLAGS_STRIPOPENING | FLAGS_ADDLEFTBRACE; + PutString(PseudoOp_MacroDef); + flags |= FLAG_SKIP_OPENING | FLAG_ADD_LEFT_BRACE; } break; case 'o': if(b == 'b') { // ".ob" = output to file fBlah = FALSE; - fputs(PseudoOp_ToFile, global_output_stream); + PutString(PseudoOp_ToFile); + flags |= FLAG_ADD_CBM; } break; case 'r': if(b == 't') { // ".rt" = end of macro def fBlah = FALSE; - fputs(PseudoOp_EndMacroDef, global_output_stream); + PutString(PseudoOp_EndMacroDef); } break; case 's': if(b == 'y') { // ".sy" = symbol dump fBlah = FALSE; - fputs(PseudoOp_LabelDump, global_output_stream); - fputs("\"symboldump.txt\";", global_output_stream); + PutString(PseudoOp_LabelDump); + PutString("\"symboldump.txt\";"); } break; case 't': if(b == 'x') { // ".tx" = insert string fBlah = FALSE; - fputs(PseudoOp_PetTxt, global_output_stream); + PutString(PseudoOp_PetTxt); } if(b == 's') { // ".ts" = screen code string fBlah = FALSE; - fputs(PseudoOp_ScrTxt, global_output_stream); + PutString(PseudoOp_ScrTxt); } break; case 'w': if(b == 'o') { // ".wo" = insert words fBlah = FALSE; - fputs(PseudoOp_Word, global_output_stream); + PutString(PseudoOp_Word); } break; @@ -154,31 +155,31 @@ int hypra_PseudoOpcode(void) {// '.' was last read } else fBlah = TRUE; if(fBlah) { - fputs("; ToACME: .", global_output_stream); + PutString("; ToACME: ."); if(a) PutByte(a); if(b) PutByte(b); - fputs(" cannot be converted\n", global_output_stream); + PutString(" cannot be converted\n"); } - return(Flags); + return(flags); } // Process ocpode // -int hypra_RealOpcode(void) {// character was last read +void hypra_RealOpcode(void) {// character was last read - PutByte(Pet2ISO_Table[GotByte]); + PutByte(PET2ISO(GotByte)); GetByte(); - if((GotByte == ' ') || (GotByte == ';') || (GotByte == 0)) - return(0); - PutByte(Pet2ISO_Table[GotByte]); + if((GotByte == ' ') || (GotByte == ';') || (GotByte == '\0')) + return; + PutByte(PET2ISO(GotByte)); GetByte(); - if((GotByte == ' ') || (GotByte == ';') || (GotByte == 0)) - return(0); - PutByte(Pet2ISO_Table[GotByte]); + if((GotByte == ' ') || (GotByte == ';') || (GotByte == '\0')) + return; + PutByte(PET2ISO(GotByte)); GetByte();// exit with unused byte pre-read - return(0); + return; } // Main routine for HypraAss conversion @@ -193,7 +194,7 @@ void hypra_main(void) { while(!ReachedEOF) { // skip link pointer (if it's zero, report as end marker) if(GetLE16() == 0) - fputs("; ToACME: Found BASIC end marker.\n", global_output_stream); + PutString("; ToACME: Found BASIC end marker.\n"); GetLE16(); // skip line number @@ -213,8 +214,10 @@ void hypra_main(void) { // branch to relevant routine if(GotByte == '.') gigahypra_Opcode(hypra_PseudoOpcode()); - else - gigahypra_Opcode(hypra_RealOpcode()); + else { + hypra_RealOpcode(); + gigahypra_Opcode(FLAG_INSERT_SPACE); + } } // skip comment, if there is one diff --git a/contrib/toacme/src/io.c b/contrib/toacme/src/io.c index 199dc05..f853e27 100644 --- a/contrib/toacme/src/io.c +++ b/contrib/toacme/src/io.c @@ -15,10 +15,10 @@ // Variables // -byte_t PaddingValue; +int PaddingValue; FILE *global_input_stream; FILE *global_output_stream; -byte_t GotByte = 0; +int GotByte = 0; bool ReachedEOF = FALSE; @@ -28,14 +28,14 @@ bool ReachedEOF = FALSE; // Set byte sent after EOF // -inline void input_set_padding(byte_t pad) { +inline void input_set_padding(int pad) { PaddingValue = pad; } // Fetch and buffer byte // -byte_t GetByte(void) { +int GetByte(void) { int w; if(ReachedEOF) @@ -44,7 +44,7 @@ byte_t GetByte(void) { w = getc(global_input_stream); if(w == EOF) ReachedEOF = TRUE; - GotByte = (byte_t) w; + GotByte = w; } return(GotByte); } @@ -60,6 +60,12 @@ unsigned int GetLE16(void) { // +// output string +// +inline void PutString(const char string[]) { + fputs(string, global_output_stream); +} + // Write byte to output file // inline void PutByte(const char b) { @@ -92,7 +98,7 @@ void io_process_load_address(void) { int load_address; load_address = GetLE16(); - fputs("; ToACME: Original source code file had load address $", global_output_stream); + PutString("; ToACME: Original source code file had load address $"); io_put_low_16b_hex(load_address); PutByte('\n'); } diff --git a/contrib/toacme/src/io.h b/contrib/toacme/src/io.h index 922df7f..f69fa40 100644 --- a/contrib/toacme/src/io.h +++ b/contrib/toacme/src/io.h @@ -16,7 +16,7 @@ // Variables // -extern byte_t GotByte; +extern int GotByte; extern bool ReachedEOF; extern FILE *global_input_stream; extern FILE *global_output_stream; @@ -24,9 +24,10 @@ extern FILE *global_output_stream; // Prototypes // -extern void input_set_padding(const byte_t); -extern byte_t GetByte(void); +extern void input_set_padding(const int); +extern int GetByte(void); extern unsigned int GetLE16(void); // get little-endian 16-bit value +extern void PutString(const char string[]); extern void PutByte(const char b); extern void io_put_low_byte_hex(int v); extern void io_put_low_16b_hex(int w); diff --git a/contrib/toacme/src/main.c b/contrib/toacme/src/main.c index ac9467e..477efb0 100644 --- a/contrib/toacme/src/main.c +++ b/contrib/toacme/src/main.c @@ -36,8 +36,8 @@ int main(int argc, char *argv[]) { // handle "toacme -h" and "toacme --help" just like "toacme" if(argc == 2) { - if((strcmp(argv[1], "-h") == NULL) - || (strcmp(argv[1], "--help") == NULL)) + if((strcmp(argv[1], "-h") == 0) + || (strcmp(argv[1], "--help") == 0)) argc = 1; } // "toacme" without any switches gives info and exits successfully @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) { return(EXIT_FAILURE); } // be nice and ensure input and output are different - if(strcmp(argv[2], argv[3]) == NULL) { + if(strcmp(argv[2], argv[3]) == 0) { fputs("Input and output files must be different.\n", stderr); return(EXIT_FAILURE); } diff --git a/contrib/toacme/src/mnemo.c b/contrib/toacme/src/mnemo.c index e0d8d4e..4a02a96 100644 --- a/contrib/toacme/src/mnemo.c +++ b/contrib/toacme/src/mnemo.c @@ -63,6 +63,16 @@ const char MnemonicTXA[] = "txa"; const char MnemonicTXS[] = "txs"; const char 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"; + // Mnemonics of 65c02 instructions const char MnemonicBRA[] = "bra"; const char MnemonicPHX[] = "phx"; diff --git a/contrib/toacme/src/mnemo.h b/contrib/toacme/src/mnemo.h index acbedcb..658428d 100644 --- a/contrib/toacme/src/mnemo.h +++ b/contrib/toacme/src/mnemo.h @@ -32,6 +32,12 @@ extern const char MnemonicSTA[], MnemonicSTX[], MnemonicSTY[]; extern const char MnemonicTSX[], MnemonicTXA[], MnemonicTAY[]; extern const char MnemonicTYA[], MnemonicTAX[], MnemonicTXS[]; +// Mnemonics of undocumented ("illegal") 6502 instructions +extern const char MnemonicSLO[], MnemonicRLA[]; +extern const char MnemonicSRE[], MnemonicRRA[]; +extern const char MnemonicSAX[], MnemonicLAX[]; +extern const char MnemonicDCP[], MnemonicISC[]; + // Mnemonics of 65c02 instructions extern const char MnemonicBRA[]; extern const char MnemonicPHX[], MnemonicPHY[]; diff --git a/contrib/toacme/src/obj.c b/contrib/toacme/src/obj.c index 056d077..ae33af2 100644 --- a/contrib/toacme/src/obj.c +++ b/contrib/toacme/src/obj.c @@ -18,88 +18,88 @@ // Constants // -// 6502 code table (mnemonics only) +// 6502 code table (mnemonics only) *illegals* const char* mnemo_of_code[] = { - MnemonicBRK, MnemonicORA, NULL, NULL, // $00-$03 - NULL, MnemonicORA, MnemonicASL, NULL, // $04-$07 - MnemonicPHP, MnemonicORA, MnemonicASL, NULL, // $08-$0b - NULL, MnemonicORA, MnemonicASL, NULL, // $0c-$0f - MnemonicBPL, MnemonicORA, NULL, NULL, // $10-$13 - NULL, MnemonicORA, MnemonicASL, NULL, // $14-$17 - MnemonicCLC, MnemonicORA, NULL, NULL, // $18-$1b - NULL, MnemonicORA, MnemonicASL, NULL, // $1c-$1f - MnemonicJSR, MnemonicAND, NULL, NULL, // $20-$23 - MnemonicBIT, MnemonicAND, MnemonicROL, NULL, // $24-$27 - MnemonicPLP, MnemonicAND, MnemonicROL, NULL, // $28-$2b - MnemonicBIT, MnemonicAND, MnemonicROL, NULL, // $2c-$2f - MnemonicBMI, MnemonicAND, NULL, NULL, // $30-$33 - NULL, MnemonicAND, MnemonicROL, NULL, // $34-$37 - MnemonicSEC, MnemonicAND, NULL, NULL, // $38-$3b - NULL, MnemonicAND, MnemonicROL, NULL, // $3c-$3f - MnemonicRTI, MnemonicEOR, NULL, NULL, // $40-$43 - NULL, MnemonicEOR, MnemonicLSR, NULL, // $44-$47 - MnemonicPHA, MnemonicEOR, MnemonicLSR, NULL, // $48-$4b - MnemonicJMP, MnemonicEOR, MnemonicLSR, NULL, // $4c-$4f - MnemonicBVC, MnemonicEOR, NULL, NULL, // $50-$53 - NULL, MnemonicEOR, MnemonicLSR, NULL, // $54-$57 - MnemonicCLI, MnemonicEOR, NULL, NULL, // $58-$5b - NULL, MnemonicEOR, MnemonicLSR, NULL, // $5c-$5f - MnemonicRTS, MnemonicADC, NULL, NULL, // $60-$63 - NULL, MnemonicADC, MnemonicROR, NULL, // $64-$67 - MnemonicPLA, MnemonicADC, MnemonicROR, NULL, // $68-$6b - MnemonicJMP, MnemonicADC, MnemonicROR, NULL, // $6c-$6f - MnemonicBVS, MnemonicADC, NULL, NULL, // $70-$73 - NULL, MnemonicADC, MnemonicROR, NULL, // $74-$77 - MnemonicSEI, MnemonicADC, NULL, NULL, // $78-$7b - NULL, MnemonicADC, MnemonicROR, NULL, // $7c-$7f - NULL, MnemonicSTA, NULL, NULL, // $80-$83 - MnemonicSTY, MnemonicSTA, MnemonicSTX, NULL, // $84-$87 - MnemonicDEY, NULL, MnemonicTXA, NULL, // $88-$8b - MnemonicSTY, MnemonicSTA, MnemonicSTX, NULL, // $8c-$8f - MnemonicBCC, MnemonicSTA, NULL, NULL, // $90-$93 - MnemonicSTY, MnemonicSTA, MnemonicSTX, NULL, // $94-$97 - MnemonicTYA, MnemonicSTA, MnemonicTXS, NULL, // $98-$9b - NULL, MnemonicSTA, NULL, NULL, // $9c-$9f - MnemonicLDY, MnemonicLDA, MnemonicLDX, NULL, // $a0-$a3 - MnemonicLDY, MnemonicLDA, MnemonicLDX, NULL, // $a4-$a7 - MnemonicTAY, MnemonicLDA, MnemonicTAX, NULL, // $a8-$ab - MnemonicLDY, MnemonicLDA, MnemonicLDX, NULL, // $ac-$af - MnemonicBCS, MnemonicLDA, NULL, NULL, // $b0-$b3 - MnemonicLDY, MnemonicLDA, MnemonicLDX, NULL, // $b4-$b7 - MnemonicCLV, MnemonicLDA, MnemonicTSX, NULL, // $b8-$bb - MnemonicLDY, MnemonicLDA, MnemonicLDX, NULL, // $bc-$bf - MnemonicCPY, MnemonicCMP, NULL, NULL, // $c0-$c3 - MnemonicCPY, MnemonicCMP, MnemonicDEC, NULL, // $c4-$c7 - MnemonicINY, MnemonicCMP, MnemonicDEX, NULL, // $c8-$cb - MnemonicCPY, MnemonicCMP, MnemonicDEC, NULL, // $cc-$cf - MnemonicBNE, MnemonicCMP, NULL, NULL, // $d0-$d3 - NULL, MnemonicCMP, MnemonicDEC, NULL, // $d4-$d7 - MnemonicCLD, MnemonicCMP, NULL, NULL, // $d8-$db - NULL, MnemonicCMP, MnemonicDEC, NULL, // $dc-$df - MnemonicCPX, MnemonicSBC, NULL, NULL, // $e0-$e3 - MnemonicCPX, MnemonicSBC, MnemonicINC, NULL, // $e4-$e7 - MnemonicINX, MnemonicSBC, MnemonicNOP, NULL, // $e8-$eb - MnemonicCPX, MnemonicSBC, MnemonicINC, NULL, // $ec-$ef - MnemonicBEQ, MnemonicSBC, NULL, NULL, // $f0-$f3 - NULL, MnemonicSBC, MnemonicINC, NULL, // $f4-$f7 - MnemonicSED, MnemonicSBC, NULL, NULL, // $f8-$fb - NULL, MnemonicSBC, MnemonicINC, NULL, // $fc-$ff +MnemonicBRK, MnemonicORA, NULL, MnemonicSLO, // $00-$03 +NULL, MnemonicORA, MnemonicASL, MnemonicSLO, // $04-$07 +MnemonicPHP, MnemonicORA, MnemonicASL, NULL, // $08-$0b +NULL, MnemonicORA, MnemonicASL, MnemonicSLO, // $0c-$0f +MnemonicBPL, MnemonicORA, NULL, MnemonicSLO, // $10-$13 +NULL, MnemonicORA, MnemonicASL, MnemonicSLO, // $14-$17 +MnemonicCLC, MnemonicORA, NULL, MnemonicSLO, // $18-$1b +NULL, MnemonicORA, MnemonicASL, MnemonicSLO, // $1c-$1f +MnemonicJSR, MnemonicAND, NULL, MnemonicRLA, // $20-$23 +MnemonicBIT, MnemonicAND, MnemonicROL, MnemonicRLA, // $24-$27 +MnemonicPLP, MnemonicAND, MnemonicROL, NULL, // $28-$2b +MnemonicBIT, MnemonicAND, MnemonicROL, MnemonicRLA, // $2c-$2f +MnemonicBMI, MnemonicAND, NULL, MnemonicRLA, // $30-$33 +NULL, MnemonicAND, MnemonicROL, MnemonicRLA, // $34-$37 +MnemonicSEC, MnemonicAND, NULL, MnemonicRLA, // $38-$3b +NULL, MnemonicAND, MnemonicROL, MnemonicRLA, // $3c-$3f +MnemonicRTI, MnemonicEOR, NULL, MnemonicSRE, // $40-$43 +NULL, MnemonicEOR, MnemonicLSR, MnemonicSRE, // $44-$47 +MnemonicPHA, MnemonicEOR, MnemonicLSR, NULL, // $48-$4b +MnemonicJMP, MnemonicEOR, MnemonicLSR, MnemonicSRE, // $4c-$4f +MnemonicBVC, MnemonicEOR, NULL, MnemonicSRE, // $50-$53 +NULL, MnemonicEOR, MnemonicLSR, MnemonicSRE, // $54-$57 +MnemonicCLI, MnemonicEOR, NULL, MnemonicSRE, // $58-$5b +NULL, MnemonicEOR, MnemonicLSR, MnemonicSRE, // $5c-$5f +MnemonicRTS, MnemonicADC, NULL, MnemonicRRA, // $60-$63 +NULL, MnemonicADC, MnemonicROR, MnemonicRRA, // $64-$67 +MnemonicPLA, MnemonicADC, MnemonicROR, NULL, // $68-$6b +MnemonicJMP, MnemonicADC, MnemonicROR, MnemonicRRA, // $6c-$6f +MnemonicBVS, MnemonicADC, NULL, MnemonicRRA, // $70-$73 +NULL, MnemonicADC, MnemonicROR, MnemonicRRA, // $74-$77 +MnemonicSEI, MnemonicADC, NULL, MnemonicRRA, // $78-$7b +NULL, MnemonicADC, MnemonicROR, MnemonicRRA, // $7c-$7f +NULL, MnemonicSTA, NULL, MnemonicSAX, // $80-$83 +MnemonicSTY, MnemonicSTA, MnemonicSTX, MnemonicSAX, // $84-$87 +MnemonicDEY, NULL, MnemonicTXA, NULL, // $88-$8b +MnemonicSTY, MnemonicSTA, MnemonicSTX, MnemonicSAX, // $8c-$8f +MnemonicBCC, MnemonicSTA, NULL, NULL, // $90-$93 +MnemonicSTY, MnemonicSTA, MnemonicSTX, MnemonicSAX, // $94-$97 +MnemonicTYA, MnemonicSTA, MnemonicTXS, NULL, // $98-$9b +NULL, MnemonicSTA, NULL, NULL, // $9c-$9f +MnemonicLDY, MnemonicLDA, MnemonicLDX, MnemonicLAX, // $a0-$a3 +MnemonicLDY, MnemonicLDA, MnemonicLDX, MnemonicLAX, // $a4-$a7 +MnemonicTAY, MnemonicLDA, MnemonicTAX, NULL, // $a8-$ab +MnemonicLDY, MnemonicLDA, MnemonicLDX, MnemonicLAX, // $ac-$af +MnemonicBCS, MnemonicLDA, NULL, MnemonicLAX, // $b0-$b3 +MnemonicLDY, MnemonicLDA, MnemonicLDX, MnemonicLAX, // $b4-$b7 +MnemonicCLV, MnemonicLDA, MnemonicTSX, NULL, // $b8-$bb +MnemonicLDY, MnemonicLDA, MnemonicLDX, MnemonicLAX, // $bc-$bf +MnemonicCPY, MnemonicCMP, NULL, MnemonicDCP, // $c0-$c3 +MnemonicCPY, MnemonicCMP, MnemonicDEC, MnemonicDCP, // $c4-$c7 +MnemonicINY, MnemonicCMP, MnemonicDEX, NULL, // $c8-$cb +MnemonicCPY, MnemonicCMP, MnemonicDEC, MnemonicDCP, // $cc-$cf +MnemonicBNE, MnemonicCMP, NULL, MnemonicDCP, // $d0-$d3 +NULL, MnemonicCMP, MnemonicDEC, MnemonicDCP, // $d4-$d7 +MnemonicCLD, MnemonicCMP, NULL, MnemonicDCP, // $d8-$db +NULL, MnemonicCMP, MnemonicDEC, MnemonicDCP, // $dc-$df +MnemonicCPX, MnemonicSBC, NULL, MnemonicISC, // $e0-$e3 +MnemonicCPX, MnemonicSBC, MnemonicINC, MnemonicISC, // $e4-$e7 +MnemonicINX, MnemonicSBC, MnemonicNOP, NULL, // $e8-$eb +MnemonicCPX, MnemonicSBC, MnemonicINC, MnemonicISC, // $ec-$ef +MnemonicBEQ, MnemonicSBC, NULL, MnemonicISC, // $f0-$f3 +NULL, MnemonicSBC, MnemonicINC, MnemonicISC, // $f4-$f7 +MnemonicSED, MnemonicSBC, NULL, MnemonicISC, // $f8-$fb +NULL, 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[]) { - fputs(pre, global_output_stream); + PutString(pre); io_put_low_byte_hex(byte); - fputs(post, global_output_stream); + PutString(post); } // output 4-digit hex argument with correct addressing mode // static void put_argument4(const char pre[], int word, const char post[]) { - fputs(pre, global_output_stream); + PutString(pre); io_put_low_16b_hex(word); - fputs(post, global_output_stream); + PutString(post); } static int pc; // needed by "relative" addressing mode handler @@ -109,7 +109,7 @@ static int pc; // needed by "relative" addressing mode handler // to the program counter // addressing mode handler function for 1-byte-instructions -static int am_implicit(void) { +static int am_implied(void) { return(1); } // addressing mode handler functions for 2-byte-instructions @@ -167,70 +167,70 @@ static int am_indirect16(void) { // 6502 code table (addressing mode handler functions) int (*addressing_mode_of_code[])(void) = { - am_implicit, am_indirect_x, am_implicit, am_implicit, // $00-$03 - am_implicit, am_absolute8, am_absolute8, am_implicit, // $04-$07 - am_implicit, am_immediate, am_implicit, am_implicit, // $08-$0b - am_implicit, am_absolute16, am_absolute16, am_implicit, // $0c-$0f - am_relative, am_indirect_y, am_implicit, am_implicit, // $10-$13 - am_implicit, am_abs_x8, am_abs_x8, am_implicit, // $14-$17 - am_implicit, am_abs_y16, am_implicit, am_implicit, // $18-$1b - am_implicit, am_abs_x16, am_abs_x16, am_implicit, // $1c-$1f - am_absolute16, am_indirect_x, am_implicit, am_implicit, // $20-$23 - am_absolute8, am_absolute8, am_absolute8, am_implicit, // $24-$27 - am_implicit, am_immediate, am_implicit, am_implicit, // $28-$2b - am_absolute16, am_absolute16, am_absolute16, am_implicit, // $2c-$2f - am_relative, am_indirect_y, am_implicit, am_implicit, // $30-$33 - am_implicit, am_abs_x8, am_abs_x8, am_implicit, // $34-$37 - am_implicit, am_abs_y16, am_implicit, am_implicit, // $38-$3b - am_implicit, am_abs_x16, am_abs_x16, am_implicit, // $3c-$3f - am_implicit, am_indirect_x, am_implicit, am_implicit, // $40-$43 - am_implicit, am_absolute8, am_absolute8, am_implicit, // $44-$47 - am_implicit, am_immediate, am_implicit, am_implicit, // $48-$4b - am_absolute16, am_absolute16, am_absolute16, am_implicit, // $4c-$4f - am_relative, am_indirect_y, am_implicit, am_implicit, // $50-$53 - am_implicit, am_abs_x8, am_abs_x8, am_implicit, // $54-$57 - am_implicit, am_abs_y16, am_implicit, am_implicit, // $58-$5b - am_implicit, am_abs_x16, am_abs_x16, am_implicit, // $5c-$5f - am_implicit, am_indirect_x, am_implicit, am_implicit, // $60-$63 - am_implicit, am_absolute8, am_absolute8, am_implicit, // $64-$67 - am_implicit, am_immediate, am_implicit, am_implicit, // $68-$6b - am_indirect16, am_absolute16, am_absolute16, am_implicit, // $6c-$6f - am_relative, am_indirect_y, am_implicit, am_implicit, // $70-$73 - am_implicit, am_abs_x8, am_abs_x8, am_implicit, // $74-$77 - am_implicit, am_abs_y16, am_implicit, am_implicit, // $78-$7b - am_implicit, am_abs_x16, am_abs_x16, am_implicit, // $7c-$7f - am_implicit, am_indirect_x, am_implicit, am_implicit, // $80-$83 - am_absolute8, am_absolute8, am_absolute8, am_implicit, // $84-$87 - am_implicit, am_implicit, am_implicit, am_implicit, // $88-$8b - am_absolute16, am_absolute16, am_absolute16, am_implicit, // $8c-$8f - am_relative, am_indirect_y, am_implicit, am_implicit, // $90-$93 - am_abs_x8, am_abs_x8, am_abs_y8, am_implicit, // $94-$97 - am_implicit, am_abs_y16, am_implicit, am_implicit, // $98-$9b - am_implicit, am_abs_x16, am_implicit, am_implicit, // $9c-$9f - am_immediate, am_indirect_x, am_immediate, am_implicit, // $a0-$a3 - am_absolute8, am_absolute8, am_absolute8, am_implicit, // $a4-$a7 - am_implicit, am_immediate, am_implicit, am_implicit, // $a8-$ab - am_absolute16, am_absolute16, am_absolute16, am_implicit, // $ac-$af - am_relative, am_indirect_y, am_implicit, am_implicit, // $b0-$b3 - am_abs_x8, am_abs_x8, am_abs_y8, am_implicit, // $b4-$b7 - am_implicit, am_abs_y16, am_implicit, am_implicit, // $b8-$bb - am_abs_x16, am_abs_x16, am_abs_y16, am_implicit, // $bc-$bf - am_immediate, am_indirect_x, am_implicit, am_implicit, // $c0-$c3 - am_absolute8, am_absolute8, am_absolute8, am_implicit, // $c4-$c7 - am_implicit, am_immediate, am_implicit, am_implicit, // $c8-$cb - am_absolute16, am_absolute16, am_absolute16, am_implicit, // $cc-$cf - am_relative, am_indirect_y, am_implicit, am_implicit, // $d0-$d3 - am_implicit, am_abs_x8, am_abs_x8, am_implicit, // $d4-$d7 - am_implicit, am_abs_y16, am_implicit, am_implicit, // $d8-$db - am_implicit, am_abs_x16, am_abs_x16, am_implicit, // $dc-$df - am_immediate, am_indirect_x, am_implicit, am_implicit, // $e0-$e3 - am_absolute8, am_absolute8, am_absolute8, am_implicit, // $e4-$e7 - am_implicit, am_immediate, am_implicit, am_implicit, // $e8-$eb - am_absolute16, am_absolute16, am_absolute16, am_implicit, // $ec-$ef - am_relative, am_indirect_y, am_implicit, am_implicit, // $f0-$f3 - am_implicit, am_abs_x8, am_abs_x8, am_implicit, // $f4-$f7 - am_implicit, am_abs_y16, am_implicit, am_implicit, // $f8-$fb - am_implicit, am_abs_x16, am_abs_x16, am_implicit, // $fc-$ff +am_implied, am_indirect_x, am_implied, am_indirect_x, // $00-$03 +am_implied, am_absolute8, am_absolute8, am_absolute8, // $04-$07 +am_implied, am_immediate, am_implied, am_implied, // $08-$0b +am_implied, am_absolute16, am_absolute16, am_absolute16, // $0c-$0f +am_relative, am_indirect_y, am_implied, am_indirect_y, // $10-$13 +am_implied, am_abs_x8, am_abs_x8, am_abs_x8, // $14-$17 +am_implied, am_abs_y16, am_implied, am_abs_y16, // $18-$1b +am_implied, am_abs_x16, am_abs_x16, am_abs_x16, // $1c-$1f +am_absolute16, am_indirect_x, am_implied, am_indirect_x, // $20-$23 +am_absolute8, am_absolute8, am_absolute8, am_absolute8, // $24-$27 +am_implied, am_immediate, am_implied, am_implied, // $28-$2b +am_absolute16, am_absolute16, am_absolute16, am_absolute16, // $2c-$2f +am_relative, am_indirect_y, am_implied, am_indirect_y, // $30-$33 +am_implied, am_abs_x8, am_abs_x8, am_abs_x8, // $34-$37 +am_implied, am_abs_y16, am_implied, am_abs_y16, // $38-$3b +am_implied, am_abs_x16, am_abs_x16, am_abs_x16, // $3c-$3f +am_implied, am_indirect_x, am_implied, am_indirect_x, // $40-$43 +am_implied, am_absolute8, am_absolute8, am_absolute8, // $44-$47 +am_implied, am_immediate, am_implied, am_implied, // $48-$4b +am_absolute16, am_absolute16, am_absolute16, am_absolute16, // $4c-$4f +am_relative, am_indirect_y, am_implied, am_indirect_y, // $50-$53 +am_implied, am_abs_x8, am_abs_x8, am_abs_x8, // $54-$57 +am_implied, am_abs_y16, am_implied, am_abs_y16, // $58-$5b +am_implied, am_abs_x16, am_abs_x16, am_abs_x16, // $5c-$5f +am_implied, am_indirect_x, am_implied, am_indirect_x, // $60-$63 +am_implied, am_absolute8, am_absolute8, am_absolute8, // $64-$67 +am_implied, am_immediate, am_implied, am_implied, // $68-$6b +am_indirect16, am_absolute16, am_absolute16, am_absolute16, // $6c-$6f +am_relative, am_indirect_y, am_implied, am_indirect_y, // $70-$73 +am_implied, am_abs_x8, am_abs_x8, am_abs_x8, // $74-$77 +am_implied, am_abs_y16, am_implied, am_abs_y16, // $78-$7b +am_implied, am_abs_x16, am_abs_x16, am_abs_x16, // $7c-$7f +am_implied, am_indirect_x, am_implied, am_indirect_x, // $80-$83 +am_absolute8, am_absolute8, am_absolute8, am_absolute8, // $84-$87 +am_implied, am_implied, am_implied, am_implied, // $88-$8b +am_absolute16, am_absolute16, am_absolute16, am_absolute16, // $8c-$8f +am_relative, am_indirect_y, am_implied, am_implied, // $90-$93 +am_abs_x8, am_abs_x8, am_abs_y8, am_abs_y8, // $94-$97 +am_implied, am_abs_y16, am_implied, am_implied, // $98-$9b +am_implied, am_abs_x16, am_implied, am_implied, // $9c-$9f +am_immediate, am_indirect_x, am_immediate, am_indirect_x, // $a0-$a3 +am_absolute8, am_absolute8, am_absolute8, am_absolute8, // $a4-$a7 +am_implied, am_immediate, am_implied, am_implied, // $a8-$ab +am_absolute16, am_absolute16, am_absolute16, am_absolute16, // $ac-$af +am_relative, am_indirect_y, am_implied, am_indirect_y, // $b0-$b3 +am_abs_x8, am_abs_x8, am_abs_y8, am_abs_y8, // $b4-$b7 +am_implied, am_abs_y16, am_implied, am_implied, // $b8-$bb +am_abs_x16, am_abs_x16, am_abs_y16, am_abs_y16, // $bc-$bf +am_immediate, am_indirect_x, am_implied, am_indirect_x, // $c0-$c3 +am_absolute8, am_absolute8, am_absolute8, am_absolute8, // $c4-$c7 +am_implied, am_immediate, am_implied, am_implied, // $c8-$cb +am_absolute16, am_absolute16, am_absolute16, am_absolute16, // $cc-$cf +am_relative, am_indirect_y, am_implied, am_indirect_y, // $d0-$d3 +am_implied, am_abs_x8, am_abs_x8, am_abs_x8, // $d4-$d7 +am_implied, am_abs_y16, am_implied, am_abs_y16, // $d8-$db +am_implied, am_abs_x16, am_abs_x16, am_abs_x16, // $dc-$df +am_immediate, am_indirect_x, am_implied, am_indirect_x, // $e0-$e3 +am_absolute8, am_absolute8, am_absolute8, am_absolute8, // $e4-$e7 +am_implied, am_immediate, am_implied, am_implied, // $e8-$eb +am_absolute16, am_absolute16, am_absolute16, am_absolute16, // $ec-$ef +am_relative, am_indirect_y, am_implied, am_indirect_y, // $f0-$f3 +am_implied, am_abs_x8, am_abs_x8, am_abs_x8, // $f4-$f7 +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 @@ -239,7 +239,7 @@ void output_mnemonic(int byte) { const char* mnemo = mnemo_of_code[byte]; if(mnemo) - fputs(mnemo, global_output_stream); + PutString(mnemo); else put_argument2("$", byte, ""); } @@ -262,5 +262,5 @@ void obj_main(void) { GetByte(); } // report end-of-file - fputs("; ToACME: Reached end-of-file.\n", global_output_stream); + PutString("; ToACME: Reached end-of-file.\n"); } diff --git a/contrib/toacme/src/pet2iso.c b/contrib/toacme/src/pet2iso.c index 6077182..c30f0ce 100644 --- a/contrib/toacme/src/pet2iso.c +++ b/contrib/toacme/src/pet2iso.c @@ -15,7 +15,7 @@ // // Conversion table -const byte_t Pet2ISO_Table[256] = { +const char Pet2ISO_Table[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, diff --git a/contrib/toacme/src/pet2iso.h b/contrib/toacme/src/pet2iso.h index 883f20f..2cae39d 100644 --- a/contrib/toacme/src/pet2iso.h +++ b/contrib/toacme/src/pet2iso.h @@ -15,7 +15,8 @@ // Constants // -extern const byte_t Pet2ISO_Table[256]; // Conversion table +extern const char Pet2ISO_Table[256]; // Conversion table +#define PET2ISO(v) (Pet2ISO_Table[(unsigned char) v]) #endif diff --git a/contrib/toacme/src/scr2iso.c b/contrib/toacme/src/scr2iso.c index afb9866..88ae551 100644 --- a/contrib/toacme/src/scr2iso.c +++ b/contrib/toacme/src/scr2iso.c @@ -15,7 +15,7 @@ // // Conversion table -const byte_t Scr2ISO_Table[256] = { +const char Scr2ISO_Table[256] = { 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, diff --git a/contrib/toacme/src/scr2iso.h b/contrib/toacme/src/scr2iso.h index f4e0d3a..3c1d3e0 100644 --- a/contrib/toacme/src/scr2iso.h +++ b/contrib/toacme/src/scr2iso.h @@ -15,7 +15,8 @@ // Constants // -extern const byte_t Scr2ISO_Table[256]; // Conversion table +extern const char Scr2ISO_Table[256]; // Conversion table +#define SCR2ISO(v) (Scr2ISO_Table[(unsigned char) v]) #endif diff --git a/contrib/toacme/src/version.c b/contrib/toacme/src/version.c index 19b1139..8b08d1a 100644 --- a/contrib/toacme/src/version.c +++ b/contrib/toacme/src/version.c @@ -4,9 +4,9 @@ // // Version // -#define RELEASE_NUMBER "0.8" // change before release (FIXME) -#define CHANGE_DATE "16 Jun" // change before release -#define CHANGE_YEAR "2005" // change before release +#define RELEASE_NUMBER "0.9" // change before release (FIXME) +#define CHANGE_DATE "12 Mar" // change before release +#define CHANGE_YEAR "2006" // change before release #define HOME_PAGE "http://home.pages.de/~mac_bacon/smorbrod/acme/" @@ -34,8 +34,9 @@ void version_show_info(const char program_name[]) { "ToACME - converts other assemblers' source codes to ACME format.\n" "Release "RELEASE_NUMBER" ("CHANGE_DATE" "CHANGE_YEAR"), Copyright (C) 1999-"CHANGE_YEAR" Marco Baye.\n" PLATFORM_VERSION"\n" -"Fixes for AssBlaster macro conversion done by "STEFAN".\n" -"Token table for Giga-Assembler supplied by Andreas Paul.\n" +"Thanks to "STEFAN" for fixing the AssBlaster macro conversion code.\n" +"Thanks to Andreas Paul for helping with the Giga-Assembler mode.\n" +"Thanks to Arndt Dettke for helping with the Hypra-Assembler mode.\n" "\n" "The newest version can be found at the ACME homepage:\n" HOME_PAGE"\n" @@ -50,7 +51,7 @@ HOME_PAGE"\n" "--------------------------------------------------\n" "ab3 C64: AssBlaster 3.0 to 3.2 good\n" "f8ab C64: Flash8-AssBlaster ok\n" -"giga C64: Giga-Assembler needs testing\n" +"giga C64: Giga-Assembler ok\n" "hypra C64: Hypra-Assembler ok\n" "object object code files poor\n" "\n" @@ -66,15 +67,15 @@ extern void hypra_main(void); extern void obj_main(void); int version_parse_id(const char id[]) { - if(strcmp(id, "ab3") == NULL) + if(strcmp(id, "ab3") == 0) client_main = ab3_main; - else if(strcmp(id, "f8ab") == NULL) + else if(strcmp(id, "f8ab") == 0) client_main = f8ab_main; - else if(strcmp(id, "giga") == NULL) + else if(strcmp(id, "giga") == 0) client_main = giga_main; - else if(strcmp(id, "hypra") == NULL) + else if(strcmp(id, "hypra") == 0) client_main = hypra_main; - else if(strcmp(id, "object") == NULL) + else if(strcmp(id, "object") == 0) client_main = obj_main; return(client_main ? 0 : 1); } @@ -82,9 +83,9 @@ int version_parse_id(const char id[]) { // do the actual work // void version_main(void) { - fputs( -";ACME 0.85\n" + PutString( +";ACME 0.88\n" "; ToACME: Converted by ToACME, release " RELEASE_NUMBER ".\n" - , global_output_stream); + ); client_main(); }