x86 CS and IP detailed

Source: Internet
Author: User

CS and IP are the two most critical registers in 8086CPU, which indicate the address at which the CPU is currently reading instructions.

CS is the code segment register.

The IP is the instruction pointer register.


In 8086PC, at any moment, the content in CS is m,ip content is n,8086cpu will start from memory (m*16) +n unit, read an instruction and execute.

It can also be said that: 8086, at any time, the CPU will CS:IP point to the content as an instruction execution.

Figure 2.10 shows how the 8086CPU read and execute instructions work (the figure contains only parts that are closely related to the problem to be explained, and the numbers in the figure are 16 binary).

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/5A/65/wKioL1T9Ht7AebYYAAFd0mOVqYE522.jpg "title=" 134954511.jpg "alt=" Wkiol1t9ht7aebyyaafd0movqye522.jpg "/>

Figure 2.10 illustrates the following.

(1) 8086CPU current status: CS content is 2000h,ip content is 0000H;

(2) The memory 20000h~20009h unit holds the executable machine code;

(3) The assembly instruction corresponding to the machine code stored in the Memory 20000h~20009h unit is as follows.

Address: 20000h~20002h, content: B8 23 01, Length: 3Byte, corresponding assembly instructions: MOV ax,0123h

Address: 20003h~20005h, Content: BB 03 00, Length: 3Byte, corresponding assembly instruction: MOV bx,0003h

Address: 20006h~20007h, Content: D8, Length: 2Byte, corresponding assembly instructions: MOV AX,BX

Address: 20008h~20009h, Content: D8, Length: 2Byte, corresponding assembly instruction: add AX,BX


The following picture (Figure 2.11~, figure 2.19), described in Figure 2.10 as the initial state, shows the 8086CPU read, execute an instruction process. Note the changes that take place in each picture (the description of the 8086CPU below is in the logical structure, macro-process level, the purpose is to enable the reader of the principle of the CPU has a clear, intuitive understanding, for assembly language learning lay the foundation. The physical structure of the CPU and the specifics of the work are concealed.


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5A/65/wKioL1T9IOTSW5MTAAFUhO19OLU818.jpg "style=" float: none; "title=" 135102694.jpg "alt=" Wkiol1t9iotsw5mtaafuho19olu818.jpg "/>

2.11

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5A/69/wKiom1T9H8mA794ZAAFjMQB-MKU020.jpg "style=" float: none; "title=" 135130276.jpg "alt=" Wkiom1t9h8ma794zaafjmqb-mku020.jpg "/>

2.12

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5A/65/wKioL1T9IQOSSsvIAAFZ3xZDLPE649.jpg "style=" float: none; "title=" 2.13.jpg "alt=" Wkiol1t9iqosssviaafz3xzdlpe649.jpg "/>

2.13

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5A/69/wKiom1T9H-jhp0KyAAFcq_N-iak318.jpg "style=" float: none; "title=" 2.14.jpg "alt=" Wkiom1t9h-jhp0kyaafcq_n-iak318.jpg "/>

2.14

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5A/65/wKioL1T9IQOy-fGvAAFFwfj4R_U526.jpg "style=" float: none; "title=" 2.15.jpg "alt=" Wkiol1t9iqoy-fgvaaffwfj4r_u526.jpg "/>

2.15

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5A/65/wKioL1T9IQOwRCH-AAFO-f17j78318.jpg "style=" float: none; "title=" 2.16.jpg "alt=" Wkiol1t9iqowrch-aafo-f17j78318.jpg "/>

2.16

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5A/69/wKiom1T9H-iST7G6AAFPgG0RGjI640.jpg "style=" float: none; "title=" 2.17.jpg "alt=" Wkiom1t9h-ist7g6aafpgg0rgji640.jpg "/>

2.17


(after reading an instruction, the value in the IP automatically increases so that the CPU can read the next instruction.) Due to the current read-in instruction B82301

The length is 3 bytes, so the value in the IP is added to 3. At this point, Cs:ip points to memory unit 2000:0003. )


x86 CS and IP detailed

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.