1
0
mirror of https://github.com/livingcomputermuseum/pdp7-unix.git synced 2026-01-22 02:35:07 +00:00

I've changed the assembler so that it groks the <ab> string literal

syntax. I think it's OK, but it probably needs more testing.
write_test.s was changed to exercise the string parsing.
This commit is contained in:
Warren Toomey 2016-02-26 07:35:36 +10:00
parent 018af6f43e
commit c84b2dffdd
2 changed files with 30 additions and 2 deletions

View File

@ -198,7 +198,7 @@ sub parse_statement {
# Parse an expression and return either:
# a single value which is a PDP-7 word
# a single value which is undef, as this was a statement
# a single value which is undef, as this was unrecognised
sub parse_expression {
my $expression = shift;
@ -346,6 +346,34 @@ sub parse_expression {
#printf( "o>%s<o o>%s<o o>%s<o\n",
# $word1 || "", $word2 || "", $word3 || "" );
# This is a 2-character string literal, put each in separate nine bits
if ($word1=~ m{^<(.)(.)>$}) {
print("String literal <$1 and $2>\n") if ($debug);
return((ord($1) << 9) | ord($2));
}
# This is a <n string literal which might have been followed by a numeric literal
if ($word1=~ m{^<(.)}) {
print("String literal <$1 and $word2\n") if ($debug);
my $msb= $1;
my $lsb= (defined($word2)) ? parse_expression($word2) : 0;
return((ord($msb) << 9) | $lsb);
}
# This is a n> string literal preceded by a numeric literal
if (defined($word2) && ($word2=~ m{(.)>$})) {
print("String literal $word1 and $1>\n") if ($debug);
my $msb= parse_expression($word1);
my $lsb= $1;
return(($msb << 9) | ord($lsb));
}
# This is a n> string literal not preceded by a numeric literal
if ($word1=~ m{(.)>$}) {
print("String literal $1>\n") if ($debug);
return(ord($1));
}
# This a defined instruction
if ( defined( $inst{$word1} ) ) {
#printf( "Found the instruction %s: 0%o\n", $word1, $inst{$word1} );

View File

@ -47,7 +47,7 @@ in: 023
out: 0
" Hello, world\n, two ASCII chars per word
hello: 0110145; 0154154; 0157054; 040; 0167157; 0162154; 0144012
hello: <He>; <l 0154; 0157 ,>; 040; <wo>; <rl>; <d 012
helloptr: hello
" fred as a string, NUL terminated