I am working on a memory allocation monitor, and part of the project involves hand-writing some assembly to copy some memory.
I have just a quick question which has me very confused. Here is a simple piece of code I am working on to make sure my rep movs bounds are addressed to valid memory segments:
// Bounds checking (ecx contains the copy source address)
verr cx // According to documentation, this should set ZF = 1 if segment cx is readable.
// When I am debugging, flag AC is being set = 1, which I understand to be
// the same as ZF.
jnz // According to documentation, "Jump near if not zero (ZF=0)".
// So it should skip to if cx is not readable.
// When debugging it is jumping if AC = 0 or AC = 1.
// Perform the copy of bytes
mov esi, ecx // Set source address
mov edi, eax // destination address
mov ecx, // number of byte to copy
rep movs byte [edi], byte [esi]
My problem is in the bound checking and my use of jnz and verr. Anyone know why it isn't working? According to the documentation I thought this would work.