My favorites | Sign in
Project Home Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Project Information
Members

.class public Contest .super java/lang/Object

; ; Team members: Bianca Cutler ; ; ; ; ; Your assignment is to fill in the fibs method below ; so that it creates (exactly) the output you see in ; fibsgolden.txt ; ; The contest will be won by those entries that compute the ; correct output and whose bytecode files are smallest ; ; For reference, a solution in Java is presented in Fibs.java ; ;

; ; standard initializer ; .method public

<init>
()V
aload_0 invokenonvirtual java/lang/Object/
<init>
()V return
.end method

.method public static fibs()V

; set limits used by this method
.limit locals 7 .limit stack 3

;local variables
;obj getstatic java/lang/System/out Ljava/io/PrintStream; astore_1
;counter for loop bipush 1 istore 2
bipush 1 istore 4 bipush 44 istore 5 bipush 3 istore 6 aload 1 ldc "The fib of 0 is 0" invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V aload 1 ldc "The fib of 1 is 1" invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V aload 1 ldc "The fib of 2 is 1" invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
Loop:
iload 2
iload 4
iadd
iload 4 istore 2 istore 4 iload 4

aload 1 ;push obj
ldc "The fib of "
invokevirtual java/io/PrintStream/print(Ljava/lang/String;)V
iload 6 invokestatic java/lang/String/valueOf(I)Ljava/lang/String; astore 3 aload 1 ;push obj aload 3 ;push string invokevirtual java/io/PrintStream/print(Ljava/lang/String;)V
aload 1 ; push object
ldc " is "
invokevirtual java/io/PrintStream/print(Ljava/lang/String;)V
invokestatic java/lang/String/valueOf(I)Ljava/lang/String; astore 3 ;prints aload 1 ;push obj aload 3 ;push string invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
iinc 5 -1 iinc 6 1
iload 5
ifne Loop
; done return
return .end method

; ; You should not need to change anything below this line. ; .method public static main([Ljava/lang/String;)V

; set limits used by this method .limit locals 1 ; = parameters + locals
invokestatic Contest/fibs()V return
.end method

Powered by Google Project Hosting