Experiment 1-programming with machine instructions and assembly instructions (2)

Source: Internet
Author: User
Debug Command supplement

In executiondThe command can contain the address parameter (segment address: Offset address), where the segment address is first sentdsRegister and then hand it over to the processor.

Therefore,dThe 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 courseeCommands,aCommands anduThe 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 thattThe 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 ).

  1. Write the following program into the memory, execute and fill in the blanks:

    To verify the experiment results, make the following two adjustments:
    1. In useaRuneCommand to set the memory unit0021:0To0021:7Change 8 bytes of data30H,31H,32H,33H,34H,35H,36H,37H
    2. Setmov ax, ffffChangemov 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

  2. Why?2000:0~2000:fWill the content in change?

    Shows the running result:

    After careful observation2000:aTo2000:dThe data in the memory is stored according to the small-end method.csAndipAccording 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,csI 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)

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.