Author Topic: A trick for "m2m" macro  (Read 439 times)

HSE

  • Member
  • *****
  • Posts: 2005
  • AMD 7-32 / i3 10-64
A trick for "m2m" macro
« on: January 01, 2022, 06:43:31 AM »
Hi all!

 ObjAsm m2m macro is a little problematic for dual bitness because in 32 bit can trash one register (and in 32 bits registers are few). But a little trick can prevent that:
Code: [Select]
m2m [xsi].orden, xordenmodelo, @if64bits(r13)
Code: [Select]
@if64bits macro RegAux
    if @WordSize eq 4
        exitm <>
    else
        exitm <&RegAux>
    endif   
endm

Then:
Code: [Select]
32bits:
00407ADC | FF 75 0C                 | push dword ptr ss:[ebp + C]             |
00407ADF | 8F 46 10                 | pop dword ptr ds:[esi + 10]             |

64bits:
00007FF781378601 | 4C 8B 6D 28              | mov r13,qword ptr ss:[rbp+28]           |
00007FF781378605 | 4C 89 6E 1C              | mov qword ptr ds:[rsi+1C],r13           |

Regards, HSE.
Equations in Assembly: SmplMath

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 868
  • ObjAsm Developer
    • ObjAsm
Re: A trick for "m2m" macro
« Reply #1 on: January 02, 2022, 04:19:19 AM »
Hi HSE
Nice trick. Thanks for sharing it  :thumbsup:

Biterider