/* */
/* */
/* (C) 2003 Ullrich von Bassewitz */
-/* Römerstraße 52 */
+/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
#include <string.h>
/* common */
+#include "addrsize.h"
#include "mmodel.h"
/*****************************************************************************/
-/* Data */
+/* Data */
/*****************************************************************************/
"huge",
};
+/* Address sizes for the segments */
+unsigned char CodeAddrSize = ADDR_SIZE_ABS;
+unsigned char DataAddrSize = ADDR_SIZE_ABS;
+unsigned char ZpAddrSize = ADDR_SIZE_ZP;
+
/*****************************************************************************/
-/* Code */
+/* Code */
/*****************************************************************************/
/* Check all CPU names */
for (I = 0; I < MMODEL_COUNT; ++I) {
- if (strcmp (MemoryModelNames[I], Name) == 0) {
- return (mmodel_t)I;
- }
+ if (strcmp (MemoryModelNames[I], Name) == 0) {
+ return (mmodel_t)I;
+ }
}
/* Not found */
+void SetMemoryModel (mmodel_t Model)
+/* Set the memory model updating the MemoryModel variables and the address
+** sizes for the segments.
+*/
+{
+ /* Remember the memory model */
+ MemoryModel = Model;
+
+ /* Set the address sizes for the segments */
+ switch (MemoryModel) {
+
+ case MMODEL_NEAR:
+ /* Code: near, data: near */
+ CodeAddrSize = ADDR_SIZE_ABS;
+ DataAddrSize = ADDR_SIZE_ABS;
+ break;
+
+ case MMODEL_FAR:
+ /* Code: far, data: near */
+ CodeAddrSize = ADDR_SIZE_FAR;
+ DataAddrSize = ADDR_SIZE_ABS;
+ break;
+
+ case MMODEL_HUGE:
+ /* Code: far, data: far */
+ CodeAddrSize = ADDR_SIZE_FAR;
+ DataAddrSize = ADDR_SIZE_FAR;
+ break;
+
+ default:
+ break;
+ }
+
+ /* Zeropage is always zeropage */
+ ZpAddrSize = ADDR_SIZE_ZP;
+}