X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=op.c;h=836f4de173b01add2b452414574c98b9c5c13953;hp=f0ec970cef2da8edc8984d374e226023c67ee1a7;hb=c38505ee4b2a0de59926107e52fb8bb84041a0e4;hpb=261f8d9198c4235bcdced4403ba391553e6bd0d1 diff --git a/op.c b/op.c index f0ec970..836f4de 100644 --- a/op.c +++ b/op.c @@ -2,7 +2,7 @@ // Jaguar Object Processor assembler // // by James Hammons -// (C) 2018 Underground Software +// (C) 2019 Underground Software // #include "op.h" @@ -17,23 +17,17 @@ #include "sect.h" #include "token.h" -// Macros to help define things (though largely unnecessary for this assembler) -#define BITMAP 3100 -#define SCBITMAP 3101 -#define GPUOBJ 3102 -#define BRANCH 3103 -#define STOP 3104 -#define NOP 3105 -#define JUMP 3106 +#define DEF_MO +#include "opkw.h" // For MO_* macros // Function prototypes -int HandleBitmap(void); -int HandleScaledBitmap(void); -int HandleGPUObject(void); -int HandleBranch(void); -int HandleStop(void); -int HandleNOP(void); -int HandleJump(void); +static int HandleBitmap(void); +static int HandleScaledBitmap(void); +static int HandleGPUObject(void); +static int HandleBranch(void); +static int HandleStop(void); +static int HandleNOP(void); +static int HandleJump(void); // OP assembler vars. static uint8_t lastObjType; @@ -55,19 +49,19 @@ int GenerateOPCode(int state) switch (state) { - case BITMAP: + case MO_BITMAP: return HandleBitmap(); - case SCBITMAP: + case MO_SCBITMAP: return HandleScaledBitmap(); - case GPUOBJ: + case MO_GPUOBJ: return HandleGPUObject(); - case BRANCH: + case MO_BRANCH: return HandleBranch(); - case STOP: + case MO_STOP: return HandleStop(); - case NOP: + case MO_NOP: return HandleNOP(); - case JUMP: + case MO_JUMP: return HandleJump(); } @@ -104,7 +98,7 @@ static inline uint64_t CheckFlags(char * s) // Form: bitmap , , , , , , , // , , , // -int HandleBitmap(void) +static int HandleBitmap(void) { uint64_t xpos = 0; uint64_t ypos = 0; @@ -183,7 +177,7 @@ 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); @@ -203,7 +197,7 @@ int HandleBitmap(void) // , , , , , // , , // -int HandleScaledBitmap(void) +static int HandleScaledBitmap(void) { uint64_t xpos = 0; uint64_t ypos = 0; @@ -308,7 +302,7 @@ 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); @@ -329,7 +323,7 @@ int HandleScaledBitmap(void) // Insert GPU object // Form: gpuobj , (bits 14-63 of this object) // -int HandleGPUObject(void) +static int HandleGPUObject(void) { uint64_t eval; uint16_t eattr; @@ -351,7 +345,7 @@ int HandleGPUObject(void) if (!(eattr & DEFINED)) return error("bad expression in data"); - at_eol(); + ErrorIfNotAtEOL(); uint64_t p1 = 0x02 | ((ypos * 2) << 3) | (eval << 14); @@ -368,7 +362,7 @@ int HandleGPUObject(void) // branch OPFLAG, // branch SECHALF, // -int HandleBranch(void) +static int HandleBranch(void) { char missingKeyword[] = "missing VC, OPFLAG, or SECHALF in branch"; uint32_t cc = 0; @@ -416,7 +410,7 @@ 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); @@ -431,7 +425,7 @@ int HandleBranch(void) // Insert a stop object // Form: stop // -int HandleStop(void) +static int HandleStop(void) { lastObjType = 4; D_quad(4LL); @@ -444,7 +438,7 @@ int HandleStop(void) // Insert a phrase sized "NOP" in the object list (psuedo-op) // Form: nop // -int HandleNOP(void) +static int HandleNOP(void) { uint64_t eval = (orgaddr + 8) & 0x3FFFF8; // This is "branch if VC > 2047". Branch addr is next phrase, so either way @@ -462,7 +456,7 @@ int HandleNOP(void) // Insert an unconditional jump in the object list (psuedo-op) // Form: jump // -int HandleJump(void) +static int HandleJump(void) { uint64_t eval; uint16_t eattr; @@ -474,7 +468,7 @@ 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);