1
0
mirror of https://github.com/cc65/cc65.git synced 2024-09-29 17:56:21 +00:00

Implement character set translation and different target systems

git-svn-id: svn://svn.cc65.org/cc65/trunk@295 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2000-08-21 21:20:40 +00:00
parent 6f4a92b259
commit c77d0dea94
5 changed files with 45 additions and 9 deletions

View File

@ -46,6 +46,7 @@
#include "objcode.h" #include "objcode.h"
#include "objfile.h" #include "objfile.h"
#include "symtab.h" #include "symtab.h"
#include "target.h"
#include "toklist.h" #include "toklist.h"
#include "ulabel.h" #include "ulabel.h"
#include "expr.h" #include "expr.h"
@ -478,11 +479,15 @@ static ExprNode* Factor (void)
switch (Tok) { switch (Tok) {
case TOK_INTCON: case TOK_INTCON:
case TOK_CHARCON:
N = LiteralExpr (IVal); N = LiteralExpr (IVal);
NextTok (); NextTok ();
break; break;
case TOK_CHARCON:
N = LiteralExpr ((unsigned char) XlatChar ((char)IVal));
NextTok ();
break;
case TOK_NAMESPACE: case TOK_NAMESPACE:
NextTok (); NextTok ();
if (Tok != TOK_IDENT) { if (Tok != TOK_IDENT) {

View File

@ -44,6 +44,7 @@
#include "version.h" #include "version.h"
/* ca65 */ /* ca65 */
#include "abend.h"
#include "error.h" #include "error.h"
#include "expr.h" #include "expr.h"
#include "filetab.h" #include "filetab.h"
@ -60,6 +61,7 @@
#include "pseudo.h" #include "pseudo.h"
#include "scanner.h" #include "scanner.h"
#include "symtab.h" #include "symtab.h"
#include "target.h"
#include "ulabel.h" #include "ulabel.h"
@ -82,6 +84,7 @@ static void Usage (void)
" -l\t\t\tCreate a listing if assembly was ok\n" " -l\t\t\tCreate a listing if assembly was ok\n"
" -o name\t\tName the output file\n" " -o name\t\tName the output file\n"
" -s\t\t\tEnable smart mode\n" " -s\t\t\tEnable smart mode\n"
" -t sys\t\tSet the target system\n"
" -v\t\t\tIncrease verbosity\n" " -v\t\t\tIncrease verbosity\n"
" -D name[=value]\tDefine a symbol\n" " -D name[=value]\tDefine a symbol\n"
" -I dir\t\tSet an include directory search path\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" " --listing\t\tCreate a listing if assembly was ok\n"
" --pagelength n\tSet the page length for the listing\n" " --pagelength n\tSet the page length for the listing\n"
" --smart\t\tEnable smart mode\n" " --smart\t\tEnable smart mode\n"
" --target sys\t\tSet the target system\n"
" --verbose\t\tIncrease verbosity\n" " --verbose\t\tIncrease verbosity\n"
" --version\t\tPrint the assembler version\n", " --version\t\tPrint the assembler version\n",
ProgName); ProgName);
@ -168,8 +172,7 @@ static void DefineSymbol (const char* Def)
/* Check if have already a symbol with this name */ /* Check if have already a symbol with this name */
if (SymIsDef (SymName)) { if (SymIsDef (SymName)) {
fprintf (stderr, "`%s' is already defined\n", SymName); AbEnd ("`%s' is already defined", SymName);
exit (EXIT_FAILURE);
} }
/* Define the symbol */ /* Define the symbol */
@ -203,8 +206,7 @@ static void OptCPU (const char* Opt, const char* Arg)
SetCPU (CPU_SUNPLUS); SetCPU (CPU_SUNPLUS);
#endif #endif
} else { } else {
fprintf (stderr, "Invalid CPU: `%s'\n", Arg); AbEnd ("Invalid CPU: `%s'", Arg);
exit (EXIT_FAILURE);
} }
} }
@ -263,8 +265,7 @@ static void OptPageLength (const char* Opt, const char* Arg)
} }
Len = atoi (Arg); Len = atoi (Arg);
if (Len != -1 && (Len < MIN_PAGE_LEN || Len > MAX_PAGE_LEN)) { if (Len != -1 && (Len < MIN_PAGE_LEN || Len > MAX_PAGE_LEN)) {
fprintf (stderr, "Invalid page length: %d\n", Len); AbEnd ("Invalid page length: %d", Len);
exit (EXIT_FAILURE);
} }
PageLength = 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) static void OptVerbose (const char* Opt, const char* Arg)
/* Increase verbosity */ /* Increase verbosity */
{ {
@ -444,6 +463,7 @@ int main (int argc, char* argv [])
{ "--listing", 0, OptListing }, { "--listing", 0, OptListing },
{ "--pagelength", 1, OptPageLength }, { "--pagelength", 1, OptPageLength },
{ "--smart", 0, OptSmart }, { "--smart", 0, OptSmart },
{ "--target", 1, OptTarget },
{ "--verbose", 0, OptVerbose }, { "--verbose", 0, OptVerbose },
{ "--version", 0, OptVersion }, { "--version", 0, OptVersion },
}; };
@ -497,6 +517,10 @@ int main (int argc, char* argv [])
OptSmart (Arg, 0); OptSmart (Arg, 0);
break; break;
case 't':
OptTarget (Arg, GetArg (&I, 2));
break;
case 'v': case 'v':
OptVerbose (Arg, 0); OptVerbose (Arg, 0);
break; break;

View File

@ -32,6 +32,7 @@ OBJS = condasm.o \
repeat.o \ repeat.o \
scanner.o \ scanner.o \
symtab.o \ symtab.o \
target.o \
toklist.o \ toklist.o \
ulabel.o ulabel.o

View File

@ -90,6 +90,7 @@ OBJS = condasm.obj \
repeat.obj \ repeat.obj \
scanner.obj \ scanner.obj \
symtab.obj \ symtab.obj \
target.obj \
toklist.obj \ toklist.obj \
ulabel.obj ulabel.obj
@ -136,6 +137,7 @@ FILE pseudo.obj
FILE repeat.obj FILE repeat.obj
FILE scanner.obj FILE scanner.obj
FILE symtab.obj FILE symtab.obj
FILE target.obj
FILE toklist.obj FILE toklist.obj
FILE ulabel.obj FILE ulabel.obj
LIBRARY ..\common\common.lib LIBRARY ..\common\common.lib

View File

@ -58,6 +58,7 @@
#include "options.h" #include "options.h"
#include "repeat.h" #include "repeat.h"
#include "symtab.h" #include "symtab.h"
#include "target.h"
#include "pseudo.h" #include "pseudo.h"
@ -268,6 +269,8 @@ static void DoASCIIZ (void)
ErrorSkip (ERR_STRCON_EXPECTED); ErrorSkip (ERR_STRCON_EXPECTED);
return; return;
} }
/* Translate into target charset and emit */
XlatStr (SVal);
EmitData ((unsigned char*) SVal, strlen (SVal)); EmitData ((unsigned char*) SVal, strlen (SVal));
NextTok (); NextTok ();
if (Tok == TOK_COMMA) { if (Tok == TOK_COMMA) {
@ -302,7 +305,8 @@ static void DoByte (void)
{ {
while (1) { while (1) {
if (Tok == TOK_STRCON) { if (Tok == TOK_STRCON) {
/* A string */ /* A string, translate into target charset and emit */
XlatStr (SVal);
EmitData ((unsigned char*) SVal, strlen (SVal)); EmitData ((unsigned char*) SVal, strlen (SVal));
NextTok (); NextTok ();
} else { } else {