"Fossies" - the Fresh Open Source Software Archive

Member "fasm/tools/symbols.inc" (9 Feb 2020, 7700 Bytes) of package /linux/misc/fasm-1.73.22.tgz:


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

    1 
    2 symbols:
    3     mov edx,[input_file]
    4     call    open
    5     jc  input_not_found
    6     mov al,2
    7     xor edx,edx
    8     call    lseek
    9     cmp eax,30h
   10     jb  invalid_input
   11     push    eax
   12     call    alloc
   13     jc  not_enough_memory
   14     push    eax
   15     xor al,al
   16     xor edx,edx
   17     call    lseek
   18     mov ecx,[esp+4]
   19     mov edx,[esp]
   20     call    read
   21     jc  reading_error
   22     pop eax ecx
   23     cmp dword [eax],1A736166h
   24     jne invalid_input
   25     mov [input],eax
   26     add [eax+16],eax
   27     add [eax+24],eax
   28     add [eax+32],eax
   29     add [eax+48],eax
   30     mov edx,[eax+16]
   31     add [eax+8],edx
   32 
   33     mov ebx,eax
   34     mov eax,[ebx+20]
   35     add eax,[ebx+36]
   36     cmp eax,1000h
   37     ja  allocate_output_buffer
   38     mov eax,1000h
   39     allocate_output_buffer:
   40     call    alloc
   41     jc  not_enough_memory
   42     mov [output_buffer],eax
   43 
   44     mov edx,[output_file]
   45     call    create
   46     jc  writing_error
   47     mov [output_handle],ebx
   48 
   49     mov ebx,[input]
   50     mov edx,[ebx+24]
   51     mov ebp,[ebx+28]
   52     add ebp,edx
   53     dump_symbols:
   54     cmp edx,ebp
   55     je  dump_done
   56     test    byte [edx+8],1
   57     jz  next_symbol
   58     test    byte [edx+9],4
   59     jnz next_symbol
   60     mov edi,[output_buffer]
   61     mov esi,[edx+24]
   62     test    esi,esi
   63     jz  anonymous_symbol
   64     mov ebx,[input]
   65     btr esi,31
   66     jc  symbol_name_in_strings_table
   67     add esi,[ebx+32]
   68     lodsb
   69     movzx   ecx,al
   70     rep movsb
   71     jmp symbol_name_ok
   72      symbol_name_in_strings_table:
   73     add esi,[ebx+16]
   74     call    write_string
   75     jmp symbol_name_ok
   76      anonymous_symbol:
   77     mov al,'@'
   78     stosb
   79     stosb
   80      symbol_name_ok:
   81     test    byte [edx+9],2
   82     jnz negative_value
   83     mov eax,': 0x'
   84     stosd
   85     mov eax,[edx+4]
   86     call    write_hex_dword
   87     mov eax,[edx]
   88     call    write_hex_dword
   89     jmp write_address_registers
   90      negative_value:
   91     mov eax,': -0'
   92     stosd
   93     mov al,'x'
   94     stosb
   95     mov ecx,[edx]
   96     mov eax,[edx+4]
   97     not ecx
   98     not eax
   99     add ecx,1
  100     adc eax,0
  101     push    ecx
  102     or  ecx,eax
  103     jnz negative_value_ok
  104     mov byte [edi],'1'
  105     inc edi
  106       negative_value_ok:
  107     call    write_hex_dword
  108     pop eax
  109     call    write_hex_dword
  110      write_address_registers:
  111     mov bl,[edx+12]
  112     mov bh,[edx+14]
  113     call    write_address_register
  114     mov bl,[edx+13]
  115     mov bh,[edx+15]
  116     call    write_address_register
  117     mov bl,[edx+11]
  118     cmp bl,0
  119     je  symbol_type_ok
  120     jl  negated_symbol
  121     mov ax,', '
  122     stosw
  123     jmp write_symbol_type
  124      negated_symbol:
  125     mov ax,', '
  126     stosw
  127     mov esi,_negated
  128     call    write_string
  129     neg bl
  130      write_symbol_type:
  131     cmp bl,1
  132     je  segment_type
  133     cmp bl,5
  134     je  rva_type
  135     cmp bl,6
  136     je  plt_type
  137     test    byte [edx+20+3],80h
  138     jnz external
  139     mov esi,_relocatable
  140     call    write_string
  141     cmp dword [edx+20],0
  142     je  symbol_type_ok
  143     mov esi,_in_section
  144     call    write_string
  145     jmp write_symbol_base
  146      simple_relocatable:
  147     mov esi,_relocatable
  148     call    write_string
  149     jmp symbol_type_ok
  150      external:
  151     mov esi,_relative_to_external
  152     call    write_string
  153     jmp write_symbol_base
  154      segment_type:
  155     mov esi,_relocatable_segment
  156     call    write_string
  157     jmp symbol_type_ok
  158      rva_type:
  159     mov esi,_rva
  160     call    write_string
  161     jmp write_symbol_base
  162      plt_type:
  163     mov esi,_plt
  164     call    write_string
  165      write_symbol_base:
  166     mov esi,[edx+20]
  167     btr esi,31
  168     jc  write_external_name
  169     dec esi
  170     shl esi,2
  171     mov ebx,[input]
  172     add esi,[ebx+48]
  173     mov esi,[esi]
  174     add esi,[ebx+16]
  175     call    write_string
  176     mov al,'('
  177     stosb
  178     mov eax,[edx+20]
  179     call    write_dec_number
  180     mov al,')'
  181     stosb
  182     jmp symbol_type_ok
  183      write_external_name:
  184     mov ebx,[input]
  185     add esi,[ebx+16]
  186     call    write_string
  187     jmp symbol_type_ok
  188      symbol_type_ok:
  189     mov esi,_defined
  190     call    write_string
  191     mov ebx,[edx+28]
  192     mov eax,[input]
  193     add ebx,[eax+32]
  194     call    write_line_identifier
  195     mov ax,0A0Dh
  196     stosw
  197     push    edx
  198     mov ebx,[output_handle]
  199     mov ecx,edi
  200     mov edx,[output_buffer]
  201     sub ecx,edx
  202     call    write
  203     pop edx
  204     next_symbol:
  205     add edx,32
  206     jmp dump_symbols
  207     dump_done:
  208     mov ebx,[output_handle]
  209     call    close
  210     ret
  211 
  212 write_string:
  213     lodsb
  214     test    al,al
  215     jz  string_ok
  216     stosb
  217     jmp write_string
  218       string_ok:
  219     ret
  220 write_hex_dword:
  221     mov ebx,eax
  222     mov ecx,8
  223       write_hex_digits:
  224     xor al,al
  225     shld    eax,ebx,4
  226     cmp al,10
  227     sbb al,69h
  228     das
  229     stosb
  230     shl ebx,4
  231     loop    write_hex_digits
  232     ret
  233 write_dec_number:
  234     push    ebx edx
  235     mov ecx,1000000000
  236     xor edx,edx
  237     xor bl,bl
  238       dec_number_loop:
  239     div ecx
  240     push    edx
  241     cmp ecx,1
  242     je  write_dec_digit
  243     or  bl,bl
  244     jnz write_dec_digit
  245     or  al,al
  246     jz  dec_digit_ok
  247     not bl
  248       write_dec_digit:
  249     add al,30h
  250     stosb
  251       dec_digit_ok:
  252     mov eax,ecx
  253     xor edx,edx
  254     mov ecx,10
  255     div ecx
  256     mov ecx,eax
  257     pop eax
  258     or  ecx,ecx
  259     jnz dec_number_loop
  260     pop edx ebx
  261     ret
  262 write_address_register:
  263     cmp bh,0
  264     je  register_ok
  265     jl  negative_register
  266     mov al,'+'
  267     jmp register_sign_ok
  268       negative_register:
  269     mov al,'-'
  270       register_sign_ok:
  271     stosb
  272     push    esi
  273     mov esi,address_registers
  274       find_register:
  275     lodsb
  276     test    al,al
  277     jz  register_not_found
  278     cmp al,bl
  279     je  register_found
  280     cmp bl,[esi]
  281     je  register_found
  282     lodsb
  283     movzx   eax,al
  284     add esi,eax
  285     jmp find_register
  286       register_not_found:
  287     mov al,bl
  288     shr al,5
  289     cmp al,0Ch shr 1
  290     je  xmm_register
  291     cmp al,0Eh shr 1
  292     je  ymm_register
  293     cmp al,6 shr 1
  294     je  zmm_register
  295       register_found:
  296     lodsb
  297     movzx   ecx,al
  298     rep movsb
  299       write_register_scale:
  300     pop esi
  301     cmp bh,1
  302     je  register_ok
  303     mov al,'*'
  304     stosb
  305     movzx   eax,bh
  306     call    write_dec_number
  307       register_ok:
  308     ret
  309       zmm_register:
  310     mov al,'z'
  311     jmp vector_address_register
  312       ymm_register:
  313     mov al,'y'
  314     jmp vector_address_register
  315       xmm_register:
  316     mov al,'x'
  317       vector_address_register:
  318     stosb
  319     mov ax,'mm'
  320     stosw
  321     mov al,bl
  322     and eax,11111b
  323     call    write_dec_number
  324     jmp write_register_scale
  325 
  326 write_line_identifier:
  327     test    dword [ebx+4],80000000h
  328     jnz identify_macro_generated_line
  329     mov esi,[ebx]
  330     mov eax,[input]
  331     test    esi,esi
  332     jz  main_file
  333     add esi,[eax+32]
  334     jmp file_name_ok
  335       main_file:
  336     mov esi,[eax+8]
  337       file_name_ok:
  338     call    write_string
  339     mov al,'['
  340     stosb
  341     mov eax,[ebx+4]
  342     call    write_dec_number
  343     mov al,']'
  344     stosb
  345     ret
  346       identify_macro_generated_line:
  347     mov al,'{'
  348     stosb
  349     mov esi,_generated_by
  350     call    write_string
  351     push    ebx
  352     mov ebx,[ebx+8]
  353     mov eax,[input]
  354     add ebx,[eax+32]
  355     call    write_line_identifier
  356     pop ebx
  357     mov eax,[ebx+8]
  358     cmp eax,[ebx+12]
  359     je  macro_generated_line_identifier_ok
  360     mov esi,_from
  361     call    write_string
  362     push    ebx
  363     mov ebx,[ebx+12]
  364     mov eax,[input]
  365     add ebx,[eax+32]
  366     call    write_line_identifier
  367     pop ebx
  368       macro_generated_line_identifier_ok:
  369     mov al,'}'
  370     stosb
  371     ret
  372 
  373 not_enough_memory:
  374     call    error
  375     db  'not enough memory to load the required data',0
  376 input_not_found:
  377     call    error
  378     db  'the input file was not found',0
  379 code_not_found:
  380     call    error
  381     db  'the assembled file was not found',0
  382 source_not_found:
  383     call    error
  384     db  'could not find some of the source files',0
  385 reading_error:
  386     call    error
  387     db  'some error occured while trying to read file',0
  388 writing_error:
  389     call    error
  390     db  'some error occured while trying to write file',0
  391 invalid_input:
  392     call    error
  393     db  'input file is not a recognized assembly information format',0
  394 
  395 address_registers db 23h,2,'bx'
  396           db 25h,2,'bp'
  397           db 26h,2,'si'
  398           db 27h,2,'di'
  399           db 40h,3,'eax'
  400           db 41h,3,'ecx'
  401           db 42h,3,'edx'
  402           db 43h,3,'ebx'
  403           db 44h,3,'esp'
  404           db 45h,3,'ebp'
  405           db 46h,3,'esi'
  406           db 47h,3,'edi'
  407           db 48h,3,'r8d'
  408           db 49h,3,'r9d'
  409           db 4Ah,4,'r10d'
  410           db 4Bh,4,'r11d'
  411           db 4Ch,4,'r12d'
  412           db 4Dh,4,'r13d'
  413           db 4Eh,4,'r14d'
  414           db 4Fh,4,'r15d'
  415           db 80h,3,'rax'
  416           db 81h,3,'rcx'
  417           db 82h,3,'rdx'
  418           db 83h,3,'rbx'
  419           db 84h,3,'rsp'
  420           db 85h,3,'rbp'
  421           db 86h,3,'rsi'
  422           db 87h,3,'rdi'
  423           db 88h,2,'r8'
  424           db 89h,2,'r9'
  425           db 8Ah,3,'r10'
  426           db 8Bh,3,'r11'
  427           db 8Ch,3,'r12'
  428           db 8Dh,3,'r13'
  429           db 8Eh,3,'r14'
  430           db 8Fh,3,'r15'
  431           db 94h,3,'eip'
  432           db 98h,3,'rip'
  433           db 0,1,'?'
  434 
  435 _negated db 'negated ',0
  436 _relocatable_segment db 'relocatable segment',0
  437 _relocatable db 'relocatable',0
  438 _in_section db ' in section ',0
  439 _relative_to_external db 'relative to external ',0
  440 _rva db 'relative to RVA or GOT-based offset of ',0
  441 _plt db 'relative to address of PLT entry for ',0
  442 _defined db ', defined in ',0
  443 _generated_by db 'line generated by ',0
  444 _from db ' from ',0