Skip to content

Commit

Permalink
implement the [gs]et_byte ops, though no tests yet
Browse files Browse the repository at this point in the history
  • Loading branch information
cotto committed Jul 14, 2011
1 parent e7365ae commit b5ae2ab
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/m0/perl5/m0_assembler.pl
Original file line number Diff line number Diff line change
Expand Up @@ -617,11 +617,13 @@ sub parse_chunks {
0x1B set_imm
0x1C deref
0x1D set_ref
0x1E csym
0x1F ccall_arg
0x20 ccall_ret
0x21 ccall
0x22 print_s
0x23 print_i
0x24 print_n
0x25 exit
0x1E set_byte
0x1F get_byte
0x20 csym
0x21 ccall_arg
0x22 ccall_ret
0x23 ccall
0x24 print_s
0x25 print_i
0x26 print_n
0x27 exit
18 changes: 18 additions & 0 deletions src/m0/perl5/m0_interp.pl
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ sub new_interp {
\&m0_opfunc_set_imm,
\&m0_opfunc_deref,
\&m0_opfunc_set_ref,
\&m0_opfunc_set_byte,
\&m0_opfunc_get_byte,
\&m0_opfunc_csym,
\&m0_opfunc_ccall_arg,
\&m0_opfunc_ccall_ret,
Expand Down Expand Up @@ -461,6 +463,22 @@ sub m0_opfunc_set_ref {
$$cf->[$a1][ $$cf->[$a2] ] = $$cf->[$a3];
}

sub m0_opfunc_set_byte {
my ($cf, $a1, $a2, $a3) = @_;
m0_say "set_byte $a1, $a2, $a3";

$$cf->[$a1] = bytes::substr($$cf->[$a2], $$cf->[$a3]);
my $new_byte = bytes::chr($$cf->[$a3] & 255);
bytes::substr($$cf->[$a2], $$cf->[$a3], $new_byte);
}

sub m0_opfunc_get_byte {
my ($cf, $a1, $a2, $a3) = @_;
m0_say "get_byte $a1, $a2, $a3";

$$cf->[$a1] = bytes::substr($$cf->[$a2], $$cf->[$a3], 1);
}

sub m0_opfunc_csym {
my ($cf, $a1, $a2, $a3) = @_;
m0_say "csym $a1, $a2, $a3";
Expand Down

0 comments on commit b5ae2ab

Please sign in to comment.