The assembler patches:
        * handle blank lines containing a label
        * handle constants in decimal,octal, or hex.

Opcode table patch (and basic_opcodes.ops):
        * adds and, or, not, xor, shl, and shr.

**** Builds ok, but coredumps in the interpreter.  Any hints on what I
did wrong welcome! ****

Attached is also a test program for the new ops (which coredumps).


Brian


? op.h
? config.h
? patch
? interp_guts.h
? basic_opcodes.c
? test_prog
? test2.pbc
? test3.pbc
? euclid.pbc
? bitops.pbc
? bitops+assembler.patch
? t/bitops.pasm
Index: assemble.pl
===================================================================
RCS file: /home/perlcvs/parrot/assemble.pl,v
retrieving revision 1.8
diff -u -r1.8 assemble.pl
--- assemble.pl 2001/09/12 09:54:46     1.8
+++ assemble.pl 2001/09/12 20:24:07
@@ -62,19 +62,17 @@
     push @code, $_;
     $pc += 1+@args;
 }
-
 emit_magic();
 emit_fixup_section();
 emit_constants_section();
-
 # Now assemble
 $pc = 0;
 my $line = 0;
-while ($_ = shift @code) {
+foreach (@code) {
     $line++;
     chomp;
     s/,/ /g;
-
+    next if(/^\s*$/);
     my ($opcode, @args) = split /\s+/, $_;
 
     if (!exists $opcodes{lc $opcode}) {
@@ -93,6 +91,8 @@
        } elsif($rtype eq "D") {
            # a destination
            $args[$_]=fixup($args[$_]);
+       } else {
+          $args[$_]=oct($args[$_]) if($args[$_]=~/^0/);
        }
        $output .= pack $type, $args[$_];
     }
Index: basic_opcodes.ops
===================================================================
RCS file: /home/perlcvs/parrot/basic_opcodes.ops,v
retrieving revision 1.8
diff -u -r1.8 basic_opcodes.ops
--- basic_opcodes.ops   2001/09/12 18:39:12     1.8
+++ basic_opcodes.ops   2001/09/12 20:24:07
@@ -329,3 +329,34 @@
 // NOOP
 AUTO_OP noop {
 }
+
+// AND_I
+AUTO_OP and_i {
+  INT_REG(P1)=INT_REG(P2) & INT_REG(P3);
+}
+
+// NOT_I
+AUTO_OP not_i {
+  INT_REG(P1)=!INT_REG(P2);
+}
+
+// OR_I
+AUTO_OP or_i {
+  INT_REG(P1)=INT_REG(P2) | INT_REG(P3);
+}
+
+// SHL_I
+AUTO_OP shl_i_ic {
+  INT_REG(P1)=INT_REG(P2) << P3;
+}
+
+
+// SHR_I
+AUTO_OP shr_i_ic {
+  INT_REG(P1)=INT_REG(P2) >> P3;
+}
+
+// XOR
+AUTO_OP xor_i {
+  INT_REG(P1)=INT_REG(P2) ^ INT_REG(P3);
+}
Index: opcode_table
===================================================================
RCS file: /home/perlcvs/parrot/opcode_table,v
retrieving revision 1.9
diff -u -r1.9 opcode_table
--- opcode_table        2001/09/12 18:39:12     1.9
+++ opcode_table        2001/09/12 20:24:07
@@ -102,3 +102,10 @@
 clear_n        0
 clear_p        0
 
+# Bitops
+and_i  3       I I I
+not_i  2       I I
+or_i   3       I I I
+shl_i_ic 3     I I i
+shr_i_ic 3     I I i
+xor_i  3       I I I
# bitops.pasm : test bitops.
#   and, not, or, shl, shr, xor
# Brian Wheeler ([EMAIL PROTECTED])

MAIN:   set_i_ic        I1,0b11111111
        set_i_ic        I2,0b00000000
        set_i_ic        I3,0b10101010
        set_i_ic        I4,0b01010101
        set_i_ic        I5,0
        set_s_sc        S1,"OK"
        set_s_sc        S2,"NG"
        set_s_sc        S3,"Test Number"
                
        # test 'and'
        set_s_sc        S5,"AND Test"
        print_s         S5
        
AND_T1: 
        inc_i           I5
        print_s         S3
        print_i         I5      
        and_i           I6,I1,I2
        print_i         I6
        eq_i_ic         I6,I2,A1_OK,A1_NG

A1_OK:  print_s         S1
        branch_ic       AND_T2

A1_NG:  print_s         S2
        branch_ic       AND_T2



AND_T2:
        inc_i           I5
        print_s         S3
        print_i         I5
        and_i           I6,I1,I3
        eq_i_ic         I6,I3,A2_OK,A3_NG
        
A2_OK:  print_s         S1
        branch_ic       AND_T3
        
A3_NG:  print_s         S2
        branch_ic       AND_T3
        
AND_T3: inc_i           I5
        print_s         S3
        print_i         I5
        and_i           I6,I3,I4
        eq_i_ic         I6,I2,A3_OK,A3_NG

A3_OK:  print_s         S1
        branch_ic       OR_T

A3_NG:  print_s         S2
        branch_ic       OR_T
        


        
        # test or
OR_T:
        set_s_sc        S5,"OR Test"
        print_s         S5
        set_i_ic        I5,0
        
        end     

Reply via email to