flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > proc stdcall64

Author
Thread Post new topic Reply to topic
Fatih



Joined: 13 Nov 2010
Posts: 6
Fatih
Hi.

I Need translated version of proc32.inc to programming 64 bit programming

All register/mem pushed 64 bit
[rsp+xx] points parameters
calling conversation is stdcall

Thanks all


Description: \fasmw16916\INCLUDE\MACRO\PROC32.INC
Download
Filename: PROC32.INC
Filesize: 7.93 KB
Downloaded: 60 Time(s)

Post 13 Nov 2010, 20:24
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
Fatih,

MACRO\PROC64.INC isn't good enough?
Post 13 Nov 2010, 20:48
View user's profile Send private message Reply with quote
Fatih



Joined: 13 Nov 2010
Posts: 6
Fatih
No. i want to programming stack frame based. No fastcall

I want translated ver. of proc32.inc
32 bit stdcall -> 64 bit stdcall


;sample code
;--------------------------------------------------

org 0
use64
main:
;parameters pushed on stack on reverse order
;--------------------------------------------------
stdcall stdcall64, r8, r9, [color]
retq


align 4
proc stdcall64 stdcall uses rax r8 r15, \
@x:QWORD, @y:QWORD, @color:QWORD

;all parameters on stack. not on regs
;--------------------------------------------------
mov r12,[@x]
mov r15,[@y]
........
retq
endp


align 4
color dq 0xffffff
Post 13 Nov 2010, 20:54
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
Fatih,

You don't have to follow standard calling conventions, and Tomasz don't have to follow your desires. I think it's fair.
Post 13 Nov 2010, 21:18
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3025
Location: vpcmipstrm
bitRAKE
The current package macros should be sufficient examples to construct similar 64-bit macros. Please, post what you have and we can help work through your implementation. Wink
Post 14 Nov 2010, 03:34
View user's profile Send private message Visit poster's website Reply with quote
Fatih



Joined: 13 Nov 2010
Posts: 6
Fatih
Code:
;Assembly Code:
;------------------------------------------------------
include "proc32.inc"

org 0
use64 
main: 
        ;parameters pushed on stack on reverse order
        ;--------------------------------------------------
        stdcall stdcall64, r8, r9, qword 1 
        ret


align 4 
proc stdcall64 stdcall uses rax r8 r15, \ 
     @x:QWORD, @y:QWORD, @color:QWORD

        mov r12,[@x]
        mov r15,[@y]
        ret
        ;retq ;if retq used stack cleaning (leave, ret 0x18) not inluded.
endp


Disassembly Code:
;------------------------------------------------------
00000000  6801000000        push dword 0x1            ;WRONG!!!!!!!!!!
00000005  4151              push r9
00000007  4150              push r8
00000009  E802000000        call dword 0x10
0000000E  C3                ret
0000000F  90                nop
00000010  55                push rbp
00000011  4889E5            mov rbp,rsp
00000014  50                push rax
00000015  4150              push r8
00000017  4157              push r15
00000019  4C8B6508          mov r12,[rbp+0x8]
0000001D  4C8B7D10          mov r15,[rbp+0x10]
00000021  415F              pop r15
00000023  4158              pop r8
00000025  58                pop rax
00000026  C9                leave
00000027  C21800            ret 0x18    


and modified proc32.inc file below

NOTE: changed macro instruction only
esp -> rsp
pushd -> pushq


Description: modified proc32.inc file
Download
Filename: PROC32.INC
Filesize: 7.93 KB
Downloaded: 55 Time(s)

Post 14 Nov 2010, 14:35
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3025
Location: vpcmipstrm
bitRAKE
No such instruction as PUSH imm64.

stdcall stdcall64, r8, r9, 1

PUSHQ, PUSHD, etc... are superfluous - if the general form were used then the macros could be used across USE16, USE32, USE64 with little or no change. FASM selects the appropriate instruction based on code selection.
Post 14 Nov 2010, 16:33
View user's profile Send private message Visit poster's website Reply with quote
Fatih



Joined: 13 Nov 2010
Posts: 6
Fatih
Thanks baldr & bitRAKE for help

I have to work a little more "AMD64 Architecture Programmer’s Manual Volume 3: General-Purpose and System Instructions"

Good work
Post 14 Nov 2010, 19:57
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.