Programming with machine instructions and assembly instructions (Modified Version)

Source: Internet
Author: User
  • Program the experiment name using machine commands and assembly instructions (1)
  • Lab Date: 8.8.10.22
  • School: Software Institute
  • Major: Computer Science and Technology
  • Grade: Level 2017
  • Shift: 5
  • Name: Chen yiming
  • Student ID 20171308194


I. Tutorial Purpose 
1. understand how to use the debug tool to compile and debug assembly commands.

2. master the basic knowledge about CPU, registers, and memory in Chapter 2.

3. Master the usage of several commands mov, add, sub, and JMP in Chapter 2.


2. Test preparation 
1. Review teaching materials 1st ~ 2 Chapter content, complete the relevant test points in the Teaching Material

2. Learn the usage of the debug tool by combining the tutorial 1 (p35) and the public mail document center → the tutorial 1 文.pdf 1→ →.


Iii. experiment content 
1. Tutorial 1 (p35)

(1) Practice Teaching Material P35-45 "Preparation knowledge: Debug use", learn debug start, exit and common instructions usage;

(2) Complete lab tasks on the basis of the exercises 」

TIPS: "2. Experiment task" each task can find clues in the preface to the teaching material or in the exercises. We recommend that you complete item (1) of the content and content required in "2. Experiment Preparation" so that it is easy to complete the "2. Experiment task. For example, the experimental task (1) can be completed by referring to the teaching material P41-43 (7); The experimental task (2) is similar and related to the test point of the teaching material P20 (2;


Iv. experiment conclusion 
Task 1:

Write the following program segments into the memory and execute them one by one. Observe the changes in the related registers in the CPU after each command is executed.

First, use the e command to write the machine code command as required by the question (you can find an address at: 0 ):

No way after reaching the text input limit, you can only execute it first. After the execution is complete, check the memory units that have written data... the data is correct.

Run the following command to decompile the machine code:

It is consistent with the Assembly command in the book.

Then enter the assembly command:

In the middle, I couldn't tell the letters "1" and "L", and an error occurred...

After the command is entered, run the-T command in one step:

Data is rewritten for the specified register, just like for class lectures.

If there are too many command lines, use-T + number = to execute all the subsequent commands:

Final result:

Task 2: Write the following three commands into the memory unit starting from 2000:0, and use these three commands to calculate the 8th power of 2.

MoV ax, 1

Add ax, ax

JMP 2000:0003

Solution: the 3rd power of 2 is 8. Let's look at the three commands given to us by the question. After the first command is executed, the value of ax is 1, and the value of ax is 2 after the second command is executed. Then we need to execute this statement seven times, so we need to use the JMP command, by changing the Cs and IP register values, the CPU continues to execute this command repeatedly, so it writes seven more JMP statements at so that the CPU executes the second statement repeatedly, so that the value in ax is changed to the eighth power of two .... This is the final result.

Final lab

Question 3

There is a production date written in the ROM on the PC motherboard, in the memory fff00h ~ Find the production date in several units of fffffh and try to change it.

The experiment is as follows:

Failed to modify. It seems that it is because of the RoM relationship and cannot be modified.

Question 4

Fill in data to the unit starting with memory b8100h, for example:

-E b810: 0000 01 01 02 03 03 04 04

This is the result of a series of experiments:

There are some results and insights:

When writing data to the Register, every two bytes of data will generate a new color area, and each time the CS code of the write area is generated, this will generate a line feed for the color block area, and finally get some results.


5. Experiment experiences and insights
This experiment focuses on R commands (used to view and modify the content in registers), d commands (used to view the content in memory), and E commands (used to modify the content in memory), u command (disassembly command), t command (execute code line command)

After so many experiments and tests, it seems that the memory space is memory.

My computer screen runs a very small dosbox window, and finally found that pressing Alt + enter can enter full screen mode for operations.

I have experienced dosbox installation before. Do not install the program on the system disk. Otherwise, there may be permission problems.

For the time being, there will certainly be a lot to learn. We need to make a good study of compilation !!

21:28:25

Programming with machine instructions and assembly instructions (Modified Version)

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.