From c77d0dea94a33f1d035645f266782c5029837f32 Mon Sep 17 00:00:00 2001 From: cuz Date: Mon, 21 Aug 2000 21:20:40 +0000 Subject: [PATCH] Implement character set translation and different target systems git-svn-id: svn://svn.cc65.org/cc65/trunk@295 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/ca65/expr.c | 7 ++++++- src/ca65/main.c | 36 ++++++++++++++++++++++++++++++------ src/ca65/make/gcc.mak | 1 + src/ca65/make/watcom.mak | 4 +++- src/ca65/pseudo.c | 6 +++++- 5 files changed, 45 insertions(+), 9 deletions(-) diff --git a/src/ca65/expr.c b/src/ca65/expr.c index 5cd4610c4..ba3117857 100644 --- a/src/ca65/expr.c +++ b/src/ca65/expr.c @@ -46,6 +46,7 @@ #include "objcode.h" #include "objfile.h" #include "symtab.h" +#include "target.h" #include "toklist.h" #include "ulabel.h" #include "expr.h" @@ -478,11 +479,15 @@ static ExprNode* Factor (void) switch (Tok) { case TOK_INTCON: - case TOK_CHARCON: N = LiteralExpr (IVal); NextTok (); break; + case TOK_CHARCON: + N = LiteralExpr ((unsigned char) XlatChar ((char)IVal)); + NextTok (); + break; + case TOK_NAMESPACE: NextTok (); if (Tok != TOK_IDENT) { diff --git a/src/ca65/main.c b/src/ca65/main.c index 08f701ccf..697d47c32 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -44,6 +44,7 @@ #include "version.h" /* ca65 */ +#include "abend.h" #include "error.h" #include "expr.h" #include "filetab.h" @@ -60,6 +61,7 @@ #include "pseudo.h" #include "scanner.h" #include "symtab.h" +#include "target.h" #include "ulabel.h" @@ -82,6 +84,7 @@ static void Usage (void) " -l\t\t\tCreate a listing if assembly was ok\n" " -o name\t\tName the output file\n" " -s\t\t\tEnable smart mode\n" + " -t sys\t\tSet the target system\n" " -v\t\t\tIncrease verbosity\n" " -D name[=value]\tDefine a symbol\n" " -I dir\t\tSet an include directory search path\n" @@ -99,6 +102,7 @@ static void Usage (void) " --listing\t\tCreate a listing if assembly was ok\n" " --pagelength n\tSet the page length for the listing\n" " --smart\t\tEnable smart mode\n" + " --target sys\t\tSet the target system\n" " --verbose\t\tIncrease verbosity\n" " --version\t\tPrint the assembler version\n", ProgName); @@ -168,8 +172,7 @@ static void DefineSymbol (const char* Def) /* Check if have already a symbol with this name */ if (SymIsDef (SymName)) { - fprintf (stderr, "`%s' is already defined\n", SymName); - exit (EXIT_FAILURE); + AbEnd ("`%s' is already defined", SymName); } /* Define the symbol */ @@ -203,8 +206,7 @@ static void OptCPU (const char* Opt, const char* Arg) SetCPU (CPU_SUNPLUS); #endif } else { - fprintf (stderr, "Invalid CPU: `%s'\n", Arg); - exit (EXIT_FAILURE); + AbEnd ("Invalid CPU: `%s'", Arg); } } @@ -263,8 +265,7 @@ static void OptPageLength (const char* Opt, const char* Arg) } Len = atoi (Arg); if (Len != -1 && (Len < MIN_PAGE_LEN || Len > MAX_PAGE_LEN)) { - fprintf (stderr, "Invalid page length: %d\n", Len); - exit (EXIT_FAILURE); + AbEnd ("Invalid page length: %d", Len); } PageLength = Len; } @@ -279,6 +280,24 @@ static void OptSmart (const char* Opt, const char* Arg) +static void OptTarget (const char* Opt, const char* Arg) +/* Set the target system */ +{ + int T; + if (Arg == 0) { + NeedArg (Opt); + } + + /* Map the target name to a target id */ + T = MapTarget (Arg); + if (T < 0) { + AbEnd ("Invalid target name: `%s'", Arg); + } + Target = (target_t) T; +} + + + static void OptVerbose (const char* Opt, const char* Arg) /* Increase verbosity */ { @@ -444,6 +463,7 @@ int main (int argc, char* argv []) { "--listing", 0, OptListing }, { "--pagelength", 1, OptPageLength }, { "--smart", 0, OptSmart }, + { "--target", 1, OptTarget }, { "--verbose", 0, OptVerbose }, { "--version", 0, OptVersion }, }; @@ -497,6 +517,10 @@ int main (int argc, char* argv []) OptSmart (Arg, 0); break; + case 't': + OptTarget (Arg, GetArg (&I, 2)); + break; + case 'v': OptVerbose (Arg, 0); break; diff --git a/src/ca65/make/gcc.mak b/src/ca65/make/gcc.mak index 6407780dc..9bd03e597 100644 --- a/src/ca65/make/gcc.mak +++ b/src/ca65/make/gcc.mak @@ -32,6 +32,7 @@ OBJS = condasm.o \ repeat.o \ scanner.o \ symtab.o \ + target.o \ toklist.o \ ulabel.o diff --git a/src/ca65/make/watcom.mak b/src/ca65/make/watcom.mak index 220bb3500..e634ed4b7 100644 --- a/src/ca65/make/watcom.mak +++ b/src/ca65/make/watcom.mak @@ -90,6 +90,7 @@ OBJS = condasm.obj \ repeat.obj \ scanner.obj \ symtab.obj \ + target.obj \ toklist.obj \ ulabel.obj @@ -117,7 +118,7 @@ FILE condasm.obj FILE dbginfo.obj FILE ea.obj FILE error.obj -FILE expr.obj +FILE expr.obj FILE filetab.obj FILE fragment.obj FILE global.obj @@ -136,6 +137,7 @@ FILE pseudo.obj FILE repeat.obj FILE scanner.obj FILE symtab.obj +FILE target.obj FILE toklist.obj FILE ulabel.obj LIBRARY ..\common\common.lib diff --git a/src/ca65/pseudo.c b/src/ca65/pseudo.c index d5e76901f..8321ad3f9 100644 --- a/src/ca65/pseudo.c +++ b/src/ca65/pseudo.c @@ -58,6 +58,7 @@ #include "options.h" #include "repeat.h" #include "symtab.h" +#include "target.h" #include "pseudo.h" @@ -268,6 +269,8 @@ static void DoASCIIZ (void) ErrorSkip (ERR_STRCON_EXPECTED); return; } + /* Translate into target charset and emit */ + XlatStr (SVal); EmitData ((unsigned char*) SVal, strlen (SVal)); NextTok (); if (Tok == TOK_COMMA) { @@ -302,7 +305,8 @@ static void DoByte (void) { while (1) { if (Tok == TOK_STRCON) { - /* A string */ + /* A string, translate into target charset and emit */ + XlatStr (SVal); EmitData ((unsigned char*) SVal, strlen (SVal)); NextTok (); } else { -- 2.39.5