Hello ,
The code probably doesnt use system calls-i am not sure. But there are some asm units that could take some time if we try to rewrite them in pascal. I am attaching one such code.
Thanks and Regards, Anuradha
PAGE 58,132 TITLE Compare routine PAGE ;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ;³ Following EQU has to be set to 0 for NEAR call {$L compress.obj} ³ ;³ 1 for FAR call {INTERFACE in unit} ³ ;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ; @_NEAR_FAR EQU 1 ; ;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ;³ Return codes for compare ³ ;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ; @C_RC_1G2 EQU -1 ; Return code first parameter greater @C_RC_1S2 EQU 1 ; Return code first parameter smaller @C_RC_1E2 EQU 0 ; Return code parameters equal PAGE ;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ;³ Do not change following equates ³ ;³ Internals and parameter definitions ³ ;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ; ; ; Pascal parameter offsets on stack ; @P_RET_ADD EQU 2*(@_NEAR_FAR+1) ; Size of the return address @P_SOURCE1 EQU [BP+@P_RET_ADD+14] ; Address of structure1 @P_OFFSET1 EQU [BP+@P_RET_ADD+12] ; Offset in structure1 @P_SOURCE2 EQU [BP+@P_RET_ADD+8] ; Address of structure2 @P_OFFSET2 EQU [BP+@P_RET_ADD+6] ; Offset in structure2 @P_LENGTH EQU [BP+@P_RET_ADD+4] ; Length to compare PAGE ;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ;³ Compare routine : ³ ;³ Definition in Pascal : ³ ;³ FUNCTION COMPARE( VAR structure 1 ; ³ ;³ offset in structure 1 : INTEGER ; ³ ;³ VAR structure 2 ; ³ ;³ offset in structure 2 : INTEGER ; ³ ;³ length to compare : WORD ) : INTEGER ; ³ ;³ Return codes : ³ ;³ See equates above. ³ ;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ; CODE SEGMENT BYTE PUBLIC 'CODE' ASSUME CS:CODE ; COMPARE PROC NEAR ; PUSH DS ; Save Pascal environment and PUSH BP ; get parameter addressablitity MOV BP,SP PAGE ;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ;³ Set source and target address for compare. ³ ;³ Initialize compare counter. ³ ;³ Do the compare ³ ;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ; COMP_000: LDS SI,@P_SOURCE1 ; DS:SI to structure 1 ADD SI,@P_OFFSET1 LES DI,@P_SOURCE2 ; ES:DI to structure 2 ADD DI,@P_OFFSET2 MOV CX,@P_LENGTH ; Compare counter JCXZ COMP_001 ; If nothing to compare then equal CLD REPE CMPSB ; Do the compare JE COMP_001 JB COMP_002 MOV AX,@C_RC_1G2 ; Return 1 greater than 2 JMP SHORT COMP_EX COMP_001: MOV AX,@C_RC_1E2 ; Return 1 equal 2 JMP SHORT COMP_EX COMP_002: MOV AX,@C_RC_1S2 ; Return 1 smaller than 2 PAGE ;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ;³ Return point : restore Pascal environment and remove parameters. ³ ;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ; COMP_EX: MOV SP,BP ; Delete local scratch path POP BP ; Restore Pascal environment POP DS IF @_NEAR_FAR RETF 14 ; Kill parameters and return ELSE RETN 14 ; Kill parameters and return ENDIF ; COMPARE ENDP ; CODE ENDS ; PUBLIC COMPARE ; END
Anuradha wrote:
The code probably doesnt use system calls-i am not sure. But there are some asm units that could take some time if we try to rewrite them in pascal. I am attaching one such code.
;³ Compare routine : ³ ;³ Definition in Pascal : ³ ;³ FUNCTION COMPARE( VAR structure 1 ; ³ ;³ offset in structure 1 : INTEGER ; ³ ;³ VAR structure 2 ; ³ ;³ offset in structure 2 : INTEGER ; ³ ;³ length to compare : WORD ) : INTEGER ; ³
A compare routine!? So what's wrong with MemComp (in the GPC unit)?
It doesn't have the offset parameters, but in most cases this will even make the invocation easier. E.g., if you previously used (I can only guess since you didn't give an example) Compare (Foo, i * SizeOf (Foo[0]), Bar, j * SizeOf (Bar[0]), s) you can now write MemComp (Foo[i], Bar[j], s) . And even in the unusual case that the offsets have nothing to do with the structure of the var parameters, you only need a type cast into a byte array or something (not exactly the cleanest Pascal, but still much better than asm code), or if you're afraid of changing the callers at all, it's easy to write a Compare function which does just that and calls MemComp.
Not meaning to be rude, but I really suggest you first look at the features GPC offers before deciding to use some self-made work-arounds. Unlike some other popular compilers, GPC has a rich set of built-in and library routines that cover many areas where with other compilers you might have to use some work-arounds.
Frank
PS: Your example file contains many strange characters:
;ÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÿ
etc. I suppose they should have been Dos graphic characters. But then your MIME headers are wrong:
Content-Type: text/plain; charset=iso-8859-1; name="New Text Document.txt"
^^^^^^^^^^^^^^^^^^