Support for emulating ISZERO instruction.
This commit is contained in:
@@ -228,6 +228,8 @@ void Instruction::executeOn(Core &c) {
|
|||||||
break;
|
break;
|
||||||
case RTOP: pReg[pdest] = reg[rsrc[0]];
|
case RTOP: pReg[pdest] = reg[rsrc[0]];
|
||||||
break;
|
break;
|
||||||
|
case ISZERO: pReg[pdest] = !reg[rsrc[0]];
|
||||||
|
break;
|
||||||
case NOTP: pReg[pdest] = !(pReg[psrc[0]]);
|
case NOTP: pReg[pdest] = !(pReg[psrc[0]]);
|
||||||
break;
|
break;
|
||||||
case ISNEG: pReg[pdest] = (1ll<<(wordSz*8 - 1))®[rsrc[0]];
|
case ISNEG: pReg[pdest] = (1ll<<(wordSz*8 - 1))®[rsrc[0]];
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ HARPEM = ../harptool -E
|
|||||||
HARPDIS = ../harptool -D
|
HARPDIS = ../harptool -D
|
||||||
4BARCH = 4b16/16/2
|
4BARCH = 4b16/16/2
|
||||||
|
|
||||||
all: simple.bin sieve.bin 2thread.bin simple.4b.bin sieve.4b.bin 2thread.4b.bin
|
all: simple.bin sieve.bin 2thread.bin simple.4b.bin sieve.4b.bin 2thread.4b.bin bubble.bin bubble.4b.bin
|
||||||
|
|
||||||
run: simple.out sieve.out 2thread.out simple.4b.out sieve.4b.out 2thread.4b.out
|
run: simple.out sieve.out 2thread.out simple.4b.out sieve.4b.out 2thread.4b.out bubble.out bubble.4b.out
|
||||||
|
|
||||||
disas: simple.d sieve.d 2thread.d simple.4b.d sieve.4b.d 2thread.4b.d
|
disas: simple.d sieve.d 2thread.d simple.4b.d sieve.4b.d 2thread.4b.d bubble.d bubble.4b.d
|
||||||
|
|
||||||
%.4b.out : %.4b.bin
|
%.4b.out : %.4b.bin
|
||||||
$(HARPEM) -a $(4BARCH) -c $< > $@
|
$(HARPEM) -a $(4BARCH) -c $< > $@
|
||||||
@@ -22,6 +22,12 @@ disas: simple.d sieve.d 2thread.d simple.4b.d sieve.4b.d 2thread.4b.d
|
|||||||
2thread.4b.bin : boot.4b.HOF lib.4b.HOF 2thread.4b.HOF
|
2thread.4b.bin : boot.4b.HOF lib.4b.HOF 2thread.4b.HOF
|
||||||
$(HARPLD) --arch $(4BARCH) -o 2thread.4b.bin $^
|
$(HARPLD) --arch $(4BARCH) -o 2thread.4b.bin $^
|
||||||
|
|
||||||
|
bubble.bin : boot.HOF lib.HOF bubble.HOF
|
||||||
|
$(HARPLD) -o bubble.bin $^
|
||||||
|
|
||||||
|
bubble.4b.bin : boot.4b.HOF lib.4b.HOF bubble.4b.HOF
|
||||||
|
$(HARPLD) --arch $(4BARCH) -o bubble.4b.bin $^
|
||||||
|
|
||||||
simple.bin : boot.HOF lib.HOF simple.HOF
|
simple.bin : boot.HOF lib.HOF simple.HOF
|
||||||
$(HARPLD) -o $@ $^
|
$(HARPLD) -o $@ $^
|
||||||
|
|
||||||
|
|||||||
49
src/test/bubble.s
Normal file
49
src/test/bubble.s
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
/* Bubble Sort */
|
||||||
|
|
||||||
|
.def SIZE 100
|
||||||
|
|
||||||
|
.align 4096
|
||||||
|
.perm x
|
||||||
|
.global
|
||||||
|
|
||||||
|
entry: ldi %r1, Array; /* p = array; */
|
||||||
|
oloop: /* do { */
|
||||||
|
ori %r2, %r1, #0; /* q = p; */
|
||||||
|
iloop:
|
||||||
|
subi %r3, %r2, ArrayEnd; /* while (q != array+N) { */
|
||||||
|
iszero @p0, %r3;
|
||||||
|
@p0 ? jmpi onext;
|
||||||
|
|
||||||
|
ld %r3, %r2, #0; /* if (*q > *(q + 1)) { */
|
||||||
|
ld %r4, %r2, __WORD; /* temp = *(q + 1); */
|
||||||
|
sub %r5, %r3, %r4;
|
||||||
|
isneg @p0, %r5;
|
||||||
|
notp @p0, @p0;
|
||||||
|
@p0 ? jmpi inext;
|
||||||
|
st %r3, %r2, __WORD; /* *(q + 1) = *q; */
|
||||||
|
st %r3, %r2, #0; /* *q = temp; */
|
||||||
|
/* } */
|
||||||
|
inext: addi %r2, %r2, #1; /* q++; */
|
||||||
|
jmpi iloop; /* } */
|
||||||
|
onext: addi %r1, %r1, #1; /* p++; */
|
||||||
|
subi %r3, %r1, ArrayEnd; /* } while (p != p + SIZE); */
|
||||||
|
rtop @p0, %r3;
|
||||||
|
@p0 ? jmpi oloop;
|
||||||
|
|
||||||
|
/* p = array; do { printdec(*p); p++; } while(p != array+N); */
|
||||||
|
printresults: ldi %r1, Array;
|
||||||
|
printloop: ld %r7, %r1, #0;
|
||||||
|
jali %r5, printdec;
|
||||||
|
addi %r1, %r1, __WORD;
|
||||||
|
subi %r2, %r1, ArrayEnd;
|
||||||
|
rtop @p0, %r2;
|
||||||
|
@p0 ? jmpi printloop;
|
||||||
|
trap;
|
||||||
|
|
||||||
|
.align 4096
|
||||||
|
.perm rw
|
||||||
|
Array:
|
||||||
|
.word 3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0
|
||||||
|
.word 2 8 8 4 1 9 7 1 6 9 3 9 9 3 7 5 1 0 5 8 2 0 9 7 4 9 4 4 5 9 2 3 0
|
||||||
|
.word 7 8 1 6 4 0 6 2 8 6 2 0 8 9 9 8 6 2 8 0 3 4 8 2 5 3 4 2 1 1 7 0 6 7
|
||||||
|
ArrayEnd: .word 0
|
||||||
Reference in New Issue
Block a user