Question like "how do I generate {some Java code} with ASM" has been answered in ASM FAQ:
If you want to know how to generate a synchronized block, a try catch block, a finally statement, or any other Java construct, write the Java code you want to generate in a temporary class, compile it with javac, and then use the ASMifier to get the ASM code that will generate this class (see "10. How do I get the bytecode of an existing class?").
You can go even further, by comparing output of ASMifier before and after transformation as described in this article.