--- M6502/Orao.pm 2007/07/31 10:52:06 49 +++ M6502/Orao.pm 2007/07/31 11:14:19 50 @@ -241,28 +241,6 @@ ); } -=head2 prompt - - $orao->prompt( $address, $last_command ); - -=cut - -sub prompt { - my $self = shift; - $self->app->sync; - my $a = shift; - my $last = shift; - print STDERR $self->hexdump( $a ), - $last ? "[$last] " : '', - "> "; - my $in = ; - chomp($in); - warn "## prompt got: $in\n" if $self->debug; - $in ||= $last; - $last = $in; - return split(/\s+/, $in) if $in; -} - =head1 Memory management Orao implements all I/O using mmap addresses. This was main reason why @@ -323,14 +301,35 @@ Command-line debugging intrerface is implemented for communication with emulated device -=head2 cli +=head2 prompt - $orao->cli(); + $orao->prompt( $address, $last_command ); =cut my $last = 'r 1'; +sub prompt { + my $self = shift; + $self->app->sync; + my $a = shift; + print STDERR $self->hexdump( $a ), + $last ? "[$last] " : '', + "> "; + my $in = ; + chomp($in); + warn "## prompt got: $in\n" if $self->debug; + $in ||= $last; + $last = $in; + return split(/\s+/, $in) if $in; +} + +=head2 cli + + $orao->cli(); + +=cut + sub cli { my $self = shift; my $a = $PC || confess "no pc?"; @@ -343,16 +342,21 @@ if ( $c =~ m/^[qx]/i ) { exit; } elsif ( $c eq '?' ) { + my $t = $self->trace ? 'on' : 'off' ; + my $d = $self->debug ? 'on' : 'off' ; warn <<__USAGE__; -uage: +Usage: + x|q\t\texit e 6000 6010\tdump memory, +/- to walk forward/backward m 1000 ff 00\tput ff 00 on 1000 j|u 1000\t\tjump (change pc) r 42\t\trun 42 instruction opcodes -t\t\ttrace on/off -d\t\tdebug on/off +t\t\ttrace [$t] +d\t\tdebug [$d] + __USAGE__ + warn sprintf(" PC: %04x A:%02x P:%02x X:%02x Y:%02x S:%02x\n", $PC, $A, $P, $X, $Y, $S); } elsif ( $c =~ m/^e/i ) { $a = $v if defined($v); my $to = shift @v; @@ -373,12 +377,15 @@ $a = $v; $self->poke_code( $a, @v ); printf "poke %d bytes at %04x\n", $#v + 1, $a; + $last = '+'; } elsif ( $c =~ m/^l/i ) { my $to = shift @v || 0x1000; $a = $to; $self->load_oraoemu( $v, $a ); + $last = ''; } elsif ( $c =~ m/^s/i ) { $self->save_dump( $v || 'mem.dump', @v ); + $last = ''; } elsif ( $c =~ m/^r/i ) { $run_for = $v || 1; print "run_for $run_for instructions\n"; @@ -388,6 +395,7 @@ printf "set pc to %04x\n", $to; $PC = $to; # remember for restart $run_for = 1; + $last = sprintf('m %04x', $to); last; } elsif ( $c =~ m/^t/ ) { $self->trace( not $self->trace );