the first demo: HelloWorld compiled by masm5.0

编辑一个16位的 IBM-CP 汇编小程序的一般步骤如下:

1.编辑汇编源程序(edit the source file): 如 demo.asm

Code:
  1. data segment   
  2.     message db 'Hello World! welcome to assemble world',13, 10, '$'  
  3. data ends   
  4.   
  5. stack segment   
  6.     dw  100 dup(?)   
  7.     tos equ this type word   
  8. stack ends   
  9.   
  10. code segment   
  11.     assume cs:code, ds:data, ss:stack   
  12. start:   
  13.     mov ax, data   
  14.     mov ds, ax   
  15.     mov ax, stack   
  16.     mov ss, ax   
  17.   
  18.     mov dx, offset message   
  19.     mov ah, 09h   
  20.     int 21h   
  21.   
  22.     mov ah, 4ch   
  23.     int 21h   
  24.   
  25.                    
  26. code ends   
  27. end start   
  28.   
  29.   

2.用汇编程序masm5.0 对源程序进行编译:(complie the source file with assemble complier masm5.0)

       首先 winkey +r 启动运行对话框,在“运行”输入“cmd”  enter,启动命令行窗口,进入工作区:就是你存放汇编源程序的目录:若该目录为 d:/work 则执行如下操作:

Code:
  1. Microsoft Windows XP [版本 5.1.2600]   
  2. (C) 版权所有 1985-2001 Microsoft Corp.   
  3.   
  4. C:/Documents and Settings/253642xvvn>d:   
  5.   
  6. D:/>cd work   
  7.   
  8. D:/work>dir   
  9.  驱动器 D 中的卷没有标签。   
  10.  卷的序列号是 0478-A8CB   
  11.   
  12.  D:/work 的目录   
  13.   
  14. 2011-02-24  09:31    <DIR>          .   
  15. 2011-02-24  09:31    <DIR>          ..   
  16. 2011-02-23  19:34    <DIR>          bin   
  17. 2011-02-24  09:12               389 demo.asm   
  18. 2011-02-24  09:11               350 demo.asm~   
  19. 2011-02-24  09:30               243 DEMO.CRF   
  20. 2011-02-24  09:30               789 DEMO.EXE   
  21. 2011-02-24  09:30             2,188 DEMO.LST   
  22. 2011-02-24  09:30               271 DEMO.MAP   
  23. 2011-02-24  09:30               180 DEMO.OBJ   
  24. 2011-02-23  20:35                 0 HelloWorld.asm   
  25. 2011-02-23  20:37               405 hw.asm   
  26. 2011-02-23  14:50               407 keydown.asm   
  27. 2011-02-23  20:35                 0 key_pressdown.asm   
  28. 2011-02-23  20:35                 0 lcate_cursor.asm   
  29. 2011-02-23  19:45               626 movsb.asm   
  30. 2011-02-23  20:08             2,073 vector.asm   
  31. 2011-02-23  20:23               667 VECTOR.EXE   
  32. 2011-02-23  19:12               404 World.asm   
  33.               16 个文件          8,992 字节   
  34.                3 个目录 28,501,487,616 可用字节   
  35.   
  36. D:/work>   

    接着,需要设置编译器的路径:以下操作只是将汇编器masm5.0的所在的目录 d:/masm5.0 临时追加在环境变量path中;

       此时,该追加的路径,只对当前命令行窗口以及其后继窗口(由start启动的)有效; 要想永久有效,可以设置系统环境变量

   ,设置方法:  右击我的电脑--》属性--》高级--》环境变量 找到path, 编辑;具体方式,百度吧,有图文并茂的,O(∩_∩)O~。

