Trying to get this to work. Just a "my first" program to help me make the transition mentally to x64, but it crashes if printf is invoked - why? Commenting out printf makes it not crash, and the stack pointer is the same at the start of the program as it is before the ret.
Yes, Windows.
include 'win64a.inc'
format PE64 Console 4.0
entry main
section '.text' code data readable executable
main:
mov rdx, rsp
mov rcx, text
call [printf]
xor rax,rax
ret
text db "It's 5 AM. Do you know where your stack pointer is? (%016x)", 10, 0
align 16
data import
library msvc,'msvcrt.dll'
import msvc,printf,'printf'
end data
Name:
Anonymous2012-05-26 17:22
filling a nop spot with something that needs something else
Name:
Anonymous2012-05-26 18:06
Had another crack at it and found out it's clobbering the top of the stack - is there any justification whatsoever for this?
Name:
Anonymous2012-05-26 18:33
>>3
x86 is shit, use MIPS, ARM or PowerPC instead.
Name:
Anonymous2012-05-26 18:42
>>1 x64
It would help if you wrote asm for an existing processor architecture. I'm going to assume the x in x64 stands for PPC, which also explains why it won't compile since that shit ain't valid PPC64 code
In the Microsoft x64 calling convention, it's the caller's responsibility to allocate 32 bytes of "shadow space" on the stack right before calling the function (regardless of the actual number of parameters used), and to pop the stack after the call. The shadow space is used to spill RCX, RDX, R8, and R9.
Name:
Anonymous2012-05-27 15:10
>>10
Not one version of Microsoft software is even compiled for PPC64. Fuck, those registers aren't even valid PPC64. You're not making any sense