Initial commit. Harptool, some docs, and the initial logo attempt.
git-svn-id: http://www.cdkersey.com/harp/harptool@1 0246edb2-e076-4747-b392-db732a341fa2
This commit is contained in:
51
src/test/2thread.s
Normal file
51
src/test/2thread.s
Normal file
@@ -0,0 +1,51 @@
|
||||
/* 2-SIMD-thread test program! */
|
||||
|
||||
.perm x
|
||||
.entry
|
||||
.global
|
||||
entry: ldi %r0, #0;
|
||||
|
||||
ldi %r2, #1;
|
||||
ldi %r1, Array2;
|
||||
clone %r2;
|
||||
ldi %r1, Array1;
|
||||
ldi %r5, #2;
|
||||
jalis %r5, %r5, sumArr;
|
||||
ldi %r7, Array1;
|
||||
ld %r7, %r7, #0;
|
||||
jali %r5, printdec;
|
||||
ldi %r7, Array2;;
|
||||
ld %r7, %r7, #0;
|
||||
jali %r5, printdec
|
||||
trap;
|
||||
|
||||
/* Sum multiple arrays at once through the magic of SIMD! */
|
||||
sumArr: ldi %r3, #0;
|
||||
ldi %r4, #8;
|
||||
loop: ld %r2, %r1, #0;
|
||||
add %r3, %r3, %r2;
|
||||
addi %r1, %r1, #8;
|
||||
subi %r4, %r4, #1;
|
||||
rtop @p0, %r4;
|
||||
@p0 ? jmpi loop;
|
||||
st %r3, %r1, #-64;
|
||||
jmprt %r5;
|
||||
|
||||
.perm rw
|
||||
.word Array1 -1
|
||||
.word Array1_01 -2
|
||||
.word Array1_02 -3
|
||||
.word Array1_03 -4
|
||||
.word Array1_04 -5
|
||||
.word Array1_05 -6
|
||||
.word Array1_06 -7
|
||||
.word Array1_07 -8
|
||||
|
||||
.word Array2 1
|
||||
.word Array2_00 2
|
||||
.word Array2_01 3
|
||||
.word Array2_02 4
|
||||
.word Array2_03 5
|
||||
.word Array2_04 6
|
||||
.word Array2_05 7
|
||||
.word Array2_06 8
|
||||
32
src/test/Makefile
Normal file
32
src/test/Makefile
Normal file
@@ -0,0 +1,32 @@
|
||||
HARPLD = ../harptool -L
|
||||
HARPAS = ../harptool -A
|
||||
4WARCH = 2b16/1/8
|
||||
|
||||
all: sieve.bin 2thread.bin sieve.4w.bin 2thread.4w.bin
|
||||
|
||||
2thread.bin : lib.HOF 2thread.HOF boot.HOF
|
||||
$(HARPLD) -o 2thread.bin boot.HOF 2thread.HOF lib.HOF
|
||||
|
||||
2thread.4w.bin : lib.4w.HOF 2thread.4w.HOF boot.4w.HOF
|
||||
$(HARPLD) --arch $(4WARCH) -o 2thread.4w.bin boot.4w.HOF 2thread.4w.HOF 2thread.4w.HOF lib.4w.HOF
|
||||
|
||||
sieve.bin : lib.HOF sieve.HOF boot.HOF
|
||||
$(HARPLD) -o sieve.bin boot.HOF sieve.HOF lib.HOF
|
||||
|
||||
sieve.4w.bin : lib.4w.HOF sieve.4w.HOF boot.4w.HOF
|
||||
$(HARPLD) --arch $(4WARCH) -o sieve.4w.bin boot.4w.HOF sieve.4w.HOF lib.4w.HOF
|
||||
|
||||
%.4w.bin : %.4w.HOF
|
||||
$(HARPLD) --arch $(4WARCH) -o $@ $<
|
||||
|
||||
%.bin : %.HOF
|
||||
$(HARPLD) -o $@ $<
|
||||
|
||||
%.4w.HOF : %.s
|
||||
$(HARPAS) --arch $(4WARCH) -o $@ $<
|
||||
|
||||
%.HOF : %.s
|
||||
$(HARPAS) -o $@ $<
|
||||
|
||||
clean:
|
||||
rm -f *.HOF *.bin *~
|
||||
41
src/test/boot.4w.s
Normal file
41
src/test/boot.4w.s
Normal file
@@ -0,0 +1,41 @@
|
||||
.perm x
|
||||
|
||||
.entry
|
||||
boot: ldi %r5 kernEnt;
|
||||
skep %r5 ;
|
||||
ldi %r0 #0x1;
|
||||
ldi %r1 #0x18;
|
||||
ldi %r2 #0x4;
|
||||
muli %r2 %r2 #0x8;
|
||||
subi %r2 %r2 #0x1;
|
||||
shl %r0 %r0 %r2 ;
|
||||
tlbadd %r0 %r0 %r1 ;
|
||||
ei ;
|
||||
ldi %r5 entry;
|
||||
jmpru %r5 ;
|
||||
kernEnt: subi %r0 %r0 #0x8;
|
||||
rtop @p0 %r0 ;
|
||||
@p0 ? reti ;
|
||||
ldi %r8 #0x1;
|
||||
ldi %r1 #0x4;
|
||||
muli %r1 %r1 #0x8;
|
||||
subi %r1 %r1 #0x1;
|
||||
shl %r8 %r8 %r1 ;
|
||||
ld %r0 %r8 #0x0;
|
||||
subi %r1 %r0 #0x71;
|
||||
rtop @p0 %r1 ;
|
||||
notp @p0 @p0 ;
|
||||
@p0 ? halt ;
|
||||
st %r0 %r8 #0x0;
|
||||
ldi %r0 #0xa;
|
||||
st %r0 %r8 #0x0;
|
||||
reti ;
|
||||
entry: ldi %r7 hello;
|
||||
jali %r5 puts;
|
||||
jmpi entry;
|
||||
.perm rw
|
||||
.word hello 0x6c6c6548
|
||||
.word __anonWord0 0x41202c6f
|
||||
.word __anonWord1 0x6e616c74
|
||||
.word __anonWord2 0xa216174
|
||||
.word __anonWord3 0x0
|
||||
52
src/test/boot.s
Normal file
52
src/test/boot.s
Normal file
@@ -0,0 +1,52 @@
|
||||
/* Bootstrap program for HARP. */
|
||||
|
||||
.perm x
|
||||
.entry
|
||||
|
||||
boot: ldi %r5, kernEnt;
|
||||
skep %r5;
|
||||
|
||||
/* ldi %r0, #1;
|
||||
ldi %r1, #033;
|
||||
ldi %r2, __WORD;
|
||||
muli %r2, %r2, #8;
|
||||
subi %r2, %r2, #1;
|
||||
shl %r0, %r0, %r2;
|
||||
tlbadd %r0, %r0, %r1; */
|
||||
|
||||
ei;
|
||||
|
||||
ldi %r5, entry;
|
||||
jmpru %r5;
|
||||
|
||||
.perm x
|
||||
/* The Kernel Entry Point / Interrupt service routine. */
|
||||
kernEnt: subi %r0, %r0, #1;
|
||||
rtop @p0, %r0;
|
||||
@p0 ? jmpi kernEnt1; /* If it's not page not found, try again. */
|
||||
|
||||
ldi %r0, #077; /* Just map virt to phys, any address. */
|
||||
tlbadd %r1, %r1, %r0;
|
||||
reti;
|
||||
|
||||
kernEnt1: subi %r0, %r0, #7; /* If it's not console input, halt.*/
|
||||
rtop @p0, %r0;
|
||||
@p0 ? halt;
|
||||
|
||||
ldi %r8, #1;
|
||||
ldi %r1, __WORD;
|
||||
muli %r1, %r1, #8;
|
||||
subi %r1, %r1, #1;
|
||||
shl %r8, %r8, %r1;
|
||||
|
||||
ld %r0, %r8, #0;
|
||||
subi %r1, %r0, #0x71
|
||||
rtop @p0, %r1
|
||||
notp @p0, @p0
|
||||
@p0 ? halt; /* If it's 'q', halt. */
|
||||
st %r0, %r8, #0;
|
||||
ldi %r0, #0xa;
|
||||
st %r0, %r8, #0;
|
||||
reti;
|
||||
|
||||
|
||||
50
src/test/lib.s
Normal file
50
src/test/lib.s
Normal file
@@ -0,0 +1,50 @@
|
||||
/*******************************************************************************
|
||||
HARPtools by Chad D. Kersey, Summer 2011
|
||||
********************************************************************************
|
||||
|
||||
Sample HARP assmebly programs. These should work on anything from a 4x up.
|
||||
|
||||
*******************************************************************************/
|
||||
/* Library: print decimals and strings! */
|
||||
.perm x
|
||||
.global
|
||||
printdec: ldi %r8, #1;
|
||||
shli %r8, %r8, (__WORD*8 - 1);
|
||||
and %r6, %r8, %r7;
|
||||
rtop @p0, %r6;
|
||||
@p0 ? ldi %r6, #0x2d;
|
||||
@p0 ? st %r6, %r8, #0;
|
||||
@p0 ? neg %r7, %r7;
|
||||
printdec_l1: modi %r6, %r7, #10;
|
||||
divi %r7, %r7, #10;
|
||||
addi %r6, %r6, #0x30;
|
||||
st %r6, %r9, digstack;
|
||||
addi %r9, %r9, __WORD;
|
||||
rtop @p0, %r7;
|
||||
@p0 ? jmpi printdec_l1;
|
||||
printdec_l2: subi %r9, %r9, __WORD;
|
||||
ld %r6, %r9, digstack;
|
||||
st %r6, %r8, #0;
|
||||
rtop @p0, %r9;
|
||||
@p0 ? jmpi printdec_l2;
|
||||
ldi %r6, #0x0a;
|
||||
st %r6, %r8, #0;
|
||||
jmpr %r5
|
||||
|
||||
.global
|
||||
puts: ldi %r8, #1;
|
||||
shli %r8, %r8, (__WORD*8 - 1);
|
||||
|
||||
puts_l: ld %r6, %r7, #0;
|
||||
andi %r6, %r6, #0xff;
|
||||
rtop @p0, %r6;
|
||||
notp @p0, @p0;
|
||||
@p0 ? jmpi puts_end;
|
||||
st %r6, %r8, #0;
|
||||
addi %r7, %r7, #1;
|
||||
jmpi puts_l;
|
||||
puts_end: jmpr %r5
|
||||
|
||||
.perm rw
|
||||
.word digstack 0
|
||||
.word 9
|
||||
81
src/test/sieve.s
Normal file
81
src/test/sieve.s
Normal file
@@ -0,0 +1,81 @@
|
||||
/*******************************************************************************
|
||||
HARPtools by Chad D. Kersey, Summer 2011
|
||||
********************************************************************************
|
||||
|
||||
Sample HARP assmebly program.
|
||||
|
||||
*******************************************************************************/
|
||||
/* sieve of erastophanes: Find some primes. */
|
||||
.def SIZE 0x2000 /* TODO: How should I write constants? */
|
||||
|
||||
.align 4096
|
||||
.perm x
|
||||
.entry
|
||||
.global
|
||||
entry: ldi %r7, hello
|
||||
jali %r5, puts
|
||||
ldi %r0, #2; /* i = 2 */
|
||||
loop1: muli %r1, %r0, __WORD;
|
||||
st %r0, %r1, array;
|
||||
addi %r0, %r0, #1;
|
||||
subi %r1, %r0, SIZE;
|
||||
rtop @p0, %r1;
|
||||
@p0 ? jmpi loop1;
|
||||
|
||||
ldi %r0, #1;
|
||||
|
||||
loop2: addi %r0, %r0, #1;
|
||||
muli %r1, %r0, __WORD;
|
||||
ld %r1, %r1, array;
|
||||
rtop @p0, %r1;
|
||||
notp @p0, @p0;
|
||||
@p0 ? jmpi loop2;
|
||||
|
||||
mul %r2, %r1, %r1;
|
||||
subi %r3, %r2, SIZE;
|
||||
neg %r3, %r3
|
||||
isneg @p0, %r3;
|
||||
@p0 ? jmpi end;
|
||||
|
||||
ldi %r3, #0;
|
||||
loop3: muli %r4, %r2, __WORD;
|
||||
st %r3, %r4, array;
|
||||
add %r2, %r2, %r1;
|
||||
ldi %r4, SIZE;
|
||||
sub %r4, %r2, %r4;
|
||||
isneg @p0, %r4;
|
||||
notp @p0, @p0;
|
||||
@p0 ? jmpi loop2;
|
||||
jmpi loop3;
|
||||
|
||||
end: ldi %r0, __WORD; /* i = 2 */
|
||||
shli %r0, %r0, #1;
|
||||
ldi %r11, #0;
|
||||
loop4: ld %r1, %r0, array;
|
||||
rtop @p0, %r1;
|
||||
@p0 ? addi %r7, %r1, #0;
|
||||
@p0 ? jali %r5, printdec;
|
||||
rtop @p0, %r1;
|
||||
@p0 ? addi %r11, %r11, #1;
|
||||
addi %r0, %r0, __WORD;
|
||||
ldi %r5, __WORD;
|
||||
muli %r5, %r5, SIZE;
|
||||
sub %r1, %r0, %r5;
|
||||
rtop @p0, %r1;
|
||||
@p0 ? jmpi loop4;
|
||||
|
||||
addi %r7, %r11, #0;
|
||||
jali %r5, printdec;
|
||||
trap; /* All traps currently cause a halt. */
|
||||
|
||||
.perm rw /* TODO: How should I write section permissions? */
|
||||
/* TODO: String literals! */
|
||||
.string hello "\"Harp!\" is how a harp seal says hello!\n"
|
||||
|
||||
.global
|
||||
.word array 0 /* Basically, 0 and 1 are pre-cleared. */
|
||||
.word _0 0 /* I would love to not have to give this a name. */
|
||||
.word 0x1ffe /* Should arithmetic be possible? Technically SIZE-2, but that
|
||||
would be hard. Should making symbols happen here be possible
|
||||
in general? Currently if it's not a name it must be a
|
||||
literal. */
|
||||
Reference in New Issue
Block a user