flat assembler
Message board for the users of flat assembler.
Index
> Main > Stack Realignment "Techniques" Goto page Previous 1, 2, 3, 4, 5, 6, 7, 8 Next |
Author |
|
system error 03 Sep 2017, 10:19
That's due to your poor understanding of "requirement" vs "recommendation". It is not my fault. Btw, you can also save something in the memory. You don't have to use any non-volatiles register. See, that's the difference between "recommendation" vs "requirement".
Requirement: First integer argument: RCX. Violate this, and your face will be BOOMED. Recommendation: rbx, rsi, rdi,.... blah blah blah. But you can always use a memory for saving data. Not necessarily using non-volatiles registers. No boom. hehehehe xD |
|||
03 Sep 2017, 10:19 |
|
revolution 03 Sep 2017, 10:19
system error wrote: Scratching R15 will not create any boom if you're not interested in using or preserving it. But the opposite of that is this: If you call a C function it makes no difference what you put in R15, it will ignore it, and it will preserve it. If you call an API function it makes no difference what you put in R15, it will ignore it, and it will preserve it. And an alternative to that is this: If your internal code follows random calling conventions, then when calling another function it might or might not care about R15 and/or might or might not preserve R15. But that is your own lookout to make sure everything works as expected. Like I mentioned above I also call this mode "chaos". It creates some wonderful bug hunting problems, unless you are really really careful about absolutely everything. And making small changes can become a nightmare. |
|||
03 Sep 2017, 10:19 |
|
system error 03 Sep 2017, 10:26
revolution wrote:
C functions uses no R15. If I were to create a callable function from C, I'll stick to the RCX, RDX, R8, R9..... and the XMMs. That's the ABI 64 CONVENTION. How difficult is this to be fully understood? xD |
|||
03 Sep 2017, 10:26 |
|
revolution 03 Sep 2017, 10:33
system error wrote: C functions uses no R15. system error wrote: If I were to create a callable function from C, I'll stick to the RCX, RDX, R8, R9..... and the XMMs. That's the ABI 64 CONVENTION. How difficult is this to be fully understood? xD |
|||
03 Sep 2017, 10:33 |
|
sinsi 03 Sep 2017, 11:04
Quote: That's due to your poor understanding of "requirement" vs "recommendation". Genuine question: is English your first language? sinsi wrote:
Must=Required May=Recommended |
|||
03 Sep 2017, 11:04 |
|
system error 03 Sep 2017, 11:08
Preserving R15 or any other non-volatiles doesn't involve any specific ABI requirement. In assemblers book for beginners, it is called "CHAPTER 2: PRESERVING ANY REGISTERS". It's just a general technique commonly employed everywhere from 8-bit processors to 64-bit processors of the x86 family.
push rbx call aWinApi pop rbx This is just a recommendation if you wished to preserve RBX. You are not FORCED to save it if you don't want it to. This is why it serves as "recommendation" rather than "requirement". It is up to the users! This techniques is EXACTLY THE SAME in dealing with 32-bit APIs. It's called register preservation. Not a specific 64-bit ABI requirement. |
|||
03 Sep 2017, 11:08 |
|
revolution 03 Sep 2017, 11:16
system error wrote: push rbx BTW: No one has proposed the example you show above except you, so you have in fact created a strawman argument which you then argue against. So it appears that we are all in violent agreement. Yay. End of thread? |
|||
03 Sep 2017, 11:16 |
|
system error 03 Sep 2017, 11:18
sinsi wrote: You seem to have it backwards... No smarty pant, just use this simple register-preservation technique, IF, you want to preserve it. Code: mov rcx,5 push rcx @@: call AWinAPI ;RCX possibly used and not saved as per the ABI pop rcx dec rcx jnz @b This technique is also availlable in 32-bit APIs. It's common sense - you want to use it later, just preserve it. You don't create a special stack frame inside it for ALL non-volatiles or else your code will be EXTREMELY BLOATED. Probably more bloated than your brain. hahahaha xD THEN AGAIN, since it is a recommendation and not a 64-bit requirement, you can also do this; Code: mov rcx,5 mov [_rcx],rcx @@: call AWinAPI ;RCX possibly used and not saved as per the ABI mov rcx,[_rcx] dec rcx jnz @b See smarty pant. That's why we call it recommendation. It's up to you if you want to save it, how you want to it and where you want to preserve it. xD I say your English is not good enough to make you FULLY understand a simple technical documentation. You need something else... like BANGING YOUR HEAD to the wall. hahahaha xD |
|||
03 Sep 2017, 11:18 |
|
revolution 03 Sep 2017, 11:22
system error: RCX is defined in the ABI as volatile. Once again this is your strawman argument. You setup a situation where RCX (a volatile) requires saving and then state that it requires saving (umm well yeah of course). But no one else said that RCX didn't need saving, only you. And once again we are in violent agreement. Yay. Now end of thread?
Last edited by revolution on 03 Sep 2017, 11:23; edited 1 time in total |
|||
03 Sep 2017, 11:22 |
|
system error 03 Sep 2017, 11:22
revolution wrote:
You probably have no idea that users also create a ABI-compliant API codes. Now let me see how you would implement all the non-volatile savings in your stack frame. Then you'll understand what I meant by "recommendation" vs "requirements". Well, you asked for it xD |
|||
03 Sep 2017, 11:22 |
|
system error 03 Sep 2017, 11:24
revolution wrote: system error: RCX is defined in the ABI as volatile. Once again this is your strawman argument. You setup a situation where RCX (a volatile) requires saving and then state that it requires saving. But no one else said that, only you. And once again we are in violent agreement. Yay. Now end of thread? Not my code. It's Sinsi's code. I am just demonstrating where he missed the point of register preservations. Now you're starting to sound like an idiot too. Are you really that MAD? hahahaha xD |
|||
03 Sep 2017, 11:24 |
|
revolution 03 Sep 2017, 11:24
system error wrote: You probably have no idea that users also create a ABI-compliant API codes. Now let me see how you would implement all the non-volatile savings in your stack frame. Then you'll understand what I meant by "recommendation" vs "requirements". Well, you asked for it xD |
|||
03 Sep 2017, 11:24 |
|
system error 03 Sep 2017, 11:25
revolution wrote:
Of course you don't. You are clueless right from the beginning anyway. HAHAHA xD |
|||
03 Sep 2017, 11:25 |
|
revolution 03 Sep 2017, 11:26
system error wrote: Not my code. It's Sinsi's code. I am just demonstrating where he missed the point of register preservations. Now you're starting to sound like an idiot too. Are you really that MAD? hahahaha xD |
|||
03 Sep 2017, 11:26 |
|
system error 03 Sep 2017, 11:33
revolution wrote:
So I preserved it for him the usual "preserving the register" way. What's your problem? Are you extremely mad at me? xD |
|||
03 Sep 2017, 11:33 |
|
revolution 03 Sep 2017, 11:40
system error wrote: So I preserved it for him the usual "preserving the register" way. What's your problem? system error wrote: Are you extremely mad at me? xD |
|||
03 Sep 2017, 11:40 |
|
sinsi 03 Sep 2017, 11:43
Stack frame, stack frame, stack frame.
What? Quote: BANGING YOUR HEAD to the wall Bye bye |
|||
03 Sep 2017, 11:43 |
|
system error 03 Sep 2017, 11:44
revolution wrote:
I will continue the discussion once you have calmed your tits down. In the mean time, try to figure out how "saving ALL the non-volatiles" in your ABI-compliant functions would look like. Cheers xD |
|||
03 Sep 2017, 11:44 |
|
system error 03 Sep 2017, 11:46
sinsi wrote: Stack frame, stack frame, stack frame. hahaha. You are one funny guy. That's more like it. Why so serious? xD |
|||
03 Sep 2017, 11:46 |
|
Goto page Previous 1, 2, 3, 4, 5, 6, 7, 8 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.