News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

@RND

Started by mabdelouahab, December 23, 2016, 02:36:53 AM

Previous topic - Next topic

mabdelouahab


@RND Macro __mask
LOCAL m
m=(@SubStr(%@Time,7,2)+@Line)*(@SubStr(%@Date,1,2)+@SubStr(%@Date,4,2)*100+@SubStr(%@Date,7,2))* (-1001)
m=(m+@SubStr(%@Time,1,2)+@SubStr(%@Time,4,2))*(@SubStr(%@Time,7,2)+1)
IFNB <__mask>
m = m AND __mask
ENDIF
EXITM % m
endm
% echo [@RND(0FFh)]
% echo [@RND(0FFFFh)]
% echo [@RND(0FFFFFFFFh)]


Output:
  [180]
  [32700]
  [3880145092]

Problem: In 64bit, He gives me max:4294967295 (0FFFFFFFFh), is only 32 bit


% echo [@RND(0FFh)]
% echo [@RND(0FFFFh)]
% echo [@RND(0FFFFFFFh)]
% echo [@RND(0FFFFFFFFFFFFFFFFh)]


Output:
  [49]
  [61489]
  [256457777]
  [4282419249]




GoneFishing

Hi  mabdelouahab,

Thank you for an interesting question. I had a pleasure searching for an answer . So ... I  use  JWASM as assembler because it's open source .
First of all let's specify -dt command line option ( you need DEBUG enabled build of JWASM ) to get verbose output from assembler
Now we see this:
Quote
...
28[@RND.6]. get_operand(??0001): sym->state=1 type=>NULL< ofs=F8CB7705 memtype=C0h total_size=4294967294 defined=1
28[@RND.6]. get_operand(??0001): equate hval=FFFFFFFEh, lval=F8CB7705h
28[@RND.6]. 1 get_operand exit, ok, kind=0 value=FFFFFFFEF8CB7705 hvalue=0 mem_type=C0h abs=0 string=NULL is_type=0 type=>NULL< sym=NULL mbr=NULL
28[@RND.6]. 1 evaluate exit, rc=0, kind=0 value=-4415850747(0xFFFFFFFEF8CB7705) memtype=C0h string=NULL indirect=0 type=>NULL<
28[@RND.6]. myltoa( value=F8CB7705h, out=4174083845, radix=10, sign=0, 0)
28[@RND.6]. ExpandToken: curr pos=3, start expr=1, expr size=8
28[@RND.6]. ExpandLine(   EXITM <4174083845>): expansion occured, retokenize
28[@RND.6]. ExpandLine(>   EXITM <4174083845><) exit, rc=0, token_count=2
28[@RND.6]. RunMacro(@RND): EXITM, result=>4174083845<
...
Here we see  all the magic transformations happening under the hood .

Notice that function myltoa takes only low 32 bits of value variable :
expans.c

/* C ltoa() isn't fully compatible since hex digits are lower case.
* for JWasm, it's ensured that 2 <= radix <= 16.
*/
char *myltoa( uint_32 value, char *buffer, unsigned radix, bool sign, bool addzero )
/**********************************************************************************/


HTH