Computer Original language--compilation

Source: Internet
Author: User

8086 of the Addressing method
    • When the CPU accesses the memory unit, it gives the address of the memory unit, all the memory units have a unique address, called the Physical address

    • 8086 has 20-bit address bus, can transmit 20-bit address, 1M addressing capability

    • But it is also a 16-bit structure of the CPU, it can be processed, transmitted, temporarily stored in the address of 16 bits. If the address is simply emitted from the inside, then it can only send out a 16-bit address, showing only 64KB of addressing capacity

8086 generates 1 20-bit physical addresses using a method that is synthesized internally with 2 16-bit addresses

Image.png

Image.png

Image.png

Image.png

Memory Segmentation Management
    • 8086 the physical address is given in the form of "base address (segment address x16) + offset address = Physical Address"

    • For ease of development, we can take a segmented approach to managing memory, such as:

Image.png

    • The memory unit of address 10000H~100FFH consists of a segment with a starting address (base address) of 10000H, a segment address of 1000H, and a size of 100H

    • The memory unit of address 10000H1007FH, 10080H100FFH consists of 2 segments, their starting address (base address) is: 10000H and 10080H, the segment address is 1000H and 1008H, the size is 80H

    • When programming, you can consider a number of contiguous address memory units as a segment, using segment address x16 as the starting address (base address) of the segment, and locating the memory unit in the segment with an offset address

    • Segment Address x16 must be a multiple of 16, so the start address (base address) of a segment must also be a multiple of 16

    • The offset address is 16 bits and the 16-bit address has a 64KB addressing capacity, so the length of a segment is 64KB maximum

Image.png

Segment Register
    • 8086 when accessing memory, it is necessary to provide the segment address and offset address of the memory unit by the relevant part, and feed the address adder to synthesize the physical address

    • What part provides the segment address? Segment address is stored in the 8086 segment register

    • 8086 There are 4 segment registers: CS, DS, SS, ES, which provide the segment address of the memory unit by these 4 segment registers when the CPU needs to access memory

    • CS (Code Segment): Snippet Register

    • DS (Data Segment): segment Register

    • SS (Stack Segment): Stack segment Register

    • ES (Extra Segment): Additional segment Register

CS and IP
    • CS is the code segment register, and the IP is the instruction pointer register, which indicates the address where the CPU is currently reading the instruction

    • At any moment, 8086CPU will refer to the instruction of the CS:IP as the next command that needs to be taken out.

Image.png

Image.png

The execution process of the instruction

12

13

14

15

16

17

18

19

21st

22

23

24

25

26

Summarize

Directives and data
    • In memory or on disk, there is no difference between instructions and data, both binary information

    • When the CPU is working, it sees information as an instruction, and some information as data, giving different meanings to the same information.

Image.png

    • What does the CPU take in-memory information as an instruction?

    • The CPU considers the contents of the memory unit pointed to by CS:IP as instructions

    • If a piece of memory has been executed by the CPU, the memory unit it resides in must be CS:IP pointed to.

JMP directives
    • The CPU from where the execution of instructions is determined by CS, the content of the IP, we can change the CS, IP content to control the CPU to execute the target instruction

    • 8086 provides a MOV instruction (delivery instruction) that can be used to modify the value of most registers, such as

    • mov ax,10, mov bx,20, mov cx,30, mov dx,40

    • However, the MOV instruction cannot be used to set the value of CS, IP, 8086 does not provide such a function

    • 8086 provides additional instructions to modify the CS, IP values, these instructions are collectively referred to as transfer instructions, the simplest is the JMP command

Image.png

Image.png

JMP Instructions-Practice

! [Image.png] (Http://upload-images.jianshu.io/upload_images/2990730-fde7c6e8497e3ffd.png?imageMogr 2/auto-orient/strip% 7cimageview2/2/w/1240)

Image.png

Image.png

Code snippet

Image.png

Image.png

Image.png

Image.png

This article Hank


Computer Original language--compilation

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.