Having finished with the description of Pascal, let's move on
to C.
The implementation of C on the Spectrum is very special.
is digital and has one big drawback:
it does not implement floating arithmetic
comma, which prevents wide
using C when creating programs.
However, the flip side of this was
significant increase in operating speed
programs created in C. Program for
C works 10-15 times faster than program
we are on BASIC performing similar
actions. So if you don't feel like it
tinker with assembler, then you can
you can use Hisoft C, practically
without losing any speed at all.
For special fans of C there is
library float, implementing in C operating
floating point radios. I won't
provide descriptions of C libraries here,
since everyone can download them
and see the comments. I will only give
necessary information regarding functions
standard libraries stdio.h and
stdio.lib.
After loading the compiler, the system re-
goes into modecompilation. In this
mode, you can enter a program and, on-
Press SS+I to compile it. After com-
pilation, if there are no errors, you will be offered
launch it by pressing the "Y" key. I bring
example from the system software reference book
Rammam:
main()
{
printf("First program");
};
TYPE Y TO RUN
First program
TURE Y TO RUN
But this set option is only suitable
for small test programs, for
for large programs there is a string
editor, the transition to which is carried out
This is done by successively pressing EDIT and
ENTER.
As was already said at the beginning of the article,
editors of differentHisoft products
practically no different from each other,
so I won't talk about it here
typing and editing the program, only
I will dwell on the features of command C.
The C compilation command translates the system
into the compilation mode described above. For
transferring text from the editor to the buffer
compiler you need to type #include and on-
press . The text will be moved to
buffer, and pressing SS+I will cause compilation
tion of the program.
Reserved words in C:
AUTO ELSE LONG TYPEDEF
BREAK ENTRY REGISTER UNION
CASE EXTERN RETURN UNSIGNED
CHARE FLOAT SHORT WHILE
CONTINUE FOR SIZEOF DEFAULT
GOTO STATIC DO IF
STRUCT FORTRAN DOUBLE INT
SWITCH ASM INLINE CAST
As mentioned above, the compiler
does not support floating point operations
fifth, therefore, although corresponding
words andreserved, compiler with
doesn't work with them.
Now a few words about unloading from
sawed program to disk. For you-
loading the program in compilation mode
ra before #include type #translate
, and your program will be unloaded
on. However, after unloading the compiler
will be reset.
A few words must be said about the special
fike commands inline for C. Argument
of this command - an arbitrary expression,
which during compilation will transform
encoded into machine code, with the first ar-
gument will give 1 byte of code, and everything that follows will
yushchie - 2 bytes.
Example:
cls()
{
inline(0xcd,0xd68);
}
Another difference between Hisoft C and the basic one
language is the presence of classes. Unfortunately-
no, noit is quite clear how to use them
vat, although any variable is associated with
by your class. Those interested can try
deal with this phenomenon.
Well, at the end there is a list of compiler errors:
0. No character
1. Unknown data type
2. Error in character constant
3. Invalid preprocessor directive
4. Macro buffer is full
5. Incorrect macro definition
6. The macro should not have parameters
7. Unable to open file
8. The included file contains the directive
include another file
9. WHILE required
10. No loop or switch
11.No cycle
12. no switch
13. Too many CASEs
14. More than one DEFAULT
15. Missing label in GOTO
16. Reuse of identification
ficator
17. Incorrect use of directive
you are a preprocessor
18.Name table overflow
19. Too many types
20.Double type declaration
21.Double class declaration
22.Global table overflow
names
23. Too many global variables
24. Double declaration
25. Local name table overflow
26. Variable not mentioned in the list
parameters
27. Undefined variable
28. Invalid value in the RETURN command
29. An array of functions is used
30. Expression too complex
31. Expression too complex
32.Invalid operation argument
33.Invalid operand type
34. Non-l-expression used
35. Structure fields not defined
36. Primary expression is missing
37. Variable not declared
38.Type name required
39. Requires a constantexpression
40.Missing function name
41. Incorrect use of 3-array
gum operator
42. The receiver must be an l-expression
43. Incorrect use of 3-array
gum operator
44.Pointer required
45. Invalid parameter type
46. Unknown data type
47. It is impossible to use this opera-
torus
48. Incorrect declaration
49. Error in the ad
51. Double declaration of attribute
52. Structure declaration used
to function
53. The structure contains itself
54. Error in declaration
55. Required ) in the function declaration
56. Incorrect parameter format
functions
57.Unknown function result type
60. Not enough memory
61. Incorrect assignment of initial
data
62. Incorrect assignment
61. Incorrect assignment of initial
data
62. Incorrect assignment
63. Incorrect assignment
64. Too much initial data
In the C standard librarystdio.lib
provides the ability to work with graphics
fics at the level of BASIC capabilities.
Therefore, theoretically, you can write in Cprograms that use graphics.
At the very end of the article I must say,
that, although in high-level languages it is not
there are possibilities to work with dis-
extensive memory, I have met before
library for C gam128.h, support-
working with memory banks.
R.S. According to ARTY (leader of the DI group
GITAL REALITY), RST7began creating
I'm learning my C for Spectrum.
Share your thoughts about the article