|
发表于 2013-12-15 18:47:03
|
显示全部楼层
在Loop S后面插入一条 Jmp $或者是jmp start
这样就可以防止程序执行完毕就退出了!
还有一种,使用键盘中断int 16h 强烈推介!
这3中都是一句话,夹在Loop S后面
详细代码如下:assume cs:data,ds:data,ss:stack
data segment
db 'Weloome to Masm!' db 02h,24h,71h data ends
stack segment
dd 8 dup (0) stack ends
code segment
start: mov ax,data mov ds,ax mov ax,stack mov ss,ax mov sp,16h mov ax,0b872h mov es,ax mov cx,3s: push cx mov cx,16s1: mov al,ds:[bx] mov es:[bp],al inc bx add bp,2 loop s1 sub bp,bp sub bx,bx mov cx,16s2: mov al,ds:10h[di] mov es:[bp+1],al add bp,2 loop s2 inc di add bp,0ah pop cx loop s jmp [ DISCUZ_CODE_22 ]nbsp; mov ax,4c00h int 21h code ends
end start
第二种方法:跳转到头部!assume cs:data,ds:data,ss:stack
data segment
db 'Weloome to Masm!'
db 02h,24h,71h
data ends
stack segment
dd 8 dup (0)
stack ends
code segment
start: mov ax,data
mov ds,ax
mov ax,stack
mov ss,ax
mov sp,16h
mov ax,0b872h
mov es,ax
mov cx,3
s: push cx
mov cx,16
s1: mov al,ds:[bx]
mov es:[bp],al
inc bx
add bp,2
loop s1
sub bp,bp
sub bx,bx
mov cx,16
s2: mov al,ds:10h[di]
mov es:[bp+1],al
add bp,2
loop s2
inc di
add bp,0ah
pop cx
loop s
jmp start
mov ax,4c00h
int 21h
code ends
end start
第三种方法:相当于C语言的Getchar();assume cs:data,ds:data,ss:stack
data segment
db 'Weloome to Masm!'
db 02h,24h,71h
data ends
stack segment
dd 8 dup (0)
stack ends
code segment
start: mov ax,data
mov ds,ax
mov ax,stack
mov ss,ax
mov sp,16h
mov ax,0b872h
mov es,ax
mov cx,3
s: push cx
mov cx,16
s1: mov al,ds:[bx]
mov es:[bp],al
inc bx
add bp,2
loop s1
sub bp,bp
sub bx,bx
mov cx,16
s2: mov al,ds:10h[di]
mov es:[bp+1],al
add bp,2
loop s2
inc di
add bp,0ah
pop cx
loop s
int 16h ;16号键盘中断,按下任意键后才会继续往下执行!这样就起到了暂停作用,强烈推介使用这种方法!在书的最后一章有介绍!
mov ax,4c00h
int 21h
code ends
end start
求最佳! 不懂的可以加我QQ:1447380573
|
|