Code:
  1. Microsoft Windows XP [版本 5.1.2600]   
  2. (C) 版权所有 1985-2001 Microsoft Corp.   
  3.   
  4. C:/Documents and Settings/253642xvvn>d:   
  5.   
  6. D:/>cd work   
  7.   
  8. D:/work>dir   
  9.  驱动器 D 中的卷没有标签。   
  10.  卷的序列号是 0478-A8CB   
  11.   
  12.  D:/work 的目录   
  13.   
  14. 2011-02-24  10:07    <DIR>          .   
  15. 2011-02-24  10:07    <DIR>          ..   
  16. 2011-02-23  19:34    <DIR>          bin   
  17. 2011-02-24  09:12               389 demo.asm   
  18. 2011-02-24  09:11               350 demo.asm~   
  19. 2011-02-24  09:55               243 DEMO.CRF   
  20. 2011-02-24  09:55               789 DEMO.EXE   
  21. 2011-02-24  09:55             2,188 DEMO.LST   
  22. 2011-02-24  09:30               271 DEMO.MAP   
  23. 2011-02-24  09:55               180 DEMO.OBJ   
  24. 2011-02-24  10:07                 0 dir   
  25. 2011-02-23  20:35                 0 HelloWorld.asm   
  26. 2011-02-23  20:37               405 hw.asm   
  27. 2011-02-23  14:50               407 keydown.asm   
  28. 2011-02-23  20:35                 0 key_pressdown.asm   
  29. 2011-02-23  20:35                 0 lcate_cursor.asm   
  30. 2011-02-23  19:45               626 movsb.asm   
  31. 2011-02-24  10:07                 0 path   
  32. 2011-02-23  20:08             2,073 vector.asm   
  33. 2011-02-23  20:23               667 VECTOR.EXE   
  34. 2011-02-23  19:12               404 World.asm   
  35.               18 个文件          8,992 字节   
  36.                3 个目录 28,501,487,616 可用字节   
  37.   
  38. D:/work>dir d:/masm5.0   
  39.  驱动器 D 中的卷没有标签。   
  40.  卷的序列号是 0478-A8CB   
  41.   
  42.  d:/masm5.0 的目录   
  43.   
  44. 2011-02-23  18:57    <DIR>          .   
  45. 2011-02-23  18:57    <DIR>          ..   
  46. 1987-07-31  00:00            15,830 CREF.EXE   
  47. 1987-07-31  00:00             9,499 ERROUT.EXE   
  48. 1987-07-31  00:00            12,149 EXEMOD.EXE   
  49. 1987-10-15  05:00            14,803 EXEPACK.EXE   
  50. 1987-07-31  00:00            32,150 LIB.EXE   
  51. 1987-07-31  00:00            39,100 LINK.EXE   
  52. 1987-07-31  00:00            24,199 MAKE.EXE   
  53. 2002-10-12  11:27               967 MAKE.PIF   
  54. 1987-07-31  00:00            65,557 MASM.EXE   
  55. 1987-07-31  00:00            10,601 SETENV.EXE   
  56.               10 个文件        224,855 字节   
  57.                2 个目录 28,501,487,616 可用字节   
  58.   
  59. D:/work>path   
  60. PATH=e:/Xilinx/10.1/EDK/bin/nt;e:/Xilinx/10.1/EDK/lib/nt;e:/Xilinx/10.1/ISE/bin/   
  61. nt;e:/Xilinx/10.1/ISE/lib/nt;%LMC_HOME%/lib/pcnt.lib;D:/jdk1.6.0_21/bin;C:/WINDO   
  62. WS/system32;C:/WINDOWS;C:/WINDOWS/System32/Wbem;C:/Program Files/Intel/DMIX;C:/P   
  63. rogram Files/Common Files/Thunder Network/KanKan/Codecs;D:/jdk1.6.0_21/mingw/bin   
  64. ;e:/Xilinx/10.1/ChipScope/bin/nt;c:/Program Files/Microsoft SQL Server/100/Tools   
  65. /Binn/;c:/Program Files/Microsoft SQL Server/100/DTS/Binn/;C:/Program Files/doxy   
  66. gen/bin;D:/jdk1.6.0_21/jre/bin;C:/Program Files/Common Files/TTKN/Bin;D:/Program   
  67.  Files/Microsoft Visual Studio/Common/Tools/WinNT;D:/Program Files/Microsoft Vis   
  68. ual Studio/Common/MSDev98/Bin;D:/Program Files/Microsoft Visual Studio/Common/To   
  69. ols;D:/Program Files/Microsoft Visual Studio/VC98/bin;C:/Program Files/Nmap;C:/P   
  70. rogram Files/SSH Communications Security/SSH Secure Shell   
  71.   
  72. D:/work>echo %path%   
  73. e:/Xilinx/10.1/EDK/bin/nt;e:/Xilinx/10.1/EDK/lib/nt;e:/Xilinx/10.1/ISE/bin/nt;e:   
  74. /Xilinx/10.1/ISE/lib/nt;%LMC_HOME%/lib/pcnt.lib;D:/jdk1.6.0_21/bin;C:/WINDOWS/sy   
  75. stem32;C:/WINDOWS;C:/WINDOWS/System32/Wbem;C:/Program Files/Intel/DMIX;C:/Progra   
  76. m Files/Common Files/Thunder Network/KanKan/Codecs;D:/jdk1.6.0_21/mingw/bin;e:/X   
  77. ilinx/10.1/ChipScope/bin/nt;c:/Program Files/Microsoft SQL Server/100/Tools/Binn   
  78. /;c:/Program Files/Microsoft SQL Server/100/DTS/Binn/;C:/Program Files/doxygen/b   
  79. in;D:/jdk1.6.0_21/jre/bin;C:/Program Files/Common Files/TTKN/Bin;D:/Program File   
  80. s/Microsoft Visual Studio/Common/Tools/WinNT;D:/Program Files/Microsoft Visual S   
  81. tudio/Common/MSDev98/Bin;D:/Program Files/Microsoft Visual Studio/Common/Tools;D   
  82. :/Program Files/Microsoft Visual Studio/VC98/bin;C:/Program Files/Nmap;C:/Progra   
  83. m Files/SSH Communications Security/SSH Secure Shell   
  84.   
  85. D:/work>set path=d:/masm5.0;%path%   
  86.   
  87. D:/work>path   
  88. PATH=d:/masm5.0;e:/Xilinx/10.1/EDK/bin/nt;e:/Xilinx/10.1/EDK/lib/nt;e:/Xilinx/10   
  89. .1/ISE/bin/nt;e:/Xilinx/10.1/ISE/lib/nt;%LMC_HOME%/lib/pcnt.lib;D:/jdk1.6.0_21/b   
  90. in;C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System32/Wbem;C:/Program Files/Inte   
  91. l/DMIX;C:/Program Files/Common Files/Thunder Network/KanKan/Codecs;D:/jdk1.6.0_2   
  92. 1/mingw/bin;e:/Xilinx/10.1/ChipScope/bin/nt;c:/Program Files/Microsoft SQL Serve   
  93. r/100/Tools/Binn/;c:/Program Files/Microsoft SQL Server/100/DTS/Binn/;C:/Program   
  94.  Files/doxygen/bin;D:/jdk1.6.0_21/jre/bin;C:/Program Files/Common Files/TTKN/Bin   
  95. ;D:/Program Files/Microsoft Visual Studio/Common/Tools/WinNT;D:/Program Files/Mi   
  96. crosoft Visual Studio/Common/MSDev98/Bin;D:/Program Files/Microsoft Visual Studi   
  97. o/Common/Tools;D:/Program Files/Microsoft Visual Studio/VC98/bin;C:/Program File   
  98. s/Nmap;C:/Program Files/SSH Communications Security/SSH Secure Shell   
  99.   
  100. D:/work>echo %path%   
  101. d:/masm5.0;e:/Xilinx/10.1/EDK/bin/nt;e:/Xilinx/10.1/EDK/lib/nt;e:/Xilinx/10.1/IS   
  102. E/bin/nt;e:/Xilinx/10.1/ISE/lib/nt;%LMC_HOME%/lib/pcnt.lib;D:/jdk1.6.0_21/bin;C:   
  103. /WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System32/Wbem;C:/Program Files/Intel/DMI   
  104. X;C:/Program Files/Common Files/Thunder Network/KanKan/Codecs;D:/jdk1.6.0_21/min   
  105. gw/bin;e:/Xilinx/10.1/ChipScope/bin/nt;c:/Program Files/Microsoft SQL Server/100   
  106. /Tools/Binn/;c:/Program Files/Microsoft SQL Server/100/DTS/Binn/;C:/Program File   
  107. s/doxygen/bin;D:/jdk1.6.0_21/jre/bin;C:/Program Files/Common Files/TTKN/Bin;D:/P   
  108. rogram Files/Microsoft Visual Studio/Common/Tools/WinNT;D:/Program Files/Microso   
  109. ft Visual Studio/Common/MSDev98/Bin;D:/Program Files/Microsoft Visual Studio/Com   
  110. mon/Tools;D:/Program Files/Microsoft Visual Studio/VC98/bin;C:/Program Files/Nma   
  111. p;C:/Program Files/SSH Communications Security/SSH Secure Shell   
  112.   
  113. D:/work>  

 用masm5.0 汇编器masm 和链接器link 分别对源文件,进行编译连接。

