All pastes #273751 Raw Edit

Untitled

public text v1 · immutable
·published 2006-12-10 03:01 UTC
rendered paste body
.class public oneplusone
.super java/lang/Object
.method public <init>()V
	aload_0
	invokespecial java/lang/Object/<init>()V
	return
.end method
.method public static main([Ljava/lang/String;)V
	.limit stack 5
	.limit locals 100
	ldc 0
	istore 1 ; int a
	
	ldc 0
	istore 2 ; int b
	
	ldc 0
	istore 3 ; boolean c (note that booleans are encoded as 0 or 1, the JVM has no boolean type)
	
	ldc 42
	istore 1 ; a = 42
	
	ldc 2
	iload 1
	iadd
	istore 2 ; b = a + 2 (b = 44, a = 42)
	
	ldc 1
	iload 2
	iadd
	iload 1
	iadd
	istore 1 ; a = (a+(b+1)) ; (b = 44, a = 87)
	
	iload 2
	iload 1 ; a
	ldc 3 ; 3
	iadd ; This is the (3+a)
	if_icmplt Lessthan ; Jump to the LessThan bit
	ldc 0
	istore 3
	goto Continue
Lessthan:
	ldc 1
	istore 3
	goto Continue
	

Continue:

	goto L2 ; Start of the while loop stuff
L1:
	iload 2
	ldc 2
	iadd
	istore 2 ; b = b + 2
	goto L2 ; Jump to the condition
L2:
	iload 2
	iload 1
	if_icmplt L1 ; Jump into the body of the loop if condition is true. Otherwise, this will just carry on to printing stuff out.
	
	
	iload 3
	ldc 0
	if_icmpeq L1i ; if (c) (Actually says if (c==1))
	
	iload 2
	istore 1 ; a = b, body of the if
	
	goto L2i ; Jump to after the end of the else
L1i:
	goto L2i ; No statements in the "else" block here
L2i:

	
	iload 1 ; put a on the stack ready for printing out
	getstatic java/lang/System/out Ljava/io/PrintStream;
	swap
	invokevirtual java/io/PrintStream/println(I)V ; print a
	
	iload 2 ; put b on the stack ready for printing out
	getstatic java/lang/System/out Ljava/io/PrintStream;
	swap
	invokevirtual java/io/PrintStream/println(I)V ; print b

	iload 3 ; put c on the stack ready for printing out
	getstatic java/lang/System/out Ljava/io/PrintStream;
	swap
	invokevirtual java/io/PrintStream/println(I)V ; print c

	return
.end method