[Asm2class-usage] [asm2class - asm2class usage] RE: Example of java assembly source
Status: Beta
Brought to you by:
boretti
From: SourceForge.net <no...@so...> - 2004-05-19 14:47:26
|
Read and respond to this message at: https://sourceforge.net/forum/message.php?msg_id=2577064 By: nobody // // 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 // // // Solve the hanoi problem // // // Define a class named "org.boretti.asm2class.example.hanoi" // Lorg/boretti/asm2class/example/hanoi; : // // Define the number of disk to use // - . $ START I 4 // // Define a method named "main" with String [] as parameter and no // return value. This method is public and static // * . main ([Ljava/lang/String;)V : getstatic Lorg/boretti/asm2class/example/hanoi; START I iconst_0 iconst_1 iconst_2 invokestatic Lorg/boretti/asm2class/example/hanoi; (IIII)V hanoi return // // Define how to translate disks // 0:Nombre // 1:From // 2:To // 3:Inter // * . hanoi(IIII)V : iload_0 lookupswitch DEFAULT 0 : CASE0 1 : CASE1 2 : CASE2 CASE1 : iload_1 iload_2 invokestatic Lorg/boretti/asm2class/example/hanoi; (II)V translate goto CASE0 CASE2 : iload_1 iload_3 invokestatic Lorg/boretti/asm2class/example/hanoi; (II)V translate iload_1 iload_2 invokestatic Lorg/boretti/asm2class/example/hanoi; (II)V translate iload_3 iload_2 invokestatic Lorg/boretti/asm2class/example/hanoi; (II)V translate goto CASE0 DEFAULT : iload_0 iconst_m1 iadd dup istore 4 iload_1 iload_3 iload_2 invokestatic Lorg/boretti/asm2class/example/hanoi; (IIII)V hanoi iload_1 iload_2 invokestatic Lorg/boretti/asm2class/example/hanoi; (II)V translate iload 4 iload_3 iload_2 iload_1 invokestatic Lorg/boretti/asm2class/example/hanoi; (IIII)V hanoi CASE0 : return // // Define how to translate a disk // * . translate(II)V : getstatic Ljava/lang/System; out Ljava/io/PrintStream; dup iload_0 iconst_1 iadd invokevirtual Ljava/io/PrintStream; (I)V print dup ldc "->" invokevirtual Ljava/io/PrintStream; (Ljava/lang/String;)V print iload_1 iconst_1 iadd invokevirtual Ljava/io/PrintStream; (I)V println return ______________________________________________________________________ You are receiving this email because you elected to monitor this forum. To stop monitoring this forum, login to SourceForge.net and visit: https://sourceforge.net/forum/unmonitor.php?forum_id=373524 |