;       Static Name Aliases
;
        TITLE   vputstr
;       NAME    vputstr.C

        .287
_TEXT   SEGMENT  BYTE PUBLIC 'CODE'
_TEXT   ENDS
_DATA   SEGMENT  WORD PUBLIC 'DATA'
_DATA   ENDS
CONST   SEGMENT  WORD PUBLIC 'CONST'
CONST   ENDS
_BSS    SEGMENT  WORD PUBLIC 'BSS'
_BSS    ENDS
DGROUP  GROUP   CONST,  _BSS,   _DATA
        ASSUME  CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP
EXTRN   __chkstk:NEAR

_TEXT      SEGMENT

        PUBLIC  _vputstr
_vputstr        PROC NEAR
        push    bp
        mov     bp,sp
        mov     ax,6
        call    __chkstk
        push    si
        push    di

;       row = 4
;       col = 6
;       str = 8
;       attr = 10
;       retrace = 12
;       register si = c
;       scr_ofs = -6

        mov     ah,15
        int     10h
        cmp     al,7
        jne     $color

        mov     WORD PTR [bp+12],0      ;retrace
        mov     dx,0b000h
        jmp     short $ocalc
$color:
        mov     dx,0b800h
$ocalc:
        mov     es,dx

        mov     ax,160
        mov     bx,WORD PTR [bp+4]          ;row
        mul     bx
        mov     cx,[bp+6]       ;col
        shl     cx,1
        add     ax,cx
        mov     di,ax       ;scr_ofs

        mov     ah,BYTE PTR [bp+10]      ;attr
        mov     si,[bp+8]       ;str
        mov     cx,WORD PTR [bp+12]    ;retrace
        cld

$WC20:
        lodsb
        cmp     al,0
        je      cleanup
        jcxz    $I22                    ;retrace

        push    ax
        mov     dx,3dah
$WC24:
        in      al,dx
        test    al,1
        jne     $WC24

        sti
$WC26:
        in      al,dx
        test    al,1
        je      $WC26
        pop     ax

$I22:
        stosw
        cli
        jmp     $WC20

cleanup:

        pop     di
        pop     si
        mov     sp,bp
        pop     bp
        ret

_vputstr        ENDP
_TEXT   ENDS
END
