Author Topic: GAS to MASM  (Read 689 times)

etairi

  • Regular Member
  • *
  • Posts: 10
GAS to MASM
« on: December 31, 2017, 09:10:56 AM »
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

  • Member
  • *****
  • Posts: 8519
  • Assembler is fun ;-)
    • MasmBasic
Re: GAS to MASM
« Reply #1 on: December 31, 2017, 09:57:58 AM »
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

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Re: GAS to MASM
« Reply #2 on: December 31, 2017, 10:44:31 AM »
Hi etairi,

are you sure that it is GAS code? That should look similar to this:
Code: [Select]
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
Get your facts first, and then you can distort them.

etairi

  • Regular Member
  • *
  • Posts: 10
Re: GAS to MASM
« Reply #3 on: December 31, 2017, 08:59:08 PM »
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

  • Member
  • *****
  • Posts: 8519
  • Assembler is fun ;-)
    • MasmBasic
Re: GAS to MASM
« Reply #4 on: December 31, 2017, 09:31:59 PM »
I 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.