I. Call and RET directives
Second, in the sub-process, you need to save the value of the register may be modified, here you can use the uses pseudo-directive to generate
Compilation example of a city array summation
1TITLEPagera Proc Demo2INCLUDE Irvine32.Inc3 includelib Irvine32.lib4 includelib Kernel32.lib5 includelib User32.lib6 7 8 . Data9 Array DWORD 1000h,2000h,3000h,4000hTen One . Code A - ;--------------------------------------------------- - ; the ;Calcute The sum of an array of 32-bit int integers - ;Receives:esi = the array offset - ;ECX = the size of array - ;returns:eax = Sum of an array + ;--------------------------------------------------- - + arraysum PROC A at PushESI - Pushecx - moveax0 - L1: - AddEax,[esi] - AddEsi,type DWORD in Loop L1 - to Popecx + PopESI - ret the * arraysum ENDP $ Panax Notoginseng ;--------------------------------------------------- - ; the ;Calcute The sum of an array of 32-bit int integers + ;Receives:esi = the array offset A ;ECX = the size of array the ;returns:eax = Sum of an array + ;--------------------------------------------------- - $ arraysumwithuses PROC USES esi ecx $ - moveax0 - L2: the AddEax,[esi] - AddEsi,type DWORDWuyi Loop L2 the - ret Wu - arraysumwithuses ENDP About $ - - Main PROC - A movEsi,offset Array + movEcx,lengthof Array the PagerArraysum - PagerDumpregs $ movEsi,offset Array the movEcx,lengthof Array the Pagerarraysumwithuses the PagerDumpregs the ret - in main ENDP the theEND Main
Execution Result:
"Intel Assembler 5th Edition" Assembly Call sub-procedure