Code:
  1.   
  2. D:/work>masm demo.asm   
  3. Microsoft (R) Macro Assembler Version 5.00   
  4. Copyright (C) Microsoft Corp 1981-1985, 1987.  All rights reserved.   
  5.   
  6. Object filename [demo.OBJ]: demo   
  7. Source listing  [NUL.LST]: demo   
  8. Cross-reference [NUL.CRF]: demo   
  9.   
  10.   49376 + 400128 Bytes symbol space free   
  11.   
  12.       0 Warning Errors   
  13.       0 Severe  Errors   
  14.   
  15. D:/work>link demo   
  16.   
  17. Microsoft (R) Overlay Linker  Version 3.60   
  18. Copyright (C) Microsoft Corp 1983-1987.  All rights reserved.   
  19.   
  20. Run File [DEMO.EXE]: demo   
  21. List File [NUL.MAP]: demo   
  22. Libraries [.LIB]:   
  23. LINK : warning L4021: no stack segment   
  24.   
  25. D:/work>demo   
  26. Hello World! welcome to assemble world   
  27.   
  28. D:/work>link demo;   
  29.   
  30. Microsoft (R) Overlay Linker  Version 3.60   
  31. Copyright (C) Microsoft Corp 1983-1987.  All rights reserved.   
  32.   
  33. LINK : warning L4021: no stack segment  

 3.运行编译和链接后生成可执行程序: demo.exe

