December 2nd, 2008, 04:57 PM
TASM help needed! returning from a FAR CALL
I have this problem that i cannot manage to solve.
I had to write a program that reads hex symbols (a set of simple commands, like mov dx, 1234h) from the entered input file (in PSP). It's all ok, i have opened the file, read the commands, stored them in a var in dseg. Now i have to jump to these commands, execute them and give the control back to the original CS:IP. So anyway, as i read in some forums, i defined a var:
pfnFarCall db 0F3h,05h,0E9h,05Ah
and executed it:
call dword ptr [pfnFarCall]
and the following code in data segment is:
BA 34 12 C3
(mov dx, 1234h)
now the CS:IP are in the stack. It's all fine, the simple command (mov dx, 1234h) is done, but i have to go back into the code segment. Ret seems to work fine, but it doesn't return to the right place. The CS:IP before the call were 5AF9:0103 ant in stack they were 5AF9:0107 (return address of the instruction after call). So anyway, when the ret from the data segment is done, the control is given to a wrong spot. CS = 5AE9, IP = 0107. This is what's bothering me, because i have to go to CS = 5AF9, IP = 0107.
please, help me!!!
Tags for this Thread
Click Here to Expand Forum to Full Width