"Fossies" - the Fresh Open Source Software Archive

Member "fasm/tools/win32/prepsrc.asm" (21 Feb 2022, 2118 Bytes) of package /linux/misc/fasm-1.73.30.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Generic Assembler source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 
    2 format PE console 4.0
    3 entry start
    4 
    5 include 'win32a.inc'
    6 
    7 section '.data' data readable writeable
    8 
    9   _usage db 'preprocessed source dumper for flat assembler',0Dh,0Ah
   10      db 'usage: prepsrc <input> <output>',0Dh,0Ah
   11      db 0
   12   _error_prefix db 'error: ',0
   13   _error_suffix db '.',0Dh,0Ah,0
   14 
   15   input_file dd 0
   16   output_file dd 0
   17 
   18   display_handle dd ?
   19   bytes_count dd ?
   20 
   21   params rb 1000h
   22 
   23 section '.text' code readable executable
   24 
   25   start:
   26 
   27     mov [display_handle],STD_OUTPUT_HANDLE
   28 
   29     call    get_params
   30     jnc make_dump
   31 
   32     mov esi,_usage
   33     call    display_string
   34     invoke  ExitProcess,2
   35 
   36   make_dump:
   37     call    preprocessed_source
   38     invoke  ExitProcess,0
   39 
   40   error:
   41     mov [display_handle],STD_ERROR_HANDLE
   42     mov esi,_error_prefix
   43     call    display_string
   44     pop esi
   45     call    display_string
   46     mov esi,_error_suffix
   47     call    display_string
   48     invoke  ExitProcess,1
   49 
   50   get_params:
   51     invoke  GetCommandLine
   52     mov esi,eax
   53     mov edi,params
   54     find_command_start:
   55     lodsb
   56     cmp al,20h
   57     je  find_command_start
   58     cmp al,22h
   59     je  skip_quoted_name
   60     skip_name:
   61     lodsb
   62     cmp al,20h
   63     je  find_param
   64     or  al,al
   65     jz  all_params
   66     jmp skip_name
   67     skip_quoted_name:
   68     lodsb
   69     cmp al,22h
   70     je  find_param
   71     or  al,al
   72     jz  all_params
   73     jmp skip_quoted_name
   74     find_param:
   75     lodsb
   76     cmp al,20h
   77     je  find_param
   78     cmp al,0Dh
   79     je  all_params
   80     or  al,al
   81     jz  all_params
   82     cmp [input_file],0
   83     jne get_output_file
   84     mov [input_file],edi
   85     jmp process_param
   86       get_output_file:
   87     cmp [output_file],0
   88     jne bad_params
   89     mov [output_file],edi
   90     process_param:
   91     cmp al,22h
   92     je  string_param
   93     copy_param:
   94     stosb
   95     lodsb
   96     cmp al,20h
   97     je  param_end
   98     cmp al,0Dh
   99     je  param_end
  100     or  al,al
  101     jz  param_end
  102     jmp copy_param
  103     string_param:
  104     lodsb
  105     cmp al,22h
  106     je  string_param_end
  107     cmp al,0Dh
  108     je  param_end
  109     or  al,al
  110     jz  param_end
  111     stosb
  112     jmp string_param
  113     bad_params:
  114     stc
  115     ret
  116     param_end:
  117     dec esi
  118     string_param_end:
  119     xor al,al
  120     stosb
  121     jmp find_param
  122     all_params:
  123     cmp [input_file],0
  124     je  bad_params
  125     cmp [output_file],0
  126     je  bad_params
  127     clc
  128     ret
  129 
  130   include 'system.inc'
  131 
  132   include '..\prepsrc.inc'
  133 
  134 section '.idata' import data readable writeable
  135 
  136   library kernel32,'KERNEL32.DLL'
  137 
  138   include 'api\kernel32.inc'