weinan030416

导航

汇编hello world

普通

data segment ;数据段
    string db 'Hello,World!$'
data ends
code segment ;代码段
assume cs:code,ds:data
start:
    mov ax,data ;获取段基址
    mov ds,ax ;将段基址送入寄存器
    mov dx,offset string
    mov ah,9
    int 21h
    mov ah,4ch
    int 21h
code ends
end start

 

简化段定义

.model small
.stack        ;默认为1kb
.data
string db 'hello world!', 0dh, 0ah, '$'
.code
start:             ;完整段的开始方式
    mov ax, @data
    mov ds, ax
    mov dx, offset string
    mov ah, 9     ;这里一定不要写成了ax或则al,初学者很常见这种错误。
    int 21h
    mov ax, 4c00h
    int 21h
end start

 

posted on 2023-02-07 09:07  楠030416  阅读(13)  评论(0编辑  收藏  举报