#include <errno.h>
/* common */
+#include "addrsize.h"
+#include "mmodel.h"
#include "xmalloc.h"
/* cc65 */
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);
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;
}
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);
}