Code:
  1. D:/work>demo   
  2. Hello World! welcome to assemble world   
  3.   
  4. D:/work>demo.exe   
  5. Hello World! welcome to assemble world   
  6.   
  7. D:/work>   

总结:值得一提的是在编译的过程中生成的 *.lst,  *.crf 和连接后生成的*.map 非常有用的。当编译出错时,可以同过*.list 文件进行查看错误的位置》 crf文件是一个十六进制的文件, map文件是object文件连接时重定位的依据,记录各个段的映射信息。

下面看一个出错的例子:

Code:
  1. data segment   
  2.     message db 'Hello World! welcome to assemble world',13, 10, '$'  
  3. data ends   
  4.   
  5. stack segment   
  6.     dw  100 dup(?)   
  7.     tos equ this type word   
  8. stack ends   
  9.   
  10. code segment   
  11.     assume cs:code, ds:data, ss:stack   
  12. start:   
  13.     mov ax, data   
  14.     mov ds, ax   
  15.     mov ax, stack   
  16.     mov ss, ax   
  17.   
  18.     mov dx, offset massage   
  19.     mov ah, 09h   
  20.     int 21h   
  21.   
  22.     mov ah, 4ch   
  23.     int 21h   
  24.   
  25.                    
  26. code ends   
  27. end start  

 汇编时:

