use Data::SExpression qw/consp scalarp/;
use Scalar::Util qw/looks_like_number/;
-our $VERSION = '0.002';
+our $VERSION = '0.004';
our %TYPES = (
LIST => 0,
die 'Computed addr is not a number: ', Dumper($addr), "\n" unless looks_like_number $addr;
- if (ref $type eq 'Data::SExpression::Symbol') {
+ if (!looks_like_number $type) {
die "No such type: $type\n" unless exists $TYPES{$type};
$type = $TYPES{$type};
- } elsif (!looks_like_number $type) {
- die "Type is not a number or symbol: $type\n"
}
$addr += (1 << $self->{addr_bits}) if $addr < 0;
my ($self, $fh) = @_;
$fh //= \*STDOUT;
+ die "addr_bits + type_bits >= 16\n"if $self->{addr_bits} + $self->{type_bits} > 16;
+
my $length = @{$self->{memory}};
print $fh pack('n', $length);
for (@{$self->{memory}}) {
Can be called multiple times to lay out multiple sequences of
S-expressions one after another.
+=item $asm->B<process>(I<$sexp>)
+
+Given an already-parsed sexp (meaning a
+L<Data::SExpression> object), lay it out in memory.
+Can be called multiple times to lay out multiple sequences of
+S-expressions one after another.
+
=item $asm->B<finish>
Move the last pointer to position 5, and put the free pointer at