Assembly language Learning

Source: Internet
Author: User

Fragmented records:

The 8086CPU registers are 16-bit and can hold two bytes; The 4 registers, AX, BX, CX, DX, are commonly used to hold general data, known as general-purpose registers.
Ax:

In 8086CPU, the four registers can be divided into two independent use of 8-bit registers, with the-H and-L for the left and right eight bits;

Instruction Mov,add: Left operand = left operand and right operand operation result.

Physical Address method in 8086CPU: Two 16-bit addresses synthesize a 20-bit physical address:
Segment Address x16+ offset address = Physical address;
' Segment Address x16 ' is visualized as the base address, memory is also managed in this segmented memory; segment register: CS and IP, both indicate the address of the instruction currently being read by the CPU, CS is the code segment register, and IP is the instruction pointer register, and if CS is M,ip N, 8086CPU will be from memory mx The 16+N unit begins reading an instruction and executes it.

CS and IP cannot be changed by MOV, can be used ' jmp ' command, shaped like "jmp segment Address: Offset Address", this is modified both content, if only want to modify the content of IP, can be used "jmp a legitimate register", such as jmp ax or jmp bx.
Finally, pay attention to the CPU's working process:
① reads the instruction from the memory unit pointed to by the CS:IP, and reads the instruction into the instruction buffer;
②ip refers to a downward instruction;
③ executes the command. (Go to ① repeat step).

Use of debug in DOS:
/* for debug in Win10
1. One method is to select the command line mode by pressing F8 enter mode when the boot interface is turned on.

2. In the graphical interface:
If there is the best debug, no words win+r input command;
My WINDOWS10 family version does not have the debug program also cannot run the command, can only own the way out, for example the degree Niang; emmm, share.
Download a DOSBox, and then directly open Sogou Search to download a debug.exe;
Install DOSBox, preferably choose to install the disk outside the C drive (System disk), to avoid problems, then open the installed folder DOSBox 0.74 Options.bat file, pull to the bottom, add the following code:

  

You can also enter code in DOSBox, but do this to avoid losing each time you open it.
In the command, D is the real disk as a virtual drive: \dosbox_self is a custom folder, then add the Debug.exe that are not included, put the downloaded Debug.exe into the folder, open the DOSBOX input debug to use.

Normal use:

*/
-R: View, change the contents of CPU register;
View CS and IP values, such as:

Where CS is 073f,ip is 0102, that is, the CPU is currently reading CS:IP that is 0X74F2 instruction, and in debug also shows the memory unit stored in the machine code, for UH. 0000, followed by the assembly instructions for translation.

Use the r instruction to change the value in the register, such as:

-D: command to view the content, such as D 1000:0, the "-D segment Address: Offset Address" form, the next 128 cells will be displayed, the right is the ASCII value;

Can try D 1000:9, the same output 128 unit content, again such as D 1000:9 9 can control the output;

-E: Overwrite the contents of memory, one is shaped like E 1000:0 carriage return, there will be the next line per byte value, '. ' After directly entering the modified value, the space does not modify or continue to the next, enter the end; the second form e 1000:0 "FDFD" "DFDS" 12 121; with-R can be viewed, but the machine code is written such as: B8 (mov ax,0001), b90200 (mov cx, 0002), 01c8 (add ax,cx), the-D command cannot display the code, can be viewed with the-u command (Shape u 1000:0)

The-t command can be used to execute the instructions we write, but you must first have Cs:ip point to the command unit you want to execute, one instruction at a time:

Each register value changes with the instruction;

-a command writes the machine instruction in memory in the form of assembly instruction: form:-A 1000:0 (1000:0 is the preset address of the input instruction)

Enter the end of the return, the-D command to view the machine code.

Each instruction can indicate that the instruction and the data are essentially the same in the machine.

View register information, modify the modification register:-R;

View Memory Unit Contents:-D;

Modify Memory Unit Contents:-E;

Explanation of memory contents for machine code and corresponding assembly instructions:-U;

Execute CS:IP point to the memory unit:-T;

Write assembly instruction into memory:-A.

In the PC and the motherboard ROM is written with a production date, in memory Fff00h~fffffh some units, where the content can not be modified, and can not be controlled with the output length of D, because it is read-only memory area.

がんばって

Assembly language Learning

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.