Author Topic: OPTION STACKBASE also broken in x64  (Read 8199 times)

jj2007

  • Member
  • *****
  • Posts: 10026
  • Assembler is fun ;-)
    • MasmBasic
Re: OPTION STACKBASE also broken in x64
« Reply #30 on: March 22, 2017, 01:18:02 PM »
aw27, your 64 bit example is a mirror of your programming skills.

I have not seen any evidence so far that you know how to program. You are just unable to cope with any issue.  :badgrin:

Folks,

You are both lightyears ahead of the average programmer (same for John & Steve, of course). You are working in an extremely tricky language, in an area that is so far badly explored. It is understandable that in certain moments the stress takes over and lets you write such things, but don't forget that you have a common goal: The best assembler in 64-bit land. You are damn close to that goal, don't spoil the party :icon14:

P.S.: I've great sympathy for Hutch' proposal to reduce the options, or at least to make them secret and officially undocumented. Frameless is pretty useless IMHO, no need to save ebp, as you have a bunch of new registers in 64-bit land. And it was never significantly faster.

habran

  • Member
  • *****
  • Posts: 1220
    • uasm
Re: OPTION STACKBASE also broken in x64
« Reply #31 on: March 22, 2017, 01:43:19 PM »
HI hutch--,
now you are talking... thank you for confirming our thoughts :t
We'll do exactly that 8)
Cod-Father

habran

  • Member
  • *****
  • Posts: 1220
    • uasm
Re: OPTION STACKBASE also broken in x64
« Reply #32 on: March 22, 2017, 02:08:40 PM »
Hi jj2007 :biggrin:
Thank you for the flowers  :bgrin:
Long time ago I've learned in my life that to give choice to people is a big mistake, because they will always chose the worst option,
so, you do that only if you don't care about them.

So, we will probable give 3 options. My proposal is:
  win64:11                     ;we will force it and you will not need to declare it
  OPTION STACKBASE     ;this one will go together with x64

  for 32 bit we will leave that choice of OPTION STACKBASE
 and if not declared it will be normal 32 bit compatible with masm

If someone want to do on they own, they can still use:
OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE

I'll just see with Johnsa if he agrees about it.


 
Cod-Father

AW

  • Member
  • *****
  • Posts: 2550
  • Let's Make ASM Great Again!
Re: OPTION STACKBASE also broken in x64
« Reply #33 on: March 22, 2017, 06:49:07 PM »
Long time ago I've learned in my life that to give choice to people is a big mistake, because they will always chose the worst option,
Rush forwarding was never a solution for anything.
The truth is, your win64:11 is broken as well as I demonstrated easily. While I recognize Johnsa is trying to save the ship you are doing exactly the inverse.  :(

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6958
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: OPTION STACKBASE also broken in x64
« Reply #34 on: March 22, 2017, 07:02:19 PM »
aw27,

Just keep in mind that these guys are doing a massive amount of work getting this assembler up and going and on the way through there will be bits and pieces that need to be fixed. Bug reports are useful to the extent that it helps in the development but that does not translate into telling them what to do. Design decisions are the choice of the authors, not the testers and while its fair to make suggestions, the final decisions must be left to them.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

AW

  • Member
  • *****
  • Posts: 2550
  • Let's Make ASM Great Again!
Re: OPTION STACKBASE also broken in x64
« Reply #35 on: March 22, 2017, 07:13:52 PM »
aw27,
the final decisions must be left to them.
Always! And you know as well that products done against the market expectancies go down the toilet.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6958
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: OPTION STACKBASE also broken in x64
« Reply #36 on: March 22, 2017, 08:42:39 PM »
 :biggrin:

> Always! And you know as well that products done against the market expectancies go down the toilet.

The simple solution is to write your own.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

AW

  • Member
  • *****
  • Posts: 2550
  • Let's Make ASM Great Again!
Re: OPTION STACKBASE also broken in x64
« Reply #37 on: March 22, 2017, 10:03:52 PM »
:biggrin:

> Always! And you know as well that products done against the market expectancies go down the toilet.

The simple solution is to write your own.
Things don't work like that in real life.

johnsa

  • Member
  • ****
  • Posts: 799
    • Uasm
Re: OPTION STACKBASE also broken in x64
« Reply #38 on: March 23, 2017, 10:00:22 PM »
Hi,

After investigating this one I can confirm that Visual (C++) is NOT aligning the stack to 16.

I've setup test C++ and ASM project and I've saved a screen-shot here:

www.terraspace.co.uk/stack.png

C++ will align RSP to 16 in it's own prologue to keep locals etc. aligned, but it doesn't do this up-front accounting for the call's 8byte return, hence the wrong alignment once into the ASM proc.

coder

  • Member
  • **
  • Posts: 103
Re: OPTION STACKBASE also broken in x64
« Reply #39 on: March 23, 2017, 10:14:09 PM »
I think it's the same with GCC. It's the library functions (paticularly the WinAPI) that require stack alignment, not the main or the entire program. You should have known this long ago.


coder

  • Member
  • **
  • Posts: 103
Re: OPTION STACKBASE also broken in x64
« Reply #40 on: March 23, 2017, 10:26:18 PM »
Also you guys should take into account the linker's own requirements. Some linkers do align the stack for your code while others don't.

 

johnsa

  • Member
  • ****
  • Posts: 799
    • Uasm
Re: OPTION STACKBASE also broken in x64
« Reply #41 on: March 24, 2017, 01:54:52 AM »
I can confirm that using FRAME (as intended) does counter the mis-alignment by 8 and ensures the stack is aligned to 16 on entry.

I've linked to the C++ project with assembler module, simply decorate the PROCs with "FRAME" and everything will be good to go! :)

http://www.terraspace.co.uk/testapp.zip

Code: [Select]


option casemap : none
option frame : auto
option win64: 11
OPTION STACKBASE : RSP

.code

sub1 proc private frame dest : ptr, src : ptr, val1 : qword, val2 : qword
mov dest, rcx
mov src, rdx
mov val1, r8
mov val2, r9
mov rax, qword ptr[rdx]
add rax, val1
add rax, val2
mov qword ptr[rcx], rax

ret
sub1 endp

getSum proc public frame dest:ptr, src : ptr, val1 : qword, val2 : qword
mov dest, rcx
mov src, rdx
mov val1, r8
mov val2, r9
INVOKE sub1, dest, src, val1, val2
ret
getSum endp

end


coder

  • Member
  • **
  • Posts: 103
Re: OPTION STACKBASE also broken in x64
« Reply #42 on: March 24, 2017, 02:17:10 AM »
johnsa

It's good to know that everything is turning out just fine for you guys.

Keep up the good work and get some sleep.


johnsa

  • Member
  • ****
  • Posts: 799
    • Uasm
Re: OPTION STACKBASE also broken in x64
« Reply #43 on: March 24, 2017, 02:20:17 AM »
Thanks.. :) I think 2.22 has some great fixes and new features!

Time to take a nap/break though ;)

AW

  • Member
  • *****
  • Posts: 2550
  • Let's Make ASM Great Again!
Re: OPTION STACKBASE also broken in x64
« Reply #44 on: March 24, 2017, 03:32:03 PM »
After investigating this one I can confirm that Visual (C++) is NOT aligning the stack to 16.
Of course not and does not have to. What is required is to align the stack "before" the call is made. How is it possible to have simultaneously the stack aligned before the call and immediately after the call?
I give up. It is too much nonsense for me.