Debug Command supplement
In executiond
The command can contain the address parameter (segment address: Offset address), where the segment address is first sentds
Register and then hand it over to the processor.
Therefore,d
The command can also be used as follows:d SR:offset
(SR refers to segment register)
For example:
-R ds: 1000-d DS: 0; view the content in the memory range starting from 1000:0
-R ds: 1000-d DS: 10 18; view 1000:10 ~ Contents in
-D Cs: 0; view the instruction code in the current Code segment
-D ss: 0; view the content in the current stack segment
Of coursee
Commands,a
Commands andu
The same is true for commands.
For example:
-R ds: 1000-e DS: 0 11 22 33 44 55 66; write data in the memory range starting from 1000:0
-U Cs: 0. The code in the current Code segment is displayed in the form of assembly instructions. The offset address of the code 0 is displayed.
-R ds: 1000-a DS: 0; write commands to memory units starting from 1000:0 in the form of Assembly commands
Interesting phenomenon
When you execute the following code, you will find thatt
The command will not work:
mov ax, 2000 ; 1mov ss, ax ; 2mov sp, 10 ; 3mov ax, 3123 ; 4push ax ; 5mov ax, 3366 ; 6push ax ; 7
Shows the result of one-step execution:
It can be seen that lines 2nd and lines 3rd are executed together (I am different from the presentation in books, and may be related to the software version ).
We need to know what is going on in the future: when executing the command to modify the SS register, the next command will be executed together.
Lab
This experiment is a 3rd-page experiment task in assembly language (Wang Shuang, 74th ).
Write the following program into the memory, execute and fill in the blanks:
To verify the experiment results, make the following two adjustments:
- In use
a
Rune
Command to set the memory unit0021:0
To0021:7
Change 8 bytes of data30H
,31H
,32H
,33H
,34H
,35H
,36H
,37H
- Set
mov ax, ffff
Changemov ax, 0021
MoV ax, 0021mov ds, axmov ax, 2200mov SS, axmov sp, 0100mov ax, [0]; AX = _ 3130_add ax, [2]; AX = _ 6462_mov BX, [4]; BX = _ 3534_add BX, [6]; BX = _ 6c6a_push ax; SP = _ 00fe _; the address of the modified memory unit is _ 220fe _ and the content is _ 6462_push BX; SP = _ 00fc _; the address of the modified memory unit is _ 220fc _ and the content is _ 6c6a_pop ax; SP = _ 00fe _; AX = _ 6c6a_pop BX; SP = _ 0100 _; BX = _ 6462_push [4]; SP = _ 00fe _; the address of the modified memory unit is _ 220fe _. The content is _ 3534_push [6]; SP = _ 00fc _; the address of the modified memory unit is _ 220fc _ and the content is _ 3736 _
The following figure shows the running result:
This experiment reports an error in freedos, as shown in:
Finally I had to use a MS-DOS, I analyzed the reason is that freedos is not fully compatible with 16-bit assembly appearoperand size mismatch
Why?2000:0
~2000:f
Will the content in change?
Shows the running result:
After careful observation2000:a
To2000:d
The data in the memory is stored according to the small-end method.cs
Andip
According to the online materials, this is to temporarily save some running environment variables when defining the stack segment. The saved data in the 10 bytes near the top of the stack isss
,ip
,cs
I have not verified whether the value is correct, but it should be related to the system scheduling.
In my opinion, assembly is a required course for computer science. In computer systems, it is good to take a single course. What really needs to be learned is not how to use it. This is to make up for the basic knowledge of a Computer Major. If you learn something that is useful, there is no return. If you only see 1% of one thing, it does not mean that you see the remaining 99%. If you are not sure about all the factors, you can do a good job of yourself. Do something, while you are still young.
Invictus Maneo.
Experiment 1-programming with machine instructions and assembly instructions (2)