Code:
  1. D:/work>masm demo.asm   
  2. Microsoft (R) Macro Assembler Version 5.00   
  3. Copyright (C) Microsoft Corp 1981-1985, 1987.  All rights reserved.   
  4.   
  5. Object filename [demo.OBJ]: demo   
  6. Source listing  [NUL.LST]: demo   
  7. Cross-reference [NUL.CRF]: demo   
  8. demo.asm(18): error A2009: Symbol not defined: MASSAGE   
  9.   
  10.   48692 + 399436 Bytes symbol space free   
  11.   
  12.       0 Warning Errors   
  13.       1 Severe  Errors   
  14.   
  15. D:/work>   
  16.   

1 severe Errors 说明出现了一个严重的错误,但错误在哪里呢? 这使,列表文件demo.lst文件就有用处了,看看的它的内容:

     可以进入demo.lst所在的目录,用文本编辑器查看,也可以在命令行下用如下方式查看:

Code:
  1.   
  2.   
  3. D:/work>type demo.lst | more   
  4. Microsoft (R) Macro Assembler Version 5.00                  2/24/11 10:39:04   
  5.                                                              Page     1-1   
  6.   
  7.   
  8.        1 0000                           data segment   
  9.        2 0000  48 65 6C 6C 6F 20 57             message db 'Hello World! welcom   
  10.                                         e to assemble world',13, 10, '$'   
  11.        3       6F 72 6C 64 21 20 77   
  12.        4       65 6C 63 6F 6D 65 20   
  13.        5       74 6F 20 61 73 73 65   
  14.        6       6D 62 6C 65 20 77 6F   
  15.        7       72 6C 64 0D 0A 24   
  16.        8 0029                           data ends   
  17.        9   
  18.       10 0000                           stack segment   
  19.       11 0000  0064[                            dw      100 dup(?)   
  20.       12           ????   
  21.       13                         ]   
  22.       14   
  23.       15 =                                      tos equ this type word   
  24.       16 00C8                           stack ends   
  25.       17   
  26.       18 0000                           code segment   
  27.       19                                        assume cs:code, ds:data, ss:sta   
  28.                                         ck   
  29.       20 0000                           start:   
  30.       21 0000  B8 ---- R                        mov ax, data   
  31.       22 0003  8E D8                            mov ds, ax   
  32.       23 0005  B8 ---- R                        mov ax, stack   
  33.       24 0008  8E D0                            mov ss, ax   
  34.       25   
  35.       26 000A  BA 0000 U                        mov dx, offset massage   
  36. demo.asm(18): error A2009: Symbol not defined: MASSAGE   
  37.       27 000D  B4 09                            mov ah, 09h   
  38.       28 000F  CD 21                            int 21h   
  39.       29   
  40.       30 0011  B4 4C                            mov ah, 4ch   
  41.       31 0013  CD 21                            int 21h   
  42.       32   
  43.       33   
  44.       34 0015                           code ends   
  45.       35                                end start   
  46. Microsoft (R) Macro Assembler Version 5.00                  2/24/11 10:39:04   
  47.                                                              Symbols-1   
  48.   
  49.   
  50.   
  51. Segments and Groups:   
  52.   
  53.                 N a m e                 Length   Align  Combine Class   
  54.   
  55. CODE . . . . . . . . . . . . . .        0015    PARA    NONE   
  56. DATA . . . . . . . . . . . . . .        0029    PARA    NONE   
  57. STACK  . . . . . . . . . . . . .        00C8    PARA    NONE   
  58.   
  59. Symbols:   
  60.   
  61.                 N a m e                 Type     Value   Attr   
  62.   
  63. MESSAGE  . . . . . . . . . . . .        L BYTE  0000    DATA   
  64.   
  65. START  . . . . . . . . . . . . .        L NEAR  0000    CODE   
  66.   
  67. TOS  . . . . . . . . . . . . . .        TEXT  this type word   
  68.   
  69. @FILENAME  . . . . . . . . . . .        TEXT  demo   
  70.   
  71.   
  72.      27 Source  Lines   
  73.      27 Total   Lines   
  74.       8 Symbols   
  75.   
  76.   48692 + 399436 Bytes symbol space free   
  77.   
  78.       0 Warning Errors   
  79.       1 Severe  Errors   
  80.   

