home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Shareware - Software Farm 2
/
wosw_2.zip
/
wosw_2
/
CPROG
/
CEXPRESS.ZIP
/
SCREEN.ASM
/
WRTENDB.ASM
< prev
next >
Wrap
Assembly Source File
|
1989-05-03
|
3KB
|
91 lines
;void write_end_b(strg,col,row,length,color);
; unsigned char *strg,col,row,length,color;
EXTRN _memory_model:byte
EXTRN _error_code:byte
EXTRN _video_page:byte
_TEXT SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:_TEXT
PUBLIC _write_end_b
_write_end_b proc near
push bp ;
mov bp,sp ;set up 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: mov bh,_video_page ;set video page
push ds ;save 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: mov byte ptr[bp+4],1 ;_error_code 1 = 0 Length
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 dx,dx ;
mov dl,[bp+10] ;length of line
or dx,dx ;test for zero Length
jnz L1 ;jump if nonzero
mov byte ptr[bp+4],0 ;0 = no error
L1: sub ax,ax ;AX holds number trailing spaces
cmp cx,dx ;strg >= Length?
jae L2 ;jump ahead if so
sub dx,cx ;minus Strg length
mov ax,dx ;number trailing spaces
L2: mov di,cx ;DI holds Strg Length
mov dh,[bp+8] ;Row to DH
dec dh ;count from 0
mov dl,[bp+6] ;Col to DL
dec dl ;count from 0
mov bl,[bp+12] ;Attribute to BL
mov bp,ax ;number trailing chars
mov cx,1 ;chars to wrt each time
mov ah,2 ;func to set cursor
int 10h ;set initial cursor pos
or di,di ;test for zero strg len
jz L4 ;jump ahead if null
L3: mov al,[si] ;get a char
inc si ;forward string ptr for next time
mov ah,9 ;function to write char
int 10h ;write the char
inc dl ;forward column pos
mov ah,2 ;function to set cursor
int 10h ;reset cursor
dec di ;end of string?
jnz L3 ;loop till finished
L4: or bp,bp ;test for no chars clear
jz L6 ;jump ahead if none
L5: mov al,32 ;now write space char
mov ah,9 ;function to write char
int 10h ;write the char
inc dl ;forward column pos
mov ah,2 ;function to set cursor
int 10h ;reset cursor
dec bp ;end of line?
jnz L5 ;loop till end of line
L6: pop ds ;restore DS
mov al,[bp+4] ;fetch _error_code
mov _error_code,al ;set it
pop si ;
pop di ;
pop bp ;
cmp _memory_model,0 ;quit
jle quit ;
db 0CBh ;RET far
quit: ret ;RET near
_write_end_b endp
_TEXT ENDS
END