Assembly: Why does jumping to a label that returns via ret cause a segmentation fault?
Posted
by
Terribad
on Stack Overflow
See other posts from Stack Overflow
or by Terribad
Published on 2012-03-23T23:22:34Z
Indexed on
2012/03/23
23:29 UTC
Read the original article
Hit count: 181
Linux Assembly Tutorial states:
there is one very important thing to remember: If you are planning to return from a procedure (with the RET instruction), don't jump to it! As in "never!" Doing that will cause a segmentation fault on Linux (which is OK – all your program does is terminate), but in DOS it may blow up in your face with various degrees of terribleness.
But I cannot understand why does it causes a segmentation fault. it sounds just like returning from a function.
I have a situation where I need to implement the logic "If X happens, call procedure A. Otherwise, call procedure B." Is there any other way than jumping around like a kangaroo weaving spaghetti code?
© Stack Overflow or respective owner