java disassembler/assembler

Daniel Reynaud reynaud.danyel@wanadoo.fr
Tue Oct 25 19:21:00 GMT 2005


> Well, printing everything twice is not a good interface.
> Instead of:
>
> ;                2: invokespecial 1 (java/lang/Object/<init> ()V)
>
> and then later:
>
>         invokespecial java/lang/Object/<init>()V

it was an example to show you both the output of the disassembler in warmode 
and the jasmin translation. It is possible to have just the warmode output, 
or just the jasmin translation (it is even possible to have nothing, for 
those who were wondering :).


> The assembler could just ignore the "#NNN=" prefix.   It would
> be nice to have an option where the the assembler would try to
> use constant pool entry NNN if it is unused or matches the request,
> or pick a different or new entry otherwise (and printing a warning).
> But I don't that's a critical feature.

I'll see what I can do with this. Sounds like a good idea. The jasmin code 
is becoming quite messy however if we combine all the new features.


> Note also you only want to print the constant pool and the constant
> pool indexes, in a "verbose" mode - probably not by default.

sure, the default is to print the jasmin output



Here is what I added these days :

- the new jasmin language accepts the pc of opcodes before the instruction, 
for example
0: ldc "hello"
2: invokesomething


- use of absolute or relative offset instead of labels. Example :
0: ldc "hello"
2: goto 0L      ; the L means "0 as a label", so goto offset 0
5: goto 0       ; traditional goto, so goto 0 means stay here
8: goto -8      ; traditional goto, go 8 bytes backward
Label0:
11: goto Label0 ; traditional jasmin goto, with a label as a target
14: goto 1      ; go 1 byte forward
17: goto 5L     ; go to offset 5

I think you've understood what I mean.


- I finally implemented StackMap attributes. It's quite awful but here is 
what I use :
You define stack map frames between .stack and .end stack, the attribute is 
implicitly the addition of all your stack map frames. You can define your 
stack map frames inside the code (the more convenient is to put them at the 
offset they represent). Example :

.method blablabla
...
    .stack
        offset 12
        locals Null
        locals Top
        locals Object foo/bar/Hello
        stack Null
    .end stack
      12: aload_0
      13: invokevirtual maddany/HelloWorldMIDlet/notifyDestroyed()V

    .stack
        offset 16
        locals Null
        locals Integer
        stack Uninitialized 12
        stack Long
    .end stack
      16: return

.end method

I think that's all. I'm preparing some documentation with all the syntax 
extensions to Jasmin.

Regards,
Daniel 



More information about the Java mailing list