80-Bus News


November–December 1984, Volume 3, Issue 6

Page 33 of 55

default routine is executed, in this case the output of an error message and the setting of an error flag.

Now we have introduced the ‘break’ statement, I think that we should give it a further airing along with its bedmate the ‘continue’ statement. Although ‘C’ allows the use of the ‘goto’ statement, it should never be necessary to use it. Let us say that we are in the body of an executing loop and we come across the following:

if( vbll_1 == 0 ) break;

vbl_1 is tested for a zero value and if it is found to be true the loop is exited and control is passed to the statement immediatly following the loop statements. A nice clean way don’t you think to conditionally exit an executing loop.

if the following was encountered:

if( vbl_1 == 0 ) continue;

‘C’ would interpret this as, if vbl_1 is found to be 0 then forget about the remainder of the looping statements and continue with the next iteration. This is not an exit from the loop but the forcing of a premature ‘NEXT’, to give a comparison in BASIC.

It did occur to me a while back that if you used ‘£define goto structured_repass’ the preprocessor would replace ‘structured_repass’ with goto, which means that you could have as many goto’s in your code as you wanted and no one would be any the wiser, especially if you put it in STDIO.H where it could not be found in a source listing. If you want to get your own back, using methods like that, ‘C’ could be the ideal medium for ‘drop through’ spaghetti programmers!

Arithmetic operators

All the normal operators are supported and usually conform to the standard rules of operator precedence. As you may have already noticed there are two ways that arithmetic syntax can be entered. I call these ‘longhand’ and ‘shorthand’ for convenience. Here is some equivalent syntax.

x=x+1x++increments x by 1
x=x+3X+=3increments x by 3
x=x*3x*=3multiplies x by 3

In addition to these you will also have bitwise logical operators at your beck and call, some examples below.

x>>=4shifts x four bits to the right
x<<=6shifts x six bits to the left

Page 33 of 55