发现该文件,是对汇编的一些详细信息,很容易就找到了发生错误的地方:

   demo.asm(18): error A2009: Symbol not defined: MASSAGE   

下面就修改一下,源文件demo.asm的18行:

Code:
  1. data segment   
  2.     message db 'Hello World! welcome to assemble world',13, 10, '$'  
  3. data ends   
  4.   
  5. stack segment   
  6.     dw  100 dup(?)   
  7.     tos equ this type word   
  8. stack ends   
  9.   
  10. code segment   
  11.     assume cs:code, ds:data, ss:stack   
  12. start:   
  13.     mov ax, data   
  14.     mov ds, ax   
  15.     mov ax, stack   
  16.     mov ss, ax   
  17.   
  18.     mov dx, offset massage   
  19.     mov ah, 09h   
  20.     int 21h   
  21.   
  22.     mov ah, 4ch   
  23.     int 21h   
  24.   
  25.                    
  26. code ends   
  27. end start   
  28.   
  29.   

原来,数据段定义的变量 message ,此处误写成了 massage,所以就有了变量符号massage无定义的错误。修改后,就能编译通过了:

Code:
  1. D:/work>masm demo.asm   
  2. Microsoft (R) Macro Assembler Version 5.00   
  3. Copyright (C) Microsoft Corp 1981-1985, 1987.  All rights reserved.   
  4.   
  5. Object filename [demo.OBJ]: demo   
  6. Source listing  [NUL.LST]: demo   
  7. Cross-reference [NUL.CRF]: demo   
  8.   
  9.   48692 + 399436 Bytes symbol space free   
  10.   
  11.       0 Warning Errors   
  12.       0 Severe  Errors  

 接着link, link 的一种快捷方式 link demo; 就不需要指派文件名了

Code:
  1.   
  2. D:/work>link demo ;   
  3.   
  4. Microsoft (R) Overlay Linker  Version 3.60   
  5. Copyright (C) Microsoft Corp 1983-1987.  All rights reserved.   
  6.   
  7. LINK : warning L4021: no stack segment   
  8.   
  9. D:/work>link demo   
  10.   
  11. Microsoft (R) Overlay Linker  Version 3.60   
  12. Copyright (C) Microsoft Corp 1983-1987.  All rights reserved.   
  13.   
  14. Run File [DEMO.EXE]: demo   
  15. List File [NUL.MAP]: demo   
  16. Libraries [.LIB]:   
  17. LINK : warning L4021: no stack segment   
  18.   
  19. D:/work>   

下面看一看, demo.lst, demo.crf. demo.map文件的内容吧:

demo.lst文件的内容

