Hey all.  This is a (fairly stupid) pbc dumper, including a dissassembler.
I say fairly stupid because it creates code that won't assemble, because it
tries to do a very literal translation back to pasm.

Sample output (of the bytecode part; the rest is pretty non-contriversial):
set_i_ic         I0, 32         # 55 0 32
set_i_ic         I1, 0          # 55 1 0
chr_s_i_sc       S0, I0, str_const(0)           # 185 0 0 0
print_sc         str_const(1)           # 27 1
gt_i_ic_ic       I0, 99, 6              # 87 0 99 6
print_sc         str_const(2)           # 27 2
print_i  I0             # 22 0
print_sc         str_const(3)           # 27 3
print_s  S0             # 26 0
inc_i    I0             # 124 0
add_i_i_ic       I1, I1, 8              # 101 1 1 8
cmod_i_i_ic      I2, I1, 80             # 106 2 1 80
print_sc         str_const(4)           # 27 4
set_i_ic         I1, 0          # 55 1 0
lt_i_ic_ic       I0, 127, -33           # 75 0 127 -33
print_sc         str_const(4)           # 27 4
end             # 0

(As you can see, the formating is rather ugly, and it produces
"str_const(n)" constructions instead of substituting in the constant's
value.  That's what is uncompileable.  Surprisingly (to me, anyway), using a
constant integer instead of a label works.)

Hope that this is useful.

         -=- James Mastros

Attachment: pdump.pl
Description: Perl program

Reply via email to