DonNews #11
21 апреля 2000 |
|
Soft - Description of the C compiler for the Spectrum.
Disabler / DPL A few words about the application ... Today in our application: Hisoft C compiler or speaking in Russian - the compiler for haysoftovskogo C. Please do not cry Type: yes zae .. whether it suck! But you 're wrong. This version is the Working most of those that I caught, plus I took the courage a little zaREMIXit it. Thus, ship it and see - ZX-IBM Text Editor! But not so fast! He redesigned for work with texts Hisoft C, and yet, I Reversed the PgUp and PgDown, so it is more convenient flipping. And where is Tse minus minus?? Well Well, the logical question! Try select Quit from the File menu and you will find it. Yes, if you desired to go back to editor quit compilers (Edit, B). And now a little description of the language itself and compiler command: We leave to the compiler and type: main () { printf ("nHello Everybody! n"); } push SS + I (compilation), and if you no mistake appears: "Type Y to run" (Press Y to start). Click and see: Hello Everybody! Type Y to run Ponazhimat Y a few times you get tired, but this is just the beginning! This entry programs suitable for small programok more serious need to dial in the editor, which can be accessed by clicking Edit (CS +1). Editor will not be described here, since he is totally MustDie (If someone has worked in Gens'e I understand). You will need Only two teams Editor: "B" and "C". Team "B" (Back, Basic, Bye, Bitch:)) will return to normal editor. Team "C" (Compiler) will return you to the regime compiler. Basic compiler commands. All teams start with a sharp compilers (#). There are three things: Team "# include" # Include (without parameters) Pasting text from clipboard editor. Principle the present form of this command, you do not need (I hope never!). 1 # include: filename Paste text from a disk. Figure - the number of drive after dvuetochiya is the name of ishodnyaka. # Include a:? Filename? Connect from the library only those functions that are used in your program. The command "# list" # List This command disables text output program at compile time. At the stage izpolzovat debugging is not recommended. # List + Team back "# list-" The command "# translate" # Translate a: filename Used to compile the program. Works in conjunction with # include. For example: # Translate a: compile # Include a: coolprog After compiling the program and clicking SS + I you get to the disk file named compile, you can run it by typing in Basic'e the following: Rand Usr 15619: Rem: Load "compile" Code Rand Usr 25200 Programme structure For any C program is a function of standard name main (). All the rest function in the program may be in any place, ie, meaning that There is no difference where the function to main () or after. In the "C" there is no division on the functions and operators, they are equal. Ie the operator can return a value, and the function can not return. And the operators and functions must have parameters. If not, then after the name should stand empty brackets. The simplest C program is as follows: main (); Any function can be performed with only one operator. If you want to more than one resort to such things as composite operator. It begins with a "{" And ends with "}". Operators inside the compound are separated by ";" each statement ends with ";". For example, if must fulfill two print statement - is will look like: {Printf ("Hi"); printf ("All!");} Thus, a program that is makes will be as follows: main () { printf ("Hi"); prinft ("All"); } Variable Types C for several types are standard, they are all integers, are: Type Meaning single-byte unsigned char 0 .. 255 (any one character) int sign dvubaytny -32768 .. 32767 unsigned double-byte unsigned 0 .. 65535 So as you can specify any of its type team typedef, such as the definition File type: typedef int file; Declaring Variables Each variable before using must be declared and it must be assigned to one of the types defined earlier, The variables you can set the initial value. For example, we have for the two nested cycles need to declare three variables integer type, while two of them have set the initial value: int i = 0, sum = 0; main () { int j; for (; i <= 10; i + +) for (j = 0; j <11; j + +) sum + = i + j; } In the example you have met three teams of which you (probably) did not know: "Sum + = i + j" - the logic is simple to Komad ugliness. It is an analogue "Sum = sum + i + j", ie, the sum + = 1 and sum = sum +1 obsolyutno are identical. By analogy build team -=, *=, etc. "I + +" - the postfix form of increment. Works as follows: take variable i, is used for computing then incremented For example: We have: a = 10, b = 25 Calculate: a + = (b + +) / * postfix increment * / We get: a = 35, b = 26 We have: a = 10, b = 25 Compute: a +=(++ b) / * Prefix increment * / We get: a = 36, b = 26 We have: a = 10, b = 25 Calculate: a + = (b -) / * postfix decrement * / We get: a = 35, b = 24 We have: a = 10, b = 25 Compute: a +=(-- b) / * Prefix decrement * / We get: a = 34, b = 24 PS: Please do not mix with feces:) is completely carved things! You can also just write b + + And the last team: for. Ee format as follows: for (<vyr.1>, <vyr.2>, <vyr.3>) operator; where: vyr.1 - any expression for the installation initial values of the cycle. vyr.2 - an expression that checks the end cycle, ie, for works yet vyr.2 truth. vyr.3 - to change the parameters of the cycle. If you do not understand how it works give an example for Basic and C: Rem Basic prog. Let a = 0 For i = 1 to 14 Step 2 Print i; "-"; i ^ 2 a = a + i Next i Print a / * C prog. * / Int a = 0; Main () { Int i; For (i = 1; i <= 14; i + = 2) { Printf ("n% d -% d", i, i * i); a + = i; } Printf ("n% d", a); } Here we met the team "Printf" with what that character set. As you probably guessed it - the operator of the press, but not easy! It only works on print format and the format is: first, operator is written in inverted commas Management string, and then a comma lists what you need print. Control characters begin with the sign "(backslash), and format data with a "%" (percent). All that nepodhodit the format control string - napyamuyu posylyaetsya print. If, after sign "is a number, it perceived as a character code for printing For example you can print a quote as follows: Printf ("34") / * 34 - code "* / Also identified a number of characters perceived after "as a control: n - newline - Print character '- Prints character' "- Print symbol Print sizes: % D - print a decimal number % O - ... octal ... % X - ... hexadecimal ... % U - ... unsigned ... % C - ... one character % S - ... print row Indices Pretty interesting thing. If you yuzaete HRC, the inept handling of can spoil it, I actually made in writing maaalenkogo, but insidious virus, but that's another topic. So what is a pointer? This variable, which as its value uses the address of the other variable, or, simply speaking, a reference the variable. Pointers in C apply rather actively, for example, to write in memory byte, or a sample, as well as in functions with an indefinite number of parameters, such as in the statement printf, we set the control string on which he selects from the memory variables for Print. Declare a pointer to a variable can be as follows: typedef char * ukaz; In this case, will be declared a pointer a variable of type char. An asterisk is for determining what is a pointer. There is one more sign that "'." He allows raz'adresovat variable, ie, refer to its address. Example: typedef char * ukazat; main () { char litter; ukazat = 'litter; printf ("nAdr is% u", * ukazat); } In the example declares a pointer ukazat on a char variable and litter type char, after which the index is assigned address value of the variable and displayed on screen. I think it's understandable. If not, bring another primerchik: poke (addr, data); unsigned addr; char data; { typedef char * ukazat; * Cast (ukazat) addr = data; } I think the name you guessed that this function does. This is the analogue team poke at basic'e. She lozhit bytes "Data" address "addr". You should have been confuse the string: * cast (ukazat) addr = data, but it is logical. Operator "(ukazat)" - this is cast to type, and all sequence does the following: take variable addr, leads her to type a pointer to a variable of type char, after What puts this address variable data, type char. Conclusion In the next room, if there will be feedback You can read further information Language C. If you have any questions, wishes and suggestions - write. If you are interested in languages I will small list of those about whom I can tell: Basic (ZX / PC), Quick Basic (PC), Visual Basic (PC), Mega Basic (ZX), Laser Basic (ZX), Beta Basic (ZX), Hisoft Pascal (ZX), Borland Turbo Pascal (PC), Hisoft C (ZX), Borland C + + (PC), C + + Builder (PC), FoxPro (PC) - Management System Relational databases, Auto Lisp (PC) - Language processing graphics applications AutoCad, SQL (PC) - query language Assembler (ZX). And finally, if you have any Languages for speccy - kindly requested send, and as you get bonus'a CD with all the languages that have ever were created by speccy, from modifications and compilers, Basic, Pascal, C to assemblers (all latest versions). Yes, still going Commanderie Collection! If you have Commanderie not specified in list or newer version, plz send. Bonus - as in the previous requezt! Honey Comm. 4.00 (atm) Honey Comm. 4.512 (pentagon) MOA Service Luxe Copy 512 (pent) + protector Quick Comm. 2.3 Global Comm. 1.1 Smash Comm. 2.0 Conver Comm. 4.61 Perfect Comm. 1.5 Consul Comm. 3.33 Total Comm. 1.4 F Comm. 4.01 Max Petrov Comm. Rst # 7 Comm. 2.0 E-mage Work Station 1.00 Real Comm. 1.9 Direct Comm. 3.04R Neos Comm. (Alpha ver.) Last requezt: going to a collection boot'ov (now about a hundred pieces). Taken in four naminatsiyah: Hidden boot - raspologaetsa zero track; System boot - a quick boot to the system discs, most importantly - a lot of files can be seen immediately and can quickly launch any of them; Protect boot - boot with protection from Copy (brand boot'y) and copy protection; Demo boot - a nice boot, preferably with music.
Other articles:
Similar articles:
В этот день... 23 November