home *** CD-ROM | disk | FTP | other *** search
- ;**********************************************************************
- ; type
- ; AnyString = string[255];
- ;
- ; Function LEFT(S : AnyString; N : integer; C : Char); AnyString;
- ; external 'B:LEFT';
- ;**********************************************************************
- LEFT proc near
- push bp
- mov bp,sp
- push ds
- lea si,[bp+9] ; first character of string to center
- lea bx,[bp+264] ; length byte of centered string
- mov ax,[bp+6] ; get N
- mov ss:[bx],al ; set length of centered string
- inc bx ; point to 1st byte of result
- mov cl,[bp+8] ; length of string to center
- xor ch,ch
- sub ax,cx
- ja lef1
- xor ax,ax
- jmp lef2
- ;
- lef1: mov di,bx
- add di,cx ; point to 1st byte of pad
- mov cx,ax ; get length of pad
- mov ax,[bp+4] ; get fill-byte
- push ss
- pop es
- cld
- rep stosb ; pad result on right
- ;
- lef2: mov di,bx
- push ss
- pop ds
- mov cl,[bp+8] ; length of string to left-justify
- xor ch,ch
- cld
- rep movsb
- ;
- pop ds
- mov sp,bp
- pop bp
- pop bx ; pop IP value into bx . . .
- mov ax,cs:[bx] ; . . . to peek at call compiler
- cmp ax,0FFB1h ; has set up. If its CALL 121E
- jnz lef3 ; we want to skip it,
- add bx,5 ; because it messes with SP.
- lef3: push bx ; put IP back where we found it
- ret 260 ; leave result on stack
- LEFT endp