]> Shamusworld >> Repos - rmac/blobdiff - op.c
Version bump for last commit. :-)
[rmac] / op.c
diff --git a/op.c b/op.c
index 6a78fbc01f6898a7b5ab05e39b7fab4caf1c1c48..6a7d51d6c45322bb213ff75769b2e6e53a0bbde1 100644 (file)
--- a/op.c
+++ b/op.c
@@ -37,7 +37,6 @@ static TOKEN fixupExpr[4] = { CONST, 0, 0, ENDEXPR };
 //static PTR fixupPtr = { .tk = (fixupExpr + 1) };             // C99 \o/
 static PTR fixupPtr = { (uint8_t *)(fixupExpr + 1) };  // meh, it works
 
-
 //
 // The main Object Processor assembler. Basically just calls the sub functions
 // to generate the appropriate code.
@@ -47,6 +46,11 @@ int GenerateOPCode(int state)
        if (!robjproc)
                return error("opcode only valid in OP mode");
 
+       // It's OK to call this before validating state. If the state is invalid, an
+       // error will be generated and no object file will be produced, so it
+       // doesn't matter if the line number symbols are a little off.
+       GENLINENOSYM();
+
        switch (state)
        {
        case MO_BITMAP:
@@ -68,7 +72,6 @@ int GenerateOPCode(int state)
        return error("unknown OP opcode");
 }
 
-
 static inline void GetSymbolUCFromTokenStream(char * s)
 {
        strcpy(s, string[tok[1]]);
@@ -76,7 +79,6 @@ static inline void GetSymbolUCFromTokenStream(char * s)
        tok += 2;
 }
 
-
 static inline uint64_t CheckFlags(char * s)
 {
        GetSymbolUCFromTokenStream(s);
@@ -89,10 +91,10 @@ static inline uint64_t CheckFlags(char * s)
                return 0x04;
        else if (strcmp(scratchbuf, "RELEASE") == 0)
                return 0x08;
+
        return 0;
 }
 
-
 //
 // Define a bitmap object
 // Form: bitmap <data>, <xloc>, <yloc>, <dwidth>, <iwidth>, <iheight>, <bpp>,
@@ -177,7 +179,7 @@ static int HandleBitmap(void)
                }
        }
 
-       at_eol();
+       ErrorIfNotAtEOL();
 
        uint64_t p1 = 0x00 | ((ypos * 2) << 3) | (iheight << 14) | (linkAddr << 21) | (dataAddr << 40);
        uint64_t p2 = xpos | (bpp << 12) | (pitch << 15) | (dwidth << 18) | (iwidth << 28) | (index << 38) | (flags << 45) | (firstpix << 49);
@@ -190,7 +192,6 @@ static int HandleBitmap(void)
        return OK;
 }
 
-
 //
 // Define a scaled bitmap object
 // Form: scbitmap <data>, <xloc>, <yloc>, <dwidth>, <iwidth>, <iheight>,
@@ -302,7 +303,7 @@ static int HandleScaledBitmap(void)
                }
        }
 
-       at_eol();
+       ErrorIfNotAtEOL();
 
        uint64_t p1 = 0x01 | ((ypos * 2) << 3) | (iheight << 14) | (linkAddr << 21) | (dataAddr << 40);
        uint64_t p2 = xpos | (bpp << 12) | (pitch << 15) | (dwidth << 18) | (iwidth << 28) | (index << 38) | (flags << 45) | (firstpix << 49);
@@ -318,10 +319,9 @@ static int HandleScaledBitmap(void)
        return OK;
 }
 
-
 //
 // Insert GPU object
-// Form: gpuobj <line #>, <userdata> (bits 14-63 of this object)
+// Form: gpuobj <userdata> (bits 3-63 of this object)
 //
 static int HandleGPUObject(void)
 {
@@ -329,25 +329,15 @@ static int HandleGPUObject(void)
        uint16_t eattr;
        SYM * esym = 0;
 
-       if (expr(exprbuf, &eval, &eattr, &esym) != OK)
-               return ERROR;
-
-       if (!(eattr & DEFINED))
-               return error("bad expression in y position");
-
-       uint64_t ypos = eval;
-
-       CHECK_COMMA;
-
        if (expr(exprbuf, &eval, &eattr, &esym) != OK)
                return ERROR;
 
        if (!(eattr & DEFINED))
                return error("bad expression in data");
 
-       at_eol();
+       ErrorIfNotAtEOL();
 
-       uint64_t p1 = 0x02 | ((ypos * 2) << 3) | (eval << 14);
+       uint64_t p1 = 0x02 | (eval << 3);
 
        lastObjType = 2;
        D_quad(p1);
@@ -355,7 +345,6 @@ static int HandleGPUObject(void)
        return OK;
 }
 
-
 //
 // Insert a branch object
 // Form: branch VC <condition (<, =, >)> <line #>, <link addr>
@@ -410,7 +399,7 @@ static int HandleBranch(void)
        if (!(eattr & DEFINED))
                AddFixup(FU_QUAD | FU_OBJLINK, sloc, exprbuf);
 
-       at_eol();
+       ErrorIfNotAtEOL();
 
        uint64_t p1 = 0x03 | (cc << 14) | ((ypos * 2) << 3) | ((eval & 0x3FFFF8) << 21);
 
@@ -420,7 +409,6 @@ static int HandleBranch(void)
        return OK;
 }
 
-
 //
 // Insert a stop object
 // Form: stop
@@ -433,7 +421,6 @@ static int HandleStop(void)
        return OK;
 }
 
-
 //
 // Insert a phrase sized "NOP" in the object list (psuedo-op)
 // Form: nop
@@ -451,7 +438,6 @@ static int HandleNOP(void)
        return OK;
 }
 
-
 //
 // Insert an unconditional jump in the object list (psuedo-op)
 // Form: jump <link addr>
@@ -468,7 +454,7 @@ static int HandleJump(void)
        if (!(eattr & DEFINED))
                AddFixup(FU_QUAD | FU_OBJLINK, sloc, exprbuf);
 
-       at_eol();
+       ErrorIfNotAtEOL();
 
        // This is "branch if VC < 2047", which pretty much guarantees the branch.
        uint64_t p1 = 0x03 | (1 << 14) | (0x7FF << 3) | ((eval & 0x3FFFF8) << 21);
@@ -478,4 +464,3 @@ static int HandleJump(void)
 
        return OK;
 }
-