jasmine

3 views
Skip to first unread message

animesh biswas

unread,
Mar 30, 2011, 5:34:46 AM3/30/11
to compiler-cons...@googlegroups.com
Hi,
i have some confusions regarding instruction sets.

I want to add all integer type value  using ldc and all double type value using ldc2_w in stack.

But i am confused about arithmetic operation instruction sets regarding double type.
Because there are various option regarding one word and two word double.For example ldc2_w adds 2 word in stack .
But corresponding operation like dcmpg does not say that it process two word or one word.
I am planning to use ldc and iadd,imul,idiv etc for int.I have done exercise in PLT course.For integer my compiler seems works.
Would you please tell me which instructions will be suitable for double.
 
Animesh

Björn von Sydow

unread,
Mar 30, 2011, 6:02:13 AM3/30/11
to compiler-cons...@googlegroups.com
Hi,

you can certainly push constants using the two instructions you mention. Your code will be a little bigger than necessary, but that is a minor thing. You need to use ldc2_w for doubles, since they have size two words.

As regards the dcmp<op> instructions, there is really no confusion. You can look at the descriptions of the operators in Chapter 6 of The Java Virtual Machine Specification to see the specified behaviour. You find this linked from the Resources page on the course web site or by following this link:

http://java.sun.com/docs/books/jvms/second_edition/html/VMSpecTOC.doc.html

Note the convenient alphabetic index of instructions at the top of the Chapter 6 page.

Best regards

Björn

Reply all
Reply to author
Forward
0 new messages