cvsuser 01/09/22 13:13:17
Modified: . assemble.pl
Log:
Assembler register numbering rigour.
Courtesy of: Leon Brocard <[EMAIL PROTECTED]>
Revision Changes Path
1.39 +4 -2 parrot/assemble.pl
Index: assemble.pl
===================================================================
RCS file: /home/perlcvs/parrot/assemble.pl,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -w -r1.38 -r1.39
--- assemble.pl 2001/09/22 16:18:48 1.38
+++ assemble.pl 2001/09/22 20:13:17 1.39
@@ -21,7 +21,7 @@
'listing=s'));
if($options{'version'}) {
- print $0,'Version $Id: assemble.pl,v 1.38 2001/09/22 16:18:48 simon Exp $
',"\n";
+ print $0,'Version $Id: assemble.pl,v 1.39 2001/09/22 20:13:17 simon Exp $
',"\n";
exit;
}
@@ -75,7 +75,7 @@
my $line=0;
my %equate=('*'=>sub { return $pc },
'__DATE__'=>'"'.scalar(localtime).'"',
- '__VERSION__'=>'" $Revision: 1.38 $ "',
+ '__VERSION__'=>'" $Revision: 1.39 $ "',
'__LINE__' => sub { return $line });
my($code,$in_macro,$cur_macro);
while(my $l=shift(@program)) {
@@ -162,6 +162,7 @@
1 while $code=~s/\"([^\\\"]*(?:\\.[^\\\"]*)*)\"/constantize($1)/eg;
$code=~s/,/ /g;
+ $code =~ s/#.*$//; # Strip end-of-line comments
my($opcode,@args)=split(/\s+/,$code);
if(exists($macros{$opcode})) {
# found a macro
@@ -303,6 +304,7 @@
if($rtype eq "I" || $rtype eq "N" || $rtype eq "P" || $rtype eq "S") {
# its a register argument
$args[$_]=~s/^[INPS](\d+)$/$1/i;
+ error("Register $1 out of range (should be 0-31) in
'$opcode'",$file,$line) if $1 < 0 or $1 > 31;
} elsif($rtype eq "D") {
# a destination
if($args[$_]=~/^\$/) {