Terraspace / UASM

UASM - Macro Assembler
http://www.terraspace.co.uk/uasm.html
Other
220 stars 49 forks source link

Don't generate PROC prologue/epilogue when not necessary #119

Closed db4 closed 4 years ago

db4 commented 4 years ago

This code

.CODE

option WIN64: 1

func PROC uses rbx
     ret
func ENDP

END

is compiled as

func:
  0000000000000000: 48 55              push        rbp
  0000000000000002: 53                 push        rbx
  0000000000000003: 48 83 EC 08        sub         rsp,8
  0000000000000007: 48 8B EC           mov         rbp,rsp
  000000000000000A: 48 8D 65 08        lea         rsp,[rbp+8]
  000000000000000E: 5B                 pop         rbx
  000000000000000F: 5D                 pop         rbp
  0000000000000010: C3                 ret

why prologue/epilogue is generated? jwasm 2.12 used to compile it correctly:

func:
  0000000000000000: 53                 push        rbx
  0000000000000001: 5B                 pop         rbx
  0000000000000002: C3                 ret
john-terraspace commented 4 years ago

I’ll have a look at this one, this is probably due to the fact that win64:1 makes no attempt to optimise the prologue so doesn’t take into consideration that the single uses aligns the stack already.

From: Dmitry Bely notifications@github.com Sent: 06 November 2019 07:19 To: Terraspace/UASM UASM@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [Terraspace/UASM] Don't generate PROC prologue/epilogue when not necessary (#119)

This code

.CODE

option WIN64: 1

func PROC uses rbx ret func ENDP

END

is compiled as

func: 0000000000000000: 48 55 push rbp 0000000000000002: 53 push rbx 0000000000000003: 48 83 EC 08 sub rsp,8 0000000000000007: 48 8B EC mov rbp,rsp 000000000000000A: 48 8D 65 08 lea rsp,[rbp+8] 000000000000000E: 5B pop rbx 000000000000000F: 5D pop rbp 0000000000000010: C3 ret

why prologue/epilogue is generated? jwasm 2.12 used to compile it correctly:

func: 0000000000000000: 53 push rbx 0000000000000001: 5B pop rbx 0000000000000002: C3 ret

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Terraspace/UASM/issues/119?email_source=notifications&email_token=AEAZAVCFIXC3CPJOIGLBPV3QSJVWBA5CNFSM4JJQXQH2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HXEN6AA , or unsubscribe https://github.com/notifications/unsubscribe-auth/AEAZAVBYFT7GDN4LL4O5QH3QSJVWBANCNFSM4JJQXQHQ .

john-terraspace commented 4 years ago

Fixed in 2.50