Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Selection of Basic JVM Instructions In the description of actions, stack and variable area refer to the operand stack and the variable area, respectively, in

image text in transcribedimage text in transcribed

Selection of Basic JVM Instructions In the description of actions, "stack" and "variable area" refer to the operand stack and the variable area, respectively, in the top runtime stack frame. push value onto operand stack o iconst_k (Osk s5): push int constant k onto stack o iload_k (Osks 3): push value at address k in variable area onto stack obipush k: push byte int constant k onto stack o iload k: push value at address k in variable area onto stack For long, float, double types, replace prefix "i" by "1", "f", "d", respectively (except for bipush). pop from operand stack o istore_k (0 sk s 3): pop stack and store into address k in variable area o istore k: pop stack and store into address k in variable area For long, float, double types, replace prefix "i" by "1", "f", "d", respectively. arithmetic o iadd, isub, imul, idiv: pop top two values from stack, apply operator to stack[top-1) and stack[top], push result onto stack For long, float, double types, replace prefix "i" by "1", "f", "d", respectively. conditional jump o if_icmpeq k: pop top two int values from stack; if stack[top-1] = stack[top] then go to instruction at address k o if_icmpne k: pop top two int values from stack; if stack[top-1] # stack[top] then go to instruction at address k o if_icmplt k: pop top two int values from stack; if stack[top-1] stack[top] then go to instruction at address k o if_icmpge k: pop top two int values from stack; if stack[top-1] 2 stack[top] then go to instruction at address k unconditional jump o goto k: go to instruction at address k function invocation o invokevirtual #k: invoke instance-level function numbered k o invokestatic #k: invoke static function numbered k function return o return : exit from void-type function o ireturn : pop top int value from stack, push it onto caller's stack, and exit from function call For long, float, double types, replace prefix "i" by "1", "f", "d", respectively. Instructions operating on references have the prefix "a", for example: aconst_null, aload, aload_k (0 sks 3), astore, astore_k (0 sks 3), areturn. Consider the stack-machine instructions ("push y" through "pop to x") to compute the assignment x = y + (z*y)*z in this course note. Translate these instructions into JVM instructions. Presume that x, y, z are integer variables respectively stored at virtual addresses 0, 1, 2 in the variable area. Use instructions listed in the Selection of Basic JVM Instructions in this course note. Selection of Basic JVM Instructions In the description of actions, "stack" and "variable area" refer to the operand stack and the variable area, respectively, in the top runtime stack frame. push value onto operand stack o iconst_k (Osk s5): push int constant k onto stack o iload_k (Osks 3): push value at address k in variable area onto stack obipush k: push byte int constant k onto stack o iload k: push value at address k in variable area onto stack For long, float, double types, replace prefix "i" by "1", "f", "d", respectively (except for bipush). pop from operand stack o istore_k (0 sk s 3): pop stack and store into address k in variable area o istore k: pop stack and store into address k in variable area For long, float, double types, replace prefix "i" by "1", "f", "d", respectively. arithmetic o iadd, isub, imul, idiv: pop top two values from stack, apply operator to stack[top-1) and stack[top], push result onto stack For long, float, double types, replace prefix "i" by "1", "f", "d", respectively. conditional jump o if_icmpeq k: pop top two int values from stack; if stack[top-1] = stack[top] then go to instruction at address k o if_icmpne k: pop top two int values from stack; if stack[top-1] # stack[top] then go to instruction at address k o if_icmplt k: pop top two int values from stack; if stack[top-1] stack[top] then go to instruction at address k o if_icmpge k: pop top two int values from stack; if stack[top-1] 2 stack[top] then go to instruction at address k unconditional jump o goto k: go to instruction at address k function invocation o invokevirtual #k: invoke instance-level function numbered k o invokestatic #k: invoke static function numbered k function return o return : exit from void-type function o ireturn : pop top int value from stack, push it onto caller's stack, and exit from function call For long, float, double types, replace prefix "i" by "1", "f", "d", respectively. Instructions operating on references have the prefix "a", for example: aconst_null, aload, aload_k (0 sks 3), astore, astore_k (0 sks 3), areturn. Consider the stack-machine instructions ("push y" through "pop to x") to compute the assignment x = y + (z*y)*z in this course note. Translate these instructions into JVM instructions. Presume that x, y, z are integer variables respectively stored at virtual addresses 0, 1, 2 in the variable area. Use instructions listed in the Selection of Basic JVM Instructions in this course

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine Ricardo

2nd Edition

1449606008, 978-1449606008

More Books

Students also viewed these Databases questions

Question

How will your strategy receive approval?

Answered: 1 week ago