Hardware Reference
In-Depth Information
{
delay(200000);
}
delay(limit)
long limit;
{
long x;
for(x = 1; x < limit; ++x);
}
Where more than one argument is to be passed to a function, they are simply
listed and separated by commas. The data type for each argument must then
be defined before the opening brace of the function body. A function definition
dealing with port output, for example, might be declared with statements of the
form:
out (port, byte)
int port, byte;
{
...
...
...
}
The corresponding function call would require a statement of the form:
out(255,128);
In this case, the value 255 would be passed into
port
whilst the value 128 would
be passed into
byte
.
I/O functions
The following types of I/O function are available within C:
Stream I/O In which a data file or data item is treated as a stream of
individual characters. Examples of stream I/O functions
include
fopen
,
fgetc
,
fgets
, and
fclose
.
Low-level I/O Routines which do not perform buffering and formating
but which, instead, directly invoke the I/O capabilities of
the operating system. Examples of low-level I/O functions
include
open
,
close
,
read
, and
write
.
Console and
An extension of stream I/O which permits reading and writ-
ing to a console/terminal or sending/receiving bytes of data
via an I/O port. Examples of console and port I/O functions
include
getch
,
cgets
,
cputs
,
inp
, and
outp
(the latter are
used in many control applications).
port I/O
Messages
Messages in C can be printed using statements of the form:
printf
(message string goes here)