MASM 16位汇编程序几种典型的格式

1.有名段

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. data segment  
  2.         output db 'Hello world!$'  
  3. data ends  
  4.   
  5. code segment  
  6. start:   
  7.         assume ds:data,cs:code  
  8.         mov ax,data  
  9.         mov ds,ax  
  10.           
  11.         mov dx,offset output  
  12.         mov ah,09h  
  13.         int 21h  
  14.           
  15.         mov ax, 4c00h  
  16.         int 21h  
  17.   
  18. code ends  
  19.         end start  

2.无名段

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. .model small  
  2. .data  
  3.         output db 'Hello world! $'  
  4. .code  
  5. start:  mov ax,@data  
  6.         mov ds,ax  
  7.           
  8.         mov dx,offset output  
  9.         mov ah,09h  
  10.         int 21h  
  11.           
  12.         mov ax, 4c00h  
  13.         int 21h  
  14.   
  15.         end start  

3.带有.startup的无名段

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
    1. .model small  
    2. .data  
    3.         output db 'Hello world! $'  
    4. .code  
    5. .startup;会自动参数设置DS,SS,SP的代码  
    6.         ;mov ax,@data          
    7.         ;mov ds,ax  
    8.                   
    9.         mov dx,offset output  
    10.         mov ah,09h  
    11.         int 21h  
    12.           
    13.         ;mov ax, 4c00h  
    14.         ;int 21h      
    15. .exit 0 ;产生退出操作系统的代码,所以不需要上面的两行代码了END  
原文地址:https://www.cnblogs.com/loanhicks/p/6720394.html