News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

GAS to MASM

Started by etairi, December 31, 2017, 09:10:56 AM

Previous topic - Next topic

etairi

I have a GAS code that I call inside Rust, and it seems to work fine and give correct results. I tried to rewrite it in MASM, but when I run the MASM version inside Rust I get exception thrown, due to some kiond of access violation while reading a location. My MASM version can be found here. Whereas my original GAS version can be found here. If someone can point me out what is wrong in my MASM code, I would really appreciate it.

jj2007

Staring at uncommented code won't help much. What you can do is to insert an int 3 shortly before calling the original, correctly working GAS code. Then run the exe with X64Dbg und compare the disassembly with your Masm code.

Or, even easier, zip up the two DLLs and attach it here. Maybe we can spot the little difference directly.

Gunther

Hi etairi,

are you sure that it is GAS code? That should look similar to this:

movl %eax, %eax
movq %rax, %rdx
movl $0, %ecx
movl $4096, %eax
movl %eax, %eax
salq $2, %rax
leaq 31(%rax), %rdx
movl $16, %eax
subq $1, %rax
addq %rdx, %rax
movl $16, %ecx
movl $0, %edx
divq %rcx
imulq $16, %rax, %rax

Your code looks like NASM code. Moreover, I can only emphasize what Jochen has already said. Good luck for you.

Gunther
You have to know the facts before you can distort them.

etairi

Quote from: Gunther on December 31, 2017, 10:44:31 AM
Hi etairi,

are you sure that it is GAS code?
Your code looks like NASM code. Moreover, I can only emphasize what Jochen has already said. Good luck for you.

Gunther

Hi Gunther,

I'm using `.intel_syntax noprefix `. The code segment that I have posted is only one function. My assembly file is around 2000 lines, and contains multiple functions, but that particular function that I have posted is causing the problem. I will try to debug as Jochen suggested, if not I will try to post DLL here.

jj2007

Quote from: etairi on December 31, 2017, 08:59:08 PMI will try to post DLL here.

Both DLLs, please. If you are worried about privacy, either try to isolate the function, or post the DLLs, wait for confirmation that I got it, and remove the attachment immediately after.