Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

jump statments - behaviour question

Status
Not open for further replies.

NaiLBoMB

Programmer
May 22, 2003
17
0
0
GB
does a jump statement behave like a call statement?
i.e.: if i wrote this;

monkey:
push cx
mov cx, [underfelt]
inc cx
cmp cx, 133
je handbag
mov [underfelt], cx
pop cx
ret
handbag:
mov cx, 0
ret


then if the value of cx was incremented to 133, and the procedure jumped to the handbag function, when it hit the ret command would it return to where it left off in the monkey function? or would i have to include a pop cx and move cx back into the variable in the handbag function?

 
I don't understand what you are trying to do.

The differents between call & jump:
Call -> This instruction push the address into stack, then process the procedure. When the procedure hit RET instruction, it will pop back the address from the stack so it will return to the caller.

Jmp -> jump directly into procedure without pushes the address. When the procedure hit RET instruction, it will pop from the stack and return to anywhere (depends on the value in the stack)

-- AirCon --
 
.. which means you can push an address and then use a jmp to call a subroutine ending in ret. The ret will then "return" to whatever address you pushed. You must of course push the same size of address as the ret/retf is expecting. It wouldn't be sensible to do this with a conditional jump, because then if you don't make the jump, you will be left with an address on the top of the stack.
You can also push an address and then do a ret as a way of executing an indirect jump.
Hope that helps.
btw, not a very tasteful user-name.
 
its not distastful, its a reference to my hairstyle. my girlie says it looks like a nailbomb went off near my head
 
OK! Like! Hope comments on jumps helpful anyway. Good luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top