-
Notifications
You must be signed in to change notification settings - Fork 0
/
newton1.j
executable file
·212 lines (188 loc) · 3.24 KB
/
newton1.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
.class public newton1
.super java/lang/Object
.field private static _runTimer LRunTimer;
.field private static _standardIn LPascalTextIn;
.field private static number I
.method public <init>()V
aload_0
invokenonvirtual java/lang/Object/<init>()V
return
.limit locals 1
.limit stack 1
.end method
.method private static root(F)F
.var 1 is r F
.var 0 is x F
.var 2 is root F
.line 17
fconst_1
fstore_1
.line 19
fload_0
fload_1
fdiv
fload_1
fadd
iconst_2
i2f
fdiv
fstore_1
.line 20
fload_0
fload_1
fdiv
fload_1
fadd
iconst_2
i2f
fdiv
fstore_1
.line 21
fload_0
fload_1
fdiv
fload_1
fadd
iconst_2
i2f
fdiv
fstore_1
.line 22
fload_0
fload_1
fdiv
fload_1
fadd
iconst_2
i2f
fdiv
fstore_1
.line 23
fload_0
fload_1
fdiv
fload_1
fadd
iconst_2
i2f
fdiv
fstore_1
.line 24
fload_0
fload_1
fdiv
fload_1
fadd
iconst_2
i2f
fdiv
fstore_1
.line 25
fload_0
fload_1
fdiv
fload_1
fadd
iconst_2
i2f
fdiv
fstore_1
.line 26
fload_0
fload_1
fdiv
fload_1
fadd
iconst_2
i2f
fdiv
fstore_1
.line 28
fload_1
fstore_2
fload_2
freturn
.limit locals 3
.limit stack 2
.end method
.method private static print(IF)V
.var 0 is n I
.var 1 is root F
.line 33
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "The square root of %4d is %8.4f\n"
iconst_2
anewarray java/lang/Object
dup
iconst_0
iload_0
invokestatic java/lang/Integer.valueOf(I)Ljava/lang/Integer;
aastore
dup
iconst_1
fload_1
invokestatic java/lang/Float.valueOf(F)Ljava/lang/Float;
aastore
invokestatic java/lang/String/format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
invokevirtual java/io/PrintStream.print(Ljava/lang/String;)V
return
.limit locals 2
.limit stack 7
.end method
.method public static main([Ljava/lang/String;)V
new RunTimer
dup
invokenonvirtual RunTimer/<init>()V
putstatic newton1/_runTimer LRunTimer;
new PascalTextIn
dup
invokenonvirtual PascalTextIn/<init>()V
putstatic newton1/_standardIn LPascalTextIn;
.line 37
getstatic java/lang/System/out Ljava/io/PrintStream;
invokevirtual java/io/PrintStream.println()V
.line 38
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "Enter a new number: "
invokevirtual java/io/PrintStream.print(Ljava/lang/String;)V
.line 39
getstatic newton1/_standardIn LPascalTextIn;
invokevirtual PascalTextIn.readInteger()I
dup
iconst_0
sipush 32767
invokestatic RangeChecker/check(III)V
putstatic newton1/number I
.line 40
getstatic newton1/number I
getstatic newton1/number I
i2f
invokestatic newton1/root(F)F
invokestatic newton1/print(IF)V
.line 42
getstatic java/lang/System/out Ljava/io/PrintStream;
invokevirtual java/io/PrintStream.println()V
.line 43
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "Enter a new number: "
invokevirtual java/io/PrintStream.print(Ljava/lang/String;)V
.line 44
getstatic newton1/_standardIn LPascalTextIn;
invokevirtual PascalTextIn.readInteger()I
dup
iconst_0
sipush 32767
invokestatic RangeChecker/check(III)V
putstatic newton1/number I
.line 45
getstatic newton1/number I
getstatic newton1/number I
i2f
invokestatic newton1/root(F)F
invokestatic newton1/print(IF)V
getstatic newton1/_runTimer LRunTimer;
invokevirtual RunTimer.printElapsedTime()V
return
.limit locals 1
.limit stack 4
.end method