Assembly language (Wang Shuang) a test

experiment one

A, Debug use

1.1 What is Debug

To view the contents of various registers in the CPU, memory and operating situation of the machine code level tracking program tools.

1.2 Debug functions used

· Check with the R command, change the contents of the CPU registers

· Check the contents of memory with the command D

· Rewrite the contents of memory with the E command

· Use the U command to memory translated into machine instructions assembly instructions

· Execute a machine instruction with T command

· Format of the assembler instruction writes a machine instruction in the command memory with the A

In 1.3 win10 enter Debug

Open dosbox, enter the debug command line

1.4 Check with R commands, change the contents of CPU registers

It is known that the AX, BX, CX, DX, CS, IP six registers, other registers first ignored

Input r
Here Insert Picture Description
Note that the values of CS and IP, CS = 0740, IP = 0100 , the memory 0740 that is to say: the instruction for the CPU 0100 to read the current instruction execution, is also listed at the bottom of the CS: IP points memory storage unit at the machine code instruction and translates into assembly

Input r register name content register

Here Insert Picture Description

Re-enter r structure after modified viewable

1.5 Check the contents of memory with the command D

D more command format, only the introductory part, using the d address segment: offset address format to view, Debug lists the contents from the specified memory cell of the memory cell 128, the input d 1000: 0 after listed Debug 1000: content 7F: 0 ~ 1000

If the input D 1000: 9 output is shown, from 1000: 9 display start until 1000: 88, with the output of the hexadecimal format, the output of each line starts from an address integer multiple of 16, a maximum output of 16 units of content, the middle "-" 8 units each of the left and right, easy to view, the rightmost display the ASCII code corresponding to each memory cell data can be displayed, if there is no corresponding ASCII code, instead of using "."

Here Insert Picture Description
Using the d address segment: offset address after, then use d , can follow list the contents of the same format

After entering a Debug, use d directly view, Debug will list the contents of a preset address

D can also command to check the specified range, the use of d Address segment: offset address of the end of the start offset address format, such as to look at 1000: 0 1000: 9 content can be used d 1000: 0 9 achieved
Here Insert Picture Description
if wanted See content of the memory cell 10000H, there are many possible methods, since the figure of all segment address: offset address are the physical addresses 10000H shows
Here Insert Picture Description
the contents of memory 1.6 rewrite command E

Can e ...... start address of the data format to perform, such as the memory 1000: 0 1000: Write the contents of unit 9 is 0,1,2,3,4,5 ......
Here Insert Picture Description
these data may also be character

Here Insert Picture Description
Or a string
Here Insert Picture Description
can be individually modified, such as entering e 1000: 10 Enter, the original content will be displayed starting address, we enter a new value in the following, the next address value is performed by the space. "" modify, if do not want to modify, press space to the next address, press Enter to exit the rewrite is completed after
Here Insert Picture Description
1.7 written in machine code using the command E, U command to check the meaning of machine code, T command execution machine code

Machine code is data, the same method can be used to machine code corresponding to the binary number written to memory, the memory 1000 in our example: writing a piece of data units 0
Here Insert Picture Description

mov ax,0001H      b80100
mov cx,0002H      b90200
add ax,cx        01c8

Use U command from 1000: the beginning of the contents of the memory unit 0 in the translated assembly instructions, and displayed

Here Insert Picture Description

One or more instructions may be executed using the command T

First check registers in the CPU R command status
Here Insert Picture Description
observed CS: IP to point memory cell has not requested so modified CS, IP R command with the contents of the CS: IP to point 1000: 0
Here Insert Picture Description
Next, the T command is executed. after the T command, CPU execute CS: IP to point to the instruction, the instruction execution, Debug display state of the CPU registers, the process continues using the T command, we should pay attention to changes in AX, CX, IP value

Here Insert Picture Description

1.8 A with a command written in the form of instructions compiled machine instructions in memory

Prior to writing the machine with the E inconvenient command instructions, preferably written directly in the form of assembly instructions, which uses command A, as shown in FIG from 1000: a write command in the memory unit zero, A 1000: 0

Here Insert Picture Description

On the carriage after the write address given assembler instructions, assembler instruction is written to continue, press ENTER signals the end address is given directly after the

Can simply use the command A, A i.e., an initial address is not specified, the start address from a predetermined input command

Second, the experimental

2.1 ** ** E command using the command A and the following two ways to write instruction memory, and executed one by one related changes were observed in the CPU register (be careful not to add H at the time of writing assembler instruction)

机器码					  汇编指令
b8 20 4e				mov ax,4E20H
05 16 14				add ax,1416H
bb 00 20				mov bx,2000H
01 d8					add ax,bx
89 c3					mov bx,ax
01 d8					add ax,bx
b8 1a 00				mov ax,001AH
bb 26 00				mov bx,0026H
00 d8					add al,bl
00 dc					add ah,bl
00 c7					add bh,al
b4 00					mov ah,0H
00 d8					add al,bl
04 9c					add al,9CH

2.2 The following written instructions 2000 3: 0 starts in the memory unit, calculation instruction using three 8 th power of 2

mov ax,1
add ax,ax
jmp 2000:0003

A: The 8 cycles, the result is 100H (square 16)

2.3 ROM on the system board to write the PC has a production date, in a few units of memory FFF00H ~ FFFFFH, find the production date and try to change it

A: You can not be modified because ROM is a read-only memory, can not be modified

2.4 Fill B8100H from the start of the unit memory data such as:

e B810:0000 01 01 02 02 03 03 04 04

Experiment with different data or fill out a different address

A:
Here Insert Picture Description
After the transport of the pattern is displayed as outputs the corresponding content on the display of the A0000 ~ BFFFF memory address space, the input data segment address.

The distribution of specific 8086PC machine memory address space can look at the first chapter 1.15

Published 84 original articles · won praise 7 · views 10000 +

Guess you like

Origin blog.csdn.net/weixin_43569916/article/details/104227611