Converts all 0-bits of its operand to 1-bits and all 1-bits to 0-bits. Note that - is not the same as -. Rvalue Logical not. The result is zero if the operand is non-zero; otherwise, the result is one. Takes the Rvalue and allows it to be used as an Lvalue an address. This is the only case in which a unary operation returns an Lvalue. Both seek to generate an address using one or more Lvalues. The following are exactly equivalent everywhere:.
To be able to write or understand B programs, it is vital that you understand the validity of this relationship. Since addresses in B are only 18 bits long, treating longer numbers as addresses may lead to unexpected consequences. When one of a , i or the sum exceeds 18 bits, the value in the upper 18 bits is undefined. All other operators are binary operators: they require both a left and a right operand. Each operand must be an Rvalued expression. The result of any binary operation is also an Rvalue. With one exception, the order in which the two operands are evaluated is arbitrary, so the evaluation of one side should not depend on a side effect of the evaluation of the other side a function call, for instance.
Logical operators are the only exception. Their operands are always evaluated strictly from left to right. The code that B generates for floating point operations is correct, but not especially efficient, since the compiler generates a separate load and store each time a floating point operand is used. This means that floating point capability is available if you need it, but for intensive use of floating point, you should probably call a Fortran or Pascal routine to do the job.
The binary operators that follow are listed in the order in which they are evaluated: the operators described first are evaluated first. The chart summarizes the results of bitwise operations. These operators are described in more detail below. The table shows the effect of each operation on one bit. The three bitwise operators group from left to right. If bit i of both operands is one, then bit i of the result is one.
Otherwise, bit i of the result is zero. If bit i is on in one, but not in the other, then bit i of the result is on one. Otherwise, the bit is off zero. If bit i is on in either of the two operands or in both, bit i in the result is on also. Otherwise, the bit is off. This results in a divide check abort if the right operand is zero. The result is zero if the left operand is less than the right. The result is truncated towards zero if the right operand does not divide evenly into the left. The result is positive if the operands are both positive or both negative; otherwise, it is negative.
If the remainder of the integer division is non-zero, it has the same sign as the left operand. All floating point operators assume floating point operands. Multiplicative operators group from left to right. These provide integer or floating point addition and subtraction. Additive operators group left to right. The result is 1 if the given relation between two integer operands is true; otherwise, the result is zero.
The left hand operand is always evaluated first. If its result is zero, the result of the expression is zero and the right hand operand is not evaluated. If the result is non-zero, the result of the total expression is non-zero and the right hand operand is not evaluated. The first operand is evaluated.
If the result is non-zero, the second operand is evaluated and returned, while the third expression is ignored. If the result of the first operand is zero, the third operand is evaluated and returned, while the second is ignored. In both cases, the value that is returned is an Rvalue. For example, a function to calculate the maximum of two numbers might be coded as. Note that neither floating point nor relational operators may be used in compound assignments. In all cases, the right hand operand is evaluated first, even though the operator in the assignment may have higher binding strength than an operator in the expression.
Remember that assignment is an operation, not a statement, and so is valid almost anywhere, including conditional expressions, such as. Parentheses are used in this case to alter the order of precedence. These are required here because the assignment operators have the lowest evaluation precedence, which means they are evaluated last. If the parentheses were removed, x would be assigned either zero or one, depending on the outcome of the comparison. One of the advantages or programming in B is the large library of functions available to the language.
Every B library function available for public use has an expl file under "expl b lib". There is also an index of all documented routines in " expl b lib index ". This chapter only discusses the routines you need to get started using B. Furthermore, we do not discuss all the features of the functions mentioned here.
The "explain" files are more up to date and detailed than this manual can be. The B library functions were written to run quickly in as small a space as possible. For this reason, most library functions do no error checking. It is up to the programmer to make sure that library functions are passed valid arguments. If invalid arguments are passed to a library function, the function could very well give meaningless results or cause your program to abort.
In particular note that a large number of library routines may "lockup fault" if called with the wrong number of arguments. For historical reasons, the library is known as the B library , but in fact, the library supports several languages. Many library routines are sensitive to the format of pointer arguments and must have the upper 18 bits zero in order for the routine to function correctly.
If the upper 18 bits are non-zero, the function takes the lower 18 bits as a machine pointer and the upper 18 bits as the actual word address. In addition, non-zero values in the upper 18 bits of a pointer may cause the function to behave in slightly different ways. In particular, you must remember to mask off the upper 18 bits when dealing with values passed in the argv vector to the routine MAIN.
Some functions may return a value. This chapter indicates the nature of return values using sample assignments. Also, some functions are called with a variable number of arguments. If you want to use an optional argument, you must usually specify all the optional arguments which precede it in the function's argument list. Throughout this chapter, optional arguments are shown in square brackets.
For example, if a function is shown as. Sometimes, the first argument may be optional. In this case, the function examines its first argument to see if it is a valid unit number; if the number is not valid, the function adjusts argument references accordingly. Chapter 8 also provides a detailed discussion of read and write units. For the time being, all you need to know is that unit is a way to specify the physical device used in a read or write operation. This is a common feature of most B output functions.
If num contains the integer five, the print line has the form "The number is 5. The first line contains the floating point value of x and the second line contains the octal equivalent of this value. Note that the second line ends in another new-line character. If a character in the format string is not part of a recognized format, it is printed as it appears. If a format does not have a corresponding argument, it is printed as a literal string. PRINT returns a pointer to the created print string as its value.
For this reason,.
The value newpos which SCAN returns is the position of the character which ended the scanning. In this way, SCAN can be called repeatedly to obtain arguments from a command line. All these functions have explain files. The library supplies several functions which let you obtain or release memory dynamically. All such memory is located in a free storage pool called the heap. Dynamic allocation from the heap is useful when you need storage for a vector, but won't be able to decide how much space you need until run-time.
If you did know the amount of space, you could just declare the correct length at compilation time. All memory allocation is done by manipulating a linked list of free memory called the free list. The free list initially includes the so-called "core hole". In TSS, a subsystem is aborted with the message "not enough core to run job" if a request for memory cannot be satisfied.
Sequential input routines read any sequential file in standard system format, including media 0, 2 or 3 BCD, media 5, 6 or 7 ASCII and media 1 compressed source decks comdks ; in the process, the input routines convert the input to ASCII if necessary. A B program may have several files open for reading or writing at the same time. There are five units whose function is predefined and may not be altered by the program. Normally, you should use unit 0 to read from the standard input instead of Normally you should use unit 1 for output instead of In batch, output to -1 goes to the execution report.
Unit 0 is initialized as the standard input unit. In TSS, this is the terminal but input may come from a file if you redirect the standard input on the command line that invokes the program. Similarly, unit 1 is initialized as the standard output unit. In TSS, the default standard output is the terminal, but this may be redirected on the command line that invokes the program. Units 2 through 49 may be assigned by or to you, using various library functions. These units are usually associated with permanent or temporary disk files. It is permissible to open units 0 or 1 , but the usual practice is to leave them alone, so they may be redirected.
OPEN has the form. Normally, you omit the unit argument; this gives OPEN the freedom to choose any free unit. If you do specify a unit, and that unit is already open, OPEN saves the state of the open unit on a stack, then reassigns the unit number for the specified use. This string may also specify an altname in quotes. The string may not specify permissions. If ret is not negative, the open succeeded and ret contains the number of the unit just opened. If there was an error of some kind, ret is given a negative value and no unit is opened.
You only get this negative return value if you specify special access actions for OPEN in the event of an error. Usually if OPEN encounters an accessing error, it simply aborts your program. Only a few of the various situations accepted by OPEN are dealt with in this section. For a full description of OPEN , see " expl b lib open ".
Most of the time, the only thing you need to specify with OPEN is how you want to access the unit.
Tiger Compiler Reference Manual
Here are the alternatives: r read means you want to read from the unit. If the unit is a file that doesn't contain anything, or if appending is not appropriate with this particular output device, the result is the same as if you had used the 'w' action. For ordinary sequential file processing, you usually only have to specify one of the above actions. OPEN offers three ways to specify the mode of the unit being opened in the action string.
They are listed below. When "b" is specified, the unit being opened must be a random access file. The filename argument is a pointer to the start of a block in memory. Normally, OPEN never returns an error status, since the default action is to abort the program with a reasonably understandable error message. Including "m" in the action string tells OPEN to display an error message before returning an error status to the caller. As an example, suppose you write. OPEN prints an error message, then returns a negative value to indicate that the open operation failed.
For most errors, OPEN returns the negative of the file system error status. For example, OPEN returns -5 for "permissions denied". When you use OPEN to open a unit for reading, the unit which is opened is usually made the new default input unit. Similarly, using OPEN to open a unit for writing makes that unit the new default output unit. A quick access name is one which contains no slashes or dollar signs and does not have an altname.
It must also be less than nine characters long; if not, it is considered to be in error. If you are opening a file and the name is a quick access name for example, b. If such a file is not found, the file accessor searches for a file of that name in the current catalog. If the specified file name is not of the quick access form, it is assumed to be the name of a permanent file.
If the search fails and the file is being opened for write or append, OPEN tries to create the file. If the file name is of the quick access form, OPEN tries to create a temporary file; otherwise, it tries to create a permanent file. If the file was already in the AFT when accessed or if the file is a temporary file created during the access, the file is left in the AFT when the unit is closed. If the file was not in the AFT initially and the file is permanent, it is removed from the AFT when the unit is closed. You may override these defaults by including appropriate characters in the action string.
The character 't' for transient forces a file to be removed from the AFT when it is closed, whether or not it was in the AFT to begin with; and the character 'k' for keep keeps the file in the AFT even if it would normally be removed. This has the form:. For sequential stream output units, CLOSE flushes the output buffer if necessary, and writes an end-of-file mark if appropriate. Otherwise, the unit number is free for further allocation. When your main function terminates, or when you call EXIT directly, all open units are closed automatically. If you press Break during the execution of a program, EXIT is called unless your program has established its own break handling procedure.
Even though B does this clean-up closing automatically, it is a good idea to close units once you have finished using them. B uses about words of memory for each open unit. Closing an unneeded unit therefore releases quite a bit of memory which your program can use for other purposes. If a library routine tries to read data from a unit that is not open, the routine returns a value which indicates nothing happened.
Similarly, output to a unit which is not open simply vanishes. Initially, the default read unit is the standard input unit unit 0 and the default write unit is the standard output unit unit 1. Successful calls to OPEN change the default read or write unit unless you specify "u" as part of the action string. If new. The number of the old read unit is returned. Before starting your main program, the run-time initialization routine which prepares your program for execution calls a function named.
In your JCL, you might have something like. BSET breaks the command line up into "arguments". An argument is either a string of non-blank characters, a quoted string, or a redirect request. Input for unit 0 comes from this file, rather than the terminal.
If You're an Educator
Output to unit 1 goes to this file, rather than the terminal. The output overwrites any current contents of the file. A quoted string on the command line is delimited by either single or double quotes. To get a quote inside a quoted string, either use the quote which is not the delimiter or else put in two of the delimiter characters, as in. BSET collects arguments which are not redirect requests and builds a vector of pointers to those strings. MAIN is then invoked with. In addition,. BSET builds an external vector called.
Each word of. All writes on unit 1 go to the file b. The ARGV and. If you do not want to use. BSET , simply supply your own function definition of. Normally, however, you will want. BSET , because it simplifies the task of handling command lines. In fact, there are even more powerful facilities built into. BSET for scanning command lines with arguments of specified types. As well, you may call. BSET to scan an arbitrary string. For full details, see the explain file " expl b lib.
Compressed source decks are handled correctly, but the way B handles object decks is probably not very useful. Media 0 is always taken as variable-length BCD.
- C Standard Library Reference Tutorial.
- The GNU C Reference Manual.
- Navigation menu?
If the file is null to start with, OPEN treats the situation just like a regular open for writing. On input from a terminal, you may separate logical records lines by using either the "return" or "line-feed" key. End-of-file on a file is signalled by the presence of a special record at the end of the file. On single-case terminals, you can get a backslash by typing an 'L' and the shift key; thus an FS character is CNTL and shift- 'L' , followed by a carriage return.
Sequential file output is written in GFRC standard system format with blocks of words. All other record terminators do get written out. A new logical record is started after any record terminator is received. A word buffer is written out only when it is necessary to start a new buffer or when you call CLOSE. The library functions buffer terminal output. When using random-access files, your program is responsible for all input or output done on the file. You may read or write any number of sectors with one function call. The rules are the same as for the regular OPEN call, except that the 'b' in the action string indicates a random file.
The first sector number in the file is zero. The arguments have the same meaning as those for READ. If the number of words you transmit is not a multiple of 64, the unused fraction is filled with zeroes on writing. When the string is exhausted, the unit is in EOF status. If you want to start getting characters at some point other than the first character position, use the optional starting character position pos. It is up to you to make sure that the vector indicated by string is large enough to hold whatever data your program puts into it.
- igraph Reference Manual?
- Handbook of Human Rights!
- C: A Reference Manual (5th Edition) - PDF Free Download;
- Well-Being: Happiness in a Worthwhile Life!
This chapter deals with the process of compiling B programs. It also says a few words on programming style and ways to make your B programs more readable. The B command compiles B source code. If given a source file, the B command calls the compiler to read the source and generate a set of object modules. Only the most common uses of the B command are discussed here. For full details, see the explain file " expl b command ". If there are no fatal errors in compilation, the load module which the compiler creates is left in a random file called ". If you have a quick access permanent file called ".
This file is "grown" automatically by the TSS loader as required. You can force the B command to execute the program after it is compiled by specifying. However, if your program plans to interpret a command line, it's better to invoke your program with the GO command.
There are a few other options in the B command which you may find useful. You can also use this option to decrease your stack-size from the default of words, in the interests of saving space. However, it is inadvisable to use a stack-size of less than words, since pre-execution routines like. BSET require about words of stack to work properly. By default, the B compiler stores a number of debug tables in your program.
These can be used later to detect error conditions and generate useful diagnostic messages. Fully debugged production programs, however, need not carry these debug tables when running. The -Tables option may be used to turn off the loading of debug tables, as in. If you change one routine in a program, you don't want to be forced to recompile the whole program. To avoid this, you can store routines in a random library.
That way, you need only recompile one routine or one group of routines to make a change. With this option, the loader is not called to prepare a load module. The object decks prepared by the compiler are simply stored in the specified library for later use.
AVR Libc Reference Manual -
Libraries are searched in the order they appear on the command line. In all cases, the keyword may be abbreviated using the following rule: in the explain file, a keyword is shown with upper and lowercase letters. A valid abbreviation must include those letters which are in uppercase, along with any other letters in the order in which they appear. This object deck also contains the externals defined before the first function definition, if any. A separate object deck is generated for each function.
An object deck is also generated for each group of externals between function bodies and one for the group of externals after the last function body, if any. B accepts line-numbered source files. If the first character of the first file is a digit, the compiler assumes the source file has line numbers. If so, on each line of the file, the compiler tries to find a line number by collecting numeric characters until a non-numeric character is found.
This number is used in error messages pertaining to that line. When end-of-file is encountered in the included file, processing in the original file resumes at the line following the file inclusion request. The filename given may be in any of the forms acceptable in the TSS environment, such as.
The file inclusion feature lets you keep parts of a large module broken up into easily manageable files, while retaining the ability to compile the files together. File inclusion is often used to bring in a file of manifest definitions, such as TSS DRL equivalences; this avoids a lot of re- typing of manifests which a variety of programs use. Any line whose first character is a ' ' is assumed to be one of the compiler directives shown below.
In each case, "text" denotes a string of characters which begins with any non-blank character. If the compiler has not found a lbl directive by the time the compiler generates an object deck, the compiler uses the current file name. Subtype Declarations 3. Classification of Operations 3.
Subtype Predicates 3. Objects and Named Numbers 3. Object Declarations 3. Number Declarations 3. Derived Types and Classes 3. Scalar Types 3. Array Types 3. Discriminants 3. Record Types 3. Tagged Types and Type Extensions 3. Type Extensions 3. Dispatching Operations of Tagged Types 3. Abstract Types and Subprograms 3.
Interface Types 3. Access Types 3. Declarative Parts 4. Names and Expressions 4. Names 4. Indexed Components 4. Slices 4. Selected Components 4. Attributes 4. User-Defined References 4. User-Defined Indexing 4. Literals 4. Aggregates 4. Expressions 4. Update Expressions 4. Operators and Expression Evaluation 4.
Type Conversions 4. Qualified Expressions 4. Allocators 4. Static Expressions and Static Subtypes 5. Statements 5. Simple and Compound Statements - Sequences of Statements 5. Assignment Statements 5. If Statements 5. Case Statements 5. Loop Statements 5. User-Defined Iterator Types 5. Generalized Loop Iteration 5. Loop Invariants, Variants and Entry Values 5. Block Statements 5. Exit Statements 5. Goto Statements 5. Proof Pragmas 6. Subprograms 6. Subprogram Declarations 6. Preconditions and Postconditions 6. Subprogram Contracts 6.
Contract Cases 6. Global Aspects 6. Depends Aspects 6. Class-Wide Global and Depends Aspects 6. Formal Parameter Modes 6. Subprogram Bodies 6. Conformance Rules 6. Inline Expansion of Subprograms 6. Subprogram Calls 6. Parameter Associations 6. Anti-Aliasing 6. Return Statements 6. Nonreturning Procedures 6. Overloading of Operators 6. Null Procedures 6.
Expression Functions 6. Ghost Entities 7. Packages 7. Package Specifications and Declarations 7. Abstraction of State 7. External State 7. External State - Variables 7. Initializes Aspects 7. What registers are used by the C compiler? How do I put an array of strings completely in ROM? How to use external RAM? Which -O flag to use? How do I relocate code to a fixed address?
My UART is generating nonsense! My ATmega keeps crashing! Port F is completely broken! Why do all my "foo Why does the compiler compile an 8-bit operation that uses bitwise operators into a bit operation in assembly? How to detect RAM memory and variable overlap problems? What is this "clock skew detected" message? Why are many interrupt flags cleared by writing a logical 1? Why have "programmed" fuses the bit value 0?