Date : Sun, 08 Apr 1984 14:00:25-MST
From : Keith Petersen <KPETERSEN@SIMTEL20.ARPA>
Subject: Dave Rand: question about returning to CCP
Dave Rand, the author of NSWP2, left this file on the SYSOP RCPM.
Replies to me, if you like, and I'll relay to Dave.
--Keith
----
Dave Rand
10232 - 160 Street
Edmonton, Alberta Canada
T5P 3E9
(403) 484-4114
03/21/84
A few days ago, I had a call from a mildly irate user of NSWP2. He claimed
that NSWP failed on the 'X' command, and proceeded to tell me why. I can
find no reason behind his logic, so here it is... if someone has an
idea, PLEASE let me know!
In NSWP, I don't jump to zero when I exit. Instead, I do what amounts to a
return to the CCP. The actual code involved goes like this...
XTHL ;get contents of (SP) into HL
SHLD CCPRET+1 ;save it as part of a JMP instruction
LXI SP,STACK ;and move stack local
later on, when I want to return to CP/M, I use:
CCPRET: JMP 0000h ;to be filled in
The users' system was a heavily modified CPM 2.2 system, that included
bank selected memory. He says, however, that had I have done things
'correctly', I should have used the following code:
lxi h,0 ;offset zero
dad sp ;from stack pointer
shld CCPSTK+1 ;and save old stack address
LXI SP,STACK ;and move stack local
and to return to the CCP:
CCPSTK: lxi SP,0 ;to be filled in
ret ;get back!
Now... You know, and I know, that JMPing to the address on the top of the
stack is EXACTLY the same as RET'ing, except that I don't preserve the stack.
But DR's CCP, along with all CCP replacements, ALWAYS use the code:
CALL 100h ;execute transient program
LXI SP,LOCS ;restore stack, in case we get back.
except for CPM 3.0, which uses
LXI H,0 ;return address of warm boot!
push h
jmp 100h ;execute transient
What I think, is that his CCP (which has been modified by him), DOES NOT
do the LXI SP. However, I am open to suggestions. By the way, he is the
ONLY user (from the 50 or so that have contacted me) that has reported this
problem.
I am mystified. He claims that the LXI SP is there. If that is the case
(which I don't believe), magic must be occuring. If anyone can explain
to me the difference between the JMP and the RET, I would forever be in
your debt!
Thanks in advance... Dave Rand