flat assembler
Message board for the users of flat assembler.

Index > Windows > Help with translating java script code into ASM code

Author
Thread Post new topic Reply to topic
ps



Joined: 13 Feb 2005
Posts: 2
ps 13 Feb 2005, 22:35
Hi,
I am a total newbie, although I have a little programming knowledge Rolling Eyes
Here is what I need to do, but I am not skilled enough so I can not manage to do this without help...
I need to write a small windows GUI generating random numbers.
To be more specific:
To the constant values, for example "999", "321" and 743, I need to add 2- digit RANDOM numbers...
My java script code looks like this:
Code:
function getRandomNumber(max)
      {
        return Math.round(Math.random() * max);
      }

      function generateKey()
      {
        prefix = ["999", "321"];
        suffix = ["1", "2", "3", "5", "6", "7", "8", "9", "0"]

        return prefix[getRandomNumber(prefix.length - 1)] + getRandomNumber(9) + suffix[getRandomNumber(suffix.length - 1)];
    

My question is how the above code can be represented in asm code ... Rolling Eyes
well I started to write the skeleton of this program, but I do not have any clu how to write it correct and complete..
Code:
format PE GUI 4.0
entry start

include '%fasminc%\win32a.inc'


ID_GENERATE     = 102
ID_PAPAR        = 103

section '.code' code readable executable

  start:

        invoke  GetModuleHandle,0
        invoke  DialogBoxParam,eax,37,HWND_DESKTOP,DialogProc,0
  exit:
        invoke  ExitProcess,0

proc DialogProc,hwnddlg,msg,wparam,lparam
        push    ebx esi edi
        cmp     [msg],WM_INITDIALOG
        je      wminitdialog
        cmp     [msg],WM_COMMAND
        je      wmcommand
        cmp     [msg],WM_CLOSE
        je      wmclose
        xor     eax,eax
        jmp     finish                           

Any help will be appreaciated and I thank you all in advance!
Post 13 Feb 2005, 22:35
View user's profile Send private message Reply with quote
ps



Joined: 13 Feb 2005
Posts: 2
ps 17 Feb 2005, 17:44
I guess it is not that easy to represent the above simple code in ASM even for advanced programmers Sad as there is no reply until now - or maybe the javascript code is the problem
Code:
return prefix[getRandomNumber(prefix.length - 1)] + getRandomNumber(9) + suffix[getRandomNumber(suffix.length - 1)];    

An explaination with few words, what the above code does do:
The function returns either the prefix '999' or '321' in random order + 1digit random number + 1 digit random number from the suffix lenght
results will look like this 99923, 32108, 99934 etc..
Anyway - I'll continue the search for more info...
Post 17 Feb 2005, 17:44
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.