A group of people raised a strange problem, the loop of this code is not normal
; Masmplus code Templates-Console programs
.386
. Model Flat, StdCall
Option Casemap:none
Include Windows.inc
Include User32.inc
Include Kernel32.inc
Include Masm32.inc
Include Gdi32.inc
Includelib Gdi32.lib
Includelib User32.lib
Includelib Kernel32.lib
Includelib Masm32.lib
Include Macro.asm
. Data
Lpmsg db "Hello world!", 0
. Data?
Buffer db Max_path dup (?)
. CODE
START:
MOV ecx,5
@@:
Invoke Messageboxa,null,ctext (""), Ctext ("" "), MB_OK
Loop @B
Invoke exitprocess,0
End START
The reason loop equals ECX-1, and then look at ecx==0, if not loop, if not equal to the loop, but this ecx is not 5
Adding Pushad Popad before and after calling the API is normal.
;masmplus Code Templates-Console programs.386. Model flat, Stdcalloption casemap:noneinclude windows.Incinclude User32.Incinclude KERNEL32.Incinclude Masm32.Incinclude GDI32.Incincludelib gdi32.libincludelib user32.libincludelib kernel32.libincludelib masm32.libinclude macro.asm.data LPMSG DB"Hello world!",0. Data? Buffer db Max_path dup (?) . CODESTART: movEcx5@@: PushadInvoke Messageboxa,null,ctext (" -"), Ctext (" -"), MB_OKPopadLoop @B invoke ExitProcess,0End START
In the assembly if the assembly and call API mix, pay attention to Pushad Popad