seg_a           segment byte public
                    assume  cs:seg_a, ds:seg_a


                    org     100h

    header          proc    far

    start:
                    mov     ah,0Fh
                    int     10h                     ; Video display   ah=functn 0Fh
                                                    ;  get state, al=mode, bh=page
                                                    ;   ah=columns on screen
                    push    ax
                    xor     ah,ah                   ; Zero register
                    mov     al,5
                    int     10h                     ; Video display   ah=functn 00h
                                                    ;  set display mode in al
                    mov     cx,51h
                    mov     ax,17Fh
                    sub     ax,1000h
                    mov     si,ax
    loc_1:
                    push    cx
                    push    si
                    pop     ds
                    push    ds
                    xor     si,si                   ; Zero register
                    mov     ax,0B800h
                    mov     es,ax
                    xor     di,di                   ; Zero register
                    mov     cx,4000h
                    rep     movsb                   ; Rep when cx >0 Mov [si] to es:[di]
                    pop     ax
                    add     ax,40h
                    mov     si,ax
                    pop     cx
                    sub     cx,1
                    cmp     cx,0
                    jne     loc_1                   ; Jump if not equal
                    call    sub_1
                    xor     ah,ah                   ; Zero register
                    int     16h                     ; Keyboard i/o  ah=function 00h
                                                    ;  get keybd char in al, ah=scan
                    pop     ax
                    mov     ah,0
                    int     10h                     ; Video display   ah=functn 00h
                                                    ;  set display mode in al
                    xor     ah,ah                   ; Zero register
                    int     21h                     ; DOS Services  ah=function 00h
                                                    ;  terminate, cs=progm seg prefx

    header          endp

    ;
    ;                              SUBROUTINE
    ;

    sub_1           proc    near
                    mov     cx,15h
                    xor     ax,ax                   ; Zero register
    loc_2:
                    push    cx
                    push    ax
                    mov     ds,ax
                    xor     si,si                   ; Zero register
                    mov     ax,0B800h
                    mov     es,ax
                    xor     di,di                   ; Zero register
                    mov     cx,4000h
                    repne   movsb                   ; Rep zf=0+cx >0 Mov [si] to es:[di]
                    push    cs
                    pop     ds
                    mov     ax,17Fh
                    mov     si,ax
                    mov     ax,0B800h
                    mov     es,ax
                    xor     di,di                   ; Zero register
                    mov     cx,4000h
                    repne   movsb                   ; Rep zf=0+cx >0 Mov [si] to es:[di]
                    pop     ax
                    pop     cx
                    add     ax,120h
                    sub     cx,1
                    cmp     cx,0
                    jne     loc_2                   ; Jump if not equal
                    retn
    sub_1           endp


    seg_a           ends



                    end     start