Category : Assembly Language Source Code
Archive   : EXCOM.ZIP
Filename : EXMODE.C

 
Output of file : EXMODE.C contained in archive : EXCOM.ZIP
#include
#include

/*
(C) 1987, Crystal Computer Consulting Inc.
This software may be used freely, at your own risk
as long as this notice is not removed.

Dr. Dobb's Journal, June 1987 EXMODE

*/
#define EXINIT 4 /* ah value for extended init */
#define EXCOM 0x5A5A /* magic value to identify excom */
#define DTR 0x01 /* DTR input flow control */
#define RTS 0x02 /* RTS input flow control */
#define XNXFIN 0x04 /* XON/XOFF input flow flowcontrol */
#define NOCTS 0x10 /* CTS not required for Transmit */
#define NODSR 0x20 /* DSR not required for Transmit */
#define B19200 0x40 /* set baud rate to 19200 */
#define B38400 0x80 /* set baud rate to 38400 */
#define COMINIT 0x100 /* port was selected */

typedef struct {
char
*str; /* command string */
void
(*fnct)(); /* command to execute */
int
arg; /* argument to pass */
} CMDS; /* exmode command table */

char
*insmsg = "excom installed",
*remmsg = "excom not installed",
*helpmsg;
int
init1 = 0, /* extended init for com1 */
init2 = 0, /* extended init for com2 */
portnum = -1; /* port to initialize */
void
exit(), install(), remove(), exinit(), setport();
CMDS
cmds[] = {
"install", install, 0,
"remove", remove, 0,
"com1", setport, 0,
"com2", setport, 1,
"dtr", exinit, DTR,
"rts", exinit, RTS,
"xnxfin", exinit, XNXFIN,
"nocts", exinit, NOCTS,
"nodsr", exinit, NODSR,
"19200", exinit, B19200,
"38400", exinit, B38400,
NULL
};

main(argc, argv)
int
argc;
register char
**argv;
{
register CMDS
*cmdp;
/* is excom installed */
if (int14(EXINIT, 0, 0) == EXCOM && int14(EXINIT, 0, 1) == EXCOM)
helpmsg = insmsg;
else
helpmsg = remmsg;
if (argc == 1)
help(helpmsg);
while (*++argv != NULL) {
/* look up the argument in the command table */
for (cmdp = cmds; cmdp->str != NULL; ++cmdp)
if (strcmp(*argv, cmdp->str) == 0)
break;

if (cmdp->str == NULL)
help("bad command");

else {
/* excom must be installed to set options */
if (helpmsg == remmsg && cmdp->fnct != install)
help(helpmsg);

/* excute the command */
(*cmdp->fnct)(cmdp->arg);
}
}
if ((init1 & (B19200 | B38400)) == (B19200 | B38400)
|| (init2 & (B19200 | B38400)) == (B19200 | B38400))
help("ambiguous baud rate setting");
/* actually send the init bits to excom */
if ((init1 & COMINIT) != 0)
init14(EXINIT, init1, 0);

if ((init2 & COMINIT) != 0)
init14(EXINIT, init2, 1);
exit(0);
}
/* install excom */
void
install()
{
system("excom");
helpmsg = insmsg;
}

/* remove excom */
void
remove()
{
int14(5, 0, 0);
helpmsg = remmsg;
}

/* collect up the init bite for each port */
void
exinit(thebit)
int
thebit;
{
if (portnum == -1)
help("no port selected");

else if (portnum == 0)
init1 != thebit; /* this looked like | but tried ! on second pass */

else

setport(newport)
int
newport;
{
portnum = newport;

if (portnum == 0)
init1 != COMINIT; /* same as above | to ! */

else
init2 != COMINIT; /* once again | to ! */
}

/* perform int 14h with ah, al & dx as passed, return ax value */
int14(cmd, val, port)
int
cmd,
val,
port;
{
union REGS
ir, /* registers send to BIOS */
or; /* registers returned from BIOS */

ir.h.ah = cmd;
ir.h.al = val;
ir.x.dx = port;

int86(0x14, &ir, &or);

return or.x.ax;

}

/* provide a bit of assistance */
help(msg)
char
*msg;
{
printf("\n%s\n\n", msg);

fputs("install\t\tinstall excom\n", stdout);
fputs("remove\t\tremove excom\n", stdout);
fputs("com1\t\tsubsequent commands for com1\n", stdout);
fputs("com2\t\tsubsequent commands for com2\n", stdout);
fputs("dtr\t\tuse DTR for input flow control\n", stdout);
fputs("rts\t\tuse RTS for input flow control\n", stdout);
fputs("xnxfin\t\tuse XON/XOFF (^S ^Q) input flow control\n", stdout);
fputs("nocts\t\tdon't require CTS to transmit\n", stdout);
fputs("nodsr\t\tdon't require DSR to transmit\n", stdout);
fputs("19200\t\tset baud rate\n", stdout);
fputs("38400\t\tset baud rate\n", stdout);

exit(1);
}


  3 Responses to “Category : Assembly Language Source Code
Archive   : EXCOM.ZIP
Filename : EXMODE.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/