]> Shamusworld >> Repos - rmac/commitdiff
6502 mode: fix clearing of its RAM space with each .6502 invocation. Also fixed chptr...
authorggn <ggn.dbug@gmail.com>
Fri, 21 Apr 2017 11:49:33 +0000 (14:49 +0300)
committerShamus Hammons <jlhamm@acm.org>
Fri, 21 Apr 2017 18:42:40 +0000 (13:42 -0500)
6502.c
direct.c
direct.h
docs/rmac.rst
sect.c
token.c
token.h

diff --git a/6502.c b/6502.c
index afc0ba1aa5839ce577b3321604ed1cfff7d1acc4..099c89d115f2ab208560b8705c2c0fb38ca02e5b 100644 (file)
--- a/6502.c
+++ b/6502.c
@@ -25,6 +25,7 @@ static uint16_t orgmap[1024][2];              // Mark all 6502 org changes
 // Exported vars
 const char in_6502mode[] = "directive illegal in .6502 section";
 uint16_t * currentorg = &orgmap[0][0]; // Current org range
 // Exported vars
 const char in_6502mode[] = "directive illegal in .6502 section";
 uint16_t * currentorg = &orgmap[0][0]; // Current org range
+char strtoa8[128];     // ASCII to Atari 800 internal conversion table
 
 //
 // 6502 addressing modes;
 
 //
 // 6502 addressing modes;
@@ -145,9 +146,24 @@ static int abs2zp[] =
        -1                      // ZPY
 };
 
        -1                      // ZPY
 };
 
+static char a8internal[] =
+{
+    ' ', 0,   '!', 1,   '"', 2,   '#', 3,   '$',  4,   '%', 5,   '&', 6,   '\'', 7,
+    '(', 8,   ')', 9,   '*', 10,  '+', 11,  ',',  12,  '-', 13,  '.', 14,  '/',  15,
+    '0', 16,  '1', 17,  '2', 18,  '3', 19,  '4',  20,  '5', 21,  '6', 22,  '7',  23,
+    '8', 24,  '9', 25,  ':', 26,  ';', 27,  '<',  28,  '=', 29,  '>', 30,  '?',  31,
+    '@', 32,  'A', 33,  'B', 34,  'C', 35,  'D',  36,  'E', 37,  'F', 38,  'G',  39,
+    'H', 40,  'I', 41,  'J', 42,  'K', 43,  'L',  44,  'M', 45,  'N', 46,  'O',  47,
+    'P', 48,  'Q', 49,  'R', 50,  'S', 51,  'T',  52,  'U', 53,  'V', 54,  'W',  55,
+    'X', 56,  'Y', 57,  'Z', 58,  '[', 59,  '\\', 60,  ']', 61,  '^', 62,  '_',  63,
+    'a', 97,  'b', 98,  'c', 99,  'd', 100, 'e',  101, 'f', 102, 'g', 103, 'h',  104,
+    'i', 105, 'j', 106, 'k', 107, 'l', 108, 'm',  109, 'n', 110, 'o', 111, 'p',  112,
+    'q', 113, 'r', 114, 's', 115, 't', 116, 'u',  117, 'v', 118, 'w', 119, 'x',  120,
+    'y', 121, 'z', 122
+};
 
 //
 
 //
-// Initialize 6502 assembler
+//  initialize 6502 assembler
 //
 void Init6502()
 {
 //
 void Init6502()
 {
@@ -186,8 +202,26 @@ void Init6502()
 
        // Set up first org section (set to zero)
        orgmap[0][0] = 0;
 
        // Set up first org section (set to zero)
        orgmap[0][0] = 0;
-}
 
 
+    SwitchSection(M6502);      // Switch to 6502 section
+    //
+    // Initialise string conversion table(s)
+    //
+
+    char *p = a8internal;
+    memset(strtoa8, 31, 128);   // 31=fallback value ("?")
+    for (; p < a8internal + sizeof(a8internal); p += 2)
+    {
+        strtoa8[p[0]] = p[1];
+    }
+
+    if (challoc == 0) {
+        // Allocate and clear 64K of space for the 6502 section
+        chcheck(UPSEG_SIZE);
+        memset(sect[M6502].scode->chptr, 0, UPSEG_SIZE);
+    }
+    SwitchSection(TEXT);    // Go back to TEXT
+}
 
 //
 // .6502 --- enter 6502 mode
 
 //
 // .6502 --- enter 6502 mode
