Information Technology Reference
In-Depth Information
Microsoft C++ uses the equivalent _ inp() function (which is prototyped in conio.h ).
Inputting a word from a port
The assembly language command to input a word is
IN AX,DX
where DX is the data register which contains the address of the input port. The 16-bit
value loaded from this address is put into the register AX .
For Turbo/Borland C the equivalent function is inport() . Its general syntax is as follows:
value=inport(PORTADDRESS);
where PORTADDRESS is the address of the input port and value is loaded with the 16-
bit value at this address. This function is prototyped in the header file dos.h .
For Turbo Pascal the equivalent is accessed via the portw[] array. Its general syntax is as
follows:
value:=portw[PORTADDRESS];
where PORTADDRESS is the address of the input port and value is the 16-bit value at
this 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 _ inpw() function (which is prototyped in conio.h ).
Outputting a byte to an I/O port
The assembly language command to output a byte is
OUT DX,AL
where DX is the data register which contains the address of the output port. The 8-bit
value sent to this address is stored in register AL .
For Turbo/Borland C the equivalent function is outportb() . Its general syntax is as fol-
lows:
outportb(PORTADDRESS,value);
where PORTADDRESS is the address of the output port and value is the 8-bit value to
be sent to this 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:
Search WWH ::




Custom Search