From fa3fa16330b07b13c8d11f1c83f090c328247547 Mon Sep 17 00:00:00 2001 From: Tom Schouten Date: Fri, 28 Feb 2003 09:57:32 +0000 Subject: pdp scaf svn path=/trunk/externals/pdp/; revision=443 --- scaf/Makefile.config | 34 --- scaf/Makefile.config.in | 30 +++ scaf/compiler/Makefile | 6 + scaf/compiler/kernel.scaf | 130 +++++++++++ scaf/compiler/optim.rules | 74 +++++++ scaf/compiler/scafc | 44 ++++ scaf/compiler/scafc.pl | 269 +++++++++++++++++++++++ scaf/compiler/scafmacro.s | 487 +++++++++++++++++++++++++++++++++++++++++ scaf/configure.ac | 53 +++++ scaf/doc/pdp_ca.pd | 78 +++++++ scaf/modules/Makefile | 21 -- scaf/modules/carules.scaf | 117 ---------- scaf/pdp/scaf_feeder.s | 50 +++++ scaf/rules/Makefile | 14 ++ scaf/rules/carules.scaf | 117 ++++++++++ scaf/system/Makefile | 21 -- scaf/system/kernel.scaf | 130 ----------- scaf/system/optim.rules | 74 ------- scaf/system/scaf_feeder.s | 49 ----- scaf/system/scaf_feeder_test.c | 30 --- scaf/system/scafc.pl | 269 ----------------------- scaf/system/scafmacro.s | 487 ----------------------------------------- 22 files changed, 1352 insertions(+), 1232 deletions(-) delete mode 100644 scaf/Makefile.config create mode 100644 scaf/Makefile.config.in create mode 100644 scaf/compiler/Makefile create mode 100644 scaf/compiler/kernel.scaf create mode 100644 scaf/compiler/optim.rules create mode 100755 scaf/compiler/scafc create mode 100755 scaf/compiler/scafc.pl create mode 100644 scaf/compiler/scafmacro.s create mode 100644 scaf/configure.ac create mode 100644 scaf/doc/pdp_ca.pd delete mode 100644 scaf/modules/Makefile delete mode 100644 scaf/modules/carules.scaf create mode 100644 scaf/pdp/scaf_feeder.s create mode 100644 scaf/rules/Makefile create mode 100644 scaf/rules/carules.scaf delete mode 100644 scaf/system/Makefile delete mode 100644 scaf/system/kernel.scaf delete mode 100644 scaf/system/optim.rules delete mode 100644 scaf/system/scaf_feeder.s delete mode 100644 scaf/system/scaf_feeder_test.c delete mode 100755 scaf/system/scafc.pl delete mode 100644 scaf/system/scafmacro.s (limited to 'scaf') diff --git a/scaf/Makefile.config b/scaf/Makefile.config deleted file mode 100644 index c41fd37..0000000 --- a/scaf/Makefile.config +++ /dev/null @@ -1,34 +0,0 @@ -# pd's directory -PD_DIR = /home/tom/pd/distro/pd -PDP_DIR = /home/tom/pd/packet - -#PD_DIR = /usr/local/pd -#PDP_DIR = /usr/local/pdp - -SCAF_DIR = $(PDP_DIR)/scaf - - - - -# build flags - -PDP_CA_INCLUDE = -I$(PD_DIR)/src -I$(PDP_DIR)/include -I$(SCAF_DIR)/include -PDP_CA_LIBS = -ldl -PDP_CA_AFLAGS = -#--gstabs -PDP_CA_CFLAGS = -DPD -O2 -funroll-loops -fomit-frame-pointer -ffast-math \ - -Wall -W -Wstrict-prototypes -Werror \ - -Wno-unused -Wno-parentheses -Wno-switch -g -# -Wshadow - -# compiler and assembler -#CC = gcc-3.2 -CC = gcc -AS = as - -# build rules - -.c.o: - $(CC) $(PDP_CA_CFLAGS) $(PDP_CA_INCLUDE) -o $*.o -c $*.c -.s.o: - $(AS) -o $*.o $*.s $(PDP_CA_AFLAGS) diff --git a/scaf/Makefile.config.in b/scaf/Makefile.config.in new file mode 100644 index 0000000..12927d3 --- /dev/null +++ b/scaf/Makefile.config.in @@ -0,0 +1,30 @@ +# build flags + +# define the include paths here if configure can't find them +# PDP_CFLAGS=-I/somehere/pdp/include +# PD_CFLAGS=-I/somewhere/pd/src + + +prefix=@prefix@ +PDP_CA_INCLUDE = @CPPFLAGS@ +PDP_CA_LIBS = @LIBS@ +DEFAULT_RULES_LIB = @DEFAULT_RULES_LIB@ +PDP_CA_AFLAGS = +#--gstabs +PDP_CA_CFLAGS = -DPD -O2 -funroll-loops -fomit-frame-pointer -ffast-math \ + -Wall -W -Wstrict-prototypes -Werror \ + -Wno-unused -Wno-parentheses -Wno-switch -g $(PDP_CFLAGS) $(PD_CFLAGS) \ + -DPDP_CA_RULES_LIB=\"$(DEFAULT_RULES_LIB)\" +# -Wshadow + +# compiler and assembler +#CC = gcc-3.2 +#CC = gcc +#AS = as + +# build rules + +.c.o: + $(CC) $(PDP_CA_CFLAGS) $(PDP_CA_INCLUDE) $(PDP_CA_DEFS) -o $*.o -c $*.c +.s.o: + $(AS) -o $*.o $*.s $(PDP_CA_AFLAGS) diff --git a/scaf/compiler/Makefile b/scaf/compiler/Makefile new file mode 100644 index 0000000..16e82cd --- /dev/null +++ b/scaf/compiler/Makefile @@ -0,0 +1,6 @@ +all: + +clean: + rm -f *~ + rm -f *.o + diff --git a/scaf/compiler/kernel.scaf b/scaf/compiler/kernel.scaf new file mode 100644 index 0000000..0bc2788 --- /dev/null +++ b/scaf/compiler/kernel.scaf @@ -0,0 +1,130 @@ +( Pure Data Packet - scaforth kernel. ) +( Copyright (c) by Tom Schouten ) +( ) +( This program is free software; you can redistribute it and/or modify ) +( it under the terms of the GNU General Public License as published by ) +( the Free Software Foundation; either version 2 of the License, or ) +( [at your option] any later version. ) +( ) +( This program is distributed in the hope that it will be useful, ) +( but WITHOUT ANY WARRANTY; without even the implied warranty of ) +( MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ) +( GNU General Public License for more details. ) +( ) +( You should have received a copy of the GNU General Public License ) +( along with this program; if not, write to the Free Software ) +( Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ) + + + + + +( this file contains the inline words in the scaforth kernel. ) +( when a file is compiled to asm, it will consist of word ) +( definition asm routines, macros and jmp call ret instructions. ) +( ) +( all words in this file are defined in terms of asm macros ) +( defined in scafmacros.s ) + + + +( stack manip words ) + +: over dup dropover ; + +( neighbourhood cell fetch words ) + +: @-+ dup dropldTL ; +: @0+ dup dropldTM ; +: @++ dup dropldTR ; +: @-0 dup dropldML ; +: @00 dup dropldMM ; +: @+0 dup dropldMR ; +: @-- dup dropldBL ; +: @0- dup dropldBM ; +: @+- dup dropldBR ; + +( boolean logic ) + +: or overor nip ; +: xor overxor nip ; +: and overand nip ; + +( binary constant loading ) + +: 1 dup dropone ; +: 0 dup dropzero ; + +( 4,3,2,1 bit add stack to register, leave carry on stack ) + +: ++++ adb0 adb1 adb2 adb3 ; +: +++ adb0 adb1 adb2 ; +: ++ adb0 adb1 ; +: + adb0 ; + +( 4,3,2 bit shifted 1 add ) + +: ++++<<1 adb1 adb2 adb3 ; +: +++<<1 adb1 adb2 ; +: ++<<1 adb1 ; + +( 4,3 bit shifted 2 add ) + +: ++++<<2 adb2 adb3 ; +: +++<<2 adb2 ; + +( 4 bit shifted 3 add ) + +: ++++<<3 adb3 ; + +( 4 bit accumulator access ) + +: !a0 dupsta0 drop ; +: !a1 dupsta1 drop ; +: !a2 dupsta2 drop ; +: !a3 dupsta3 drop ; + +: @a0 dup droplda0 ; +: @a1 dup droplda1 ; +: @a2 dup droplda2 ; +: @a3 dup droplda3 ; + +( 4,3,2,1 bit accumulator zero tests ) + +: ?anz dup dropisnonzero4 ; +: ?anz4 dup dropisnonzero4 ; +: ?anz3 dup dropisnonzero3 ; +: ?anz2 dup dropisnonzero2 ; +: ?anz1 dup dropisnonzero1 ; + +( load constants into accumulator ) + +: a0 a0000 ; +: a-0 a0000 ; +: a+0 a0000 ; +: a+1 a0001 ; +: a+2 a0010 ; +: a+3 a0011 ; +: a+4 a0100 ; +: a+5 a0101 ; +: a+6 a0110 ; +: a+7 a0111 ; + +: a+8 a1000 ; +: a+9 a1001 ; +: a+10 a1010 ; +: a+11 a1011 ; +: a+12 a1100 ; +: a+13 a1101 ; +: a+14 a1110 ; +: a+15 a1111 ; + +: a-8 a1000 ; +: a-7 a1001 ; +: a-6 a1010 ; +: a-5 a1011 ; +: a-4 a1100 ; +: a-3 a1101 ; +: a-2 a1110 ; +: a-1 a1111 ; + diff --git a/scaf/compiler/optim.rules b/scaf/compiler/optim.rules new file mode 100644 index 0000000..282caf4 --- /dev/null +++ b/scaf/compiler/optim.rules @@ -0,0 +1,74 @@ +# Pure Data Packet - scaf optimization rules. +# Copyright (c) by Tom Schouten +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + +# this file contains scaf source optimization rules for scaf compiler +# applied after kernel word inlining and before compilation to asm + +# one rule that's not in here, and is the responsability for the +# final compilation step: "word ;" is "jmp word" instead of "call word ret" + +# TODO: think about order! + +# no discrimination between pre inline and post inline optimization ops yet + +# pre inline optimizations + +"over xor" -> "overxor" +"over and" -> "overand" +"over or" -> "overor" + +"drop 1" -> "dropone" +"drop 0" -> "dropzero" +"over add" -> "overadd" +"over addc" -> "overaddc" + +"dup !a0" -> "dupsta0" +"dup !a1" -> "dupsta1" +"dup !a2" -> "dupsta2" +"dup !a3" -> "dupsta3" + +"drop @a0" -> "droplda0" +"drop @a1" -> "droplda1" +"drop @a2" -> "droplda2" +"drop @a3" -> "droplda3" + +"drop ?anz" -> "dropisnonzero4" +"drop ?anz4" -> "dropisnonzero4" +"drop ?anz3" -> "dropisnonzero3" +"drop ?anz2" -> "dropisnonzero2" +"drop ?anz1" -> "dropisnonzero1" + +"drop @-+" -> "dropldTL" +"drop @0+" -> "dropldTM" +"drop @++" -> "dropldTR" +"drop @-0" -> "dropldML" +"drop @00" -> "dropldMM" +"drop @+0" -> "dropldMR" +"drop @--" -> "dropldBL" +"drop @0-" -> "dropldBM" +"drop @+-" -> "dropldBR" + + +# post inline optimizations + +"dup drop" -> "" +"swap drop" -> "nip" +"dup swap" -> "dup" +"drop dup" -> "dropdup" +"drop over" -> "dropover" +"nip dup" -> "nipdup" diff --git a/scaf/compiler/scafc b/scaf/compiler/scafc new file mode 100755 index 0000000..ae800e5 --- /dev/null +++ b/scaf/compiler/scafc @@ -0,0 +1,44 @@ +#!/bin/sh +#scaf->scafo compiler + +if test "xx$1" == "xx" +then + echo + echo "scaf rules compiler" + echo "usage:" + echo " scafc source [dest]" + echo + exit 0 +fi + +if test "xx$2" == "xx" +then + DEST=$1o +else + DEST=$2 +fi + +if ! test -f $1 +then + echo "source module $1 not found." + exit 1 +fi + +SCAFDIR=`dirname $0` +if ! test -f $SCAFDIR/scafc.pl; +then + SCAFDIR=`dirname $SCAFDIR` + SCAFDIR="$SCAFDIR/lib/scaf" + if ! test -f $SCAFDIR/scafc.pl + then + echo "scaf library not found in $SCAFDIR" + exit 1 + fi +fi + +TMP_S=`tempfile -s .s` +$SCAFDIR/scafc.pl -I$SCAFDIR $1 > $TMP_S \ +&& gcc -export_dynamic -shared -o $DEST $TMP_S \ +&& strip --strip-unneeded $DEST \ +&& rm $TMP_S \ +|| exit 1 diff --git a/scaf/compiler/scafc.pl b/scaf/compiler/scafc.pl new file mode 100755 index 0000000..ee6b969 --- /dev/null +++ b/scaf/compiler/scafc.pl @@ -0,0 +1,269 @@ +#!/usr/bin/perl + +# Pure Data Packet - scafc: scaf compiler. +# Copyright (c) by Tom Schouten +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# + +# set this if you want to enable/disable optimizing + +$optimize = 1; + + +# this parses a single scaf line +# it is not very intelligent. only looks for 1 def on a line +# todo: change later so it can read multiple lines + + +sub remove_illegal_characters { + my $line = shift; + $$line =~ s/\+/_PLUS_/g; + $$line =~ s/-/_MINUS_/g; + $$line =~ s/\@/_AT_/g; + $$line =~ s/:/_COLON_/g; + $$line =~ s/\?/_QMARK_/g; + $$line =~ s/</_GT_/g; + $$line =~ s/=/_EQ_/g; + $$line =~ s/\(/_OPEN_/g; + $$line =~ s/\)/_CLOSE_/g; +} + +sub parse_scaf_line { + my $word, $def, $sub; + shift; + + # this transforms the source into a parsed assembly like form + # a word label: ":" + # a word definition line "" + # last def = + + # dont process if line doesn't have a def + + # first remove comments + s/\(\s+(\S+\s+)*?\)//g; + + if (m/:\s+/){ + + # separate word and definition + m/:\s+(\S+)\s+(.*)/; + $word = $1; + $def = $2; + + # remove illegal characters; + remove_illegal_characters \$word; + remove_illegal_characters \$def; + + # format definition in asm style + $def =~ s/(\S+)(\s*)/\t$1\n/g; + + # replace ; by r + $def =~ s/\s+;\s*/\n\tr\n/; + + # put word: def into one string + $sub = "$word:\n$def\n"; + + # debug + #$sub =~ s/\t//g; + #$sub =~ s/\n/\n/g; + #print "$sub"; + + return $sub; + + } + +}; + + + +# load and parse scaf source file +sub load_source { + my $filename = shift; + open(SOURCE, $filename) or die "Can't locate source module $filename\n"; + my @parsedsource; + while (){ + my $sub = parse_scaf_line $_; + if ($sub) { + push @parsedsource, ($sub); + } + + } + close(SOURCE); + return @parsedsource; + +} + +# this routine parses the optimization rules +sub load_optim { + my $filename = shift; + open(OPTIM, $filename) or die "Can't locate optimization rule file $filename\n"; + my @parsedoptim; + while (){ + unless (m/\A\#/){ + + if (m/\"\s*(.*?)\s*\".*?\"\s*(.*?)\s*\"/) + { + my $source = $1; + my $dest = $2; + + $source =~ s/\s+/\n\t/; + $dest =~ s/\s+/\n\t/; + $source = "\t$source\n"; + $dest = "\t$dest\n"; + + remove_illegal_characters \$source; + remove_illegal_characters \$dest; + + push @parsedoptim, ("$source:$dest"); + } + } + } + close(OPTIM); + + return @parsedoptim; + + +} + + + +# inline one parsed source's definitions into another parsed source's +sub inline_defs { + my $dest = shift; + my $source = shift; + + #print @$dest; + #print @$source; + + + # loop over file with inline defs + foreach (@$source) { + #print "$_\n"; + m/(\S+):\n(.*)\tr\n/s; + + my $def = "\t$1\n"; + my $body = $2; + + #print "$def\n"; + #print "$body\n"; + + foreach (@$dest) { + s/$def/$body/g; + } + + } + +} + +# this changes to c or j all defined words +# the undefined words are supposed to be asm macros +sub call_defs { + my $dest = shift; + + foreach (@$dest){ + m/(\S+):\n/s; + my $word = $1; + foreach (@$dest){ + s/\t$word\n\tr\n/\tj $word\n/sg; + s/\t$word\n/\tc $word\n/sg; + } + } +} + +# substitue word sequences in dest using optim table +sub subst_optim { + my $dest = shift; + my $optim = shift; + foreach (@$optim){ + m/(.*?):(.*)/s; + my $key = $1; + my $subst = $2; + + foreach (@$dest){ + s/$key/$subst/sg; + } + } +} + +# add directives to produce global symbols +# global symbols need to start with carule_ +sub global_syms { + my $source = shift; + foreach (@$source){ + s/rule_(\S+):\n/.globl\trule_$1\n.type\trule_$1,\@function\nrule_$1:\n/sg; + } +} + +# create an array with names for bookkeeping +sub name_array { + my @namearray; + my $source = shift; + push @namearray, (".globl rulenames\nrulenames:\n"); + foreach (@$source){ + if (m/rule_(\S+):/s){ + push @namearray, (".asciz\t\"$1\"\n"); + } + } + push @namearray, (".byte\t0\n"); + return @namearray; + +} + +# main program body + +$dir="."; + +$source = "-"; + + +# parse command line +foreach (@ARGV){ + if (m/-I(.*)/) { + $dir = $1; + } + else { + $source = $_; + } +} + +$kernel = "$dir/kernel.scaf"; +$macro = "$dir/scafmacro.s"; +$rules = "$dir/optim.rules"; + + + +# load files +@psource = load_source $source; +@pkernel = load_source $kernel; +@poptim = load_optim $rules; + + +# substitute kernel defs in source +if ($optimize) {subst_optim \@psource, \@poptim;} +inline_defs \@psource, \@pkernel; + +if ($optimize) {subst_optim \@psource, \@poptim;} + +call_defs \@psource; +global_syms \@psource; +@pnames = name_array \@psource; + +# print out asm file +print ".include \"$macro\"\n\n"; +print @psource; +print @pnames; + diff --git a/scaf/compiler/scafmacro.s b/scaf/compiler/scafmacro.s new file mode 100644 index 0000000..04e6537 --- /dev/null +++ b/scaf/compiler/scafmacro.s @@ -0,0 +1,487 @@ + # Pure Data Packet - scaf assembler macros. + # Copyright (c) by Tom Schouten + # + # This program is free software; you can redistribute it and/or modify + # it under the terms of the GNU General Public License as published by + # the Free Software Foundation; either version 2 of the License, or + # (at your option) any later version. + # + # This program is distributed in the hope that it will be useful, + # but WITHOUT ANY WARRANTY; without even the implied warranty of + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + # GNU General Public License for more details. + # + # You should have received a copy of the GNU General Public License + # along with this program; if not, write to the Free Software + # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + # + + + # this file contains pure asm macros. it is to be included before assembly + # after scaforth.pl has processed the .scaf file + + # *************************** JMP CALL RET ************************************** + # j c r + + .macro j address + jmp \address + .endm + + .macro c address + call \address + .endm + + .macro r + ret + .endm + + + # *************************** CA CELL ACCESS MACROS ***************************** + # dropldTL - dropldBR + + # shift / load rectangle macros: + + # shift rectangle horizontal + # result is in reg1 + .macro shift reg1 reg2 count + psllq $(16-\count), \reg1 + psrlq $(16+\count), \reg2 + psrlq $32, \reg1 + psllq $32, \reg2 + por \reg2, \reg1 + .endm + + .macro ldtop reg1 reg2 + movq (%edi), \reg1 + movq 8(%edi), \reg2 + .endm + + .macro ldcenter reg1 reg2 + movq 8(%edi), \reg1 + movq 16(%edi), \reg2 + .endm + + .macro ldbottom reg1 reg2 + movq 16(%edi), \reg1 + movq 24(%edi), \reg2 + .endm + + + # dropld from top row + + # dropld the top left square + .macro dropldTL + ldtop %mm0, %mm1 + shift %mm0, %mm1, -1 + .endm + + # dropld the top mid square + .macro dropldTM + ldtop %mm0, %mm1 + shift %mm0, %mm1, 0 + .endm + + # dropld the top right square + .macro dropldTR + ldtop %mm0, %mm1 + shift %mm0, %mm1, 1 + .endm + + + + # dropld from center row + + # dropld the mid left square + .macro dropldML + ldcenter %mm0, %mm1 + shift %mm0, %mm1, -1 + .endm + + # dropld the mid mid square + .macro dropldMM + ldcenter %mm0, %mm1 + shift %mm0, %mm1, 0 + .endm + + # dropld the mid right square + .macro dropldMR + ldcenter %mm0, %mm1 + shift %mm0, %mm1, 1 + .endm + + + + + + # dropld from bottom row + + # dropld the bottom left square + .macro dropldBL + ldbottom %mm0, %mm1 + shift %mm0, %mm1, -1 + .endm + + # dropld the bottom mid square + .macro dropldBM + ldbottom %mm0, %mm1 + shift %mm0, %mm1, 0 + .endm + + # dropld the bottom right square + .macro dropldBR + ldbottom %mm0, %mm1 + shift %mm0, %mm1, 1 + .endm + + + + # *************************** CA STACK MANIP MACROS ***************************** + # these are the only asm macros that have a stack effect other than + # just replacing the TOS + # + # dup drop dropdup swap nip dropover + + .macro dup + lea -8(%esi), %esi + movq %mm0, (%esi) + .endm + + .macro drop + movq (%esi), %mm0 + lea 8(%esi), %esi + .endm + + .macro dropdup + movq (%esi), %mm0 + .endm + + .macro nipdup + movq %mm0, (%esi) + .endm + + .macro swap + movq (%esi), %mm1 + movq %mm0, (%esi) + movq %mm1, %mm0 + .endm + + .macro nip + lea 8(%esi), %esi + .endm + + .macro dropover + movq 8(%esi), %mm0 + .endm + + + # *************************** CA BOOLEAN LOGIC MACROS ***************************** + # overxor overand overor not + + .macro overxor + pxor (%esi), %mm0 + .endm + + .macro overand + pand (%esi), %mm0 + .endm + + .macro overor + por (%esi), %mm0 + .endm + + .macro not + pxor %mm3, %mm0 + .endm + + + + # *************************** CONSTANTS ***************************** + # dropzero dropone + + .macro dropzero + pxor %mm0, %mm0 + .endm + + .macro dropone + pcmpeqw %mm0, %mm0 + .endm + + + # *************************** 4 BIT REG ACCESS ****************************** + # dupsta0 - dupsta4 droplda0 - droplda4 + # store bit in accumulator + + # bit store + + .macro dupsta0 + movq %mm0, %mm4 + .endm + + .macro dupsta1 + movq %mm0, %mm5 + .endm + + .macro dupsta2 + movq %mm0, %mm6 + .endm + + .macro dupsta3 + movq %mm0, %mm7 + .endm + + # load bit from accumulator + + .macro droplda0 + movq %mm4, %mm0 + .endm + + .macro droplda1 + movq %mm5, %mm0 + .endm + + .macro droplda2 + movq %mm6, %mm0 + .endm + + .macro droplda3 + movq %mm7, %mm0 + .endm + + + # *************************** LOAD 4 BIT CONSTANT IN REG ****************************** + # a0000 - a1111 + + .macro ldbit0 value + .ifeq \value + movq %mm1, %mm4 + .else + movq %mm3, %mm4 + .endif + .endm + + .macro ldbit1 value + .ifeq \value + movq %mm1, %mm5 + .else + movq %mm3, %mm5 + .endif + .endm + + .macro ldbit2 value + .ifeq \value + movq %mm1, %mm6 + .else + movq %mm3, %mm6 + .endif + .endm + + .macro ldbit3 value + .ifeq \value + movq %mm1, %mm7 + .else + movq %mm3, %mm7 + .endif + .endm + + .macro ldbin b3 b2 b1 b0 + pxor %mm1, %mm1 + ldbit0 \b0 + ldbit1 \b1 + ldbit2 \b2 + ldbit3 \b3 + .endm + + .macro a0000 + ldbin 0 0 0 0 + .endm + + .macro a0001 + ldbin 0 0 0 1 + .endm + + .macro a0010 + ldbin 0 0 1 0 + .endm + + .macro a0011 + ldbin 0 0 1 1 + .endm + + .macro a0100 + ldbin 0 1 0 0 + .endm + + .macro a0101 + ldbin 0 1 0 1 + .endm + + .macro a0110 + ldbin 0 1 1 0 + .endm + + .macro a0111 + ldbin 0 1 1 1 + .endm + + .macro a1000 + ldbin 1 0 0 0 + .endm + + .macro a1001 + ldbin 1 0 0 1 + .endm + + .macro a1010 + ldbin 1 0 1 0 + .endm + + .macro a1011 + ldbin 1 0 1 1 + .endm + + .macro a1100 + ldbin 1 1 0 0 + .endm + + .macro a1101 + ldbin 1 1 0 1 + .endm + + .macro a1110 + ldbin 1 1 1 0 + .endm + + .macro a1111 + ldbin 1 1 1 1 + .endm + + + + + # *************************** 4 BIT COUNTER ****************************** + # adds TOS to bit of counter and returns carry in TOS + # + # adb0 - adb3 + + + .macro adb0 + movq %mm4, %mm2 + pxor %mm0, %mm4 + pand %mm2, %mm0 + .endm + + .macro adb1 + movq %mm5, %mm2 + pxor %mm0, %mm5 + pand %mm2, %mm0 + .endm + + .macro adb2 + movq %mm6, %mm2 + pxor %mm0, %mm6 + pand %mm2, %mm0 + .endm + + .macro adb3 + movq %mm7, %mm2 + pxor %mm0, %mm7 + pand %mm2, %mm0 + .endm + + + # *************************** ACCUMULATOR TESTS *************************** + # dropisnonzero4 - dropisnonzero1 + + .macro dropisnonzero4 + movq %mm4, %mm0 + por %mm5, %mm0 + por %mm6, %mm0 + por %mm7, %mm0 + .endm + + .macro dropisnonzero3 + movq %mm4, %mm0 + por %mm5, %mm0 + por %mm6, %mm0 + .endm + + .macro dropisnonzero2 + movq %mm4, %mm0 + por %mm5, %mm0 + .endm + + .macro dropisnonzero1 + movq %mm4, %mm0 + .endm + + + # *************************** REGISTER SHIFT OPERATIONS ********************** + # shift and leave shifted out byte on stack + # rotate trough top of stack + + .macro dropshiftright + movq %mm4, %mm0 + movq %mm5, %mm4 + movq %mm6, %mm5 + movq %mm7, %mm6 + pxor %mm7, %mm7 + .endm + + .macro dropshiftleft + movq %mm7, %mm0 + movq %mm6, %mm7 + movq %mm5, %mm6 + movq %mm4, %mm5 + pxor %mm4, %mm4 + .endm + + .macro dropshiftrighta + movq %mm4, %mm0 + movq %mm5, %mm4 + movq %mm6, %mm5 + movq %mm7, %mm6 + .endm + + .macro rotateright + movq %mm4, %mm1 + movq %mm5, %mm4 + movq %mm6, %mm5 + movq %mm7, %mm6 + movq %mm1, %mm7 + .endm + + .macro rotateleft + movq %mm7, %mm1 + movq %mm6, %mm7 + movq %mm5, %mm6 + movq %mm4, %mm5 + movq %mm1, %mm4 + .endm + + .macro rotaterightstack + movq %mm0, %mm1 + movq %mm4, %mm0 + movq %mm5, %mm4 + movq %mm6, %mm5 + movq %mm7, %mm6 + movq %mm1, %mm7 + .endm + + .macro rotateleftstack + movq %mm0, %mm1 + movq %mm7, %mm0 + movq %mm6, %mm7 + movq %mm5, %mm6 + movq %mm4, %mm5 + movq %mm1, %mm4 + .endm + + # *************************** OTHER REGISTER OPERATIONS ********************** + # anot : complement reg (can be used to implement subtraction) + + .macro anot + pxor %mm3, %mm4 + pxor %mm3, %mm5 + pxor %mm3, %mm6 + pxor %mm3, %mm7 + .endm diff --git a/scaf/configure.ac b/scaf/configure.ac new file mode 100644 index 0000000..4b15a18 --- /dev/null +++ b/scaf/configure.ac @@ -0,0 +1,53 @@ +AC_INIT(pdp/pdp_ca_system.c) +AC_PROG_CC +AC_HEADER_STDC + +dnl default install prefix is /usr/local +if test $prefix == "NONE"; +then + prefix=/usr/local +fi + +AC_PATH_PROG(PDP_CONFIG,pdp-config,"no", $PATH) + +AC_CHECK_LIB(m,sin) +AC_CHECK_LIB(dl,dlopen,, echo libdl not found. sorry... || exit 1) + + +TOPSRC=`pwd` +PARENT=`dirname $TOPSRC` + +dnl if pdp-config is found use it to get the cflags +if ! test $PDP_CONFIG == "no" +then + PDP_CPPFLAGS=`$PDP_CONFIG --cflags` + +dnl if not, check in the parent dir (in case we are distributed with the pdp package) +elif test -f $PARENT/include/pdp.h +then + PDP_CPPFLAGS="-I$PARENT/include" +fi + +CPPFLAGS="$CPPFLAGS $PDP_CPPFLAGS" +AC_CHECK_HEADER(m_pd.h,,PD_OK=no) +AC_CHECK_HEADER(pdp.h,,PDP_OK=no) + +if test PD_OK == "no"; +then + echo "WARNING: m_pd.h not found. Is PD installed? + echo "WARNING: You can ignore this warning if you have set the PD_CFLAGS manually in Makefile.config.in +fi + +if test PDP_OK == "no"; +then + echo "WARNING: pdp.h not found. Is PDP installed? + echo "WARNING: You can ignore this warning if you have set the PDP_CFLAGS manually in Makefile.config.in +fi + +CPPFLAGS="$CPPFLAGS $PDFLAGS $PDPFLAGS -I$TOPSRC/include" + +DEFAULT_RULES_LIB=$prefix/lib/scaf/default.scafo; +AC_SUBST(DEFAULT_RULES_LIB) + +AC_CONFIG_FILES(Makefile.config) +AC_OUTPUT diff --git a/scaf/doc/pdp_ca.pd b/scaf/doc/pdp_ca.pd new file mode 100644 index 0000000..64e7e27 --- /dev/null +++ b/scaf/doc/pdp_ca.pd @@ -0,0 +1,78 @@ +#N canvas 62 0 753 664 10; +#X obj 46 613 pdp_ca; +#X obj 45 254 metro 40; +#X msg 45 206 bang; +#X msg 84 206 stop; +#X msg 184 340 random; +#X msg 181 137 rule gameoflife; +#X floatatom 185 586 5 0 0 0 - - -; +#X obj 185 558 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 +1; +#X obj 46 638 pdp_ca2image; +#X msg 181 215 rules; +#X msg 185 434 close; +#X floatatom 96 228 5 0 0 0 - - -; +#X obj 46 662 pdp_xv; +#X floatatom 183 285 5 0 0 0 - - -; +#X msg 183 314 vshift \$1; +#X msg 185 486 2D; +#X msg 185 535 fullscreen1D \$1; +#X obj 185 513 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 +1; +#X text 197 606 1st inlet: active input (bang or ca); +#X text 197 621 2nd inlet: passive input (ca); +#X text 196 638 3rd inlet: nb of iterations; +#X text 307 137 set a rule by name; +#X text 308 206 print rules in library; +#X msg 181 187 ruleindex \$1; +#X text 307 183 set a rule by index; +#X floatatom 181 165 5 0 0 0 - - -; +#X text 313 534 off: compute one line at a time; +#X text 313 548 on: update entire image (all lines); +#X text 313 520 specify how to compute a 1D ca; +#X text 313 464 interpret rules as a 1D ca with (space+time); +#X text 313 493 interpret rules as a 2D ca with (space); +#X msg 185 465 1D; +#X text 314 436 close current library; +#X obj 179 43 openpanel; +#X msg 179 66 open \$1; +#X msg 184 370 dim 64 64; +#X text 314 371 set ca dimensions; +#X obj 179 24 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X text 306 22 open a source rule file or compiled rule library; +#X text 306 38 (when it's a source file \, make sure the "scafc" compiler +is in the system path); +#X msg 340 70 opensrc \$1; +#X msg 446 70 openlib \$1; +#X text 306 72 use; +#X text 419 71 and; +#X text 306 89 to explicitly open source or library; +#X text 314 342 init ca with random noise; +#X text 314 312 vertical shift compensation; +#X text 181 257 bang computes next iteration(s); +#X msg 185 397 dim 512 512; +#X connect 0 0 8 0; +#X connect 1 0 0 0; +#X connect 2 0 1 0; +#X connect 3 0 1 0; +#X connect 4 0 0 0; +#X connect 5 0 0 0; +#X connect 6 0 0 2; +#X connect 7 0 6 0; +#X connect 8 0 12 0; +#X connect 9 0 0 0; +#X connect 10 0 0 0; +#X connect 11 0 1 1; +#X connect 13 0 14 0; +#X connect 14 0 0 0; +#X connect 15 0 0 0; +#X connect 16 0 0 0; +#X connect 17 0 16 0; +#X connect 23 0 0 0; +#X connect 25 0 23 0; +#X connect 33 0 34 0; +#X connect 34 0 0 0; +#X connect 35 0 0 0; +#X connect 37 0 33 0; +#X connect 48 0 0 0; diff --git a/scaf/modules/Makefile b/scaf/modules/Makefile deleted file mode 100644 index 7bb0dc9..0000000 --- a/scaf/modules/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -OBJ = carules.scafo - -SCAFDIR = ../system - -.SUFFIXES: .scaf -.SUFFIXES: .scafo - -.scaf.o: - $(SCAFDIR)/scafc.pl -I$(SCAFDIR) $*.scaf | as -o $*.o - -.o.scafo: - gcc -export_dynamic -shared -o $*.scafo $*.o - rm $*.o - strip --strip-unneeded $*.scafo - -all: $(OBJ) - -clean: - rm -f *.scafo - rm -f *~ - diff --git a/scaf/modules/carules.scaf b/scaf/modules/carules.scaf deleted file mode 100644 index 32aef4a..0000000 --- a/scaf/modules/carules.scaf +++ /dev/null @@ -1,117 +0,0 @@ -( Pure Data Packet - ca rules library. ) -( Copyright (c) by Tom Schouten ) -( ) -( This program is free software; you can redistribute it and/or modify ) -( it under the terms of the GNU General Public License as published by ) -( the Free Software Foundation; either version 2 of the License, or ) -( [at your option] any later version. ) -( ) -( This program is distributed in the hope that it will be useful, ) -( but WITHOUT ANY WARRANTY; without even the implied warranty of ) -( MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ) -( GNU General Public License for more details. ) -( ) -( You should have received a copy of the GNU General Public License ) -( along with this program; if not, write to the Free Software ) -( Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ) - - - -( this is the standard ca rules library ) -( a rule that is accessible from the ouside should start with "rule_" ) -( and has to return exactly one item on the stack (this is checked in pdp_ca) ) - - -( a word is a sequence of non whitespace characters (\S+) ) -( words are separated by whitespace (\s+) ) -( so "word ;" is not the same as "word;" ) - -( all words between the "(" word and the ")" word are ignored ) - -( ":" starts a definition, the next word is the name of the new word ) -( newline ends a definition ) - -( no more than one definition per line ) -( no more than one line per definition ) - -( ";" returns to calling word ) -( if no ";" is encountered the next defined word is executed ) -( this is to have multiple entry points ) -( multiple exit points don't make sense since there are no conditional words ) - - - -: +(4) ++++ ; ( 4 bit add TOS - carry on TOS ) -: +(3) +++ ; ( 3 bit add TOS - carry on TOS ) -: +(2) ++ ; ( 2 bit add TOS - carry on TOS ) - -: +top @-+ +(4) drop @0+ +(4) drop @++ +(4) ; ( add top row to reg - carry on TOS ) -: +mid @-0 +(4) drop @00 +(4) drop @+0 +(4) ; ( add mid row to reg - carry on TOS ) -: +bot @-- +(4) drop @0- +(4) drop @+- +(4) ; ( add bot row to reg - carry on TOS ) -: +all +top drop +mid drop +bot ; ( add all cells to reg - carry on TOS ) - -: +mid-1 @-0 +(4) drop @+0 +(4) ; ( add mid row except center element to reg - carry on TOS ) -: +all-1 +top drop +mid-1 drop +bot ; ( add all cells expet middle one to reg - carry on TOS ) - - -: countall a-0 +all drop ; ( count all cells - no stack effect ) -: countall-1 a-0 +all-1 drop ; ( count all cells except middle one - no stack effect ) - -: +topbot @0+ +(3) drop @0- +(3) ; -: +leftright @+0 +(3) drop @-0 +(3) ; -: +star +topbot drop +leftright ; -: countstar a-0 +star drop ; - -: =2or3? @a2 not @a1 and ; ( sum equal to 2 or 3? only checks 3 bits ) -: =3? =2or3? @a0 and ; ( sum equal to 3 ? ) -: =2? =2or3? @a0 not and ; ( sum equal to 2 ? ) -: =4? @a2 @a1 not and @a0 not and ; ( sum equal to 4 ? ) - - - -( some test rules ) - -( : rule_one 1 ; ) -( : rule_zero 0 ; ) -( : rule_id @00 ; ) - - -: rule_shiftleft @+0 ; -: rule_shifttop @0- ; -: rule_shiftbot @0+ ; -: rule_shifttopright @-- ; -: rule_strobe @00 not ; - -( game of life ) - -: rule_gameoflife countall-1 =2? @00 and =3? or ; - -( wolfram's rule 110) - -: rule_w110 @00 @+0 and not @-0 @00 @+0 or or and ; - - -( some other rules ) - -: rule_w110mod @0+ @+0 and not @-+ @0+ @++ or or and ; - -: rule_w110mod2 @0+ @+0 and not @-+ @0+ @+0 or or and ; -: rule_w110mod3 @0+ @++ and not @-+ @0+ @++ or or and @-0 @00 @+0 or or and ; - -: rule_golmod countall-1 =3? @00 and =2? or ; -: rule_golmod2 countall-1 =2? @0+ and =3? or ; -: rule_golmod3 countall-1 =2? @++ and =3? or ; -: rule_golmod4 countall-1 =2? @++ @-- or and =3? or ; -: rule_golmod5 countall-1 =2? @++ @-- or and =3? @+- and or ; -: rule_golmod6 countall-1 =2? @++ @-- or and =3? @+- and or @0+ or ; -: rule_golmod7 countall-1 =2? @++ @-- or and =3? @+- and or @0+ or @00 and ; - -( ca's with a short settling time ) - -: rule_block countstar =4? not =2? and @00 or ; -: rule_noiseedges countstar =4? =3? or not =2? and @00 or @++ xor ; -: rule_noiseplanes countstar =4? =3? or not =2? and @00 or @++ xor @-- xor ; - - -( : rule_noiseplanes countstar =4? =3? or not =2? and @00 or @++ xor @-- xor ; ) - diff --git a/scaf/pdp/scaf_feeder.s b/scaf/pdp/scaf_feeder.s new file mode 100644 index 0000000..e7ef3c6 --- /dev/null +++ b/scaf/pdp/scaf_feeder.s @@ -0,0 +1,50 @@ +# Pure Data Packet - scaf feeder routine. +# Copyright (c) by Tom Schouten +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# + +# for dup +.include "../compiler/scafmacro.s" + + +# *rg is only used for returning the stack pointer +# the 4 bit counter is using registers mm4-mm7 now +# long long scaf_feeder(void *tos, void *rg, *void() ca_rule, void *env) +.globl scaf_feeder +.type scaf_feeder, @function +scaf_feeder: + pushl %ebp + movl %esp, %ebp + push %esi + push %edi + + movl 20(%ebp), %edi # load env ptr + movl 8(%ebp), %esi # load TOS2 ptr + movl 16(%ebp), %eax # address of ca routine + pcmpeqw %mm3, %mm3 # load 1 reg + + call *%eax # TOS = 32x2 cell result + dup # push %mm0 to memory + movl (%esi), %eax + movl 4(%esi), %edx + lea 16(%esi), %esi # discard stack + movl %esi, (%edi) # store for stack underflow check + + emms + pop %edi + pop %esi + leave + ret diff --git a/scaf/rules/Makefile b/scaf/rules/Makefile new file mode 100644 index 0000000..997207c --- /dev/null +++ b/scaf/rules/Makefile @@ -0,0 +1,14 @@ +OBJ = carules.scafo + +.SUFFIXES: .scaf +.SUFFIXES: .scafo + +.scaf.scafo: + ../compiler/scafc $*.scaf + +all: $(OBJ) + +clean: + rm -f *.scafo + rm -f *.s + rm -f *~ diff --git a/scaf/rules/carules.scaf b/scaf/rules/carules.scaf new file mode 100644 index 0000000..32aef4a --- /dev/null +++ b/scaf/rules/carules.scaf @@ -0,0 +1,117 @@ +( Pure Data Packet - ca rules library. ) +( Copyright (c) by Tom Schouten ) +( ) +( This program is free software; you can redistribute it and/or modify ) +( it under the terms of the GNU General Public License as published by ) +( the Free Software Foundation; either version 2 of the License, or ) +( [at your option] any later version. ) +( ) +( This program is distributed in the hope that it will be useful, ) +( but WITHOUT ANY WARRANTY; without even the implied warranty of ) +( MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ) +( GNU General Public License for more details. ) +( ) +( You should have received a copy of the GNU General Public License ) +( along with this program; if not, write to the Free Software ) +( Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ) + + + +( this is the standard ca rules library ) +( a rule that is accessible from the ouside should start with "rule_" ) +( and has to return exactly one item on the stack (this is checked in pdp_ca) ) + + +( a word is a sequence of non whitespace characters (\S+) ) +( words are separated by whitespace (\s+) ) +( so "word ;" is not the same as "word;" ) + +( all words between the "(" word and the ")" word are ignored ) + +( ":" starts a definition, the next word is the name of the new word ) +( newline ends a definition ) + +( no more than one definition per line ) +( no more than one line per definition ) + +( ";" returns to calling word ) +( if no ";" is encountered the next defined word is executed ) +( this is to have multiple entry points ) +( multiple exit points don't make sense since there are no conditional words ) + + + +: +(4) ++++ ; ( 4 bit add TOS - carry on TOS ) +: +(3) +++ ; ( 3 bit add TOS - carry on TOS ) +: +(2) ++ ; ( 2 bit add TOS - carry on TOS ) + +: +top @-+ +(4) drop @0+ +(4) drop @++ +(4) ; ( add top row to reg - carry on TOS ) +: +mid @-0 +(4) drop @00 +(4) drop @+0 +(4) ; ( add mid row to reg - carry on TOS ) +: +bot @-- +(4) drop @0- +(4) drop @+- +(4) ; ( add bot row to reg - carry on TOS ) +: +all +top drop +mid drop +bot ; ( add all cells to reg - carry on TOS ) + +: +mid-1 @-0 +(4) drop @+0 +(4) ; ( add mid row except center element to reg - carry on TOS ) +: +all-1 +top drop +mid-1 drop +bot ; ( add all cells expet middle one to reg - carry on TOS ) + + +: countall a-0 +all drop ; ( count all cells - no stack effect ) +: countall-1 a-0 +all-1 drop ; ( count all cells except middle one - no stack effect ) + +: +topbot @0+ +(3) drop @0- +(3) ; +: +leftright @+0 +(3) drop @-0 +(3) ; +: +star +topbot drop +leftright ; +: countstar a-0 +star drop ; + +: =2or3? @a2 not @a1 and ; ( sum equal to 2 or 3? only checks 3 bits ) +: =3? =2or3? @a0 and ; ( sum equal to 3 ? ) +: =2? =2or3? @a0 not and ; ( sum equal to 2 ? ) +: =4? @a2 @a1 not and @a0 not and ; ( sum equal to 4 ? ) + + + +( some test rules ) + +( : rule_one 1 ; ) +( : rule_zero 0 ; ) +( : rule_id @00 ; ) + + +: rule_shiftleft @+0 ; +: rule_shifttop @0- ; +: rule_shiftbot @0+ ; +: rule_shifttopright @-- ; +: rule_strobe @00 not ; + +( game of life ) + +: rule_gameoflife countall-1 =2? @00 and =3? or ; + +( wolfram's rule 110) + +: rule_w110 @00 @+0 and not @-0 @00 @+0 or or and ; + + +( some other rules ) + +: rule_w110mod @0+ @+0 and not @-+ @0+ @++ or or and ; + +: rule_w110mod2 @0+ @+0 and not @-+ @0+ @+0 or or and ; +: rule_w110mod3 @0+ @++ and not @-+ @0+ @++ or or and @-0 @00 @+0 or or and ; + +: rule_golmod countall-1 =3? @00 and =2? or ; +: rule_golmod2 countall-1 =2? @0+ and =3? or ; +: rule_golmod3 countall-1 =2? @++ and =3? or ; +: rule_golmod4 countall-1 =2? @++ @-- or and =3? or ; +: rule_golmod5 countall-1 =2? @++ @-- or and =3? @+- and or ; +: rule_golmod6 countall-1 =2? @++ @-- or and =3? @+- and or @0+ or ; +: rule_golmod7 countall-1 =2? @++ @-- or and =3? @+- and or @0+ or @00 and ; + +( ca's with a short settling time ) + +: rule_block countstar =4? not =2? and @00 or ; +: rule_noiseedges countstar =4? =3? or not =2? and @00 or @++ xor ; +: rule_noiseplanes countstar =4? =3? or not =2? and @00 or @++ xor @-- xor ; + + +( : rule_noiseplanes countstar =4? =3? or not =2? and @00 or @++ xor @-- xor ; ) + diff --git a/scaf/system/Makefile b/scaf/system/Makefile deleted file mode 100644 index 2a07f4f..0000000 --- a/scaf/system/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -all: scaf_feeder.o - -test: scaf_feeder_test - -OBJ = scaf_feeder_test.o scaf_feeder.o - - -scaf_feeder_test: $(OBJ) - gcc -o scaf_feeder_test *.o -g -ldl - -.s.o: - as -o $*.o $*.s - -.c.o: - gcc -c $*.c -o $*.o -g - -clean: - rm -f *~ - rm -f *.o - rm -f scaf_feeder_test - diff --git a/scaf/system/kernel.scaf b/scaf/system/kernel.scaf deleted file mode 100644 index 0bc2788..0000000 --- a/scaf/system/kernel.scaf +++ /dev/null @@ -1,130 +0,0 @@ -( Pure Data Packet - scaforth kernel. ) -( Copyright (c) by Tom Schouten ) -( ) -( This program is free software; you can redistribute it and/or modify ) -( it under the terms of the GNU General Public License as published by ) -( the Free Software Foundation; either version 2 of the License, or ) -( [at your option] any later version. ) -( ) -( This program is distributed in the hope that it will be useful, ) -( but WITHOUT ANY WARRANTY; without even the implied warranty of ) -( MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ) -( GNU General Public License for more details. ) -( ) -( You should have received a copy of the GNU General Public License ) -( along with this program; if not, write to the Free Software ) -( Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ) - - - - - -( this file contains the inline words in the scaforth kernel. ) -( when a file is compiled to asm, it will consist of word ) -( definition asm routines, macros and jmp call ret instructions. ) -( ) -( all words in this file are defined in terms of asm macros ) -( defined in scafmacros.s ) - - - -( stack manip words ) - -: over dup dropover ; - -( neighbourhood cell fetch words ) - -: @-+ dup dropldTL ; -: @0+ dup dropldTM ; -: @++ dup dropldTR ; -: @-0 dup dropldML ; -: @00 dup dropldMM ; -: @+0 dup dropldMR ; -: @-- dup dropldBL ; -: @0- dup dropldBM ; -: @+- dup dropldBR ; - -( boolean logic ) - -: or overor nip ; -: xor overxor nip ; -: and overand nip ; - -( binary constant loading ) - -: 1 dup dropone ; -: 0 dup dropzero ; - -( 4,3,2,1 bit add stack to register, leave carry on stack ) - -: ++++ adb0 adb1 adb2 adb3 ; -: +++ adb0 adb1 adb2 ; -: ++ adb0 adb1 ; -: + adb0 ; - -( 4,3,2 bit shifted 1 add ) - -: ++++<<1 adb1 adb2 adb3 ; -: +++<<1 adb1 adb2 ; -: ++<<1 adb1 ; - -( 4,3 bit shifted 2 add ) - -: ++++<<2 adb2 adb3 ; -: +++<<2 adb2 ; - -( 4 bit shifted 3 add ) - -: ++++<<3 adb3 ; - -( 4 bit accumulator access ) - -: !a0 dupsta0 drop ; -: !a1 dupsta1 drop ; -: !a2 dupsta2 drop ; -: !a3 dupsta3 drop ; - -: @a0 dup droplda0 ; -: @a1 dup droplda1 ; -: @a2 dup droplda2 ; -: @a3 dup droplda3 ; - -( 4,3,2,1 bit accumulator zero tests ) - -: ?anz dup dropisnonzero4 ; -: ?anz4 dup dropisnonzero4 ; -: ?anz3 dup dropisnonzero3 ; -: ?anz2 dup dropisnonzero2 ; -: ?anz1 dup dropisnonzero1 ; - -( load constants into accumulator ) - -: a0 a0000 ; -: a-0 a0000 ; -: a+0 a0000 ; -: a+1 a0001 ; -: a+2 a0010 ; -: a+3 a0011 ; -: a+4 a0100 ; -: a+5 a0101 ; -: a+6 a0110 ; -: a+7 a0111 ; - -: a+8 a1000 ; -: a+9 a1001 ; -: a+10 a1010 ; -: a+11 a1011 ; -: a+12 a1100 ; -: a+13 a1101 ; -: a+14 a1110 ; -: a+15 a1111 ; - -: a-8 a1000 ; -: a-7 a1001 ; -: a-6 a1010 ; -: a-5 a1011 ; -: a-4 a1100 ; -: a-3 a1101 ; -: a-2 a1110 ; -: a-1 a1111 ; - diff --git a/scaf/system/optim.rules b/scaf/system/optim.rules deleted file mode 100644 index 282caf4..0000000 --- a/scaf/system/optim.rules +++ /dev/null @@ -1,74 +0,0 @@ -# Pure Data Packet - scaf optimization rules. -# Copyright (c) by Tom Schouten -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - -# this file contains scaf source optimization rules for scaf compiler -# applied after kernel word inlining and before compilation to asm - -# one rule that's not in here, and is the responsability for the -# final compilation step: "word ;" is "jmp word" instead of "call word ret" - -# TODO: think about order! - -# no discrimination between pre inline and post inline optimization ops yet - -# pre inline optimizations - -"over xor" -> "overxor" -"over and" -> "overand" -"over or" -> "overor" - -"drop 1" -> "dropone" -"drop 0" -> "dropzero" -"over add" -> "overadd" -"over addc" -> "overaddc" - -"dup !a0" -> "dupsta0" -"dup !a1" -> "dupsta1" -"dup !a2" -> "dupsta2" -"dup !a3" -> "dupsta3" - -"drop @a0" -> "droplda0" -"drop @a1" -> "droplda1" -"drop @a2" -> "droplda2" -"drop @a3" -> "droplda3" - -"drop ?anz" -> "dropisnonzero4" -"drop ?anz4" -> "dropisnonzero4" -"drop ?anz3" -> "dropisnonzero3" -"drop ?anz2" -> "dropisnonzero2" -"drop ?anz1" -> "dropisnonzero1" - -"drop @-+" -> "dropldTL" -"drop @0+" -> "dropldTM" -"drop @++" -> "dropldTR" -"drop @-0" -> "dropldML" -"drop @00" -> "dropldMM" -"drop @+0" -> "dropldMR" -"drop @--" -> "dropldBL" -"drop @0-" -> "dropldBM" -"drop @+-" -> "dropldBR" - - -# post inline optimizations - -"dup drop" -> "" -"swap drop" -> "nip" -"dup swap" -> "dup" -"drop dup" -> "dropdup" -"drop over" -> "dropover" -"nip dup" -> "nipdup" diff --git a/scaf/system/scaf_feeder.s b/scaf/system/scaf_feeder.s deleted file mode 100644 index 1cd8fd3..0000000 --- a/scaf/system/scaf_feeder.s +++ /dev/null @@ -1,49 +0,0 @@ -# Pure Data Packet - scaf feeder routine. -# Copyright (c) by Tom Schouten -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# - -.include "scafmacro.s" - - -# *rg is only used for returning the stack pointer -# the 4 bit counter is using registers mm4-mm7 now -# long long scaf_feeder(void *tos, void *rg, *void() ca_rule, void *env) -.globl scaf_feeder -.type scaf_feeder, @function -scaf_feeder: - pushl %ebp - movl %esp, %ebp - push %esi - push %edi - - movl 20(%ebp), %edi # load env ptr - movl 8(%ebp), %esi # load TOS2 ptr - movl 16(%ebp), %eax # address of ca routine - pcmpeqw %mm3, %mm3 # load 1 reg - - call *%eax # TOS = 32x2 cell result - dup # push %mm0 to memory - movl (%esi), %eax - movl 4(%esi), %edx - lea 16(%esi), %esi # discard stack - movl %esi, (%edi) # store for stack underflow check - - emms - pop %edi - pop %esi - leave - ret diff --git a/scaf/system/scaf_feeder_test.c b/scaf/system/scaf_feeder_test.c deleted file mode 100644 index 23a2661..0000000 --- a/scaf/system/scaf_feeder_test.c +++ /dev/null @@ -1,30 +0,0 @@ -#include - -void scaf_feeder_asm (void *tos, void *reg, void (*ca_rule)(), void *env); - -void ca_test() {} - -main() -{ - int stack[256]; - int reg[8]; - int env[8]; - - void *libhandle; - void *ca_routine; - - - if (!(libhandle = dlopen("../modules/test.scafo", RTLD_NOW))){ - printf("error: %s\n", dlerror()); - exit(1); - } - - if (!(ca_routine = dlsym(libhandle, "carule_1"))){ - printf("error: %s\n", dlerror()); - exit(1); - } - - scaf_feeder_asm(stack+254, reg, ca_routine, env); - - dlclose(libhandle); -} diff --git a/scaf/system/scafc.pl b/scaf/system/scafc.pl deleted file mode 100755 index ee6b969..0000000 --- a/scaf/system/scafc.pl +++ /dev/null @@ -1,269 +0,0 @@ -#!/usr/bin/perl - -# Pure Data Packet - scafc: scaf compiler. -# Copyright (c) by Tom Schouten -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# - -# set this if you want to enable/disable optimizing - -$optimize = 1; - - -# this parses a single scaf line -# it is not very intelligent. only looks for 1 def on a line -# todo: change later so it can read multiple lines - - -sub remove_illegal_characters { - my $line = shift; - $$line =~ s/\+/_PLUS_/g; - $$line =~ s/-/_MINUS_/g; - $$line =~ s/\@/_AT_/g; - $$line =~ s/:/_COLON_/g; - $$line =~ s/\?/_QMARK_/g; - $$line =~ s/</_GT_/g; - $$line =~ s/=/_EQ_/g; - $$line =~ s/\(/_OPEN_/g; - $$line =~ s/\)/_CLOSE_/g; -} - -sub parse_scaf_line { - my $word, $def, $sub; - shift; - - # this transforms the source into a parsed assembly like form - # a word label: ":" - # a word definition line "" - # last def = - - # dont process if line doesn't have a def - - # first remove comments - s/\(\s+(\S+\s+)*?\)//g; - - if (m/:\s+/){ - - # separate word and definition - m/:\s+(\S+)\s+(.*)/; - $word = $1; - $def = $2; - - # remove illegal characters; - remove_illegal_characters \$word; - remove_illegal_characters \$def; - - # format definition in asm style - $def =~ s/(\S+)(\s*)/\t$1\n/g; - - # replace ; by r - $def =~ s/\s+;\s*/\n\tr\n/; - - # put word: def into one string - $sub = "$word:\n$def\n"; - - # debug - #$sub =~ s/\t//g; - #$sub =~ s/\n/\n/g; - #print "$sub"; - - return $sub; - - } - -}; - - - -# load and parse scaf source file -sub load_source { - my $filename = shift; - open(SOURCE, $filename) or die "Can't locate source module $filename\n"; - my @parsedsource; - while (){ - my $sub = parse_scaf_line $_; - if ($sub) { - push @parsedsource, ($sub); - } - - } - close(SOURCE); - return @parsedsource; - -} - -# this routine parses the optimization rules -sub load_optim { - my $filename = shift; - open(OPTIM, $filename) or die "Can't locate optimization rule file $filename\n"; - my @parsedoptim; - while (){ - unless (m/\A\#/){ - - if (m/\"\s*(.*?)\s*\".*?\"\s*(.*?)\s*\"/) - { - my $source = $1; - my $dest = $2; - - $source =~ s/\s+/\n\t/; - $dest =~ s/\s+/\n\t/; - $source = "\t$source\n"; - $dest = "\t$dest\n"; - - remove_illegal_characters \$source; - remove_illegal_characters \$dest; - - push @parsedoptim, ("$source:$dest"); - } - } - } - close(OPTIM); - - return @parsedoptim; - - -} - - - -# inline one parsed source's definitions into another parsed source's -sub inline_defs { - my $dest = shift; - my $source = shift; - - #print @$dest; - #print @$source; - - - # loop over file with inline defs - foreach (@$source) { - #print "$_\n"; - m/(\S+):\n(.*)\tr\n/s; - - my $def = "\t$1\n"; - my $body = $2; - - #print "$def\n"; - #print "$body\n"; - - foreach (@$dest) { - s/$def/$body/g; - } - - } - -} - -# this changes to c or j all defined words -# the undefined words are supposed to be asm macros -sub call_defs { - my $dest = shift; - - foreach (@$dest){ - m/(\S+):\n/s; - my $word = $1; - foreach (@$dest){ - s/\t$word\n\tr\n/\tj $word\n/sg; - s/\t$word\n/\tc $word\n/sg; - } - } -} - -# substitue word sequences in dest using optim table -sub subst_optim { - my $dest = shift; - my $optim = shift; - foreach (@$optim){ - m/(.*?):(.*)/s; - my $key = $1; - my $subst = $2; - - foreach (@$dest){ - s/$key/$subst/sg; - } - } -} - -# add directives to produce global symbols -# global symbols need to start with carule_ -sub global_syms { - my $source = shift; - foreach (@$source){ - s/rule_(\S+):\n/.globl\trule_$1\n.type\trule_$1,\@function\nrule_$1:\n/sg; - } -} - -# create an array with names for bookkeeping -sub name_array { - my @namearray; - my $source = shift; - push @namearray, (".globl rulenames\nrulenames:\n"); - foreach (@$source){ - if (m/rule_(\S+):/s){ - push @namearray, (".asciz\t\"$1\"\n"); - } - } - push @namearray, (".byte\t0\n"); - return @namearray; - -} - -# main program body - -$dir="."; - -$source = "-"; - - -# parse command line -foreach (@ARGV){ - if (m/-I(.*)/) { - $dir = $1; - } - else { - $source = $_; - } -} - -$kernel = "$dir/kernel.scaf"; -$macro = "$dir/scafmacro.s"; -$rules = "$dir/optim.rules"; - - - -# load files -@psource = load_source $source; -@pkernel = load_source $kernel; -@poptim = load_optim $rules; - - -# substitute kernel defs in source -if ($optimize) {subst_optim \@psource, \@poptim;} -inline_defs \@psource, \@pkernel; - -if ($optimize) {subst_optim \@psource, \@poptim;} - -call_defs \@psource; -global_syms \@psource; -@pnames = name_array \@psource; - -# print out asm file -print ".include \"$macro\"\n\n"; -print @psource; -print @pnames; - diff --git a/scaf/system/scafmacro.s b/scaf/system/scafmacro.s deleted file mode 100644 index 04e6537..0000000 --- a/scaf/system/scafmacro.s +++ /dev/null @@ -1,487 +0,0 @@ - # Pure Data Packet - scaf assembler macros. - # Copyright (c) by Tom Schouten - # - # This program is free software; you can redistribute it and/or modify - # it under the terms of the GNU General Public License as published by - # the Free Software Foundation; either version 2 of the License, or - # (at your option) any later version. - # - # This program is distributed in the hope that it will be useful, - # but WITHOUT ANY WARRANTY; without even the implied warranty of - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - # GNU General Public License for more details. - # - # You should have received a copy of the GNU General Public License - # along with this program; if not, write to the Free Software - # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - # - - - # this file contains pure asm macros. it is to be included before assembly - # after scaforth.pl has processed the .scaf file - - # *************************** JMP CALL RET ************************************** - # j c r - - .macro j address - jmp \address - .endm - - .macro c address - call \address - .endm - - .macro r - ret - .endm - - - # *************************** CA CELL ACCESS MACROS ***************************** - # dropldTL - dropldBR - - # shift / load rectangle macros: - - # shift rectangle horizontal - # result is in reg1 - .macro shift reg1 reg2 count - psllq $(16-\count), \reg1 - psrlq $(16+\count), \reg2 - psrlq $32, \reg1 - psllq $32, \reg2 - por \reg2, \reg1 - .endm - - .macro ldtop reg1 reg2 - movq (%edi), \reg1 - movq 8(%edi), \reg2 - .endm - - .macro ldcenter reg1 reg2 - movq 8(%edi), \reg1 - movq 16(%edi), \reg2 - .endm - - .macro ldbottom reg1 reg2 - movq 16(%edi), \reg1 - movq 24(%edi), \reg2 - .endm - - - # dropld from top row - - # dropld the top left square - .macro dropldTL - ldtop %mm0, %mm1 - shift %mm0, %mm1, -1 - .endm - - # dropld the top mid square - .macro dropldTM - ldtop %mm0, %mm1 - shift %mm0, %mm1, 0 - .endm - - # dropld the top right square - .macro dropldTR - ldtop %mm0, %mm1 - shift %mm0, %mm1, 1 - .endm - - - - # dropld from center row - - # dropld the mid left square - .macro dropldML - ldcenter %mm0, %mm1 - shift %mm0, %mm1, -1 - .endm - - # dropld the mid mid square - .macro dropldMM - ldcenter %mm0, %mm1 - shift %mm0, %mm1, 0 - .endm - - # dropld the mid right square - .macro dropldMR - ldcenter %mm0, %mm1 - shift %mm0, %mm1, 1 - .endm - - - - - - # dropld from bottom row - - # dropld the bottom left square - .macro dropldBL - ldbottom %mm0, %mm1 - shift %mm0, %mm1, -1 - .endm - - # dropld the bottom mid square - .macro dropldBM - ldbottom %mm0, %mm1 - shift %mm0, %mm1, 0 - .endm - - # dropld the bottom right square - .macro dropldBR - ldbottom %mm0, %mm1 - shift %mm0, %mm1, 1 - .endm - - - - # *************************** CA STACK MANIP MACROS ***************************** - # these are the only asm macros that have a stack effect other than - # just replacing the TOS - # - # dup drop dropdup swap nip dropover - - .macro dup - lea -8(%esi), %esi - movq %mm0, (%esi) - .endm - - .macro drop - movq (%esi), %mm0 - lea 8(%esi), %esi - .endm - - .macro dropdup - movq (%esi), %mm0 - .endm - - .macro nipdup - movq %mm0, (%esi) - .endm - - .macro swap - movq (%esi), %mm1 - movq %mm0, (%esi) - movq %mm1, %mm0 - .endm - - .macro nip - lea 8(%esi), %esi - .endm - - .macro dropover - movq 8(%esi), %mm0 - .endm - - - # *************************** CA BOOLEAN LOGIC MACROS ***************************** - # overxor overand overor not - - .macro overxor - pxor (%esi), %mm0 - .endm - - .macro overand - pand (%esi), %mm0 - .endm - - .macro overor - por (%esi), %mm0 - .endm - - .macro not - pxor %mm3, %mm0 - .endm - - - - # *************************** CONSTANTS ***************************** - # dropzero dropone - - .macro dropzero - pxor %mm0, %mm0 - .endm - - .macro dropone - pcmpeqw %mm0, %mm0 - .endm - - - # *************************** 4 BIT REG ACCESS ****************************** - # dupsta0 - dupsta4 droplda0 - droplda4 - # store bit in accumulator - - # bit store - - .macro dupsta0 - movq %mm0, %mm4 - .endm - - .macro dupsta1 - movq %mm0, %mm5 - .endm - - .macro dupsta2 - movq %mm0, %mm6 - .endm - - .macro dupsta3 - movq %mm0, %mm7 - .endm - - # load bit from accumulator - - .macro droplda0 - movq %mm4, %mm0 - .endm - - .macro droplda1 - movq %mm5, %mm0 - .endm - - .macro droplda2 - movq %mm6, %mm0 - .endm - - .macro droplda3 - movq %mm7, %mm0 - .endm - - - # *************************** LOAD 4 BIT CONSTANT IN REG ****************************** - # a0000 - a1111 - - .macro ldbit0 value - .ifeq \value - movq %mm1, %mm4 - .else - movq %mm3, %mm4 - .endif - .endm - - .macro ldbit1 value - .ifeq \value - movq %mm1, %mm5 - .else - movq %mm3, %mm5 - .endif - .endm - - .macro ldbit2 value - .ifeq \value - movq %mm1, %mm6 - .else - movq %mm3, %mm6 - .endif - .endm - - .macro ldbit3 value - .ifeq \value - movq %mm1, %mm7 - .else - movq %mm3, %mm7 - .endif - .endm - - .macro ldbin b3 b2 b1 b0 - pxor %mm1, %mm1 - ldbit0 \b0 - ldbit1 \b1 - ldbit2 \b2 - ldbit3 \b3 - .endm - - .macro a0000 - ldbin 0 0 0 0 - .endm - - .macro a0001 - ldbin 0 0 0 1 - .endm - - .macro a0010 - ldbin 0 0 1 0 - .endm - - .macro a0011 - ldbin 0 0 1 1 - .endm - - .macro a0100 - ldbin 0 1 0 0 - .endm - - .macro a0101 - ldbin 0 1 0 1 - .endm - - .macro a0110 - ldbin 0 1 1 0 - .endm - - .macro a0111 - ldbin 0 1 1 1 - .endm - - .macro a1000 - ldbin 1 0 0 0 - .endm - - .macro a1001 - ldbin 1 0 0 1 - .endm - - .macro a1010 - ldbin 1 0 1 0 - .endm - - .macro a1011 - ldbin 1 0 1 1 - .endm - - .macro a1100 - ldbin 1 1 0 0 - .endm - - .macro a1101 - ldbin 1 1 0 1 - .endm - - .macro a1110 - ldbin 1 1 1 0 - .endm - - .macro a1111 - ldbin 1 1 1 1 - .endm - - - - - # *************************** 4 BIT COUNTER ****************************** - # adds TOS to bit of counter and returns carry in TOS - # - # adb0 - adb3 - - - .macro adb0 - movq %mm4, %mm2 - pxor %mm0, %mm4 - pand %mm2, %mm0 - .endm - - .macro adb1 - movq %mm5, %mm2 - pxor %mm0, %mm5 - pand %mm2, %mm0 - .endm - - .macro adb2 - movq %mm6, %mm2 - pxor %mm0, %mm6 - pand %mm2, %mm0 - .endm - - .macro adb3 - movq %mm7, %mm2 - pxor %mm0, %mm7 - pand %mm2, %mm0 - .endm - - - # *************************** ACCUMULATOR TESTS *************************** - # dropisnonzero4 - dropisnonzero1 - - .macro dropisnonzero4 - movq %mm4, %mm0 - por %mm5, %mm0 - por %mm6, %mm0 - por %mm7, %mm0 - .endm - - .macro dropisnonzero3 - movq %mm4, %mm0 - por %mm5, %mm0 - por %mm6, %mm0 - .endm - - .macro dropisnonzero2 - movq %mm4, %mm0 - por %mm5, %mm0 - .endm - - .macro dropisnonzero1 - movq %mm4, %mm0 - .endm - - - # *************************** REGISTER SHIFT OPERATIONS ********************** - # shift and leave shifted out byte on stack - # rotate trough top of stack - - .macro dropshiftright - movq %mm4, %mm0 - movq %mm5, %mm4 - movq %mm6, %mm5 - movq %mm7, %mm6 - pxor %mm7, %mm7 - .endm - - .macro dropshiftleft - movq %mm7, %mm0 - movq %mm6, %mm7 - movq %mm5, %mm6 - movq %mm4, %mm5 - pxor %mm4, %mm4 - .endm - - .macro dropshiftrighta - movq %mm4, %mm0 - movq %mm5, %mm4 - movq %mm6, %mm5 - movq %mm7, %mm6 - .endm - - .macro rotateright - movq %mm4, %mm1 - movq %mm5, %mm4 - movq %mm6, %mm5 - movq %mm7, %mm6 - movq %mm1, %mm7 - .endm - - .macro rotateleft - movq %mm7, %mm1 - movq %mm6, %mm7 - movq %mm5, %mm6 - movq %mm4, %mm5 - movq %mm1, %mm4 - .endm - - .macro rotaterightstack - movq %mm0, %mm1 - movq %mm4, %mm0 - movq %mm5, %mm4 - movq %mm6, %mm5 - movq %mm7, %mm6 - movq %mm1, %mm7 - .endm - - .macro rotateleftstack - movq %mm0, %mm1 - movq %mm7, %mm0 - movq %mm6, %mm7 - movq %mm5, %mm6 - movq %mm4, %mm5 - movq %mm1, %mm4 - .endm - - # *************************** OTHER REGISTER OPERATIONS ********************** - # anot : complement reg (can be used to implement subtraction) - - .macro anot - pxor %mm3, %mm4 - pxor %mm3, %mm5 - pxor %mm3, %mm6 - pxor %mm3, %mm7 - .endm -- cgit v1.2.1