better build

This commit is contained in:
Christoph J. Scherr 2023-12-10 16:05:22 +01:00
parent 58cff0bba6
commit 9edefd8877
2 changed files with 24 additions and 9 deletions

View File

@ -8,5 +8,5 @@ else
ls -lah bin/$1.class ls -lah bin/$1.class
echo -e "executing ================================================\n" echo -e "executing ================================================\n"
cd bin cd bin
java $1 java $1 "${@:2}" # the first arg is what java should do, the other are args
fi fi

View File

@ -9,9 +9,10 @@
.method public static factorial(I)I ; calc `given`! .method public static factorial(I)I ; calc `given`!
.limit locals 3 .limit locals 3
.limit stack 5 .limit stack 2
bipush 1 ; ; note that parameters are automatically stored as
istore 0 ; store the parameter `given` ; local variables, we dont need to do `istore 0` to
; store the given integer in a local variable.
bipush 1 ; we start calculating with `p`=1 bipush 1 ; we start calculating with `p`=1
istore 1 ; store `p` istore 1 ; store `p`
bipush 2 ; we start calculating with `j`=1 bipush 2 ; we start calculating with `j`=1
@ -43,11 +44,25 @@
.end method .end method
.method public static main([Ljava/lang/String;)V .method public static main([Ljava/lang/String;)V
.limit locals 1 .limit locals 3
.limit stack 2 .limit stack 4
getstatic java/lang/System/out Ljava/io/PrintStream; ; parse cli args to int
bipush 5 ; set parameter 1 aload 0
aaload 0
invokestatic java/lang/Integer/parseInt(Ljava/lang/String;)I
istore 1
; format
iload 1
ldc "! = "
iload 1
invokestatic Factorial/factorial(I)I ; call factorial invokestatic Factorial/factorial(I)I ; call factorial
invokevirtual java/io/PrintStream/println(I)V invokevirtual java/lang/String/format(ILjava/lang/String;I)I
astore 2
; output
getstatic java/lang/System/out Ljava/io/PrintStream;
aload 2 ; load formatted str
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
return return
.end method .end method