flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
tthsqe 13 Jan 2022, 17:29
> Changing number to dq makes the first and last example work if all the registers are changed to the x64 version
I think the vararg arguments to printf are all void* like hence are treated like "integer" arguments in the ABI. Certainly I wouldn't expect printf to look in xmm0 fir an argument as the function is not type safe. |
|||
![]() |
|
Rick 13 Jan 2022, 19:26
tthsqe wrote: > Changing number to dq makes the first and last example work if all the registers are changed to the x64 version Good one, never thought about that, I'll try it that way. |
|||
![]() |
|
Rick 13 Jan 2022, 19:33
I've found the solution, it's indeed required to pass the arguments as if integer arguments as @tthsqe mentioned. Here the final solution:
Code: format PE64 console entry start include "../include/macros/import.inc" include "../include/macros/proc64.inc" include "../include/macros/struct.inc" include "../include/macros/import64.inc" section '.data' data readable writeable number dd 12.1 fmt db 'The number is %f',10,0 section '.text' code readable executable start: sub rsp, 8 ; 16bit align cvtss2sd xmm0, DWORD PTR number ; convert single to double precision movq rdx, xmm0 ; move into rdx as argument lea rcx, [fmt] call [printf] invoke ExitProcess, 0 section '.idata' import data readable writeable library kernel, 'KERNEL32.DLL',\ msvcrt, 'MSVCRT.DLL' import kernel,\ ExitProcess,'ExitProcess' import msvcrt,\ printf, 'printf' |
|||
![]() |
|
tthsqe 14 Jan 2022, 13:41
Note that the MS ABI and system V ABI are quite different on printf: in linux you would indeed put the floating point arguments in xmm0, xmm1, ... , and then tell it the number of floating point arguments you used in `al`. This works up to 8 floating point arguments, then the rest are put on the stack.
|
|||
![]() |
|
Roman 15 Jan 2022, 11:09
Quote: sub rsp, 8 ; 16bit align Its align 64 bits! |
|||
![]() |
|
macomics 15 Jan 2022, 12:10
Code: push rax ; shorter ; OR and spl, -16 ; correct align 128 bits Roman wrote:
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.