Assembly Experiment 2 programming with machine instructions and assembly instructions

Source: Internet
Author: User

Lab task

(1) use DEBUG to write the following program segments into the memory and execute them one by one. Fill in the blanks based on the actual running conditions of the commands.

A. Use the e command to modify the value of 0021:0 ~ 0021: F Data is 30 h, 31 H, 32 h, 33 H, 34 h, 35 h, 36 h, 37 h, and can be viewed.

B. Write the following program segments into the memory.

MoV ax, 0021

MoV ds, ax

MoV ax, 2200

MoV SS, ax

MoV SP 0100

MoV ax, [0]; AX = 3130 h;

Add ax, [2]; AX = 6462 h;

MoV BX, [4], BX = 3534 h;

Add Bx, [6]; BX = 6c6ah;

Push ax; SP = 00feh; the address of the modified memory unit is 2200: 00feh and the content is 6462 h;

Push BX; SP = 00fch; the address of the modified memory unit is 2200: 00fch, And the content is 6c6ah;

Pop ax; SP = 00feh; AX = 6c6ah;

Pop BX; SP = 0100 h; BX = 6462 h;

Push [4] sp = 00feh; the address of the modified memory unit is 2200: 00feh, And the content is 3534 h;

Push [6] sp = 00fch; the address of the modified memory unit is 2200: 00fch, And the content is 3736 h;

The above is my theoretical analysis of this Code. Let's take a look at the specific operations.

A slight error occurred during the input, but it doesn't matter. Continue to make up (I don't know if it has any impact on the memory space)

 

The values of ax and BX comply with the theoretical values. The first SP also matches.

 

 

Check the memory unit to meet the expected value.

(2) observe the experiment process shown in Figure 3.19 and analyze the cause ~ 2000: will the content in F change?

Input seven lines of commands and call it again. The compilation code needs to be typed more. Run the e command to modify the 16 memory unit values after,

Then run the D command to view the memory unit. The modification is successful.

The value starting from 2000:0 has not changed.

 

In this step, the value of F starts to change at. If the mov SS and 10 operations are missing, the value of the SS segment register changes to 2000, and the address of the data segment changes,

Stack loading and Operation

Stack 3366h,

The function of the first line of code is to assign the value of ax to 2000 and the value of the SS segment register to 2000. At this time, the top of the stack is 2000:0010, mov sp, 10, after reading the information, we found that 10 Memory Spaces are reserved for the following registers, such as CS.

As for the interrupt mechanism written in the book, that is, every time debug uses t to execute the command, it will stop executing and display the status of each memory and the next operation. The above mov SS, 10 must have been executed, however, the next stack cannot completely restore the state of the memory in the previous step, so the value of the F' memory unit after 2000:0 has changed.

Summary and reflection

1. also need to pay attention to push is sp-2, pop is SP + 2, the stack of the empty stack is 0010 h at the top.

2. For the-D command, you can observe the content of one or more memory units at a time, which is helpful for the experiment.

3. Check the information to get a preliminary understanding of the process of the interrupt mechanism, which should be paid attention to in future assembly programming.

4. The compilation language should also be frequently written and written incorrectly. Press enter more ......

Assembly Experiment 2 programming with machine instructions and assembly instructions

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.