Add basic support for ODEX instructions
diff --git a/dexlib2/src/main/java/org/jf/dexlib2/builder/MutableMethodImplementation.java b/dexlib2/src/main/java/org/jf/dexlib2/builder/MutableMethodImplementation.java
index 148bafd..a77ae25 100644
--- a/dexlib2/src/main/java/org/jf/dexlib2/builder/MutableMethodImplementation.java
+++ b/dexlib2/src/main/java/org/jf/dexlib2/builder/MutableMethodImplementation.java
@@ -601,6 +601,9 @@
             case Format22c:
                 setInstruction(location, newBuilderInstruction22c((Instruction22c) instruction));
                 return;
+            case Format22cs:
+                setInstruction(location, newBuilderInstruction22cs((Instruction22cs) instruction));
+                return;
             case Format22s:
                 setInstruction(location, newBuilderInstruction22s((Instruction22s) instruction));
                 return;
@@ -636,9 +639,21 @@
             case Format35c:
                 setInstruction(location, newBuilderInstruction35c((Instruction35c) instruction));
                 return;
+            case Format35mi:
+                setInstruction(location, newBuilderInstruction35mi((Instruction35mi) instruction));
+                return;
+            case Format35ms:
+                setInstruction(location, newBuilderInstruction35ms((Instruction35ms) instruction));
+                return;
             case Format3rc:
                 setInstruction(location, newBuilderInstruction3rc((Instruction3rc)instruction));
                 return;
+            case Format3rmi:
+                setInstruction(location, newBuilderInstruction3rmi((Instruction3rmi)instruction));
+                return;
+            case Format3rms:
+                setInstruction(location, newBuilderInstruction3rms((Instruction3rms)instruction));
+                return;
             case Format51l:
                 setInstruction(location, newBuilderInstruction51l((Instruction51l)instruction));
                 return;
@@ -771,6 +786,15 @@
     }
 
     @Nonnull
