The MASM Forum

General => The Campus => Topic started by: HSE on July 25, 2016, 09:52:53 AM

Title: rep movsb error in Win 7?
Post by: HSE on July 25, 2016, 09:52:53 AM
Hi!

Why I obtain an error at program closing using this macro? There is no error if I allow winXP compatibility in exe properties.

CopiaObjeto macro tipo_de_objeto, ObjectDest, ObjectOrig

DbgText "CopiaObjeto macro"
;int 3
push esi
push edi
push ecx
pushfd

mov edi, &ObjectDest;[Dest]
    cld
    mov esi, &ObjectOrig
    mov ecx , sizeof TPL_&tipo_de_objeto;[ln]
    rep movsb

    popfd
    pop ecx
pop edi
pop esi
endm


Thanks in advance.
Title: Re: rep movsb error in Win 7?
Post by: hutch-- on July 25, 2016, 10:45:14 AM
That code should work anywhere. What are the instructions "pushfd" "popfd" being used for when the data copy has nothing to do with processor flags ?
Title: Re: rep movsb error in Win 7?
Post by: HSE on July 25, 2016, 12:37:00 PM
Thanks Hutch!
I put all the push and pop just in case ("cld" change direction flag). Only "esi" need to be preserved.   
The extrange thing is that Xp compatibilty remove the issue, it's almost the same code you showed for 64bits.
Title: Re: rep movsb error in Win 7?
Post by: jj2007 on July 25, 2016, 04:39:38 PM
What is "an error"? What do you see happen in the debugger after the int 3?
Title: Re: rep movsb error in Win 7?
Post by: HSE on July 25, 2016, 11:36:30 PM
If rep it's not the problem then... I'm overwriting something necesary to dipose the objects!  :icon_redface:  And trying to destroy 2 times the same object result in a random jump (theory here).

I'm sure in ObjAsm there is an especific function, but it's a little hard to find  :icon_eek:.

Hutch: Perhaps you can move the topic to ObjAsm, because (I think now) the issue is related to that (another option it's subforum "Beer abstinence consequences")  :biggrin: .

Thanks very much. 

Working: CopiaObjeto macro tipo_de_objeto, ObjectDest, ObjectOrig

push esi

    cld
mov edi, &ObjectDest;[Dest]
    add edi , 16
    mov esi, &ObjectOrig
    add esi, 16
    mov ecx , sizeof TPL_&tipo_de_objeto;[ln]
    sub ecx , 16
    rep movsb

pop esi
endm