Skip to content

B side: Making choices and repeating

A cassette tape with a handwritten label: "B Side. Fortran, the language that speaks maths."

B B side · Fortran · The language that speaks maths

How do you say "if" and "again"?

13 Fortran words in this segment
13 Assembly words for the same job

What Fortran says well here

  • Choices and loops are blocks: IF ... END IF, SELECT CASE, DO ... END DO. The shape of the text shows the logic.

What is hard to say

  • You do not see the separate steps that the processor does.

One sentence in Fortran

if (fuel == 0) then
call no_fuel()
end if

It says: If fuel is 0, run the subroutine no_fuel.

The words, by part of speech

Verbs (8) · A statement that does something, for example PRINT, CALL or ALLOCATE.

WordMeaningExample
IF ... THEN ... END IFDo a block only if a condition is true.if (fuel <= 0.0) then
SELECT CASEChoose one block from many, by the value of one name.select case (key)
DODo a block again, a number of times.do i = 1, 10
DO WHILEDo a block again while a condition is true.do while (.not. landed)
EXITStop the loop now.exit
CYCLEGo to the next turn of the loop.cycle
STOPStop the program.stop
ERROR STOPStop the program and report a failure. The build script sees the failure and stops. This is how a check says no.if (mismatches /= 0) error stop 'The A side and the B side disagree.'

Idioms (2) · A built-in function or subroutine, for example SQRT or MATMUL.

WordMeaningExample
BTESTIs one bit of a whole number 1? The same question as TEST on the A side.if (btest(flags, 3)) then
MERGEChoose the first value when the condition is true, or the second when it is false. One idiom replaces an IF block.merge('true ', 'false', ok)

Grammar marks (3) · Maths signs (+ - * / **), the = sign, and (:) for part of an array.

WordMeaningExample
ELSEStarts the block to do when the condition is false.else
== /= < > <= >=Compare two values: equal, not equal, less, greater, less or equal, greater or equal.if (x /= 0) then
.and. .or. .not.Join or reverse conditions.if (a .and. .not. b) then

Watch out: what the review found

These notes come from the review of the AI-written guides. They show traps that are easy to miss.

  • D02-M7 major On real PCs, DRAM refresh, ISA wait states, the 8088 prefetch queue and 486 caches make exact cycle counts not practical. The claim is true on the C64 and NES. It is not true on the DOS target that the roadmap uses.