B side: Keeping values

B B side · Fortran · The language that speaks maths
How do you tell the machine to remember a number?
19 Fortran words in this segment
26 Assembly words for the same job
What Fortran says well here
- Each name has a type, for example INTEGER or REAL. The compiler stops many mistakes before the program runs.
- A list or a table of values (an array) is one noun, with a name and a shape.
What is hard to say
- You do not choose where the values go in memory. The compiler chooses for you.
One sentence in Fortran
integer :: lives = 3It says: Make a whole-number name, lives, with the value 3.
The words, by part of speech
Verbs (2) · A statement that does something, for example PRINT, CALL or ALLOCATE.
| Word | Meaning | Example |
|---|---|---|
| ALLOCATE | Make space for an ALLOCATABLE array. | allocate(x(n)) |
| DEALLOCATE | Release the space of an array. | deallocate(x) |
Nouns (6) · A kind of value (a type), for example INTEGER or REAL.
| Word | Meaning | Example |
|---|---|---|
| INTEGER | A whole number, for example -1, 0 or 42. | integer :: lives |
| REAL | A number with a decimal point, for example 3.14. | real :: speed |
| LOGICAL | A value that is true or false. | logical :: landed |
| CHARACTER | Text. | character(len=20) :: name |
| COMPLEX | A complex number: a real part and an imaginary part. | complex :: z |
| TYPE | A new noun that you make from other nouns (a derived type). | type :: ship |
Adjectives (9) · An attribute, for example ALLOCATABLE or PARAMETER.
| Word | Meaning | Example |
|---|---|---|
| PARAMETER | The value never changes (a constant). | real, parameter :: g = 1.62 |
| DIMENSION | This name holds a list or a table of values (an array). | real, dimension(100) :: x |
| ALLOCATABLE | The program sets the size of this array when it runs. | real, allocatable :: x(:) |
| POINTER | This name points to a different value. | real, pointer :: p |
| TARGET | A pointer can point to this value. | real, target :: t |
| SAVE | Keep this value between calls. | integer, save :: count |
| KIND | Select the precision: how many digits a number keeps. | real(kind=real64) :: t |
| INT8 / INT16 | A kind name from ISO_FORTRAN_ENV: a whole number of exactly 1 or 2 bytes. The same size as a BYTE or a WORD on the A side. | integer(int16) :: table(0:255) |
| REAL64 | A kind name from ISO_FORTRAN_ENV: a decimal-point number of 8 bytes (double precision). | real(real64) :: theta |
Grammar marks (2) · Maths signs (+ - * / **), the = sign, and (:) for part of an array.
| Word | Meaning | Example |
|---|---|---|
| :: | Separates the description from the names in a declaration. | real :: x, y |
| = | Put the value on the right into the name on the left. It is not the maths "equals". | x = x + 1 |
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-M4 major These are 16-bit registers. 16.16 math needs 32-bit registers (EAX and the others, 386 and later) or register pairs on the 8086.
REP MOVSD(L31) also needs a 386 or later. The document mixes 8086 and 386 targets and does not say so. - D13-M4 major The video names neither LoROM nor HiROM, and it does not discuss fast or slow ROM. Its memory lesson is the data bank register: ROM from bank $C0, code in the second half of each bank, so the mirror reaches the hardware registers and "the first 8K of low RAM" (20:35 to 21:59). It moved the objects from bank $7F to the first RAM bank to avoid bank switches. The document misses this lesson, which is the closest SNES parallel to the 8086 segment registers.