Timeline for How do I properly exit a program and return to the CCP in CP/M?
Current License: CC BY-SA 4.0
19 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 11 at 11:15 | comment | added | dgnuff |
Just for the sake of completeness, calling / jumping to BDOS (0005h) with C containing zero will also do a warm restart. Not that it was used a lot, since JMP 0 or RST 0 are only one instruction vs the two needed for the BDOS method. Citation: seasip.info/Cpm/bdos.html
|
|
Apr 9 at 17:40 | vote | accept | cjs | ||
Apr 9 at 13:20 | history | edited | tofro | CC BY-SA 4.0 |
added 28 characters in body
|
Apr 9 at 11:38 | comment | added | tofro | @Raffzahn Disagree with "not recommended by DR" - Some DR example programs do exactly that, and the manuals point out the preconditions you have to meet. | |
Apr 9 at 11:36 | comment | added | tofro | @Raffzahn While we're nit-picking: No, a RST 0 isn't necessarily the same thing as pressing the RESET button - It does execute the same code, yes, but a hardware reset may do a lot more things than that (I'm assuming that's what your "(usually)" meant to say). | |
Apr 9 at 11:35 | comment | added | Raffzahn | @tofro Possible manual page to add. Well, the question is asked about something well known to any CP/M programmer by someone who seems to have knowledge (and able to read), so it's setup for getting a wiki like answer :)) Also, the last one isn't about what one can do, but explaining the elegance of using RST 0 to always produce a stable system. Last, while there is a return address in the 32 bytes of CCP provided stack, RETurning is not recommended by DR. | |
Apr 9 at 11:26 | history | edited | tofro | CC BY-SA 4.0 |
added 79 characters in body
|
Apr 9 at 11:22 | comment | added | tofro | @Raffzahn I was actually assuming that anyone who can write CP/M programs would know that ;) I was also assuming that any such person would be aware that JMP 0 actually wastes memory ;) And I don't quite agree with your last sentence: Of course RST 0 presents you with a guaranteed clean state, but at the cost of a disk access - That you can avoid by simply returning to the CCP. Well, if you're program makes a mess of the system, you're probably better off with a RST 0... | |
Apr 9 at 11:18 | comment | added | Raffzahn | For the first part it might be useful to point out that RST 0 and JMP 0 execute both the same code as both jump to address 0 (as does PCHL with HL=0, have seen that as well). In addition the same is reached (usually) by pressing RESET as that also starts execution a 0. (might be complicated by computer structure). After all, it's the whole idea of using the reset vector to support recovery (warmstart) in as many situation as possible. | |
Apr 9 at 11:17 | history | edited | tofro | CC BY-SA 4.0 |
added 84 characters in body
|
Apr 9 at 11:11 | history | edited | tofro | CC BY-SA 4.0 |
added 20 characters in body
|
Apr 9 at 11:04 | history | edited | tofro | CC BY-SA 4.0 |
added 219 characters in body
|
Apr 9 at 10:57 | comment | added | tofro | But generally, if you only use a few bytes of stack (CP/M does indeed guarantee 7 * 2 bytes and does guarantee that it won't use that stack in system calls) and your program is reasonably small, there shouldn't be problem doing that. | |
Apr 9 at 10:54 | comment | added | tofro | Actually, CP/M doesn't "give" any stack to transient programs - They have to set it up themselves in the TPA. For small utilities, you might get away with re-using a few bytes from the CCP's stack, but it can't be a lot. All of DR example programs set up their own stack and so should yours. You have the choice of restoring the CCP stack and return as pointed out above, but that's it. Also, there isn't a "standard" memory size below CCP - There are a lot of 3PP CPPs, and resident utilities that go between BDOS/BIOS and the CCP, so there really is no rule of thumb. But 8-10k should really be OK | |
Apr 9 at 10:43 | comment | added | cjs |
Presumably very small utilities with that know they won't overflow the original stack or overwrite the CCP could simply just ret at the end of the program, then, right? How big and where is the stack that CP/M 2.2 gives to user programs, and where does the CCP start small (24K?) and "regular sized" (64K) CP/M systems?
|
|
Apr 9 at 10:11 | history | edited | tofro | CC BY-SA 4.0 |
added 221 characters in body
|
Apr 9 at 10:05 | history | edited | tofro | CC BY-SA 4.0 |
added 221 characters in body
|
Apr 9 at 9:55 | history | edited | tofro | CC BY-SA 4.0 |
added 221 characters in body
|
Apr 9 at 9:48 | history | answered | tofro | CC BY-SA 4.0 |