Translate nasm code to Tasm

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
os_ambition

Translate nasm code to Tasm

Post by os_ambition »

Hi,
Please help me to translate this to TASM code

and   di, byte -0x20


thank u very much in advance.

os_ambition
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Translate nasm code to Tasm

Post by Pype.Clicker »

why in the world do you need to use TASM ?? :o
I thought that assembler was obsolete for years ...

btw, if you *really* need it that hard, simply remove the "byte" information (TASM should be able to guess that you'll be happy with a one-byte constant automatically) ...
os_ambition

Re:Translate nasm code to Tasm

Post by os_ambition »

what do you mean by -0x20, is this negative 20 hex? I need this value in tasm.


thank u again
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Translate nasm code to Tasm

Post by Candy »

os_ambition wrote: what do you mean by -0x20, is this negative 20 hex? I need this value in tasm.


thank u again
that should be the 2-s complement of 0x20, or (as a byte) 0xE0.
astrocrep

Re:Translate nasm code to Tasm

Post by astrocrep »

just try

Code: Select all

and   di, -20h  
if that doesn't work then try:

Code: Select all

mov   ax, -20h
and   di, ax  
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Translate nasm code to Tasm

Post by Pype.Clicker »

Candy wrote: that should be the 2-s complement of 0x20, or (as a byte) 0xE0.
Hey, beware...
the byte thing means the argument should be encoded as a byte, but it will be expanded to a word ... now, iirc that expansion is signed.

In other word, we're using (cf p 3-31 of instruction set reference -- 24547107.pdf)
opcode:"83 /4 ib" instruction:"AND r/m16, imm8" description:"r/m16 AND imm8 (sign-extended)"
That means that the equivalent in TASM is

Code: Select all

AND di, FFE0h
and not

Code: Select all

AND di, E0h
No need to say that the author of the NASM code was an obfuscating person (using 2's complement with bit-by-bit logical instructions makes no sense *at all*)
os_ambition

Re:Translate nasm code to Tasm

Post by os_ambition »

thank u very very much Pype.clicker,

that's why I like TASM, it's simple and straight
Post Reply