1.有名段
- data segment
- output db 'Hello world!$'
- data ends
- code segment
- start:
- assume ds:data,cs:code
- mov ax,data
- mov ds,ax
- mov dx,offset output
- mov ah,09h
- int 21h
- mov ax, 4c00h
- int 21h
- code ends
- end start
2.无名段
- .model small
- .data
- output db 'Hello world! $'
- .code
- start: mov ax,@data
- mov ds,ax
- mov dx,offset output
- mov ah,09h
- int 21h
- mov ax, 4c00h
- int 21h
- end start
3.带有.startup的无名段
- .model small
- .data
- output db 'Hello world! $'
- .code
- .startup;会自动参数设置DS,SS,SP的代码
- ;mov ax,@data
- ;mov ds,ax
- mov dx,offset output
- mov ah,09h
- int 21h
- ;mov ax, 4c00h
- ;int 21h
- .exit 0 ;产生退出操作系统的代码,所以不需要上面的两行代码了END