Code:
  1. Microsoft (R) Macro Assembler Version 5.00                  2/24/11 10:57:05   
  2.                                                              Page     1-1   
  3.   
  4.   
  5.        1 0000               data segment    
  6.        2 0000  48 65 6C 6C 6F 20 57     message db 'Hello World! welcom   
  7.                     e to assemble world',13, 10, '$'    
  8.        3       6F 72 6C 64 21 20 77    
  9.        4       65 6C 63 6F 6D 65 20    
  10.        5       74 6F 20 61 73 73 65    
  11.        6       6D 62 6C 65 20 77 6F    
  12.        7       72 6C 64 0D 0A 24       
  13.        8 0029               data ends    
  14.        9                    
  15.       10 0000               stack segment    
  16.       11 0000  0064[                dw  100 dup(?)    
  17.       12       ????            
  18.       13             ]     
  19.       14                   
  20.       15 =                  tos equ this type word    
  21.       16 00C8               stack ends    
  22.       17                    
  23.       18 0000               code segment    
  24.       19                    assume cs:code, ds:data, ss:sta   
  25.                     ck    
  26.       20 0000               start:    
  27.       21 0000  B8 ---- R            mov ax, data    
  28.       22 0003  8E D8                mov ds, ax    
  29.       23 0005  B8 ---- R            mov ax, stack    
  30.       24 0008  8E D0                mov ss, ax    
  31.       25                    
  32.       26 000A  BA 0000 R            mov dx, offset message    
  33.       27 000D  B4 09                mov ah, 09h    
  34.       28 000F  CD 21                int 21h    
  35.       29                    
  36.       30 0011  B4 4C                mov ah, 4ch    
  37.       31 0013  CD 21                int 21h    
  38.       32                    
  39.       33                                    
  40.       34 0015               code ends    
  41.       35                end start    
  42. Microsoft (R) Macro Assembler Version 5.00                  2/24/11 10:57:05   
  43.                                                              Symbols-1   
  44.   
  45.   
  46. Segments and Groups:   
  47.   
  48.                 N a m e             Length   Align  Combine Class   
  49.   
  50. CODE . . . . . . . . . . . . . .    0015    PARA    NONE       
  51. DATA . . . . . . . . . . . . . .    0029    PARA    NONE       
  52. STACK  . . . . . . . . . . . . .    00C8    PARA    NONE       
  53.   
  54. Symbols:               
  55.   
  56.                 N a m e             Type     Value   Attr   
  57.   
  58. MESSAGE  . . . . . . . . . . . .    L BYTE  0000    DATA   
  59.   
  60. START  . . . . . . . . . . . . .    L NEAR  0000    CODE   
  61.   
  62. TOS  . . . . . . . . . . . . . .    TEXT  this type word           
  63.   
  64. @FILENAME  . . . . . . . . . . .    TEXT  demo         
  65.   
  66.   
  67.      27 Source  Lines   
  68.      27 Total   Lines   
  69.       8 Symbols   
  70.   
  71.   48692 + 399436 Bytes symbol space free   
  72.   
  73.       0 Warning Errors   
  74.       0 Severe  Errors   

demo.crf文件的内容:(用十六进制显示)

Code:
  1. 0000000: 073a 4f08 6465 6d6f 2e61 736d 0200 0005  .:O.demo.asm....   
  2. 0000010: 0044 4154 4104 0100 0202 0025 024d 4553  .DATA......%.MES   
  3. 0000020: 5341 4745 0402 0004 0300 0404 0004 0500  SAGE............   
  4. 0000030: 0406 0004 0700 0104 4441 5441 0408 0004  ........DATA....   
  5. 0000040: 0900 0200 0005 0053 5441 434b 040a 0004  .......STACK....   
  6. 0000050: 0b00 040c 0004 0d00 040e 0002 0000 2506  ..............%.   
  7. 0000060: 544f 5304 0f00 0104 5354 4143 4b04 1000  TOS.....STACK...   
  8. 0000070: 0411 0002 0000 0500 434f 4445 0412 0001  ........CODE....   
  9. 0000080: 0443 4f44 4501 0444 4154 4101 0453 5441  .CODE..DATA..STA   
  10. 0000090: 434b 0413 0002 ffff 2502 5354 4152 5404  CK......%.START.   
  11. 00000a0: 1400 0101 4441 5441 0415 0004 1600 0101  ....DATA........   
  12. 00000b0: 5354 4143 4b04 1700 0418 0004 1900 0101  STACK...........   
  13. 00000c0: 4d45 5353 4147 4504 1a00 041b 0004 1c00  MESSAGE.........   
  14. 00000d0: 041d 0004 1e00 041f 0004 2000 0421 0001  .......... ..!..   
  15. 00000e0: 0443 4f44 4504 2200 0104 5354 4152 5404  .CODE."...START.   
  16. 00000f0: 2300 050a                                #...   

demo.map文件的内容如下:

