From 956a328a6f7157f38b985608fdd26e5a33304b26 Mon Sep 17 00:00:00 2001 From: fincs Date: Sun, 24 Jan 2016 11:58:16 +0100 Subject: [PATCH] Add proper support for the MOVA instruction --- Manual.md | 3 ++- source/picasso.h | 1 + source/picasso_assembler.cpp | 9 ++++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Manual.md b/Manual.md index 2dc70d5..a426938 100644 --- a/Manual.md +++ b/Manual.md @@ -238,7 +238,7 @@ Syntax | Description `rcp rDest, rSrc1` | `rsq rDest, rSrc1` | `mov rDest, rSrc1` | -`mova rSrc1` | +`mova idxReg, rSrc1` | `cmp rSrc1, opx, opy, rSrc2` | `call procName` | `for iReg` | @@ -261,6 +261,7 @@ Syntax | Description - In instructions that take two source operands, the first is wide and the second is narrow. - `dph`/`sge`/`slt` have a special form where the first operand is narrow and the second is wide. This usage is detected automatically by `picasso`. - `mad`, which takes three source operands, has two forms: the first is wide-wide-narrow, and the second is wide-narrow-wide. This is also detected automatically. Additionally, relative addressing is not supported. +- `idxReg`: Represents an indexing register to write to using the mova instruction. Can be `a0`, `a1` or `a01` (the latter writes to both `a0` and `a1`). - `iReg`: Represents an integer vector uniform source operand. - `bReg`: Represents a boolean uniform source operand. - `procName`: Represents the name of a procedure. diff --git a/source/picasso.h b/source/picasso.h index 43d3736..9807620 100644 --- a/source/picasso.h +++ b/source/picasso.h @@ -44,6 +44,7 @@ enum #define OPDESC_MASK_D123 OPDESC_MAKE(0xF, 0x1FF, 0x1FF, 0x1FF) #define OPDESC_MASK_D12 OPDESC_MAKE(0xF, 0x1FF, 0x1FF, 0) #define OPDESC_MASK_D1 OPDESC_MAKE(0xF, 0x1FF, 0, 0) +#define OPDESC_MASK_MOVA OPDESC_MAKE(0xC, 0x1FF, 0, 0) #define OPDESC_MASK_1 OPDESC_MAKE(0, 0x1FF, 0, 0) #define OPDESC_MASK_12 OPDESC_MAKE(0, 0x1FF, 0x1FF, 0) diff --git a/source/picasso_assembler.cpp b/source/picasso_assembler.cpp index bf7a253..775e5c2 100644 --- a/source/picasso_assembler.cpp +++ b/source/picasso_assembler.cpp @@ -855,13 +855,20 @@ DEF_COMMAND(format5) DEF_COMMAND(formatmova) { + NEXT_ARG(targetReg); NEXT_ARG(src1Name); ENSURE_NO_MORE_ARGS(); + int mask; + if (strcmp(targetReg, "a0")==0) mask = BIT(3); + else if (strcmp(targetReg, "a1")==0) mask = BIT(2); + else if (strcmp(targetReg, "a01")==0) mask = BIT(3) | BIT(2); + else return throwError("invalid destination register for mova: %s\n", targetReg); + ARG_TO_SRC1_REG2(rSrc1, src1Name); int opdesc = 0; - safe_call(findOrAddOpdesc(opdesc, OPDESC_MAKE(0, rSrc1Sw, 0, 0), OPDESC_MASK_1)); + safe_call(findOrAddOpdesc(opdesc, OPDESC_MAKE(mask, rSrc1Sw, 0, 0), OPDESC_MASK_MOVA)); #ifdef DEBUG printf("%s:%02X d%02X (0x%X)\n", cmdName, opcode, rSrc1, opdesc);