Subversion Repositories Kolibri OS

Rev

Rev 1039 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

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