I got told to try and use 'jmp rather than 'call', but 'jmp' is not liking me .. when I jump it doesn't return (so it never exits and not happy days ), but calling returns and exits as normal.
I am happy using 'call' but is there actually a reason I should try and overcome 'jmp' ?
This simple code just shows if when I jmp
it never returns and exits.
_start:
jmp _Print
jmp _Exit
ret
_Exit:
; normal exit
ret
_Print
; print something
ret
also .. I'm running this all in a Linux terminal if that changes anything.
ret
, a bogus return address gets popped off the stack and your code jumps to it. You can fake acall
with ajmp
but prior to doing jmp you must push the return address on the stack yourself. What assembler and what OS are you targeting? 16 or 32 bit? – PastramiJMP
instead, except to be done in school to teach you how aCALL
andRET
function together by simulating theCALL
withJMP
. It will also teach you something about the stack – PastramiCALL
andRET
are designed to build and tear down the stack depending on your calling convention. So by usingJMP
you don't build the stack appropriately. aJMP
is more for loops or continuation of code elsewhere. In other words. aCALL
is aJMP
with the added feature of pushing the next instruction address onto the stack. – Antediluvian