Basic knowledge of microcomputer principles

Source: Internet
Author: User

1. Number of machines and real values

The computer can only represent 0 and 1 types of digital. To represent positive and negative numbers, you need to select a specific symbol to represent the number. Generally, the highest digit is selected, when the sign bit is 0, it indicates a positive number, and when the sign bit is 1, it indicates a negative number, that is, the number symbol is digitalized in the computer.

The representation of a number in a computer is called the number of machines. The value of the actual number itself is called the true value.

Features of the number of machines:

(1). Number of machines plus or minus signs;

(2) The size of the range indicated by the number of machines is limited by the length of the machine word.

Bit: the minimum data unit that a computer can represent. It only has two states: 0 and 1, indicating a larger number. More digits must be combined as a whole, each time a bit is added, the number that can be expressed is doubled.

The concept of byte: an 8-bit binary number is the basic unit for data processing by computers. The memory of a microcomputer is composed of one storage unit, and each storage unit is one byte, therefore, memory is stored in bytes, and the size of the storage capacity is also measured by the number of bytes.

Word concept: when a computer processes data, the CPU accesses, processes, or transfers data once through the data bus. It is usually composed of one or more bytes.

The concept of Word Length: the number of binary digits of a word. The length of a word is the length of the actual number of digits that a computer can process at a time. Therefore, word length is an important indicator of computer performance. Generally, the number of digits in a computer is the length of the word.

(3). the decimal point cannot be marked directly. You must specify the decimal point location in a certain way.

2. Expression of the number of symbols:

In order to solve the problem of calculating the number of machines with symbols in the machine, three different formats of machine number X are introduced.

Set x = x (1) x (2) x (3 )... X (n-1), where X (I) is a binary number, I = 1, 2 ,..., (n-1 ),

(1). Source Code

If X> = 0, [x] original = 0 x (1) x (2)... x (n-1 );

If x <= 0, [x] original = 1 x (1) x (2)... x (n-1 );

According to the definition

[+ 0] original = 0 0 0 0 ..

[-0] original = 1 0 0 0 0...

Advantage: simple representation, easy to convert to true values;

Disadvantage: You need to determine the symbols during the operation to increase the computing time of the machine;

(2) Anti-code

If X> = 0, [x] is reversed to 0 x (1) x (2)... x (n-1 );

If x <= 0, [x] is reversed to 1 x (1) x (2)... x (n-1 );

According to the definition

[+ 0] inverse = 0 0 0 0 0 ..

[-0] inverse = 1 111111 ..

(3). Supplemental code

If X> = 0, [x] is supplemented with 0 x (1) x (2)... x (n-1 );

If x <= 0, [x] fill = [x] Reverse + 1;

According to the definition

[+ 0] fill = 0 0 0 0 ..

[-0] fill = 00 0 0 0...

Advantage: complement code facilitates computation;

3. complement operation

(1) If X is negative, [[x] fill = [x] original

(2). = +
The language expression of this formula is that the complement code of the sum of two n-bit binary numbers is equal to the sum of the two complement codes.
When the two numbers with symbols are expressed in the form of supplementary codes, the addition operation can calculate the symbol bit and the value bit together (if the symbol bit has a forward bit, it will be discarded ), the result is a complement of the sum of two numbers.

(3). = +
This formula indicates that the sum can be used for the sum.
Here, the negative operation is performed on the subtrahend, that is, the negative number indicated by the complement code (whether positive or negative) is obtained using the complement code (if it is a positive number, negative. It turns out to be a negative number. Positive is obtained after negative ). Generally, it is known that the obtained process is variable or negative. When the two signed numbers are represented by the complement code, the subtraction operation can be implemented by "changing the complement addition", that is,-= +

Note: [-y] Complement Method: For [y] fill "with the symbol bit, change to anti-add 1 ";

4. Solution to overflow in complement operations

(1). Use double sign bits.

(2). Use carry

5. Fixed Points and floating points

(1). The number of decimal points is fixed in the number.

Two Representation Methods: Fixed Point pure decimal point and fixed point pure integer;

(2). floating point notation;

N = 2 P S

N indicates a floating point number or a real number,

S indicates the ending number of N, which is represented by a signed decimal point. Generally, it is represented by the original code. The length of the ending number specifies the valid digits (precision) of the number)

2 indicates the base number of N,

P indicates the exponent, called the order code. It is expressed by a signed integer and generally by a complement code. The size of the order code specifies the range of numbers;

Floating point representation

Number of tail characters of the level code;

The level sign indicates the sign bit of the level code. 0 indicates positive, and 1 indicates negative;

The tail sign indicates the symbol bit of the number of digits. 0 indicates positive, and 1 indicates negative;

Normalized floating point number: meets the 0.5 <= S <1 limit;

(3) IEEE floating point representation method

6. BCD code

BCD code:
BCD (Binary coded decimal) is a decimal number expressed in binary encoding (see Table 3.3). The decimal number ranges from 0 ~ Ten digits are the most commonly used. In a computer, the same number can be expressed in two BCD formats: ① compressed BCD code ② non-compressed BCD code

Compressed BCD code:
The compressed BCD code uses a four-digit binary number to represent a decimal digit. The entire decimal number is represented by a string of BCD codes. For example, the number of decimal places 59 indicates that the compressed BCD code is 0101 1001, and the number of decimal places 1946 indicates that the compressed BCD code is 0001 1001 0100.

Non-compressed BCD code:
Non-compressed BCD codes use eight-bit binary numbers to represent a decimal digit. Four lower BCD codes and four higher BCD codes are 0. For example, 78 in decimal format indicates that the compressed BCD code is 0000 0111 0000 1000.

When inputting data from the keyboard, the computer receives an ascii code. It is very easy to convert the number represented by the ASCII code into a BCD code, as long as the four-digit high ASCII code is cleared.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.