home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Interactive Guide
/
c-cplusplus-interactive-guide.iso
/
c_ref
/
csource4
/
225_01
/
deff3.txt
< prev
next >
Wrap
Text File
|
1987-06-10
|
18KB
|
536 lines
DEFF3.TXT
---------
I have given, below, a description of each of the functions
which I have written for the file -
DEFF3.C
and which may be accessed through -
DEFF3(.CRL)
when you use the CLINK function with BDS C. It is not
necessary to specify "DEFF3" on the command line as BDS C
will look for any missing functions in the DEFF files,
automatically, in answer to a RETURN entered when it asks
you for instructions as to which CRL files it should search
for the missing functions.
If you intend to use DEFF3 in this way then it should be on
the same disk as the BDS C DEFF files. Now, the functions
I have written are -
BINARY GET_DEFAULT RESET_DSK
BITCOUNT GET_IOBYTE REVERSE
CGET INDEX SEARCH_FIRST
CLOSE_FILE ISALNUM SEARCH_NEXT
CLRSCREEN ITOA SELECT_DSK
CPUT LISTC SET_ATTRIBUTES
CON_STAT MAKE_RO SETDMA
CREATE_FILE OPEN_FILE SET_IOBYTE
DIRECTC PRINT_DEC SHELL_SORT
DPB_ADR PRT_STR SWAP_POINTERS
ERASE_FILE READ_SEQ_SEC USER_ID
GET_CPM READ_STR WRITE_SEQ_SEC
ADDED FUNCTIONS
---------------
L_SHIFT R_SHIFT PRT_BIN
BIT_SET BIT_RESET ISPRINT
SCOPY_N GET_ALV
char BINARY(x, v, n)
int x, v[], n;
--------------------
Checks whether a binary number (x) occurs in a sorted array
(v, of n elements) and, if so, returns the binary number or
else returns -1 if it doesn't occur.
char BITCOUNT(n)
unsigned n;
----------------
Returns the number of set bits ( = 1) in a byte.
unsigned BIT_RESET(u, n)
unsigned u;
int n;
------------------------
Will reset (to zero) the nominated bit number ( n = 0 to 15)
in an unsigned integer "u". Returns the unsigned integer
with the nominated bit reset to zero.
unsigned BIT_SET(u, n)
unsigned u;
int n;
----------------------
Will set (to one) the nominated bit number ( n = 0 to 15)
in an unsigned integer "u". Returns the unsigned integer
with the nominated bit set to one.
char CGET()
-----------
Similar to "getchar" in what it does except that it will
read ANY byte value from the console. i.e. the value you
enter doesn't have to be either ASCII or printable.
It returns the value of the byte entry.
char CLOSE_FILE(fcb)
char fcb[36];
--------------------
This will close the file whose name is included in the file
control block pointed to by "fcb". It is the companion
function to "OPEN_FILE" and should be used to close any file
previously opened with OPEN_FILE. It returns the same
values as OPEN_FILE.
void CLRSCREEN()
----------------
Will clear the screen and home the cursor, using in-built
terminal software commands. It is (probably) only usable
by Hazeltine family terminals but could be altered to suit
other terminals provided you know the byte value(s) to send
to the terminal to activate the clear screen/home function.
Doesn't return anything.
char CON_STAT()
---------------
This checks the console status and returns ZERO if there is
no character waiting, else it returns 0xff....NOT the
character itself. It is a useful function for those inputs
where you tell the user -
"Enter any character to continue."
void CPUT(c)
int c;
------------
Similar to "putchar" except that it will send ANY byte value
to the console. Naturally the console will only display
the "visible" characters. Doesn't return anything useful.
char CREATE_FILE(fcb)
char fcb[36];
---------------------
This will create the file named in the file control block
(see open_file for a description of this) an initialise it
for both read and write functions. Note particularly that
it doesn't check to see whether a file of this name already
exists so you need to do this independently if you want to
make sure you haven't got two files of the same name in the
disk directory.
It is supposed to return 0xff (255 decimal) if the disk is
full and the name can't be created, but I'm not so sure
that you can rely on it to do so. Probably the best way
to be sure is to now try to open the file (with open_file)
and see what happens then.
char DIRECTC(duty)
int duty;
------------------
This is CP/M function No. 6 and it can be used to either get
a character from the terminal, or to send a character to the
console. It depends on the value of "duty" which should be
either -
0xff for input from the terminal
or the byte value for output to the console
It returns the input character in the first case or zero in
the second case.
unsigned DPB_ADR()
------------------
Gives the Disk Parameter Block address (pointer to). You
should first have declared the pointer as -
struct dpb *pointer;
This allows access to the following values -
int pointer->SPT No. of records per track
char pointer->BSH Block Shift Factor
char pointer->BKM Block Mask
char pointer->EXM Extent Mask
int pointer->DSM Disk Space Maximum (highest block)
int pointer->DRM Directory Maximum (highest entry)
char pointer->AL0 Initial Allocation Vector
char pointer->AL1 do (high byte)
int pointer->CKS Check Area Size
int pointer->OFF Count of reserved tracks
Note that the definition for "dpb" is given in "PEC.H" and
this should be "included" in the programme if you wish to
access the disk parameter block.
char ERASE_FILE(fcb)
char fcb[36];
--------------------
Erases from the directory the name of the file in the file
control block. For a description of this see open_file.
It will return 0xff if the file isn't found.
unsigned GET_ALV()
------------------
Returns a pointer to the Allocation Vector which gives the
allocation block map for the selected disk. Note the map
is a number of bytes with a particular bit set if the block
is in use. You can obtain the highest allocation block
number from the Disk Parameter Block (see DPB_ADR).
int GET_CPM()
-------------
Returns a 16-bit number (in HL) with the details -
H = 0x00 for CP/M OR H = 0x01 for MP/M
L = 0x00 for all releases prior to 2.0
L = 0x20 for version 2.0, 0x21 for version 2.1, 0x22
for version 2.2, and so on.
If you want to use any of this information then you will
need to mask off H (or L) to find out what it was the
function returned.
char GET_DEFAULT()
-----