|
|
|
Virtual Machines
Exercises
Translate by hand the following class into
Java Virtual Machine code (can you improve on the code created by SJC?):
public class HandTranslate {
static int x;
... main method elided ...
static int testandset(int n)
{
int result;
int i;
if (n > x) x = n;
i = 0;
while (i < n)
{
result = x * x;
}
return result;
}
}
Reading
- Dragon Chapter 6.2,7.1-7.2,7.4
- ASM documentation (see Resources in the left pane)
- JVM spec (see Resources in the left pane)
Materials
Virtual Machines, the JVM and ASM
|