"Intel Assembler 5th Edition" Assembly Call sub-procedure

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.