If the computer starts in the middle of the stream, it has no way to know—it will be completely confused.
Fortunately, that's not how the protocol works. The computer and terminal have to sync up before they can communicate. There are a few different ways of doing that, but once they're in sync (which includes agreeing on how long each 1 or 0 should last), they both follow a set pattern.
In this example:
- The terminal starts out holding the line high (sending constant 1s) to indicate that it has nothing to say.
- When the terminal has something to say, it brings the line low for a moment (sending a 0). That's the "start" bit.
- The terminal then sends seven bits for the character: always exactly seven, since it's using ASCII, which is a seven-bit encoding.
- After those seven bits, it sends one additional bit for error checking. This is a 1 if there were an odd number of 1s in the character, and a 0 otherwise. This is the "parity" bit.
- Finally, it pulls the line high again to indicate that it once more has nothing to say.
The computer keeps track of which "mode" the connection is in at all times. If it sees a zero, it might record it as part of the data, or might switch from "idle" mode to "start listening for data" mode, or check the parity: it all depends on what it's seen before.