You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Compiler construction 2011
I get an error:
"Unable to pop operand of an empty stack"
This is my generated code:
.method public static main()I
.limit locals 2
.limit stack 4
iconst_2
istore 0
iconst_5
istore 1
lab0:
iconst_1 //Push on constant on the stack
iload 0 //loads an item, stack = 2 now
iconst_0 //push constant on stack, stack = 3
if_icmpgt lab2 //Compares, pops the 2 topmost items so one
should be left on the stack
pop //At this point there should be one item
left on the stack bur apparently there isn't
iconst_0
lab2:
if_icmplt lab1
iload 1
iload 0
imul
istore 1
iinc 0 -1
goto lab0
lab1:
iconst_0
ireturn
.end method
Rasmus Knutsson
unread,
Apr 15, 2011, 4:54:49 AM4/15/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Compiler construction 2011
As far as I understand it, if_icmpgt will pop the stack whether it
jumps or not. You seem to assume it doesn't pop if it doesn't jump.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Compiler construction 2011
No thats not it, I push 3 items onto the stack if_icmpgt pops two of
them so there should be one item left on the stack when pop is called
or am I wrong?
Maria Lemon Sjölander
unread,
Apr 15, 2011, 5:06:12 AM4/15/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Compiler construction 2011
I spotted the error, when jumping to lab2 I only have one item on the
stack when if_icmplt lab1 expects two.