From 18966d9339fbe39c24f0a9de6fbf92dff0a7c1e2 Mon Sep 17 00:00:00 2001 From: chad Date: Fri, 30 May 2014 09:54:01 -0600 Subject: [PATCH] New sample program. --- src/test/Makefile | 12 +++++++++--- src/test/lfsr.s | 26 ++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 src/test/lfsr.s diff --git a/src/test/Makefile b/src/test/Makefile index 3f7db684..51a26aeb 100644 --- a/src/test/Makefile +++ b/src/test/Makefile @@ -5,12 +5,12 @@ HARPDIS = ../harptool -D 4BARCH = 4b16/16/2 all: simple.bin sieve.bin 2thread.bin simple.4b.bin sieve.4b.bin 2thread.4b.bin bubble.bin bubble.4b.bin dotprod.bin dotprod.4b.bin matmul.bin matmul.4b.bin \ - matmul-mt.s + matmul-mt.s lfsr.bin run: simple.out sieve.out 2thread.out simple.4b.out sieve.4b.out 2thread.4b.out bubble.out bubble.4b.out dotprod.out dotprod.4b.out matmul.out matmul.4b.out\ - matmul-mt.out + matmul-mt.out lfsr.4b.out lfsr.out -disas: simple.d sieve.d 2thread.d simple.4b.d sieve.4b.d 2thread.4b.d bubble.d bubble.4b.d dotprod.d dotprod.4b.d matmul.d matmul.4b.d matmul-mt.d +disas: simple.d sieve.d 2thread.d simple.4b.d sieve.4b.d 2thread.4b.d bubble.d bubble.4b.d dotprod.d dotprod.4b.d matmul.d matmul.4b.d matmul-mt.d lfsr.d %.4b.out : %.4b.bin $(HARPEM) -a $(4BARCH) -c $< > $@ @@ -36,6 +36,9 @@ simple.bin : boot.HOF lib.HOF simple.HOF sieve.bin : boot.HOF lib.HOF sieve.HOF $(HARPLD) -o $@ $^ +lfsr.bin : boot.HOF lib.HOF lfsr.HOF + $(HARPLD) -o $@ $^ + dotprod.bin : boot.HOF lib.HOF dotprod.HOF $(HARPLD) -o $@ $^ @@ -57,6 +60,9 @@ dotprod.4b.bin : boot.4b.HOF lib.4b.HOF dotprod.4b.HOF matmul.4b.bin : boot.4b.HOF lib.4b.HOF matmul.4b.HOF $(HARPLD) --arch $(4BARCH) -o $@ $^ +lfsr.4b.bin : boot.4b.HOF lib.4b.HOF lfsr.4b.HOF + $(HARPLD) --arch $(4BARCH) -o $@ $^ + %.4b.bin : %.4b.HOF $(HARPLD) --arch $(4BARCH) -o $@ $< diff --git a/src/test/lfsr.s b/src/test/lfsr.s new file mode 100644 index 00000000..3a27d328 --- /dev/null +++ b/src/test/lfsr.s @@ -0,0 +1,26 @@ +.perm x +.entry +.global +entry: ldi %r0, #0x1234; + ldi %r3, #100; + +loop: ori %r7, %r0, #0; + jali %r5, printhex + jali %r5, lfsr_step + + subi %r3, %r3, #1 + rtop @p0, %r3 + @p0 ? jmpi loop + + halt + +/* %r0: value and return value + * %r5: return address + */ +lfsr_step: shri %r1, %r0, #30 + shri %r2, %r0, #2 + xor %r1, %r1, %r2 + andi %r1, %r1, #1 + shli %r0, %r0, #1 + or %r0, %r0, %r1 + jmpr %r5