Make byte encoding use 0xff for no predicate, otherwise preg num.
git-svn-id: http://www.cdkersey.com/harp/harptool@122 0246edb2-e076-4747-b392-db732a341fa2
This commit is contained in:
@@ -103,8 +103,8 @@ void Decoder::setRefs(const std::vector<Ref*> &refVec) {
|
|||||||
Instruction *ByteDecoder::decode(const vector<Byte> &v, Size &n) {
|
Instruction *ByteDecoder::decode(const vector<Byte> &v, Size &n) {
|
||||||
Instruction &inst = *(new Instruction());
|
Instruction &inst = *(new Instruction());
|
||||||
|
|
||||||
RegNum pred = readByte(v, n);
|
uint8_t pred = readByte(v, n);
|
||||||
if (pred) inst.setPred(pred - 1);
|
if (pred != 0xff) inst.setPred(pred);
|
||||||
|
|
||||||
unsigned op = readByte(v, n);
|
unsigned op = readByte(v, n);
|
||||||
inst.setOpcode(Instruction::Opcode(op));
|
inst.setOpcode(Instruction::Opcode(op));
|
||||||
@@ -190,8 +190,8 @@ ByteEncoder::ByteEncoder(const ArchDef &ad) {
|
|||||||
Size ByteEncoder::encode(Ref *&ref, vector<Byte> &v, Size n0, Instruction &i) {
|
Size ByteEncoder::encode(Ref *&ref, vector<Byte> &v, Size n0, Instruction &i) {
|
||||||
Size n(n0);
|
Size n(n0);
|
||||||
|
|
||||||
if (i.hasPred()) writeByte(v, n, i.getPred() + 1);
|
if (i.hasPred()) writeByte(v, n, i.getPred());
|
||||||
else writeByte(v, n, 0);
|
else writeByte(v, n, 0xff);
|
||||||
|
|
||||||
writeByte(v, n, Byte(i.getOpcode()));
|
writeByte(v, n, Byte(i.getOpcode()));
|
||||||
|
|
||||||
|
|||||||
@@ -12,26 +12,18 @@
|
|||||||
.perm x
|
.perm x
|
||||||
.entry
|
.entry
|
||||||
.global
|
.global
|
||||||
entry: ldi %r7, hello; jali %r5, puts;
|
entry:
|
||||||
|
|
||||||
ldi %r0, #2; /* i = 2 */
|
ldi %r0, #2; /* i = 2 */
|
||||||
loop1: addi %r7, %r0, #0;
|
loop1: addi %r7, %r0, #0;
|
||||||
jali %r5, printdec;
|
jali %r5, printdec;
|
||||||
|
|
||||||
muli %r1, %r0, __WORD;
|
muli %r1, %r0, __WORD;
|
||||||
ldi %r7, wrstr;
|
|
||||||
jali %r5, puts;
|
|
||||||
st %r0, %r1, array;
|
st %r0, %r1, array;
|
||||||
ldi %r7, wrfin;
|
|
||||||
jali %r5, puts;
|
|
||||||
addi %r0, %r0, #1;
|
addi %r0, %r0, #1;
|
||||||
subi %r1, %r0, SIZE;
|
subi %r1, %r0, SIZE;
|
||||||
rtop @p0, %r1;
|
rtop @p0, %r1;
|
||||||
@p0 ? jmpi loop1;
|
@p0 ? jmpi loop1;
|
||||||
|
|
||||||
ldi %r7, xstr;
|
|
||||||
jali %r5, puts;
|
|
||||||
|
|
||||||
ldi %r0, #1;
|
ldi %r0, #1;
|
||||||
loop2: addi %r0, %r0, #1;
|
loop2: addi %r0, %r0, #1;
|
||||||
muli %r1, %r0, __WORD;
|
muli %r1, %r0, __WORD;
|
||||||
@@ -78,10 +70,6 @@ loop4: ld %r1, %r0, array;
|
|||||||
trap; /* All traps currently cause a halt. */
|
trap; /* All traps currently cause a halt. */
|
||||||
|
|
||||||
.perm rw /* TODO: How should I write section permissions? */
|
.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
|
.global
|
||||||
array: .space 0x1000 /* SIZE words of space. */
|
array: .space 0x1000 /* SIZE words of space. */
|
||||||
|
|||||||
Reference in New Issue
Block a user