Code:
  1. LINK : warning L4021: no stack segment   
  2.   
  3.  Start  Stop   Length Name                   Class   
  4.  00000H 00028H 00029H DATA                      
  5.  00030H 000F7H 000C8H STACK                     
  6.  00100H 00114H 00015H CODE                      
  7.   
  8. Program entry point at 0010:0000   

呵呵,这几个文件时不不是很有用呀。

编译成功了,link也成功了,但是运行不是我们想要的结果,该怎么办呢? 用调试命令debug;

Code:
  1. D:/work>debug demo   
  2. File not found   
  3. -u   
  4. 13F4:0100 21E8          AND     AX,BP   
  5. 13F4:0102 4C            DEC     SP   
  6. 13F4:0103 1483          ADC     AL,83   
  7. 13F4:0105 C4068946      LES     AX,[4689]   
  8. 13F4:0109 F8            CLC   
  9. 13F4:010A 8956FA        MOV     [BP-06],DX   
  10. 13F4:010D A1B817        MOV     AX,[17B8]   
  11. 13F4:0110 0B06BA17      OR      AX,[17BA]   
  12. 13F4:0114 751C          JNZ     0132   
  13. 13F4:0116 837E0AFF      CMP     WORD PTR [BP+0A],-01   
  14. 13F4:011A 7408          JZ      0124   
  15. 13F4:011C 3400          XOR     AL,00   
  16. 13F4:011E E313          JCXZ    0133   
  17. -t   
  18.   
  19. AX=0000  BX=0000  CX=0000  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000   
  20. DS=13F4  ES=13F4  SS=13F4  CS=13F4  IP=0102   NV UP EI PL ZR NA PE NC   
  21. 13F4:0102 4C            DEC     SP   
  22. -?   
  23. assemble     A [address]   
  24. compare      C range address   
  25. dump         D [range]   
  26. enter        E address [list]   
  27. fill         F range list   
  28. go           G [=address] [addresses]   
  29. hex          H value1 value2   
  30. input        I port   
  31. load         L [address] [drive] [firstsector] [number]   
  32. move         M range address   
  33. name         N [pathname] [arglist]   
  34. output       O port byte   
  35. proceed      P [=address] [number]   
  36. quit         Q   
  37. register     R [register]   
  38. search       S range list   
  39. trace        T [=address] [value]   
  40. unassemble   U [range]   
  41. write        W [address] [drive] [firstsector] [number]   
  42. allocate expanded memory        XA [#pages]   
  43. deallocate expanded memory      XD [handle]   
  44. map expanded memory pages       XM [Lpage] [Ppage] [handle]   
  45. display expanded memory status  XS   
  46. -q  

debug  几个有用的命令 :

      u :反汇编

      t:单步执行

      q:退出debug:

具体参数的用法可在debug 下用? 查看。

Code:
  1.   
  2. D:/work>debug   
  3. -?   
  4. assemble     A [address]   
  5. compare      C range address   
  6. dump         D [range]   
  7. enter        E address [list]   
  8. fill         F range list   
  9. go           G [=address] [addresses]   
  10. hex          H value1 value2   
  11. input        I port   
  12. load         L [address] [drive] [firstsector] [number]   
  13. move         M range address   
  14. name         N [pathname] [arglist]   
  15. output       O port byte   
  16. proceed      P [=address] [number]   
  17. quit         Q   
  18. register     R [register]   
  19. search       S range list   
  20. trace        T [=address] [value]   
  21. unassemble   U [range]   
  22. write        W [address] [drive] [firstsector] [number]   
  23. allocate expanded memory        XA [#pages]   
  24. deallocate expanded memory      XD [handle]   
  25. map expanded memory pages       XM [Lpage] [Ppage] [handle]   
  26. display expanded memory status  XS   
  27. -q   
  28.   
  29. D:/work>  

以上就是一个程序的开发流程。其实,和其他语言的大致一样,基本上都是这个流程。这就是程序设计语言的相似性。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值