+    private BuilderInstruction22cs newBuilderInstruction22cs(@Nonnull Instruction22cs instruction) {
+        return new BuilderInstruction22cs(
+                instruction.getOpcode(),
+                instruction.getRegisterA(),
+                instruction.getRegisterB(),
+                instruction.getFieldOffset());
+    }
+
+    @Nonnull
     private BuilderInstruction22s newBuilderInstruction22s(@Nonnull Instruction22s instruction) {
         return new BuilderInstruction22s(
                 instruction.getOpcode(),
@@ -869,6 +893,32 @@
     }
 
     @Nonnull
+    private BuilderInstruction35mi newBuilderInstruction35mi(@Nonnull Instruction35mi instruction) {
+        return new BuilderInstruction35mi(
+                instruction.getOpcode(),
+                instruction.getRegisterCount(),
+                instruction.getRegisterC(),
+                instruction.getRegisterD(),
+                instruction.getRegisterE(),
+                instruction.getRegisterF(),
+                instruction.getRegisterG(),
+                instruction.getInlineIndex());
+    }
+
+    @Nonnull
+    private BuilderInstruction35ms newBuilderInstruction35ms(@Nonnull Instruction35ms instruction) {
+        return new BuilderInstruction35ms(
+                instruction.getOpcode(),
+                instruction.getRegisterCount(),
+                instruction.getRegisterC(),
+                instruction.getRegisterD(),
+                instruction.getRegisterE(),
+                instruction.getRegisterF(),
+                instruction.getRegisterG(),
+                instruction.getVtableIndex());
+    }
+
+    @Nonnull
     private BuilderInstruction3rc newBuilderInstruction3rc(@Nonnull Instruction3rc instruction) {
         return new BuilderInstruction3rc(
                 instruction.getOpcode(),
@@ -878,6 +928,24 @@
     }
 
     @Nonnull
+    private BuilderInstruction3rmi newBuilderInstruction3rmi(@Nonnull Instruction3rmi instruction) {
+        return new BuilderInstruction3rmi(
+                instruction.getOpcode(),
+                instruction.getStartRegister(),
+                instruction.getRegisterCount(),
+                instruction.getInlineIndex());
+    }
+
+    @Nonnull
+    private BuilderInstruction3rms newBuilderInstruction3rms(@Nonnull Instruction3rms instruction) {
+        return new BuilderInstruction3rms(
+                instruction.getOpcode(),
+                instruction.getStartRegister(),
+                instruction.getRegisterCount(),
+                instruction.getVtableIndex());
+    }
+
+    @Nonnull
     private BuilderInstruction51l newBuilderInstruction51l(@Nonnull Instruction51l instruction) {
         return new BuilderInstruction51l(
                 instruction.getOpcode(),
diff --git a/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction22cs.java b/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction22cs.java
new file mode 100644
index 0000000..e43f39d
--- /dev/null
+++ b/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction22cs.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2012, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.jf.dexlib2.builder.instruction;
+
+import org.jf.dexlib2.Format;
+import org.jf.dexlib2.Opcode;
+import org.jf.dexlib2.builder.BuilderInstruction;
+import org.jf.dexlib2.iface.instruction.formats.Instruction22c;
+import org.jf.dexlib2.iface.instruction.formats.Instruction22cs;
+import org.jf.dexlib2.iface.reference.Reference;
+import org.jf.dexlib2.util.Preconditions;
+
+import javax.annotation.Nonnull;
+
+public class BuilderInstruction22cs extends BuilderInstruction implements Instruction22cs {
+    public static final Format FORMAT = Format.Format22cs;
+
+    protected final int registerA;
+    protected final int registerB;
+    protected final int fieldOffset;
+
+    public BuilderInstruction22cs(@Nonnull Opcode opcode,
+                                  int registerA,
+                                  int registerB,
+                                  int fieldOffset) {
+        super(opcode);
+        this.registerA = Preconditions.checkNibbleRegister(registerA);
+        this.registerB = Preconditions.checkNibbleRegister(registerB);
+        this.fieldOffset = fieldOffset;
+    }
+
+    @Override public int getRegisterA() { return registerA; }
+    @Override public int getRegisterB() { return registerB; }
+    @Override public int getFieldOffset() { return fieldOffset; }
+    @Override public Format getFormat() { return FORMAT; }
+}
\ No newline at end of file
diff --git a/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction35mi.java b/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction35mi.java
new file mode 100644
index 0000000..43aed78
--- /dev/null
+++ b/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction35mi.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2012, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.jf.dexlib2.builder.instruction;
+
+import org.jf.dexlib2.Format;
+import org.jf.dexlib2.Opcode;
+import org.jf.dexlib2.builder.BuilderInstruction;
+import org.jf.dexlib2.iface.instruction.formats.Instruction35mi;
+import org.jf.dexlib2.util.Preconditions;
+
+import javax.annotation.Nonnull;
+
+public class BuilderInstruction35mi extends BuilderInstruction implements Instruction35mi {
+    public static final Format FORMAT = Format.Format35mi;
+
+    protected final int registerCount;
+    protected final int registerC;
+    protected final int registerD;
+    protected final int registerE;
+    protected final int registerF;
+    protected final int registerG;
+    protected final int inlineIndex;
+
+    public BuilderInstruction35mi(@Nonnull Opcode opcode,
+                                  int registerCount,
+                                  int registerC,
+                                  int registerD,
+                                  int registerE,
+                                  int registerF,
+                                  int registerG,
+                                  int inlineIndex) {
+        super(opcode);
+        this.registerCount = Preconditions.check35cAnd45ccRegisterCount(registerCount);
+        this.registerC = (registerCount>0) ? Preconditions.checkNibbleRegister(registerC) : 0;
+        this.registerD = (registerCount>1) ? Preconditions.checkNibbleRegister(registerD) : 0;
+        this.registerE = (registerCount>2) ? Preconditions.checkNibbleRegister(registerE) : 0;
+        this.registerF = (registerCount>3) ? Preconditions.checkNibbleRegister(registerF) : 0;
+        this.registerG = (registerCount>4) ? Preconditions.checkNibbleRegister(registerG) : 0;
+        this.inlineIndex = inlineIndex;
+    }
+
+    @Override public int getRegisterCount() { return registerCount; }
+    @Override public int getRegisterC() { return registerC; }
+    @Override public int getRegisterD() { return registerD; }
+    @Override public int getRegisterE() { return registerE; }
+    @Override public int getRegisterF() { return registerF; }
+    @Override public int getRegisterG() { return registerG; }
+    @Override public int getInlineIndex() { return inlineIndex; }
+    @Override public Format getFormat() { return FORMAT; }
+
+}
diff --git a/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction35ms.java b/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction35ms.java
new file mode 100644
index 0000000..824dbd8
--- /dev/null
+++ b/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction35ms.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2012, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.jf.dexlib2.builder.instruction;
+
+import org.jf.dexlib2.Format;
+import org.jf.dexlib2.Opcode;
+import org.jf.dexlib2.builder.BuilderInstruction;
+import org.jf.dexlib2.iface.instruction.formats.Instruction35ms;
+import org.jf.dexlib2.util.Preconditions;
+
+import javax.annotation.Nonnull;
+
+public class BuilderInstruction35ms extends BuilderInstruction implements Instruction35ms {
+    public static final Format FORMAT = Format.Format35ms;
+
+    protected final int registerCount;
+    protected final int registerC;
+    protected final int registerD;
+    protected final int registerE;
+    protected final int registerF;
+    protected final int registerG;
+    protected final int vtableIndex;
+
+    public BuilderInstruction35ms(@Nonnull Opcode opcode,
+                                  int registerCount,
+                                  int registerC,
+                                  int registerD,
+                                  int registerE,
+                                  int registerF,
+                                  int registerG,
+                                  int vtableIndex) {
+        super(opcode);
+        this.registerCount = Preconditions.check35cAnd45ccRegisterCount(registerCount);
+        this.registerC = (registerCount>0) ? Preconditions.checkNibbleRegister(registerC) : 0;
+        this.registerD = (registerCount>1) ? Preconditions.checkNibbleRegister(registerD) : 0;
+        this.registerE = (registerCount>2) ? Preconditions.checkNibbleRegister(registerE) : 0;
+        this.registerF = (registerCount>3) ? Preconditions.checkNibbleRegister(registerF) : 0;
+        this.registerG = (registerCount>4) ? Preconditions.checkNibbleRegister(registerG) : 0;
+        this.vtableIndex = vtableIndex;
+    }
+
+    @Override public int getRegisterCount() { return registerCount; }
+    @Override public int getRegisterC() { return registerC; }
+    @Override public int getRegisterD() { return registerD; }
+    @Override public int getRegisterE() { return registerE; }
+    @Override public int getRegisterF() { return registerF; }
+    @Override public int getRegisterG() { return registerG; }
+    @Override public int getVtableIndex() { return vtableIndex; }
+    @Override public Format getFormat() { return FORMAT; }
+}
diff --git a/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction3rmi.java b/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction3rmi.java
new file mode 100644
index 0000000..1df7b30
--- /dev/null
+++ b/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction3rmi.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2012, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.jf.dexlib2.builder.instruction;
+
+import org.jf.dexlib2.Format;
+import org.jf.dexlib2.Opcode;
+import org.jf.dexlib2.builder.BuilderInstruction;
+import org.jf.dexlib2.iface.instruction.formats.Instruction3rmi;
+import org.jf.dexlib2.iface.instruction.formats.Instruction3rms;
+import org.jf.dexlib2.util.Preconditions;
+
+import javax.annotation.Nonnull;
+
+public class BuilderInstruction3rmi extends BuilderInstruction implements Instruction3rmi {
+    public static final Format FORMAT = Format.Format3rmi;
+
+    protected final int startRegister;
+    protected final int registerCount;
+    protected final int inlineIndex;
+
+    public BuilderInstruction3rmi(@Nonnull Opcode opcode,
+                                  int startRegister,
+                                  int registerCount,
+                                  int inlineIndex) {
+        super(opcode);
+        this.startRegister = Preconditions.checkShortRegister(startRegister);
+        this.registerCount = Preconditions.checkRegisterRangeCount(registerCount);
+        this.inlineIndex = inlineIndex;
+    }
+
+    @Override public int getStartRegister() { return startRegister; }
+    @Override public int getRegisterCount() { return registerCount; }
+    @Override public int getInlineIndex() { return inlineIndex; }
+    @Override public Format getFormat() { return FORMAT; }
+}
+
diff --git a/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction3rms.java b/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction3rms.java
new file mode 100644
index 0000000..bd73901
--- /dev/null
+++ b/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction3rms.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2012, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.jf.dexlib2.builder.instruction;
+
+import org.jf.dexlib2.Format;
+import org.jf.dexlib2.Opcode;
+import org.jf.dexlib2.builder.BuilderInstruction;
+import org.jf.dexlib2.iface.instruction.formats.Instruction3rc;
+import org.jf.dexlib2.iface.instruction.formats.Instruction3rms;
+import org.jf.dexlib2.iface.reference.Reference;
+import org.jf.dexlib2.util.Preconditions;
+
+import javax.annotation.Nonnull;
+
+public class BuilderInstruction3rms extends BuilderInstruction implements Instruction3rms {
+    public static final Format FORMAT = Format.Format3rms;
+
+    protected final int startRegister;
+    protected final int registerCount;
+    protected final int vtableIndex;
+
+    public BuilderInstruction3rms(@Nonnull Opcode opcode,
+                                  int startRegister,
+                                  int registerCount,
+                                  int vtableIndex) {
+        super(opcode);
+        this.startRegister = Preconditions.checkShortRegister(startRegister);
+        this.registerCount = Preconditions.checkRegisterRangeCount(registerCount);
+        this.vtableIndex = vtableIndex;
+    }
+
+    @Override public int getStartRegister() { return startRegister; }
+    @Override public int getRegisterCount() { return registerCount; }
+    @Override public int getVtableIndex() { return vtableIndex; }
+    @Override public Format getFormat() { return FORMAT; }
+}
+
diff --git a/dexlib2/src/main/java/org/jf/dexlib2/writer/DexWriter.java b/dexlib2/src/main/java/org/jf/dexlib2/writer/DexWriter.java
index 00cce65..1b0d9df 100644
--- a/dexlib2/src/main/java/org/jf/dexlib2/writer/DexWriter.java
+++ b/dexlib2/src/main/java/org/jf/dexlib2/writer/DexWriter.java
@@ -1017,6 +1017,9 @@
                         case Format22c:
                             instructionWriter.write((Instruction22c)instruction);
                             break;
+                        case Format22cs:
+                            instructionWriter.write((Instruction22cs)instruction);
+                            break;
                         case Format22s:
                             instructionWriter.write((Instruction22s)instruction);
                             break;
@@ -1047,9 +1050,21 @@
                         case Format35c:
                             instructionWriter.write((Instruction35c)instruction);
                             break;
+                        case Format35mi:
+                            instructionWriter.write((Instruction35mi)instruction);
+                            break;
+                        case Format35ms:
+                            instructionWriter.write((Instruction35ms)instruction);
+                            break;
                         case Format3rc:
                             instructionWriter.write((Instruction3rc)instruction);
                             break;
+                        case Format3rmi:
+                            instructionWriter.write((Instruction3rmi)instruction);
+                            break;
+                        case Format3rms:
+                            instructionWriter.write((Instruction3rms)instruction);
+                            break;
                         case Format45cc:
                             instructionWriter.write((Instruction45cc)instruction);
                             break;
diff --git a/dexlib2/src/main/java/org/jf/dexlib2/writer/InstructionWriter.java b/dexlib2/src/main/java/org/jf/dexlib2/writer/InstructionWriter.java
index 1b883f1..f6fd52f 100644
--- a/dexlib2/src/main/java/org/jf/dexlib2/writer/InstructionWriter.java
+++ b/dexlib2/src/main/java/org/jf/dexlib2/writer/InstructionWriter.java
@@ -239,6 +239,16 @@
         }
     }
 
+    public void write(@Nonnull Instruction22cs instruction) {
+        try {
+            writer.write(getOpcodeValue(instruction.getOpcode()));
+            writer.write(packNibbles(instruction.getRegisterA(), instruction.getRegisterB()));
+            writer.writeUshort(instruction.getFieldOffset());
+        } catch (IOException ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
     public void write(@Nonnull Instruction22s instruction) {
         try {
             writer.write(getOpcodeValue(instruction.getOpcode()));
@@ -343,6 +353,30 @@
         }
     }
 
+    public void write(@Nonnull Instruction35mi instruction) {
+        try {
+            writer.write(getOpcodeValue(instruction.getOpcode()));
+            writer.write(packNibbles(instruction.getRegisterG(), instruction.getRegisterCount()));
+            writer.writeUshort(instruction.getInlineIndex());
+            writer.write(packNibbles(instruction.getRegisterC(), instruction.getRegisterD()));
+            writer.write(packNibbles(instruction.getRegisterE(), instruction.getRegisterF()));
+        } catch (IOException ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    public void write(@Nonnull Instruction35ms instruction) {
+        try {
+            writer.write(getOpcodeValue(instruction.getOpcode()));
+            writer.write(packNibbles(instruction.getRegisterG(), instruction.getRegisterCount()));
+            writer.writeUshort(instruction.getVtableIndex());
+            writer.write(packNibbles(instruction.getRegisterC(), instruction.getRegisterD()));
+            writer.write(packNibbles(instruction.getRegisterE(), instruction.getRegisterF()));
+        } catch (IOException ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
     public void write(@Nonnull Instruction3rc instruction) {
         try {
             writer.write(getOpcodeValue(instruction.getOpcode()));
@@ -354,6 +388,29 @@
         }
     }
 
+    public void write(@Nonnull Instruction3rmi instruction) {
+        try {
+            writer.write(getOpcodeValue(instruction.getOpcode()));
+            writer.write(instruction.getRegisterCount());
+            writer.writeUshort(instruction.getInlineIndex());
+            writer.writeUshort(instruction.getStartRegister());
+        } catch (IOException ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+
+    public void write(@Nonnull Instruction3rms instruction) {
+        try {
+            writer.write(getOpcodeValue(instruction.getOpcode()));
+            writer.write(instruction.getRegisterCount());
+            writer.writeUshort(instruction.getVtableIndex());
+            writer.writeUshort(instruction.getStartRegister());
+        } catch (IOException ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
     public void write(@Nonnull Instruction45cc instruction) {
         try {
             writer.write(getOpcodeValue(instruction.getOpcode()));