80-Bus News

  

November–December 1984, Volume 3, Issue 6











Page 29 of 55











| {

29

The file STDIO.H is supplied with a compiler and is -included” at the beginning of most programs that require 10 capabilities. It is itself “Cc” source code and it declares items to the program such as file control blocks and 10 buffers that will be used later on. It also declares things like “NULL” which can be seen in openit, this is analagous to the M80 equates that are seen at the beginning of a program. Examples from stdio-h are typically:

£define NULL 0 gdefine TRUE 1 f£define FALSE 0

You can also use the fdefine facility to define equates of your own in the identical way. The -C” macro preprocessor that most compilers have looks through your code and replaces all occurrences of -NULL” with –0’ and so on. gdefine entries can also be used for inserting macros into your code.

-C” data types

The next two lines declare permanent storage for the variables -count” and -fd’, don’t worry about the -*’ in front of the -fd* it means that it is an integer pointer, more on that later. These variables defined in this way outside of any functions declare then as global to all functions in this source file and also to any modules that are to be linked in later. Being globals they will reside in memory and maintain their set values throughout the run of the program. They may be accessed and altered by any of the program functions.

-C’ also allows you to use local or, to give them their proper name, automatic variables, these are declared inside the body of a function and reside in the stack area until a return from the function occurs. Automatic variables are declared as follows.

functionx()

{

int var_a, var_b; char array[16];

The above declares two 16 bit integers and an array of 16 bytes in the stack area. So you can see that you are able to create space for storage and arrays that you can process inside a function, store a result and discard on exit. Once the function has done its stuff the stack pointer is restored to its previous value before the routine was called and the stack space made available for other uses.

The data types available to you sometimes depend upon the compiler that you have but a typical -C compiler will have the following types.

short or char – These usually occupy a single byte.

int – Integer data type, usually two bytes long.

long – Long integer, usually four bytes long.

float – Single precision FP variable usually 4 bytes long. double – Double precision FP usually 8 bytes long.


This is an OCR’d version of the scanned page and likely contains recognition errors.











Page 29 of 55