Assembly 'call' vs 'jmp' -


i got told try , use 'jmp rather 'call', 'jmp' not liking me .. when jump doesn't return (so never exits , not happy days ), calling returns , exits normal.

i happy using 'call' there reason should try , overcome 'jmp' ?

this simple code shows if when 'jmp' never returns , exits.

thankyou in advanced help.

_start:      jmp _print     jmp _exit  ret   _exit:      ; normal exit   ret   _print      ; print  ret 

also .. i'm running in linux terminal if changes anything

well, first of all, jmp 'jumps' label give (which memory address program instructions stored in memory) while call stores location return (below call instruction) in stack, jmp label, , @ ret instruction, jmp location stored (as said above, below call instruction). bit of difference there can see. imho, believe fine call functions, c++ compiler functions, if must jmp, alright then, make sure push return location or create label return once done executing code.

here example of jumping other label when done:

_start:     jmp _print;    _start_label:     jmp _exit;  _exit:  ; exit stuff goes here   ret;       _print:  ;print stuff goes here  jmp _start_label; 

or use call :)


Comments