Experiment 2 programming with machine instructions and assembly instructions

Source: Internet
Author: User

1. Prerequisites:

Run the T command to modify the stack register SS commands, such as mov SS, ax, mov SS, [0], pop SS, etc, its next command for modifying the offset SP address is also followed by execution. Generally, after executing a command using the T command, it will stop executing, the status of each register of the current CPU and the command to be executed in the next step are displayed, but this is not done in the above case. This phenomenon is part of the post-learning content: the interruption mechanism.

2. Lab tasks

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

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 modified memory unit address is 2200: 00fe. The content is 6462 H.

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

Pop ax; SP = 00feh, Ax = 6c6ah

Pop BX; SP = 0100 H, BX = 6462 H

 

Push [4]; SP = 00feh. The modified memory unit address is 2200: 00fe. The content is 3534 H.

Push [6]; SP = 00fch. The modified memory unit address is 2200: 00fc content is 3736 H.

 

Rewrite with the E command, and write with the command:

 

Result of one-step operation:

 

 

Data in the stack address:

 

 

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

 

Figure 3.19 example of an experiment using debug

 

 

A: The use of commands such as t in debug causes interruptions. the interruption process uses the current stack space to store key CPU data. Therefore, some data in the stack is not operated by us.

If the stack is out of bounds during the interruption process, the command window in windows will be forced to close.

 

Experiment summary:

 

During debugging, different commands may be assigned to different register addresses. The command address is CS, the data segment address is DS, And the stack segment address is ss; you cannot assign values to segment registers directly or indirectly by assigning values to other registers. The top of the initialization stack is determined by the point of the SS: SP address. When using the stack, the CPU cannot automatically identify the stack size, and there is a risk of stack overflow.

 

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.