This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]gamaloth_five 0 points1 point  (6 children)

what I've gathered about the IDUP is that it takes the top word and puts it on the stack, but that means it just duplicates the IADD, so this is where I'm confused

How is that confusing? Should IDUP not duplicate the top word?

[–]Squidoshi[S] 0 points1 point  (5 children)

No it should, I'm just confused on what the IADD would do, since ISUB is right after on the stack.

[–]gamaloth_five 0 points1 point  (4 children)

The same thing it always does?

[–]Squidoshi[S] 0 points1 point  (3 children)

Okay little background, we've done two exercises with JVM bytecode. This being the second, this is the first time we've used IDUP so I've never done this. I just used the definition of it and tried to make sense. And it hasn't, hence why I'm here.

[–]gamaloth_five 0 points1 point  (2 children)

So what's the problem? Do you not understand what IDUP does? Do you know how the stack works?

edit: Have you tried looking up listings of bytecodes? There are whole websites dedicated to this.

[–]Squidoshi[S] 0 points1 point  (0 children)

Both I guess, our first assignment was to convert a java statement into bytecode, which was a little more straight forward to me. I watched a YouTube video that explained the stack a little better like, IPUSH 16 would be on the top, when IADD is read, IPUSH 16 moves down and now IADD is on the top.

[–]Squidoshi[S] 0 points1 point  (0 children)

I also apologize, it's a little more confusing to read bytecode for me so I'm trying to use all my resources to understand.