ALP to simulate TYPE command using PSP

, by Engineer's Vision


;ALP to simulate TYPE command using PSP


disp macro msg
        lea dx,msg
        mov ah,09h
        int 21h
endm

.model small
.stack 100
.data
        msg1 db 10,13,"File is open$"
        msg2 db 10,13,"Error in opening file$"
        msg3 db 10,13,"File can be read$"
        msg4 db 10,13,"Not able to read file$"
        arr1 db 20h dup(0)
        arr2 db 20h dup(0)
        handle dw ?
        d dw ?
.code
        mov ax,@data
        mov ds,ax
       
        mov ah,62h      ;dos fun gives source addr
        int 21h

        mov es,bx

        mov di,0082h    ;starting add of psp
        lea si,arr1
l1:     mov ah,es:[di]
        cmp ah,0dh
        jne r1
        jmp l3

r1:     mov [si],ah
        inc si
        inc di
        jmp l1
       
l3:     mov ah,3dh      ;opening file
        mov al,02h      ;dos command for read/write
        lea dx,arr1
        int 21h

        mov handle,ax
        jc l6
        disp msg1       ;open
        jmp r5

l6:     disp msg2       ; not open
        jmp l4

r5:     mov ah,42h
        mov al,02h      ;end of file
        mov bx,handle
        mov cx,0000h
        mov dx,0000h
        int 21h

        mov d,ax

        mov ah,42h
        mov al,00h      ;start of file
        mov bx,handle
        mov cx,0000h
        mov dx,0000h
        int 21h

l7:     mov ah,3fh
        mov bx,handle
        mov cx,d
        lea dx,arr2
        int 21h
        jc r2
        disp msg3       ;file can be read
        lea si,arr2
        jmp l8
r2:     disp msg4       ;can not read
        jmp l4

l8:
        mov dx,[si]
        mov ah,02h
        int 21h
        inc si
        dec cx
        jnz l8

l4:     mov ah,4ch
        int 21h
end


0 comments: