"Fossies" - the Fresh Open Source Software Archive

Member "fasm/source/assemble.inc" (9 Feb 2020, 42134 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. See also the latest Fossies "Diffs" side-by-side code changes report for "assemble.inc": 1.73.21_vs_1.73.22.

    1 
    2 ; flat assembler core
    3 ; Copyright (c) 1999-2020, Tomasz Grysztar.
    4 ; All rights reserved.
    5 
    6 assembler:
    7     xor eax,eax
    8     mov [stub_size],eax
    9     mov [current_pass],ax
   10     mov [resolver_flags],eax
   11     mov [number_of_sections],eax
   12     mov [actual_fixups_size],eax
   13       assembler_loop:
   14     mov eax,[labels_list]
   15     mov [tagged_blocks],eax
   16     mov eax,[additional_memory]
   17     mov [free_additional_memory],eax
   18     mov eax,[additional_memory_end]
   19     mov [structures_buffer],eax
   20     mov esi,[source_start]
   21     mov edi,[code_start]
   22     xor eax,eax
   23     mov dword [adjustment],eax
   24     mov dword [adjustment+4],eax
   25     mov [addressing_space],eax
   26     mov [error_line],eax
   27     mov [counter],eax
   28     mov [format_flags],eax
   29     mov [number_of_relocations],eax
   30     mov [undefined_data_end],eax
   31     mov [file_extension],eax
   32     mov [next_pass_needed],al
   33     mov [output_format],al
   34     mov [adjustment_sign],al
   35     mov [evex_mode],al
   36     mov [code_type],16
   37     call    init_addressing_space
   38       pass_loop:
   39     call    assemble_line
   40     jnc pass_loop
   41     mov eax,[additional_memory_end]
   42     cmp eax,[structures_buffer]
   43     je  pass_done
   44     sub eax,18h
   45     mov eax,[eax+4]
   46     mov [current_line],eax
   47     jmp missing_end_directive
   48       pass_done:
   49     call    close_pass
   50     mov eax,[labels_list]
   51       check_symbols:
   52     cmp eax,[memory_end]
   53     jae symbols_checked
   54     test    byte [eax+8],8
   55     jz  symbol_defined_ok
   56     mov cx,[current_pass]
   57     cmp cx,[eax+18]
   58     jne symbol_defined_ok
   59     test    byte [eax+8],1
   60     jz  symbol_defined_ok
   61     sub cx,[eax+16]
   62     cmp cx,1
   63     jne symbol_defined_ok
   64     and byte [eax+8],not 1
   65     or  [next_pass_needed],-1
   66       symbol_defined_ok:
   67     test    byte [eax+8],10h
   68     jz  use_prediction_ok
   69     mov cx,[current_pass]
   70     and byte [eax+8],not 10h
   71     test    byte [eax+8],20h
   72     jnz check_use_prediction
   73     cmp cx,[eax+18]
   74     jne use_prediction_ok
   75     test    byte [eax+8],8
   76     jz  use_prediction_ok
   77     jmp use_misprediction
   78       check_use_prediction:
   79     test    byte [eax+8],8
   80     jz  use_misprediction
   81     cmp cx,[eax+18]
   82     je  use_prediction_ok
   83       use_misprediction:
   84     or  [next_pass_needed],-1
   85       use_prediction_ok:
   86     test    byte [eax+8],40h
   87     jz  check_next_symbol
   88     and byte [eax+8],not 40h
   89     test    byte [eax+8],4
   90     jnz define_misprediction
   91     mov cx,[current_pass]
   92     test    byte [eax+8],80h
   93     jnz check_define_prediction
   94     cmp cx,[eax+16]
   95     jne check_next_symbol
   96     test    byte [eax+8],1
   97     jz  check_next_symbol
   98     jmp define_misprediction
   99       check_define_prediction:
  100     test    byte [eax+8],1
  101     jz  define_misprediction
  102     cmp cx,[eax+16]
  103     je  check_next_symbol
  104       define_misprediction:
  105     or  [next_pass_needed],-1
  106       check_next_symbol:
  107     add eax,LABEL_STRUCTURE_SIZE
  108     jmp check_symbols
  109       symbols_checked:
  110     cmp [next_pass_needed],0
  111     jne next_pass
  112     mov eax,[error_line]
  113     or  eax,eax
  114     jz  assemble_ok
  115     mov [current_line],eax
  116     cmp [error],undefined_symbol
  117     jne error_confirmed
  118     mov eax,[error_info]
  119     or  eax,eax
  120     jz  error_confirmed
  121     test    byte [eax+8],1
  122     jnz next_pass
  123       error_confirmed:
  124     call    error_handler
  125       error_handler:
  126     mov eax,[error]
  127     sub eax,error_handler
  128     add [esp],eax
  129     ret
  130       next_pass:
  131     inc [current_pass]
  132     mov ax,[current_pass]
  133     cmp ax,[passes_limit]
  134     je  code_cannot_be_generated
  135     jmp assembler_loop
  136       assemble_ok:
  137     ret
  138 
  139 create_addressing_space:
  140     mov ebx,[addressing_space]
  141     test    ebx,ebx
  142     jz  init_addressing_space
  143     test    byte [ebx+0Ah],1
  144     jnz illegal_instruction
  145     mov eax,edi
  146     sub eax,[ebx+18h]
  147     mov [ebx+1Ch],eax
  148       init_addressing_space:
  149     mov ebx,[tagged_blocks]
  150     mov dword [ebx-4],10h
  151     mov dword [ebx-8],24h
  152     sub ebx,8+24h
  153     cmp ebx,edi
  154     jbe out_of_memory
  155     mov [tagged_blocks],ebx
  156     mov [addressing_space],ebx
  157     xor eax,eax
  158     mov [ebx],edi
  159     mov [ebx+4],eax
  160     mov [ebx+8],eax
  161     mov [ebx+10h],eax
  162     mov [ebx+14h],eax
  163     mov [ebx+18h],edi
  164     mov [ebx+1Ch],eax
  165     mov [ebx+20h],eax
  166     ret
  167 
  168 assemble_line:
  169     mov eax,[tagged_blocks]
  170     sub eax,100h
  171     cmp edi,eax
  172     ja  out_of_memory
  173     lods    byte [esi]
  174     cmp al,1
  175     je  assemble_instruction
  176     jb  source_end
  177     cmp al,3
  178     jb  define_label
  179     je  define_constant
  180     cmp al,4
  181     je  label_addressing_space
  182     cmp al,0Fh
  183     je  new_line
  184     cmp al,13h
  185     je  code_type_setting
  186     cmp al,10h
  187     jne illegal_instruction
  188     lods    byte [esi]
  189     jmp segment_prefix
  190       code_type_setting:
  191     lods    byte [esi]
  192     mov [code_type],al
  193     jmp instruction_assembled
  194       new_line:
  195     lods    dword [esi]
  196     mov [current_line],eax
  197     and [prefix_flags],0
  198     cmp [symbols_file],0
  199     je  continue_line
  200     cmp [next_pass_needed],0
  201     jne continue_line
  202     mov ebx,[tagged_blocks]
  203     mov dword [ebx-4],1
  204     mov dword [ebx-8],14h
  205     sub ebx,8+14h
  206     cmp ebx,edi
  207     jbe out_of_memory
  208     mov [tagged_blocks],ebx
  209     mov [ebx],eax
  210     mov [ebx+4],edi
  211     mov eax,[addressing_space]
  212     mov [ebx+8],eax
  213     mov al,[code_type]
  214     mov [ebx+10h],al
  215       continue_line:
  216     cmp byte [esi],0Fh
  217     je  line_assembled
  218     jmp assemble_line
  219       define_label:
  220     lods    dword [esi]
  221     cmp eax,0Fh
  222     jb  invalid_use_of_symbol
  223     je  reserved_word_used_as_symbol
  224     mov ebx,eax
  225     lods    byte [esi]
  226     mov [label_size],al
  227     call    make_label
  228     jmp continue_line
  229       make_label:
  230     mov eax,edi
  231     xor edx,edx
  232     xor cl,cl
  233     mov ebp,[addressing_space]
  234     sub eax,[ds:ebp]
  235     sbb edx,[ds:ebp+4]
  236     sbb cl,[ds:ebp+8]
  237     jp  label_value_ok
  238     call    recoverable_overflow
  239       label_value_ok:
  240     mov [address_sign],cl
  241     test    byte [ds:ebp+0Ah],1
  242     jnz make_virtual_label
  243     or  byte [ebx+9],1
  244     xchg    eax,[ebx]
  245     xchg    edx,[ebx+4]
  246     mov ch,[ebx+9]
  247     shr ch,1
  248     and ch,1
  249     neg ch
  250     sub eax,[ebx]
  251     sbb edx,[ebx+4]
  252     sbb ch,cl
  253     mov dword [adjustment],eax
  254     mov dword [adjustment+4],edx
  255     mov [adjustment_sign],ch
  256     or  al,ch
  257     or  eax,edx
  258     setnz   ah
  259     jmp finish_label
  260       make_virtual_label:
  261     and byte [ebx+9],not 1
  262     cmp eax,[ebx]
  263     mov [ebx],eax
  264     setne   ah
  265     cmp edx,[ebx+4]
  266     mov [ebx+4],edx
  267     setne   al
  268     or  ah,al
  269       finish_label:
  270     mov ebp,[addressing_space]
  271     mov ch,[ds:ebp+9]
  272     mov cl,[label_size]
  273     mov edx,[ds:ebp+14h]
  274     mov ebp,[ds:ebp+10h]
  275       finish_label_symbol:
  276     mov al,[address_sign]
  277     xor al,[ebx+9]
  278     and al,10b
  279     or  ah,al
  280     xor [ebx+9],al
  281     cmp cl,[ebx+10]
  282     mov [ebx+10],cl
  283     setne   al
  284     or  ah,al
  285     cmp ch,[ebx+11]
  286     mov [ebx+11],ch
  287     setne   al
  288     or  ah,al
  289     cmp ebp,[ebx+12]
  290     mov [ebx+12],ebp
  291     setne   al
  292     or  ah,al
  293     or  ch,ch
  294     jz  label_symbol_ok
  295     cmp edx,[ebx+20]
  296     mov [ebx+20],edx
  297     setne   al
  298     or  ah,al
  299       label_symbol_ok:
  300     mov cx,[current_pass]
  301     xchg    [ebx+16],cx
  302     mov edx,[current_line]
  303     mov [ebx+28],edx
  304     and byte [ebx+8],not 2
  305     test    byte [ebx+8],1
  306     jz  new_label
  307     cmp cx,[ebx+16]
  308     je  symbol_already_defined
  309     btr dword [ebx+8],10
  310     jc  requalified_label
  311     inc cx
  312     sub cx,[ebx+16]
  313     setnz   al
  314     or  ah,al
  315     jz  label_made
  316     test    byte [ebx+8],8
  317     jz  label_made
  318     mov cx,[current_pass]
  319     cmp cx,[ebx+18]
  320     jne label_made
  321       requalified_label:
  322     or  [next_pass_needed],-1
  323       label_made:
  324     ret
  325       new_label:
  326     or  byte [ebx+8],1
  327     ret
  328       define_constant:
  329     lods    dword [esi]
  330     inc esi
  331     cmp eax,0Fh
  332     jb  invalid_use_of_symbol
  333     je  reserved_word_used_as_symbol
  334     push    eax
  335     or  [operand_flags],1
  336     call    get_value
  337     pop ebx
  338     xor cl,cl
  339     mov ch,[value_type]
  340     cmp ch,3
  341     je  invalid_use_of_symbol
  342       make_constant:
  343     and byte [ebx+9],not 1
  344     cmp eax,[ebx]
  345     mov [ebx],eax
  346     setne   ah
  347     cmp edx,[ebx+4]
  348     mov [ebx+4],edx
  349     setne   al
  350     or  ah,al
  351     mov al,[value_sign]
  352     xor al,[ebx+9]
  353     and al,10b
  354     or  ah,al
  355     xor [ebx+9],al
  356     cmp cl,[ebx+10]
  357     mov [ebx+10],cl
  358     setne   al
  359     or  ah,al
  360     cmp ch,[ebx+11]
  361     mov [ebx+11],ch
  362     setne   al
  363     or  ah,al
  364     xor edx,edx
  365     cmp edx,[ebx+12]
  366     mov [ebx+12],edx
  367     setne   al
  368     or  ah,al
  369     or  ch,ch
  370     jz  constant_symbol_ok
  371     mov edx,[symbol_identifier]
  372     cmp edx,[ebx+20]
  373     mov [ebx+20],edx
  374     setne   al
  375     or  ah,al
  376       constant_symbol_ok:
  377     mov cx,[current_pass]
  378     xchg    [ebx+16],cx
  379     mov edx,[current_line]
  380     mov [ebx+28],edx
  381     test    byte [ebx+8],1
  382     jz  new_constant
  383     cmp cx,[ebx+16]
  384     jne redeclare_constant
  385     test    byte [ebx+8],2
  386     jz  symbol_already_defined
  387     or  byte [ebx+8],4
  388     and byte [ebx+9],not 4
  389     jmp instruction_assembled
  390       redeclare_constant:
  391     btr dword [ebx+8],10
  392     jc  requalified_constant
  393     inc cx
  394     sub cx,[ebx+16]
  395     setnz   al
  396     or  ah,al
  397     jz  instruction_assembled
  398     test    byte [ebx+8],4
  399     jnz instruction_assembled
  400     test    byte [ebx+8],8
  401     jz  instruction_assembled
  402     mov cx,[current_pass]
  403     cmp cx,[ebx+18]
  404     jne instruction_assembled
  405       requalified_constant:
  406     or  [next_pass_needed],-1
  407     jmp instruction_assembled
  408       new_constant:
  409     or  byte [ebx+8],1+2
  410     jmp instruction_assembled
  411       label_addressing_space:
  412     lods    dword [esi]
  413     cmp eax,0Fh
  414     jb  invalid_use_of_symbol
  415     je  reserved_word_used_as_symbol
  416     mov cx,[current_pass]
  417     test    byte [eax+8],1
  418     jz  make_addressing_space_label
  419     cmp cx,[eax+16]
  420     je  symbol_already_defined
  421     test    byte [eax+9],4
  422     jnz make_addressing_space_label
  423     or  [next_pass_needed],-1
  424       make_addressing_space_label:
  425     mov dx,[eax+8]
  426     and dx,not (2 or 100h)
  427     or  dx,1 or 4 or 400h
  428     mov [eax+8],dx
  429     mov [eax+16],cx
  430     mov edx,[current_line]
  431     mov [eax+28],edx
  432     mov ebx,[addressing_space]
  433     mov [eax],ebx
  434     or  byte [ebx+0Ah],2
  435     jmp continue_line
  436       assemble_instruction:
  437 ;    mov     [operand_size],0
  438 ;    mov     [operand_flags],0
  439 ;    mov     [operand_prefix],0
  440 ;    mov     [rex_prefix],0
  441     and dword [operand_size],0
  442 ;    mov     [opcode_prefix],0
  443 ;    mov     [vex_required],0
  444 ;    mov     [vex_register],0
  445 ;    mov     [immediate_size],0
  446     and dword [opcode_prefix],0
  447     call    instruction_handler
  448       instruction_handler:
  449     movzx   ebx,word [esi]
  450     mov al,[esi+2]
  451     add esi,3
  452     add [esp],ebx
  453     ret
  454       instruction_assembled:
  455     test    [prefix_flags],not 1
  456     jnz illegal_instruction
  457     mov al,[esi]
  458     cmp al,0Fh
  459     je  line_assembled
  460     or  al,al
  461     jnz extra_characters_on_line
  462       line_assembled:
  463     clc
  464     ret
  465       source_end:
  466     dec esi
  467     stc
  468     ret
  469 
  470 org_directive:
  471     lods    byte [esi]
  472     cmp al,'('
  473     jne invalid_argument
  474     cmp byte [esi],'.'
  475     je  invalid_value
  476     call    get_qword_value
  477     mov cl,[value_type]
  478     test    cl,1
  479     jnz invalid_use_of_symbol
  480     push    eax
  481     mov ebx,[addressing_space]
  482     mov eax,edi
  483     sub eax,[ebx+18h]
  484     mov [ebx+1Ch],eax
  485     test    byte [ebx+0Ah],1
  486     jnz in_virtual
  487     call    init_addressing_space
  488     jmp org_space_ok
  489       in_virtual:
  490     call    close_virtual_addressing_space
  491     call    init_addressing_space
  492     or  byte [ebx+0Ah],1
  493       org_space_ok:
  494     pop eax
  495     mov [ebx+9],cl
  496     mov cl,[value_sign]
  497     sub [ebx],eax
  498     sbb [ebx+4],edx
  499     sbb byte [ebx+8],cl
  500     jp  org_value_ok
  501     call    recoverable_overflow
  502       org_value_ok:
  503     mov edx,[symbol_identifier]
  504     mov [ebx+14h],edx
  505     cmp [output_format],1
  506     ja  instruction_assembled
  507     cmp edi,[code_start]
  508     jne instruction_assembled
  509     cmp eax,100h
  510     jne instruction_assembled
  511     bts [format_flags],0
  512     jmp instruction_assembled
  513 label_directive:
  514     lods    byte [esi]
  515     cmp al,2
  516     jne invalid_argument
  517     lods    dword [esi]
  518     cmp eax,0Fh
  519     jb  invalid_use_of_symbol
  520     je  reserved_word_used_as_symbol
  521     inc esi
  522     mov ebx,eax
  523     mov [label_size],0
  524     lods    byte [esi]
  525     cmp al,':'
  526     je  get_label_size
  527     dec esi
  528     cmp al,11h
  529     jne label_size_ok
  530       get_label_size:
  531     lods    word [esi]
  532     cmp al,11h
  533     jne invalid_argument
  534     mov [label_size],ah
  535       label_size_ok:
  536     cmp byte [esi],80h
  537     je  get_free_label_value
  538     call    make_label
  539     jmp instruction_assembled
  540       get_free_label_value:
  541     inc esi
  542     lods    byte [esi]
  543     cmp al,'('
  544     jne invalid_argument
  545     push    ebx ecx
  546     or  byte [ebx+8],4
  547     cmp byte [esi],'.'
  548     je  invalid_value
  549     call    get_address_value
  550     or  bh,bh
  551     setnz   ch
  552     xchg    ch,cl
  553     mov bp,cx
  554     shl ebp,16
  555     xchg    bl,bh
  556     mov bp,bx
  557     pop ecx ebx
  558     and byte [ebx+8],not 4
  559     mov ch,[value_type]
  560     test    ch,1
  561     jnz invalid_use_of_symbol
  562       make_free_label:
  563     and byte [ebx+9],not 1
  564     cmp eax,[ebx]
  565     mov [ebx],eax
  566     setne   ah
  567     cmp edx,[ebx+4]
  568     mov [ebx+4],edx
  569     setne   al
  570     or  ah,al
  571     mov edx,[address_symbol]
  572     mov cl,[label_size]
  573     call    finish_label_symbol
  574     jmp instruction_assembled
  575 load_directive:
  576     lods    byte [esi]
  577     cmp al,2
  578     jne invalid_argument
  579     lods    dword [esi]
  580     cmp eax,0Fh
  581     jb  invalid_use_of_symbol
  582     je  reserved_word_used_as_symbol
  583     inc esi
  584     push    eax
  585     mov al,1
  586     cmp byte [esi],11h
  587     jne load_size_ok
  588     lods    byte [esi]
  589     lods    byte [esi]
  590       load_size_ok:
  591     cmp al,8
  592     ja  invalid_value
  593     mov [operand_size],al
  594     and dword [value],0
  595     and dword [value+4],0
  596     lods    byte [esi]
  597     cmp al,82h
  598     jne invalid_argument
  599     call    get_data_point
  600     jc  value_loaded
  601     push    esi edi
  602     mov esi,ebx
  603     mov edi,value
  604     rep movs byte [edi],[esi]
  605     pop edi esi
  606       value_loaded:
  607     mov [value_sign],0
  608     mov eax,dword [value]
  609     mov edx,dword [value+4]
  610     pop ebx
  611     xor cx,cx
  612     jmp make_constant
  613       get_data_point:
  614     lods    byte [esi]
  615     cmp al,':'
  616     je  get_data_offset
  617     cmp al,'('
  618     jne invalid_argument
  619     mov ebx,[addressing_space]
  620     mov ecx,edi
  621     sub ecx,[ebx+18h]
  622     mov [ebx+1Ch],ecx
  623     cmp byte [esi],11h
  624     jne get_data_address
  625     cmp word [esi+1+4],'):'
  626     jne get_data_address
  627     inc esi
  628     lods    dword [esi]
  629     add esi,2
  630     cmp byte [esi],'('
  631     jne invalid_argument
  632     inc esi
  633     cmp eax,0Fh
  634     jbe reserved_word_used_as_symbol
  635     mov edx,undefined_symbol
  636     test    byte [eax+8],1
  637     jz  addressing_space_unavailable
  638     mov edx,symbol_out_of_scope
  639     mov cx,[eax+16]
  640     cmp cx,[current_pass]
  641     jne addressing_space_unavailable
  642     test    byte [eax+9],4
  643     jz  invalid_use_of_symbol
  644     mov ebx,eax
  645     mov ax,[current_pass]
  646     mov [ebx+18],ax
  647     or  byte [ebx+8],8
  648     call    store_label_reference
  649       get_addressing_space:
  650     mov ebx,[ebx]
  651       get_data_address:
  652     push    ebx
  653     cmp byte [esi],'.'
  654     je  invalid_value
  655     or  [operand_flags],1
  656     call    get_address_value
  657     pop ebp
  658     call    calculate_relative_offset
  659     cmp [next_pass_needed],0
  660     jne data_address_type_ok
  661     cmp [value_type],0
  662     jne invalid_use_of_symbol
  663       data_address_type_ok:
  664     mov ebx,edi
  665     xor ecx,ecx
  666     add ebx,eax
  667     adc edx,ecx
  668     mov eax,ebx
  669     sub eax,[ds:ebp+18h]
  670     sbb edx,ecx
  671     jnz bad_data_address
  672     mov cl,[operand_size]
  673     add eax,ecx
  674     cmp eax,[ds:ebp+1Ch]
  675     ja  bad_data_address
  676     clc
  677     ret
  678       addressing_space_unavailable:
  679     cmp [error_line],0
  680     jne get_data_address
  681     push    [current_line]
  682     pop [error_line]
  683     mov [error],edx
  684     mov [error_info],eax
  685     jmp get_data_address
  686       bad_data_address:
  687     call    recoverable_overflow
  688     stc
  689     ret
  690       get_data_offset:
  691     cmp [output_format],2
  692     jae invalid_operand
  693     lods    byte [esi]
  694     cmp al,'('
  695     jne invalid_argument
  696     cmp byte [esi],'.'
  697     je  invalid_value
  698     call    get_dword_value
  699     cmp [value_type],0
  700     je  data_offset_ok
  701     call    recoverable_invalid_address
  702       data_offset_ok:
  703     add eax,[code_start]
  704     jc  bad_data_address
  705     mov ebx,eax
  706     movzx   ecx,[operand_size]
  707     add eax,ecx
  708     jc  bad_data_address
  709     mov edx,[addressing_space]
  710     test    byte [edx+0Ah],1
  711     jnz data_offset_from_virtual
  712     cmp eax,edi
  713     ja  bad_data_address
  714     clc
  715     ret
  716       data_offset_from_virtual:
  717     cmp eax,[undefined_data_end]
  718     ja  bad_data_address
  719     clc
  720     ret
  721 
  722 store_directive:
  723     cmp byte [esi],11h
  724     je  sized_store
  725     lods    byte [esi]
  726     cmp al,'('
  727     jne invalid_argument
  728     call    get_byte_value
  729     xor edx,edx
  730     movzx   eax,al
  731     mov [operand_size],1
  732     jmp store_value_ok
  733       sized_store:
  734     or  [operand_flags],1
  735     call    get_value
  736       store_value_ok:
  737     cmp [value_type],0
  738     jne invalid_use_of_symbol
  739     mov dword [value],eax
  740     mov dword [value+4],edx
  741     lods    byte [esi]
  742     cmp al,80h
  743     jne invalid_argument
  744     call    get_data_point
  745     jc  instruction_assembled
  746     push    esi edi
  747     mov esi,value
  748     mov edi,ebx
  749     rep movs byte [edi],[esi]
  750     mov eax,edi
  751     pop edi esi
  752     cmp ebx,[undefined_data_end]
  753     jae instruction_assembled
  754     cmp eax,[undefined_data_start]
  755     jbe instruction_assembled
  756     mov [undefined_data_start],eax
  757     jmp instruction_assembled
  758 
  759 display_directive:
  760     lods    byte [esi]
  761     cmp al,'('
  762     jne invalid_argument
  763     cmp byte [esi],0
  764     jne display_byte
  765     inc esi
  766     lods    dword [esi]
  767     mov ecx,eax
  768     push    edi
  769     mov edi,[tagged_blocks]
  770     sub edi,8
  771     sub edi,eax
  772     cmp edi,[esp]
  773     jbe out_of_memory
  774     mov [tagged_blocks],edi
  775     rep movs byte [edi],[esi]
  776     stos    dword [edi]
  777     xor eax,eax
  778     stos    dword [edi]
  779     pop edi
  780     inc esi
  781     jmp display_next
  782       display_byte:
  783     call    get_byte_value
  784     push    edi
  785     mov edi,[tagged_blocks]
  786     sub edi,8+1
  787     mov [tagged_blocks],edi
  788     stos    byte [edi]
  789     mov eax,1
  790     stos    dword [edi]
  791     dec eax
  792     stos    dword [edi]
  793     pop edi
  794       display_next:
  795     cmp edi,[tagged_blocks]
  796     ja  out_of_memory
  797     lods    byte [esi]
  798     cmp al,','
  799     je  display_directive
  800     dec esi
  801     jmp instruction_assembled
  802 show_display_buffer:
  803     mov eax,[tagged_blocks]
  804     or  eax,eax
  805     jz  display_done
  806     mov esi,[labels_list]
  807     cmp esi,eax
  808     je  display_done
  809       display_messages:
  810     sub esi,8
  811     mov eax,[esi+4]
  812     mov ecx,[esi]
  813     sub esi,ecx
  814     cmp eax,10h
  815     je  write_addressing_space
  816     test    eax,eax
  817     jnz skip_block
  818     push    esi
  819     call    display_block
  820     pop esi
  821       skip_block:
  822     cmp esi,[tagged_blocks]
  823     jne display_messages
  824       display_done:
  825     ret
  826       write_addressing_space:
  827     mov ecx,[esi+20h]
  828     jecxz   skip_block
  829     push    esi
  830     mov edi,[free_additional_memory]
  831     mov esi,[output_file]
  832     test    esi,esi
  833     jz  addressing_space_written
  834     xor ebx,ebx
  835       copy_output_path:
  836     lodsb
  837     cmp edi,[structures_buffer]
  838     jae out_of_memory
  839     stosb
  840     test    al,al
  841     jz  output_path_copied
  842     cmp al,'/'
  843     je  new_path_segment
  844     cmp al,'\'
  845     je  new_path_segment
  846     cmp al,'.'
  847     jne copy_output_path
  848     mov ebx,edi
  849     jmp copy_output_path
  850       new_path_segment:
  851     xor ebx,ebx
  852     jmp copy_output_path
  853       output_path_copied:
  854     test    ebx,ebx
  855     jnz append_extension
  856     mov byte [edi-1],'.'
  857     mov ebx,edi
  858       append_extension:
  859     mov edi,ebx
  860     add ebx,ecx
  861     inc ebx
  862     cmp ebx,[structures_buffer]
  863     jae out_of_memory
  864     mov esi,[esp]
  865     mov esi,[esi+18h]
  866     sub esi,ecx
  867     rep movs byte [edi],[esi]
  868     xor al,al
  869     stos    byte [edi]
  870     mov edx,[free_additional_memory]
  871     call    create
  872     jc  write_failed
  873     mov esi,[esp]
  874     mov edx,[esi+18h]
  875     mov ecx,[esi+1Ch]
  876     call    write
  877     jc  write_failed
  878     call    close
  879       addressing_space_written:
  880     pop esi
  881     jmp skip_block
  882 
  883 times_directive:
  884     lods    byte [esi]
  885     cmp al,'('
  886     jne invalid_argument
  887     cmp byte [esi],'.'
  888     je  invalid_value
  889     call    get_count_value
  890     cmp eax,0
  891     je  zero_times
  892     cmp byte [esi],':'
  893     jne times_argument_ok
  894     inc esi
  895       times_argument_ok:
  896     push    [counter]
  897     push    [counter_limit]
  898     mov [counter_limit],eax
  899     mov [counter],1
  900       times_loop:
  901     mov eax,esp
  902     sub eax,[stack_limit]
  903     cmp eax,100h
  904     jb  stack_overflow
  905     push    esi
  906     or  [prefix_flags],1
  907     call    continue_line
  908     mov eax,[counter_limit]
  909     cmp [counter],eax
  910     je  times_done
  911     inc [counter]
  912     pop esi
  913     jmp times_loop
  914       times_done:
  915     pop eax
  916     pop [counter_limit]
  917     pop [counter]
  918     jmp instruction_assembled
  919       zero_times:
  920     call    skip_symbol
  921     jnc zero_times
  922     jmp instruction_assembled
  923 
  924 virtual_directive:
  925     lods    byte [esi]
  926     cmp al,'('
  927     je  continue_virtual_area
  928     cmp al,80h
  929     jne virtual_at_current
  930     lods    byte [esi]
  931     cmp al,'('
  932     jne invalid_argument
  933     cmp byte [esi],'.'
  934     je  invalid_value
  935     call    get_address_value
  936     mov ebp,[address_symbol]
  937     or  bh,bh
  938     setnz   ch
  939     jmp set_virtual
  940       virtual_at_current:
  941     dec esi
  942       virtual_fallback:
  943     mov ebp,[addressing_space]
  944     mov al,[ds:ebp+9]
  945     mov [value_type],al
  946     mov eax,edi
  947     xor edx,edx
  948     xor cl,cl
  949     sub eax,[ds:ebp]
  950     sbb edx,[ds:ebp+4]
  951     sbb cl,[ds:ebp+8]
  952     mov [address_sign],cl
  953     mov bx,[ds:ebp+10h]
  954     mov cx,[ds:ebp+10h+2]
  955     xchg    bh,bl
  956     xchg    ch,cl
  957     mov ebp,[ds:ebp+14h]
  958       set_virtual:
  959     xchg    bl,bh
  960     xchg    cl,ch
  961     shl ecx,16
  962     mov cx,bx
  963     push    ecx eax
  964     mov ebx,[addressing_space]
  965     test    byte [ebx+0Ah],1
  966     jnz non_virtual_end_ok
  967     mov eax,edi
  968     xchg    eax,[undefined_data_end]
  969     cmp eax,edi
  970     je  non_virtual_end_ok
  971     mov [undefined_data_start],edi
  972       non_virtual_end_ok:
  973     call    allocate_virtual_structure_data
  974     call    init_addressing_space
  975     or  byte [ebx+0Ah],1
  976     cmp byte [esi],86h
  977     jne addressing_space_extension_ok
  978     cmp word [esi+1],'('
  979     jne invalid_argument
  980     mov ecx,[esi+3]
  981     add esi,3+4
  982     add [ebx+18h],ecx
  983     mov [ebx+20h],ecx
  984     or  byte [ebx+0Ah],2
  985     push    ebx
  986     mov ebx,characters
  987       get_extension:
  988     lods    byte [esi]
  989     stos    byte [edi]
  990     xlat    byte [ebx]
  991     test    al,al
  992     jz  invalid_argument
  993     loop    get_extension
  994     inc esi
  995     pop ebx
  996       addressing_space_extension_ok:
  997     pop eax
  998     mov cl,[address_sign]
  999     not eax
 1000     not edx
 1001     not cl
 1002     add eax,1
 1003     adc edx,0
 1004     adc cl,0
 1005     add eax,edi
 1006     adc edx,0
 1007     adc cl,0
 1008     mov [ebx],eax
 1009     mov [ebx+4],edx
 1010     mov [ebx+8],cl
 1011     pop dword [ebx+10h]
 1012     mov [ebx+14h],ebp
 1013     mov al,[value_type]
 1014     test    al,1
 1015     jnz invalid_use_of_symbol
 1016     mov [ebx+9],al
 1017     jmp instruction_assembled
 1018       allocate_structure_data:
 1019     mov ebx,[structures_buffer]
 1020     sub ebx,18h
 1021     cmp ebx,[free_additional_memory]
 1022     jb  out_of_memory
 1023     mov [structures_buffer],ebx
 1024     ret
 1025       find_structure_data:
 1026     mov ebx,[structures_buffer]
 1027       scan_structures:
 1028     cmp ebx,[additional_memory_end]
 1029     je  no_such_structure
 1030     cmp ax,[ebx]
 1031     je  structure_data_found
 1032     add ebx,18h
 1033     jmp scan_structures
 1034       structure_data_found:
 1035     ret
 1036       no_such_structure:
 1037     stc
 1038     ret
 1039       allocate_virtual_structure_data:
 1040     call    allocate_structure_data
 1041     mov word [ebx],virtual_directive-instruction_handler
 1042     mov ecx,[addressing_space]
 1043     mov [ebx+12],ecx
 1044     mov [ebx+8],edi
 1045     mov ecx,[current_line]
 1046     mov [ebx+4],ecx
 1047     mov ebx,[addressing_space]
 1048     mov eax,edi
 1049     sub eax,[ebx+18h]
 1050     mov [ebx+1Ch],eax
 1051     ret
 1052       continue_virtual_area:
 1053     cmp byte [esi],11h
 1054     jne invalid_argument
 1055     cmp byte [esi+1+4],')'
 1056     jne invalid_argument
 1057     inc esi
 1058     lods    dword [esi]
 1059     inc esi
 1060     cmp eax,0Fh
 1061     jbe reserved_word_used_as_symbol
 1062     mov edx,undefined_symbol
 1063     test    byte [eax+8],1
 1064     jz  virtual_area_unavailable
 1065     mov edx,symbol_out_of_scope
 1066     mov cx,[eax+16]
 1067     cmp cx,[current_pass]
 1068     jne virtual_area_unavailable
 1069     mov edx,invalid_use_of_symbol
 1070     test    byte [eax+9],4
 1071     jz  virtual_area_unavailable
 1072     mov ebx,eax
 1073     mov ax,[current_pass]
 1074     mov [ebx+18],ax
 1075     or  byte [ebx+8],8
 1076     call    store_label_reference
 1077     mov ebx,[ebx]
 1078     test    byte [ebx+0Ah],4
 1079     jz  virtual_area_unavailable
 1080     and byte [ebx+0Ah],not 4
 1081     mov edx,ebx
 1082     call    allocate_virtual_structure_data
 1083     mov [addressing_space],edx
 1084     push    esi
 1085     mov esi,[edx+18h]
 1086     mov ecx,[edx+1Ch]
 1087     mov eax,[edx+20h]
 1088     sub esi,eax
 1089     add ecx,eax
 1090     lea eax,[edi+ecx]
 1091     cmp eax,[tagged_blocks]
 1092     jae out_of_memory
 1093     mov eax,esi
 1094     sub eax,edi
 1095     sub [edx+18h],eax
 1096     sub [edx],eax
 1097     sbb dword [edx+4],0
 1098     sbb byte [edx+8],0
 1099     mov al,cl
 1100     shr ecx,2
 1101     rep movs dword [edi],[esi]
 1102     mov cl,al
 1103     and cl,11b
 1104     rep movs byte [edi],[esi]
 1105     pop esi
 1106     jmp instruction_assembled
 1107       virtual_area_unavailable:
 1108     cmp [error_line],0
 1109     jne virtual_fallback
 1110     push    [current_line]
 1111     pop [error_line]
 1112     mov [error],edx
 1113     mov [error_info],eax
 1114     jmp virtual_fallback
 1115       end_virtual:
 1116     call    find_structure_data
 1117     jc  unexpected_instruction
 1118     push    ebx
 1119     call    close_virtual_addressing_space
 1120     pop ebx
 1121     mov eax,[ebx+12]
 1122     mov [addressing_space],eax
 1123     mov edi,[ebx+8]
 1124       remove_structure_data:
 1125     push    esi edi
 1126     mov ecx,ebx
 1127     sub ecx,[structures_buffer]
 1128     shr ecx,2
 1129     lea esi,[ebx-4]
 1130     lea edi,[esi+18h]
 1131     std
 1132     rep movs dword [edi],[esi]
 1133     cld
 1134     add [structures_buffer],18h
 1135     pop edi esi
 1136     ret
 1137       close_virtual_addressing_space:
 1138     mov ebx,[addressing_space]
 1139     mov eax,edi
 1140     sub eax,[ebx+18h]
 1141     mov [ebx+1Ch],eax
 1142     add eax,[ebx+20h]
 1143     test    byte [ebx+0Ah],2
 1144     jz  addressing_space_closed
 1145     or  byte [ebx+0Ah],4
 1146     push    esi edi ecx edx
 1147     mov ecx,eax
 1148     mov eax,[tagged_blocks]
 1149     mov dword [eax-4],11h
 1150     mov dword [eax-8],ecx
 1151     sub eax,8
 1152     sub eax,ecx
 1153     mov [tagged_blocks],eax
 1154     lea edi,[eax+ecx-1]
 1155     add eax,[ebx+20h]
 1156     xchg    eax,[ebx+18h]
 1157     sub eax,[ebx+20h]
 1158     lea esi,[eax+ecx-1]
 1159     mov eax,edi
 1160     sub eax,esi
 1161     std
 1162     shr ecx,1
 1163     jnc virtual_byte_ok
 1164     movs    byte [edi],[esi]
 1165       virtual_byte_ok:
 1166     dec esi
 1167     dec edi
 1168     shr ecx,1
 1169     jnc virtual_word_ok
 1170     movs    word [edi],[esi]
 1171       virtual_word_ok:
 1172     sub esi,2
 1173     sub edi,2
 1174     rep movs dword [edi],[esi]
 1175     cld
 1176     xor edx,edx
 1177     add [ebx],eax
 1178     adc dword [ebx+4],edx
 1179     adc byte [ebx+8],dl
 1180     pop edx ecx edi esi
 1181       addressing_space_closed:
 1182     ret
 1183 repeat_directive:
 1184     test    [prefix_flags],1
 1185     jnz unexpected_instruction
 1186     lods    byte [esi]
 1187     cmp al,'('
 1188     jne invalid_argument
 1189     cmp byte [esi],'.'
 1190     je  invalid_value
 1191     call    get_count_value
 1192     cmp eax,0
 1193     je  zero_repeat
 1194     call    allocate_structure_data
 1195     mov word [ebx],repeat_directive-instruction_handler
 1196     xchg    eax,[counter_limit]
 1197     mov [ebx+10h],eax
 1198     mov eax,1
 1199     xchg    eax,[counter]
 1200     mov [ebx+14h],eax
 1201     mov [ebx+8],esi
 1202     mov eax,[current_line]
 1203     mov [ebx+4],eax
 1204     jmp instruction_assembled
 1205       end_repeat:
 1206     test    [prefix_flags],1
 1207     jnz unexpected_instruction
 1208     call    find_structure_data
 1209     jc  unexpected_instruction
 1210     mov eax,[counter_limit]
 1211     inc [counter]
 1212     cmp [counter],eax
 1213     jbe continue_repeating
 1214       stop_repeat:
 1215     mov eax,[ebx+10h]
 1216     mov [counter_limit],eax
 1217     mov eax,[ebx+14h]
 1218     mov [counter],eax
 1219     call    remove_structure_data
 1220     jmp instruction_assembled
 1221       continue_repeating:
 1222     mov esi,[ebx+8]
 1223     jmp instruction_assembled
 1224       zero_repeat:
 1225     mov al,[esi]
 1226     or  al,al
 1227     jz  missing_end_directive
 1228     cmp al,0Fh
 1229     jne extra_characters_on_line
 1230     call    find_end_repeat
 1231     jmp instruction_assembled
 1232       find_end_repeat:
 1233     call    find_structure_end
 1234     cmp ax,repeat_directive-instruction_handler
 1235     jne unexpected_instruction
 1236     ret
 1237 while_directive:
 1238     test    [prefix_flags],1
 1239     jnz unexpected_instruction
 1240     call    allocate_structure_data
 1241     mov word [ebx],while_directive-instruction_handler
 1242     mov eax,1
 1243     xchg    eax,[counter]
 1244     mov [ebx+10h],eax
 1245     mov [ebx+8],esi
 1246     mov eax,[current_line]
 1247     mov [ebx+4],eax
 1248       do_while:
 1249     push    ebx
 1250     call    calculate_logical_expression
 1251     or  al,al
 1252     jnz while_true
 1253     mov al,[esi]
 1254     or  al,al
 1255     jz  missing_end_directive
 1256     cmp al,0Fh
 1257     jne extra_characters_on_line
 1258       stop_while:
 1259     call    find_end_while
 1260     pop ebx
 1261     mov eax,[ebx+10h]
 1262     mov [counter],eax
 1263     call    remove_structure_data
 1264     jmp instruction_assembled
 1265       while_true:
 1266     pop ebx
 1267     jmp instruction_assembled
 1268       end_while:
 1269     test    [prefix_flags],1
 1270     jnz unexpected_instruction
 1271     call    find_structure_data
 1272     jc  unexpected_instruction
 1273     mov eax,[ebx+4]
 1274     mov [current_line],eax
 1275     inc [counter]
 1276     jz  too_many_repeats
 1277     mov esi,[ebx+8]
 1278     jmp do_while
 1279       find_end_while:
 1280     call    find_structure_end
 1281     cmp ax,while_directive-instruction_handler
 1282     jne unexpected_instruction
 1283     ret
 1284 if_directive:
 1285     test    [prefix_flags],1
 1286     jnz unexpected_instruction
 1287     call    calculate_logical_expression
 1288     mov dl,al
 1289     mov al,[esi]
 1290     or  al,al
 1291     jz  missing_end_directive
 1292     cmp al,0Fh
 1293     jne extra_characters_on_line
 1294     or  dl,dl
 1295     jnz if_true
 1296     call    find_else
 1297     jc  instruction_assembled
 1298     mov al,[esi]
 1299     cmp al,1
 1300     jne else_true
 1301     cmp word [esi+1],if_directive-instruction_handler
 1302     jne else_true
 1303     add esi,4
 1304     jmp if_directive
 1305       if_true:
 1306     xor al,al
 1307       make_if_structure:
 1308     call    allocate_structure_data
 1309     mov word [ebx],if_directive-instruction_handler
 1310     mov byte [ebx+2],al
 1311     mov eax,[current_line]
 1312     mov [ebx+4],eax
 1313     jmp instruction_assembled
 1314       else_true:
 1315     or  al,al
 1316     jz  missing_end_directive
 1317     cmp al,0Fh
 1318     jne extra_characters_on_line
 1319     or  al,-1
 1320     jmp make_if_structure
 1321       else_directive:
 1322     test    [prefix_flags],1
 1323     jnz unexpected_instruction
 1324     mov ax,if_directive-instruction_handler
 1325     call    find_structure_data
 1326     jc  unexpected_instruction
 1327     cmp byte [ebx+2],0
 1328     jne unexpected_instruction
 1329       found_else:
 1330     mov al,[esi]
 1331     cmp al,1
 1332     jne skip_else
 1333     cmp word [esi+1],if_directive-instruction_handler
 1334     jne skip_else
 1335     add esi,4
 1336     call    find_else
 1337     jnc found_else
 1338     call    remove_structure_data
 1339     jmp instruction_assembled
 1340       skip_else:
 1341     or  al,al
 1342     jz  missing_end_directive
 1343     cmp al,0Fh
 1344     jne extra_characters_on_line
 1345     call    find_end_if
 1346     call    remove_structure_data
 1347     jmp instruction_assembled
 1348       end_if:
 1349     test    [prefix_flags],1
 1350     jnz unexpected_instruction
 1351     call    find_structure_data
 1352     jc  unexpected_instruction
 1353     call    remove_structure_data
 1354     jmp instruction_assembled
 1355       find_else:
 1356     call    find_structure_end
 1357     cmp ax,else_directive-instruction_handler
 1358     je  else_found
 1359     cmp ax,if_directive-instruction_handler
 1360     jne unexpected_instruction
 1361     stc
 1362     ret
 1363       else_found:
 1364     clc
 1365     ret
 1366       find_end_if:
 1367     call    find_structure_end
 1368     cmp ax,if_directive-instruction_handler
 1369     jne unexpected_instruction
 1370     ret
 1371       find_structure_end:
 1372     push    [error_line]
 1373     mov eax,[current_line]
 1374     mov [error_line],eax
 1375       find_end_directive:
 1376     call    skip_symbol
 1377     jnc find_end_directive
 1378     lods    byte [esi]
 1379     cmp al,0Fh
 1380     jne no_end_directive
 1381     lods    dword [esi]
 1382     mov [current_line],eax
 1383       skip_labels:
 1384     cmp byte [esi],2
 1385     jne labels_ok
 1386     add esi,6
 1387     jmp skip_labels
 1388       labels_ok:
 1389     cmp byte [esi],1
 1390     jne find_end_directive
 1391     mov ax,[esi+1]
 1392     cmp ax,prefix_instruction-instruction_handler
 1393     je  find_end_directive
 1394     add esi,4
 1395     cmp ax,repeat_directive-instruction_handler
 1396     je  skip_repeat
 1397     cmp ax,while_directive-instruction_handler
 1398     je  skip_while
 1399     cmp ax,if_directive-instruction_handler
 1400     je  skip_if
 1401     cmp ax,else_directive-instruction_handler
 1402     je  structure_end
 1403     cmp ax,end_directive-instruction_handler
 1404     jne find_end_directive
 1405     cmp byte [esi],1
 1406     jne find_end_directive
 1407     mov ax,[esi+1]
 1408     add esi,4
 1409     cmp ax,repeat_directive-instruction_handler
 1410     je  structure_end
 1411     cmp ax,while_directive-instruction_handler
 1412     je  structure_end
 1413     cmp ax,if_directive-instruction_handler
 1414     jne find_end_directive
 1415       structure_end:
 1416     pop [error_line]
 1417     ret
 1418       no_end_directive:
 1419     mov eax,[error_line]
 1420     mov [current_line],eax
 1421     jmp missing_end_directive
 1422       skip_repeat:
 1423     call    find_end_repeat
 1424     jmp find_end_directive
 1425       skip_while:
 1426     call    find_end_while
 1427     jmp find_end_directive
 1428       skip_if:
 1429     call    skip_if_block
 1430     jmp find_end_directive
 1431       skip_if_block:
 1432     call    find_else
 1433     jc  if_block_skipped
 1434     cmp byte [esi],1
 1435     jne skip_after_else
 1436     cmp word [esi+1],if_directive-instruction_handler
 1437     jne skip_after_else
 1438     add esi,4
 1439     jmp skip_if_block
 1440       skip_after_else:
 1441     call    find_end_if
 1442       if_block_skipped:
 1443     ret
 1444 end_directive:
 1445     lods    byte [esi]
 1446     cmp al,1
 1447     jne invalid_argument
 1448     lods    word [esi]
 1449     inc esi
 1450     cmp ax,virtual_directive-instruction_handler
 1451     je  end_virtual
 1452     cmp ax,repeat_directive-instruction_handler
 1453     je  end_repeat
 1454     cmp ax,while_directive-instruction_handler
 1455     je  end_while
 1456     cmp ax,if_directive-instruction_handler
 1457     je  end_if
 1458     cmp ax,data_directive-instruction_handler
 1459     je  end_data
 1460     jmp invalid_argument
 1461 break_directive:
 1462     mov ebx,[structures_buffer]
 1463     mov al,[esi]
 1464     or  al,al
 1465     jz  find_breakable_structure
 1466     cmp al,0Fh
 1467     jne extra_characters_on_line
 1468       find_breakable_structure:
 1469     cmp ebx,[additional_memory_end]
 1470     je  unexpected_instruction
 1471     mov ax,[ebx]
 1472     cmp ax,repeat_directive-instruction_handler
 1473     je  break_repeat
 1474     cmp ax,while_directive-instruction_handler
 1475     je  break_while
 1476     cmp ax,if_directive-instruction_handler
 1477     je  break_if
 1478     add ebx,18h
 1479     jmp find_breakable_structure
 1480       break_if:
 1481     push    [current_line]
 1482     mov eax,[ebx+4]
 1483     mov [current_line],eax
 1484     call    remove_structure_data
 1485     call    skip_if_block
 1486     pop [current_line]
 1487     mov ebx,[structures_buffer]
 1488     jmp find_breakable_structure
 1489       break_repeat:
 1490     push    ebx
 1491     call    find_end_repeat
 1492     pop ebx
 1493     jmp stop_repeat
 1494       break_while:
 1495     push    ebx
 1496     jmp stop_while
 1497 
 1498 define_data:
 1499     cmp edi,[tagged_blocks]
 1500     jae out_of_memory
 1501     cmp byte [esi],'('
 1502     jne simple_data_value
 1503     mov ebx,esi
 1504     inc esi
 1505     call    skip_expression
 1506     xchg    esi,ebx
 1507     cmp byte [ebx],81h
 1508     jne simple_data_value
 1509     inc esi
 1510     call    get_count_value
 1511     inc esi
 1512     or  eax,eax
 1513     jz  duplicate_zero_times
 1514     cmp byte [esi],91h
 1515     jne duplicate_single_data_value
 1516     inc esi
 1517       duplicate_data:
 1518     push    eax esi
 1519       duplicated_values:
 1520     cmp edi,[tagged_blocks]
 1521     jae out_of_memory
 1522     clc
 1523     call    near dword [esp+8]
 1524     lods    byte [esi]
 1525     cmp al,','
 1526     je  duplicated_values
 1527     cmp al,92h
 1528     jne invalid_argument
 1529     pop ebx eax
 1530     dec eax
 1531     jz  data_defined
 1532     mov esi,ebx
 1533     jmp duplicate_data
 1534       duplicate_single_data_value:
 1535     cmp edi,[tagged_blocks]
 1536     jae out_of_memory
 1537     push    eax esi
 1538     clc
 1539     call    near dword [esp+8]
 1540     pop ebx eax
 1541     dec eax
 1542     jz  data_defined
 1543     mov esi,ebx
 1544     jmp duplicate_single_data_value
 1545       duplicate_zero_times:
 1546     cmp byte [esi],91h
 1547     jne skip_single_data_value
 1548     inc esi
 1549       skip_data_value:
 1550     call    skip_symbol
 1551     jc  invalid_argument
 1552     cmp byte [esi],92h
 1553     jne skip_data_value
 1554     inc esi
 1555     jmp data_defined
 1556       skip_single_data_value:
 1557     call    skip_symbol
 1558     jmp data_defined
 1559       simple_data_value:
 1560     cmp edi,[tagged_blocks]
 1561     jae out_of_memory
 1562     clc
 1563     call    near dword [esp]
 1564       data_defined:
 1565     lods    byte [esi]
 1566     cmp al,','
 1567     je  define_data
 1568     dec esi
 1569     stc
 1570     ret
 1571 data_bytes:
 1572     call    define_data
 1573     jc  instruction_assembled
 1574     lods    byte [esi]
 1575     cmp al,'('
 1576     je  get_byte
 1577     cmp al,'?'
 1578     jne invalid_argument
 1579     mov eax,edi
 1580     mov byte [edi],0
 1581     inc edi
 1582     jmp undefined_data
 1583       get_byte:
 1584     cmp byte [esi],0
 1585     je  get_string
 1586     call    get_byte_value
 1587     stos    byte [edi]
 1588     ret
 1589       get_string:
 1590     inc esi
 1591     lods    dword [esi]
 1592     mov ecx,eax
 1593     lea eax,[edi+ecx]
 1594     cmp eax,[tagged_blocks]
 1595     ja  out_of_memory
 1596     rep movs byte [edi],[esi]
 1597     inc esi
 1598     ret
 1599       undefined_data:
 1600     mov ebp,[addressing_space]
 1601     test    byte [ds:ebp+0Ah],1
 1602     jz  mark_undefined_data
 1603     ret
 1604       mark_undefined_data:
 1605     cmp eax,[undefined_data_end]
 1606     je  undefined_data_ok
 1607     mov [undefined_data_start],eax
 1608       undefined_data_ok:
 1609     mov [undefined_data_end],edi
 1610     ret
 1611 data_unicode:
 1612     or  [base_code],-1
 1613     jmp define_words
 1614 data_words:
 1615     mov [base_code],0
 1616     define_words:
 1617     call    define_data
 1618     jc  instruction_assembled
 1619     lods    byte [esi]
 1620     cmp al,'('
 1621     je  get_word
 1622     cmp al,'?'
 1623     jne invalid_argument
 1624     mov eax,edi
 1625     and word [edi],0
 1626     scas    word [edi]
 1627     jmp undefined_data
 1628     ret
 1629       get_word:
 1630     cmp [base_code],0
 1631     je  word_data_value
 1632     cmp byte [esi],0
 1633     je  word_string
 1634       word_data_value:
 1635     call    get_word_value
 1636     call    mark_relocation
 1637     stos    word [edi]
 1638     ret
 1639       word_string:
 1640     inc esi
 1641     lods    dword [esi]
 1642     mov ecx,eax
 1643     jecxz   word_string_ok
 1644     lea eax,[edi+ecx*2]
 1645     cmp eax,[tagged_blocks]
 1646     ja  out_of_memory
 1647     xor ah,ah
 1648       copy_word_string:
 1649     lods    byte [esi]
 1650     stos    word [edi]
 1651     loop    copy_word_string
 1652       word_string_ok:
 1653     inc esi
 1654     ret
 1655 data_dwords:
 1656     call    define_data
 1657     jc  instruction_assembled
 1658     lods    byte [esi]
 1659     cmp al,'('
 1660     je  get_dword
 1661     cmp al,'?'
 1662     jne invalid_argument
 1663     mov eax,edi
 1664     and dword [edi],0
 1665     scas    dword [edi]
 1666     jmp undefined_data
 1667       get_dword:
 1668     push    esi
 1669     call    get_dword_value
 1670     pop ebx
 1671     cmp byte [esi],':'
 1672     je  complex_dword
 1673     call    mark_relocation
 1674     stos    dword [edi]
 1675     ret
 1676       complex_dword:
 1677     mov esi,ebx
 1678     cmp byte [esi],'.'
 1679     je  invalid_value
 1680     call    get_word_value
 1681     push    eax
 1682     inc esi
 1683     lods    byte [esi]
 1684     cmp al,'('
 1685     jne invalid_operand
 1686     mov al,[value_type]
 1687     push    eax
 1688     cmp byte [esi],'.'
 1689     je  invalid_value
 1690     call    get_word_value
 1691     call    mark_relocation
 1692     stos    word [edi]
 1693     pop eax
 1694     mov [value_type],al
 1695     pop eax
 1696     call    mark_relocation
 1697     stos    word [edi]
 1698     ret
 1699 data_pwords:
 1700     call    define_data
 1701     jc  instruction_assembled
 1702     lods    byte [esi]
 1703     cmp al,'('
 1704     je  get_pword
 1705     cmp al,'?'
 1706     jne invalid_argument
 1707     mov eax,edi
 1708     and dword [edi],0
 1709     scas    dword [edi]
 1710     and word [edi],0
 1711     scas    word [edi]
 1712     jmp undefined_data
 1713       get_pword:
 1714     push    esi
 1715     call    get_pword_value
 1716     pop ebx
 1717     cmp byte [esi],':'
 1718     je  complex_pword
 1719     call    mark_relocation
 1720     stos    dword [edi]
 1721     mov ax,dx
 1722     stos    word [edi]
 1723     ret
 1724       complex_pword:
 1725     mov esi,ebx
 1726     cmp byte [esi],'.'
 1727     je  invalid_value
 1728     call    get_word_value
 1729     push    eax
 1730     inc esi
 1731     lods    byte [esi]
 1732     cmp al,'('
 1733     jne invalid_operand
 1734     mov al,[value_type]
 1735     push    eax
 1736     cmp byte [esi],'.'
 1737     je  invalid_value
 1738     call    get_dword_value
 1739     call    mark_relocation
 1740     stos    dword [edi]
 1741     pop eax
 1742     mov [value_type],al
 1743     pop eax
 1744     call    mark_relocation
 1745     stos    word [edi]
 1746     ret
 1747 data_qwords:
 1748     call    define_data
 1749     jc  instruction_assembled
 1750     lods    byte [esi]
 1751     cmp al,'('
 1752     je  get_qword
 1753     cmp al,'?'
 1754     jne invalid_argument
 1755     mov eax,edi
 1756     and dword [edi],0
 1757     scas    dword [edi]
 1758     and dword [edi],0
 1759     scas    dword [edi]
 1760     jmp undefined_data
 1761       get_qword:
 1762     call    get_qword_value
 1763     call    mark_relocation
 1764     stos    dword [edi]
 1765     mov eax,edx
 1766     stos    dword [edi]
 1767     ret
 1768 data_twords:
 1769     call    define_data
 1770     jc  instruction_assembled
 1771     lods    byte [esi]
 1772     cmp al,'('
 1773     je  get_tword
 1774     cmp al,'?'
 1775     jne invalid_argument
 1776     mov eax,edi
 1777     and dword [edi],0
 1778     scas    dword [edi]
 1779     and dword [edi],0
 1780     scas    dword [edi]
 1781     and word [edi],0
 1782     scas    word [edi]
 1783     jmp undefined_data
 1784       get_tword:
 1785     cmp byte [esi],'.'
 1786     jne complex_tword
 1787     inc esi
 1788     cmp word [esi+8],8000h
 1789     je  fp_zero_tword
 1790     mov eax,[esi]
 1791     stos    dword [edi]
 1792     mov eax,[esi+4]
 1793     stos    dword [edi]
 1794     mov ax,[esi+8]
 1795     add ax,3FFFh
 1796     jo  value_out_of_range
 1797     cmp ax,7FFFh
 1798     jge value_out_of_range
 1799     cmp ax,0
 1800     jg  tword_exp_ok
 1801     mov cx,ax
 1802     neg cx
 1803     inc cx
 1804     cmp cx,64
 1805     jae value_out_of_range
 1806     cmp cx,32
 1807     ja  large_shift
 1808     mov eax,[esi]
 1809     mov edx,[esi+4]
 1810     mov ebx,edx
 1811     shr edx,cl
 1812     shrd    eax,ebx,cl
 1813     jmp tword_mantissa_shift_done
 1814       large_shift:
 1815     sub cx,32
 1816     xor edx,edx
 1817     mov eax,[esi+4]
 1818     shr eax,cl
 1819       tword_mantissa_shift_done:
 1820     jnc store_shifted_mantissa
 1821     add eax,1
 1822     adc edx,0
 1823       store_shifted_mantissa:
 1824     mov [edi-8],eax
 1825     mov [edi-4],edx
 1826     xor ax,ax
 1827     test    edx,1 shl 31
 1828     jz  tword_exp_ok
 1829     inc ax
 1830       tword_exp_ok:
 1831     mov bl,[esi+11]
 1832     shl bx,15
 1833     or  ax,bx
 1834     stos    word [edi]
 1835     add esi,13
 1836     ret
 1837       fp_zero_tword:
 1838     xor eax,eax
 1839     stos    dword [edi]
 1840     stos    dword [edi]
 1841     mov al,[esi+11]
 1842     shl ax,15
 1843     stos    word [edi]
 1844     add esi,13
 1845     ret
 1846       complex_tword:
 1847     call    get_word_value
 1848     push    eax
 1849     cmp byte [esi],':'
 1850     jne invalid_operand
 1851     inc esi
 1852     lods    byte [esi]
 1853     cmp al,'('
 1854     jne invalid_operand
 1855     mov al,[value_type]
 1856     push    eax
 1857     cmp byte [esi],'.'
 1858     je  invalid_value
 1859     call    get_qword_value
 1860     call    mark_relocation
 1861     stos    dword [edi]
 1862     mov eax,edx
 1863     stos    dword [edi]
 1864     pop eax
 1865     mov [value_type],al
 1866     pop eax
 1867     call    mark_relocation
 1868     stos    word [edi]
 1869     ret
 1870 data_file:
 1871     lods    word [esi]
 1872     cmp ax,'('
 1873     jne invalid_argument
 1874     add esi,4
 1875     call    open_binary_file
 1876     mov eax,[esi-4]
 1877     lea esi,[esi+eax+1]
 1878     mov al,2
 1879     xor edx,edx
 1880     call    lseek
 1881     push    eax
 1882     xor edx,edx
 1883     cmp byte [esi],':'
 1884     jne position_ok
 1885     inc esi
 1886     cmp byte [esi],'('
 1887     jne invalid_argument
 1888     inc esi
 1889     cmp byte [esi],'.'
 1890     je  invalid_value
 1891     push    ebx
 1892     call    get_count_value
 1893     pop ebx
 1894     mov edx,eax
 1895     sub [esp],edx
 1896     jc  value_out_of_range
 1897       position_ok:
 1898     cmp byte [esi],','
 1899     jne size_ok
 1900     inc esi
 1901     cmp byte [esi],'('
 1902     jne invalid_argument
 1903     inc esi
 1904     cmp byte [esi],'.'
 1905     je  invalid_value
 1906     push    ebx edx
 1907     call    get_count_value
 1908     pop edx ebx
 1909     cmp eax,[esp]
 1910     ja  value_out_of_range
 1911     mov [esp],eax
 1912       size_ok:
 1913     xor al,al
 1914     call    lseek
 1915     pop ecx
 1916     mov edx,edi
 1917     add edi,ecx
 1918     jc  out_of_memory
 1919     cmp edi,[tagged_blocks]
 1920     ja  out_of_memory
 1921     call    read
 1922     jc  error_reading_file
 1923     call    close
 1924     lods    byte [esi]
 1925     cmp al,','
 1926     je  data_file
 1927     dec esi
 1928     jmp instruction_assembled
 1929       open_binary_file:
 1930     push    esi
 1931     push    edi
 1932     mov eax,[current_line]
 1933       find_current_source_path: 
 1934     mov esi,[eax] 
 1935     test    byte [eax+7],80h 
 1936     jz  get_current_path 
 1937     mov eax,[eax+8]
 1938     jmp find_current_source_path
 1939       get_current_path:
 1940     lodsb
 1941     stosb
 1942     or  al,al
 1943     jnz get_current_path
 1944       cut_current_path:
 1945     cmp edi,[esp]
 1946     je  current_path_ok
 1947     cmp byte [edi-1],'\'
 1948     je  current_path_ok
 1949     cmp byte [edi-1],'/'
 1950     je  current_path_ok
 1951     dec edi
 1952     jmp cut_current_path
 1953       current_path_ok:
 1954     mov esi,[esp+4]
 1955     call    expand_path
 1956     pop edx
 1957     mov esi,edx
 1958     call    open
 1959     jnc file_opened
 1960     mov edx,[include_paths]
 1961       search_in_include_paths:
 1962     push    edx esi
 1963     mov edi,esi
 1964     mov esi,[esp+4]
 1965     call    get_include_directory
 1966     mov [esp+4],esi
 1967     mov esi,[esp+8]
 1968     call    expand_path
 1969     pop edx
 1970     mov esi,edx
 1971     call    open
 1972     pop edx
 1973     jnc file_opened
 1974     cmp byte [edx],0
 1975     jne search_in_include_paths
 1976     mov edi,esi
 1977     mov esi,[esp]
 1978     push    edi
 1979     call    expand_path
 1980     pop edx
 1981     mov esi,edx
 1982     call    open
 1983     jc  file_not_found
 1984       file_opened:
 1985     mov edi,esi
 1986     pop esi
 1987     ret
 1988 reserve_bytes:
 1989     lods    byte [esi]
 1990     cmp al,'('
 1991     jne invalid_argument
 1992     cmp byte [esi],'.'
 1993     je  invalid_value
 1994     call    get_count_value
 1995     mov ecx,eax
 1996     mov edx,ecx
 1997     add edx,edi
 1998     jc  out_of_memory
 1999     cmp edx,[tagged_blocks]
 2000     ja  out_of_memory
 2001     push    edi
 2002     cmp [next_pass_needed],0
 2003     je  zero_bytes
 2004     add edi,ecx
 2005     jmp reserved_data
 2006       zero_bytes:
 2007     xor eax,eax
 2008     shr ecx,1
 2009     jnc bytes_stosb_ok
 2010     stos    byte [edi]
 2011       bytes_stosb_ok:
 2012     shr ecx,1
 2013     jnc bytes_stosw_ok
 2014     stos    word [edi]
 2015       bytes_stosw_ok:
 2016     rep stos dword [edi]
 2017       reserved_data:
 2018     pop eax
 2019     call    undefined_data
 2020     jmp instruction_assembled
 2021 reserve_words:
 2022     lods    byte [esi]
 2023     cmp al,'('
 2024     jne invalid_argument
 2025     cmp byte [esi],'.'
 2026     je  invalid_value
 2027     call    get_count_value
 2028     mov ecx,eax
 2029     mov edx,ecx
 2030     shl edx,1
 2031     jc  out_of_memory
 2032     add edx,edi
 2033     jc  out_of_memory
 2034     cmp edx,[tagged_blocks]
 2035     ja  out_of_memory
 2036     push    edi
 2037     cmp [next_pass_needed],0
 2038     je  zero_words
 2039     lea edi,[edi+ecx*2]
 2040     jmp reserved_data
 2041       zero_words:
 2042     xor eax,eax
 2043     shr ecx,1
 2044     jnc words_stosw_ok
 2045     stos    word [edi]
 2046       words_stosw_ok:
 2047     rep stos dword [edi]
 2048     jmp reserved_data
 2049 reserve_dwords:
 2050     lods    byte [esi]
 2051     cmp al,'('
 2052     jne invalid_argument
 2053     cmp byte [esi],'.'
 2054     je  invalid_value
 2055     call    get_count_value
 2056     mov ecx,eax
 2057     mov edx,ecx
 2058     shl edx,1
 2059     jc  out_of_memory
 2060     shl edx,1
 2061     jc  out_of_memory
 2062     add edx,edi
 2063     jc  out_of_memory
 2064     cmp edx,[tagged_blocks]
 2065     ja  out_of_memory
 2066     push    edi
 2067     cmp [next_pass_needed],0
 2068     je  zero_dwords
 2069     lea edi,[edi+ecx*4]
 2070     jmp reserved_data
 2071       zero_dwords:
 2072     xor eax,eax
 2073     rep stos dword [edi]
 2074     jmp reserved_data
 2075 reserve_pwords:
 2076     lods    byte [esi]
 2077     cmp al,'('
 2078     jne invalid_argument
 2079     cmp byte [esi],'.'
 2080     je  invalid_value
 2081     call    get_count_value
 2082     mov ecx,eax
 2083     shl ecx,1
 2084     jc  out_of_memory
 2085     add ecx,eax
 2086     mov edx,ecx
 2087     shl edx,1
 2088     jc  out_of_memory
 2089     add edx,edi
 2090     jc  out_of_memory
 2091     cmp edx,[tagged_blocks]
 2092     ja  out_of_memory
 2093     push    edi
 2094     cmp [next_pass_needed],0
 2095     je  zero_words
 2096     lea edi,[edi+ecx*2]
 2097     jmp reserved_data
 2098 reserve_qwords:
 2099     lods    byte [esi]
 2100     cmp al,'('
 2101     jne invalid_argument
 2102     cmp byte [esi],'.'
 2103     je  invalid_value
 2104     call    get_count_value
 2105     mov ecx,eax
 2106     shl ecx,1
 2107     jc  out_of_memory
 2108     mov edx,ecx
 2109     shl edx,1
 2110     jc  out_of_memory
 2111     shl edx,1
 2112     jc  out_of_memory
 2113     add edx,edi
 2114     jc  out_of_memory
 2115     cmp edx,[tagged_blocks]
 2116     ja  out_of_memory
 2117     push    edi
 2118     cmp [next_pass_needed],0
 2119     je  zero_dwords
 2120     lea edi,[edi+ecx*4]
 2121     jmp reserved_data
 2122 reserve_twords:
 2123     lods    byte [esi]
 2124     cmp al,'('
 2125     jne invalid_argument
 2126     cmp byte [esi],'.'
 2127     je  invalid_value
 2128     call    get_count_value
 2129     mov ecx,eax
 2130     shl ecx,2
 2131     jc  out_of_memory
 2132     add ecx,eax
 2133     mov edx,ecx
 2134     shl edx,1
 2135     jc  out_of_memory
 2136     add edx,edi
 2137     jc  out_of_memory
 2138     cmp edx,[tagged_blocks]
 2139     ja  out_of_memory
 2140     push    edi
 2141     cmp [next_pass_needed],0
 2142     je  zero_words
 2143     lea edi,[edi+ecx*2]
 2144     jmp reserved_data
 2145 align_directive:
 2146     lods    byte [esi]
 2147     cmp al,'('
 2148     jne invalid_argument
 2149     cmp byte [esi],'.'
 2150     je  invalid_value
 2151     call    get_count_value
 2152     mov edx,eax
 2153     dec edx
 2154     test    eax,edx
 2155     jnz invalid_align_value
 2156     or  eax,eax
 2157     jz  invalid_align_value
 2158     cmp eax,1
 2159     je  instruction_assembled
 2160     mov ecx,edi
 2161     mov ebp,[addressing_space]
 2162     sub ecx,[ds:ebp]
 2163     cmp dword [ds:ebp+10h],0
 2164     jne section_not_aligned_enough
 2165     cmp byte [ds:ebp+9],0
 2166     je  make_alignment
 2167     cmp [output_format],3
 2168     je  pe_alignment
 2169     cmp [output_format],5
 2170     jne object_alignment
 2171     test    [format_flags],1
 2172     jnz pe_alignment
 2173       object_alignment:
 2174     mov ebx,[ds:ebp+14h]
 2175     cmp byte [ebx],0
 2176     jne section_not_aligned_enough
 2177     cmp eax,[ebx+10h]
 2178     jbe make_alignment
 2179     jmp section_not_aligned_enough
 2180       pe_alignment:
 2181     cmp eax,1000h
 2182     ja  section_not_aligned_enough
 2183       make_alignment:
 2184     dec eax
 2185     and ecx,eax
 2186     jz  instruction_assembled
 2187     neg ecx
 2188     add ecx,eax
 2189     inc ecx
 2190     mov edx,ecx
 2191     add edx,edi
 2192     jc  out_of_memory
 2193     cmp edx,[tagged_blocks]
 2194     ja  out_of_memory
 2195     push    edi
 2196     cmp [next_pass_needed],0
 2197     je  nops
 2198     add edi,ecx
 2199     jmp reserved_data
 2200       invalid_align_value:
 2201     cmp [error_line],0
 2202     jne instruction_assembled
 2203     mov eax,[current_line]
 2204     mov [error_line],eax
 2205     mov [error],invalid_value
 2206     jmp instruction_assembled
 2207       nops:
 2208     mov eax,90909090h
 2209     shr ecx,1
 2210     jnc nops_stosb_ok
 2211     stos    byte [edi]
 2212       nops_stosb_ok:
 2213     shr ecx,1
 2214     jnc nops_stosw_ok
 2215     stos    word [edi]
 2216       nops_stosw_ok:
 2217     rep stos dword [edi]
 2218     jmp reserved_data
 2219 err_directive:
 2220     mov al,[esi]
 2221     cmp al,0Fh
 2222     je  invoked_error
 2223     or  al,al
 2224     jz  invoked_error
 2225     jmp extra_characters_on_line
 2226 assert_directive:
 2227     call    calculate_logical_expression
 2228     or  al,al
 2229     jnz instruction_assembled
 2230     cmp [error_line],0
 2231     jne instruction_assembled
 2232     mov eax,[current_line]
 2233     mov [error_line],eax
 2234     mov [error],assertion_failed
 2235     jmp instruction_assembled