summaryrefslogtreecommitdiff
path: root/msdos/README.msdos
blob: 3a5c38fcaeb6a9851901420b3f372a01bcd99201 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
		   Notes on the MS-DOS Perl port

			Diomidis Spinellis
			 (dds@cc.ic.ac.uk)

[0. First copy the files in the msdos directory into the parent
directory--law]

1.  Compiling.

     Perl has been compiled under MS-DOS using the Microsoft
C  compiler  version 5.1.  Before compiling install dir.h as
<sys/dir.h>.  You will need a Unix-like make  program  (e.g.
pdmake) and something like yacc (e.g. bison).  You could get
away by running yacc and dry running make on  a  Unix  host,
but  I  haven't tried it.  Compilation takes 12 minutes on a
20MHz 386 machine (together with formating the  manual),  so
you  will probably need something to do in the meantime. The
executable is 272k and the top level directory needs 1M  for
sources  and  about the same ammount for the object code and
the executables.

     The makefile will compile glob for you which  you  will
need  to  place somewhere in your path so that perl globbing
will work correctly.  I have not tried all the tests or  the
examples,  nor the awk and sed to Perl translators.  You are
on your own with them.  In the eg directory I have  included
an  example  program  that uses ioctl to display the charac-
teristics of the storage devices of the system.

2.  Using MS-DOS Perl

     The MS-DOS version of perl has most of the  functional-
ity of the Unix version.  Functions that can not be provided
under  MS-DOS  like  sockets,  password  and  host  database
access,  fork  and wait have been ommited and will terminate
with a fatal error.  Care has been taken  to  implement  the
rest.   In particular directory access, redirection (includ-
ing pipes, but excluding the pipe function),  system,  ioctl
and sleep have been provided.

[Files currently can be edited in-place provided you are cre-
ating  a  backup.   However, if the backup coincidentally has 
the same name as the original, or  if  the  resulting  backup 
filename  is invalid, then the file will probably be trashed.
For example, don't do

	perl -i~ script makefile
	perl -i.bak script file.dat

because  (1)  MS-DOS treats "makefile~" and "makefile" as the
same filename, and (2) "file.dat.bak" is an invalid filename.
The  files  "makefile"  and  "file.dat" will probably be lost 
forever.  Moral of the story:   Don't  use  in-place  editing 
under MS-DOS. --rjc]

2.1.  Interface to the MS-DOS ioctl system call.

     The function code of the  ioctl  function  (the  second
argument) is encoded as follows:

- The lowest nibble of the function code goes to AL.
- The two middle nibbles go to CL.
- The high nibble goes to CH.

     The return code is -1 in the case of an  error  and  if
successful:

- for functions AL = 00, 09, 0a the value of the register DX
- for functions AL = 02 - 08, 0e the value of the register AX
- for functions AL = 01, 0b - 0f the number 0.

     See the perl manual for instruction on how  to  distin-
guish between the return value and the success of ioctl.

     Some ioctl functions need a number as the  first  argu-
ment.   Provided  that  no  other files have been opened the
number  can  be   obtained   if   ioctl   is   called   with
@fdnum[number]  as  the  first  argument after executing the
following code:

        @fdnum = ("STDIN", "STDOUT", "STDERR");
        $maxdrives = 15;
        for ($i = 3; $i < $maxdrives; $i++) {
                open("FD$i", "nul");
                @fdnum[$i - 1] = "FD$i";
        }

2.2.  Binary file access

     Files are opened in text mode by default.   This  means
that  CR LF pairs are translated to LF.  If binary access is
needed the `binary'  function  should  be  used.   There  is
currently  no  way to reverse the effect of the binary func-
tion.  If that is needed close and reopen the file.

2.3.  Interpreter startup.

     The effect of the Unix #!/bin/perl interpreter  startup
can  be  obtained  under  MS-DOS by giving the script a .bat
extension and using the following lines on its begining:

        @REM=("
        @perl %0.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
        @end ") if 0 ;

(Note that you will probably want an absolute path name in
front of %0.bat).

				March 1990

				Diomidis Spinellis <dds@cc.ic.ac.uk>
				Myrsinis 1
				GR-145 62 Kifissia
				Greece

--------------------------------------------------------------------------

	Revisions to the MS-DOS support in Perl 4.0
	Tom Dinger, 18 March 1991

The DOS compatibility added to Perl sometime in release 3.x was not
maintained, and Perl as distributed could not be built without changes.

Both myself and Len Reed more or less "rediscovered" how to get Perl built
and running reliably for MS-DOS, using the Microsoft C compiler.  He and I
have communicated, and will be putting together additional patches for the
DOS version of Perl.

1. Compiling Perl

    For now, I have not supplied a makefile, as there is no standard for
    make utilities under DOS.  All the files can be compiled with Microsoft
    C 5.1, using the switches "-AL -Ox" for Large memory model, maximum
    optimization (this turned out a few code generation bugs in MSC 5.1).
    The code will also compile with MSC 6.00A, with the optimization
    "-Oacegils /Gs" for all files (regcomp.c has special case code to change
    the aliasing optimizations).

    Generally, you follow the instructions given above to compile and build
    Perl 4.0 for DOS.  I used the output of SunOS yacc run on perly.y,
    without modification, but I expect both Bison and Berkeley-YACC will work
    also.  From inspection of the generated code, however, I believe AT&T
    derived YACC produces the smallest tables, i.e. uses the least memory.
    This is important for a 300K executable file.

2. Editing in-place.

    You will need the file suffix.c from the os2 subdirectory -- it will
    create a backup file with much less danger for DOS.

3. A "Smarter" chdir() function.

    I have added to the DOS version of Perl 4.0 a replacement chdir()
    function.  Unlike the "normal" behavior, it is aware of drive letters
    at the start of paths for DOS.  So for example:

    perl_chdir( "B:" )      changes to the default directory, on drive B:
    perl_chdir( "C:\FOO" )  changes to the specified directory, on drive C:
    perl_chdir( "\BAR" )    changes to the specified directory on the
                            current drive.

4. *.BAT Scripts as Perl scripts

    The strategy described above for turning a Perl script into a *.BAT
    script do not work.  I have been using the following lines at the
    beginning of a Perl *.BAT script:

        @REM=(qq!
        @perl -S %0.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
        @goto end !) if 0 ;

    and the following at the end of the *.BAT script:

        @REM=(qq!
        :end !) if 0 ;

    If you like, with the proper editor you can replace the four '!'
    characters with some untypeable character, such as Ctrl-A.  This will
    allow you to pass any characters, including ".." strings as arguments.

4. Things to Come

     *  Better temporary file handling.
     *  A real Makefile -- Len Reed has one for Dmake 3.6
     *  Swapping code -- swaps most of Perl out of memory (to EMS, XMS or
	disk) before running a sub-program or pipe.
     *	MKS command line support, both into Perl, and to other programs
	spawned by Perl.
     *	Smarter pipe functions, not using COMMAND.COM.


					Tom Dinger
					tdinger@East.Sun.COM
					Martch 18, 1991