flat assembler
Message board for the users of flat assembler.

Index > Windows > command line arguments

Author
Thread Post new topic Reply to topic
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
how do I get command line arguments in console app?
Post 29 May 2004, 10:09
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7797
Location: Kraków, Poland
Tomasz Grysztar
Console fasm uses GetCommandLineA function of KERNEL32 for this.
Post 29 May 2004, 10:12
View user's profile Send private message Visit poster's website Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
to split the command line into separate parameters, you can use my parse_command_line function.
Post 29 May 2004, 11:10
View user's profile Send private message Visit poster's website Reply with quote
Vortex



Joined: 17 Jun 2003
Posts: 318
Vortex
To get the command line parameters,
you can use __GetMainArgs exported by C run-time DLLs.

Another example, my tool dlltoinc uses this function.

_________________
Code it... That's all...
Post 29 May 2004, 13:32
View user's profile Send private message Visit poster's website Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo
This snippet gets following parameters: one filename, one optional filename and some optional switches

Code:
      api   GetCommandLine
        mov   esi,eax
       mov   ah,'"'
 lodsb
       cmp   al,ah
 je    .pass_ini_path
        mov   ah,' '
  .pass_ini_path:
     lodsb
       cmp   al,ah
 je    .find_arguments
       cmp   al,0Dh
        je    .no_arguments
 or    al,al
 je    .no_arguments
 jmp   .pass_ini_path

  .find_arguments:
  lodsb
       or    al,al
 je    .no_arguments
 cmp   al,' '
      je    .find_arguments
       mov   ah,'"'
 cmp   al,ah
 je    .start_argument
       mov   ah,' '
      dec   esi
  .start_argument:
 mov   [filename],esi
  .get_argument:
        lodsb
       cmp   al,ah
 je    .put_end_terminator
   or    al,al
 je    .load_source
  cmp   al,0Dh
        je    .load_source
  cmp   al,0Ah
        je    .load_source
  jmp   .get_argument

  .put_end_terminator:
       mov   byte [esi-1],0
  .next_args:
   lodsb
       cmp   al,0
  je    .load_source
  cmp   al,0Dh
        je    .load_source
  cmp   al,0Ah
        je    .load_source
  cmp   al,'-'
      jne   .next_args
    lodsb
       cmp   al,'w'
      je    .wide_char
    cmp   al,'g'
      je    .golink_output
        cmp   al,'a'
      jne   .next_args
  .alink_output:
    or    [out_flag],OUT_FLAG_ALINK
     jmp   .next_args
  .golink_output:
   mov   [out_flag],OUT_FLAG_GOLINK
    jmp   .next_args
  .wide_char:
       or    [out_flag],OUT_FLAG_WIDE
      jmp   .next_args
    
  .no_functions:
    sc    WriteOut,license,sizeof.license
       sc    WriteOut,no_funct,sizeof.no_funct
     call  .clean_up
     jmp   .terminate
  .error_read:
      sc    WriteOut,license,sizeof.license
       sc    WriteOut,err_read,sizeof.err_read
     mov   eax,SCRIPT_ERROR_READ
 call  .clean_up
     jmp   .terminate
  .no_arguments:
    sc    WriteOut,license,sizeof.license+sizeof.use_instr
      jmp   .terminate    
Post 29 May 2004, 14:13
View user's profile Send private message Yahoo Messenger Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
hmm... "GetCommandLine"... Who could have quessed it?

thanks.
Post 29 May 2004, 19:11
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number 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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.