// // Copyright (C) 2004 Boretti Mathieu // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // // // Define a class named "org.boretti.asm2class.example.somme" // Lorg/boretti/asm2class/example/find/recherche1; : // // Define a method named "main" with String [] as parameter and no // return value. This method is public and static // * . main ([Ljava/lang/String;)V : // // Push the static field "out" from class java.lang.System // that is of type java.io.PrintStream onto the stack // getstatic Ljava/lang/System; out Ljava/io/PrintStream; // 1 // // Duplicate the head // dup // 1 1 // // Store this static field into register 0 // astore_1 // 1 // // Push a small text // ldc "Please insert a text" // 1 t // // Display the text // invokevirtual Ljava/io/PrintStream; (Ljava/lang/String;)V println // // // Creer un DataInputStream // new Ljava/io/DataInputStream; // 1 // // Duplicate the head // dup // 1 1 // // Push the static field "in" from class java.lang.System // that is of type java.io.InputStream onto the stack // getstatic Ljava/lang/System; in Ljava/io/InputStream; // 1 1 // // Call initializer method // invokespecial Ljava/io/DataInputStream; (Ljava/io/InputStream;)V // 1 // // Read Line // invokevirtual Ljava/io/DataInputStream; ()Ljava/lang/String; readLine // 1 // iconst_0 istore_2 LOOP : dup aload_0 dup arraylength iload_2 if_icmple FINLOOP iload_2 aaload invokevirtual Ljava/lang/Object; (Ljava/lang/Object;)Z equals ifne TROUVE iinc 2 1 goto LOOP FINLOOP : pop2 return TROUVE : pop aload_1 ldc "Trouver" invokevirtual Ljava/io/PrintStream; (Ljava/lang/String;)V println // return