Subversion Repositories SvarDOS

Rev

Rev 491 | Rev 494 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 491 Rev 493
Line 20... Line 20...
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
 * DEALINGS IN THE SOFTWARE.
22
 * DEALINGS IN THE SOFTWARE.
23
 */
23
 */
24
 
24
 
25
/*
-
 
26
 * SvarCOM is a command-line interpreter.
-
 
27
 *
-
 
28
 * a little memory area is allocated as high as possible. it contains:
-
 
29
 *  - a signature (like XMS drivers do)
-
 
30
 *  - a routine for exec'ing programs
-
 
31
 *  - a "last command" buffer for input history
-
 
32
 *
-
 
33
 * when svarcom starts, it tries locating the routine in memory.
-
 
34
 *
-
 
35
 * if found:
-
 
36
 *   waits for user input and processes it. if execing something is required, set the "next exec" field in routine's memory and quit.
-
 
37
 *
-
 
38
 * if not found:
-
 
39
 *   installs it by creating a new PSP, set int 22 vector to the routine, set my "parent PSP" to the routine
-
 
40
 *   and quit.
-
 
41
 *
-
 
42
 * PSP structure
-
 
43
 * http://www.piclist.com/techref/dos/psps.htm
-
 
44
 *
-
 
45
 *
-
 
46
 *
-
 
47
 * === MCB ===
-
 
48
 *
-
 
49
 * each time that DOS allocates memory, it prefixes the allocated memory with
-
 
50
 * a 16-bytes structure called a "Memory Control Block" (MCB). This control
-
 
51
 * block has the following structure:
-
 
52
 *
-
 
53
 * Offset  Size     Description
-
 
54
 *   00h   byte     'M' =  non-last member of the MCB chain
-
 
55
 *                  'Z' = indicates last entry in MCB chain
-
 
56
 *                  other values cause "Memory Allocation Failure" on exit
-
 
57
 *   01h   word     PSP segment address of the owner (Process Id)
-
 
58
 *                  possible values:
-
 
59
 *                    0 = free
-
 
60
 *                    8 = Allocated by DOS before first user pgm loaded
-
 
61
 *                    other = Process Id/PSP segment address of owner
-
 
62
 *   03h  word      number of paragraphs related to this MCB (excluding MCB)
-
 
63
 *   05h  11 bytes  reserved
-
 
64
 *   10h  ...       start of actual allocated memory block
-
 
65
 */
-
 
66
 
-
 
67
#include <i86.h>
25
#include <i86.h>
68
#include <dos.h>
26
#include <dos.h>
69
#include <stdio.h>
27
#include <stdio.h>
70
#include <stdlib.h>
28
#include <stdlib.h>
71
#include <string.h>
29
#include <string.h>