From 9aac60a6832a1062ed2a2704c7a989d09f1b5d56 Mon Sep 17 00:00:00 2001 From: fincs Date: Wed, 27 Dec 2017 14:44:20 +0100 Subject: [PATCH] Index regs can only be used with uniform regs (discovered by @Tilka) --- Manual.md | 2 +- source/picasso_assembler.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Manual.md b/Manual.md index 6381adc..c69049b 100644 --- a/Manual.md +++ b/Manual.md @@ -51,7 +51,7 @@ Registers may also be assigned additional names in order to make the code more l For convenience, registers may be addressed using an offset from a known register. This is called indexing. For example, `c8[4]` is equivalent to `c12`; and `r4[-2]` is equivalent to `r2`. Indexing is useful for addressing arrays of registers (such as matrices). -Some source operands of instructions (called SRC1) support relative addressing. This means that it is possible to use one of the three built-in indexing registers (`a0`, `a1` and `a2` aka `lcnt`) to address a register, e.g. `someArray[lcnt]`. Adding an offset is also supported, e.g. `someArray[lcnt+2]`. This is useful in FOR loops. +Some source operands of instructions (called SRC1) support relative addressing. This means that it is possible to use one of the three built-in indexing registers (`a0`, `a1` and `a2` aka `lcnt`) to address a register, e.g. `someArray[lcnt]`. Adding an offset is also supported, e.g. `someArray[lcnt+2]`. This is useful in FOR loops. Index registers can only be used with floating-point vector uniform registers, though. Normal floating-point vector registers may also be negated by prepending a minus sign before it, e.g. `-r2` or `-someArray[lcnt+2]`. diff --git a/source/picasso_assembler.cpp b/source/picasso_assembler.cpp index 52babbd..89d5abf 100644 --- a/source/picasso_assembler.cpp +++ b/source/picasso_assembler.cpp @@ -786,6 +786,8 @@ static int parseReg(char* pos, int& outReg, int& outSw, int* idxType = NULL) return throwError("invalid boolean uniform register: %s\n", pos); break; } + if (idxType && *idxType && outReg < 0x20 || outReg >= 0x80) + return throwError("index register not allowed with this kind of register\n"); outReg += regOffset; return 0; }