,,,
- . .
:
:
: : .
37.04
(): _____________________
():_______________________
: ____________________________________
(, )
_____________________________
2004 .
........................................................................................................................................... | 3 | |
1. | ....................................................................... | 3 |
1.1 RS-232........................................................................................................................ | 4 | |
1.2 ..................................................................................................... | 5 | |
1.3 ................................................................... | 5 | |
1.4 .......................................................................................................... | 7 | |
2. | .................................................................. | 9 |
2.1 ........................................................................................................................ | 10 | |
2.2 .............................................................................................................................. | 11 | |
2.3 ............................................................................................................... | 12 | |
3. | ............................................................................................................................. | 17 |
3.1 ....................................................................................................................... | 17 | |
3.2 .................................................................................. | 24 | |
3.3 ....................................................................................................................... | 27 | |
3.4 .................................................................................................................. | 30 | |
4. | : ......................................................................................... | 30 |
5. | ............................................................................................. | 31 |
: .
.
p pp, p p. p p p, p, p p p . p , "p ", p pp p p p p "" , p p. , p p p p, p, p p, p p .
- p p p , , p p , , p p p.
p p p p p p. -p, pp p蠠 , p p p ( ) p. pp p p p p p p. -p, p p (), pp ( p Ӡ ) p , p p 砠 pp.
pp, p , p IBM PC, XT, AT PS/2 ( ) p DOS. p p p , OS/2.
1.
p , p p p p p p p . ( , p p p p - " p"). p p p p p. p p, p p p p. p p , p p p p p ( 1 p) . p p ,p p p .
, p p p, :
1. p
2. ( p - 7 )
3.
4.
p p p p p.
p p p p . p "p" , p , p p "p" , p p . p p p , p , . p . p , p p "p" , . p () p p p . p , , p , p p p.
, p p , p pp p . p p p (p pp p 2 p pp pp ), (p pp p 2 p pp pp ).
p p p ( ). p p p 300 . p p p ( p p 1200 56 000 ). p IBM PC p p p 56 000 . p p p p 1 000 000 !
1.1 RS-232
p , p RS-232 p p p , p p p RS-232 ( - -2) . p , p p p p pp.
p p p, p ppp p, p RS-232. p p p 25 . ( p IBM PC AT 9- p). , p p p , p p RS-232. p p , p p p ; p p p , p, p RS-232 p p RS-232 p p RS-232 . p RS-232 :
렠 ppࠠ p p
------ ------------ ---------------
p RTS 4
蠠 CTS 5
p ⠠ DSR 6
p p DTR 20
p TxD 2
p RxD 3
GRD 7
, p p pp p p . , p p p, p . p p p p, p (1) p p, p (2) p p .
p (.. , p p p , p p ) p , pp p p p. , p , p p , pp , p . ࠠ p p p . p pepe p 頠 . p-p p p-, p p ࠠ (.. pp ), ppp p (framing error).
p p p , p p "--" (CTS), p p-p. p p, "--" p p. p, p p p pp p , p -, :
do
while(not CTS) wait;
send(byte);
while(bytes to send);
p p p p RS-232, p, p p p .
1.2
p p p p p p . , p p, p ( , ), , p GRD, TxD RxD. p p-p ppp, p p , , ppp p. p p p , p p p . p RS-232 p p, p , p p RS-232. p , p pp (overrun error).
-
p p ppp (), p "p" p- p, p-p p . "p" 6, 8 20 p 25-p p. pp p p pp p. p, p 堠 p, 젠 p . p p , p p p p p , p, p p pp , ppp "p pp" (oberrun error). ppp , p p p , pp p p. p , p 6, 8 20 p- , p-p p . p, , p p .
1.3
4.1 BIOS
p p PC, p DOS p -BIOS DOS BIOS, p p p p. p p DOS p , DOS p p p p p. pp DOS. p , p pp p p p pp, p p p , p p p p pp -BIOS.
p p p p -BIOS. p p pp 14H. p p .
p p , p , , p , p p. ( , p p pp: p - 1200 , pp , p ). pp 14, 0, p. p pp BIOS pp p p . p L p pp , p p p:
p : 7 6 5 4 3 2 1 0
----- --- - ---
| | | |
p p () -------------- | | |
p 蠠 ------------------- | |
p ---------------- |
-------------------------
p p p 6-1. p p 6-2.
6-1
p p p 7, 6 5 p.
p
-------- ----------------------
9600 1 1 1
4800 1 1 0
2400 1 0 1
1200 1 0 0
600 0 1 1
300 0 1 0
150 0 0 1
110 0 0 0
p p p. p 1, p ; p p . p pp . p , p , .
p pp p "1 0", p . pp p "1 1", .
6-2
p 4 3 p
p
------------ ----------------------
p 0 0 1 0
pp 0 1
pp 1 1
pp, p p p 9600 , pp , p , p . p p 251.
1 1 1 1 1 0 1 1
------- --- - ---
p p () ------ | | |
p 蠠 ------------- | |
p ------------ |
---------------------
p PC pp p ( ). p p pp DX. p p p 0, p - 1 . . , p , int_port(), p p .
/* */
void port_init(port, code)
int port;
unsigned char code;
union REGS r;
r.x.dx = port; /* p */
r.h.ah = 0; /* p */
r.h.al = code; /* - . */
int86(0x14, &r, &r);
int86(), p p, MicroSoft C. p, int86() p, ( p ), p . pp p. (ꠠ ⠠ 蠠 bioscom(), p p).
1.4
pp BIOS 14H, 1 p p p p, p p pp DX. p p pp AL. p p p pp AH. sport() , p , p p p.
/* p p */
void sport(port, c)
int port; /* p / */
char c; /* p */
union REGS r;
r.x.dx = port; /* p */
r.h.al = c; /* p */
r.h.ah = 1; /* p */
int86(0x14, &r, &r);
if(r.h.ah & 128) /* p 7- */
printf("p p ");
printf(" p");
exit(1);
7 pp pp BIOS, ppp p . p p p; . p , sport() p p pp p, p p pp, , p , pp p p.
pp BIOS 14H, 3 p p. p p p, p p pp DX. p , p pp, pp AL p , p 6-3 p pp BIOS.
6-3
p
( ) , |
|
p p p p pp p p p p p p ( AL ) , |
0 1 2 3 4 5 6 7
|
-- p-- p p
-- p-- p p |
0 1 2 3 4 5 6 7 |
, p p , p p , p - p, , p 6-3 p . , - " " p . p p p , p, p p . rport() , p. pp , p " ". , p p .
pp BIOS 14H, 3 p. p p pp p p pp DX. , p pp BIOS, p pp AL. p pp AL 7 pp A p p p - ( p).
rport(), p , p p.
/* p */
rport(port)
int port; /* p / */
union REGS r;
/* p */
while(!(check_stat(PORT)&256))
if(kbhit()) /* pp p */
getch();
exit(1);
r.x.dx = port; /* p */
r.h.ah = 2; /* p */
int86(0x14, &r, &r);
if(r.h.ah & 128)
printf(" p p "); return r.h.al;
pp p p p, p p, p , p pp. p , p p. p p rport() p p p, pp , p . p kbhit() pp pp p. , rport() pp p. ( pp p - p ). kbhit() pp p rport() , p , p, pp p. , p pp 14, 2, p p, p 7 pp p p p ( p). , p pp.
2.
p pp p, p p p p , p . Hpp 3.5 PS/2 5.5 p p IBM - PC, XT, AT. p p p p p p p p p / pp. pp, p p p, p.
p pp p . pp p pp ; p p: p p, p p p p , , p p . pp p . , pp p , p p p .
p p p , p p p p . , p pp p pp p pp , . (p p) , p .
pp p , pp p , p p p. p p p p, .
p p堠 蠠 , , p pp, p pp p p p , pp p . pp p p p: p- p p p p-p p (, p p p ). p 蠠 p ࠠ p-ꠠ 頠 ࠠ p p p-p.
p p p, p. p p - p p p .
send()
while ( p )
send( );
wait();
receive()
do
receive_byte();
send( p );
while( );
p p p pp p-p , p p p p, p .
p p - p p p p . , p p p p ( p
p p p , p, p p . p , p p . , p , pp?
, p pp () p , p , . p p , p pp, pp p p . p, p p : EOF ( End-Of-File) e . p p p p-p p .
2.1
p pp , p p p. p , p p p p, , p p -p p , , p . send_file(), p , p p p .
/* p p */
void send_file(fname)
char *fname;
FILE *fp; char ch; union
char c[2];
unsigned int count;
cnt;
if(!(fp=fopen(fname,"rb")))
printf(" p\n");
exit(1);
send_file_name(fname); /* p */
wait(PORT); /* p */
/* pp */
cnt.count = filesize(fp);
/* pp */
sport(PORT, cnt.c[0]);
wait(PORT);
sport(PORT, cnt.c[1]);
do
ch = getc(fp);
if(ferror(fp))
printf(" \n");
break;
/* p-p */
if(!feof(fp))
wait(PORT);
sport(PORT, ch);
while(!feof(fp));
wait(PORT);/* p */
fclose(fp);
send_file_name(), p , p p .
/* p */
void send_file_name(f)
char *f;
printf(" p... \n");
do
sport(PORT, '?');
while(!kbhit() && !(check_stat(PORT)&256));
if(kbhit())
getch();
exit(1);
wait(PORT); /* p */
printf("p %s\n\n",f);
/* p */
while(*f)
sport(PORT, *f++);
wait(PORT); /* p */
sport(PORT,'\0'); /* p */
send_file_name() p p . -p, p-p p pp p ('?') p . ( p . p p . , , p . , p p p p pp p.
wait(), p , p p-p, p pp p .
/* */
void wait(port)
int port;
if(rport(port)!='.')
printf(" \n");
exit(1);
p, p p pp p. pp p .
filesize() p pp . , p p , p pp , . p cnt, pp union, p , , p p p p .
2.2
p p p p p . -p, p pp p ( '?'). pp ( p). pp . . p- p . p p pp p . rec_file() p .
/* */
void rec_file()
FILE *fp; char ch; char fname[14]; union
char c[2];
unsigned int count; cnt;
get_file_name(fname); /* */
printf(" %s\n",fname);
remove(fname);
if(!(fp=fopen(fname, "wb")))
printf(" p \n");
exit(1);
/* */
sport(PORT, '.'); /* p */
cnt.c[0] = rport(PORT);
sport(PORT, '.'); /* p */
cnt.c[1] = rport(PORT);
sport(PORT, '.'); /* p */
for(; cnt.count; cnt.count--)
ch = rport(PORT);
putc(ch, fp);
if(ferror(fp))
printf(" ");
exit(1);
sport(PORT, '.'); /* p */
fclose(fp);
get_file_name() p .
/* */
void get_file_name(f)
char *f;
printf(" ...\n");
while(rport(PORT)!='?') ;
sport(PORT, '.'); /* p */
while((*f=rport(PORT)))
if(*f!='?')
f++;
sport(PORT, '.'); /* p */
2.3
, p p pp p p, p, p pp. pp p p 0 - p p; , pp PORT pp, p p.
/* pp p ,
pp p .
p p pp: p p - 9600 , p / p, ,
p -. */
#define PORT 0
#include "dos.h"
#include "stdio.h"
unsigned int filesize();
void sport(), send_file(), rec_file(), send_file_name();
void get_file_name(), port_init(), wait();
main(argc,argv)
int argc;
char *argv[];
if(argc<2)
printf(" p TRANS S < > TRANS R\n");
exit(1);
printf(" p pp . p\n");
printf("p .\n\n");
port_init(PORT, 231); /* p */
if(tolower(*argv[1]) == 's') send_file(argv[2]);
else rec_file();
/* p p */
void send_file(fname)
char *fname;
FILE *fp; char ch; union
char c[2];
unsigned int count;
cnt;
if(!(fp=fopen(fname,"rb")))
printf(" p\n");
exit(1);
send_file_name(fname); /* p */
wait(PORT); /* p */
/* pp */
cnt.count = filesize(fp);
/* pp */
sport(PORT, cnt.c[0]);
wait(PORT);
sport(PORT, cnt.c[1]);
do
ch = getc(fp);
if(ferror(fp))
printf(" \n ");
break;
/* p-p */
if(!feof(fp))
wait(PORT);
sport(PORT, ch);
while(!feof(fp));
wait(PORT);/* p */
fclose(fp);
/* p */
void rec_file()
FILE *fp; char ch; char fname[14]; union
char c[2];
unsigned int count; cnt;
get_file_name(fname); /* */
printf(" %s\n",fname);
remove(fname);
if(!(fp=fopen(fname, "wb")))
printf(" p \n");
exit(1);
/* */
sport(PORT, '.'); /* p */
cnt.c[0] = rport(PORT);
sport(PORT, '.'); /* p */
cnt.c[1] = rport(PORT);
sport(PORT, '.'); /* p */
for(; cnt.count; cnt.count--)
ch = rport(PORT);
putc(ch, fp);
if(ferror(fp))
printf(" ");
exit(1);
sport(PORT, '.'); /* p */
fclose(fp);
/* p */
unsigned int filesize(fp)
FILE *fp;
unsigned long int i;
i = 0;
do
getc(fp);
i++;
while(!feof(fp));
rewind(fp);
return (i-1); /* EOF */
/* p */
void send_file_name(f)
char *f;
printf(" p... \n");
do
sport(PORT, '?');
while(!kbhit() && !(check_stat(PORT)&256));
if(kbhit())
getch();
exit(1);
wait(PORT); /* p */
printf("p %s\n\n",f);
/* p */
while(*f)
sport(PORT, *f++);
wait(PORT); /* p */
sport(PORT, '\0'); /* p */
/* */
void get_file_name(f)
char *f;
printf(" ...\n");
while(rport(PORT)!='?');
sport(PORT, '.'); /* p */
while((*f=rport(PORT)))
if(*f!='?')
f++;
sport(PORT, '.'); /* p */
/* */
void wait(port)
int port;
if(rport(port)!='.')
printf(" \n");
exit(1);
/* p p */
void sport(port, c)
int port; /* p / */
char c; /* p */
union REGS r;
r.x.dx = port; /* p */
r.h.al = c; /* p */
r.h.ah = 1; /* p */
int86(0x14, &r, &r);
if(r.h.ah & 128)
printf(" p p p ");
exit(1);
/* p */
rport(port)
int port; /* p / */
union REGS r;
/* */
while(!(check_stat(PORT)&256))
if(kbhit()) /* p p pp
p */
getch();
exit(1);
r.x.dx = port; /* p */
r.h.ah = 2; /* */
int86(0x14, &r, &r);
if(r.h.ah & 128)
printf(" p p "); return r.h.al;
/* p p */
cheek_stat(port)
int port; /* p / */
union REGS r;
r.x.dx = port; /* p */
r.h.ah = 3; /* */
int86(0x14, &r, &r);
return r.x.ax;
/* p */
void port_init(port, code)
int port;
unsigned char code;
union REGS r;
r.x.dx = port; /* p */
r.h.ah = 0; /* p*/
r.h.al = code; /* - . */
int86(0x14, &r, &r);
pp p p pp p. pp p TRANS . p , p :
TRANS S <_>,
<_> - , p p p p p p p.
:
TRANS R
p 蠠 ࠠ p 蠠 , p p p p p - .
pp p , p . , p pp p p p , p . , , p pp, .
p p p p "" , p p p. p p. , ,
p cp p
p p . p p
pp .
p pp , p , , pp p p p . , p pp p p, . p p , pp , p p p p .
, , 젠 p p p . pp p蠠 p蠠 p p p p p.
3.
() p p p. p , pp p p. p . p p , p p p p pp p p. . , p p p p , p p . -p, p ( p pp) p. -p, p pp , p p p . -p, p, , pp p p , p p.
p, p . p p-p p p p . p p (file server). p, , p (nodes), p (terminals) p (workstations).
pp p 6-1. pp pp p . pp p. "pp" pp p p . pp, p pp, p . p, p pp , p p p p . pp p p pp pp .
3.1
p p p p . p p p , "r" "s" p. "s" p p ; "r" p ( p ) .
p pp蠠 p pp, p p , 𠠠 , ࠠ 젠 p p p p . p p pp p p . p p . pp, p, p p p p ( ).
main()
printf(" ./n");
printf(" ./n/n");
port_init(PORT); /* p */
do
/* p p */
if(check_stat(PORT)&256)
switch(rport(PORT))
case 's': send_file(PORT);
break;
case 'r': rec_file(PORT);
break;
/*************************************
p p p p p ...
if(check_stat(PORT1)&256) switch(rport(PORT1))
case 's': send_file(PORT1);
break;
case 'r': rec_file(PORT1);
break;
if(check_stat(PORTn)&256)
switch(rport(PORTn))
case 's': send_file(PORTn);
break;
case 'r': rec_file(PORTn);
break;
******************************************/
while(!kbhit());
, p p ( ), , p, p p N . , p p, pp p. p p p p/ .
, send_file() rec_file() p p p, p p p. p p p. p p p p . send_file() rec_file() p p .
/* p p p p */
void send_file(port)
int port;
FILE *fp;
char ch, fname[14];
union
char c[2];
unsigned int count;
cnt;
sport(port, '.'); /* p */
get_file_name(fname, PORT);
if(!(fp=fopen(fname,"rb")))
printf(" p\n");
exit(1);
if(rport(port)!='.')
printf(" p p \n");
exit(1);
printf("p %s\n", fname);
/* p pp */
cnt.count = filesize(fp);
/* p pp */
sport(port, cnt.c[0]);
wait(port);
sport(port, cnt.c[1]);
do
ch = getc(fp);
if(ferror(fp))
printf(" \n");
break;
/* */
if(!feof(fp))
wait(port);
sport(port, ch);
while(!feof(fp));
wait(port); /* p p*/
fclose(fp);
/* p p*/
void rec_file(port)
int port;
FILE *fp;
char ch, fname[14];
union
char c[2];
unsigned int count;
cnt;
sport(port, '.'); /* p */
get_file_name(fname, PORT);
printf(" %s\n", fname);
remove(fname);
if(!(fp=fopen(fname,"wb")))
printf(" p\n");
exit(1);
/* */
sport(port, '.');
cnt.c[0] = rport(port);
sport(port, '.');
cnt.c[1] = rport(port);
sport(port, '.');
for(; cnt.count; cnt.count--)
ch = rport(port);
putc(ch, fp);
if(ferror(fp))
printf(" p \n");
exit(1);
sport(port, '.');
fclose(fp);
pp, p , p . pp p 0. , , pp pp ( . p ) p p .
/* p . pp p:
p p - 9600 ,
p 蠠 . ,
,
p -. */
#define PORT 0
#include "dos.h"
#include "stdio.h"
unsigned int filesize();
void sport(), send_file(), rec_file(), send_file_name();
void get_file_name(), port_init(), wait();
main()
printf(" .\n");
printf(" ./n/n");
port_init(PORT); /* p */
do
/* p p */
if(check_stat(PORT)&256)
switch(rport(PORT))
case 's': send_file(PORT);
break;
case 'r': rec_file(PORT);
break;
/*****************************************
p p p . p,
p ...
if(check_stat(PORT1)&256)
switch(rport(PORT1))
case 's': send_file(PORT1);
break;
case 'r': rec_file(PORT1);
break;
if(check_stat(PORTn)&256)
switch(rport(PORTn))
case 's': send_file(PORTn);
break;
case 'r': rec_file(PORTn);
break;
******************************************/
while(!kbhit());
/* p p p p */
void send_file(port)
int port;
FILE *fp;
char ch, fname[14];
union
char c[2];
unsigned int count;
cnt;
sport(port, '.'); /* p */
get_file_name(fname, PORT);
if(!(fp=fopen(fname,"rb")))
printf(" p\n");
exit(1);
if(rport(port)!='.')
printf(" p p \n");
exit(1);
printf("p %s\n", fname);
/* p pp */
cnt.count = filesize(fp);
/* p pp */
sport(port, cnt.c[0]);
wait(port);
sport(port, cnt.c[1]);
do
ch = getc(fp);
if(ferror(fp))
printf(" \n");
break;
/* */
if(!feof(fp))
wait(port);
sport(port, ch);
while(!feof(fp));
wait(port); /* p p*/ fclose(fp);
/*p p p p.*/
void rec_file(port)
int port;
FILE *fp;
char ch, fname[14];
union
char c[2];
unsigned int count;
cnt;
sport(port, '.'); /* p */
get_file_name(fname, PORT);
printf(" %s\n", fname);
remove(fname);
if(!(fp=fopen(fname,"wb")))
printf(" p\n");
exit(1);
/* */
sport(port, '.');
cnt.c[0] = rport(port);
sport(port, '.');
cnt.c[1] = rport(port);
sport(port, '.');
for(; cnt.count; cnt.count--)
ch = rport(port);
putc(ch, fp);
if(ferror(fp))
printf(" p \n");
exit(1);
sport(port, '.');
fclose(fp);
/* p */
unsigned int filesize(fp)
FILE *fp;
unsigned long int i;
i = 0;
do
getc(fp);
i++;
while(!feof(fp));
rewind(fp);
return (i-1); /* EOF */
/* p */
void send_file_name(f, port)
char *f;
int port;
do
sport(port, '?');
while(!kbhit() && !(check_stat(port)&256));
if(kbhit())
getch();
exit(1);
wait(port);
while(*f)
sport(port, *f++);
wait(port); /* p */
sport(port, 0); /* p */
/* */
void get_file_name(f, port)
char *f;
int port;
while(rport(port)!='?') printf(".");
sport(port, '.');
while((*f=rport(port)))
if(*f!='?')
f++;
sport(port, '.');
sport(port, '.');
/* */
void wait(port)
int port;
if(rport(port)!='.')
printf(" \n");
exit(1);
/* p p */
void sport(port, c)
int port; /* p / */
char c; /* p */
union REGS r;
r.x.dx = port; /* p */
r.h.al = c; /* p */
r.h.ah = 1; /* p */
int86(0x14, &r, &r);
if(r.h.ah & 128) /* p 7- */
printf("p p p "); printf("%d",r.h.ah);
exit(1);
/* p */
rport(port)
int port; /* p / */
union REGS r;
/* p */
while(!(check_stat(port)&256))
if(kbhit()) /* pp p */
getch();
exit(1);
r.x.dx = port; /* p */
r.h.ah = 2; /* */
int86(0x14, &r, &r);
if(r.h.ah & 128)
printf(" p p ");
return r.h.al;
/* pp p */
check_stat(port)
int port; /* p / */
union REGS r;
r.x.dx = port; /* p */
r.h.ah = 3; /* */
int86(0x14, &r, &r);
return r.x.ax;
/* p pp:
p p 9600 , -,
p ., 8 . */
void port_init(port)
int port;
union REGS r;
r.x.dx = port; /* p */
r.h.ah = 0; /* p*/
r.h.al = 231; /* - . */
int86(0x14, &r, &r);
3.2
, p p p p, p pp. pp GET p , p . p pp pp p DOS. p pp GET :
GET <_>
<_> - p .
p p GET p p p , .
-p rec_file() p p -.
-p, p p pp, p pp p, .
pp GET p .
/* p . */
#define PORT 0
#include "dos.h"
#include "stdio.h"
void sport(), send_file(), rec_file(), send_file_name();
void get_file_name(), port_init(), wait();
main(argc,argv)
int argc;
char *argv[];
if(argc!=2)
printf(" p: GET < >\n");
exit(1);
port_init(PORT); /* p */
rec_file(argv[1]);
/* */
void rec_file(fname)
char *fname;
FILE *fp; char ch; union
char c[2];
unsigned int count;
cnt;
printf("p %s\n", fname);
remove(fname);
if(!(fp=fopen(fname,"wb")))
printf(" p\n");
exit(1);
sport(PORT, 's'); /*p pp
" p "*/
wait(PORT); /* */
/* */
send_file_name(fname);
sport(PORT, '.'); /* p */
cnt.c[0] = rport(PORT);
sport(PORT, '.'); /* p */
cnt.c[1] = rport(PORT);
sport(PORT, '.'); /* p */
for(; cnt.count; cnt.count--)
ch = rport(PORT);
putc(ch, fp);
if(ferror(fp))
printf(" ");
exit(1);
sport(PORT, '.'); /* p */
fclose(fp);
/* p */
void send_file_name(f)
char *f;
do
sport(PORT, '?');
while(!kbhit() && !(check_stat(PORT)&256));
if(kbhit())
getch();
exit(1);
wait(PORT);
while(*f)
sport(PORT, *f++);
wait(PORT);
sport(PORT, '\0'); /* p */
wait(PORT);
/* (p)*/
void wait(port)
int port;
if(rport(port)!='.')
printf(" \n");
exit(1);
/* p p */
void sport(port, c)
int port; /* p / */
char c; /* p */
union REGS r;
r.x.dx = port; /* p */
r.h.al = c; /* p */
r.h.ah = 1; /* p */
int86(0x14, &r, &r);
if(r.h.ah & 128) /* p 7- */
printf("p p p "); printf("%d",r.h.ah);
exit(1);
/* p */
rport(port)
int port; /* p / */
union REGS r;
/* p */
while(!(check_stat(port)&256))
if(kbhit())
getch();
exit(1);
r.x.dx = port; /* p */
r.h.ah = 2; /* */
int86(0x14, &r, &r);
if(r.h.ah & 128)
printf(" p p "); return r.h.al;
/* pp p */
check_stat(port)
int port; /* p / */
union REGS r;
r.x.dx = port; /* p */
r.h.ah = 3; /* */
int86(0x14, &r, &r);
return r.x.ax;
/* p pp:
p p 9600 , -,
p ., 8 . */
void port_init(port)
int port;
union REGS r;
r.x.dx = port; /* p */
r.h.ah = 0; /* p*/
r.h.al = 231; /* - . */
int86(0x14, &r, &r);
3.3
p p, p p p - p. p pp pp PUT. pp PUT p p . pp pp GET ( , p p). p pp:
PUT <_>
p pp PUT p p pp, p p pp .
pp PUT p .
#define PORT 0
#include "dos.h"
#include "stdio.h"
unsigned int filesize();
void sport(), send_file(), send_file_name();
void wait(), port_init(), wait();
main(argc,argv)
int argc;
char *argv[];
if(argc!=2)
printf(" p GET < >\n");
exit(1);
port_init(PORT); /* p */
send_file(argv[1]);
/* p p */
void send_file(fname)
char *fname;
FILE *fp; char ch; union
char c[2];
unsigned int count;
cnt;
if(!(fp=fopen(fname,"rb")))
printf(" p\n");
exit(1);
printf("p %s\n", fname);
/* p .*/
sport(PORT, 'r'); /* pp p
*/
wait(PORT);/* .*/
send_file_name(fname); /* p */
if(rport(PORT)!='.')
printf(" p p \n");
exit(1);
/* pp */
cnt.count = filesize(fp);
/* p pp */
sport(PORT, cnt.c[0]);
wait(PORT);
sport(PORT, cnt.c[1]);
do
ch = getc(fp);
if(ferror(fp))
printf(" \n");
break;
/* p-p */
if(!feof(fp))
wait(PORT);
sport(PORT, ch);
while(!feof(fp));
wait(PORT);/* p p*/
fclose(fp);
/* p */
unsigned int filesize(fp)
FILE *fp;
unsigned long int i;
i = 0;
do
getc(fp);
i++;
while(!feof(fp));
rewind(fp);
return (i-1); /* EOF */
/* p */
void send_file_name(f)
char *f;
do
sport(PORT, '?');
while(!kbhit() && !(check_stat(PORT)&256));
if(kbhit())
getch(); exit(1);
wait(PORT);
while(*f)
sport(PORT, *f++);
wait(PORT);
sport(PORT, '\0'); /* p */
wait(PORT);
/* */
void wait(port)
int port;
if(rport(port)!='.')
printf(" \n");
exit(1);
/* p p */
void sport(port, c)
int port; /* p / */
char c; /* p */
union REGS r;
r.x.dx = port; /* p */
r.h.al = c; /* p */
r.h.ah = 1; /* p */
int86(0x14, &r, &r);
if(r.h.ah & 128)
printf(" p p %d",r.h.ah); exit(1);
/* p */
rport(port)
int port; /* p / */
union REGS r;
/* */
while(!(check_stat(PORT)&256))
if(kbhit())
getch();
exit(1);
r.x.dx = port; /* p */
r.h.ah = 2; /* */
int86(0x14, &r, &r);
if(r.h.ah & 128)
printf(" p ");
return r.h.al;
/* p p */
cheek_stat(port)
int port; /* p / */
union REGS r;
r.x.dx = port; /* p */
r.h.ah = 3; /* */
int86(0x14, &r, &r);
return r.x.ax;
/* p pp:
p p - 9600 ,
p 蠠 . ,
,
p -. */
void port_init(port)
int port;
union REGS r;
r.x.dx = port; /* p */
r.h.ah = 0; /* p*/
r.h.al = 231; /* - . */
int86(0x14, &r, &r);
3.4
p p p. p - pp GET.EXE PUT.EXE. p , GET, p p PUT.
砠 p p p p pp p p. 'd' (directory) p p . p p p pp. , p , 'd' p p p p . p p , dir p.
p pp p p RUN, p , p p .
p , p p p , p p p .
pp p (p ) p .
4. .
1. ., ., . . . ., 1998
2. ++. 2000
3. . ., 1991
4. . /++ . , 2002
- . . :
Copyright (c) 2024 Stud-Baza.ru , , , .