用汇编语言写出一个在屏幕中间显示三行不同颜色的welcome to masm!的代码
时间: 2024-02-11 09:09:58 浏览: 91
以下是汇编语言代码,能够在屏幕中间显示三行不同颜色的 "welcome to masm!" 字样:
```
.MODEL SMALL
.STACK 100h
.DATA
msg1 DB 'WELCOME TO MASM!',0
color1 DB 1
msg2 DB 'WELCOME TO MASM!',0
color2 DB 2
msg3 DB 'WELCOME TO MASM!',0
color3 DB 3
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
; get screen dimensions
MOV AH, 0Fh
INT 10h
MOV CX, 80
MOV DX, 25
SUB CX, AX
SHR CX, 1
SUB DX, BX
SHR DX, 1
; print message 1
MOV AH, 9h
MOV AL, color1
MOV BH, 0
MOV BL, 0Fh
MOV CX, 20
MOV DH, DX
ADD DH, 4
MOV DL, CX
ADD DL, 1
LEA SI, msg1
INT 10h
; print message 2
MOV AH, 9h
MOV AL, color2
MOV BH, 0
MOV BL, 0Fh
MOV CX, 20
MOV DH, DX
ADD DH, 6
MOV DL, CX
ADD DL, 1
LEA SI, msg2
INT 10h
; print message 3
MOV AH, 9h
MOV AL, color3
MOV BH, 0
MOV BL, 0Fh
MOV CX, 20
MOV DH, DX
ADD DH, 8
MOV DL, CX
ADD DL, 1
LEA SI, msg3
INT 10h
MOV AH, 4Ch
INT 21h
MAIN ENDP
END MAIN
```
该程序的功能是使用 VGA BIOS 中断来在屏幕中央显示三个不同颜色的 "welcome to masm!" 字样。变量 `msg1`、`msg2` 和 `msg3` 存储了三个不同的消息,变量 `color1`、`color2` 和 `color3` 存储了三个不同的颜色,分别是 1、2 和 3。该程序使用的是 80x25 文本模式,可以在 DOSBox 或类似的模拟器中运行。
阅读全文
相关推荐
带颜色的欢迎窗口
<script language="javascript">
var IE5=(document.getElementById && document.all)? true : false;
var W3C=(document.getElementById)? true: false;
var currIDb=null, currIDs=null, xoff=0, yoff=0; zctr=0; totz=0;
function trackmouse(evt){
if((currIDb!=null) && (currIDs!=null)){
var x=(IE5)? event.clientX+document.body.scrollLeft : evt.pageX;
var y=(IE5)? event.clientY+document.body.scrollTop : evt.pageY;
currIDb.style.left=x+xoff+'px';
currIDs.style.left=x+xoff+10+'px';
currIDb.style.top=y+yoff+'px';
currIDs.style.top=y+yoff+10+'px';
return false;
}}
function stopdrag(){
currIDb=null;
currIDs=null;
NS6bugfix();
}
function grab_id(evt){
xoff=parseInt(this.IDb.style.left)-((IE5)? event.clientX+document.body.scrollLeft : evt.pageX);
yoff=parseInt(this.IDb.style.top)-((IE5)? event.clientY+document.body.scrollTop : evt.pageY);
currIDb=this.IDb;
currIDs=this.IDs;
}
function NS6bugfix(){
if(!IE5){
self.resizeBy(0,1);
self.resizeBy(0,-1);
}}
function incrzindex(){
zctr=zctr+2;
this.subb.style.zIndex=zctr;
this.subs.style.zIndex=zctr-1;
}
function createPopup(id, title, width, height, x , y , isdraggable, boxcolor, barcolor, shadowcolor, text, textcolor, textptsize, textfamily ){
if(W3C){
zctr+=2;
totz=zctr;
var txt='';
txt+=' ';
txt+='';
txt+=' '+title+' ';
txt+=''+text+'';
document.write(txt);
this.IDh=document.getElementById(id+'_h');
this.IDh.IDb=document.getElementById(id+'_b');
this.IDh.IDs=document.getElementById(id+'_s');
this.IDh.IDb.subs=this.IDh.IDs;
this.IDh.IDb.subb=this.IDh.IDb;
this.IDh.IDb.IDov=document.getElementById(id+'_ov');
if(IE5){
this.IDh.IDb.IDov.style.width=width-6;
this.IDh.IDb.IDov.style.height=height-22;
this.IDh.IDb.IDov.style.scrollbarBaseColor=boxcolor;
this.IDh.IDb.IDov.style.overflow="auto";
}else{
this.IDh.IDs.style.MozOpacity=.5;
}
this.IDh.IDb.onmousedown=incrzindex;
if(isdraggable){
this.IDh.onmousedown=grab_id;
this.IDh.onmouseup=stopdrag;
}}}
if(W3C)document.onmousemove=trackmouse;
if(!IE5 && W3C)window.onload=NS6bugfix;
createPopup( 'box3', '欢迎光临' , 288, 90, 275, 155, true, 'FF9966' , '000000' , '800000' , '欢迎光临网页特效代码 网络因你而精彩' , 'FFFFFF' , 9 , '宋体');
</script>