zoukankan      html  css  js  c++  java
  • Assembly Experiment3

    AIMS & PREPARATIONS of THIS EXPERIMENT:

    1st point of this experiment:

    realize the programme t1.asm in DOSBox (code as follow)

    STEPS&SCREENSHOTS of THIS EXPERIMENT:

    ( 1 ). COMPILE, LINK, RUN and DEBUG the PROGRAM t1.exe

    (I used the computer which installed Win7 in lab for the experment, the disks are not virtual)

    1.Creating a txt file (23.txt) in d:epr

    2.Copy the code given above (t1.asm) into the file 23.txt

    3.Compile the programto get the object file

    compile under the Microsoft assembly compiler masm5.0

    by using the original way showed in the book

    I saved the compiled file (.OBJ file) at the folder epr in disk D (d:epr)

    after the compilation finished, a new file 23.OBJ (Object File) appered in the folder epr

    4.Link the object file (to get the run file)

    link the object file by running the link.exe in masm folder

    I also saved the run file (23.exe) in d:epr

    after the linkage, the file 23.EXE appered in the folder epr in disk D

    5.Run the exe file

    we get the result: 36

    6.Debug the run file 23.exe

    ① Using the command r to observe the numerical value saved in register cx and ds

    we can easily view that a assosiation exists between the value in cx and dx : (cs)=(ds)+10H

    ② Checking the first two bytes of PSP,

    because the PSP occupies  256bytes (100H) before the address of the program in the internal memory, and we can find the address of the first statement (MOV AH,02) is 15d9:0000, which is also the address of the program, so we set the address to 15c9:0000 (15d90H-100H=15c90H)

    by using the command d, we can get the first two bytes of PSP, which is CD and 20 indeed

    ③ Disassembling the 23.exe by using the command u, observe the source code of 23.exe

    ④ Debug the program step by step, using the command t and r

      r for command int to view the result

    the program ends after (15D9:0014    INT 21)

    at the 1st (15D9:0007    INT 21) the program gets a result---3

    at the 2nd (15D9:0010    INT 21) the program gets a result---6

    ( 2 ). COMPILE, LINK and RUN the NEW PROGRAM

    In this case, I use the DOXBox0.74-2 for Win10 to realize the compilation

    1.Creating a txt file (23.txt) in d:epr

    2.Using masm.exe and link.exe to compile and link the 233.txt

    after the compilation and linkage, 233.OBJ and 233.EXE appears in the folder E

    then run the 233.exe in the dosbox

    we find that nothing appears on the screen

    then we use the command cls to clear the screen, and run the 233.exe again

    now we can get the result of 233.exe ------- number 36, which color is red

    3.Change the number in the file 233.txt, after compilation and linkage, check the chage of its result.

    compared with the original 233.txt showed before,

    we changed the hex number in line 6 and line 8

    mov [bx], 0433h ==> mov [bx], 0432h

    mov [bx], 0436h ==> mov [bx], 0439h

    the new exe file also can't directly been showed on the screen

    by using the command cls, and run the program again, number 29, which color is also red, appers on the top of the screen

    4.Change the number in the file 233.txt again, after compilation and linkage, check the chage of its result.

    in this case we change the following statement: 

    (compared with the original file, changes also impled at line 6 and line 8)

    mov [bx], 0433h ==> mov [bx], 0333h

    mov [bx], 0436h ==> mov [bx], 0336h

    same way of compilation&linkage

    as well as same invisible result

    and same way to uncover it

    now we can see number 36 appears on the screen, but, its color is cyan

    SUMMARY & REVIEW of THIS EXPERIMENT :

    In thisexperiment, I grasped the method of compiling, linking and running of the assembly program. Especially creating a txt file with statement in it, and turn the unexecutable file to executable file by using the tool masm.exe and link.exe: masm.exe to change the txt file to object file (.OBJ file) while link.exe to change the object file to executable file (.EXE file).

    Hoever, there still confusions remained in this experiment:

    First, why using statement ( mov bx, 0       mov [bx], 0433h) instead of (mov [0], 0433h) ?

           one explanation to question1 is using the statement ( mov bx, 0      mov [bx], 0433h)  can  

           have a positive influence on the circulation later

    Second, why the result of some exe file cannot been showed on the screen immediately after execute. Instead, we need to clear the screen and run the file again to get the answer.

           one realiable explanation to question 2 is that bugs exists while running the program in   

           doxbox in some platforms which I think includes Windows 10

    Third, why the answer we get after clearing the screen and running the executable file again showed on the top of the screen? Does it belong to the execution command we typed before clearing the screen or after clearing the screen?

           I assume that the answer belongs to the command after clearing screen, but why the result

           appers on the top of the window still bothers me

  • 相关阅读:
    watir-webdriver使用过程中异常
    分治算法
    回溯算法
    线性时间求取第 K 大数
    深度和广度优先搜索算法
    排序优化——模拟栈及三路快排
    排序算法之——归并排序和快速排序
    数据结构和算法之——算法复杂度分析
    LeetCode 10——正则表达式匹配
    线性代数之——复数矩阵
  • 原文地址:https://www.cnblogs.com/mrorangerabbit/p/9977477.html
Copyright © 2011-2022 走看看