@@ -197,13 +231,6 @@ int d_6502()
        SaveSection();                  // Save curent section
        SwitchSection(M6502);   // Switch to 6502 section
 
        SaveSection();                  // Save curent section
        SwitchSection(M6502);   // Switch to 6502 section
 
-       if (challoc == 0)
-       {
-               // Allocate and clear 64K of space for the 6502 section
-               chcheck(UPSEG_SIZE);
-               memset(sect[M6502].scode->chptr, 0, UPSEG_SIZE);
-       }
-
        return 0;
 }
 
        return 0;
 }
 
@@ -556,10 +583,6 @@ badmode:
 // Generate 6502 object output file.
 //
 // ggn: converted into a com/exe/xex output format
 // Generate 6502 object output file.
 //
 // ggn: converted into a com/exe/xex output format
-//      Notes: 1. The $FFFF is only mandatory for the first segment, but let's
-//                dump it everywhere for now
-//             2. It's still dumping pages instead of more fine grained stuff.
-//                Should look into this - a8 people don't like waste so much ;)
 void m6502obj(int ofd)
 {
        uint16_t exeheader[3];
 void m6502obj(int ofd)
 {
        uint16_t exeheader[3];
index 6a41e82ed9991b9b9a5cd6f8506f42b5b0494b7d..b7dfb853791d4e236d8803c2ec4ca576b20312d0 100644 (file)
--- a/direct.c
+++ b/direct.c
@@ -27,6 +27,7 @@ TOKEN exprbuf[128];                   // Expression buffer
 SYM * symbolPtr[1000000];      // Symbol pointers table
 static long unused;                    // For supressing 'write' warnings
 char buffer[256];                      // Scratch buffer for messages
 SYM * symbolPtr[1000000];      // Symbol pointers table
 static long unused;                    // For supressing 'write' warnings
 char buffer[256];                      // Scratch buffer for messages
+int stringtype;             // Non-zero if we need any special string conversions
 
 // Function prototypes
 int d_unimpl(void);
 
 // Function prototypes
 int d_unimpl(void);
@@ -989,8 +990,21 @@ int d_dc(WORD siz)
                        if ((challoc - ch_size) < i)
                                chcheck(i);
 
                        if ((challoc - ch_size) < i)
                                chcheck(i);
 
-                       for(p=string[tok[1]]; *p!=EOS; p++)
+            if (stringtype == NORMAL)
+            {
+                for (p = string[tok[1]]; *p != EOS; p++)
                                D_byte(*p);
                                D_byte(*p);
+            }
+            else if(stringtype == A8INT)
+            {    
+                for (p = string[tok[1]]; *p != EOS; p++)
+                D_byte(strtoa8[*p]);          
+            }
+            else
+            {
+                error("String format not supported yet");
+            }
+
 
                        tok += 2;
                        goto comma;
 
                        tok += 2;
                        goto comma;
index 27219e54f6198f7433b58feb4d04afe0606f4aaf..7b4625a11bb64a5d488900b835d2a3835ed62b39 100644 (file)
--- a/direct.h
+++ b/direct.h
@@ -15,6 +15,7 @@
 extern TOKEN exprbuf[];
 extern SYM * symbolPtr[];
 extern int (* dirtab[])();
 extern TOKEN exprbuf[];
 extern SYM * symbolPtr[];
 extern int (* dirtab[])();
+extern char strtoa8[];
 
 // Exported functions
 void auto_even(void);
 
 // Exported functions
 void auto_even(void);
index f6f445eca2726ee47b86465209be56fbb9164fd3..a463ba4b4c00ca63f6bd486a0516fbcc65d35880 100644 (file)
@@ -1591,8 +1591,8 @@ common in bitmap-graphics routines). For example:
 ======================
 
 RMAC will generate code for the Atari jaguar GPU and DSP custom RISC (Reduced
 ======================
 
 RMAC will generate code for the Atari jaguar GPU and DSP custom RISC (Reduced
-Instruction Set Computer) processors. See the Atari Jaguar Software reference Manual – Tom
-& Jerry for a complete listing of Jaguar GPU and DSP assembler mnemonics and addressing
+Instruction Set Computer) processors. See the Atari Jaguar Software reference Manual "Tom
+& Jerry" for a complete listing of Jaguar GPU and DSP assembler mnemonics and addressing
 modes.
 
 `Condition Codes`_
 modes.
 
 `Condition Codes`_
diff --git a/sect.c b/sect.c
index 7a88a5610693f2271e5154f75aab471d0b0bf887..cbb15187fa8f6514af7386463d1f1ac1b128e99f 100644 (file)
--- a/sect.c
+++ b/sect.c
@@ -130,6 +130,11 @@ void SwitchSection(int sno)
                challoc = cp->challoc;
                ch_size = cp->ch_size;
                chptr = cp->chptr + ch_size;
                challoc = cp->challoc;
                ch_size = cp->ch_size;
                chptr = cp->chptr + ch_size;
+        if (m6502)
+        {
+            // For 6502 mode, add the last org'd address
+            chptr = cp->chptr + orgaddr;
+        }
        }
        else
                challoc = ch_size = 0;
        }
        else
                challoc = ch_size = 0;
