Category : C Source Code
Archive   : CEXPRESS.ZIP
Filename : WRTEND.ASM

 
Output of file : WRTEND.ASM contained in archive : CEXPRESS.ZIP
;void write_end(strg,col,row,length,color);
; unsigned char *strg,col,row,length,color;

EXTRN _memory_model:byte
EXTRN _video_buffer:word
EXTRN _snow_protect:byte
EXTRN _error_code:byte

_TEXT SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:_TEXT
PUBLIC _write_end
_write_end proc near
push bp ;
mov bp,sp ;set stack frame
push di ;
push si ;
cmp _memory_model,0 ;near or far?
jle begin ;jump if near
inc bp ;else add 2 to BP
inc bp ;
begin: push ds ;DS changed
cld ;set direction flag
mov ax,_video_buffer ;fetch _video_buffer
mov es,ax ;ES pts to buffer
mov bl,_snow_protect ;get _snow_protect before change DS
cmp _memory_model,2 ;data near or far?
jb L0 ;jump if near
lds si,dword ptr[bp+4] ;DS:SI pts to Strg
inc bp ;add 2 to BP since dword ptr
inc bp ;
jmp short L00 ;
L0: mov si,[bp+4] ;near case
L00: push si ;must find string length
sub cx,cx ;count in CX
L000: inc si ;forward strg ptr
inc cx ;inc counter
cmp byte ptr[si],0 ;end of string?
jne L000 ;loop if not
pop si ;SI back to start of string
sub ax,ax ;
mov al,[bp+8] ;get ROW value
mov byte ptr[bp+8],bl ;save _snow_protect
mov byte ptr[bp+9],1 ;_error_code 1 = len(Strg) > Length
dec ax ;count from zero
mov dl,160 ;160 bytes per line
mul dl ;times number rows
sub dx,dx ;
mov dl,[bp+10] ;move line length to DX
or dx,dx ;null?
jz L1 ;quit if so
mov byte ptr[bp+9],0 ;else 0 = no error
L1: cmp dx,cx ;Strg shorter?
jnae L2 ;jump ahead if so
sub dx,cx ;num chars at end of line
jmp short L3 ;jump ahead
L2: mov dx,0 ;else draw no extra chars
L3: sub bx,bx ;
mov bl,[bp+6] ;get COL value
mov di,bx ;
dec di ;count from zero
shl di,1 ;double for attri bytes
add di,ax ;now ES:DI pts to lst pos
mov ah,[bp+12] ;get attribute
L4: lodsb ;get a character
call WriteIt ;write char and attri
loop L4 ;go do next
L5: mov cx,dx ;num chars at end of line
mov al,32 ;space character
jcxz L7 ;jump if none to write
L6: call Writeit ;write char and attribute
loop L6 ;go do next
L7: pop ds ;restore DS
mov al,[bp+9] ;fetch Errorcode
mov _error_code,al ;set it
pop si ;
pop di ;
pop bp ;
sti ;reenable interrupts
cmp _memory_model,0 ;quit
jle quit ;
db 0CBh ;RET far
quit: ret ;RET near
_write_end endp
Writeit PROC ;_snow_protect routine
push dx ;save DX
cmp byte ptr[bp+8],0 ;protect against snow?
je R3 ;jump ahead if not
mov dx,3dah ;status byte address
mov bx,ax ;save char-attri in BX
R1: in al,dx ;get status byte
test al,1 ;test bit
jnz R1 ;loop till 0
cli ;disable interrupts
R2: in al,dx ;get status byte
test al,1 ;test bit
jz R2 ;loop till 1
mov ax,bx ;return char-attri to AX
R3: stosw ;write the character
pop dx ;restore DX
ret ;
WriteIt endp
_TEXT ENDS
END


  3 Responses to “Category : C Source Code
Archive   : CEXPRESS.ZIP
Filename : WRTEND.ASM

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/