;       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

ROW_OFS  EQU  160

_TEXT      SEGMENT
; Line 6
        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     $I18


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

        mov     WORD PTR [bp+12],0      ;retrace


        jmp     SHORT $L20001
$I18:

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

        jmp     SHORT $L20001
$WC20:


        mov     si,[bp+10]      ;attr
        mov     cl,8
        shl     si,cl
        mov     bx,[bp+8]       ;str
        inc     WORD PTR [bp+8] ;str
        mov     al,[bx]
        cbw
        or      si,ax

        cmp     WORD PTR [bp+12],0      ;retrace
        je      $I22


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

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


$I22:
        mov     ax,si
        stosw
        cli

$L20001:
        mov     bx,[bp+8]       ;str
        cmp     BYTE PTR [bx],0
        jne     $WC20

        pop     di
        pop     si
        mov     sp,bp
        pop     bp
        ret

_vputstr        ENDP
_TEXT   ENDS
END
