主题:[讨论]实现小虫爬行的代码
STACK SEGMENT PARA STACK 'STACK'
DW 50 DUP(?)
STACK_TOP LABEL WORD
STACK ENDS
data segment
t1 db ?
data ends
code segment
assume cs:code,ds:data
start:
;========================
MOV AX,STACK
MOV SS,AX
MOV SP,OFFSET STACK_TOP
mov ax,data
mov ds,ax
mov ax,0b800h
mov es,ax
mov di,1998
mov cx,7
mov si,di
next1:
mov byte ptr es:[di],15
inc di
mov byte ptr es:[di],0eh
inc di
loop next1
mov byte ptr es:[di],224
inc di
mov byte ptr es:[di],0Ah
inc di
mov cx,1000
next2:
; mov ah,0
; int 16h
call delay
sub di,2
mov byte ptr es:[di],15
inc di
mov byte ptr es:[di],0eh
inc di
mov byte ptr es:[di],224
inc di
mov byte ptr es:[di],0Ah
inc di
mov byte ptr es:[si],0
inc si
mov byte ptr es:[si],0h
inc si
loop next2
;===========================
mov ah,4ch
int 21h
delay proc
;---------------------------------
push cx
mov ah,0
int 1ah
mov t1,dl
L1:
mov ah,0
int 1ah
cmp dl,t1
JZ L1
pop cx
;---------------------------------
RET
delay endp
code ends
end start
DW 50 DUP(?)
STACK_TOP LABEL WORD
STACK ENDS
data segment
t1 db ?
data ends
code segment
assume cs:code,ds:data
start:
;========================
MOV AX,STACK
MOV SS,AX
MOV SP,OFFSET STACK_TOP
mov ax,data
mov ds,ax
mov ax,0b800h
mov es,ax
mov di,1998
mov cx,7
mov si,di
next1:
mov byte ptr es:[di],15
inc di
mov byte ptr es:[di],0eh
inc di
loop next1
mov byte ptr es:[di],224
inc di
mov byte ptr es:[di],0Ah
inc di
mov cx,1000
next2:
; mov ah,0
; int 16h
call delay
sub di,2
mov byte ptr es:[di],15
inc di
mov byte ptr es:[di],0eh
inc di
mov byte ptr es:[di],224
inc di
mov byte ptr es:[di],0Ah
inc di
mov byte ptr es:[si],0
inc si
mov byte ptr es:[si],0h
inc si
loop next2
;===========================
mov ah,4ch
int 21h
delay proc
;---------------------------------
push cx
mov ah,0
int 1ah
mov t1,dl
L1:
mov ah,0
int 1ah
cmp dl,t1
JZ L1
pop cx
;---------------------------------
RET
delay endp
code ends
end start