Перейти к содержанию

Этот урок ещё не переведён на русский язык, поэтому показан на английском.

Начало урока

The Machine's Path Depends on Data

Among the processor's few actions, one has been waiting quietly since its lesson: choose which action to perform next. Today it steps forward. Combined with comparison, it gives the machine something no calculator has — a path that is not written down anywhere, but born at run time from the meeting of program and data. This lesson is where machines stop being player pianos.

Learning goals: explain how compare-then-choose makes the executed path depend on data; trace both paths of one small program by hand; and state the consequence with long shadows — why a program's conduct cannot, in general, be read off its text.

Start with the question

A music box plays its pins in order — always the same tune. The idealized machine also performs actions in strict sequence, one per tick. So: is the machine a music box? Where would different behavior on different days even come from?

From two bricks meeting. The processor can compare two numbers. And the processor's marker — its place in the row of command-cells — is itself changeable: the action "choose what's next" moves the marker, to one address or another, depending on the comparison's outcome. That is the entire mechanism, and it deserves slow reading: the program text contains BOTH continuations, written once and forever; which one runs is decided at run time by whatever numbers the comparison happens to meet. The text is fixed; the path through it is not.

compare A, B A < B ? yes: marker to cell 600 no: marker to cell 640 actions of branch 1 actions of branch 2 Both branches exist in the text forever. The data chooses which one becomes conduct.

Nothing here violates the clock: still one action per tick, still strict sequence — the sequence of performed actions is as orderly as ever. What changed is that this sequence is no longer a copy of the text's order. Two runs of one program are two different journeys through the same country.

Продолжите этот урок на YourAIZone

В полном уроке — объяснение целиком, разобранные примеры, частые ошибки, тесты с мгновенной проверкой и ИИ-репетитор. Начните сразу как гость или создайте аккаунт, чтобы сохранять прогресс.

В полном уроке

  • Объяснение целиком
  • Разобранные примеры
  • Частые ошибки и как их избежать
  • Тестовые вопросы: 2
  • ИИ-репетитор, который отвечает на вопросы по теме
  • Отслеживание прогресса для ученика, родителей и учителя