beautypg.com

Intel 386 User Manual

Page 176

background image

7-17

SYSTEM MANAGEMENT MODE

---------------------------------------------------------------------------*/

void SerialWriteStr2()

/* Loops while writing a char out to the serial port */

{

_asm

{

mov

ax,0x3900

mov

ss,ax

mov sp,0x100

Forever:

mov

dx,0xf4fd

TstStatus:

in

al,dx

testal,0x20

je

TstStatus

// Code below is same as _SetEXRegByte(TransmitPortAddr,’X’)

mov

ax,’X’

mov

dx,0xf4f8

out

dx, al

jmp

Forever

}

}

/*********************** Function SerialWriteStr **************************

Parameters:

Unit

Unit number of the serial port. 0 for SIO port 0, 1 for SIO

port 1.

*str

Character string to be written out the serial port.

Returns:

None

Assumptions:

None

Real/Protected Mode

------------------------------------------------------------------------*/

void SerialWriteStr(int Unit, const char far *str)

{

WORD TransmitPortAddr;

WORD StatusPortAddr;

// Set Port base, based on serial port used

TransmitPortAddr = (Unit ? TBR1 : TBR0);

StatusPortAddr = (Unit ? LSR1 : LSR0);

for( ; *str != ‘\0’; str++)

{

// Wait until buffer is empty

while(!(_GetEXRegByte(StatusPortAddr) & SIO_TX_BUF_EMPTY)) ;

// Write Character

_SetEXRegByte(TransmitPortAddr,*str);

}