[Implemented] Support for __stdcall

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

[Implemented] Support for __stdcall

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

Hello again :)

PureBasic for Windows should support
the calling conventions used by Windows.
Its __stdcall:
|Argument passing order: Right to left
|Called function pops its own ARGs from the stack


Stdcall is used in .DLLs etc...
so if i have to call a DLL, i have
to re-order the stack first.

Code: Select all

> CameraPosition(CAM-Num, x, y, z)
>  PB_CameraPosition:
>  POP  dword [tempadr]  ; ReturnAddress
>  POP  dword [temp01]   ; z
>  POP  dword [temp02]   ; y
>  POP  dword [temp03]   ; x
>  PUSH dword [temp01]   ;  z
>  PUSH dword [temp02]   ;  y
>  PUSH dword [temp03]   ;  x
>  PUSH dword EAX        ;  CAM-Num
>  CALL [adr_CameraPosition]
>  JMP  [tempadr] 
If PureBasic would support __sdtcall

Code: Select all

| .DESC-File:
|  CameraPosition:sdtcall, Long, Long, Long, Long
|  None 
it would be much easier and faster:

Code: Select all

>  PB_CameraPosition:
>  POP  dword [tempadr]  ; ReturnAddress
>  CALL [adr_CameraPosition]
>  JMP  [tempadr] 

Thanks for your attention,
...Danilo
(registered PureBasic user)

Edited by - Danilo on 24 December 2001 03:49:09