The MASM Forum

General => The Laboratory => Topic started by: guga on July 17, 2012, 12:04:50 PM

Title: MAKELANGID macro error ?
Post by: guga on July 17, 2012, 12:04:50 PM
I´m mine version of VS2010, i have the following macros:

#define MAKELANGID(p, s)       ((((WORD  )(s)) << 10) | (WORD  )(p))
#define PRIMARYLANGID(lgid)    ((WORD  )(lgid) & 0x3ff)
#define SUBLANGID(lgid)        ((WORD  )(lgid) >> 10)


But, in fact. It seems to me wrong....shouldn´t they be this ?

#define MAKELANGID(p, s)       ((((WORD  )(s)) << 0x10) | (WORD  )(p))
#define PRIMARYLANGID(lgid)    ((WORD  )(lgid) & 0x3ff)
#define SUBLANGID(lgid)        ((WORD  )(lgid) >> 0x10)


Or am i missing something i the C Syntax ?

Btw: How is the syntax for such macro for masm ?

Best Regards,

guga
Title: Re: MAKELANGID macro error ?
Post by: hutch-- on July 17, 2012, 12:19:47 PM
guga,

You usually just plonk the right number in its place. The C macro is to get around the type checking in C.
Title: Re: MAKELANGID macro error ?
Post by: guga on July 17, 2012, 12:34:14 PM
Hi steve....

Didn´t followed it...What "plonk" means ?

"The C macro is to get around the type checking in C."
Ok....but in C, the value 10 is in hexadecimal notation ? I thought in C what was in hex was followed by "0x" only

Not sure if i understood, because if 10 is really (ten), then the macro seems to produce a wrong result. But if "10" means "sixteen" (hex converted from 0x10) then it works ok, right ? Or i´m still missing something on the syntax ?
Title: Re: MAKELANGID macro error ?
Post by: hutch-- on July 17, 2012, 12:41:54 PM
guga,

Depends what you are doing with it, I answered the question for using an assembler where you simply place (PLONK) the number where you need it. You know how to use either HEX or DECIMAL notation, just place the value you need in the right place when using an assembler. If you are writing this code in C, use the C macro format as it gets around the C type checking.
Title: Re: MAKELANGID macro error ?
Post by: guga on July 17, 2012, 12:51:18 PM
Hmm...many tks...I think i got it now.

This was somewhat strange for me, since it was producing wrong results (The C macro, i mean). For example, if i wanted to use such a macro in InitMUILanguage function. (or others that uses LANGID data type)

I found this macro because i´m trying to build a h2inc for RosAsm (and probably will be able to export masm syntax too) to make easier build newer equates/structures/guid/functions sets. I know we have at least 2 great tools for such thing in masm, but for rosasm it is lacking such tool. So, if i succeed to make it works correctly, it will build a sort of database that can be used to port either to rosasm or masm or others assemblers as well.
Title: Re: MAKELANGID macro error ?
Post by: dedndave on July 17, 2012, 08:51:27 PM
the primary language ID is 10 bits wide - the sublanguage ID is 6 bits wide   :P
i think what Hutch means by "plonk" is - we generally use word values that are already put together
  BLOCK "VarFileInfo"
  BEGIN
    VALUE "Translation", 0x409, 0x4E4
  END

http://msdn.microsoft.com/en-us/library/windows/desktop/dd318691%28v=vs.85%29.aspx (http://msdn.microsoft.com/en-us/library/windows/desktop/dd318691%28v=vs.85%29.aspx)
http://msdn.microsoft.com/en-us/library/windows/desktop/dd318693%28v=vs.85%29.aspx (http://msdn.microsoft.com/en-us/library/windows/desktop/dd318693%28v=vs.85%29.aspx)

over here, "plonk" is the sound my fishing tackle makes when it hits the water
you know how those Aussie guys are a little different
it comes from being upside down all day     :biggrin:
Title: Re: MAKELANGID macro error ?
Post by: hutch-- on July 18, 2012, 08:32:36 AM
 :biggrin:

Now I know you don't speak English, "plonk" is a sound when you place something in a carefree manner at a location. You fishing tackle hitting the water probably qualifies.  :P
Title: Re: MAKELANGID macro error ?
Post by: dedndave on July 18, 2012, 11:08:09 PM
 :lol:

i must be thinking of "plunk"   :biggrin:
Title: Re: MAKELANGID macro error ?
Post by: brethren on July 20, 2012, 07:59:49 AM
Quote from: hutch-- on July 18, 2012, 08:32:36 AM
:biggrin:

Now I know you don't speak English, "plonk" is a sound when you place something in a carefree manner at a location. You fishing tackle hitting the water probably qualifies.  :P

talking about the english language heres a derived term
plonker :badgrin:
1.(UK, slang, mildly pejorative) A fool
2.(UK, slang, dated) A man who sanctions sexual relationships between his girlfriend and his male friends.

btw ignore me, i'm drunk on cheap plonk :biggrin:
Title: Re: MAKELANGID macro error ?
Post by: hutch-- on July 20, 2012, 08:53:52 AM
Ah, the quality of your code drops with cheap plonk. I have just added another bottle of an old favourite, a beautifully dry Speyside pure malt distilled by Rothes distillery called Glen Grant. Not the most expensive but the hallmark of a very good pure malt, ugly bottle, stick on labels, very light colour and dryer than vinegar. I would rather pay for the booze than the bottle.  :P
Title: Re: MAKELANGID macro error ?
Post by: dedndave on July 20, 2012, 12:16:24 PM
the word Z uses from time to time is "wanker" - lol
similar slang terms are "Happy Larry" or "Happy Wally"
depending on what part of England you are from
those 2 crack me up  (http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/24.gif)
Title: Re: MAKELANGID macro error ?
Post by: hutch-- on July 20, 2012, 03:38:02 PM
Usually "wanker" refers to a person who gives the appearance of suffering from manual self delusion, a "Wally" is basically UK slang that has a similar usage to the term "Yobbo" here in OZ, someone who is dumb, clumsy or acts in bad taste among many other maladies. Then there is the "jerk", occasional loan words like "malaka" (a reference to a lack of masculinity) and a whole host of OZ idiom that is too robust for international consumption.
Title: Re: MAKELANGID macro error ?
Post by: dedndave on July 20, 2012, 10:37:44 PM
wanker, happy larry, happy wally
my interpretation is they all mean about the same thing - lol
a guy with onanistic habits   :P
Title: Re: MAKELANGID macro error ?
Post by: npnw on July 31, 2012, 01:24:51 PM
BS What flows in this forum !  :biggrin: