Sufficiently creative use of bits has gotten us very large integer values in base 2. Now let's look at something that's not numerical: text symbols like the letters A, B and C. Clearly we want to store text in computer memory: documents, people's names, Emails, etc. How do we do that?
As you can see in the diagram, we can store Roman alphabet letters (standard English letters A-Z) by assigning a numerical value for each letter. So, in our example we see a one byte binary value containing the numerical value 65 (a 1 in the 64s place and a 1 in the 1s place). We'll say that 65 stands for capital A and make 66 stand for B, 67 for C, etc., assigning a unique numerical value to each letter from A to Z.
This is not a completely unfamiliar idea if you think about Morse code, which you may have encountered at some point. It represents each letter with a series of dots and dashes -- in effect 1s and 0s. We're doing something similar here, giving each letter a particular 8-bit 1 and 0 pattern.
If we agree that a certain area of memory is meant to store text, we can store one "letter" per byte using this numerical system, so a 1000 character Email could be stored in 1000 bytes, with each byte holding the number-code for one of the characters.
It may seem an odd choice to use 65 for A, but it turns out that the standard system for assigning numbers to letters does this. It's called ASCII code, and it's used in just about every program in one way or another (possibly as part of a more modern code we'll see in a minute). ASCII stands for American Standard Code for Information Interchange. You do not need to remember that. Just remember the term ASCII, in capitals because it's an acronym. ASCII code does use 65 for A, 66 for B, etc. and it also has a different set of numbers for the lowercase letters, starting with 97 for lowercase a and 98 for lowercase b.
ASCII even has numerical codes for symbols you might not think of. For instance, there is a code for each punctuation symbol: $, #, % etc. Even a blank space counts as a "symbol", and has an ASCII code: number 32 in fact. You don't have to remember the actual numbers, just the principle that by assigning numbers to symbols, we can represent letters as well as many other symbols such as punctuation and spaces.
Look up the full ASCII table online and translate this sequence of ASCII values into its textual equivalent: 72, 101, 108, 108, 111.
Answer 1
There are a total of 128 different ASCII codes from 0 to 127. So 128 symbols may be represented by the ASCII system. This is sufficient to express anything you would type… in English. The "American" in the name for the code reflects a bias. Back in the day ASCII was created, in the early 1960s, this seemed sufficient. But of course limiting the system to English text alone is today pretty chauvinistic.
A newer symbol-coding system is displacing ASCII. This system is called Unicode and it includes a much wider variety of symbols. Like ASCII, it uses a numerical value for each symbol, but it has no limit on the values. The original 128 ASCII code numbers are included in the Unicode system as the first 128 values, but all values above that are for other symbols, representing just about every form of writing on the planet. For example, here's Unicode 20320. It represents the Chinese ideographic symbol ni3. And the next one, 22909, is the Unicode for the Chinese ideographic hao3. The two together are ni3hao2, the standard Mandarin "hello".
Unicode symbols typically take 2 bytes each to store, which allows values up to 65535. (There are Unicode symbols with higher values, but they are less commonly used.)
In our assembly programs, we'll use ASCII, since assembly generally uses the older system. However, if you're learning a newer language like Java, Python or C#, Unicode is wired in.
Some of what we'll study in assembly code will require understanding how binary numbers are added and subtracted. Let's start with binary addition, leaving subtraction for later.
It's easiest to understand binary addition by analogy from base-10 addition, so at the risk of sounding silly, let's recall a few details of how that works. When we add two multidigit base-10 numbers:
Binary addition works in the same way, except that each digit is a 0 or a 1, and carries happen a lot more frequently. Instead of carrying when a result is greater than 9, we carry when the result is greater than 1. If both digits are 1, then a result of 2, or 10 in binary, results in a 0 value for the sum digit, and a carry of 1. Translating the five rules from above into binary form:
Answer 2