1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-28 19:29:53 +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 "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) {

View File

@ -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;

View File

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

View File

@ -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

View File

@ -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 {