Information Technology Reference
In-Depth Information
port[PORTADDRESS]:=value;
where PORTADDRESS is the address of the output port and value is the 8-bit value to
be sent to that address. To gain access to this function the statement uses dos requires
to be placed near the top of the program.
Microsoft C++ uses the equivalent _ outp() function (which is prototyped in conio.h ).
Outputting a word
The assembly language command to input a byte is:
OUT DX,AX
where DX is the data register which contains the address of the output port. The 16-bit
value sent to this address is stored in register AX .
For Turbo/Borland C the equivalent function is outport() . Its general syntax is as fol-
lows:
outport(PORTADDRESS,value);
where PORTADDRESS is the address of the output port and value is the 16-bit value to
be sent to that address. This function is prototyped in the header file dos.h .
For Turbo Pascal the equivalent is accessed via the port[] array. Its general syntax is as
follows:
portw[PORTADDRESS]:=value;
where PORTADDRESS is the address of the output port and value is the 16-bit value to
be sent to that address. To gain access to this function the statement uses dos requires
to be placed near the top of the program.
Microsoft C++ uses the equivalent _ outp() function (which is prototyped in conio.h ).
In-line assembly language
Most modern C++ development systems use an inline assembler which allows assembly lan-
guage code to be embedded with C++ code. This code can use any C variable or function
name that is in scope. The __asm keyword invokes the inline assembler and can appear wher-
ever a C statement is legal. The following code is a simple __asm block enclosed in braces.
__asm
{
/* Initialize serial port */
mov dx,0x01; /* COM2: */
mov al,0xD2; /* serial port parameters */
mov ah,0x0; /* initialize serial port */
int 14h;
line_status=ah;
modem_status=al;
}
Search WWH ::




Custom Search