nStatus = inp(DLM_PORT);
printf(“DLM_PORT returned %2.2X\n”, nStatus);
nStatus = inp(DLL_PORT);
printf(“DLL_PORT returned %2.2X\n”, nStatus);
outp(LCR_PORT, nTempStatus);
First, the program gets the current contents of the LCR_PORT and saves the contents in nTempStatus. Then the program writes to LCR_PORT with nTempStatus logically ORd with the DIVISOR_LATCH_BIT. This switches the meaning of RBR_PORT to
DLL_PORT and the meaning of THR_PORT to DLM_PORT.
Be sure you reset LCR_PORT after you have finished setting (or checking) the baud rate. You set the baud rate using the identifiers prefaced with in either program.
Summary
In this chapter, you learned about input and output using C, and how to use both file I/O and port I/O.
•Files used for both program input and program output are vital to any program’s operation.
•Text-based files can be read, printed, edited, and otherwise used without conversion by people. Text files usually contain only printable, newline, and form-feed characters.
•Binary files contain any bytes that a program must place in the file. Generally, a binary file is intended for use by the program or by other programs and cannot be edited, printed, or read.
•Using temporary work files, a programmer can extend a program’s data storage space to almost the amount of free space on the disk. Work files can be text or binary, depending on the program’s requirements.
•Stream files are supported by many functions, can be text or binary, and are usually buffered and formatted.