编写一个完整的汇编语言程序,要求在屏幕上显示出字符串“Hello,Assembly language”。
datasegment
msgdb'Hello,Assemblylanguage','$'
dataends
codesegment
assumeds:data,cs:code
mainprocfar
movax,data
movds,ax
leadx,msg
movah,9
int21h
movax,4c00h
int21h
mainendp
codeends
endmain
扩展资料
汇编程序在屏幕上显示一个字符串“Hello”
datasegment
stringdb'Hello',13,10,'$';字符串以’$’符号结尾,以单引号括起来
dataends
codesegment
assumecs:code,ds:data
start:;程序的入口地址
pushds;saveolddatasegment
subax,ax;ax寄存器清零,作为数据段0偏移地址
pushax;零偏移地址入栈
movax,data
movds,ax;把数据段地址装入数据段寄存器ds
leadx,string;把字符串首地址装入dx寄存器,或写成movdx,offsetstring
movah,9;DOS功能调用,在屏幕上显示字符串
int21h;DOS中断
movah,4ch;returntoDOS
int21h
codeends
endstart;汇编的结束,程序在此执行
BUF DB 'Hello,Assembly language.$'
DATAS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS
START:
MOV AX,DATAS
MOV DS,AX
MOV DX,OFFSET BUF
MOV AH,09H
INT 21H
MOV AH,4CH
INT 21H
CODES ENDS
END START
msg db "Hello,Assembly language",0dh,0ah,'$'
data ends
code segment
assume cS:code,ds:data
start: mov ax,data
mov ds,ax
mov dx,offset msg
mov ah,9
int 21h
mov ax,4c00h
int 21h
code ends
end start