commit 194e9c8

Devine Lu Linvega  ·  2023-01-03 01:33:57 +0000 UTC
parent 31360cf
Housekeeping
1 files changed,  +22, -39
+22, -39
  1@@ -211,9 +211,7 @@ writebyte(Uint8 b)
  2 static int
  3 writeopcode(char *w)
  4 {
  5-	Uint8 res;
  6-	res = writebyte(findopcode(w));
  7-	return res;
  8+	return writebyte(findopcode(w));
  9 }
 10 
 11 static int
 12@@ -227,9 +225,7 @@ writeshort(Uint16 s, int lit)
 13 static int
 14 writelitbyte(Uint8 b)
 15 {
 16-	if(!writebyte(findopcode("LIT"))) return 0;
 17-	if(!writebyte(b)) return 0;
 18-	return 1;
 19+	return writebyte(findopcode("LIT")) && writebyte(b);
 20 }
 21 
 22 static int
 23@@ -295,47 +291,38 @@ parse(char *w, FILE *f)
 24 			return error("Invalid sublabel", w);
 25 		break;
 26 	case '#': /* literals hex */
 27-		if(!sihx(w + 1) || (slen(w) != 3 && slen(w) != 5))
 28+		if(sihx(w + 1) && slen(w) == 3)
 29+			return writelitbyte(shex(w + 1));
 30+		else if(sihx(w + 1) && slen(w) == 5)
 31+			return writeshort(shex(w + 1), 1);
 32+		else
 33 			return error("Invalid hex literal", w);
 34-		if(slen(w) == 3) {
 35-			if(!writelitbyte(shex(w + 1))) return 0;
 36-		} else if(slen(w) == 5) {
 37-			if(!writeshort(shex(w + 1), 1)) return 0;
 38-		}
 39 		break;
 40 	case '_': /* raw byte relative */
 41 		makereference(p.scope, w, p.ptr);
 42-		if(!writebyte(0xff)) return 0;
 43-		break;
 44+		return writebyte(0xff);
 45 	case ',': /* literal byte relative */
 46 		makereference(p.scope, w, p.ptr);
 47-		if(!writelitbyte(0xff)) return 0;
 48-		break;
 49+		return writelitbyte(0xff);
 50 	case '-': /* raw byte absolute */
 51 		makereference(p.scope, w, p.ptr);
 52-		if(!writebyte(0xff)) return 0;
 53-		break;
 54+		return writebyte(0xff);
 55 	case '.': /* literal byte zero-page */
 56 		makereference(p.scope, w, p.ptr);
 57-		if(!writelitbyte(0xff)) return 0;
 58-		break;
 59+		return writelitbyte(0xff);
 60 	case ':': /* raw short absolute */
 61 	case '=':
 62 		makereference(p.scope, w, p.ptr);
 63-		if(!writeshort(0xffff, 0)) return 0;
 64-		break;
 65+		return writeshort(0xffff, 0);
 66 	case ';': /* literal short absolute */
 67 		makereference(p.scope, w, p.ptr);
 68-		if(!writeshort(0xffff, 1)) return 0;
 69-		break;
 70+		return writeshort(0xffff, 1);
 71 	case '!': /* JMI */
 72 		makereference(p.scope, w, p.ptr);
 73-		if(!writebyte(0x20) || !writeshort(0xffff, 0)) return 0;
 74-		break;
 75+		return writebyte(0x20) && writeshort(0xffff, 0);
 76 	case '?': /* JCI */
 77 		makereference(p.scope, w, p.ptr);
 78-		if(!writebyte(0x40) || !writeshort(0xffff, 0)) return 0;
 79-		break;
 80+		return writebyte(0x40) && writeshort(0xffff, 0);
 81 	case '"': /* raw string */
 82 		i = 0;
 83 		while((c = w[++i]))
 84@@ -346,17 +333,14 @@ parse(char *w, FILE *f)
 85 		if(slen(w) == 1) break; /* else fallthrough */
 86 	default:
 87 		/* opcode */
 88-		if(findopcode(w) || scmp(w, "BRK", 4)) {
 89-			if(!writeopcode(w)) return 0;
 90-		}
 91+		if(findopcode(w) || scmp(w, "BRK", 4))
 92+			return writeopcode(w);
 93 		/* raw byte */
 94-		else if(sihx(w) && slen(w) == 2) {
 95-			if(!writebyte(shex(w))) return 0;
 96-		}
 97+		else if(sihx(w) && slen(w) == 2)
 98+			return writebyte(shex(w));
 99 		/* raw short */
100-		else if(sihx(w) && slen(w) == 4) {
101-			if(!writeshort(shex(w), 0)) return 0;
102-		}
103+		else if(sihx(w) && slen(w) == 4)
104+			return writeshort(shex(w), 0);
105 		/* macro */
106 		else if((m = findmacro(w))) {
107 			for(i = 0; i < m->len; i++)
108@@ -365,8 +349,7 @@ parse(char *w, FILE *f)
109 			return 1;
110 		} else {
111 			makereference(p.scope, w - 1, p.ptr);
112-			if(!writebyte(0x60) || !writeshort(0xffff, 0))
113-				return 0;
114+			return writebyte(0x60) && writeshort(0xffff, 0);
115 		}
116 	}
117 	return 1;