diff --git a/src/enc.cpp b/src/enc.cpp index 97a966e8..43a2ca97 100644 --- a/src/enc.cpp +++ b/src/enc.cpp @@ -103,8 +103,8 @@ void Decoder::setRefs(const std::vector &refVec) { Instruction *ByteDecoder::decode(const vector &v, Size &n) { Instruction &inst = *(new Instruction()); - RegNum pred = readByte(v, n); - if (pred) inst.setPred(pred - 1); + uint8_t pred = readByte(v, n); + if (pred != 0xff) inst.setPred(pred); unsigned op = readByte(v, n); inst.setOpcode(Instruction::Opcode(op)); @@ -190,8 +190,8 @@ ByteEncoder::ByteEncoder(const ArchDef &ad) { Size ByteEncoder::encode(Ref *&ref, vector &v, Size n0, Instruction &i) { Size n(n0); - if (i.hasPred()) writeByte(v, n, i.getPred() + 1); - else writeByte(v, n, 0); + if (i.hasPred()) writeByte(v, n, i.getPred()); + else writeByte(v, n, 0xff); writeByte(v, n, Byte(i.getOpcode())); diff --git a/src/test/sieve.s b/src/test/sieve.s index ab7b4936..5fe4916f 100644 --- a/src/test/sieve.s +++ b/src/test/sieve.s @@ -12,26 +12,18 @@ .perm x .entry .global -entry: ldi %r7, hello; jali %r5, puts; - +entry: ldi %r0, #2; /* i = 2 */ loop1: addi %r7, %r0, #0; jali %r5, printdec; muli %r1, %r0, __WORD; - ldi %r7, wrstr; - jali %r5, puts; st %r0, %r1, array; - ldi %r7, wrfin; - jali %r5, puts; addi %r0, %r0, #1; subi %r1, %r0, SIZE; rtop @p0, %r1; @p0 ? jmpi loop1; - ldi %r7, xstr; - jali %r5, puts; - ldi %r0, #1; loop2: addi %r0, %r0, #1; muli %r1, %r0, __WORD; @@ -78,10 +70,6 @@ loop4: ld %r1, %r0, array; trap; /* All traps currently cause a halt. */ .perm rw /* TODO: How should I write section permissions? */ -hello: .string "\"Harp!\" is how a harp seal says hello!\n" -wrstr: .string "Doing write\n" -wrfin: .string "Did write\n" -xstr: .string "Exiting loop\n" .global array: .space 0x1000 /* SIZE words of space. */