collectordave wrote:Can the compareMemory() return value be modyfied so that when comparing memory areas the return value is 0 when they are the same and the byte number beginning at 1 of the first byte that does not match?
That's not a good idea, because it would break existing code. What you need is another function.
idle was quicker ...
Anyway, in cases like this it's always a good idea to search the forum for "wilbert".
Or perhaps a simple function like the following might be sufficient:
Code: Select all
Procedure.i MemoryDiff (*mem1.Byte, *mem2.Byte, size.i)
; -- simple byte by byte comparison of two memory areas
; in : *mem1, *mem2: pointers to the memory areas
; size : number of bytes to compare
; out: offset where the first difference is, or
; -1 if both areas are identical or
; -2 on error
Protected offset.i, last.i=size-1
If *mem1 = 0 Or *mem2 = 0 Or size < 0
ProcedureReturn -2
ElseIf *mem1 = *mem2
ProcedureReturn -1
EndIf
For offset = 0 To last
If *mem1\b <> *mem2\b
ProcedureReturn offset
EndIf
*mem1 + 1
*mem2 + 1
Next
ProcedureReturn -1
EndProcedure