NO

Author Topic: Example code with the FASTCALL convention  (Read 6501 times)

Offline Vortex

  • Member
  • *
  • Posts: 865
    • http://www.vortex.masmcode.com
Example code with the FASTCALL convention
« on: April 27, 2008, 07:39:58 PM »
Here is a demo with the FASTCALL calling convention :

Code: [Select]
.386
.model flat
option casemap:none

.code

CopyString PROC FASTCALL USES ebx dest:DWORD,src:DWORD

; ecx -> destination
; edx -> source

    mov     eax,-1
@@:
    add     eax,1
    movzx   ebx,BYTE PTR [edx + eax]
    mov     BYTE PTR [ecx + eax],bl
    test    ebx,ebx
    jnz     @b
    ret

CopyString  ENDP

END

Code: [Select]
.386
.model flat,stdcall
option casemap:none

includelib  "C:\PellesC\lib\win\kernel32.lib"
includelib  msvcrt.lib

ExitProcess PROTO :DWORD
printf      PROTO C :DWORD,:VARARG

CopyString PROTO FASTCALL dest:DWORD,src:DWORD

.data
src     db 'This is a test string.',0
message db 'Destination buffer = %s',13,10,0

.data?
dest    db 100 dup(?)

.code

start:

    invoke  CopyString,ADDR dest,ADDR src
    invoke  printf,ADDR message,ADDR dest
    invoke  ExitProcess,0

END start
Code it... That's all...