Author Topic: Converting YASM to NASM  (Read 4279 times)

Barry

  • Guest
Converting YASM to NASM
« on: October 01, 2009, 02:33:17 PM »
Hi,

I'm currently working on a project that makes use of TrueCrypt. To build TrueCrypt, both NASM and YASM assemblers are required (presumably because YASM supported 64bit before NASM).

I'm attempting to lose the dependency on YASM and have the project use NASM exclusively. However, I don't have a lot of assembly language experience and have come across a problem: I've changed all the YASM reference to use NASM, but visual studio complains about the undefined symbol 'rip'.

Is there a NASM equivalent to rip? The lines in question are:
lea     tptr,[enc_tab wrt rip]
and
lea     tptr,[dec_tab wrt rip]

Would it be as straight-forward as swapping the NASM equivalent in?

Many thanks,
Barry

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2387
  • Country: us
Re: Converting YASM to NASM
« Reply #1 on: October 01, 2009, 03:45:58 PM »
From the very little I know about 64-bit code, I think "lea ???, [rel enc_tab]" should do what you want, but "lea" requires a register for destination AFAIK, so I don't know what you're going to do about "tptr"! In other words, I don't know! :)

Best,
Frank

Barry

  • Guest
Re: Converting YASM to NASM
« Reply #2 on: October 02, 2009, 09:01:01 AM »
Thanks for your reply.

I managed to adjust the x86.asm file by just adding 'NEAR' to 4 je instructions.

The problem sections of code in the x64.asm files are:

movzx   esi, byte [kptr+4*KS_LENGTH]
lea     tptr,[enc_tab wrt rip]
sub     kptr, fofs
and:

movzx   esi,byte[kptr+4*KS_LENGTH]
lea     tptr,[dec_tab wrt rip]
sub     kptr, rofs

with Visual Studio complaining about the rip in the lea instructions.

I can post the whole x64.asm code if it will help diagnose the problem.

Cheers,
Barry

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2387
  • Country: us
Re: Converting YASM to NASM
« Reply #3 on: October 02, 2009, 10:16:57 AM »
Maybe you'd better... I downloaded "TrueCrypt" and can't find any such files...

At least, what are "kptr" and "tptr"? Defined as registers? If so, "rel" should solve the problem ("rel rip" is implied). Adding "-Ox" to Nasm's command line would probably have taken care of "jcc near" (Nasm defaults to "short" jccs).

I'm confused... does Nasm complain about "rip", or VS?

This forum software is going to mutilate the code, but post it if all else fails...

Best,
Frank