News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

v2.56 vs v2.55

Started by mabdelouahab, March 03, 2023, 05:22:46 AM

Previous topic - Next topic

mabdelouahab

printf PROTO pString:PTR, args:VARARG
.data
@String DB "String1\n" ,0
.code
g1 proc
invoke printf ,addr @String
ret
g1 endp
main  PROC  argc:QWORD, argv:QWORD
g1()
printf(addr @String)
xor rax,rax
ret
main  ENDP
end 


uasm -elf64   main.asm




v2.56   (crash)
==========================================================
  ;-- frame_dummy:
entry.init0 ();
0x00401120      endbr64
0x00401124      jmp     register_tm_clones ; sym.register_tm_clones
0x00401126      nop     word cs:[rax + rax]
g1 ();
0x00401130      sub     rsp, 8
0x00401134      lea     rdi, @String ; 0x404030 ; const char *format
0x0040113b      xor     eax, eax
0x0040113d      call    printf     ; sym.imp.printf ; int printf(const char *format)
0x00401142      ret
int main (int argc, char **argv, char **envp);
0x00401143      push    rbp
0x00401144      mov     rbp, rsp
0x00401147      call    g1         ; sym.g1
0x0040114c      lea     rdi, @String ; 0x404030 ; const char *format
0x00401153      xor     eax, eax
0x00401155      call    printf     ; sym.imp.printf ; int printf(const char *format)
0x0040115a      xor     rax, rax
0x0040115d      pop     rbp
0x0040115e      ret
0x0040115f      add     bl, dh
  ;-- section..fini:
_fini ();


v2.55
==========================================================
  ;-- frame_dummy:
entry.init0 ();
0x00401120      endbr64
0x00401124      jmp     register_tm_clones ; sym.register_tm_clones
0x00401126      nop     word cs:[rax + rax]
g1 ();
0x00401130      sub     rsp, 8
0x00401134      lea     rdi, @String ; 0x404030 ; const char *format
0x0040113b      xor     eax, eax
0x0040113d      call    printf     ; sym.imp.printf ; int printf(const char *format)
0x00401142      add     rsp, 8
0x00401146      ret
int main (int argc, char **argv, char **envp);
0x00401147      push    rbp
0x00401148      mov     rbp, rsp
0x0040114b      call    g1         ; sym.g1
0x00401150      lea     rdi, @String ; 0x404030 ; const char *format
0x00401157      xor     eax, eax
0x00401159      call    printf     ; sym.imp.printf ; int printf(const char *format)
0x0040115e      xor     rax, rax
0x00401161      pop     rbp
0x00401162      ret
0x00401163      add     bl, dh
  ;-- section..fini:
_fini ();
[/b]

mabdelouahab

I couldn't compile my big projects with this version
Here's another example:

invoke printf,"string\n", 0,1,2,3,4,5,6,7

v2.56 (also crashed) ---------------------------------------------------------------------------------
0x00402588      lea     rdi, __ls36143 ; 0x40ab3f ; const char *format
0x0040258f      xor     rsi, rsi
0x00402592      mov     rdx, 1
0x00402599      mov     rcx, 2
0x004025a0      mov     r8, 3
0x004025a7      mov     r9, 4
0x004025ae      sub     rsp, 8
0x004025b2      push    7          ; 7
0x004025b4      push    6          ; 6
0x004025b6      push    5          ; 5
0x004025b8      xor     eax, eax
0x004025ba      call    printf     ; sym.imp.printf ; int printf(const char *format)
0x004025bf      add     rsp, 8

v2.55-------------------------------------------------------------
0x004025b0      sub     rsp, 8
0x004025b4      lea     rdi, __ls36143 ; 0x40ab3f ; const char *format
0x004025bb      xor     rsi, rsi
0x004025be      mov     rdx, 1
0x004025c5      mov     rcx, 2
0x004025cc      mov     r8, 3
0x004025d3      mov     r9, 4
0x004025da      push    7          ; 7
0x004025dc      push    6          ; 6
0x004025de      push    5          ; 5
0x004025e0      xor     eax, eax
0x004025e2      call    printf     ; sym.imp.printf ; int printf(const char *format)
0x004025e7      add     rsp, 0x20

mineiro

These errors happens because your procedure don't have a local variable and stack get unbalanced.
I reported this to sir johnsa in post below:
https://masm32.com/board/index.php?topic=10449.msg115637#msg115637

In your other post, an way to work with both versions until is solved is to load a variable to a register and use by reference. I spend all this day just checking that.
lea r12,W
mov [r12].struct1.s1,1
...
I'd rather be this ambulant metamorphosis than to have that old opinion about everything

mineiro

Oh, I forgot to say, when assembling to windows using printf you should disable internal macro library, the calling convention used start with systemV.
-nomlib
I faced this problem too.
I'd rather be this ambulant metamorphosis than to have that old opinion about everything

mabdelouahab


johnsa

Please try again in UASM 2.57. I've fixed the unbalanced stack and the release will be available shortly.

mabdelouahab