Archived

This topic is now archived and is closed to further replies.

How to translate these NASM code into MASM ?

This topic is 5821 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The code to mul two fixed number below is copied from allegro. I want to move it to VC60 but I do not understand the nasm code such like %2,%0 and "=&a" who can explain them. or help me to translate it into MS format that VC can recongnize __INLINE__ fixed fmul(fixed x, fixed y) { #if defined __GNUC__ && defined __i386__ fixed edx __attribute__ ((__unused__)); fixed result; asm ( " movl %2, %0 ; " " imull %3 ; " /* do the multiply */ " shrdl $16, %%edx, %0 ; " " shrl $16, %%edx ; " /* check for overflow */ " jz 0f ; " " cmpw $0xFFFF, %%dx ; " " je 0f ; " " movl %4, %5 ; " /* on overflow, set errno */ " movl $0x7FFFFFFF, %0 ; " /* and return MAXINT */ " cmpl $0, %2 ; " " jge 1f ; " " negl %0 ; " " 1: " " cmpl $0, %3 ; " " jge 0f ; " " negl %0 ; " " 0: " /* finished */ : "=&a" (result), /* the result has to go in eax */ "=&d" (edx) /* reliably reserve edx */ : "mr" (x), /* x and y can be regs or mem */ "mr" (y), "i" (ERANGE), "m" (errno) : "%cc", "memory" /* clobbers flags and errno */ ); return result; #else return ftofix (fixtof (x) * fixtof (y)); #endif }

Share this post


Link to post
Share on other sites
Which version of the DirectX SDK do you have installed ?

it could be looking in the wrong forum... oops folder.


[Hint about the actual question even though its in the wrong place: take a look at how you pass parameters to a .BAT file - you may notice a similarity...]

--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
I mostly understand the code (and possibly can think about what it is supposed to do). Maybe if you could explain me how "Fixed" type is represented, I might help. (I don''t remember it from VC6.0 and I don''t have this compiler installed on my computer... nor I have its documentation).

If you won''t get any help from elsewhere, you can e-mail me (as a last option - I don''t guarantee anything) at lifepower@fromru.com.

Share this post


Link to post
Share on other sites