diff --git a/token.c b/token.c
index 9083c9903c002ba2711aa495d3ba0255515897c9..1ef99cf572fb0cfa9ca7b28b938333ab228e41f5 100644 (file)
--- a/token.c
+++ b/token.c
@@ -1161,6 +1161,7 @@ if (debug) printf("TokenizeLine: Calling fpop() from SRC_IREPT...\n");
                // Handle multiple-character tokens
                if (c & MULTX)
                {
                // Handle multiple-character tokens
                if (c & MULTX)
                {
+            stringtype = 0;
                        switch (*ln++)
                        {
                        case '!':               // ! or !=
                        switch (*ln++)
                        {
                        case '!':               // ! or !=
@@ -1174,6 +1175,11 @@ if (debug) printf("TokenizeLine: Calling fpop() from SRC_IREPT...\n");
 
                                continue;
                        case '\'':              // 'string'
 
                                continue;
                        case '\'':              // 'string'
+                if (m6502)
+                {
+                    stringtype = A8INT; // hardcoded for now, maybe this will change in the future
+                }
+                // Fall through
                        case '\"':              // "string"
                                c1 = ln[-1];
                                *tk++ = STRING;
                        case '\"':              // "string"
                                c1 = ln[-1];
                                *tk++ = STRING;
diff --git a/token.h b/token.h
index 91230e5f0182ff86ec789ac81de9ba3dccc83e3d..aaa4fd6088e878c94f0d84d7992b8ec344cafebe 100644 (file)
--- a/token.h
+++ b/token.h
 #define MULTX           64                                     // Multiple-character tokens
 #define DOT             128                                    // [bwlsBWSL] for what follows a `.'
 
 #define MULTX           64                                     // Multiple-character tokens
 #define DOT             128                                    // [bwlsBWSL] for what follows a `.'
 
+// "special" string types
+#define NORMAL          0                   // Standard for PC/ST/whatever
+#define A8INT           1                   // Atari 800 ATASCII translation
+#define PETSCII         2                   // lol
+#define ORICSCII        3                   // lolol
+
 // Conditional assembly structures
 IFENT {
        IFENT * if_prev;                // Ptr prev .if state block (or NULL)
 // Conditional assembly structures
 IFENT {
        IFENT * if_prev;                // Ptr prev .if state block (or NULL)
@@ -148,6 +154,7 @@ extern char tolowertab[];
 extern INOBJ * cur_inobj;
 extern int mjump_align;
 extern char * string[];
 extern INOBJ * cur_inobj;
 extern int mjump_align;
 extern char * string[];
+extern int stringtype;
 
 // Exported functions
 int include(int, char *);
 
 // Exported functions
 int include(int, char *);