Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!we13!ihnp4!zehntel!dual!amd70!fortune!hpda!hplabs!sri-unix!KPETERSEN@SIMTEL20.ARPA From: KPETERSEN@SIMTEL20.ARPA Newsgroups: net.micro.cpm Subject: Dave Rand: question about returning to CCP Message-ID: <12084@sri-arpa.UUCP> Date: Sun, 8-Apr-84 16:00:25 EST Article-I.D.: sri-arpa.12084 Posted: Sun Apr 8 16:00:25 1984 Date-Received: Sat, 28-Apr-84 09:29:52 EST Lines: 72 From: Keith Petersen 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 -------