commit d60c5a0
Devine Lu Linvega
·
2022-08-06 19:17:34 +0000 UTC
parent 7a12088
Removed optimizations from uxnasm
1 files changed,
+2,
-19
+2,
-19
1@@ -44,8 +44,6 @@ typedef struct {
2 } Program;
3
4 Program p;
5-static int litlast = 0;
6-static int jsrlast = 0;
7
8 /* clang-format off */
9
10@@ -207,8 +205,6 @@ writebyte(Uint8 b)
11 return error("Memory overwrite", "");
12 p.data[p.ptr++] = b;
13 p.length = p.ptr;
14- litlast = 0;
15- jsrlast = 0;
16 return 1;
17 }
18
19@@ -217,8 +213,6 @@ writeopcode(char *w)
20 {
21 Uint8 res;
22 res = writebyte(findopcode(w));
23- if(scmp(w, "JSR2", 4))
24- jsrlast = 1;
25 return res;
26 }
27
28@@ -233,15 +227,8 @@ writeshort(Uint16 s, int lit)
29 static int
30 writelitbyte(Uint8 b)
31 {
32- if(litlast) { /* literals optimization */
33- Uint8 hb = p.data[p.ptr - 1];
34- p.ptr -= 2;
35- p.length = p.ptr;
36- return writeshort((hb << 8) + b, 1);
37- }
38 if(!writebyte(findopcode("LIT"))) return 0;
39 if(!writebyte(b)) return 0;
40- litlast = 1;
41 return 1;
42 }
43
44@@ -292,24 +279,20 @@ parse(char *w, FILE *f)
45 if(!sihx(w + 1))
46 return error("Invalid padding", w);
47 p.ptr = shex(w + 1);
48- litlast = jsrlast = 0;
49 break;
50 case '$': /* pad-relative */
51 if(!sihx(w + 1))
52 return error("Invalid padding", w);
53 p.ptr += shex(w + 1);
54- litlast = jsrlast = 0;
55 break;
56 case '@': /* label */
57 if(!makelabel(w + 1))
58 return error("Invalid label", w);
59 scpy(w + 1, p.scope, 0x40);
60- litlast = jsrlast = 0;
61 break;
62 case '&': /* sublabel */
63 if(!makelabel(sublabel(subw, p.scope, w + 1)))
64 return error("Invalid sublabel", w);
65- litlast = jsrlast = 0;
66 break;
67 case '#': /* literals hex */
68 if(!sihx(w + 1) || (slen(w) != 3 && slen(w) != 5))
69@@ -321,11 +304,11 @@ parse(char *w, FILE *f)
70 }
71 break;
72 case '.': /* literal byte zero-page */
73- makereference(p.scope, w, p.ptr - litlast);
74+ makereference(p.scope, w, p.ptr);
75 if(!writelitbyte(0xff)) return 0;
76 break;
77 case ',': /* literal byte relative */
78- makereference(p.scope, w, p.ptr - litlast);
79+ makereference(p.scope, w, p.ptr);
80 if(!writelitbyte(0xff)) return 0;
81 break;
82 case ';': /* literal short absolute */