From: cuz Date: Sat, 29 Nov 2003 07:17:31 +0000 (+0000) Subject: Memory model additions X-Git-Tag: V2.12.0~1108 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b520b182d0c1e1fdbc03b8281b3eb42362f8b699;p=cc65 Memory model additions git-svn-id: svn://svn.cc65.org/cc65/trunk@2693 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/cc65/declare.c b/src/cc65/declare.c index 0d09f7f70..3aaee6f23 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -38,6 +38,8 @@ #include /* common */ +#include "addrsize.h" +#include "mmodel.h" #include "xmalloc.h" /* cc65 */ @@ -843,6 +845,13 @@ static FuncDesc* ParseFuncDecl (const DeclSpec* Spec) Sym = Sym->PrevSym; } + /* Add the default address size for the function */ + if (CodeAddrSize == ADDR_SIZE_FAR) { + F->Flags |= FD_FAR; + } else { + F->Flags |= FD_NEAR; + } + /* Leave the lexical level remembering the symbol tables */ RememberFunctionLevel (F); @@ -903,7 +912,10 @@ static void ApplyFunctionModifiers (type* T, unsigned Flags) Flags &= ~FD_FASTCALL; } - /* Add the flags */ + /* Remove the default function address size modifiers */ + F->Flags &= ~(FD_NEAR | FD_FAR); + + /* Add the new modifers */ F->Flags |= Flags; } diff --git a/src/cc65/main.c b/src/cc65/main.c index 78df3c22c..b720c5ce9 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -556,15 +556,23 @@ static void OptListOptSteps (const char* Opt attribute ((unused)), static void OptMemoryModel (const char* Opt, const char* Arg) /* Set the memory model */ { + mmodel_t M; + + /* Check the current memory model */ if (MemoryModel != MMODEL_UNKNOWN) { AbEnd ("Cannot use option `%s' twice", Opt); } - MemoryModel = FindMemoryModel (Arg); - if (MemoryModel == MMODEL_UNKNOWN) { + + /* Translate the memory model name and check it */ + M = FindMemoryModel (Arg); + if (M == MMODEL_UNKNOWN) { AbEnd ("Unknown memory model: %s", Arg); - } else if (MemoryModel == MMODEL_HUGE) { + } else if (M == MMODEL_HUGE) { AbEnd ("Unsupported memory model: %s", Arg); } + + /* Set the memory model */ + SetMemoryModel (M); }