Information in the computer = bit + context (RPM)

Source: Internet
Author: User

Information in the computer = bit + context. Further, the information can be divided into two main categories: one is data, the other is instruction. The instruction is used to indicate the action of the operation, and the data is used to indicate the object being manipulated, both of which constitute a complete program.

For data, let's first talk about the representation and operation of integers. Unsigned encodings represent unsigned numbers, and the complement represents the number of symbols, and I believe you should be very familiar with the two encodings (unsigned encodings have no sign bits, and the highest bit of the complement represents the sign bit).

There are two kinds of integers, one is arithmetic, and the other is logical operation. Arithmetic operation refers to the usual addition and subtraction multiplier, of course, pay attention to overflow, sign bit and other situations (this speaks up too much, and I also worry that I do not speak well, do not understand the reader can go through the book). The logical operation mainly includes the shift operation, or with the non-equal, for the shift operation, must pay attention to is the arithmetic right shift or the logical right SHIFT, the algorithm moves right in the missing position to be filled the sign bit, the logical right moves to be filled zero.

Because of the floating-point expression and operation, I also mastered not too good, the reader himself turn the book.

For instructions, there are routing instructions, arithmetic instructions, logic instructions, jump commands, and instructions to support the procedure call and return. These directives correspond to the structures in C, and I will explain them to you.

The transfer instruction is mainly mov A, b this form, such as the assignment in C language and the value of taking a variable, etc. will eventually be translated into such instructions. There are three ways of addressing the delivery instructions. The first method is an immediate number addressing, in the form of MOV $imm, EM, which means that the IMM is transmitted to register or memory em, and the second way is the register address, in the form of MOV ea, EM, which means that the value of the register Ea is transmitted to EM; The third is the memory address, in the form of MOV (EA), EM, which means that the value of the memory location represented by the value in the register is transferred to EM, but this has a lot of distortion, but the essence is the same. Note that you cannot transfer from memory to storage.

In arithmetic and logic directives, such operations as subtraction, or versus non, shift operations do not have to be said, and in the C language these actions are basically no different from the assembly. I mainly say the Lea, that is, loading the valid address instruction, which is the distortion of the MOV instruction. The instruction form is Lea S, D, the effect is to transfer the address of S to D, where D must be a register, like the C language of the address operation & corresponding to this assembly language. For example, the Lea (Ea), EB, in the Mov instruction indicates that the value of the memory location represented by the value in the register is transferred to the EB, while in the LEA instruction the value of the register Ea is transferred to the Register Eb. You can also use this command to perform some arithmetic operations.

Jump commands mainly include unconditional jump and conditional jump, unconditional jump in the form of jmp label or JMP *operand, the latter's jump target is read from the register or memory. For conditional jumps, only if certain conditions are met to jump, such as JE, jne, etc., then in the assembly is how to know that these conditions are not set up? In addition to the integer registers, the CPU also contains a set of single-bit conditional code registers, such as CF (unsigned overflow), ZF (0), SF (negative), of (signed overflow), which describe the properties of the most recent operation, and some instructions specifically for setting the condition code without modifying other registers, like Test, CMP. The jump instruction determines whether to jump based on the combination of these criteria codes. In C, like if, for, while, and switch languages will eventually be translated into jump instructions.

The last instruction is to support the procedure call and the returned instruction. Where the call instruction is used for procedure calls, the RET instruction is used to return from the procedure call. The process in the C language is eventually translated into the procedure call code in the assembly. There are 8 integer registers in the x86 system, of which two registers support the implementation of the process, namely the stack pointer%esp, the frame pointer%ebp. When the call label is executed (the label represents the called token, which can also be the form of *operand), the computer will return the address (the caller's next instruction address) into the stack, the value held in the frame pointer (the caller's frame pointer) into the stack, and finally the value saved in the stack pointer to the frame pointer. The following is the execution of the instructions in the callee, when the execution of RET returns is the reverse of the call instruction, the value of the frame pointer is saved to the stack pointer, then push%EBP, the return address is updated to the program counter, continue to invoke the execution of the function.

Http://www.cnblogs.com/yilinglingyi/p/4224918.html

Information in the computer = bit + context (RPM)

Related Article

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.