.386; 32-bit architecture. Model Flat, Stdcall;include masm32.incinclude kernel32.incincludelib masm32.libincludelib Kernel32.lib.data; Data segment Sztext db "Hello asm!", 0.code; code snippet testprint proc near; process declaration push EBP; Save stack Base address register mov EBP , esp; new stack sub esp,100h; open a new 256-byte stack space push ebx; Save the base register push ESI; Save the source address push EDI; Save the destination change address Lea edi,[ebp-100h]; The new stack top address to Edimov ecx,40h; Set the number of copies mov eax,0cccccccch; Copy the value Rep STOs dword ptr Es:[edi]; Copy the contents of the EAX to the place where the EDI is pointing mov eax,[ebp+8]; Take out the first parameter push eax, transfer eax to StdOut function call StdOut; invoke function pop edi; restore edipop esi; restore esipop ebx; restore Ebpmov esp,ebp; restore Esppop ebp; Restore Ebpret; function returns testprint Endpstart:lea eax,sztext; fetch string push eax; call Testprint; invoke function pop eax; restore stack balance end start
Win32 assembly: HELLOASM