-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprintStringInts.j
46 lines (33 loc) · 1.06 KB
/
printStringInts.j
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
.class public printStringInts
.super java/lang/Object
; standard initializer
; default constructor
.method public <init>()V
aload_0
invokespecial java/lang/Object/<init>()V
return
.end method
.method public static main([Ljava/lang/String;)V
; allocate stack big enough to hold 2 items
.limit stack 3
.limit locals 2
; push string to be printed
ldc "Hello World!"
astore 0 ; astore for strings
ldc 42
istore 1 ; istore for ints
; push java.lang.System.out (type PrintStream)
; getstatic modifies the stack. Be aware.
getstatic java/lang/System/out Ljava/io/PrintStream;
aload 0 ; 0 top of stack
; invoke println
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V ; string print
; push java.lang.System.out (type PrintStream)
; getstatic modifies the stack. Be aware.
getstatic java/lang/System/out Ljava/io/PrintStream;
iload 1 ; 1 bottom of stack but at top after print
; invoke println
invokevirtual java/io/PrintStream/println(I)V ; int print
; terminate main
return
.end method