flat assembler
Message board for the users of flat assembler.
Index
> Windows > 64 bit not understood sub rsp,8 ! Goto page Previous 1, 2, 3, 4, 5, 6, 7, 8, 9 Next |
Author |
|
Ali.Z 22 Dec 2020, 10:23
just change them, your include folder\macro\procXX.inc
_________________ Asm For Wise Humans |
|||
22 Dec 2020, 10:23 |
|
Roman 22 Dec 2020, 10:27
Very nice !
Change here. Aligne there. Remember here. Modifi there. https://i.pinimg.com/originals/4b/5c/77/4b5c77afa8801e33164d8292ace71a3e.gif When to write my idea and program ? Last edited by Roman on 22 Dec 2020, 10:30; edited 1 time in total |
|||
22 Dec 2020, 10:27 |
|
Ali.Z 22 Dec 2020, 10:30
Roman wrote: Very nice ! then stop using macros and 64-bit programming. _________________ Asm For Wise Humans |
|||
22 Dec 2020, 10:30 |
|
Roman 22 Dec 2020, 10:32
Unfortunately I can not.
I write Directx 12. Directx 12 only 64 bits. And i love registers R8 to R15 and Xmm8 to xmm15 And cmp qword strings |
|||
22 Dec 2020, 10:32 |
|
revolution 22 Dec 2020, 10:35
You can also use locals
Code: proc my_proc locals my_value dq ? other_value dq ? endl mov [my_value],rsi mov [other_value],rdi endp |
|||
22 Dec 2020, 10:35 |
|
Ali.Z 22 Dec 2020, 10:37
Roman wrote: Unfortunately I can not. https://docs.microsoft.com/en-us/windows/win32/direct3d12/directx-12-programming-environment-set-up _________________ Asm For Wise Humans |
|||
22 Dec 2020, 10:37 |
|
Roman 22 Dec 2020, 13:07
I start Directx 12 on Windows 7
Microsoft porting DX12 to Win 7 And was only 64 bits dlls for DX12 https://www.nuget.org/packages/Microsoft.Direct3D.D3D12On7 I wrote a lot code for DX12 64 bits for one year. |
|||
22 Dec 2020, 13:07 |
|
FlierMate 09 May 2022, 09:06
I saw a member here use:
Code: and rsp, not 0xf Is it the same as...? Code: and rsp, -16 I am a bit confused, do we AND or SUB rsp or both? And why are there so many magic values, like 8, 16, 0x20, 0x100...? Are these numbers all working? Can someone explain? I am yet to migrate to 64-bit Windows programming. |
|||
09 May 2022, 09:06 |
|
revolution 09 May 2022, 09:11
Because of differing entry procedures from various sources it might be unknown what is the stack disposition upon the start of your code.
So to "fix" it you need to align the stack first, else you risk crashes. One method that always works is this: Code: and rsp, -16 ; or "and rsp, not 0x0f", it's the same Code: push rbp ; to assist the debugger for stack unwinding Code: sub rsp,8 Code: add rsp,-8 If you want your code to run, align the stack. If you want to risk "random" crashes, don't align. I recommend the first. It always works. Some debuggers might complain though, so your choice. |
|||
09 May 2022, 09:11 |
|
macomics 09 May 2022, 09:51
Quote:
Code: push 8 Code: push rax |
|||
09 May 2022, 09:51 |
|
revolution 09 May 2022, 10:21
If you are going to use push, then make it RBP IMO. Lose nothing, gain potential debugger support.
|
|||
09 May 2022, 10:21 |
|
macomics 09 May 2022, 13:37
revolution wrote: If you are going to use push, then make it RBP IMO. Lose nothing, gain potential debugger support. |
|||
09 May 2022, 13:37 |
|
revolution 09 May 2022, 13:42
Just because you can do something, doesn't mean it is better.
You can also do this: Code: sub rsp, 1 sub rsp, 1 sub rsp, 1 sub rsp, 1 sub rsp, 1 sub rsp, 1 sub rsp, 1 sub rsp, 1 |
|||
09 May 2022, 13:42 |
|
revolution 10 May 2022, 05:10
Or maybe this:
Code: .try: test rsp, 0x000000000000000f jz .aligned lea rsp, [rsp - 1] jmp .try .aligned: |
|||
10 May 2022, 05:10 |
|
bitRAKE 10 May 2022, 07:28
With larger data types or even just cache line aware leaf functions - it's useful to understand different techniques to get to a machine state that works for the needs of the code. My favorite is:
Code: MyFunction: .STACK_ALIGNMENT := 128 assert .STACK_ALIGNMENT > 0 \ & (.STACK_ALIGNMENT and (.STACK_ALIGNMENT - 1)) = 0 .FRAME := 1024 ; local data storage space needed enter .STACK_ALIGNMENT + .FRAME,0 and rsp,-.STACK_ALIGNMENT ; Reference aligned data types from RSP, ; and/or unaligned local storage from RBP. leave ; restore ambiguous RSP retn There are many reasons the stack could be unaligned in 64-bit windows: programs that don't use a common convention of alignment, use of external libraries that don't respect an alignment convention, etc. (If we doubted our own work, the ENTER instruction could be overloaded with a macro that provided detailed debug info when we have failed to align the stack at runtime.) _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
10 May 2022, 07:28 |
|
Furs 10 May 2022, 13:11
revolution wrote: Just because you can do something, doesn't mean it is better. |
|||
10 May 2022, 13:11 |
|
revolution 10 May 2022, 15:02
External exceptions (like from a debugger, or a task switch) should be immune the anything the app does with it's stack. It's actually possible to use RSP as a GP register if you want to, it really works, just don't try PUSH/POP/CALL/RET. You can use a fixed memory address to store the RSP value and restore when you are done.
Only the internally generated exceptions, with an internal handler, should be where a bad RSP may be a problem. |
|||
10 May 2022, 15:02 |
|
macomics 10 May 2022, 15:17
revolution wrote: External exceptions (like from a debugger, |
|||
10 May 2022, 15:17 |
|
Furs 11 May 2022, 11:53
revolution wrote: External exceptions (like from a debugger, or a task switch) should be immune the anything the app does with it's stack. Task switch is a separate matter since that's not even an exception raised for the app. It's completely unaware of it. I wasn't talking about that. |
|||
11 May 2022, 11:53 |
|
Goto page Previous 1, 2, 3, 4, 5, 6, 7, 8, 9 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.