home *** CD-ROM | disk | FTP | other *** search
- {NO NEED TO LINK!!!}
-
- TYPE
- String255 = STRING[255];
-
- VAR
- HexDigits: ARRAY[0..15] OF CHAR;
- Str1,Str2: String255;
-
- FUNCTION HexByte(SourceByte: BYTE): INTEGER; Forward;
- PROCEDURE Concat(Var S1,S2: String255; Size1: INTEGER); Forward;
- {- In a PROGRAM, Use FORWARD in place of EXTERNAL -}
-
- Internal Example;
-
- DATA SEGMENT WORD PUBLIC
-
- EXTRN HexDigits:BYTE ;Not required by INTERNAL
-
- DATA ENDS
-
- CODE SEGMENT BYTE PUBLIC
-
- ASSUME CD:CODE,DS:DATA ;Not required by INTERNAL
-
- PUBLIC HexByte,Concat ;Not required by INTERNAL
-
- ; FUNCTION HexByte(SourceByte: BYTE): INTEGER; Forward;
-
- HexByte PROC NEAR
-
- MOV BX,SP
- MOV AL,SS:[BX+2] ; Get parameter
-
- Xor Ah,Ah ; set Ah = 0 to prevent Divide Overflow
- Mov Bl,010
- Div Bl ; Al = Quo, Ah = Rem
- Mov Bx,Offset HexDigits
- Xchg Al,Ah
- XlatB
- Xchg Al,Ah
- XlatB
- Ret 2 ; T4 & T5 Externals don't remove function result
-
- HexByte ENDP
-
-
-
- ; PROCEDURE Concat(Var S1,S2: String255; Size1: INTEGER); Forward;
-
- String1 EQU DWORD PTR [BP+10]
- String2 EQU DWORD PTR [BP+6]
- SizeOf1 EQU WORD PTR [BP+4]
-
- Concat PROC NEAR
-
- Push Bp
- Mov Bp,Sp
- Push Ds
- Xor Ax,Ax
- Mov Cx,SizeOf1
- Dec Cx ;Max length is Allocated size - 1
- Xor Ch,Ch ;In no case let str1 exceed 255
- Les Di,String1
- Lds Si,String2
- Lodsb ;length(S2)
- Add Al,Es:[Di] ;+Length(S1)
- jC L1 ;exceeds 255, use Limit
- Cmp Al,Cl
- jA L1 ;exceeds Limit (use Limit)
- Mov Cl,Al ;else use sum of lengths
- Jmp Short L2
- L1: Mov Al,Cl
- L2: Sub Cl,Es:[Di] ;New length - old length(S1)
- jBE Done ;New < Old, don't shorten
- Xchg Al,Es:[Di] ;Put in new length, get old
- Inc Di ;skip length byte
- Add Di,Ax ;and original string to set dest
- Rep Movsb ;Concatenate
- Done: Pop Ds
- Pop Bp
- Ret 10
-
- Concat ENDP
-
-
- CODE ENDS
-
- END (Internal Example)
-
-
- CONST Result: RECORD
- Len: BYTE;
- Wrd: INTEGER;
- END = (Len:2;Wrd:0);
- VAR
- n: BYTE;
- ResultString: STRING[2] Absolute Result;
-
- BEGIN {Main Program}
- {- Demonstrate HexByte -}
- HexDigits:= '0123456789ABCDEF';
- FOR n := 0 TO 255 DO BEGIN
- WRITE(n:3,' ');
- Result.Wrd := HexByte(n);
- WRITE(ResultString,' ');
- END; {FOR n := 0 TO 255 DO }
- WRITELN;
- {- Demonstrate Concat -}
- Str1 := 'String1';
- Str2 := 'String2';
- WRITELN('Before Concat: ',Str1);
- FOR n := 1 TO 5 DO BEGIN
- Concat(Str1,Str2,SizeOf(Str1));
- WRITELN('After Concat',n,': ',Str1);
- END; {FOR n := 1 TO 5 DO }
- Concat(Str1,Str2,45);
- WRITELN('Partial Concat: ',Str1);
- END. {Main}
-