Hi, Karen,
Mode is the easiest(?) way.
However, I also have some code that will do that.
If you feel like doing a little assembly language,
I can give you a short script. On the other hand,
I can give you the script and you can ignore it.
In any case, here's a method using the DOS
debug.com program:
(don't type the comments, just the stuff on the left)
(the xxxx will be some 4-digit segment number,
don't worry about it.)
C:\>debug
-a 100
xxxx:0100 mov al,0 ; zero, for "off"
xxxx:0102 mov cx,03F9 ; Com1 address + 1 = int enable reg
xxxx:0105 out b al,cx ; interrupts off
xxxx:0107 mov al,13 ; DTR+RTS+LBK (loop back mode)
xxxx:0109 mov cx,03FC ; Com1 address + 4 = modem ctrl reg
xxxx:010C out b al,cx ; set loopback mode for Com1
xxxx:010E mov al,83 ; 80 = DLAB, 03 = 8-bit mode mask
xxxx:0110 mov cx,03FB ; Com1 address + 3 = line ctrl reg
xxxx:0113 out b al,cx ; turn on divisor latch access
xxxx:0115 mov ah,00 ; high-order byte of 000C
xxxx:0117 mov cx,03F9 ; "ie" reg now high-order divisor byte
xxxx:011A out b al,cx ; place first half of divisor value
xxxx:011C mov al,0C ; low-order byte (that's 12)
xxxx:011E mov cx,03F8 ; "data" reg now low-order divisor byte
xxxx:0121 out b al,cx ; place second half of divisor value
xxxx:0123 mov al,03 ; 8-bit mode mask without DLAB
xxxx:0125 mov cx,03FB ; Com1 address + 3 = line ctrl reg
xxxx:0128 out b al,cx ; turn off divisor latch access
xxxx:012A nop ; waste a cycle
xxxx:012B mov cx,03F8 ; Com1 base address = data reg
xxxx:012E in al,cx ; clear the (first) RX data reg
xxxx:0130 mov cx,03F8 ; same address (just killing time)
xxxx:0133 in al,cx ; clear the (other) RX data reg
xxxx:0135 mov al,03 ; DTR+RTS (without loop back bit)
xxxx:0137 mov cx,03FC ; Com1 address + 4 = modem ctrl reg
xxxx:013A out b al,cx ; clear loopback mode for Com1
xxxx:013C mov ax,4C00 ; terminate program, errorlevel=0
xxxx:013F int 21 ; call DOS to end
xxxx:0141 ; just press <Enter> here
-n set9600.com
-r cx
CX 0000
:0041
-w
Writing 00041 bytes
-q
C:\>
This creates a (very) small program called set9600.com
which places Com1 in loopback mode, sets the access
bit for the divisor latch, writes a zero to the high half of
the divisor latch and a 12 to the low half, clears the
divisor latch access bit (leaving the port in 8-bit mode),
eats two characters from the data register (clears the
holding reg as well), clears loopback mode, leaving
the DTR and RTS pins high, and finally exits to DOS.
You can alter the baud rate by changing the values
at lines xxxx:0115 and xxxx:011C using divisors from
the list below. You can address Com2 by changing
the base address from 03F8 to 02F8.
Now, having put you through all that, I'm going to
look through my archives for a simple program
that just sets up comm ports -- I know I have a
couple of those.
All the best,
Garry Hamilton
[EMAIL PROTECTED]
---------------------
Here is some reference material:
(the notation is C-style, but I can
convert it to ASM if needed).
---------------------
/*
8250 family serial port base (IBM) address equates
*/
#define COM1 0x03F8
#define COM2 0x02F8
#define COM3 0x03E8
#define COM4 0x02E8
// change or #undef to suit application
// #define comm COM1
/*
8250 register address offset equates
usage: COM1+LSR = actual address of COM1's LSR register
*/
#define RXR(p) (p +00) // receive register
#define TXR(p) (p +00) // transmit register
#define IER(p) (p +01) // interrupt enable register
#define DLL(p) (p +00) // RXR/TXR as divisor latch low byte (DLAB = 1)
#define DLH(p) (p +01) // IER as divisor latch high byte (DLAB = 1)
#define IIR(p) (p +02) // interrupt ID register
#define LCR(p) (p +03) // line control register
#define MCR(p) (p +04) // modem control register
#define LSR(p) (p +05) // line status register
#define MSR(p) (p +06) // modem status register
---------------------
/*
You can divide this by baud rate to get divisor
e.g.: baud_96 = BAUD_CLK / 9600 = 0x000C
*/
#define BAUD_CLK 115200L /* the "L" means "Long" or 32-bit integer
*/
---------------------
/* these are the baud rate divisor values */
#define BAUD___50 0x0900
#define BAUD___75 0x0600
#define BAUD__110 0x0417
#define BAUD__134 0x0359
#define BAUD__150 0x0300
#define BAUD__300 0x0180 /* 300 baud */
#define BAUD__600 0x00C0
#define BAUD__1k2 0x0060 /* 1200 baud */
#define BAUD__1k8 0x0040
#define BAUD__2k0 0x003A
#define BAUD__2k4 0x0030 /* 2400 baud */
#define BAUD__3k6 0x0020
#define BAUD__4k8 0x0018 /* 4800 baud */
#define BAUD__7k2 0x0010
#define BAUD__9k6 0x000C /* 9600 baud */
#define BAUD__19k 0x0006 /* 19200 baud */
---------------------
/*
8250 status bit pattern equates (these are inputs)
*/
/*
LSR (line status register) bits
*/
#define RBF 0x01 /* 00000001b rx buffer full */
#define LOR 0x02 /* 00000010b LSR overrun */
#define LPE 0x04 /* 00000100b LSR parity error */
#define LFE 0x08 /* 00001000b LSR framing error */
#define LBI 0x10 /* 00010000b LSR break interrupt */
#define TBE 0x20 /* 00100000b tx buf (hold reg) empty */
#define TSE 0x40 /* 01000000b tx shift reg empty */
#define RDE 0x0E /* 00001110b rx data error (LOR | LPE | LFE) */
/*
MSR (modem status register) bits
*/
#define DCTS 0x01 /* 00000001b delta clear to send */
#define DDSR 0x02 /* 00000010b delta data set ready */
#define TERI 0x04 /* 00000100b trailing edge ring indctr */
#define DDCD 0x08 /* 00001000b delta data carrier detect */
#define CTS 0x10 /* 00010000b clear to send */
#define DSR 0x20 /* 00100000b data set ready */
#define RRI 0x40 /* 01000000b received ring indicator */
#define DCD 0x80 /* 10000000b data carrier detect */
---------------------
/*
8250 control bit pattern equates (these are outputs)
*/
/*
LCR (line control register) bits
*/
/* (00=5, 01=6, 10=7, 11=8) */
#define WL5 0x00 /* 00000000b word length select 5 bits */
#define WL6 0x01 /* 00000001b word length select 6 bits */
#define WL7 0x02 /* 00000010b word length select 7 bits */
#define WL8 0x03 /* 00000011b word length select 8 bits */
#define STB 0x04 /* 00000100b stop bits */
#define PEN 0x08 /* 00001000b parity enable (EPS unless SPS) */
#define EPS 0x10 /* 00010000b even parity select P = (W mod 2) */
#define SPS 0x20 /* 00100000b stick parity select P = not EPS */
#define BRK 0x40 /* 01000000b set break */
#define DLAB 0x80 /* 10000000b divisor latch access bit */
/*
MCR (modem control register) bits
*/
#define DTR 0x01 /* 00000001b data terminal ready */
#define RTS 0x02 /* 00000010b request to send */
#define OT1 0x04 /* 00000100b out 1 */
#define OT2 0x08 /* 00001000b out 2 */
#define LBK 0x10 /* 00010000b loop back */
#define UNU 0xE0 /* 11100000b nothing, unused, always 0 */
---------------------
----- Original Message -----
"karen lewellen" <[EMAIL PROTECTED]> wrote:
> hi all,
> just a quick one
> can someone remind me how to set the baud rate in dos?
> i know that you can use the mode command, but is not there
> another way too?
> thanks,
To unsubscribe from SURVPC send a message to [EMAIL PROTECTED] with
unsubscribe SURVPC in the body of the message.
Also, trim this footer from any quoted replies.
More info can be found at;
http://www.softcon.com/archives/SURVPC.html