     1                                  
     2                                  %if 0
     3                                  
     4                                  lDebug initialisation
     5                                  
     6                                  Copyright (C) 1995-2003 Paul Vojta
     7                                  Copyright (C) 2008-2026 E. C. Masloch
     8                                  
     9                                  Usage of the works is permitted provided that this
    10                                  instrument is retained with the works, so that any entity
    11                                  that uses the works is notified of this instrument.
    12                                  
    13                                  DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    14                                  
    15                                  %endif
    16                                  
    17                                  %define SOURCEFILENAME "init.asm"
    18                                  %ifidni __OUTPUT_FORMAT__, obj
    19                                   %include VERSIONMAC
     1                              <1> %define _VERSION " (2026-04-12)"
    20                                   %include "debug.mac"
     1                              <1> [list -]
    14                              <3> [list -]
    14                              <2> [list -]
    86                              <1> [list -]
    86          ------------------  <1>  note: Disable usesection detection
    86          ------------------  <1>  note: usesection lDEBUG_DATA_ENTRY
    86          ------------------  <1>  note: usesection ASMTABLE1
    86          ------------------  <1>  note: usesection ASMTABLE2
    86          ------------------  <1>  note: usesection DATASTACKBASE
    86          ------------------  <1>  note: usesection MESSAGESEGMENT
    86          ------------------  <1>  note: usesection lDEBUG_CODE
    86          ------------------  <1>  note: usesection lDEBUG_CODE2
    86          ------------------  <1>  note: usesection INIT
    86          ------------------  <1>  note: usesection WLEMITALIGNINITEND
    86          ------------------  <1>  note: usesection DEVICESHIM
    86          ------------------  <1>  note: usesection WLEMITALIGNRELOCZERO
    68                              <2> %endif
    69                              <2> 
    70                              <2> 
    71                              <2> 	usesection lDEBUG_CODE
    71          ------------------  <2>  note: usesection lDEBUG_CODE
    72                              <2> section_of puts, trimputs, puts_ext_done, puts_ext_next
    73                              <2> section_of putsz_exthelp, code_retf
    74                              <2> section_of puts_getline_ext_done
    75                              <2> section_of puts_copyoutput_ext_done
    76                              <2> section_of guard_auxbuff, guard_re
    77                              <2> section_of handle_serial_flags_ctrl_c
    78                              <2> section_of hexword_high
    79                              <2> section_of call_int2D
    80                              <2> section_of copy_single_counted_string
    81                              <2> section_of intchk
    82                              <2> section_of IsIISPEntry?
    83                              <2> section_of dd_store
    84                              <2> section_of dohack, getsegmented, hexbyte, hexnyb, iseol?.notsemicolon
    85                              <2> section_of peekc, getc, prephack, readmem, setds2si, setds2bx, setes2dx
    86                              <2> section_of silence_get_start, silence_get_start.have_di, silence_count_zeroes
    87                              <2> section_of setrmlimit, skipcomm0, unhack
    88                              <2> section_of skipequals
    89                              <2> section_of to_errret_pop
    90                              <2> section_of cmd3.have_cx_convenience
    91                              <2> section_of verifysegm, verifysegm_or_error
    92                              <2> section_of pp16, resetmode, resetmode_and_test_d_b_bit
    93                              <2> section_of pp_fix32bitflags, proceedbreakpoint
    94                              <2> section_of putsz, hexword, skipcomma, cmd3, cmd3_not_ext, cmd3_preprocessed
    95                              <2> section_of hexdword
    96                              <2> section_of cmd3_not_inject, cmd3_injected
    97                              <2> section_of aa_not_inject, aa_injected, aa_before_getline, aa_after_getline
    98                              <2> section_of transfer_ext_cx_nearcall_from_code2
    99                              <2> section_of traceone, unexpectedinterrupt, dumpregs_no_disasm
   100                              <2> section_of aa_imm_entry, ia_restore_a_addr, ia_restore_u_addr, disasm
   101                              <2> section_of ia_restore_ds
   102                              <2> %ifn _SYMBOLIC
   103                              <2> section_of selector_to_segment
   104                              <2> %endif
   105                              <2> section_of disp_al, disp_al_hex, disp_al_nybble_hex, disp_ax_dec, disp_ax_hex
   106                              <2> section_of disp_dxax_times_cx_width_bx_size
   107                              <2> section_of disp_dxax_times_cx_width_bx_size.store
   108                              <2> section_of disp_message, disp_message_length_cx
   109                              <2> section_of ispm
   110                              <2> section_of setrc, error
   111                              <2> section_of _doscall, _doscall_return_es, _doscall_return_es_parameter_es_ds
   112                              <2> section_of intcall_ext_return_es, close_ext, doscall_extseg
   113                              <2> section_of yy_reset_buf
   114                              <2> section_of init_bootcmd
   115                              <2> 
   116                              <2> section_of InDOS, bootgetmemorysize
   117                              <2> section_of chkeol, decword, decdword
   118                              <2> section_of dec_dword_minwidth
   119                              <2> section_of getexpression.lit_isdigit?, getexpression.lit_ishexdigit?
   120                              <2> section_of getlinearaddr
   121                              <2> section_of getlinear_d_b
   122                              <2> section_of getlinear_high_limit
   123                              <2> section_of getlinear_32bit
   124                              <2> section_of getlinear_high_limit.do_not_use_test
   125                              <2> section_of getlinear_common
   126                              <2> section_of ifsep, iseol?, isseparator?, isstring?, movp
   127                              <2> section_of putc, putsline, putsline_crlf, putsz_error
   128                              <2> section_of setrmsegm
   129                              <2> section_of skipwh0, skipwhite
   130                              <2> section_of test_d_b_bit, test_high_limit, push_cxdx_or_edx
   131                              <2> section_of capitalise
   132                              <2> section_of setes2ax
   133                              <2> section_of zz_copy_strings_to_str_buffer
   134                              <2> section_of call_xms_move, zz_call_xms, zz_detect_xms
   135                              <2> section_of code2_to_code_ret_to_ext
   136                              <2> section_of yy_dos_parse_name, yy_open_file, yy_check_lfn
   137                              <2> section_of yy_common_parse_name
   138                              <2> section_of yy_common_parse_name_bx_buffer
   139                              <2> section_of retry_open_scriptspath
   140                              <2> section_of yy_boot_read.bx, yy_boot_seek_start.bx, yy_boot_seek_current.bx
   141                              <2> section_of yy_boot_parse_name, yy_boot_open_file
   142                              <2> section_of yy_boot_parse_name_bx_buffer
   143                              <2> section_of near_transfer_ext_return, scan_dir_aux, read_sector
   144                              <2> section_of yy_boot_init_dir, got_yyentry, scan_dir_entry
   145                              <2> section_of ..@yy_filename_empty, boot_parse_fn
   146                              <2> section_of count_store, count_store.maybe_0
   147                              <2> section_of loader_get_resident_address, loader_prepare_resident
   148                              <2> 
   149                              <2> 
   150                              <2>  %if _SYMBOLIC && _DUALCODE && _SYMBOLASMDUALCODE
   151                              <2> 	usesection lDEBUG_CODE2
   152                              <2>  %else
   153                              <2> 	usesection lDEBUG_CODE
   153          ------------------  <2>  note: usesection lDEBUG_CODE
   154                              <2>  %endif
   155                              <2> section_of bxcx_to_cx_paragraphs
   156                              <2> section_of zz_list_symbol.first, zz_list_symbol.subsequent
   157                              <2> section_of zz_xms_to_86mm, zz_xms_try_free, zz_xms_try_free_handle
   158                              <2> section_of zz_86mm_to_xms, zz_del_match.add_poison_entrypoint
   159                              <2> section_of zz_free_nonxms, zz_free_xms, zz_free_reset, zz_free_dos
   160                              <2> section_of zz_get_literal, zz_restore_strat, zz_save_strat
   161                              <2> section_of zz_switch_s, zz_transfer_buffer
   162                              <2> 
   163                              <2> 
   164                              <2> %if _SYMBOLIC
   165                              <2>  %if _DUALCODE && _SYMBOLICDUALCODE
   166                              <2> 	usesection lDEBUG_CODE2
   167                              <2>  %else
   168                              <2> 	usesection lDEBUG_CODE
   169                              <2>  %endif
   170                              <2> section_of shift_left_4_bxcx
   171                              <2> section_of selector_to_segment
   172                              <2> 
   173                              <2> section_of anti_normalise_pointer_with_displacement_bxcx, displaystring
   174                              <2> section_of getfarpointer.hash, getfarpointer.main, getfarpointer.str
   175                              <2> section_of move_delete_farpointer.hash, move_delete_farpointer.hash.sidi
   176                              <2> section_of move_delete_farpointer.main, move_delete_farpointer.str.sidi
   177                              <2> section_of move_insert_farpointer.hash, move_insert_farpointer.hash.sidi
   178                              <2> section_of move_insert_farpointer.main, move_insert_farpointer.main.sidi
   179                              <2> section_of move_insert_farpointer.str.sidi
   180                              <2> section_of normalise_pointer, normalise_pointer_with_displacement_bxcx
   181                              <2> section_of pointer_to_linear
   182                              <2> section_of save_slice_farpointer.hash, save_slice_farpointer.main
   183                              <2> section_of save_slice_farpointer.str
   184                              <2> section_of segment_to_selector
   185                              <2> section_of zz_insert, zz_match_symbol, zz_match_symbol.continue, zz_relocate
   186                              <2> 
   187                              <2> section_of binsearchhash, binsearchmain
   188                              <2> section_of check_second_slice
   189                              <2> section_of disp_size_hash, disp_size_main, disp_size_str
   190                              <2> section_of displayresult, getstring1, getstring2
   191                              <2> section_of increment_ss_ref_count
   192                              <2> section_of list_sym_storage_usage, str_index_to_pointer
   193                              <2> section_of zz_commit_insert, zz_compact, zz_compact_expand_check_nonxms
   194                              <2> section_of zz_compact_expand_check_xms
   195                              <2> section_of zz_delete_hash, zz_delete_main, zz_delete_main_and_its_hash
   196                              <2> section_of zz_delete_string, zz_expand, zz_expand_common
   197                              <2> section_of zz_get_symstr_length_bytes
   198                              <2> section_of zz_get_symstr_length_bytes.ssLength_in_cx
   199                              <2> section_of zz_get_symstr_length_indices
   200                              <2> section_of zz_get_symstr_length_indices.ssLength_in_cx
   201                              <2> section_of zz_hash, zz_hash.bx_init
   202                              <2> section_of zz_insert_main.linklist, zz_reloc_main, zz_reloc_str
   203                              <2> section_of zz_store_pre_str, zz_store_string, zz_store_string.hash_bx
   204                              <2> section_of zz_unlink_main_next
   205                              <2> %endif
   206                              <2> 
   207                              <2> %if _DUALCODE
   208                              <2> 	usesection lDEBUG_CODE2
   209                              <2> %else
   210                              <2> 	usesection lDEBUG_CODE
   210          ------------------  <2>  note: usesection lDEBUG_CODE
   211                              <2> %endif
   212                              <2> section_of FloatToStr
   213                              <2> 
   214                              <2> 
   215                              <2>  %if _DUALCODE && _EXPRDUALCODE
   216                              <2> 	usesection lDEBUG_CODE2
   217                              <2>  %else
   218                              <2> 	usesection lDEBUG_CODE
   218          ------------------  <2>  note: usesection lDEBUG_CODE
   219                              <2>  %endif
   220                              <2> 
   221                              <2> section_of getofsforbx, checkpointer, getrangeX
   222                              <2> section_of getrangeX_have_address_need_length
   223                              <2> section_of getrange, getaddr, getofsforbx_remember_bitness
   224                              <2> section_of remember_bitness, getaddr_taken
   225                              <2> section_of getstr, get_length, get_length_keyword
   226                              <2> section_of isbracketorunaryoperator?, isunaryoperator?, isoperator?
   227                              <2> section_of ..@call_operator_dispatchers
   228                              <2> section_of isseparator?, istype?, isunsignedtype?
   229                              <2> section_of handlesegment, handle3byte, handlebyte, handleword
   230                              <2> section_of handledword, handlepointer
   231                              <2> section_of uoh_abs, uoh_minus, calculate_minus_bxdx, uoh_plus
   232                              <2> section_of uoh_not_bitwise, uoh_not_boolean
   233                              <2> section_of od_minus, od_plus, od_multiply, od_divide, od_modulo, od_retn
   234                              <2> section_of od_above, od_below, od_equal, od_not, od_or, od_and, od_xor
   235                              <2> section_of od_cond, od_o, od_a, od_x, od_c, od_string_common
   236                              <2> section_of of_modulo, of_minus, of_plus, or_hhtype, of_multiply
   237                              <2> section_of set_hhtype, of_divide, of_power
   238                              <2> section_of of_compare_below_equal, of_compare_below, of_compare_not_equal
   239                              <2> section_of of_compare_equal, of_compare_above_equal, of_compare_above
   240                              <2> section_of toboolean, of_helper_compare_true, of_rightop, of_helper_compare
   241                              <2> section_of of_shift_right, of_shift_right_signed, of_shift_left
   242                              <2> section_of of_helper_getshiftdata, of_bit_mirror
   243                              <2> section_of of_or_bitwise, or_hhtype_1, of_or_boolean, of_clr_bitwise
   244                              <2> section_of of_and_bitwise, of_and_boolean, of_xor_bitwise, of_xor_boolean
   245                              <2> section_of of_helper_retbool, of_helper_getbool
   246                              <2> 
   247                              <2> section_of var_cip_setup, var_csp_setup, var_lfsr_setup, var_reverselfsr_setup
   248                              <2> section_of var_dpspsel_setup, var_seldbg_setup, var_mt_setup
   249                              <2> section_of var_ioi_setup, var_psps_setup, var_ppr_setup, var_ppi_setup
   250                              <2> section_of var_iok_setup, var_rhcount_setup
   251                              <2> section_of var_get_psp_segment, var_get_psp_selector
   252                              <2> section_of var_bootldpunit_setup, var_bootsdpunit_setup, var_bootydpunit_setup
   253                              <2> section_of var_bootldppart_setup, var_bootsdppart_setup, var_bootydppart_setup
   254                              <2> section_of var_bootunitflags_setup
   255                              <2> 
   256                              <2> section_of issymbol?, isvariable?, var_mm_setup, var_ri_setup, var_ysf_setup
   257                              <2> section_of default_variable_setup
   258                              <2> section_of var_ext_setup
   259                              <2> section_of var_ext_setup_done
   260                              <2> 
   261                              <2> section_of getstmmxdigit
   262                              <2> section_of getexpression.lit_ishexdigit?, getexpression.lit_isdigit?
   263                              <2> section_of of_cond, count_unary_operators, count_unary_operators_restrict
   264                              <2> section_of get3byte.checksignificantbits, getbyte, checksignificantbitscommon
   265                              <2> section_of getnyb, get_value_range
   266                              <2> 
   267                              <2> section_of getaddrX, getword, getdword, getexpression
   268                              <2> 
   269                              <2> section_of getrangeX.lines, getrangeX.ecx_and_0_valid
   270                              <2> section_of getrange.lines, getrange.ecx_and_0_valid, get_length.lines
   271                              <2> section_of getrangeX.lines_and_uu, getrange.lines_and_uu
   272                              <2> section_of isseparator?.except_L_or_dot, isvariable?.return_name
   273                              <2> section_of getword.checksignificantbits, getbyte.checksignificantbits
   274                              <2> 
   275                              <2> section_of seg_bx_to_sel
   276                              <2> section_of getexpression.countsignificantbits
   277                              <2> section_of ..@rr_checksignificantbits, ..@rr_operatordispatchers
   278                              <2> section_of ..@rr_operatorfunctions, ..@parsecm_getaddr
   279                              <2> section_of stack_check.internal
   280                              <2> 
   281                              <2> 
   282                              <2> 	usesection INIT
   282          ------------------  <2>  note: usesection INIT
   283                              <2> section_of init_capitalise
   284                              <2> section_of init_skipwhite, init_skipwh0
   285                              <2> section_of init_skipcomma, init_skipcomm0
   286                              <2> section_of init_skipequals
   287                              <2> 
   288                              <2> 
   289                              <2> 	usesection lDEBUG_DATA_ENTRY
   289          ------------------  <2>  note: usesection lDEBUG_DATA_ENTRY
   290                              <2> section_of entry_retn
   291                              <2> 
   292                              <2> 
   293                              <2> %if _LINK
   294                              <2>  %include "extern.mac"
     1                              <3> 
     2                              <3> ; expr.asm
     3                              <3>  extern PPLEN, PPLEN_ONLY_PREFIXES, a_addr, alloc_seg, alloc_size
     4                              <3>  extern amis_multiplex_number, asm_options, asm_startoptions
     5                              <3>  extern auxbuff_current_size, auxbuff_segorsel, behind_r_u_addr
     6                              <3>  extern bp_offset, code_seg, code_size, d_addr, dcount_addr
     7                              <3>  extern dcpm_addr, dd_default_length, dd_default_lines, dd_text_and
     8                              <3>  extern debuggerfunction, default_pp_count, default_tp_count
     9                              <3>  extern default_tt_count, device_header_address, device_mcb_paragraphs
    10                              <3>  extern dwcount_addr, dz_addr, e_addr, encodedmach87, entryseg_size
    11                              <3>  extern env_size, envseg, erc, errret
    12                              <3>  extern extdata, extdata_size, extdata_used, extseg, extseg_size
    13                              <3>  extern extseg_used, flagbits.amount, flagnames, flagvaron
    14                              <3>  extern getrange_is_uu, getrange_lines, has_mmx, hhresult
    15                              <3>  extern history.segorsel, historyseg_size, immseg, input_file_handles
    16                              <3>  extern input_file_handles.active, internalflags, internalflags2
    17                              <3>  extern internalflags3, intr8_limit, io_columns, io_columns_getline
    18                              <3>  extern io_end_buffer, io_flags, io_levels, io_rows, io_start_buffer
    19                              <3>  extern line_out, line_out_end, linkinfoaddress, load_data
    20                              <3>  extern load_input_file, load_input_file.active, load_unit_flags
    21                              <3>  extern loaddata_loadedfrom, machine, maxmachinetype, messageseg
    22                              <3>  extern messageseg_size, mmxbuff, msg.as, msg.end, msg.executing
    23                              <3>  extern msg.executing_value_range, msg.from, msg.in, msg.length
    24                              <3>  extern msg.linear, msg.lines, msg.lr, msg.nd, msg.nottaken
    25                              <3>  extern msg.nt, msg.or, msg.questionmark, msg.r, msg.stack_overflow
    26                              <3>  extern msg.stack_overflow.caller, msg.stack_overflow.cond
    27                              <3>  extern msg.stack_overflow.indirection, msg.stack_overflow.linear
    28                              <3>  extern msg.stack_overflow.parens, msg.stack_overflow.precedence
    29                              <3>  extern msg.stack_overflow.value_in, msg.t, msg.taken, msg.to
    30                              <3>  extern msg.value, msgtable_value_range, options, options2, parent
    31                              <3>  extern ppbytes, priorrc, psp22, pspdbe, pspdbg
    32                              <3>  extern qqtermcode, rc_count, rc_limit, re_count, re_limit
    33                              <3>  extern reading_access_variables, reg16names, reg8names, reg_cs
    34                              <3>  extern reg_ds, reg_efl, reg_eip, reg_esp, search_results
    35                              <3>  extern serial_columns, serial_fifo_size, serial_keep_timeout
    36                              <3>  extern serial_rows, serial_use_baseport, serial_use_dl
    37                              <3>  extern serial_use_fifo, serial_use_intnum, serial_use_irqmask
    38                              <3>  extern serial_use_params, serial_var_baseport, serial_var_dl
    39                              <3>  extern serial_var_fifo, serial_var_intnum, serial_var_irqmask
    40                              <3>  extern serial_var_params, sscounter, stack, startoptions
    41                              <3>  extern table_length_keywords, throwsp, transfer_ext_cx
    42                              <3>  extern try_amis_multiplex_number, try_debugger_amis_multiplex_number
    43                              <3>  extern types, types.addresses_minus_end, types.end, u_addr
    44                              <3>  extern usertermcode, uu_default_length, uu_default_lines, vregs
    45                              <3>  extern vregs.amount, writing_access_variables
    46                              <3>  extern flagbits, regs
    47                              <3> 
    48                              <3> ; run.asm
    49                              <3>  extern ..@aa_access_end, ..@aa_access_start, ..@dd_access_end
    50                              <3>  extern ..@dd_access_start, ..@ee_access_end, ..@ee_access_start
    51                              <3>  extern ..@ee_interactive_access_end, ..@ee_interactive_access_start
    52                              <3>  extern ..@hh_indirection_memory_access_end
    53                              <3>  extern ..@hh_indirection_memory_access_start
    54                              <3>  extern ..@readmem_fault_skip_4_near_call, ..@rr_access_end
    55                              <3>  extern ..@rr_access_start, ..@rr_variable_read_access_end
    56                              <3>  extern ..@rr_variable_read_access_start
    57                              <3>  extern ..@rr_variable_write_access_end
    58                              <3>  extern ..@rr_variable_write_access_start, ..@sss_access_end
    59                              <3>  extern ..@sss_access_start, ..@uu_access_end, ..@uu_access_start
    60                              <3>  extern ..@uu_referenced_memory_access_end
    61                              <3>  extern ..@uu_referenced_memory_access_start, ..@uu_simulate_cmps_end
    62                              <3>  extern ..@uu_simulate_cmps_start, ..@uu_simulate_scas_end
    63                              <3>  extern ..@uu_simulate_scas_start, InDOS_or_BIOS_IO, PPLEN_ONLY_STRING
    64                              <3>  extern auxbuff_behind_last_silent
    65                              <3>  extern auxbuff_start_silent, bInDbg, b_bplist.bp, b_bplist.counter
    66                              <3>  extern b_bplist.disabled_mask, b_bplist.idbuffer, b_bplist.used_mask
    67                              <3>  extern b_bplist.when, bb_deferred_message_in_lineout_behind
    68                              <3>  extern bp_display_offset, calcpointbit, cmd2_reset_re, cmd_goto
    69                              <3>  extern debug22.cleartraceflag, decbyte, dmycmd, dumpregs_extended
    70                              <3>  extern enable_rh, entry_to_code_seg, entry_to_code_segsel, eqflag
    71                              <3>  extern eqladdr, exccsip, exception_csip, exception_stack, excloc
    72                              <3>  extern g_bplist.bp, g_bplist.used_count, get_set_id_offset_length
    73                              <3>  extern getc_if_any, getcseipbyte, getint2324, getpsp
    74                              <3>  extern gg_deferred_message, gg_first_cseip_linear
    75                              <3>  extern gg_next_cseip_linear, guard_auxbuff.1_or_2, idle, in_getinput
    76                              <3>  extern int19msg, internalflags6, intr8_counter, lastcmd, msg.again
    77                              <3>  extern msg.alreadytsr, msg.area_aa_access, msg.area_dd_access
    78                              <3>  extern msg.area_ee_access, msg.area_ee_interactive_access
    79                              <3>  extern msg.area_hh_indirection_memory_access, msg.area_rr_access
    80                              <3>  extern msg.area_rr_variable_read_access
    81                              <3>  extern msg.area_rr_variable_write_access, msg.area_run_access
    82                              <3>  extern msg.area_sss_access, msg.area_uu_access
    83                              <3>  extern msg.area_uu_referenced_memory_access
    84                              <3>  extern msg.area_uu_simulate_cmps, msg.area_uu_simulate_scas
    85                              <3>  extern msg.bb_hit.1, msg.bb_hit.2.counter, msg.bb_hitpass_id.after
    86                              <3>  extern msg.bb_hitpass_id.long, msg.bb_hitpass_id.short, msg.bb_pass.1
    87                              <3>  extern msg.cant_bp_linear, msg.cant_bp_linear.address1
    88                              <3>  extern msg.cant_bp_reason, msg.cant_bp_reason0, msg.cant_bp_reason1
    89                              <3>  extern msg.cant_bp_reason2, msg.cant_bp_reason3
    90                              <3>  extern msg.cant_bp_reason3.value, msg.cant_bp_reasonu
    91                              <3>  extern msg.cant_bp_restore, msg.cant_bp_restore.value
    92                              <3>  extern msg.cant_bp_the, msg.cant_bp_type_gg
    93                              <3>  extern msg.cant_bp_type_permanent, msg.cant_bp_type_permanent.index
    94                              <3>  extern msg.cant_bp_type_proceed, msg.cant_bp_write, msg.ctrlc
    95                              <3>  extern msg.empty_message, msg.goto, msg.invalidpsp, msg.list
    96                              <3>  extern msg.list_bp.address1, msg.list_bp.first, msg.list_bp.second
    97                              <3>  extern msg.list_bp.third, msg.list_bp.value, msg.list_bp_csip_16
    98                              <3>  extern msg.list_bp_none, msg.list_bp_not_cseip, msg.notyettsr
    99                              <3>  extern msg.nowattached, msg.nowtsr1, msg.nowtsr2, msg.psphooked
   100                              <3>  extern msg.pspnotfound, msg.remember, msg.selfownedpsp, msg.silent
   101                              <3>  extern msg.warnprefix, msg.while, msg.while_not_true
   102                              <3>  extern msg.while_terminated_after, msg.while_terminated_before
   103                              <3>  extern oldcols, oldcrtp, oldcsrpos, oldmr, options3
   104                              <3>  extern options6, pp_instruction, pp_operand, progexit, progtrm
   105                              <3>  extern rc, reg_eax, reg_es, reg_gs, reg_ss
   106                              <3>  extern run_int, run_sp, run_sp_reserve, savesp, setcseipbyte
   107                              <3>  extern setint2324, setpsp, setpspdbg
   108                              <3>  extern showstring, silence_dump, spadjust, swapscreen
   109                              <3>  extern tmode0, tmode1, tmodes, tmodev, tpg_possible_breakpoint
   110                              <3>  extern tpg_proceed_bp, tt_silent_mode_number, vpage, vrows
   111                              <3>  extern while_buffer, while_buffer.length, writemem
   112                              <3> 
   113                              <3>  extern ..@getcseipbyte_fault_skip_2_near_call
   114                              <3>  extern ..@setcseipbyte_fault_skip_2_near_call
   115                              <3>  extern ..@writemem_fault_skip_4_near_call_a
   116                              <3>  extern ..@writemem_fault_skip_4_near_call_b, int0Cmsg, int0Dmsg
   117                              <3>  extern int0msg, int18msg, int1msg, int3msg, int6msg
   118                              <3>  extern int8_kbd_msg, int8msg, runint_ctrlc_msg, serial_flags
   119                              <3> 
   120                              <3> ; bb.asm
   121                              <3>  extern ..@bb_id_length, ..@bb_id_start, ..@bb_saved_linear
   122                              <3>  extern ..@bb_when_length, ..@bb_when_start, b_bplist.id
   123                              <3>  extern b_bplist.idbuffer.free
   124                              <3>  extern b_bplist.whenbuffer, b_bplist.whenbuffer.free
   125                              <3>  extern bootcmd, crlf, msg.all, msg.at
   126                              <3>  extern msg.bb_no_new, msg.bb_when, msg.boot, msg.bp, msg.bpaddress
   127                              <3>  extern msg.bpcontent, msg.bpcounter, msg.bpdisabled, msg.bpenabled
   128                              <3>  extern msg.bpnone, msg.bpnone_at, msg.bpunused, msg.counter
   129                              <3>  extern msg.existing, msg.id, msg.new, msg.notbu, msg.number
   130                              <3>  extern msg.offset, msg.when, prnquit
   131                              <3> 
   132                              <3> ; rr.asm
   133                              <3>  extern InDOS_or_BIOS_output, cmdline_buffer
   134                              <3>  extern cmdline_buffer.end, cmdline_buffer.position, disflags, ee0a
   135                              <3>  extern error_expr, flagbits_for_40, flagbits_for_80, flagsoff
   136                              <3>  extern flagsoff_style2, flagsoff_style3, flagson, flagson_style23
   137                              <3>  extern get_memref_index_bx, getline00, getline_reset_notatty
   138                              <3>  extern guard_rc, hexnyb.common, hhtype, hhvar, in_re
   139                              <3>  extern mask_4byte, masks, memrefs, memrefs.free, msg.3byte
   140                              <3>  extern msg.abort, msg.append, msg.byte, msg.count, msg.dword
   141                              <3>  extern msg.highlight, msg.internal_error_no_mmx, msg.readonly
   142                              <3>  extern msg.readonly_mem, msg.regs386, msg.regs386_off, msg.regs386_on
   143                              <3>  extern msg.replace, msg.rh, msg.rv_mode.before, msg.rv_mode_r86m
   144                              <3>  extern msg.rv_mode_v86m, msg.rvd, msg.rvd_deviceheader
   145                              <3>  extern msg.rvd_not_device, msg.rvd_size, msg.rvm, msg.rvp
   146                              <3>  extern msg.rvp_application, msg.rvp_boot, msg.rvp_device
   147                              <3>  extern msg.rvp_device_attached, msg.rvp_tsr, msg.rvv
   148                              <3>  extern msg.unexpected_auxbuff_guard, msg.unhighlight, msg.vm_auxseg
   149                              <3>  extern msg.vm_codeseg, msg.vm_dataseg, msg.vm_entryseg, msg.vm_hisseg
   150                              <3>  extern msg.vm_messageseg, msg.vp_dparent, msg.vp_dpra
   151                              <3>  extern msg.vp_dpspsegment, msg.vp_parent, msg.vp_pra
   152                              <3>  extern msg.vp_pspsegment, msg.word, operatorfunctions, psp_parent
   153                              <3>  extern psp_pra, puts_break_line_more, putsline_break_line, re_buffer
   154                              <3>  extern re_buffer.end, re_buffer.position, re_sp, regs_prior
   155                              <3>  extern regs_prior.size, retn_expr, rh_count_number
   156                              <3>  extern rh_display_with_count, shortflagbits, shortflagbits.amount
   157                              <3>  extern shortflagsoff, shortflagson, silence_dump.rh
   158                              <3>  extern silence_dump.rh.all, table_getline_prepare_ldebug
   159                              <3>  extern table_getline_prepare_ms_debug, terminate_silent_dump
   160                              <3>  extern terminate_silent_dump.if_nonnull
   161                              <3> 
   162                              <3> ; rr.asm
   163                              <3>  extern flagbits_for_shl, regs_prior.size_w
   164                              <3> 
   165                              <3> ; aa.asm
   166                              <3>  extern REP_LEN, SEGP_LEN, attach
   167                              <3>  extern ext_aa_after_getline_handler, ext_aa_before_getline_handler
   168                              <3>  extern ext_aa_inject_handler, immasm_length, immasm_rel1632_target
   169                              <3>  extern immasm_rel8_target, msg.aa_internal_error, msg.attach
   170                              <3>  extern prefixlist.after_segment, replist, segprfxtab, showmach
   171                              <3>  extern skipalpha, sm1
   172                              <3> 
   173                              <3> ; uu.asm
   174                              <3>  extern A32P_LEN, GROUP7, MN_DB, MN_LOCK, MN_LOOP
   175                              <3>  extern MN_LOOPNZ, MN_LOOPZ, MN_REP, MN_REPE, MN_REPNE
   176                              <3>  extern MN_SEG, MN_WAIT, N_LOCK, N_LTABA, N_LTABO
   177                              <3>  extern N_WTAB, O32P_AMOUNT, OPTYPES_BASE, REP_DIFF_LEN, REP_SAME_LEN
   178                              <3>  extern SFPGROUP3, SGROUP4, SPARSE_BASE, a32prfxtab, dismach
   179                              <3>  extern dmflags, has_87, immasm_far_target, immasm_imm16, locktab
   180                              <3>  extern ltaba1, ltabo1, mach_87, mnlist, mnlist_a_suffix_allowed
   181                              <3>  extern mnlist_o_suffix_allowed, mnlist_o_suffix_required
   182                              <3>  extern msg.condjump, msg.condnotjump, msg.memrefs_invalid_internal
   183                              <3>  extern msg.uninstall, msg.uu_internal_error, msg.uu_too_many_repeat
   184                              <3>  extern needsmath, needsmath_L, needsmsg, needsmsg.digit_6_ofs
   185                              <3>  extern needsmsg.digit_x_ofs, needsmsg_L, o32prfxtab, obsmach
   186                              <3>  extern obsolete, obsolete_L, opindex, opinfo, oplists
   187                              <3>  extern optypes, ppbytes.string, ppbytes.string_amount, reg_ebp
   188                              <3>  extern reg_ebx, reg_ecx, reg_edi, reg_esi, reg_fs
   189                              <3>  extern regmem, rgnam16, rgnam816, segrgnam, sibbyte
   190                              <3>  extern sqztab, tab_to, uninstall, unused, wtab1
   191                              <3> 
   192                              <3> ; uu.asm
   193                              <3>  extern reg_edx
   194                              <3> 
   195                              <3> ; uu.asm
   196                              <3>  extern MN_BSWAP, MN_O32
   197                              <3> 
   198                              <3> ; uu.asm
   199                              <3>  extern MN_A32
   200                              <3> 
   201                              <3> ; amis.asm
   202                              <3>  extern amisintr_offset, deviceshim_size, ext_amis_handler
   203                              <3> 
   204                              <3> ; boot.asm
   205                              <3>  extern boot_remember_seek_handle
   206                              <3>  extern boot_remember_seek_offset, chkeol_or_then, cmd_goto.yy_entry
   207                              <3>  extern display_y_or_ext, ext_cmdline, ext_finish.boot
   208                              <3>  extern if_exists_found_open, if_exists_not_found
   209                              <3>  extern if_exists_then_address, iseol?_or_then, loadoptiontable
   210                              <3>  extern loadoptiontable.incompatible, loadsettings
   211                              <3>  extern msdos7_message_table, msdos7_message_table.size
   212                              <3>  extern msg.boot_access_error, msg.boot_and, msg.boot_auxbuff_crossing
   213                              <3>  extern msg.boot_badchain, msg.boot_badclusters, msg.boot_badfat
   214                              <3>  extern msg.boot_bpb_load_overlap, msg.boot_bpb_too_low
   215                              <3>  extern msg.boot_cannot_set_both, msg.boot_dot_crlf
   216                              <3>  extern msg.boot_file_not_found, msg.boot_file_too_big_error
   217                              <3>  extern msg.boot_file_too_small_error, msg.boot_internal_error
   218                              <3>  extern msg.boot_invalid_filename, msg.boot_invalid_heads
   219                              <3>  extern msg.boot_invalid_sectors, msg.boot_out_of_memory_error
   220                              <3>  extern msg.boot_partition_cycle_error, msg.boot_partition_not_found
   221                              <3>  extern msg.boot_quit_fail, msg.boot_sector_not_power
   222                              <3>  extern msg.boot_sector_too_large, msg.boot_sector_too_small
   223                              <3>  extern msg.boot_segment_too_low, msg.boot_too_many_partitions_error
   224                              <3>  extern msg.bootfail, msg.bootfail_check_mismatch
   225                              <3>  extern msg.bootfail_check_mismatch.check_got
   226                              <3>  extern msg.bootfail_check_mismatch.check_offset
   227                              <3>  extern msg.bootfail_check_mismatch.check_value, msg.bootfail_code
   228                              <3>  extern msg.bootfail_read, msg.bootfail_read_errorcode
   229                              <3>  extern msg.bootfail_secsizediffer, msg.bootfail_sig
   230                              <3>  extern msg.bootfail_sig_parttable, msg.bootfail_stack_underflow
   231                              <3>  extern msg.bpb, msg.checkoffset, msg.checkvalue, msg.dir
   232                              <3>  extern msg.dirinsteadsize, msg.emptydirname, msg.entry
   233                              <3>  extern msg.guard_auxbuff_error, msg.hidden, msg.hiddenadd
   234                              <3>  extern msg.maxpara, msg.minpara, msg.protocol, msg.quit, msg.read
   235                              <3>  extern msg.sector, msg.sector_alt, msg.segment, msg.write
   236                              <3>  extern msg.yy_empty, msg.yy_filename_empty, msg.yy_no_file
   237                              <3>  extern msg.yy_requires_filename, msg.yy_too_large
   238                              <3>  extern msg.yy_too_many_handles, terminator_in_line_in.offset
   239                              <3>  extern terminator_in_line_in.value, throwret
   240                              <3>  extern yy_boot_attempt_open_pathname, yy_boot_attempt_open_stack
   241                              <3>  extern yy_is_script
   242                              <3> 
   243                              <3> ; cc.asm
   244                              <3>  extern count_var, hh.single, msg.clear, msg.clear_sequence
   245                              <3>  extern msg.range, parsecm
   246                              <3> 
   247                              <3> ; dd.asm
   248                              <3>  extern auxbuff_current_size_minus_24, charcounter
   249                              <3>  extern dstringaddr, dstringtype, firstmcb, firstumcb, intaddress
   250                              <3>  extern lastint, lastint_is_86m_and_mcb, msg.di_empty, msg.di_error
   251                              <3>  extern msg.di_freedos_reloc, msg.di_hidden, msg.di_hma, msg.di_iisp
   252                              <3>  extern msg.di_jmpfar, msg.di_jmpfarindirect, msg.di_multiplex.1
   253                              <3>  extern msg.di_multiplex.2, msg.di_multiplex.3, msg.di_nonstd_iisp
   254                              <3>  extern msg.di_system_low, msg.di_system_mcb, msg.di_system_upper
   255                              <3>  extern msg.di_testhook, msg.di_toomany, msg.di_uninst_iisp
   256                              <3>  extern msg.header, msg.header.length, msg.invmcbadr, msg.prefixes
   257                              <3>  extern msg.tableheader, msg.tableheadertop, msg.top, msg.trailer
   258                              <3>  extern msg.trailer.length, smcbmsg_unknown, smcbtypes
   259                              <3> 
   260                              <3> ; debug.asm
   261                              <3>  extern UnhookInterruptForce, UnhookInterruptForceSim, aa
   262                              <3>  extern adusetup, bb, boot_ebdaflag, boot_initcode
   263                              <3>  extern boot_new_memsizekib, boot_old_memsizekib, cc, code_start, ddd
   264                              <3>  extern device_initcode, driveno, dumpregs_extended.exit, ee
   265                              <3>  extern eld_linkcall.call_cmd3, end_of_ldebug_code, entry_int3_retf
   266                              <3>  extern errcarat, ff, get_86m_interrupt_handler_no_dos, get_columns
   267                              <3>  extern getline_close_file, getline_close_file.resetstuff, gg, hh
   268                              <3>  extern hh_depth, hh_depth_of_single_term, hhflag, ia_restore, ii
   269                              <3>  extern immasm, install_86m_interrupt_handler, int22, int2D, intr0
   270                              <3>  extern intr0C, intr0D, intr1, intr18, intr19
   271                              <3>  extern intr3, intr6, intr8, linkinfo, ll
   272                              <3>  extern ll3, ll_copy_cmdline_and_fcbs
   273                              <3>  extern ll_copy_cmdline_and_fcbs.have_cx
   274                              <3>  extern mm, msg.NULblank, msg.asmoptions_1, msg.boothelp
   275                              <3>  extern msg.build_array, msg.build_long_amount, msg.build_short_amount
   276                              <3>  extern msg.build_version_amount, msg.cannot_hook_2D.invalid
   277                              <3>  extern msg.cannot_hook_2D.nofree, msg.cannotbootquit_memsizes
   278                              <3>  extern msg.condhelp, msg.ensure_no_memory, msg.expressionhelp
   279                              <3>  extern msg.flaghelp, msg.flags_1, msg.guard_rc_error
   280                              <3>  extern msg.guard_re_error, msg.help_array, msg.help_array_amount
   281                              <3>  extern msg.help_re, msg.help_run, msg.help_source, msg.keep
   282                              <3>  extern msg.license, msg.line_out_overflow, msg.n_toolongname
   283                              <3>  extern msg.n_toolongtail, msg.nobootsupp, msg.options_array
   284                              <3>  extern msg.options_array_amount, msg.options_pages, msg.options_scan
   285                              <3>  extern msg.options_scan_amount, msg.qq_a_terminated
   286                              <3>  extern msg.qq_a_unterminated, msg.qq_device_no_c, msg.qq_device_no_d
   287                              <3>  extern msg.qq_device_none_selected, msg.qq_unterm
   288                              <3>  extern msg.rc_limit_reached, msg.re, msg.re_limit_reached
   289                              <3>  extern msg.reghelp, msg.rh_disabled, msg.rh_enabled, msg.run
   290                              <3>  extern msg.serial_cannot_hook, msg.serial_cannot_hook.new_int
   291                              <3>  extern msg.serial_cannot_hook.old_int, msg.serial_cannot_unhook
   292                              <3>  extern msg.serial_cannot_unhook.int, msg.serial_cannot_unhook.nowarn
   293                              <3>  extern msg.serial_late_unhook, msg.serial_late_unhook.int
   294                              <3>  extern msg.serial_no_keep_enter, msg.serial_no_keep_timer
   295                              <3>  extern msg.serial_request_keep, msg.source, msg.string_build
   296                              <3>  extern msg.string_options, msg.string_version
   297                              <3>  extern msg.tsr_cannot_terminate_attached, msg.varhelp, oo, ph_msg, pp
   298                              <3>  extern putrunint, putsz_exthelp, rr, run, section.DEVICESHIM.vstart
   299                              <3>  extern serial_clean_up, serial_clear_fifos, serial_eoi
   300                              <3>  extern serial_init_UART, serial_install_interrupt_handler
   301                              <3>  extern serial_interrupt_handler, serial_uninstall_interrupt_handler
   302                              <3>  extern set_irq, setscreen, sleep_delta_limit, sleep_highest_delta
   303                              <3>  extern sss, tpg_initialise_empty_auxbuff.reset
   304                              <3>  extern transfer_to_ext_puts_getline, tt, update_inttab_optional, uu
   305                              <3>  extern vv, vv_disable, vv_set, ww, yy
   306                              <3> 
   307                              <3> ; debug.asm
   308                              <3>  extern eld_linkcall
   309                              <3> 
   310                              <3> ; ee.asm
   311                              <3>  extern bufend, bufnext, fillbuf, fullbsout
   312                              <3>  extern getline_is_input_file?, line_in, linecounter, load_extension
   313                              <3>  extern msg.ext, notatty, prehak1, run2324
   314                              <3> 
   315                              <3> ; hh.asm
   316                              <3>  extern hh_div_active, hh_div_dividend, hh_div_divisor
   317                              <3>  extern msg.base, msg.group, msg.hh_div_remainder, msg.width
   318                              <3> 
   319                              <3> ; iioo.asm
   320                              <3>  extern if_exists_length, if_exists_si, if_exists_sp
   321                              <3>  extern install, msg.exists, msg.install, msg.not, msg.then
   322                              <3>  extern msg.y, resetrc, yy_or_ext_no_guard_re
   323                              <3> 
   324                              <3> ; immasm.asm
   325                              <3>  extern aa_ret, addrr, condmsg, error_mirror, index
   326                              <3>  extern msg.immasm_error_eip, presizeflags, reg32addr, segmnt
   327                              <3>  extern segrgaddr
   328                              <3> 
   329                              <3> ; msg.asm
   330                              <3>  extern ..@boot_scan_dir_return_fat16_root_entry
   331                              <3>  extern ..@boot_scan_dir_return_filenotfound
   332                              <3>  extern ..@boot_scan_dir_return_subdir_or_fat32_entry
   333                              <3>  extern alloc_size_not_reserved, asciitablenames, boot_init_foundname
   334                              <3>  extern configpath, configpath.dir_end, device_quittable_regs, dpmi32
   335                              <3>  extern execblk.cmdline, ext_command_handler, ext_finish.bp_is_set
   336                              <3>  extern ext_handle, ext_inject_handler, ext_preprocess_handler
   337                              <3>  extern ext_puts_copyoutput_handler, ext_puts_getline_handler
   338                              <3>  extern ext_puts_handler, ext_var, ext_var_amount, ext_var_format
   339                              <3>  extern ext_var_size, extcssel, extdssel, handle_scan_dir_entry
   340                              <3>  extern handle_scan_dir_not_found, history.first, history.last
   341                              <3>  extern indirect_array_errfix, init_executable_pathname
   342                              <3>  extern init_executable_pathname.end, internalflags4, internalflags5
   343                              <3>  extern internalflags7, isvariable_morebyte_nameheaders.ext
   344                              <3>  extern lastcmd_transfer_ext_address, lastcmd_transfer_ext_entry
   345                              <3>  extern line_in.end, linkcall_table, load_adr_dirbuf_segment
   346                              <3>  extern load_check_dir_attr, load_data_lowest, load_kernel_name
   347                              <3>  extern load_yy_direntry, load_yyname_input, load_yyname_next
   348                              <3>  extern near_transfer_ext_address, near_transfer_ext_entry
   349                              <3>  extern next_reserved_segment, options4, options5, options7
   350                              <3>  extern patcharea_intrtn, patcharea_intrtn.segment
   351                              <3>  extern patcharea_intrtn.size, patcharea_run, patcharea_run.segment
   352                              <3>  extern patcharea_run.size, pm_2_86m_0, promptlen, reserved_address
   353                              <3>  extern scriptspath, scriptspath.dir_end
   354                              <3>  extern sss_silent_count, sss_silent_count_used, stack_end, swch1
   355                              <3>  extern while_buffer.end
   356                              <3> 
   357                              <3> ; msg.asm
   358                              <3>  extern install_trying
   359                              <3> 
   360                              <3> ; init.asm
   361                              <3>  extern ..@init_behind, ..@init_first
   362                              <3>  extern ..@patch_no386_ds_6_DATA_ENTRY
   363                              <3>  extern ..@patch_no386_ds_code_or_entry
   364                              <3>  extern ..@patch_no386_iret_code_or_entry, behind_code_truncated
   365                              <3>  extern behind_init, behind_messagesegment_nobits
   366                              <3>  extern behind_messagesegment_nobits_truncated, debug22
   367                              <3>  extern device_header.next, devint23, devint24, entry_retf
   368                              <3>  extern execblk.fcb1, execblk.fcb2, ext_data_area, extcall_table.ret
   369                              <3>  extern extcall_table.segsel, fileext, hVdd, immasm_buffer, initcont
   370                              <3>  extern initcont.boot_entry, initcont.device, inttab, inttab.i06
   371                              <3>  extern inttab.i2D, inttab_number_variable, line_out_overflow
   372                              <3>  extern linkcall_table.code1, linkcall_table.entry
   373                              <3>  extern linkcall_table.init, oldmode, pInDOS, pSDA, regs.size
   374                              <3>  extern switchar, trim_overflow, var_addr_entries
   375                              <3>  extern var_addr_entries.amount
   376                              <3> 
   377                              <3> ; install.asm
   378                              <3>  extern installflags, msg.alreadydisabled
   379                              <3>  extern msg.alreadyenabled, msg.toggle, msg.trydisable, msg.tryenable
   380                              <3> 
   381                              <3> ; ints.asm
   382                              <3>  extern debuggeramissig, inttab_optional
   383                              <3> 
   384                              <3> ; lineio.asm
   385                              <3>  extern auxbuff_amount_silent, cmd3_set_options
   386                              <3>  extern determine_quiet_output, eldheader, getc_repeat_idle
   387                              <3>  extern getline_timer_func, handle_ctrl_c, if_exists_found_closed
   388                              <3>  extern if_exists_found_ext_open, indos_remember_seek_function
   389                              <3>  extern indos_remember_seek_handle, indos_remember_seek_offset
   390                              <3>  extern input_file_handles.to_close, msg.configkeyword
   391                              <3>  extern msg.eld_error_code, msg.eld_load_error, msg.emptykeyword
   392                              <3>  extern msg.eof, msg.executablekeyword, msg.ext_error_internal
   393                              <3>  extern msg.ext_error_invalid, msg.ext_error_io, msg.ext_error_oom
   394                              <3>  extern msg.freedos_ctrlc_workaround, msg.goto_empty
   395                              <3>  extern msg.goto_not_file, msg.goto_not_found.1, msg.goto_not_found.2
   396                              <3>  extern msg.history_internal_error, msg.more, msg.more_over
   397                              <3>  extern msg.more_over_size, msg.more_size, msg.rh_step.1
   398                              <3>  extern msg.rh_step.2, msg.scriptskeyword, msg.silent_error, msg.sof
   399                              <3>  extern msg.unexpected_noneol_rc, msg.unexpected_noneol_re
   400                              <3>  extern msg.yy_error_file_open, msg.yy_filename_missing_unquote
   401                              <3>  extern msg.yy_no_dos, qq, section.DATASTACK.vstart
   402                              <3>  extern serial_check_receive_char, serial_receive_char
   403                              <3>  extern serial_send_char, skip_rh, yy_boot
   404                              <3>  extern yy_boot_clear_remember_seek, yy_boot_close_file, yy_boot_read
   405                              <3>  extern yy_boot_remember_seek, yy_boot_seek_current
   406                              <3>  extern yy_boot_seek_start, yy_try_scriptspath
   407                              <3>  extern yy_try_scriptspath.didnotyettry
   408                              <3>  extern yy_try_scriptspath.nokeywordused
   409                              <3> 
   410                              <3> ; ll.asm
   411                              <3>  extern doserr8, ensuredebuggeeloaded, execblk, execblk.csip
   412                              <3>  extern execblk.sssp, msg.hexerror, msg.ll_unterm, msg.not_while_indos
   413                              <3>  extern msg.tsr_cannot_ll, parselw, reading
   414                              <3>  extern terminate_attached_process, ww1, ww15, zeroregs
   415                              <3> 
   416                              <3> ; mm.asm
   417                              <3>  extern has_287, has_copr, msg.c0, msg.cr, msg8088
   418                              <3>  extern msgx86, no_copr, parsecm_have_address
   419                              <3> 
   420                              <3> ; serialp.asm
   421                              <3>  extern baseport, msg.no_progress, rxfifo, rxhead
   422                              <3>  extern rxtail, serial_fcr_setting, serial_installed_intnum
   423                              <3>  extern serial_save_dl, serial_save_ier, serial_save_irq_mask
   424                              <3>  extern serial_save_irq_off, serial_save_lcr, serial_save_mcr, txfifo
   425                              <3>  extern txhead, txtail
   426                              <3> 
   427                              <3> ; ss.asm
   428                              <3>  extern msg.matches, msg.reverse, msg.seconds, msg.sleep
   429                              <3>  extern msg.ticks, sleep_repeat_idle
   430                              <3> 
   431                              <3> ; vv.asm
   432                              <3>  extern csrpos, msg.nokeep, msg.off, msg.on, msg.vv_disabled
   433                              <3>  extern msg.vv_enable_failure, xmsdrv, xmsmove
   434                              <3> 
   435                              <3> ; ww.asm
   436                              <3>  extern diskful, doserr11, doserr2, doserr3, doserr5
   437                              <3>  extern drive, drivenumber, dskerrs, not_while_indos, nowhexe
   438                              <3>  extern nownull, openerr, openerr1, writing, wwmsg1
   439                              <3>  extern wwmsg2
   440                              <3> 
   441                              <3> 
   442                              <3>  extern bCSAttr, lDEBUG_CODE_to_lDEBUG_CODE2_nearcall_helper
   443                              <3> 
   444                              <3>  extern hook2F.not_in_dos
   445                              <3> 
   446                              <3>  extern cmd4.int3, lDEBUG_CODE2_dualret_helper
   447                              <3>  extern lDEBUG_CODE2_to_lDEBUG_CODE_nearcall_helper
   448                              <3>  extern lDEBUG_CODE_to_lDEBUG_CODE2_dualcall_helper, msg.bu
   449                              <3>  extern msg.bu_relocated, msg.bu_relocated.sign
   450                              <3> 
   451                              <3>  extern nopmsupp
   452                              <3> 
   453                              <3>  extern bAddr32
   454                              <3> 
   455                              <3>  extern descriptor, descriptor.attrib, descriptor.base
   456                              <3>  extern descriptor.limit, gatewrong, msg.d.a_error, msg.d.a_error_code
   457                              <3>  extern msg.d.a_success, msg.d.a_success_sel, msg.d.b_error
   458                              <3>  extern msg.d.b_error_code, msg.d.b_success, msg.d.d_error
   459                              <3>  extern msg.d.d_error_code, msg.d.d_success, msg.d.l_error
   460                              <3>  extern msg.d.l_error_code, msg.d.l_success, msg.d.t_error
   461                              <3>  extern msg.d.t_error_code, msg.d.t_success, msg.deschelp, msg.ofs32
   462                              <3>  extern nodesc
   463                              <3> 
   464                              <3>  extern ..@patch_tsr_quit_run, areastruc_entry.qq_entry, cssel
   465                              <3>  extern ddebugareas.next, debug2F, dpmidisable, dpmientry, dpmihook
   466                              <3>  extern dpmihookamis, dpmihookcs, dpmiwatch, end_of_ldebug_code2
   467                              <3>  extern findinstalleddebugger, get_messagesegsel, handle_mode_changed
   468                              <3>  extern i23pm, msg.cannotpmquit, msg.desc, msg.dpmi_no_hook, msg.msdos
   469                              <3>  extern msg.qq_device_pm, msg.qq_still_pm, msg.qqlate_areas_error
   470                              <3>  extern msg.readonly_verifysegm, msg.readonly_verifysegm.selector
   471                              <3>  extern mydpmientry, nodosext, oldi2F, pm_reset_handlers, scratchsel
   472                              <3>  extern sr_state, switchmode, uninstall_areas.qq_entry
   473                              <3> 
   474                              <3>  extern i24pm
   475                              <3> 
   476                              <3>  extern auxbuff_switchbuffer_size, code2_seg, code2_sel, code2_size
   477                              <3>  extern code_sel, daresult, dssel, immsel
   478                              <3>  extern lDEBUG_CODE2_to_lDEBUG_CODE_dualcall_helper
   479                              <3>  extern lDEBUG_CODE_dualret_helper, messagesel, msg.desctype
   480                              <3>  extern msg.stack_overflow.desctype
   481                              <3> 
   482                              <3>  extern cmd3_mirror
   483                              <3> 
   484                              <3>  extern ..@patch_entry_seg, ..@patch_no386_ds_4, ..@patch_no386_ds_5
   485                              <3>  extern ..@patch_no386_ds_entry_pmint21_1
   486                              <3>  extern ..@patch_no386_ds_entry_pmint21_2, areas_fun, areas_sub
   487                              <3>  extern ddebugareas.prev, linkcall_table.code2
   488                              <3> 
   489                              <3>  extern areas_struc, msg.areasalreadyinstalled
   490                              <3>  extern msg.areasalreadyuninstalled, msg.areasinstalled
   491                              <3>  extern msg.areasnodebuggerfound, msg.areasnotinstalled
   492                              <3>  extern msg.areasnotinstalled.code, msg.areasnotsupported
   493                              <3>  extern msg.areasuninstalled, msg.areasuninstalled.code
   494                              <3> 
   495                              <3>  extern intcall_return_parameter_es_parameter_ds
   496                              <3>  extern lDEBUG_CODE_to_lDEBUG_CODE_dualcall_helper, pop_if, push_if
   497                              <3> 
   498                              <3>  extern isextenderavailable, msg.cannotpmload, nodosextinst
   499                              <3> 
   500                              <3>  extern install_areas, patcharea_pm_exc, patcharea_pm_exc.segment
   501                              <3>  extern patcharea_pm_exc.size
   502                              <3> 
   503                              <3>  extern pmint21
   504                              <3> 
   505                              <3>  extern debuggerexception, entry_to_code_sel, exc6msg, excCmsg
   506                              <3>  extern excDmsg, excEmsg, intrtn2_entry, pmintsave.int21
   507                              <3> 
   508                              <3>  extern convsegs, convsegs.amount_fixed, convsegs.end_fixed
   509                              <3>  extern dpmi_pm2rm, dpmi_pmsav, dpmi_rm2pm, dpmi_rmsav, endexctab
   510                              <3>  extern exc_first, exc_second, excsave, exctab, installdpmimsg
   511                              <3>  extern intrtn_entry.from_installdpmi, pmintsave, pminttab
   512                              <3>  extern pminttab.end, setrmaddr, silence_delete_one_string.internal
   513                              <3> 
   514                              <3>  extern msg.rv_mode_dpmi_16, msg.rv_mode_dpmi_32, msg.vm_code2seg
   515                              <3>  extern msg.vm_selector, msg.vp_dpspsel, msg.vp_pspsel, psp_selector
   516                              <3> 
   517                              <3>  extern ..@getcseipbyte_fault_skip_6_near_call
   518                              <3>  extern ..@hh_code1_indirection_memory_access_end
   519                              <3>  extern ..@hh_code1_indirection_memory_access_start
   520                              <3>  extern ..@readmem_fault_skip_2_near_call
   521                              <3>  extern ..@setcseipbyte_fault_skip_6_near_call
   522                              <3>  extern ..@writemem_fault_skip_2_near_call_a
   523                              <3>  extern ..@writemem_fault_skip_2_near_call_b, behind_code
   524                              <3>  extern behind_code2, convsegs.amount, ddebugareas
   525                              <3>  extern getline_extra_int22.cleartraceflag, msg.list_bp_cseip_32
   526                              <3> 
   527                              <3>  extern MN_O16
   528                              <3> 
   529                              <3>  extern MN_A16
   530                              <3> 
   531                              <3>  extern relocatedzero
   532                              <3> 
   533                              <3>  extern msg.bu_disabled
   534                              <3> 
   535                              <3>  extern reset_interrupts, set_interrupts
   536                              <3> 
   537                              <3>  extern startoptions6
   538                              <3> 
   539                              <3>  extern currentposition, msg.loader_bottom_not_allowed
   540                              <3>  extern msg.loader_too_low_load
   541                              <3> 
   542                              <3>  extern intr_loader_18, intr_loader_19, moveloader_hook_ints
   543                              <3> 
   544                              <3>  extern loader_query, loader_transfer_cmd3, loader_transfer_relocate
   545                              <3> 
   546                              <3>  extern cmd3_int_disable.set_bx_to_dx, cmd3_int_enable.set_bx_to_dx
   547                              <3>  extern ldebug_code_size, movesegrefstable, movetable
   548                              <3>  extern movetable.bottom, msg.isalready, msg.isnow, msg.loader_error
   549                              <3>  extern msg.move, msg.move_auxbuff_error, msg.move_auxdown
   550                              <3>  extern msg.move_auxup, msg.move_ebdanottop, msg.move_empty
   551                              <3>  extern msg.move_int_error, msg.move_int_panic
   552                              <3>  extern msg.move_must_be_bottom, msg.move_nottop, msg.move_oom
   553                              <3>  extern msg.move_rpl, msg.move_toolargeebda, msg.unsupportedmove
   554                              <3>  extern qq_int_unhook_sim.set_bx_to_dx
   555                              <3> 
   556                              <3>  extern moveloader.already, moveloader.bottom_to_hidden
   557                              <3>  extern moveloader.bottom_to_top, moveloader.hidden_to_bottom
   558                              <3>  extern moveloader.hidden_to_top, moveloader.top_to_bottom
   559                              <3>  extern moveloader.top_to_hidden
   560                              <3> 
   561                              <3>  extern moveloader.specificerror, moveloader_check_serial, msg.godebug
   562                              <3>  extern msg.loader_extra, msg.loader_flag, msg.loader_loadseg_low
   563                              <3>  extern msg.loader_must_be_hidden, msg.loader_sign, msg.loader_stack
   564                              <3>  extern msg.loadsupportsignature, msg.loadsupportsignature.size
   565                              <3> 
   566                              <3>  extern depack, hshrink_memory_source.offset
   567                              <3>  extern hshrink_memory_source.segment, indirect_hshrink_message_buffer
   568                              <3>  extern msg.hshrink_error, nontruncated_hshrink_message_buffer
   569                              <3> 
   570                              <3>  extern truncated_hshrink_message_buffer
   571                              <3> 
   572                              <3>  extern patch_boothelp_uncompressed
   295                              <2> %endif
   710                              <1> %endif
   711                              <1> [list -]
   714                              <1> 
   715                              <1> %include "eld.mac"
     1                              <2> %if 0
     2                              <2> 
     3                              <2> Extensions for lDebug macros
     4                              <2> 
     5                              <2> Copyright (C) 2008-2025 E. C. Masloch
     6                              <2> 
     7                              <2> Usage of the works is permitted provided that this
     8                              <2> instrument is retained with the works, so that any entity
     9                              <2> that uses the works is notified of this instrument.
    10                              <2> 
    11                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    12                              <2> 
    13                              <2> %endif
    14                              <2> 
    15                              <2> %ifndef ELD_MAC
    16                              <2> %define ELD_MAC 1
    17                              <2> 
    18                              <2> %include "lmacros3.mac"
     1                              <3> [list -]
    19                              <2> 
    20                              <2> 		; ELD executable header
    21                              <2> 	struc ELD_HEADER
    22 00000000 ????????            <2> eldhSignature:		resb 4	; "ELD1"
    23 00000004 ??????              <2> 			resb 3	; reserved
    24 00000007 ??                  <2> 			resb 1	; 26 (Ctrl-Z)
    25 00000008 ????????            <2> eldhCodeOffset:		resd 1	; position displacement from eldhSignature
    26 0000000C ????                <2> eldhCodeImageLength:	resw 1	; amount bytes, at least 32
    27 0000000E ????                <2> eldhCodeAllocLength:	resw 1	; amount bytes, added to prior. sum < 64 KiB
    28 00000010 ????????            <2> eldhDataOffset:		resd 1
    29 00000014 ????                <2> eldhDataImageLength:	resw 1	; (zero allowed)
    30 00000016 ????                <2> eldhDataAllocLength:	resw 1	; (zero allowed)
    31 00000018 ????                <2> eldhCodeEntrypoint:	resw 1	; within code section, used as displacement
    32 0000001A ????????            <2> eldhReserved:		resb 4	; reserved
    33 0000001E ????                <2> eldhExtensionSize:	resw 1	; from eldhSignature, -> past eldhx fields in use
    34                              <2> 	endstruc
    35                              <2> 	endarea ELD_HEADER, 1
    36                              <2> 
    37                              <2> 	struc ELD_HEADERX
    38 00000000 <res 20h>           <2> eldhxHeader:		resb ELD_HEADER_size
    39 00000020 ????????            <2> eldhxDescriptionOffset:	resd 1	; zero if none, from eldhxHeader. <= 128 Bytes
    40 00000024 ????????            <2> eldhxHelpOffset:	resd 1	; zero if none, from eldhxHeader
    41 00000028 ????????            <2> eldhxLibTable:		resd 1	; zero if none, from eldhxHeader
    42 0000002C ????????            <2> eldhxDateTimeOffset:	resd 1	; zero if none, from eldhxHeader
    43                              <2> 	alignb 16
    44                              <2> 	endstruc
    45                              <2> 
    46                              <2> 	struc ELD_TRAILER_HEADER
    47 00000000 ????????????????    <2> eldthSignature:		resb 8	; "ELD1TAIL"
    48 00000008 ????????            <2> eldthHeaderOffset:	resd 1	; negative displacement from eldthSignature,
    49                              <2> 				;  add this dword to the seek offset
    50 0000000C ????                <2> eldthReserved:		resw 1	; reserved, must be initialised to zero
    51 0000000E ????                <2> eldthChecksum:		resw 1	; sum of all words in trailer header = 0
    52                              <2> 	endstruc
    53                              <2> 	endarea ELD_TRAILER_HEADER, 1
    54                              <2> 
    55                              <2> 	struc ELD_LIBTABLE
    56 00000000 ????                <2> eldltFormat:		resw 1
    57                              <2> 	; 0 = uncompressed
    58                              <2> 	; 2 = heatshrink compressed
    59                              <2> 	; 3 = lzexedat -4 compressed
    60                              <2> 	; 4 = lzexedat -4 -l compressed
    61 00000002 ????                <2> eldltAmount:		resw 1
    62 00000004 ????????            <2> eldltOffset:		resd 1	; from eldhxHeader
    63                              <2> eldltCompressedLength:		; (dword, only present if format 2, 3, or 4)
    64                              <2> 	endstruc
    65                              <2> 	endarea ELD_LIBTABLE, 1
    66                              <2> 
    67                              <2> 		; ELD instance header
    68                              <2> 	struc ELD_INSTANCE
    69 00000000 ????                <2> eldiStartCode:		resw 1	; -> this structure itself (para aligned)
    70 00000002 ????                <2> eldiEndCode:		resw 1	; -> behind memory used by instance (para aligned)
    71 00000004 ????                <2> eldiStartData:		resw 1	; -> data in data entry section (para aligned), or 0
    72 00000006 ????                <2> eldiEndData:		resw 1	; -> behind data (para aligned), or 0
    73 00000008 ????????????????    <2> eldiIdentifier:		resb 8	; blank-filled text
    74 00000010 ????                <2> eldiFlags:		resw 1	; flags
    75                              <2> eldiListing_size equ 14
    76 00000012 <res Eh>            <2> eldiListing:		resb eldiListing_size
    77                              <2> 				; ASCIZ listing file name
    78                              <2> 	endstruc
    79                              <2> 		; flags for eldiFlags:
    80                              <2> eldifResident:		equ 1
    81                              <2> 
    82                              <2> 		; ELD link info header
    83                              <2> 	struc ELD_LINKINFO
    84 00000000 ????                <2> eldlSignature:		resw 1	; 0E1D1h
    85 00000002 ????????            <2> eldlReserved:		resw 2
    86 00000006 ????                <2> eldlUseLinkHash:	resw 1
    87 00000008 ????                <2> eldlDataAmount:		resw 1
    88 0000000A ????                <2> eldlDataPrefixes:	resw 1
    89 0000000C ????                <2> eldlDataEntries:	resw 1
    90 0000000E ????                <2> eldlDataAddresses:	resw 1
    91 00000010 ????                <2> eldlCodeAmount:		resw 1
    92 00000012 ????                <2> eldlCodePrefixes:	resw 1
    93 00000014 ????                <2> eldlCodeEntries:	resw 1
    94 00000016 ????                <2> eldlCodeAddresses:	resw 1
    95                              <2> 	endstruc
    96                              <2> 
    97                              <2> 	numdef ELD_CODE_VSTART, 9001h
    98                              <2> 	numdef ELD_DATA_VSTART, 8000h
    99                              <2> 	numdef ELD_RELOC_VSTART, 8000h
   100                              <2> 
   101                              <2> 	numdef ELD_RECLAIM_HINT, 0
   102                              <2> 	strdef ELD_LISTING, ""
   103                              <2> 	numdef ELD_DATETIME, 0
   104                              <2> 
   105                              <2> %if _ELD_DATETIME
   106                              <2>  %define PUT_ELDHX_DATETIME_OFFSET at eldhxDateTimeOffset, dd DATAOFFSET + datetime - datastart
   107                              <2>  %macro PUT_ELD_DATETIME 0.nolist
   108                              <2> datetime:	asciz __UTC_DATE__,'T',__UTC_TIME__,'Z'
   109                              <2> 		asciz		; for future extension
   110                              <2>  %endmacro
   111                              <2> %else
   112                              <2>  %define PUT_ELDHX_DATETIME_OFFSET
   113                              <2>  %define PUT_ELD_DATETIME
   114                              <2> %endif
   115                              <2> 
   116                              <2> %endif
   716                              <1> 
   717                              <1> %include "install.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug INSTALL command macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2023 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 	struc INSTALLFLAG
    17 00000000 ????                <2> ifKeyword:	resw 1
    18 00000002 ????                <2> ifDescription:	resw 1
    19 00000004 ????                <2> ifOptions:	resw 1
    20 00000006 ????                <2> ifValue:	resw 1
    21 00000008 ????                <2> ifTrying:	resw 1
    22 0000000A ????                <2> ifReserved:	resw 1
    23                              <2> 	endstruc
    24                              <2> 
   718                              <1> 
   719                              <1> %if _SYMBOLIC
   720                              <1> 	defaulting 0			; disable defaulting
   721                              <1> %include "symbols.mac"
   722                              <1> [list -]
   723                              <1> 		; symbolic branch defines *without* defaulting!
   724                              <1> 	numdef ZZ_INSERT_TEMP, 1
   725                              <1> 	numdef XMS_SYMBOL_TABLE, 1
   726                              <1> 	numdef BUFFER_86MM_SLICE, 0
   727                              <1> 	numdef SECOND_SLICE, 0
   728                              <1> 
   729                              <1> 	defaulting 1			; re-enable defaulting
   730                              <1> 
   731                              <1> 		; symbolic branch defines
   732                              <1> 	numdef 86MM_SYMBOL_TABLE_MAX, 256, 256
   733                              <1> %endif
   734                              <1> 
   735                              <1> 	struc SEGADR
   736 00000000 ????????            <1> saOffset:	resd 1
   737 00000004 ????                <1> saSegSel:	resw 1
   738                              <1> %if _PM
   739                              <1> saSegment:	resw 1
   740                              <1> saSelector:	resw 1
   741                              <1> %endif
   742                              <1> 	endstruc
   743                              <1> 
   744                              <1> 	%macro segmentedaddress 0.nolist
   745                              <1> 	istruc SEGADR
   746                              <1> 	iend
   747                              <1> 	%endmacro
   748                              <1> 
   749                              <1> 	struc SEGOFS16ADR
   750 00000000 ????                <1> so16aOffset:	resw 1
   751 00000002 ????                <1> so16aSegSel:	resw 1
   752                              <1> %if _PM
   753                              <1> so16aSegment:	resw 1
   754                              <1> so16aSelector:	resw 1
   755                              <1> %endif
   756                              <1> 	endstruc
   757                              <1> 
   758                              <1> 	%macro segofs16address 0-1.nolist zero
   759                              <1> 	istruc SEGOFS16ADR
   760                              <1> %ifidni %1,zero
   761                              <1> %elifidni %1,minusone
   762                              <1> at so16aOffset,		dw -1
   763                              <1> at so16aSegSel,		dw -1
   764                              <1>  %if _PM
   765                              <1> at so16aSegment,	dw -1
   766                              <1> at so16aSelector,	dw -1
   767                              <1>  %endif
   768                              <1> %else
   769                              <1>  %error Unexpected initialiser keyword
   770                              <1> %endif
   771                              <1> 	iend
   772                              <1> 	%endmacro
   773                              <1> 
   774                              <1> 	struc SEGONLYADR
   775 00000000 ????                <1> soaSegSel:	resw 1
   776                              <1> %if _PM
   777                              <1> soaSegment:	resw 1
   778                              <1> soaSelector:	resw 1
   779                              <1> %endif
   780                              <1> 	endstruc
   781                              <1> 
   782                              <1> 	%macro segonlyaddress 0.nolist
   783                              <1> 	istruc SEGONLYADR
   784                              <1> 	iend
   785                              <1> 	%endmacro
   786                              <1> 
   787                              <1> 
   788                              <1> %if _LOADER
   789                              <1> 	struc MOVETABLEENTRY
   790                              <1> mteIdentifier:		resw 1
   791                              <1> mteArrayIndex:		resw 1
   792                              <1> mteStatusMessage:	resw 1
   793                              <1> mteFromArray:
   794                              <1> mteFromBottom:		resw 1
   795                              <1> mteFromTop:		resw 1
   796                              <1> mteFromHidden:		resw 1
   797                              <1> 	endstruc
   798                              <1> %endif
   799                              <1> 
   800                              <1> %if _BOOTLDR
   801                              <1>  %include "iniload.mac"
     1                              <2> %if 0
     2                              <2> 
     3                              <2> lDebug iniload/boot interfacing structs and macros
     4                              <2> 
     5                              <2> Copyright (C) 2008-2025 E. C. Masloch
     6                              <2> 
     7                              <2> Usage of the works is permitted provided that this
     8                              <2> instrument is retained with the works, so that any entity
     9                              <2> that uses the works is notified of this instrument.
    10                              <2> 
    11                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    12                              <2> 
    13                              <2> %endif
    14                              <2> 
    15                              <2> 
    16                              <2> 	struc BS
    17 00000000 ??????              <2> bsJump:	resb 3
    18 00000003 ????????????????    <2> bsOEM:	resb 8
    19                              <2> bsBPB:
    20                              <2> 	endstruc
    21                              <2> 
    22                              <2> 	struc EBPB		;        BPB sec
    23 00000000 ????                <2> bpbBytesPerSector:	resw 1	; offset 00h 0Bh
    24 00000002 ??                  <2> bpbSectorsPerCluster:	resb 1	; offset 02h 0Dh
    25 00000003 ????                <2> bpbReservedSectors:	resw 1	; offset 03h 0Eh
    26 00000005 ??                  <2> bpbNumFATs:		resb 1	; offset 05h 10h
    27 00000006 ????                <2> bpbNumRootDirEnts:	resw 1	; offset 06h 11h -- 0 for FAT32
    28 00000008 ????                <2> bpbTotalSectors:	resw 1	; offset 08h 13h
    29 0000000A ??                  <2> bpbMediaID:		resb 1	; offset 0Ah 15h
    30 0000000B ????                <2> bpbSectorsPerFAT:	resw 1	; offset 0Bh 16h -- 0 for FAT32
    31 0000000D ????                <2> bpbCHSSectors:		resw 1	; offset 0Dh 18h
    32 0000000F ????                <2> bpbCHSHeads:		resw 1	; offset 0Fh 1Ah
    33 00000011 ????????            <2> bpbHiddenSectors:	resd 1	; offset 11h 1Ch
    34 00000015 ????????            <2> bpbTotalSectorsLarge:	resd 1	; offset 15h 20h
    35                              <2> bpbNew:				; offset 19h 24h
    36                              <2> 
    37 00000019 ????????            <2> ebpbSectorsPerFATLarge:	resd 1	; offset 19h 24h
    38 0000001D ????                <2> ebpbFSFlags:		resw 1	; offset 1Dh 28h
    39 0000001F ????                <2> ebpbFSVersion:		resw 1	; offset 1Fh 2Ah
    40 00000021 ????????            <2> ebpbRootCluster:	resd 1	; offset 21h 2Ch
    41 00000025 ????                <2> ebpbFSINFOSector:	resw 1	; offset 25h 30h
    42 00000027 ????                <2> ebpbBackupSector:	resw 1	; offset 27h 32h
    43 00000029 <res Ch>            <2> ebpbReserved:		resb 12	; offset 29h 34h
    44                              <2> ebpbNew:			; offset 35h 40h
    45                              <2> 	endstruc
    46                              <2> 
    47                              <2> 	struc BPBN		; ofs B16 S16 B32 S32
    48 00000000 ??                  <2> bpbnBootUnit:		resb 1	; 00h 19h 24h 35h 40h
    49 00000001 ??                  <2> 			resb 1	; 01h 1Ah 25h 36h 41h
    50 00000002 ??                  <2> bpbnExtBPBSignature:	resb 1	; 02h 1Bh 26h 37h 42h -- 29h for valid BPBN
    51 00000003 ????????            <2> bpbnSerialNumber:	resd 1	; 03h 1Ch 27h 38h 43h
    52 00000007 <res Bh>            <2> bpbnVolumeLabel:	resb 11	; 07h 20h 2Bh 3Ch 47h
    53 00000012 ????????????????    <2> bpbnFilesystemID:	resb 8	; 12h 2Bh 36h 47h 52h
    54                              <2> 	endstruc		; 1Ah 33h 3Eh 4Fh 5Ah
    55                              <2> 
    56                              <2> 	struc DIRENTRY
    57 00000000 ????????????????    <2> deName:		resb 8
    58 00000008 ??????              <2> deExt:		resb 3
    59 0000000B ??                  <2> deAttrib:	resb 1
    60 0000000C ??                  <2> dePlusSize:	resb 1
    61 0000000D ??????????????      <2> 		resb 7
    62 00000014 ????                <2> deClusterHigh:	resw 1
    63 00000016 ????                <2> deTime:		resw 1
    64 00000018 ????                <2> deDate:		resw 1
    65 0000001A ????                <2> deClusterLow:	resw 1
    66 0000001C ????????            <2> deSize:		resd 1
    67                              <2> 	endstruc
    68                              <2> 
    69                              <2> ATTR_READONLY	equ 1
    70                              <2> ATTR_HIDDEN	equ 2
    71                              <2> ATTR_SYSTEM	equ 4
    72                              <2> ATTR_VOLLABEL	equ 8
    73                              <2> ATTR_DIRECTORY	equ 10h
    74                              <2> ATTR_ARCHIVE	equ 20h
    75                              <2> 
    76                              <2> lsvclSignature		equ "CL"
    77                              <2> lsvclBufferLength	equ 256
    78                              <2> 
    79                              <2> 	struc LOADSTACKVARS, -10h
    80 FFFFFFF0 ????????            <2> lsvFirstCluster:	resd 1
    81 FFFFFFF4 ????????            <2> lsvFATSector:		resd 1
    82 FFFFFFF8 ????                <2> lsvFATSeg:		resw 1
    83 FFFFFFFA ????                <2> lsvLoadSeg:		resw 1
    84 FFFFFFFC ????????            <2> lsvDataStart:		resd 1
    85                              <2> 	endstruc
    86                              <2> 
    87                              <2> 	struc LOADDATA, LOADSTACKVARS - 10h
    88 FFFFFFE0 ????                <2> ldMemoryTop:	resw 1
    89 FFFFFFE2 ????                <2> ldLoadTop:	resw 1
    90 FFFFFFE4 ????                <2> ldSectorSeg:	resw 1
    91 FFFFFFE6 ??                  <2> ldFATType:	resb 1
    92                              <2> ldFlags:
    93 FFFFFFE7 ??                  <2> ldHasLBA:	resb 1
    94 FFFFFFE8 ????                <2> ldClusterSize:	resw 1
    95 FFFFFFEA ????                <2> ldParaPerSector:resw 1
    96                              <2> ldDirCluster:			; dword
    97                              <2> ldLoadingSeg:		; word
    98                              <2> ldQueryPatchValue:	; word
    99                              <2> lsvCommandLine:		; word
   100                              <2> .start:		equ $ - lsvclBufferLength
   101 FFFFFFEC ????                <2> .signature:	resw 1
   102                              <2> ldLoadUntilSeg:		; word
   103                              <2> lsvExtra:		; word
   104 FFFFFFEE ??                  <2> .partition:	resb 1	; byte
   105 FFFFFFEF ??                  <2> .flags:		resb 1	; byte
   106                              <2> 	endstruc
   107                              <2> 
   108                              <2> ldhlfPreserveLoader	equ 4
   109                              <2> 
   110                              <2> lsvefNoDataStart	equ 1
   111                              <2> lsvefPartitionNumber	equ 2
   112                              <2> lsvefPreserveLoader	equ 4
   113                              <2> 
   114                              <2> %if lsvefPreserveLoader != ldhlfPreserveLoader
   115                              <2>  %error Unexpected flag values
   116                              <2> %endif
   117                              <2> 
   118                              <2> 	struc LOADCMDLINE, LOADDATA - lsvclBufferLength
   119                              <2> ldCommandLine:
   120 FFFFFEE0 <res 100h>          <2> .start:		resb lsvclBufferLength
   121                              <2> 	endstruc
   122                              <2> 
   123                              <2> ldfHasLBA:	equ 1
   124                              <2> ldfFATInvalid:	equ 2
   125                              <2> ldfFATBuffered:	equ 4
   126                              <2> ldfDataBuffered: equ 8
   127                              <2> 
   128                              <2> 	struc LOADDATA2, LOADDATA - 10h
   129 FFFFFFD0 ????????            <2> ldRootSector:		resd 1
   130 FFFFFFD4 ????                <2> ldEntriesPerSector:	resw 1
   131                              <2> ldDataSegment:		; word
   132 FFFFFFD6 ????                <2> ldLastAvailableSector:	resw 1
   133                              <2> ldDataSector:		; dword
   134 FFFFFFD8 ????                <2> ldParasLeft:		resw 1
   135 FFFFFFDA ????                <2> ldParasDone:		resw 1
   136                              <2> 	endstruc
   137                              <2> 
   138                              <2> 	struc LOADDATA3, LOADDATA2 - 10h
   139 FFFFFFC0 ????????            <2> ldMaxCluster:		resd 1
   140 FFFFFFC4 ????????            <2> ldFileSize:		resd 1
   141 FFFFFFC8 ????????            <2> ldCurrentCluster:	resd 1
   142 FFFFFFCC ????????            <2> ldCurrentSeek:		resd 1
   143                              <2> 	endstruc
   144                              <2> 
   145                              <2> 	struc LOADERIMAGEIDENT
   146 00000000 ????????            <2> liiSignature:		resb 4		; "NLDR"
   147 00000004 ????                <2> liiVersion:		resb 2		; "00"
   148 00000006 ????                <2> liiChecksum:		resw 1		; word sum of first 8 words = 0
   149 00000008 ????                <2> liiAmountParagraphs:	resw 1
   150 0000000A ????????????        <2> liiReserved:		resw 3
   151 00000010 ????                <2> liiEntryQuerySize:	resw 1		; 0 if not supported
   152                              <2> 		; INP:	cs => NLDR image ident
   153                              <2> 		;	ip = this word field content
   154                              <2> 		;	ax = 60h
   155                              <2> 		; OUT:	ax => behind memory requested (should be >= 60h)
   156                              <2> 		; CHG:	es, ds, di, si, bx, cx, dx
   157                              <2> 		; STT:	far called, UP, EI
   158 00000012 ????                <2> liiEntryRelocate:	resw 1		; 0 if not supported
   159                              <2> 		; INP:	cs => NLDR image ident
   160                              <2> 		;	ip = this word field content
   161                              <2> 		;	ax = 60h
   162                              <2> 		; OUT:	ax => relocated NLDR segment (usually 60h)
   163                              <2> 		; CHG:	es, ds, di, si, bx, cx, dx
   164                              <2> 		; STT:	far called, UP, EI
   165 00000014 ????                <2> liiEntryDebug:		resw 1		; 0 if not supported
   166                              <2> 		; INP:	es = ds = cs = ss => relocated NLDR
   167                              <2> 		;	ip = this word field content
   168                              <2> 		;	sp = next word field content
   169                              <2> 		; STT:	running as debuggee, UP, EI
   170 00000016 ????                <2> liiStackPointer:	resw 1
   171                              <2> 	endstruc
   172                              <2> 
   173                              <2> 	struc LBAPACKET
   174 00000000 ????                <2> lpSize:		resw 1
   175 00000002 ????                <2> lpCount:	resw 1
   176 00000004 ????????            <2> lpBuffer:	resd 1
   177 00000008 ????????????????    <2> lpSector:	resq 1
   178                              <2> 	endstruc
   179                              <2> 
   180                              <2> 	struc PARTINFO
   181 00000000 ??                  <2> piBoot:		resb 1
   182 00000001 ??????              <2> piStartCHS:	resb 3
   183 00000004 ??                  <2> piType:		resb 1
   184 00000005 ??????              <2> piEndCHS:	resb 3
   185 00000008 ????????            <2> piStart:	resd 1
   186 0000000C ????????            <2> piLength:	resd 1
   187                              <2> 	endstruc
   188                              <2> 
   189                              <2> ptEmpty:		equ 0
   190                              <2> ptFAT12:		equ 1
   191                              <2> ptFAT16_16BIT_CHS:	equ 4
   192                              <2> ptExtendedCHS:		equ 5
   193                              <2> ptFAT16_CHS:		equ 6
   194                              <2> ptFAT32_CHS:		equ 0Bh
   195                              <2> ptFAT32:		equ 0Ch
   196                              <2> ptFAT16:		equ 0Eh
   197                              <2> ptExtended:		equ 0Fh
   198                              <2> ptLinux:		equ 83h
   199                              <2> ptExtendedLinux:	equ 85h
   200                              <2> 
   201                              <2> 
   202                              <2> 		; Flags of load_unit_flags
   203                              <2> lufForceCHS:		equ 1
   204                              <2> lufForceLBA:		equ 2
   205                              <2> lufForceGeometry:	equ 4
   206                              <2> luf_mask_writable equ lufForceCHS | lufForceLBA | lufForceGeometry
   802                              <1> 
   803                              <1> LOAD_INPUT_FILE_SIZE equ fromparas(paras(-LOADDATA3 + bsBPB + ebpbNew + BPBN_size))
   804                              <1> 
   805                              <1> 	struc LOADSETTINGS
   806 00000000 ????                <1> lsKernelName:	resw 1	; -> kernel file default name
   807 00000002 ????                <1> lsAddName:	resw 1	; -> additional file default name, may be empty string
   808 00000004 ????                <1> lsMinPara:	resw 1	; how much to load at least, fail if file smaller
   809 00000006 ????                <1> lsMaxPara:	resw 1	; how much to load at most (will round up to sector size)
   810 00000008 ????                <1> lsOptions:	resw 1	; option flags
   811 0000000A ????                <1> lsSegment:	resw 1	; => where to load file
   812 0000000C ????????            <1> lsEntry:	resd 1	; relative segment for CS, value for IP
   813 00000010 ????????            <1> lsBPB:		resd 1	; segment for BPB (-1 auto-BPB), offset for BPB
   814 00000014 ????                <1> lsCheckOffset:	resw 1	; offset in file segment of word to check
   815 00000016 ????                <1> lsCheckValue:	resw 1	; value to check for word, 0 if unused
   816 00000018 ????????????????    <1> lsName:		resq 1	; ASCIZ load protocol name
   817                              <1> 	endstruc
   818                              <1> 
   819                              <1> 		numdef LUF_DEFAULT_DISKETTE, 0
   820                              <1> 		numdef LUF_DEFAULT_HARDDISK, 0
   821                              <1> %endif
   822                              <1> 
   823                              <1> 
   824                              <1> %include "mzheader.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug MZ .EXE header macros
     5                              <2> 
     6                              <2> Copyright (C) 1995-2003 Paul Vojta
     7                              <2> Copyright (C) 2008-2023 E. C. Masloch
     8                              <2> 
     9                              <2> Usage of the works is permitted provided that this
    10                              <2> instrument is retained with the works, so that any entity
    11                              <2> that uses the works is notified of this instrument.
    12                              <2> 
    13                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    14                              <2> 
    15                              <2> %endif
    16                              <2> 
    17                              <2> 
    18                              <2> 	struc EXEHEADER
    19 00000000 ????                <2> exact_struc_at 00h, exeSignature:	resw 1
    20 00000002 ????                <2> exact_struc_at 02h, exeExtraBytes:	resw 1	; bytes in last page
    21 00000004 ????                <2> exact_struc_at 04h, exePages:		resw 1	; number of 512-byte pages. includes the header!
    22 00000006 ????                <2> exact_struc_at 06h, exeRelocItems:	resw 1	; number of relocation items
    23 00000008 ????                <2> exact_struc_at 08h, exeHeaderSize:	resw 1	; header size in 16-byte paragraphs
    24 0000000A ????                <2> exact_struc_at 0Ah, exeMinAlloc:	resw 1	; minimum (bss) allocation in paragraphs
    25 0000000C ????                <2> exact_struc_at 0Ch, exeMaxAlloc:	resw 1	; maximum (bss) allocation in paragraphs
    26 0000000E ????                <2> exact_struc_at 0Eh, exeInitSS:		resw 1	; init ss (is relocated)
    27 00000010 ????                <2> exact_struc_at 10h, exeInitSP:		resw 1	; init sp
    28 00000012 ????                <2> exact_struc_at 12h, exeChecksum:	resw 1
    29                              <2> exact_struc_at 14h, exeInitCSIP:
    30 00000014 ????                <2> exact_struc_at 14h, exeInitIP:		resw 1	; init ip
    31 00000016 ????                <2> exact_struc_at 16h, exeInitCS:		resw 1	; init cs (is relocated)
    32 00000018 ????                <2> exact_struc_at 18h, exeRelocTable:	resw 1	; byte offset of relocation table
    33                              <2> 		; Each relocation item is a word offset and a word segment.
    34                              <2> 		;  The segment of the item itself is relocated as well.
    35 0000001A ????                <2> exact_struc_at 1Ah, exeOverlayNum:	resw 1
    36                              <2> exact_struc_at 1Ch
    37                              <2> 	endstruc
   825                              <1> 
   826                              <1> 
   827                              <1> 	struc INPUTFILEHANDLE
   828 00000000 ????                <1> ifhHandle:	resw 1
   829 00000002 ????                <1> ifhFlags:	resw 1
   830 00000004 ????????            <1> ifhParentSeek:	resd 1
   831                              <1> 	endstruc
   832                              <1> 
   833                              <1> ifhfIsDup:		equ  100h	; before closing, seek it back
   834                              <1> 	; same value as LBA flag for boot load input files
   835                              <1> ifhfTestReserved1:	equ 1000h
   836                              <1> ifhfTestReserved2:	equ 2000h
   837                              <1> ifhfQuietInput:		equ 4000h	; do not display prompt and input
   838                              <1> ifhfQuietOutput:	equ 8000h	; do not display normal output
   839                              <1> 	; these four are valid for both input file handles and
   840                              <1> 	;  boot load input files.
   841                              <1> 
   842                              <1> 
   843                              <1> 	struc AREASTRUC
   844 00000000 <res 18h>           <1> areastrucEntry:		resb 24
   845 00000018 ????????            <1> areastrucNext:		resd 1
   846 0000001C ????????            <1> areastrucPrev:		resd 1
   847 00000020 ????                <1> areastrucSubAmount:	resw 1
   848 00000022 ????                <1> areastrucSubOffset:	resw 1
   849 00000024 ????                <1> areastrucFunAmount:	resw 1
   850 00000026 ????                <1> areastrucFunOffset:	resw 1
   851                              <1> 	endstruc
   852                              <1> 
   853                              <1> 	struc AREASTRUCSUB
   854 00000000 ????????            <1> areastrucsubLinear:	resd 1
   855 00000004 ????????            <1> areastrucsubLinearEnd:	resd 1
   856 00000008 ????                <1> areastrucsubListOffset:	resw 1
   857 0000000A ????                <1> areastrucsubListAmount:	resw 1
   858                              <1> 	endstruc
   859                              <1> 
   860                              <1> 	struc AREASTRUCFUN
   861 00000000 ????????            <1> areastrucfunLinear:	resd 1
   862 00000004 ????????            <1> areastrucfunLinearEnd:	resd 1
   863 00000008 ????                <1> areastrucfunListOffset:	resw 1
   864 0000000A ????                <1> areastrucfunListAmount:	resw 1
   865                              <1> 	endstruc
   866                              <1> 
   867                              <1> 	struc AREA
   868 00000000 ????                <1> areastart:		resw 1
   869 00000002 ????                <1> areaend:		resw 1
   870 00000004 ????                <1> areamessage:		resw 1
   871 00000006 ????                <1> 			resw 1
   872                              <1> 	endstruc
   873                              <1> 
   874                              <1> 
   875                              <1> %include "isvariab.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug isvariable? function strutures and macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2025 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 
    17                              <2> 	struc ISVARIABLESTRUC
    18 00000000 ????                <2> ivName:		resw 1		; -> name (up to 13 bytes, but actually only 11)
    19                              <2> 				;  (search for ivfNameLengthLimit for limit)
    20                              <2> 				;  (length given by ivFlags & ivfNameLengthMask)
    21                              <2> 	; The ivName pointer is only used for more-byte names. It actually
    22                              <2> 	;  contains the trailer of the name, excluding the prefix formed by
    23                              <2> 	;  the first two bytes. This suffix can be the empty string if the
    24                              <2> 	;  variable in question has a two-byte name.
    25                              <2> 	; (For one-byte names this field is unused and contains zero.)
    26 00000002 ????                <2> ivFlags:	resw 1
    27 00000004 ????                <2> ivAddress:	resw 1		; default -> variable
    28                              <2> 	; The ivAddress field is used by default_variable_setup as the base
    29                              <2> 	;  address for the variable(s). It is also used by var_ext_setup as
    30                              <2> 	;  the ELD code section offset to transfer control to. Otherwise, it
    31                              <2> 	;  is usually set to zero and unused.
    32 00000006 ????                <2> ivSetup:	resw 1		; -> set up code (in expr code section)
    33                              <2> 	; INP:	ax = array index (0-based)
    34                              <2> 	;	di = 0
    35                              <2> 	;	cl = default size of variable (1..4)
    36                              <2> 	;	ch = length of variable name
    37                              <2> 	;	bx -> ISVARIABLESTRUC structure
    38                              <2> 	; CHG:	ax, bx, cx, dx, si, di
    39                              <2> 	; OUT:	NC if valid,
    40                              <2> 	;	 bx -> var, di = 0 or di -> mask
    41                              <2> 	;	 cl = size of variable (1..4)
    42                              <2> 	;	 ch = length of variable name
    43 00000008 ??                  <2> ivArrayLast:	resb 1		; 0 if no array, FFh = 256 entries
    44                              <2> 	; The ivArrayLast field is used by the dispatcher to determine
    45                              <2> 	;  whether to support array index expressions. It is checked
    46                              <2> 	;  before decrementing the index if ivfArrayOneBased is set.
    47 00000009 ??                  <2> ivArrayBetween: resb 1		; how many bytes to skip for each index
    48                              <2> 	; The ivArrayBetween field is only used by default_variable_setup.
    49                              <2> 	endstruc
    50                              <2> 
    51                              <2> ivfNameLengthMask:	equ 15	; gives name trailer length, 0 to 11
    52                              <2> ivfNameLengthLimit:	equ 13
    53                              <2> ivfVarLengthShift:	equ 4
    54                              <2> ivfVarLengthMask:	equ 3 << ivfVarLengthShift
    55                              <2> 				; gives default variable size minus 1
    56                              <2> ivfReadOnly:		equ 80h	; variable cannot be written at all
    57                              <2> ivfArrayOneBased:	equ 100h; first array entry is 1 not 0 (ivArrayLast > 0)
    58                              <2> ivfArrayOptional:	equ 200h; array index expression is optional
    59                              <2> ivfSeparatorSpecial:	equ 400h; used for RIxxP/L/S/O
    60                              <2> 
    61                              <2> %define ISVARIABLESTRINGS db "",db ""
    62                              <2> %define IVS_ONEBYTE_NAMES ""
    63                              <2> %define IVS_MOREBYTE_NAMEHEADERS ""
    64                              <2> %assign IVS_HAVE_ONEBYTE 0
    65                              <2> %assign IVS_SINGLE_ONEBYTE 1
    66                              <2> 
    67                              <2> 		; %1 = name string
    68                              <2> 		; %2 = default variable length, 1 to 4
    69                              <2> 		; %3 = flags to set (except name length and var length)
    70                              <2> 		; %4 = ivAddress value
    71                              <2> 		; %5 = ivArrayLast, defaults to 0 (no array)
    72                              <2> 		; %6 = ivArrayBetween, defaults to 0 (immediately consecutive)
    73                              <2> 		; %7 = ivSetup, defaults to default_variable_setup
    74                              <2> 	%macro isvariablestruc 4-7.nolist 0, 0, default_variable_setup
    75                              <2> %push
    76                              <2> %strlen %$namelength %1
    77                              <2> %if %$namelength > ivfNameLengthLimit
    78                              <2>  %error Expected at most 13-byte name (or adjust isvariable? code)
    79                              <2> %endif
    80                              <2> %if IVS_ONEBYTE && %$namelength != 1
    81                              <2>  %error Expected a one-byte name
    82                              <2> %elif ! IVS_ONEBYTE && %$namelength < 2
    83                              <2>  %error Expected at least a two-byte name
    84                              <2> %endif
    85                              <2> %if IVS_ONEBYTE
    86                              <2>  %define IVS_SINGLE_ONEBYTE_NAME %1
    87                              <2>  %if IVS_HAVE_ONEBYTE
    88                              <2>   %assign IVS_SINGLE_ONEBYTE 0
    89                              <2>  %endif
    90                              <2>  %assign IVS_HAVE_ONEBYTE 1
    91                              <2>  %assign %$namelength 0
    92                              <2>  %xdefine IVS_ONEBYTE_NAMES IVS_ONEBYTE_NAMES, %1
    93                              <2>  %%name equ 0
    94                              <2> %else
    95                              <2>  %assign %$namelength %$namelength - 2
    96                              <2>  %substr %$nametrailer %1 3,-1
    97                              <2>  %substr %$nameheader %1 1,2
    98                              <2>  %xdefine IVS_MOREBYTE_NAMEHEADERS IVS_MOREBYTE_NAMEHEADERS, %$nameheader
    99                              <2>  %xdefine ISVARIABLESTRINGS ISVARIABLESTRINGS, %%name:, {db %$nametrailer}
   100                              <2> %endif
   101                              <2> 
   102                              <2> %assign %$varlength %2 - 1	; 0 means one byte, 1 means two bytes,
   103                              <2> 				;  2 means three bytes, 3 means four bytes
   104                              <2> 	istruc ISVARIABLESTRUC
   105                              <2> at ivName,		dw %%name
   106                              <2>  IV_NAME_RELOCATION
   107                              <2> at ivFlags,		dw %$$namelength | (%$$varlength << ivfVarLengthShift) | %3
   108                              <2> at ivAddress,		dw %4
   109                              <2>  IV_ADDRESS_RELOCATION
   110                              <2> at ivSetup,		dw %7
   111                              <2>  IV_SETUP_RELOCATION
   112                              <2> at ivArrayLast,		db %5
   113                              <2> at ivArrayBetween,	db %6
   114                              <2> 	iend
   115                              <2> %pop
   116                              <2> %ifndef SECTION_OF_%7
   117                              <2>  %error Unknown target section for symbol %7
   118                              <2> %elifnidni %[SECTION_OF_%7], _EXPR_SECTION
   119                              <2>  %error Wrong section for symbol %7: section_of=SECTION_OF_%7, expr=_EXPR_SECTION
   120                              <2> %endif
   121                              <2> 	%endmacro
   122                              <2> 
   123                              <2> %define IV_NAME_RELOCATION
   124                              <2> %define IV_ADDRESS_RELOCATION
   125                              <2> %define IV_SETUP_RELOCATION
   126                              <2> 
   127                              <2> 	%macro isvariablestrings 2-*.nolist
   128                              <2> %rep %0
   129                              <2>  %1
   130                              <2>  %rotate 1
   131                              <2> %endrep
   132                              <2> 	%endmacro
   876                              <1> 
   877                              <1> 
   878                              <1> %include "386.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug 386 patch macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2026 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 	numdef LINK, 0
    17                              <2> 
    18                              <2> 	numdef WPT_LABELS, 0
    19                              <2> 		; This used to be required, because CODESECTIONFIXUP used
    20                              <2> 		;  ldebug_data_entry_size, which is not yet defined during
    21                              <2> 		;  assembling of (most) lDEBUG_CODE fragments.
    22                              <2> 		; However, assembling DebugX with this option selected
    23                              <2> 		;  took more than 2 minutes, so the non-label variant
    24                              <2> 		;  is clearly to be preferred when available.
    25                              <2> 		; Now that lDEBUG_CODE has vstart=0 we can use the
    26                              <2> 		;  CODESECTIONFIXUP again and thus disable this option.
    27                              <2> 
    28                              <2> %ifn _LINK
    29                              <2> %define PATCH_NO386_TABLE ""
    30                              <2> %define PATCH_386_TABLE ""
    31                              <2> %define PATCH_NO386_TABLE2 ""
    32                              <2> %define PATCH_386_TABLE2 ""
    33                              <2> %define PATCH_NO386_TABLEENTRY ""
    34                              <2> %define PATCH_386_TABLEENTRY ""
    35                              <2> %endif
    36                              <2> 
    37                              <2> %if _ONLY386
    38                              <2> 		; Default patch macros if only running on 386+.
    39                              <2> %define _386_o32 o32
    40                              <2> %define _386_a32 a32
    41                              <2> %define _386_jmps jmp short
    42                              <2> %define _386_jmpn jmp near
    43                              <2> %define _no386_jmps comment
    44                              <2> %define _no386_jmpn comment
    45                              <2> 	%macro _386 0-1+.nolist
    46                              <2> [cpu 386]			; change CPU type
    47                              <2> 		%1		; write instruction
    48                              <2> __CPU__				; reset CPU type
    49                              <2> 	%endmacro
    50                              <2> %define _no386 comment
    51                              <2> %elif _ONLYNON386
    52                              <2> 		; Default patch macros if only running on non-386.
    53                              <2> %define _386_o32
    54                              <2> %define _386_a32
    55                              <2> %define _386_jmps comment
    56                              <2> %define _386_jmpn comment
    57                              <2> %define _no386_jmps jmp short
    58                              <2> %define _no386_jmpn jmp near
    59                              <2> %define _386 comment
    60                              <2> %define _no386
    61                              <2> %else
    62                              <2> 
    63                              <2> ; These macros are to make DEBUG's 386 support as small as
    64                              <2> ; possible. To achieve this, two patch tables are created
    65                              <2> ; in the initialisation code. One of the tables is used if
    66                              <2> ; the CPU is a 386+, the other one if it isn't. The bytes
    67                              <2> ; pointed to in the used table are over-written with NOP
    68                              <2> ; instructions. (The patched bytes are usually address or
    69                              <2> ; operand size prefixes or jumps that branch to 386/non-386
    70                              <2> ; code.)
    71                              <2> 
    72                              <2> ; There are a few special patches that require the
    73                              <2> ; initialisation code to write specific bytes other than
    74                              <2> ; NOP instructions for lower resident memory usage.
    75                              <2> ; Two are in the run: code, three in pmentry.asm.
    76                              <2> 
    77                              <2> %if _LINK
    78                              <2> 
    79                              <2> %imacro wllist 1-3.nolist
    80                              <2> %ifnempty %3
    81                              <2>  %deftok %%filenametoken %3
    82                              <2> %else
    83                              <2>  %deftok %%filenametoken __FILE__
    84                              <2> %endif
    85                              <2>  global ..@wllist_%1?%[%%l]%[%%filenametoken]
    86                              <2> ..@wllist_%1?%[%%l]%[%%filenametoken]: %2
    87                              <2> %endmacro
    88                              <2> 
    89                              <2> 	%macro patch386 2-3.nolist 1
    90                              <2> %define %%repeat
    91                              <2> %if %3 != 1
    92                              <2>  %define %%repeat r%3_
    93                              <2> %endif
    94                              <2> %ifidn _CURRENT_SECTION, lDEBUG_CODE
    95                              <2>  wllist %[%%repeat]Lpatch_%{1}386_table, %2
    96                              <2> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
    97                              <2>  wllist %[%%repeat]Lpatch_%{1}386_table2, %2
    98                              <2> %elifidn _CURRENT_SECTION, lDEBUG_DATA_ENTRY
    99                              <2>  wllist %[%%repeat]Lpatch_%{1}386_tableentry, %2
   100                              <2> %else
   101                              <2>  %error Wrong section
   102                              <2> %endif
   103                              <2> 	%endmacro
   104                              <2> 
   105                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   106                              <2> 	%macro _386_o32 0-1+.nolist
   107                              <2> _386		o32
   108                              <2> 		%1
   109                              <2> 	%endmacro
   110                              <2> 
   111                              <2> 		; Address size 32-bit prefix if 386+ CPU
   112                              <2> 	%macro _386_a32 0-1+.nolist
   113                              <2> _386		a32
   114                              <2> 		%1
   115                              <2> 	%endmacro
   116                              <2> 
   117                              <2> 		; Short jump if 386+ CPU
   118                              <2> 	%macro _386_jmps 1.nolist
   119                              <2> _386		jmp short %1
   120                              <2> 	%endmacro
   121                              <2> 
   122                              <2> 		; Near jump if 386+ CPU
   123                              <2> 	%macro _386_jmpn 1.nolist
   124                              <2> _386		jmp near %1
   125                              <2> 	%endmacro
   126                              <2> 
   127                              <2> 		; Short jump if no 386+ CPU
   128                              <2> 	%macro _no386_jmps 1.nolist
   129                              <2> _no386		jmp short %1
   130                              <2> 	%endmacro
   131                              <2> 
   132                              <2> 		; Near jump if no 386+ CPU
   133                              <2> 	%macro _no386_jmpn 1.nolist
   134                              <2> _no386		jmp near %1
   135                              <2> 	%endmacro
   136                              <2> 
   137                              <2> 		; Instruction if 386+ CPU
   138                              <2> 	%macro _386 0-1+.nolist
   139                              <2> [cpu 386]			; change CPU type
   140                              <2> %%entry:
   141                              <2> 		%1		; write instruction
   142                              <2> __CPU__				; reset CPU type
   143                              <2> %assign %%length ($ - %%entry)
   144                              <2>  patch386 no, equ %%entry, %%length
   145                              <2> 	%endmacro
   146                              <2> 
   147                              <2> 		; Instruction if no 386+ CPU
   148                              <2> 	%macro _no386 0-1+.nolist
   149                              <2> %%entry:
   150                              <2> 		%1		; write instruction
   151                              <2> %assign %%length ($ - %%entry)
   152                              <2>  patch386 , equ %%entry, %%length
   153                              <2> 	%endmacro
   154                              <2> 
   155                              <2> %else
   156                              <2> 	%macro patch386 2+.nolist
   157                              <2> %ifidn _CURRENT_SECTION, lDEBUG_CODE
   158                              <2>  %define PATCH_%{1}386_TABLE %[PATCH_%{1}386_TABLE], %2
   159                              <2> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
   160                              <2>  %define PATCH_%{1}386_TABLE2 %[PATCH_%{1}386_TABLE2], %2
   161                              <2> %elifidn _CURRENT_SECTION, lDEBUG_DATA_ENTRY
   162                              <2>  %define PATCH_%{1}386_TABLEENTRY %[PATCH_%{1}386_TABLEENTRY], %2
   163                              <2> %else
   164                              <2>  %error Wrong section
   165                              <2> %endif
   166                              <2> 	%endmacro
   167                              <2> 
   168                              <2> %if _WPT_LABELS
   169                              <2> 	; These forms provide verbose info by defining a
   170                              <2> 	; meaningful label for each patch. That fills up
   171                              <2> 	; the map file and might take longer though.
   172                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   173                              <2> 	%macro _386_o32 0-1+.nolist
   174                              <2> %%386_o32:	o32
   175                              <2> patch386 NO, %%386_o32
   176                              <2> 		%1
   177                              <2> 	%endmacro
   178                              <2> 
   179                              <2> 		; Address size 32-bit prefix if 386+ CPU
   180                              <2> 	%macro _386_a32 0-1+.nolist
   181                              <2> %%386_a32:	a32
   182                              <2> patch386 NO, %%386_a32
   183                              <2> 		%1
   184                              <2> 	%endmacro
   185                              <2> 
   186                              <2> 		; Short jump if 386+ CPU
   187                              <2> 	%macro _386_jmps 1.nolist
   188                              <2> %%386_jmps:	jmp short %1
   189                              <2> patch386 NO, %%386_jmps,%%386_jmps+1
   190                              <2> 	%endmacro
   191                              <2> 
   192                              <2> 		; Near jump if 386+ CPU
   193                              <2> 	%macro _386_jmpn 1.nolist
   194                              <2> %%386_jmpn:	jmp near %1
   195                              <2> patch386 NO, %%386_jmpn,%%386_jmpn+1,%%386_jmpn+2
   196                              <2> 	%endmacro
   197                              <2> 
   198                              <2> 		; Short jump if no 386+ CPU
   199                              <2> 	%macro _no386_jmps 1.nolist
   200                              <2> %%no386_jmps:	jmp short %1
   201                              <2> patch386 , %%no386_jmps,%%no386_jmps+1
   202                              <2> 	%endmacro
   203                              <2> 
   204                              <2> 		; Near jump if no 386+ CPU
   205                              <2> 	%macro _no386_jmpn 1.nolist
   206                              <2> %%no386_jmpn:	jmp near %1
   207                              <2> patch386 , %%no386_jmpn,%%no386_jmpn+1,%%no386_jmpn+2
   208                              <2> 	%endmacro
   209                              <2> 
   210                              <2> 		; Instruction if 386+ CPU
   211                              <2> 	%macro _386 0-1+.nolist
   212                              <2> [cpu 386]			; change CPU type
   213                              <2> %%386_instr:	%1		; write instruction
   214                              <2> __CPU__				; reset CPU type
   215                              <2> 
   216                              <2> %assign %%INSTRCOUNT 0
   217                              <2> %rep $-%%386_instr		; count size of instruction
   218                              <2>  patch386 NO, %%386_instr+%[%%INSTRCOUNT]
   219                              <2> 				; write a patch for each byte
   220                              <2>  %assign %%INSTRCOUNT %%INSTRCOUNT+1
   221                              <2> %endrep
   222                              <2> %undef %%INSTRCOUNT
   223                              <2> 	%endmacro
   224                              <2> 
   225                              <2> 		; Instruction if no 386+ CPU
   226                              <2> 	%macro _no386 0-1+.nolist
   227                              <2> %%no386_instr:	%1		; write instruction
   228                              <2> 
   229                              <2> %assign %%INSTRCOUNT 0
   230                              <2> %rep $-%%no386_instr		; count size of instruction
   231                              <2>  patch386 , %%no386_instr+%[%%INSTRCOUNT]
   232                              <2> 				; write a patch for each byte
   233                              <2>  %assign %%INSTRCOUNT %%INSTRCOUNT+1
   234                              <2> %endrep
   235                              <2> %undef %%INSTRCOUNT
   236                              <2> 	%endmacro
   237                              <2> %else	; _WPT_LABELS
   238                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   239                              <2> 	%macro _386_o32 0-1+.nolist
   240                              <2> _386		o32
   241                              <2> 		%1
   242                              <2> 	%endmacro
   243                              <2> 
   244                              <2> 		; Address size 32-bit prefix if 386+ CPU
   245                              <2> 	%macro _386_a32 0-1+.nolist
   246                              <2> _386		a32
   247                              <2> 		%1
   248                              <2> 	%endmacro
   249                              <2> 
   250                              <2> 		; Short jump if 386+ CPU
   251                              <2> 	%macro _386_jmps 1.nolist
   252                              <2> _386		jmp short %1
   253                              <2> 	%endmacro
   254                              <2> 
   255                              <2> 		; Near jump if 386+ CPU
   256                              <2> 	%macro _386_jmpn 1.nolist
   257                              <2> _386		jmp near %1
   258                              <2> 	%endmacro
   259                              <2> 
   260                              <2> 		; Short jump if no 386+ CPU
   261                              <2> 	%macro _no386_jmps 1.nolist
   262                              <2> _no386		jmp short %1
   263                              <2> 	%endmacro
   264                              <2> 
   265                              <2> 		; Near jump if no 386+ CPU
   266                              <2> 	%macro _no386_jmpn 1.nolist
   267                              <2> _no386		jmp near %1
   268                              <2> 	%endmacro
   269                              <2> 
   270                              <2> 		; Instruction if 386+ CPU
   271                              <2> 	%macro _386 0-1+.nolist
   272                              <2> %push
   273                              <2> [cpu 386]			; change CPU type
   274                              <2> %assign %$entry $ + _CURRENT_SECTION %+ FIXUP
   275                              <2> 		%1		; write instruction
   276                              <2> __CPU__				; reset CPU type
   277                              <2> 
   278                              <2> %rep ($ + _CURRENT_SECTION %+ FIXUP) - %$entry
   279                              <2> 				; count size of instruction
   280                              <2>  patch386 NO, %[%$entry]	; write a patch for each byte
   281                              <2>  %assign %$entry %$entry+1
   282                              <2> %endrep
   283                              <2> %pop
   284                              <2> 	%endmacro
   285                              <2> 
   286                              <2> 		; Instruction if no 386+ CPU
   287                              <2> 	%macro _no386 0-1+.nolist
   288                              <2> %push
   289                              <2> %assign %$entry $ + _CURRENT_SECTION %+ FIXUP
   290                              <2> 		%1		; write instruction
   291                              <2> 
   292                              <2> %rep ($ + _CURRENT_SECTION %+ FIXUP) - %$entry
   293                              <2> 				; count size of instruction
   294                              <2>  patch386 , %[%$entry]		; write a patch for each byte
   295                              <2>  %assign %$entry %$entry+1
   296                              <2> %endrep
   297                              <2> %pop
   298                              <2> 	%endmacro
   299                              <2> %endif	; _WPT_LABELS
   300                              <2> %endif	; _LINK
   301                              <2> 
   302                              <2> %endif
   303                              <2> 
   304                              <2> 		; Patch macros but for cases where the 386+
   305                              <2> 		; instructions should only be generated for
   306                              <2> 		; DEBUGX (i.e. for 32-bit DPMI addressing code).
   307                              <2> %if _PM
   308                              <2> %define _386_PM_o32	_386_o32
   309                              <2> %define _386_PM_a32	_386_a32
   310                              <2> %define _386_PM_jmps	_386_jmps
   311                              <2> %define _386_PM_jmpn	_386_jmpn
   312                              <2> %define _386_PM		_386
   313                              <2> %else
   314                              <2> %define _386_PM_o32
   315                              <2> %define _386_PM_a32
   316                              <2> %define _386_PM_jmps	comment
   317                              <2> %define _386_PM_jmpn	comment
   318                              <2> %define _386_PM		comment
   319                              <2> %endif
   320                              <2> 
   321                              <2> 
   322                              <2> %ifn _LINK
   323                              <2> %macro __writepatchtable2 0-*.nolist
   324                              <2> %if %0 & 1
   325                              <2>  %fatal Expected even number of arguments
   326                              <2> %endif
   327                              <2> %rep %0 >> 1
   328                              <2> 	%1 %2
   329                              <2> %rotate 2
   330                              <2> %endrep
   331                              <2> %endmacro
   332                              <2> 
   333                              <2> %macro __patchtable2_entry 0.nolist
   334                              <2>   ; only if this isn't the first (pseudo-)entry
   335                              <2>   %if %$lastcount != 0
   336                              <2>     %assign %$runscount %[%$runscount]+1
   337                              <2>    ; if the offset from %$previous is less than 255
   338                              <2>    %if (%$last-%$previous) < 255
   339                              <2>     %assign %$$method2tablesize %$$method2tablesize+1
   340                              <2>     ; then write a single byte (number of bytes not to patch between)
   341                              <2>     %xdefine %$$method2list %$$method2list,db,%$last-%$previous
   342                              <2>    %else
   343                              <2>     ; otherwise write a 255 ("reposition") and write the 16-bit address afterwards
   344                              <2>     %assign %$$method2tablesize %$$method2tablesize+3
   345                              <2>     %xdefine %$$method2list %$$method2list,db,255,dw,%$last
   346                              <2>     %assign %$reposcount %[%$reposcount]+1
   347                              <2>    %endif
   348                              <2>    %if %$lastcount == 1
   349                              <2>     %assign %$onecount %[%$onecount]+1
   350                              <2>    %endif
   351                              <2>    %assign %$$method2tablesize %$$method2tablesize+1
   352                              <2>    ; and write the number of bytes to be patched
   353                              <2>    %xdefine %$$method2list %$$method2list,db,%$lastcount
   354                              <2>    ; define %$previous for the next entry: it points to the next non-patched byte
   355                              <2>    %define %$previous (%[%$last]+%[%$lastcount])
   356                              <2>   %endif
   357                              <2> %endmacro
   358                              <2> 
   359                              <2> %macro writepatchtable 2-*.nolist
   360                              <2> 
   361                              <2> 	numdef %{1}_FORCE_METHOD, 0
   362                              <2> %push
   363                              <2> 		; Determine length of simple table:
   364                              <2> %assign %$method1tablesize (%0 - 2)*2
   365                              <2> 
   366                              <2> %if !_%{1}_FORCE_METHOD || _%{1}_FORCE_METHOD == 2
   367                              <2> 		; Determine length of complicated table:
   368                              <2> %assign %$method2tablesize 0
   369                              <2> %define %$method2list db,""
   370                              <2> %push
   371                              <2> %if _WPT_LABELS
   372                              <2>  %define %$previous code_start	; if list contains labels
   373                              <2> %else
   374                              <2>  %define %$previous 0
   375                              <2> %endif
   376                              <2> %define %$last %[%$previous]
   377                              <2> %assign %$lastcount 0
   378                              <2> %assign %$onecount 0
   379                              <2> %assign %$reposcount 0
   380                              <2> %assign %$bytescount %0 - 2
   381                              <2> %assign %$runscount 0
   382                              <2> %rotate 1
   383                              <2> %rep %0 - 2
   384                              <2>  %rotate 1
   385                              <2>  ;if  it continues the previous patch   and not too long   and this isn't the first
   386                              <2>  %if ((%$last+%$lastcount) == %1) && (%$lastcount < 255) && (%$lastcount != 0)
   387                              <2>   ; then do not write an entry, just increase the patch's size
   388                              <2>   %assign %$lastcount %[%$lastcount]+1
   389                              <2>  %else
   390                              <2>   ; otherwise write the last entry
   391                              <2>   __patchtable2_entry
   392                              <2>   ; define new %$last to this parameter, %$lastcount to one
   393                              <2>   %define %$last %1
   394                              <2>   %assign %$lastcount 1
   395                              <2>  %endif
   396                              <2> %endrep
   397                              <2> __patchtable2_entry
   398                              <2> 
   399                              <2> ; at the end, there's a patch with offset 0, size 0
   400                              <2> %assign %$$method2tablesize %$$method2tablesize+2
   401                              <2> %xdefine %$$method2list %$$method2list,db,0,db,0
   402                              <2> 
   403                              <2> %assign %$$onecount %$onecount
   404                              <2> %assign %$$reposcount %$reposcount
   405                              <2> %assign %$$bytescount %$bytescount
   406                              <2> %assign %$$runscount %$runscount
   407                              <2> %pop
   408                              <2> %rotate 1
   409                              <2> %endif
   410                              <2> 
   411                              <2> %if _%{1}_FORCE_METHOD == 2
   412                              <2>  %define __%{1}_method 2
   413                              <2> %elif _%{1}_FORCE_METHOD == 1
   414                              <2>  %define __%{1}_method 1
   415                              <2> %else
   416                              <2>  %if _%{1}_FORCE_METHOD
   417                              <2>   %fatal Invalid forced method selected: _%{1}_FORCE_METHOD
   418                              <2>  %endif
   419                              <2>  %if %$method1tablesize > (%$method2tablesize+20)
   420                              <2>   %define __%{1}_method 2
   421                              <2>  %else
   422                              <2>   %define __%{1}_method 1
   423                              <2>  %endif
   424                              <2> %endif
   425                              <2> 
   426                              <2> 
   427                              <2> %1:
   428                              <2> %if __%{1}_method == 2
   429                              <2> 	__writepatchtable2 %$method2list
   430                              <2> 	endarea %1
   431                              <2> %assign %$size %1_size
   432                              <2> %warning %1: %$size bytes (Method 2)
   433                              <2> %warning 1B=%$onecount repo=%$reposcount run=%$runscount byte=%$bytescount
   434                              <2> %else
   435                              <2> %rotate 1
   436                              <2> %rep %0 - 2
   437                              <2> %rotate 1
   438                              <2> 	dw %1
   439                              <2> %endrep
   440                              <2> %rotate 1
   441                              <2> 	endarea %1
   442                              <2> %assign %$size %1_size
   443                              <2> %warning %1: %$size bytes (Method 1)
   444                              <2> %1.amount equ %1_size_w
   445                              <2> %endif
   446                              <2> %pop
   447                              <2> %endmacro
   448                              <2> %endif
   879                              <1> 
   880                              <1> 
   881                              <1> %if _VDD
   882                              <1> ; standard BOPs for communication with DEBXXVDD on NT platforms
   883                              <1> %macro RegisterModule 0.nolist
   884                              <1> 	db 0C4h, 0C4h, 58h, 0
   885                              <1> 	nop
   886                              <1> %endmacro
   887                              <1> %macro UnRegisterModule 0.nolist
   888                              <1> 	db 0C4h, 0C4h, 58h, 1
   889                              <1> 	nop
   890                              <1> %endmacro
   891                              <1> %macro DispatchCall 0.nolist
   892                              <1> 	db 0C4h, 0C4h, 58h, 2
   893                              <1> 	nop
   894                              <1> %endmacro
   895                              <1> %endif
   896                              <1> 
   897                              <1> %assign CODE_INSURE_COUNT 0
   898                              <1> 
   899                              <1> 		; The entry_to_code_seg/_sel dispatcher in lDEBUG_DATA_ENTRY
   900                              <1> 		;  detects mistaken debugger breakpoints in its
   901                              <1> 		;  in-code-parameter by checking for a low-byte
   902                              <1> 		;  value equal to 0CCh (one-byte int3 opcode).
   903                              <1> 		; Therefore, we insure that all destinations jumped to
   904                              <1> 		;  via that dispatcher do not happen to be located
   905                              <1> 		;  on an offset that gives 0CCh in the low byte.
   906                              <1> 	%imacro code_insure_low_byte_not_0CCh 0.nolist
   907                              <1> %ifn _LINK
   908                              <1>  %if (($ - _CURRENT_SECTION %+ _start) & 0FFh) == 0CCh
   909                              <1> 	nop
   910                              <1>   %assign CODE_INSURE_COUNT 1 + CODE_INSURE_COUNT
   911                              <1>  %endif
   912                              <1> %endif
   913                              <1> 	%endmacro
   914                              <1> 
   915                              <1> 
   916                              <1> 		; dual code segments
   917                              <1> %if _DUALCODE && _PM
   918                              <1> 
   919                              <1> %if _DEBUG
   920                              <1> %idefine dualfunction comment
   921                              <1> %else
   922                              <1> %idefine dualfunction code_insure_low_byte_not_0CCh
   923                              <1> %endif
   924                              <1> 
   925                              <1> %idefine dualreturn call _CURRENT_SECTION %+ _dualret_helper
   926                              <1> %idefine dualdistance far
   927                              <1> 	%imacro dualcall 1.nolist
   928                              <1> %ifndef SECTION_OF_%1
   929                              <1>  %error Unknown target section for symbol %1
   930                              <1> %endif
   931                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _dualcall_helper
   932                              <1>  %if _DEBUG
   933                              <1> 	jmp strict short %%skipdata
   934                              <1>  %endif
   935                              <1> 	dw %1
   936                              <1> %%skipdata:
   937                              <1> 	%endmacro
   938                              <1> 	%imacro nearcall 1.nolist
   939                              <1> %ifndef SECTION_OF_%1
   940                              <1>  %error Unknown target section for symbol %1
   941                              <1> %endif
   942                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
   943                              <1> 	call %1
   944                              <1> %else
   945                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _nearcall_helper
   946                              <1>  %if _DEBUG
   947                              <1> 	jmp strict short %%skipdata
   948                              <1>  %endif
   949                              <1> 	dw %1
   950                              <1> %%skipdata:
   951                              <1> %endif
   952                              <1> 	%endmacro
   953                              <1> 
   954                              <1> %elif _DUALCODE && ! _PM
   955                              <1> 
   956                              <1> %idefine dualfunction comment
   957                              <1> %idefine dualreturn
   958                              <1> %idefine dualdistance far
   959                              <1> 
   960                              <1> %ifn _LINK
   961                              <1> %define PATCH_RELOCATE_FROM_lDEBUG_CODE ""
   962                              <1> %define PATCH_RELOCATE_FROM_lDEBUG_CODE2 ""
   963                              <1> 	%imacro dualcall 1.nolist
   964                              <1> %ifndef SECTION_OF_%1
   965                              <1>  %error Unknown target section for symbol %1
   966                              <1> %endif
   967                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
   968                              <1> 	push cs
   969                              <1> 	call %1
   970                              <1> %else
   971                              <1> 	call relocatedzero:%1
   972                              <1> %push
   973                              <1> %assign %$entry ($ + _CURRENT_SECTION %+ FIXUP) - 2
   974                              <1> 	relocatelist _CURRENT_SECTION, %$entry
   975                              <1> %pop
   976                              <1> %endif
   977                              <1> 	%endmacro
   978                              <1> 	%imacro relocatelist 2.nolist
   979                              <1>  %define PATCH_RELOCATE_FROM_%1 %[PATCH_RELOCATE_FROM_%1],%2
   980                              <1> 	%endmacro
   981                              <1> %else		; _LINK
   982                              <1> 	%idefine dualcall dualcall_with_filename __FILE__,
   983                              <1> 	%imacro dualcall_with_filename 2.nolist
   984                              <1> %ifndef SECTION_OF_%2
   985                              <1>  %error Unknown target section for symbol %2
   986                              <1> %endif
   987                              <1> %ifidni %[SECTION_OF_%2], _CURRENT_SECTION
   988                              <1> 	push cs
   989                              <1> 	call %2
   990                              <1> %else
   991                              <1> 	call relocatedzero:%2
   992                              <1> %ifidn _CURRENT_SECTION, lDEBUG_CODE
   993                              <1>  wllist Lrelocate_from_code, equ $ - 2, %1
   994                              <1> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
   995                              <1>  wllist Lrelocate_from_code2, equ $ - 2, %1
   996                              <1> %else
   997                              <1>  %error Wrong section
   998                              <1> %endif
   999                              <1> %endif
  1000                              <1> 	%endmacro
  1001                              <1> %endif		; _LINK
  1002                              <1>  %if _DUALCODENEARDUAL
  1003                              <1> 
  1004                              <1> %if _LINK
  1005                              <1> 	%idefine nearcall nearcall_with_filename __FILE__,
  1006                              <1> 	%imacro nearcall_with_filename 2
  1007                              <1> %ifndef SECTION_OF_%2
  1008                              <1>  %error Unknown target section for symbol %2
  1009                              <1> %endif
  1010                              <1> %ifidni %[SECTION_OF_%2], _CURRENT_SECTION
  1011                              <1> 	call %2
  1012                              <1> %else
  1013                              <1>  %push
  1014                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1015                              <1>  %xdefine %$targetsection SECTION_OF_%2
  1016                              <1>  %deftok %%filenametoken SOURCEFILENAME
  1017                              <1>   %ifndef NEARCALL_THUNK_TO_%2%[%%filenametoken]
  1018                              <1> 	hiddenusesection %$targetsection
  1019                              <1> %define NEARCALL_THUNK_TO_%2%[%%filenametoken] %%nearcall_thunk_to_%2%[%%filenametoken]
  1020                              <1> section_of %%nearcall_thunk_to_%2%[%%filenametoken]
  1021                              <1> dualfunction
  1022                              <1> %%nearcall_thunk_to_%2%[%%filenametoken]:
  1023                              <1> 	call %2
  1024                              <1> 	dualreturn
  1025                              <1> 	retf
  1026                              <1> 
  1027                              <1> 	hiddenusesection %$originalsection
  1028                              <1>   %endif
  1029                              <1>  %pop
  1030                              <1> 	dualcall_with_filename %1, NEARCALL_THUNK_TO_%2%[%%filenametoken]
  1031                              <1> %endif
  1032                              <1> 	%endmacro
  1033                              <1> %elif _LINK_COMPAT	; _LINK
  1034                              <1> 	%imacro nearcall 1
  1035                              <1> %ifndef SECTION_OF_%1
  1036                              <1>  %error Unknown target section for symbol %1
  1037                              <1> %endif
  1038                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1039                              <1> 	call %1
  1040                              <1> %else
  1041                              <1>  %push
  1042                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1043                              <1>  %xdefine %$targetsection SECTION_OF_%1
  1044                              <1>  %deftok %%filenametoken SOURCEFILENAME
  1045                              <1>   %ifndef NEARCALL_THUNK_TO_%1%[%%filenametoken]
  1046                              <1> 	hiddenusesection %$targetsection
  1047                              <1> %define NEARCALL_THUNK_TO_%1%[%%filenametoken] %%nearcall_thunk_to_%1%[%%filenametoken]
  1048                              <1> section_of %%nearcall_thunk_to_%1%[%%filenametoken]
  1049                              <1> dualfunction
  1050                              <1> %%nearcall_thunk_to_%1%[%%filenametoken]:
  1051                              <1> 	call %1
  1052                              <1> 	dualreturn
  1053                              <1> 	retf
  1054                              <1> 
  1055                              <1> 	hiddenusesection %$originalsection
  1056                              <1>   %endif
  1057                              <1>  %pop
  1058                              <1> 	dualcall NEARCALL_THUNK_TO_%1%[%%filenametoken]
  1059                              <1> %endif
  1060                              <1> 	%endmacro
  1061                              <1> %else		; _LINK, _LINK_COMPAT
  1062                              <1> 	%imacro nearcall 1
  1063                              <1> %ifndef SECTION_OF_%1
  1064                              <1>  %error Unknown target section for symbol %1
  1065                              <1> %endif
  1066                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1067                              <1> 	call %1
  1068                              <1> %else
  1069                              <1>  %push
  1070                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1071                              <1>  %xdefine %$targetsection SECTION_OF_%1
  1072                              <1>   %ifndef NEARCALL_THUNK_TO_%1
  1073                              <1> 	hiddenusesection %$targetsection
  1074                              <1> %define NEARCALL_THUNK_TO_%1 %%nearcall_thunk_to_%1
  1075                              <1> section_of %%nearcall_thunk_to_%1
  1076                              <1> dualfunction
  1077                              <1> %%nearcall_thunk_to_%1:
  1078                              <1> 	call %1
  1079                              <1> 	dualreturn
  1080                              <1> 	retf
  1081                              <1> 
  1082                              <1> 	hiddenusesection %$originalsection
  1083                              <1>   %endif
  1084                              <1>  %pop
  1085                              <1> 	dualcall NEARCALL_THUNK_TO_%1
  1086                              <1> %endif
  1087                              <1> 	%endmacro
  1088                              <1> %endif		; _LINK, _LINK_COMPAT
  1089                              <1>  %else
  1090                              <1> 	%imacro nearcall 1.nolist
  1091                              <1> %ifndef SECTION_OF_%1
  1092                              <1>  %error Unknown target section for symbol %1
  1093                              <1> %endif
  1094                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1095                              <1> 	call %1
  1096                              <1> %else
  1097                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _nearcall_helper
  1098                              <1>  %if _DEBUG
  1099                              <1> 	jmp strict short %%skipdata
  1100                              <1>  %endif
  1101                              <1> 	dw %1
  1102                              <1> %%skipdata:
  1103                              <1> %endif
  1104                              <1> 	%endmacro
  1105                              <1>  %endif
  1106                              <1> %elif ! _DUALCODE
  1107                              <1> 
  1108                              <1> %idefine dualfunction comment
  1109                              <1> %idefine dualreturn
  1110                              <1> %idefine dualdistance near
  1111                              <1> 	%imacro dualcall 1.nolist
  1112                              <1> 	call %1
  1113                              <1> 	%endmacro
  1114                              <1> 	%imacro nearcall 1.nolist
  1115                              <1> 	call %1
  1116                              <1> 	%endmacro
  1117                              <1> %assign _SYMBOLICDUALCODE 0
  1118                              <1> %assign _SYMBOLASMDUALCODE 0
  1119                              <1> 
  1120                              <1> %else
  1121                              <1>  %error Unexpected defines
  1122                              <1> %endif
  1123                              <1> 
  1124                              <1> %ifn _SYMBOLICDUALCODE
  1125                              <1>  %assign _SYMBOLASMDUALCODE 0
  1126                              <1> %endif
  1127                              <1> 
  1128                              <1>  %if _SYMBOLIC && _DUALCODE && _SYMBOLASMDUALCODE
  1129                              <1> %idefine dual2function	dualfunction
  1130                              <1> %idefine dual2return	dualreturn
  1131                              <1> %idefine dual2distance	dualdistance
  1132                              <1> %idefine dual2call	dualcall
  1133                              <1>  %else
  1134                              <1> %idefine dual2function comment
  1135                              <1> %idefine dual2return
  1136                              <1> %idefine dual2distance near
  1137                              <1> 	%imacro dual2call 1.nolist
  1138                              <1> 	call %1
  1139                              <1> 	%endmacro
  1140                              <1>  %endif
  1141                              <1> 
  1142                              <1> 
  1143                              <1> 	numdef CHECKSECTION, 0
  1144                              <1> 	numdef CHECKCALLSECTION, _CHECKSECTION
  1145                              <1> 	numdef CHECKJMPSECTION, _CHECKSECTION
  1146                              <1> 	numdef CHECKJCCSECTION, _CHECKSECTION
  1147                              <1> 
  1148                              <1> %if _CHECKCALLSECTION
  1149                              <1> 	%imacro call 1.nolist
  1150                              <1> 	%? %1
  1151                              <1> checksection %1, %?, call
  1152                              <1> 	%endmacro
  1153                              <1> %endif
  1154                              <1> %if _CHECKJMPSECTION
  1155                              <1> 	%imacro jmp 1.nolist
  1156                              <1> 	%? %1
  1157                              <1> checksection %1, %?, jmp
  1158                              <1> 	%endmacro
  1159                              <1> %endif
  1160                              <1> %if _CHECKJCCSECTION
  1161                              <1> 	%imacro je 1.nolist
  1162                              <1> 	%? %1
  1163                              <1> checksection %1, %?, jcc
  1164                              <1> 	%endmacro
  1165                              <1> 	%imacro jne 1.nolist
  1166                              <1> 	%? %1
  1167                              <1> checksection %1, %?, jcc
  1168                              <1> 	%endmacro
  1169                              <1> 	%imacro jz 1.nolist
  1170                              <1> 	%? %1
  1171                              <1> checksection %1, %?, jcc
  1172                              <1> 	%endmacro
  1173                              <1> 	%imacro jnz 1.nolist
  1174                              <1> 	%? %1
  1175                              <1> checksection %1, %?, jcc
  1176                              <1> 	%endmacro
  1177                              <1> 
  1178                              <1> 	%imacro jb 1.nolist
  1179                              <1> 	%? %1
  1180                              <1> checksection %1, %?, jcc
  1181                              <1> 	%endmacro
  1182                              <1> 	%imacro jnb 1.nolist
  1183                              <1> 	%? %1
  1184                              <1> checksection %1, %?, jcc
  1185                              <1> 	%endmacro
  1186                              <1> 	%imacro jbe 1.nolist
  1187                              <1> 	%? %1
  1188                              <1> checksection %1, %?, jcc
  1189                              <1> 	%endmacro
  1190                              <1> 	%imacro jnbe 1.nolist
  1191                              <1> 	%? %1
  1192                              <1> checksection %1, %?, jcc
  1193                              <1> 	%endmacro
  1194                              <1> 	%imacro jc 1.nolist
  1195                              <1> 	%? %1
  1196                              <1> checksection %1, %?, jcc
  1197                              <1> 	%endmacro
  1198                              <1> 	%imacro jnc 1.nolist
  1199                              <1> 	%? %1
  1200                              <1> checksection %1, %?, jcc
  1201                              <1> 	%endmacro
  1202                              <1> 	%imacro ja 1.nolist
  1203                              <1> 	%? %1
  1204                              <1> checksection %1, %?, jcc
  1205                              <1> 	%endmacro
  1206                              <1> 	%imacro jna 1.nolist
  1207                              <1> 	%? %1
  1208                              <1> checksection %1, %?, jcc
  1209                              <1> 	%endmacro
  1210                              <1> 	%imacro jae 1.nolist
  1211                              <1> 	%? %1
  1212                              <1> checksection %1, %?, jcc
  1213                              <1> 	%endmacro
  1214                              <1> 	%imacro jnae 1.nolist
  1215                              <1> 	%? %1
  1216                              <1> checksection %1, %?, jcc
  1217                              <1> 	%endmacro
  1218                              <1> 
  1219                              <1> 	%imacro jl 1.nolist
  1220                              <1> 	%? %1
  1221                              <1> checksection %1, %?, jcc
  1222                              <1> 	%endmacro
  1223                              <1> 	%imacro jnl 1.nolist
  1224                              <1> 	%? %1
  1225                              <1> checksection %1, %?, jcc
  1226                              <1> 	%endmacro
  1227                              <1> 	%imacro jle 1.nolist
  1228                              <1> 	%? %1
  1229                              <1> checksection %1, %?, jcc
  1230                              <1> 	%endmacro
  1231                              <1> 	%imacro jnle 1.nolist
  1232                              <1> 	%? %1
  1233                              <1> checksection %1, %?, jcc
  1234                              <1> 	%endmacro
  1235                              <1> 	%imacro jg 1.nolist
  1236                              <1> 	%? %1
  1237                              <1> checksection %1, %?, jcc
  1238                              <1> 	%endmacro
  1239                              <1> 	%imacro jng 1.nolist
  1240                              <1> 	%? %1
  1241                              <1> checksection %1, %?, jcc
  1242                              <1> 	%endmacro
  1243                              <1> 	%imacro jge 1.nolist
  1244                              <1> 	%? %1
  1245                              <1> checksection %1, %?, jcc
  1246                              <1> 	%endmacro
  1247                              <1> 	%imacro jnge 1.nolist
  1248                              <1> 	%? %1
  1249                              <1> checksection %1, %?, jcc
  1250                              <1> 	%endmacro
  1251                              <1> 
  1252                              <1> 	%imacro jo 1.nolist
  1253                              <1> 	%? %1
  1254                              <1> checksection %1, %?, jcc
  1255                              <1> 	%endmacro
  1256                              <1> 	%imacro jno 1.nolist
  1257                              <1> 	%? %1
  1258                              <1> checksection %1, %?, jcc
  1259                              <1> 	%endmacro
  1260                              <1> 	%imacro jp 1.nolist
  1261                              <1> 	%? %1
  1262                              <1> checksection %1, %?, jcc
  1263                              <1> 	%endmacro
  1264                              <1> 	%imacro jnp 1.nolist
  1265                              <1> 	%? %1
  1266                              <1> checksection %1, %?, jcc
  1267                              <1> 	%endmacro
  1268                              <1> 	%imacro jpe 1.nolist
  1269                              <1> 	%? %1
  1270                              <1> checksection %1, %?, jcc
  1271                              <1> 	%endmacro
  1272                              <1> 	%imacro jnpe 1.nolist
  1273                              <1> 	%? %1
  1274                              <1> checksection %1, %?, jcc
  1275                              <1> 	%endmacro
  1276                              <1> 	%imacro jpo 1.nolist
  1277                              <1> 	%? %1
  1278                              <1> checksection %1, %?, jcc
  1279                              <1> 	%endmacro
  1280                              <1> 	%imacro jnpo 1.nolist
  1281                              <1> 	%? %1
  1282                              <1> checksection %1, %?, jcc
  1283                              <1> 	%endmacro
  1284                              <1> 	%imacro js 1.nolist
  1285                              <1> 	%? %1
  1286                              <1> checksection %1, %?, jcc
  1287                              <1> 	%endmacro
  1288                              <1> 	%imacro jns 1.nolist
  1289                              <1> 	%? %1
  1290                              <1> checksection %1, %?, jcc
  1291                              <1> 	%endmacro
  1292                              <1> 
  1293                              <1> 	%imacro jcxz 1.nolist
  1294                              <1> 	%? %1
  1295                              <1> checksection %1, %?, jcc
  1296                              <1> 	%endmacro
  1297                              <1> 	%imacro jecxz 1.nolist
  1298                              <1> 	%? %1
  1299                              <1> checksection %1, %?, jcc
  1300                              <1> 	%endmacro
  1301                              <1> 	%imacro loop 1.nolist
  1302                              <1> 	%? %1
  1303                              <1> checksection %1, %?, jcc
  1304                              <1> 	%endmacro
  1305                              <1> 	%imacro loopz 1.nolist
  1306                              <1> 	%? %1
  1307                              <1> checksection %1, %?, jcc
  1308                              <1> 	%endmacro
  1309                              <1> 	%imacro loopnz 1.nolist
  1310                              <1> 	%? %1
  1311                              <1> checksection %1, %?, jcc
  1312                              <1> 	%endmacro
  1313                              <1> 	%imacro loope 1.nolist
  1314                              <1> 	%? %1
  1315                              <1> checksection %1, %?, jcc
  1316                              <1> 	%endmacro
  1317                              <1> 	%imacro loopne 1.nolist
  1318                              <1> 	%? %1
  1319                              <1> checksection %1, %?, jcc
  1320                              <1> 	%endmacro
  1321                              <1> %endif
  1322                              <1> 
  1323                              <1> 	%imacro checksection 3.nolist
  1324                              <1> %push
  1325                              <1>  %defstr %$string %1
  1326                              <1>  %substr %$shortword %$string 1, 5
  1327                              <1>  %substr %$shortsep %$string 6, 1
  1328                              <1>  %substr %$nearword %$string 1, 4
  1329                              <1>  %substr %$nearsep %$string 5, 1
  1330                              <1>  %substr %$farword %$string 1, 3
  1331                              <1>  %substr %$farsep %$string 4, 1
  1332                              <1>  %assign %$isshort 0
  1333                              <1>  %ifidni %$shortword, "short"
  1334                              <1>   %if %$shortsep == 32 || %$shortsep == 9
  1335                              <1>    %assign %$isshort 1
  1336                              <1>    %substr %$string %$string 7, -1
  1337                              <1>   %elif %$shortsep == '['
  1338                              <1>    %assign %$isshort 1
  1339                              <1>    %substr %$string %$string 6, -1
  1340                              <1>   %endif
  1341                              <1>  %endif
  1342                              <1>  %assign %$isnear 0
  1343                              <1>  %ifidni %$nearword, "near"
  1344                              <1>   %if %$nearsep == 32 || %$nearsep == 9
  1345                              <1>    %assign %$isnear 1
  1346                              <1>    %substr %$string %$string 6, -1
  1347                              <1>   %elif %$nearsep == '['
  1348                              <1>    %assign %$isnear 1
  1349                              <1>    %substr %$string %$string 5, -1
  1350                              <1>   %endif
  1351                              <1>  %endif
  1352                              <1>  %assign %$isfar 0
  1353                              <1>  %ifidni %$farword, "far"
  1354                              <1>   %if %$farsep == 32 || %$farsep == 9
  1355                              <1>    %assign %$isfar 1
  1356                              <1>    %substr %$string %$string 5, -1
  1357                              <1>   %elif %$farsep == '['
  1358                              <1>    %assign %$isfar 1
  1359                              <1>    %substr %$string %$string 4, -1
  1360                              <1>   %endif
  1361                              <1>  %endif
  1362                              <1> 
  1363                              <1>  %deftok %$token %$string
  1364                              <1> 
  1365                              <1>  %assign %$size 2
  1366                              <1>  %assign %$isreg 0
  1367                              <1>  %assign %$exit 0
  1368                              <1>  %rep 2
  1369                              <1>   %ifn %$exit
  1370                              <1>    %if %$size == 2
  1371                              <1>     %define %$regnames "ax  cx  dx  bx  sp  bp  si  di  "
  1372                              <1>    %elif %$size == 4
  1373                              <1>     %define %$regnames "eax ecx edx ebx esp ebp esi edi "
  1374                              <1>    %endif
  1375                              <1>    %assign %$index 0
  1376                              <1>    %rep 8
  1377                              <1>     %ifn %$exit
  1378                              <1>      %substr %$reg %$regnames %$index * 4 + 1, 4
  1379                              <1>      %deftok %$reg %$reg
  1380                              <1>      %ifnempty %$reg
  1381                              <1>       %ifidni %$reg, %$token
  1382                              <1>        %assign %$isreg %$size
  1383                              <1>        %assign %$exit 1
  1384                              <1>        %exitrep
  1385                              <1>       %endif
  1386                              <1>      %endif
  1387                              <1>     %endif
  1388                              <1>     %assign %$index %$index + 1
  1389                              <1>    %endrep
  1390                              <1>    %if %$exit
  1391                              <1>     %exitrep
  1392                              <1>    %endif
  1393                              <1>    %assign %$size %$size * 2
  1394                              <1>   %endif
  1395                              <1>  %endrep
  1396                              <1> 
  1397                              <1>  %assign %$ismulti 0
  1398                              <1>  %assign %$ismem 0
  1399                              <1>  %strlen %$length %$string
  1400                              <1>  %assign %$ii 0
  1401                              <1>  %rep %$length
  1402                              <1>   %substr %$point %$string %$ii + 1, 1
  1403                              <1>   %if %$point == 32 || %$point == 9
  1404                              <1>    %assign %$ismulti 1
  1405                              <1>   %endif
  1406                              <1>   %ifidn %$point, '['
  1407                              <1>    %assign %$ismem 1
  1408                              <1>   %endif
  1409                              <1>   %assign %$ii %$ii + 1
  1410                              <1>  %endrep
  1411                              <1> 
  1412                              <1>  %assign %$islocal 0
  1413                              <1>  %substr %$point %$string 1, 1
  1414                              <1>  %substr %$prefix %$string 1, 3
  1415                              <1>  %ifidn %$point, '.'
  1416                              <1>   %ifnidn %$prefix, '..@'
  1417                              <1>    %assign %$islocal 1
  1418                              <1>   %endif
  1419                              <1>  %endif
  1420                              <1> 
  1421                              <1>  %if %$isreg
  1422                              <1>   %if %$isreg == 4
  1423                              <1>    %warning 32-bit reg %3: %2 %1
  1424                              <1>   %else
  1425                              <1>    %warning 16-bit reg %3: %2 %1
  1426                              <1>   %endif
  1427                              <1>  %elif %$ismulti || %$ismem
  1428                              <1>   %warning not single %3: %2 %1
  1429                              <1>  %elif %$islocal
  1430                              <1>   %ifidni %3, call
  1431                              <1>    %warning local %3: %2 %1
  1432                              <1>   %endif
  1433                              <1>  %elifdef SECTION_OF_%[%$token]
  1434                              <1>   %ifnidni SECTION_OF_%[%$token], _CURRENT_SECTION
  1435                              <1>    %error Symbol %$token called wrongly: section_of=SECTION_OF_%[%$token], current=_CURRENT_SECTION
  1436                              <1>   %endif
  1437                              <1>  %endif
  1438                              <1> %pop
  1439                              <1> 	%endmacro
  1440                              <1> 
  1441                              <1> 
  1442                              <1> 	struc MEMREF
  1443 00000000 ????????            <1> mrLinear:		resd 1
  1444 00000004 ????????            <1> mrOffset:		resd 1
  1445 00000008 ????                <1> mrSegmentSelector:	resw 1
  1446 0000000A ????                <1> mrFlags:		resw 1
  1447 0000000C ????????            <1> mrLength:		resd 1
  1448                              <1> 	endstruc
  1449                              <1> 
  1450                              <1> 		; Currently only direct branches are allowed when
  1451                              <1> 		;  disassembling from the U command. (That is,
  1452                              <1> 		;  [disflags] & DIS_F_SHOW is clear.) All other
  1453                              <1> 		;  types of references depend on segment registers
  1454                              <1> 		;  and sometimes base and index registers, which are
  1455                              <1> 		;  not known ahead of time. They are only known for
  1456                              <1> 		;  the R command's disassembly. (DIS_F_SHOW set.)
  1457                              <1> 		; (When a mov ss or pop to ss will change ss, a
  1458                              <1> 		;  subsequent instruction using ss will not be
  1459                              <1> 		;  disassembled with the correct ss value.
  1460                              <1> 		;  This should be rare though. We may at a later
  1461                              <1> 		;  point detect this condition and not display
  1462                              <1> 		;  references with ss then.)
  1463                              <1> mrfBranchDirect:	equ    1
  1464                              <1> mrfMem:			equ    2
  1465                              <1> mrfMemSource:		equ    4
  1466                              <1> mrfMemDest:		equ    8
  1467                              <1> mrfA32:			equ   10h
  1468                              <1> mrfString:		equ   20h
  1469                              <1> mrfStringSource:	equ   40h
  1470                              <1> mrfStringDest:		equ   80h
  1471                              <1> mrfUsesSS:		equ  100h
  1472                              <1> mrfBranchIndirect:	equ  200h
  1473                              <1> 
  1474                              <1> 
  1475                              <1> %if _VXCHG && ! _VXCHGBIOS
  1476                              <1> 	struc XMSM
  1477 00000000 ????????            <1> .size_:		resd 1
  1478 00000004 ????                <1> .srchdl:	resw 1
  1479 00000006 ????????            <1> .srcadr:	resd 1
  1480 0000000A ????                <1> .dsthdl:	resw 1
  1481 0000000C ????????            <1> .dstadr:	resd 1
  1482                              <1> 	endstruc
  1483                              <1> %endif
  1484                              <1> 
  1485                              <1> 
  1486                              <1> 	; doscall is used by symbols.asm and run.asm and in
  1487                              <1> 	;  cmd3_close_handle, so define it prior
  1488                              <1> %if _PM && _NOEXTENDER
  1489                              <1> %macro doscall 0
  1490                              <1> 	nearcall _doscall
  1491                              <1> %endmacro
  1492                              <1> %else
  1493                              <1> 		; When we don't support non-extended DPMI all Int21 calls
  1494                              <1> 		; are either in Real Mode or extended (all are real Int21
  1495                              <1> 		; instructions).
  1496                              <1> %macro doscall 0
  1497                              <1> 	int 21h
  1498                              <1> %endmacro
  1499                              <1> %endif
  1500                              <1> 
  1501                              <1> 
  1502                              <1> %if _LINK
  1503                              <1> %imacro wlcalc 1-2.nolist
  1504                              <1> %deftok %%filenametoken __FILE__
  1505                              <1>  global wlcalc_%1?%[%%l]%[%%filenametoken]
  1506                              <1> wlcalc_%1?%[%%l]%[%%filenametoken]: %2
  1507                              <1> %endmacro
  1508                              <1> %endif
  1509                              <1> 
  1510                              <1> %if _BOOTLDR && _LINK
  1511                              <1> %macro lot_equate 2.nolist
  1512                              <1> LOAD_%2 equ %1
  1513                              <1> %endmacro
  1514                              <1> 
  1515                              <1> 	lot_equate    1, SET_DL_UNIT
  1516                              <1> 	lot_equate    2, SET_BL_UNIT
  1517                              <1> 	lot_equate    4, SET_SIDI_CLUSTER
  1518                              <1> 	lot_equate  10h, SET_DSSI_DPT
  1519                              <1> 	lot_equate  20h, PUSH_DPT
  1520                              <1> 	lot_equate  40h, DATASTART_HIDDEN
  1521                              <1> 	lot_equate  80h, SET_AXBX_DATASTART
  1522                              <1> 	lot_equate 100h, SET_DSBP_BPB
  1523                              <1> 	lot_equate 200h, LBA_SET_TYPE
  1524                              <1> 	lot_equate 400h, MESSAGE_TABLE
  1525                              <1> 	lot_equate 800h, SET_AXBX_ROOT_HIDDEN
  1526                              <1> 	lot_equate 1000h, CMDLINE
  1527                              <1> 	lot_equate 2000h, NO_BPB
  1528                              <1> 	lot_equate 4000h, SET_DSSI_PARTINFO
  1529                              <1> %endif
  1530                              <1> 
  1531                              <1> %if _HELP_COMPRESSED
  1532                              <1>  %assign NONCOMPRESSEDFLAG 1
  1533                              <1> %else
  1534                              <1>  %assign NONCOMPRESSEDFLAG 0
  1535                              <1> %endif
  1536                              <1> 
  1537                              <1> [list +]
  1538                              <1> 
  1539                              <1> %if _LINK
  1540                              <1>  %if _ONLY386
  1541                              <1> 	cpu 386
  1542                              <1>  %else
  1543                              <1> 	cpu 8086
  1544                              <1>  %endif
  1545                              <1> 
  1546                              <1> auxbuff_size: equ (_AUXBUFFSIZE+15) & ~15
  1547                              <1> 	endarea auxbuff, 1
  1548                              <1> 
  1549                              <1> auxbuff_max_size: equ (_AUXBUFFMAXSIZE+15) & ~15
  1550                              <1> 	endarea auxbuff_max, 1
  1551                              <1> 
  1552                              <1> %if _INIT_MAX
  1553                              <1>  auxbuff_init_size: equ (_AUXBUFFMAXSIZE+15) & ~15
  1554                              <1> %else
  1555                              <1>  auxbuff_init_size: equ (_AUXBUFFSIZE+15) & ~15
  1556                              <1> %endif
  1557                              <1> 	endarea auxbuff_init, 1
  1558                              <1> 
  1559                              <1>  %include "options.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug options and internal flags
     5                              <2> 
     6                              <2> Copyright (C) 2008-2025 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 
    17                              <2> dispregs32	equ	  1	; RX: 32-bit register display (R, T/P/G)
    18                              <2> traceints	equ	  2	; TM: trace into interrupts (T)
    19                              <2> cpdepchars	equ	  4	; allow dumping of CP-dependent characters (D, DX)
    20                              <2> fakeindos	equ	  8	; always assume InDOS flag non-zero (all)
    21                              <2> nonpagingdevice	equ	 10h	; disallow paged output with [more] prompt (all exc. P, T)
    22                              <2> 	; This option was never used anywhere:
    23                              <2> ; pagingdevice	equ	 20h	; allow paged output with [more] prompt (all exc. P, T)
    24                              <2> 				; paged output is by default on if the output device is StdOut, else off
    25                              <2> hexrn		equ	 40h	; display raw hexadecimal content of FPU registers (RN)
    26                              <2> ;novdd		equ	 80h	; don't use a registered NTVDM VDD (L, W)
    27                              <2> nondospaging	equ	100h	; paging: don't use DOS for input when waiting for a key
    28                              <2> opt1_86mnohlt	equ	200h	; (86 Mode:) HLT doesn't work, don't use it
    29                              <2> biosidles	equ	400h	; don't idle with HLT or Int2F.1680, only call BIOS Int16.00
    30                              <2> opt_usegetinput	equ	800h	; use getinput for int 21h interactive input
    31                              <2> use_si_units	equ    1000h	; in disp_*_size use SI units (kB = 1000, etc)
    32                              <2> use_jedec_units	equ    2000h	; in disp_*_size use JEDEC units (kB = 1024)
    33                              <2> enable_serial	equ    4000h	; enable serial I/O (preferred over DOS or BIOS terminal)
    34                              <2> int8_disable_serial equ	   8000h	; disable serial I/O when breaking due to intr8
    35                              <2> gg_do_not_skip_bp equ	 1_0000h	; gg: do not skip a breakpoint (bb or gg)
    36                              <2> gg_no_autorepeat equ	 2_0000h	; gg: do not auto-repeat
    37                              <2> tp_do_not_skip_bp equ	 4_0000h	; T/TP/P: do not skip a (bb) breakpoint
    38                              <2> gg_bb_hit_no_repeat equ	 8_0000h	; gg: do not auto-repeat after bb hit
    39                              <2> tp_bb_hit_no_repeat equ	10_0000h	; T/TP/P: do not auto-repeat after bb hit
    40                              <2> gg_unexpected_no_repeat equ 20_0000h	; gg: do not auto-repeat after unexpectedinterrupt
    41                              <2> tp_unexpected_no_repeat equ 40_0000h	; T/TP/P
    42                              <2> ss_no_dump:		equ 80_0000h
    43                              <2> %if _SYMBOLIC
    44                              <2> dd_no_blanks_sym:	equ 100_0000h
    45                              <2> zz_no_pm_xms:		equ 200_0000h
    46                              <2> %endif
    47                              <2> rr_disasm_no_rept:	equ 1000_0000h
    48                              <2> rr_disasm_no_show:	equ 2000_0000h
    49                              <2> opt_cmdline_quiet_input:equ 4000_0000h
    50                              <2> opt_cmdline_quiet_output:equ 8000_0000h
    51                              <2> %if _SYMBOLIC
    52                              <2> DEFAULTOPTIONS	equ zz_no_pm_xms
    53                              <2> %else
    54                              <2> DEFAULTOPTIONS	equ 0
    55                              <2> %endif
    56                              <2> 
    57                              <2> 
    58                              <2> opt2_db_header:		equ 1
    59                              <2> opt2_db_trailer:	equ 2
    60                              <2> opt2_dw_header:		equ 10h
    61                              <2> opt2_dw_trailer:	equ 20h
    62                              <2> opt2_dd_header:		equ 100h
    63                              <2> opt2_dd_trailer:	equ 200h
    64                              <2> opt2_getinput_dpmi:	equ 800h
    65                              <2> opt2_hh_compat:		equ 1000h
    66                              <2> opt2_getc_idle:		equ 2000h
    67                              <2> opt2_getc_idle_dpmi:	equ 4000h
    68                              <2> opt2_re_cancel_tpg:	equ 8000h
    69                              <2> opt2_nn_compat:		equ 1_0000h
    70                              <2> opt2_nn_capitalise:	equ 2_0000h
    71                              <2> %if _MS_0RANGE_COMPAT
    72                              <2> opt2_0range_compat:	equ 4_0000h
    73                              <2> %endif
    74                              <2> opt2_rr16_compat:	equ 8_0000h
    75                              <2> opt2_r_prompt_compat:	equ 10_0000h
    76                              <2> opt2_r_separate:	equ 20_0000h
    77                              <2> opt2_r_linebreak_always:equ 40_0000h
    78                              <2> opt2_dpminohlt:		equ 8000_0000h	; DPMI doesn't like hlt
    79                              <2> DEFAULTOPTIONS2	equ opt2_dw_header | opt2_dd_header | opt2_getc_idle_dpmi | opt2_dpminohlt
    80                              <2> 
    81                              <2> 
    82                              <2> opt3_tt_no_paging:	equ 1
    83                              <2> opt3_tp_no_paging:	equ 2
    84                              <2> opt3_pp_no_paging:	equ 4
    85                              <2> opt3_gg_no_paging:	equ 8
    86                              <2> opt3_silence_paging_set:equ 100h
    87                              <2> opt3_silence_paging_on:	equ 200h
    88                              <2> opt3_paging_rc:		equ 1000h
    89                              <2> opt3_paging_yy:		equ 2000h
    90                              <2> opt3_paging_re:		equ 4000h
    91                              <2> opt3_r_highlight_diff:	equ 10000h
    92                              <2> opt3_r_highlight_dumb:	equ 20000h
    93                              <2> opt3_r_highlight_full:	equ 40000h
    94                              <2> opt3_r_highlight_eip:	equ 80000h
    95                              <2> %if _PM
    96                              <2> opt3_ss_b_bit_set:	equ   10_0000h
    97                              <2>  %if _BREAK_INSTALLDPMI
    98                              <2> opt3_break_installdpmi:	equ   20_0000h
    99                              <2>  %endif
   100                              <2> %endif
   101                              <2> %if _DHIGHLIGHT
   102                              <2> opt3_d_highlight:	equ   80_0000h
   103                              <2> %endif
   104                              <2> %if _GETLINEHIGHLIGHT
   105                              <2> opt3_getline_highlight:	equ  100_0000h
   106                              <2> %endif
   107                              <2> opt3_no_idle_2F:	equ  200_0000h
   108                              <2> %if _DELAY_BEFORE_BP
   109                              <2> opt3_delay_before_bp:	equ  400_0000h
   110                              <2> %endif
   111                              <2> opt3_no_call_amis:	equ  800_0000h
   112                              <2> opt3_disable_autorepeat:equ 1000_0000h
   113                              <2> opt3_check_ctrlc_keyb:	equ 2000_0000h
   114                              <2> opt3_check_ctrlc_0bh:	equ 4000_0000h
   115                              <2> opt3_tsr_quit_leave_tf:	equ 8000_0000h
   116                              <2> DEFAULTOPTIONS3	equ opt3_tt_no_paging | opt3_tp_no_paging 		| opt3_pp_no_paging | opt3_gg_no_paging 		| opt3_check_ctrlc_keyb | opt3_check_ctrlc_0bh
   119                              <2> 
   120                              <2> 
   121                              <2> opt4_int_2F_hook:	equ 2
   122                              <2> opt4_int_08_hook:	equ 4
   123                              <2> opt4_int_2D_hook:	equ 8
   124                              <2> %if _CATCHINTFAULTCOND
   125                              <2> opt4_int_fault_hook:	equ 10h
   126                              <2> %endif
   127                              <2> opt4_int_serial_force:	equ 1_0000h
   128                              <2> opt4_int_2F_force:	equ 2_0000h
   129                              <2> opt4_int_08_force:	equ 4_0000h
   130                              <2> opt4_int_2D_force:	equ 8_0000h
   131                              <2> %if _CATCHINT0D
   132                              <2> opt4_int_0D_force:	equ   10_0000h
   133                              <2> %endif
   134                              <2> %if _CATCHINT0C
   135                              <2> opt4_int_0C_force:	equ   20_0000h
   136                              <2> %endif
   137                              <2> opt4_int_00_force:	equ  100_0000h
   138                              <2> opt4_int_01_force:	equ  200_0000h
   139                              <2> opt4_int_03_force:	equ  400_0000h
   140                              <2> opt4_int_06_force:	equ  800_0000h
   141                              <2> opt4_int_18_force:	equ 1000_0000h
   142                              <2> opt4_int_19_force:	equ 2000_0000h
   143                              <2> opt4_int_09_force:	equ 4000_0000h	; not used at the same time as 15h
   144                              <2> opt4_int_15_force:	equ 4000_0000h	; not used at the same time as 09h
   145                              <2> opt4_int_07_force:	equ 8000_0000h
   146                              <2> DEFAULTOPTIONS4 equ opt4_int_2F_hook
   147                              <2> 
   148                              <2> 
   149                              <2> %if _VXCHG
   150                              <2> opt6_vv_mode:		equ 1
   151                              <2> opt6_vv_keep:		equ 2
   152                              <2> opt6_vv_int16:		equ 10h
   153                              <2>  %if _VXCHG_DEFAULT_ON
   154                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq | opt6_vv_mode
   155                              <2>  %else
   156                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq
   157                              <2>  %endif
   158                              <2> %else
   159                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq
   160                              <2> %endif
   161                              <2> %if _DEBUG
   162                              <2> opt6_debug_exception_late:	equ  20h
   163                              <2> opt6_debug_exception_early:	equ  40h
   164                              <2>  %if _DEBUG_COND
   165                              <2> opt6_debug_exception:	equ  80h
   166                              <2> opt6_debug_mode:	equ 100h
   167                              <2>  %endif
   168                              <2> %endif
   169                              <2> opt6_bios_output:	equ 200h
   170                              <2> opt6_flat_binary:	equ 400h
   171                              <2> opt6_big_stack:		equ 800h
   172                              <2> opt6_40_columns:	equ 1000h
   173                              <2> opt6_40_indent_odd:	equ 2000h
   174                              <2> opt6_40_dash:		equ 4000h
   175                              <2> opt6_share_serial_irq:	equ 1_0000h
   176                              <2> opt6_serial_EOI_call:	equ 2_0000h
   177                              <2> %if _RH
   178                              <2> opt6_rh_mode:		equ 10_0000h
   179                              <2> %endif
   180                              <2> %if _DEBUG
   181                              <2> opt6_debug_putrunint_early:	equ  40_0000h
   182                              <2>  %if _DEBUG_COND
   183                              <2> opt6_debug_putrunint:		equ  80_0000h
   184                              <2>  %endif
   185                              <2> %endif
   186                              <2> opt6_bios_io:		equ 100_0000h
   187                              <2> opt6_immasm_display_uu:	equ 200_0000h
   188                              <2> opt6_immasm_debug:	equ 400_0000h
   189                              <2> opt6_immasm_flag:	equ 800_0000h
   190                              <2> opt6_immasm_nobranch:	equ 1000_0000h
   191                              <2> opt6_r_flags_style2:	equ 2000_0000h
   192                              <2> opt6_r_flags_style3:	equ 4000_0000h
   193                              <2> opt6_r_linebreak_conditional:	equ 8000_0000h
   194                              <2> 
   195                              <2> 
   196                              <2> DEFAULTOPTIONS7 equ opt7_no_tsr_ll
   197                              <2> opt7_no_free_oneshot_eld:	equ 1
   198                              <2> opt7_debug_optional_link:	equ 2
   199                              <2> opt7_quiet_install:		equ 4
   200                              <2> opt7_quick_run:			equ 8
   201                              <2> opt7_houdini:			equ 100h
   202                              <2> opt7_debug_run:			equ 200h
   203                              <2> opt7_no_ensure:			equ 1000h
   204                              <2> opt7_no_tsr_ll:			equ 2000h
   205                              <2> 
   206                              <2> 
   207                              <2> oldpacket	equ	  1	; Int25/Int26 packet method available (L, W)
   208                              <2> newpacket	equ	  2	; Int21.7305 packet method available (L, W)
   209                              <2> ntpacket	equ	  4	; VDD registered and usable (L, W)
   210                              <2> pagedcommand	equ	  8	; allows paging in puts
   211                              <2> notstdinput	equ	 10h	; DEBUG's StdIn isn't a device with StdIn bit (is file or other device)
   212                              <2> inputfile	equ	 20h	; DEBUG's StdIn is a file, notstdinput also set
   213                              <2> notstdoutput	equ	 40h	; DEBUG's StdOut isn't a device with StdOut bit (is file or other device)
   214                              <2> outputfile	equ	  80h	; DEBUG's StdOut is a file, notstdoutput also set
   215                              <2> hooked2F	equ	 100h	; Int2F hooked
   216                              <2> nohook2F	equ	 200h	; don't hook Int2F.1687 (required for Win9x, DosEmu?)
   217                              <2> unused_dif1_dpminohlt equ 400h	; DPMI doesn't like hlt
   218                              <2> protectedmode	equ	 800h	; in (DPMI) protected mode
   219                              <2> debuggeeA20	equ	1000h	; state of debuggee's A20
   220                              <2> debuggerA20	equ	2000h	; state of debugger's A20 (will be on if possible)
   221                              <2> nodosloaded	equ	4000h	; No DOS loaded currently (Boot loader mode)
   222                              <2> has386		equ	8000h	; CPU is a 386
   223                              <2> usecharcounter	equ    1_0000h	; don't reset charcounter between calls to puts
   224                              <2> runningnt	equ    2_0000h	; running in NTVDM
   225                              <2> canswitchmode	equ    4_0000h	; can switch modes (auxbuff large enough, DPMI mode switch set up)
   226                              <2> modeswitched	equ    8_0000h	; switched mode (now in the mode that we weren't entered in)
   227                              <2> promptwaiting	equ   10_0000h	; puts: any more output needs to display a prompt first
   228                              <2> switchbuffer	equ   20_0000h	; mode switch needs a buffer (auxbuff)
   229                              <2> tsrmode		equ   40_0000h	; in TSR mode; DPI and DPP not valid
   230                              <2> attachedterm	equ   80_0000h	; the attached process terminated
   231                              <2> runningdosemu	equ  100_0000h	; running in dosemu
   232                              <2> ; load_is_ldp	equ  200_0000h	; boot load: partition specified as "ldp"
   233                              <2> tt_while:	equ  400_0000h	; tt: while condition specified
   234                              <2> tt_p:		equ  800_0000h	; tt: proceed past repeated string instructions
   235                              <2> tt_silent_mode:	equ 1000_0000h	; tt: run should be silent (dump at end)
   236                              <2> tt_silence:	equ 2000_0000h	; tt: silent writing (write to auxbuff instead)
   237                              <2> tt_no_bb:	equ 4000_0000h	; tt: do not use bb breakpoints
   238                              <2> tt_no_bb_first:	equ 8000_0000h	; tt: do not use bb breakpoints at first
   239                              <2> 
   240                              <2> 
   241                              <2> dif2_gg_is_first:	equ   1
   242                              <2> dif2_gg_skip_non_cseip:	equ   2
   243                              <2> dif2_gg_skip_cseip:	equ   4
   244                              <2> dif2_gg_is_gg:		equ   8
   245                              <2> dif2_gg_first_detected:	equ  10h
   246                              <2> dif2_gg_again:		equ  20h
   247                              <2> dif2_tpg_proceed_bp_set:equ  40h
   248                              <2> dif2_tpg_keep_proceed_bp: equ 80h
   249                              <2> dif2_tpg_have_bp:	equ 100h
   250                              <2> dif2_tpg_adjusted_cseip:equ 200h
   251                              <2> dif2_tpg_do_not_adjust:	equ 400h
   252                              <2> dif2_bp_failure:	equ 800h
   253                              <2> dif2_is_pp:		equ 1000h
   254                              <2> %if _SYMBOLIC
   255                              <2> dif2_createdprocess:	equ 800_0000h	; created empty debuggee process
   256                              <2> dif2_sym_req_xms:	equ 2000h
   257                              <2> dif2_sym_req_86mm:	equ 4000h
   258                              <2> dif2_sym_req_mask equ dif2_sym_req_86mm | dif2_sym_req_xms
   259                              <2> dif2_no_pm_xms:		equ 1_0000h
   260                              <2> dif2_xms_detection_done:equ 2_0000h
   261                              <2> %endif
   262                              <2> %if _INPUT_FILE_HANDLES
   263                              <2> dif2_input_file:	equ 10_0000h
   264                              <2> dif2_closed_input_file:	equ 20_0000h
   265                              <2> %endif
   266                              <2> dif2_did_getline_file:	equ 40_0000h
   267                              <2> %if _SYMBOLIC
   268                              <2> dif2_poison:		equ 80_0000h
   269                              <2> %endif
   270                              <2> dif2_boot_loaded_kernel:equ 100_0000h
   271                              <2> %if _INPUT_FILE_BOOT
   272                              <2> dif2_input_file_boot:	equ 200_0000h
   273                              <2> dif2_closed_input_file_boot:	equ 400_0000h
   274                              <2> %endif
   275                              <2> dif2_in_silence_dump:	equ 1000_0000h
   276                              <2> dif2_int31_segment:	equ 2000_0000h
   277                              <2> dif2_nn_compat:		equ 4000_0000h
   278                              <2> dif2_nn_capitalise:	equ 8000_0000h
   279                              <2> 
   280                              <2> 
   281                              <2> dif3_load_is_ldp:	equ 1	; boot load: partition specified as "ldp"
   282                              <2> dif3_load_is_sdp:	equ 2	; boot load: partition specified as "sdp"
   283                              <2> dif3_load_is_ydp:	equ 4	; boot load: partition specified as "ydp"
   284                              <2> dif3_load_is_dp:	equ dif3_load_is_ldp 				| dif3_load_is_sdp 				| dif3_load_is_ydp
   287                              <2> dif3_load_dir_dir:	equ 8
   288                              <2> dif3_input_terminal_override:	equ 10h
   289                              <2> dif3_input_serial_override:	equ 20h
   290                              <2> dif3_if_not:		equ 40h
   291                              <2> dif3_partition_changed:	equ 80h
   292                              <2> ;
   293                              <2> dif3_input_cmdline:	equ 100h; input reading from cmdline_buffer
   294                              <2> dif3_input_cmdline_closed: equ 200h
   295                              <2> dif3_at_line_end:	equ 400h
   296                              <2> dif3_quiet_input_single:equ 800h
   297                              <2> dif3_quiet_output:	equ 1000h
   298                              <2> dif3_unquiet_error:	equ 2000h
   299                              <2> dif3_unquiet_prompt:	equ 4000h
   300                              <2> dif3_unquiet:		equ dif3_unquiet_error | dif3_unquiet_prompt
   301                              <2> dif3_return_eof:	equ 8000h
   302                              <2> dif3_highlighting:	equ 1_0000h
   303                              <2> dif3_do_not_highlight:	equ 2_0000h
   304                              <2> dif3_int10_highlight:	equ 2_0000h
   305                              <2> dif3_nosymbols_1:	equ 4_0000h
   306                              <2> dif3_nosymbols_2:	equ 8_0000h
   307                              <2> %if _PM
   308                              <2> dif3_ss_b_bit_set:	equ  10_0000h
   309                              <2> %endif
   310                              <2> dif3_gotint19:		equ  20_0000h
   311                              <2> dif3_prior_pm:		equ  40_0000h
   312                              <2> %if _DELAY_BEFORE_BP
   313                              <2> dif3_delayed		equ  80_0000h
   314                              <2> %endif
   315                              <2> dif3_input_re:		equ 100_0000h	; input reading from re_buffer
   316                              <2> dif3_input_re_closed:	equ 200_0000h
   317                              <2> dif3_accept_getrange_0:	equ 400_0000h
   318                              <2> %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
   319                              <2> dif3_in_if:		equ 800_0000h
   320                              <2> %endif
   321                              <2> dif3_auxbuff_guarded_1:	equ 1000_0000h
   322                              <2> dif3_auxbuff_guarded_2:	equ 2000_0000h
   323                              <2> dif3_auxbuff_guarded_3:	equ 4000_0000h
   324                              <2> dif3_sss_is_reverse:	equ 8000_0000h
   325                              <2> 
   326                              <2> 
   327                              <2> dif4_int_serial_hooked:	equ 1
   328                              <2> dif4_int_2F_hooked:	equ 2
   329                              <2> dif4_int_08_hooked:	equ 4
   330                              <2> dif4_int_2D_hooked:	equ 8
   331                              <2> %if _CATCHINTFAULTCOND && _CATCHINT0D
   332                              <2> dif4_int_0D_hooked:	equ 10h
   333                              <2> %endif
   334                              <2> %if _CATCHINTFAULTCOND && _CATCHINT0C
   335                              <2> dif4_int_0C_hooked:	equ 20h
   336                              <2> %endif
   337                              <2> %if _LOADER
   338                              <2> dif4_int_18_hooked:	equ 1000h
   339                              <2> dif4_int_19_hooked:	equ 2000h
   340                              <2> %endif
   341                              <2> 
   342                              <2> 
   343                              <2> %if _VXCHG
   344                              <2> dif6_vv_mode:		equ 1
   345                              <2> %endif
   346                              <2> dif6_in_hook2F:		equ 2
   347                              <2> dif6_in_amis_hook2F:	equ 4
   348                              <2> dif6_debug_mode:	equ 100h
   349                              <2> dif6_locked:		equ 200h
   350                              <2> dif6_mcp:		equ 400h
   351                              <2> %if _RH
   352                              <2> dif6_rh_mode_was:	equ  8_0000h
   353                              <2> dif6_rh_mode:		equ 10_0000h
   354                              <2> dif6_rh_mode_2:		equ 20_0000h
   355                              <2> %endif
   356                              <2> dif6_device_mode:	equ 40_0000h
   357                              <2> dif6_cpdepchars:	equ 80_0000h
   358                              <2> %if _IMMASM
   359                              <2> dif6_immasm_no_output:	equ 100_0000h
   360                              <2> dif6_immasm:		equ 200_0000h
   361                              <2> dif6_immasm_rel8:	equ 400_0000h
   362                              <2> %endif
   363                              <2> 
   364                              <2> 
   365                              <2> disasm_lowercase	equ 1
   366                              <2> disasm_commablank	equ 2
   367                              <2> disasm_nasm		equ 4
   368                              <2> disasm_lowercase_refmem:equ 8
   369                              <2> disasm_show_short:	equ 10h
   370                              <2> disasm_show_near:	equ 20h
   371                              <2> disasm_show_far:	equ 40h
   372                              <2> disasm_nec:		equ 80h
   373                              <2> disasm_40_columns:	equ 100h
   374                              <2> disasm_no_indent:	equ 200h
   375                              <2> disasm_msdebug_mnemonofs: equ 400h
   376                              <2> disasm_a16_memref:	equ 1000h
   377                              <2> disasm_a32_memref:	equ 2000h
   378                              <2> disasm_a16_string:	equ 4000h
   379                              <2> disasm_a32_string:	equ 8000h
   380                              <2> disasm_hide_modrm:	equ 10000h
   381                              <2> disasm_asize_loop_nasm:	equ 20000h
   382                              <2> disasm_modrm_always:	equ 40000h
   383                              <2> DEFAULTASMOPTIONS equ disasm_lowercase|disasm_commablank|disasm_nasm 	| disasm_a16_memref | disasm_a32_memref 	| disasm_a16_string | disasm_a32_string
   386                              <2> 
   387                              <2> 	; serial_flags values
   388                              <2> sf_init_done:	equ 1
   389                              <2> sf_ctrl_c:	equ 2
   390                              <2> sf_double_ctrl_c:	equ 4
   391                              <2> sf_built_in_fifo:	equ 8
   392                              <2> sf_use_serial:		equ 10h
  1560                              <1> %endif
    21                                  %endif
    22                                  
    23                                  %if _LINK_COMPAT
    24                                   %define FORCEWORD word
    25                                   %define FORCESTRICTWORD strict word
    26                                  %else
    27                                   %define FORCEWORD
    28                                   %define FORCESTRICTWORD
    29                                  %endif
    30                                  
    31                                  
    32                                  %if _LINK
    33                                  
    34                                  %if !(_ONLY386 || _ONLYNON386) || _DUALCODE && _PM
    35                                   wllist G_GINITGROUP_SINIT
    36                                  %endif
    37                                  
    38                                  %ifn _ONLY386 || _ONLYNON386
    39                                   wllist N_SINIT_Lpatch_386_table
    40                                   wllist N_SINIT_Lpatch_no386_table
    41                                  %if _DUALCODE
    42                                   wllist N_SINIT_Lpatch_386_table2
    43                                   wllist N_SINIT_Lpatch_no386_table2
    44                                  %endif
    45                                   wllist N_SINIT_Lpatch_386_tableentry
    46                                   wllist N_SINIT_Lpatch_no386_tableentry
    47                                  %endif
    48                                  
    49                                  %if _DUALCODE && ! _PM
    50                                   wllist N_SINIT_Lrelocate_from_code
    51                                   wllist N_SINIT_Lrelocate_from_code2
    52                                  
    53                                   extern relocate_from_code
    54                                   extern relocate_from_code.end
    55                                   extern relocate_from_code2
    56                                   extern relocate_from_code2.end
    57                                  %endif
    58                                  
    59                                  %endif
    60                                  	usesection INIT
    60          ------------------       note: usesection INIT
    61                                  
    62                                  %ifn _LINK
    63                                  CODETARGET1_equate equ CODETARGET1
    64                                  CODETARGET2_equate equ CODETARGET2
    65                                  AUXTARGET1_equate equ AUXTARGET1
    66                                  AUXTARGET2_equate equ AUXTARGET2
    67                                  BOOTCODETARGET1_equate equ BOOTCODETARGET1
    68                                  BOOTCODETARGET2_equate equ BOOTCODETARGET2
    69                                  BOOTAUXTARGET1_equate equ BOOTAUXTARGET1
    70                                  BOOTAUXTARGET2_equate equ BOOTAUXTARGET2
    71                                  ldebug_codes_size_equate equ ldebug_code_size + ldebug_code2_size
    72                                  ldebug_codes_truncated_size_equate equ ldebug_code_bootldr_truncated_size + ldebug_code2_size
    73                                  auxbuff_size_equate equ auxbuff_size
    74                                  initsectionoffset_p_equate equ paras(INITSECTIONOFFSET)
    75                                  %endif
    76                                  
    77                                  initcode:
    78                                  %if ($ - $$) != 0
    79                                   %fatal initcode expected at start of section
    80                                  %endif
    81                                  %ifn _APPLICATION
    82                                  	push cs
    83                                  	pop ds
    84                                  	mov dx, imsg.not_an_application
    85                                  	mov ah, 09h
    86                                  	int 21h
    87                                  	mov ax, 4CFFh
    88                                  	int 21h
    89                                  
    90                                  		; magic sequence for tellsize
    91                                  %if _LINK
    92                                  	mov bx, 1
    93                                   wlcalc word_wrt_INIT_extpara_behind_init, equ $ - 2
    94                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
    95                                   wlcalc word_segrel_INIT, equ $ - 2
    96                                  %else
    97                                  	mov bx, paras(INITSECTIONOFFSET + init_size + deviceshim_size + 16)
    98                                  %endif
    99                                  	mov ah, 4Ah
   100                                  	int 21h
   101                                  		; end of magic sequence for tellsize
   102                                  
   103                                  		; The +16 is to avoid entering a zero value
   104                                  		;  for exeMinAlloc and exeMaxAlloc, which
   105                                  		;  seems to be handled in a special way by
   106                                  		;  DOS. (This special handling occurs for
   107                                  		;  the uncompressed bootable build, eg
   108                                  		;  ldebugu.com, and the nonbootable MZ shim
   109                                  		;  build, eg debug.com.)
   110                                  %endif
   111                                  
   112                                  %if _APPLICATION
   113 00000000 8CD0                    	mov ax, ss
   114 00000002 8CDA                    	mov dx, ds
   115 00000004 29D0                    	sub ax, dx
   116                                  
   117 00000006 50                      	push ax			; (if sp was zero)
   118                                  
   119 00000007 89E2                    	mov dx, sp
   120 00000009 B103                    	mov cl, 3
   121 0000000B 83C20F                  	add dx, 15
   122 0000000E D1DA                    	rcr dx, 1
   123 00000010 D3EA                    	shr dx, cl
   124 00000012 01D0                    	add ax, dx
   125                                  
   126                                  %ifn _LINK
   127                                  	cmp ax, strict word paras(APPINITSTACK_END)
   128                                  %else
   129                                  
   130                                  %if 0
   131                                  %define APPINITTARGET (INITSECTIONOFFSET 			+ datastack_size 			+ ext_data_nonboot_add_size 			+ auxbuff_size + auxbuff_init_size 			+ historysegment_size 			+ app_env_size 			+ extsegment_size)
   138                                  		; The early stack goes behind the init target.
   139                                  %define APPINITSTACK_START (APPINITTARGET+init_size)
   140                                  APPINITSTACK_SIZE equ 512	; must be even
   141                                  		; This is the size of the application mode
   142                                  		;  process memory block required while still
   143                                  		;  using the init stack behind init target.
   144                                  %define APPINITSTACK_END (APPINITSTACK_START+APPINITSTACK_SIZE)
   145                                  %endif
   146                                  
   147 00000014 3D[A208]                	cmp ax, strict word relocatedzero + paras( 		+ auxbuff_size + auxbuff_init_size 		+ historysegment_size 		+ app_env_size 		+ extsegment_size 		+ APPINITSTACK_SIZE)
   153                                   wlcalc word_segrel_INIT, equ $ - 2
   154                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
   155                                   wlcalc word_wrt_INIT_extpara_behind_init, equ $ - 2
   156                                  %endif
   157 00000017 7314                    	jae .stackdownfirst
   158                                  .memupfirst:
   159                                  		; magic sequence for tellsize
   160                                  %ifn _LINK
   161                                  	mov bx, paras(APPINITSTACK_END)
   162                                  %else
   163 00000019 BB[A208]                	mov bx, relocatedzero + paras( 		+ auxbuff_size + auxbuff_init_size 		+ historysegment_size 		+ app_env_size 		+ extsegment_size 		+ APPINITSTACK_SIZE)
   169                                   wlcalc word_segrel_INIT, equ $ - 2
   170                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
   171                                   wlcalc word_wrt_INIT_extpara_behind_init, equ $ - 2
   172                                  %endif
   173 0000001C B44A                    	mov ah, 4Ah
   174 0000001E CD21                    	int 21h
   175                                  		; end of magic sequence for tellsize
   176 00000020 730B                    	jnc @F
   177                                  .memfail:
   178 00000022 BA[820F]                	mov dx, imsg.early_mem_fail
   179                                  .earlyfail:
   180 00000025 E80D1B                  	call init_putsz_cs
   181 00000028 B8FF4C                  	mov ax, 4CFFh
   182 0000002B CD21                    	int 21h
   183                                  
   184                                  @@:
   185                                  .stackdownfirst:
   186 0000002D 8CD8                    	mov ax, ds
   187                                  %ifn _LINK
   188                                  	add ax, paras(APPINITSTACK_START)
   189                                  %else
   190 0000002F 05[8208]                	add ax, strict word relocatedzero + paras( 		+ auxbuff_size + auxbuff_init_size 		+ historysegment_size 		+ app_env_size 		+ extsegment_size)
   195                                   wlcalc word_segrel_INIT, equ $ - 2
   196                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
   197                                   wlcalc word_wrt_INIT_extpara_behind_init, equ $ - 2
   198                                  %endif
   199 00000032 FA                      	cli
   200 00000033 8ED0                    	mov ss, ax
   201 00000035 BC0002                  	mov sp, APPINITSTACK_SIZE
   202 00000038 FB                      	sti
   203                                  
   204                                  		; if jumped to .stackdownfirst: now, shrink our memory block
   205                                  		; else: no-op (already grew or shrunk block)
   206                                  %ifn _LINK
   207                                  	mov bx, paras(APPINITSTACK_END)
   208                                  %else
   209 00000039 BB[A208]                	mov bx, relocatedzero + paras( 		+ auxbuff_size + auxbuff_init_size 		+ historysegment_size 		+ app_env_size 		+ extsegment_size 		+ APPINITSTACK_SIZE)
   215                                   wlcalc word_segrel_INIT, equ $ - 2
   216                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
   217                                   wlcalc word_wrt_INIT_extpara_behind_init, equ $ - 2
   218                                  %endif
   219 0000003C B44A                    	mov ah, 4Ah
   220 0000003E CD21                    	int 21h
   221 00000040 72E0                    	jc .memfail
   222                                  
   223                                  
   224 00000042 8CD8                    	mov ax, ds
   225                                  %ifn _LINK
   226                                  	add ax, paras(INITSECTIONOFFSET)
   227                                  %else
   228 00000044 05[0000]                	add ax, strict word relocatedzero + 0
   229                                   wlcalc word_segrel_INIT, equ $ - 2
   230                                  %endif
   231 00000047 8CDA                    	mov dx, ds
   232                                  %ifn _LINK
   233                                  	add dx, paras(APPINITTARGET)
   234                                  	mov cx, init_size_p
   235                                  	call init_movp
   236                                  init_size_p_equate equ init_size_p
   237                                  appinittarget_p_equate equ paras(APPINITTARGET)
   238                                  %if initsectionoffset_p_equate + init_size_p_equate > appinittarget_p_equate
   239                                   %error Overlap detected
   240                                  %endif
   241                                  %else
   242 00000049 81C2[8208]              	add dx, strict word relocatedzero + paras( 		+ auxbuff_size + auxbuff_init_size 		+ historysegment_size 		+ app_env_size 		+ extsegment_size)
   247                                   wlcalc word_segrel_INIT, equ $ - 2
   248                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
   249 0000004D B9[0000]                	mov cx, relocatedzero + 0
   250                                   wlcalc word_wrt_INIT_extpara_behind_init, equ $ - 2
   251 00000050 E8511A                  	call init_movp
   252                                  %endif
   253                                  
   254 00000053 52                      	push dx
   255 00000054 E8B401                  	call init_retf
   256                                  
   257                                  %ifn _LINK
   258                                  %if _APP_ENV_SIZE
   259                                  	mov word [cs:memsize], paras(CODETARGET2 			+ ldebug_code_bootldr_truncated_size 			+ ldebug_code2_size 			+ historysegment_size 			+ app_env_size 			+ extsegment_size)
   265                                  %endif
   266                                  
   267                                  	mov bx, ds
   268                                  	mov dx, bx
   269                                  	add bx, paras(AUXTARGET1)
   270                                  	add dx, paras(CODETARGET1)
   271                                   %if _EXTENSIONS || _HISTORY_SEPARATE_FIXED && _HISTORY || _APP_ENV_SIZE
   272                                  	mov ax, bx
   273                                  	add ax, paras(auxbuff_size)
   274                                    %if AUXTARGET1_equate <= CODETARGET1_equate
   275                                  %assign nn AUXTARGET1_equate
   276                                  %assign mm CODETARGET1_equate
   277                                     %error Unexpected layout aux = nn code = mm
   278                                    %endif
   279                                   %endif
   280                                  	mov cx, dx
   281                                  	mov word [cs:init_layout], init_app_layout_1
   282                                  	call init_check_auxbuff
   283                                  	jz @F
   284                                  
   285                                  	mov bx, ds
   286                                  	mov dx, bx
   287                                  	add bx, paras(AUXTARGET2)
   288                                  	add dx, paras(CODETARGET2)
   289                                   %if _EXTENSIONS || _HISTORY_SEPARATE_FIXED && _HISTORY || _APP_ENV_SIZE
   290                                    %if (paras(AUXTARGET1_equate) + paras(auxbuff_size_equate)) 	!= (paras(CODETARGET2_equate) + paras(ldebug_codes_truncated_size_equate))
   292                                  ldebug_code2_size_equate equ ldebug_code2_size
   293                                  ldebug_code_size_equate equ ldebug_code_size
   294                                  ldebug_code_bootldr_truncated_size_equate equ ldebug_code_bootldr_truncated_size
   295                                  %assign vv (paras(ldebug_code2_size_equate))
   296                                  %assign uu (paras(ldebug_code_size_equate))
   297                                  %assign tt (paras(ldebug_code_bootldr_truncated_size_equate))
   298                                  %assign sss (paras(CODETARGET1_equate))
   299                                  %assign rr (paras(AUXTARGET1_equate))
   300                                  %assign qq (paras(CODETARGET2_equate))
   301                                  %assign pp (paras(auxbuff_size_equate))
   302                                  %assign oo (paras(ldebug_codes_truncated_size_equate))
   303                                  %assign nn (paras(AUXTARGET1_equate) + paras(auxbuff_size_equate))
   304                                  %assign mm (paras(CODETARGET2_equate) + paras(ldebug_codes_truncated_size_equate))
   305                                     %error Unexpected layout aux1+auxb != code2+trunc
   306                                     %error code2+trunc = mm aux1+auxb = nn trunc = oo auxb = pp code2 = qq aux1 = rr
   307                                     %error code1 = sss codeseg1trunc = tt codeseg1 = uu codeseg2 = vv
   308                                    %endif
   309                                   %endif
   310                                  
   311                                  %else	; _LINK
   312                                  %if _APP_ENV_SIZE
   313                                   %if 0
   314                                  %define CODETARGET1 (MESSAGESECTIONOFFSET + messagesegment_nobits_truncated_size + datastack_size)
   315                                  %define CODETARGET2 (CODETARGET1+auxbuff_size)
   316                                  %define AUXTARGET1 (CODETARGET1+ldebug_code_bootldr_truncated_size+ldebug_code2_size)
   317                                  %define AUXTARGET2 CODETARGET1
   318                                  %define AUXTARGET3 (AUXTARGET1+auxbuff_size)
   319                                   %endif
   320 00000057 2EC706[060E][8106]      	mov word [cs:memsize], relocatedzero + paras(auxbuff_size 			+ historysegment_size 			+ app_env_size 			+ extsegment_size)
   324                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
   325                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits_truncated, equ $ - 2
   326                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
   327                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code_truncated, equ $ - 2
   328                                   wlcalc word_wrt_@@lDEBUG_CODE2@_extpara_behind_code2, equ $ - 2
   329                                  %endif
   330                                  
   331 0000005E 8CDB                    	mov bx, ds
   332 00000060 89DA                    	mov dx, bx
   333                                  	; add bx, paras(AUXTARGET1)
   334 00000062 81C3[0000]              	add bx, strict word relocatedzero + 0
   335                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
   336                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits_truncated, equ $ - 2
   337                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
   338                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code_truncated, equ $ - 2
   339                                   wlcalc word_wrt_@@lDEBUG_CODE2@_extpara_behind_code2, equ $ - 2
   340                                  	; add dx, paras(CODETARGET1)
   341 00000066 81C2[0000]              	add dx, strict word relocatedzero + 0
   342                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
   343                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits_truncated, equ $ - 2
   344                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
   345                                   %if _EXTENSIONS || _HISTORY_SEPARATE_FIXED && _HISTORY || _APP_ENV_SIZE
   346 0000006A 89D8                    	mov ax, bx
   347 0000006C 050102                  	add ax, paras(auxbuff_size)
   348                                   %endif
   349 0000006F 89D1                    	mov cx, dx
   350 00000071 2EC706[0C0E][F432]      	mov word [cs:init_layout], init_app_layout_1
   351 00000078 E89101                  	call init_check_auxbuff
   352 0000007B 743E                    	jz @F
   353                                  
   354 0000007D 8CDB                    	mov bx, ds
   355 0000007F 89DA                    	mov dx, bx
   356                                  	; add bx, paras(AUXTARGET2)
   357 00000081 81C3[0000]              	add bx, strict word relocatedzero + 0
   358                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
   359                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits_truncated, equ $ - 2
   360                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
   361                                  	; add dx, paras(CODETARGET2)
   362 00000085 81C2[0102]              	add dx, strict word relocatedzero + paras(auxbuff_size)
   363                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
   364                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits_truncated, equ $ - 2
   365                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
   366                                  %endif
   367 00000089 2EC706[0C0E][3E33]      	mov word [cs:init_layout], init_app_layout_2
   368 00000090 E87901                  	call init_check_auxbuff
   369 00000093 7426                    	jz @F
   370                                  
   371                                  		; If both prior attempts failed, we allocate
   372                                  		;  an additional 8 KiB and move the buffer to
   373                                  		;  that. This should always succeed.
   374                                  %ifn _LINK
   375                                  	mov word [cs:memsize], paras(AUXTARGET3 			+ auxbuff_size 			+ historysegment_size 			+ app_env_size 			+ extsegment_size)
   380                                  				; enlarge the final memory block size
   381                                  
   382                                  	mov bx, ds
   383                                  	add bx, paras(AUXTARGET3)
   384                                  %else	; _LINK
   385                                   %if 0
   386                                  %define CODETARGET1 (MESSAGESECTIONOFFSET + messagesegment_nobits_truncated_size + datastack_size)
   387                                  %define CODETARGET2 (CODETARGET1+auxbuff_size)
   388                                  %define AUXTARGET1 (CODETARGET1+ldebug_code_bootldr_truncated_size+ldebug_code2_size)
   389                                  %define AUXTARGET2 CODETARGET1
   390                                  %define AUXTARGET3 (AUXTARGET1+auxbuff_size)
   391                                   %endif
   392 00000095 2EC706[060E][8208]      	mov word [cs:memsize], relocatedzero + paras(auxbuff_size 			+ auxbuff_size 			+ historysegment_size 			+ app_env_size 			+ extsegment_size)
   397                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
   398                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits_truncated, equ $ - 2
   399                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
   400                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code_truncated, equ $ - 2
   401                                   wlcalc word_wrt_@@lDEBUG_CODE2@_extpara_behind_code2, equ $ - 2
   402                                  				; enlarge the final memory block size
   403                                  
   404 0000009C 8CDB                    	mov bx, ds
   405 0000009E 81C3[0102]              	add bx, strict word relocatedzero + paras(auxbuff_size)
   406                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
   407                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits_truncated, equ $ - 2
   408                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
   409                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code_truncated, equ $ - 2
   410                                   wlcalc word_wrt_@@lDEBUG_CODE2@_extpara_behind_code2, equ $ - 2
   411                                  %endif	; _LINK
   412 000000A2 89CA                    	mov dx, cx
   413                                   %if _EXTENSIONS || _HISTORY_SEPARATE_FIXED && _HISTORY || _APP_ENV_SIZE
   414 000000A4 89D8                    	mov ax, bx
   415 000000A6 050102                  	add ax, paras(auxbuff_size)
   416                                   %endif
   417 000000A9 2EC706[0C0E][F432]      	mov word [cs:init_layout], init_app_layout_3
   418 000000B0 E85901                  	call init_check_auxbuff
   419 000000B3 7406                    	jz @F
   420                                  
   421                                  		; Because this shouldn't happen, this is
   422                                  		;  considered an internal error.
   423 000000B5 BA[1D10]                	mov dx, imsg.early_reloc_fail
   424 000000B8 E96AFF                  	jmp .earlyfail
   425                                  
   426                                  @@:
   427                                   %if _EXTENSIONS || _HISTORY_SEPARATE_FIXED && _HISTORY || _APP_ENV_SIZE
   428 000000BB 50                      	push ax
   429                                   %endif
   430 000000BC E83601                  	call place_code_segments
   431                                  
   432                                  %if _MESSAGESEGMENT
   433 000000BF 8CD8                    	mov ax, ds
   434                                   %ifn _LINK
   435                                  	add ax, paras(MESSAGESECTIONOFFSET)
   436                                  	mov dx, ds
   437                                  	add dx, paras(100h + DATAENTRYTABLESIZE + datastack_size)
   438                                  	mov cx, paras(messagesegment_truncated_size)
   439                                   %else		; _LINK
   440 000000C1 05[0000]                	add ax, strict word relocatedzero + 0
   441                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
   442 000000C4 8CDA                    	mov dx, ds
   443 000000C6 81C2[0000]              	add dx, strict word relocatedzero + 0
   444                                   wlcalc word_wrt_@@lDEBUG_DATA_ENTRY@_extpara_end_of_datastack, equ $ - 2
   445 000000CA B9[0000]                	mov cx, relocatedzero + 0
   446                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_truncated, equ $ - 2
   447                                   %endif		; _LINK
   448 000000CD E8D419                  	call init_movp
   449 000000D0 8916[0000]              	mov word [messageseg], dx
   450                                   %if _HELP_COMPRESSED && ! _PM
   451 000000D4 8916[0000]              	mov [hshrink_memory_source.segment], dx
   452                                   %endif
   453                                   %if _BOOTLDR_DISCARD_HELP
   454                                     %ifn _LINK
   455                                  	mov word [messageseg_size], messagesegment_nobits_truncated_size
   456                                     %else
   457 000000D8 C706[0000][0000]        	mov word [messageseg_size], behind_messagesegment_nobits_truncated wrt MESSAGESEGMENT
   458                                     %endif
   459                                    %if _HELP_COMPRESSED
   460 000000DE C706[0000][0000]        	mov word [indirect_hshrink_message_buffer], truncated_hshrink_message_buffer
   461                                     %if _LINK || _LINK_COMPAT
   462 000000E4 8E06[0000]              	mov es, [code_seg]
   463 000000E8 26800E[0000]01          	setopt [es:patch_boothelp_uncompressed], NONCOMPRESSEDFLAG
   464                                     %endif
   465                                    %endif
   466 000000EE 1E                      	push ds
   467 000000EF 0E                      	 push cs
   468 000000F0 1F                      	 pop ds
   469 000000F1 BE[4016]                	mov si, imsg.boothelp_replacement
   470 000000F4 8EC2                    	mov es, dx
   471 000000F6 BF[0000]                	mov di, msg.boothelp
   472 000000F9 B91C00                  	mov cx, imsg.boothelp_replacement_size_w
   473 000000FC F3A5                    	rep movsw
   474 000000FE 31C0                    	xor ax, ax
   475                                     %ifn _LINK
   476                                  	mov cx, words(messagesegment_nobits_truncated_size 		- (msg.boothelp - messagesegment_start 			+ fromwords(imsg.boothelp_replacement_size_w)))
   479                                     %else
   480 00000100 B9[3800]                	mov cx, relocatedzero + fromwords(imsg.boothelp_replacement_size_w)
   481                                   wlcalc word_ext_msg.boothelp, equ $ - 2	; length + start
   482                                   wlcalc word_subr_0, equ $ - 2			; - (length + start)
   483                                   wlcalc word_wrt_MESSAGESEGMENT_ext_behind_messagesegment_nobits_truncated, equ $ - 2
   484                                   						; behind - (length + start)
   485                                   wlcalc word_shr_1, equ $ - 2			; above >> 1
   486                                     %endif
   487 00000103 F3AB                    	rep stosw
   488 00000105 1F                      	pop ds
   489                                   %endif
   490                                  %endif
   491                                  
   492                                   %if _EXTENSIONS || _HISTORY_SEPARATE_FIXED && _HISTORY || _APP_ENV_SIZE
   493 00000106 58                      	pop ax
   494                                    %if _HISTORY_SEPARATE_FIXED && _HISTORY
   495 00000107 A3[0000]                	mov word [history.segorsel + soaSegSel], ax
   496                                  %if _PM
   497                                  	mov word [history.segorsel + soaSegment], ax
   498                                  %endif
   499 0000010A 8EC0                    	mov es, ax
   500 0000010C 31FF                    	xor di, di
   501 0000010E B90010                  	mov cx, historysegment_size >> 1
   502 00000111 31C0                    	xor ax, ax
   503 00000113 F3AB                    	rep stosw
   504                                    %endif
   505                                  
   506                                    %if _APP_ENV_SIZE
   507                                     %if _HISTORY_SEPARATE_FIXED && _HISTORY
   508 00000115 8CC0                    	mov ax, es
   509 00000117 050002                  	add ax, paras(historysegment_size)
   510                                     %endif
   511 0000011A A3[0000]                	mov word [envseg], ax
   512 0000011D 8EC0                    	mov es, ax
   513 0000011F 31FF                    	xor di, di
   514 00000121 B90004                  	mov cx, app_env_size >> 1
   515 00000124 C706[0000]0008          	mov word [env_size], app_env_size
   516 0000012A 31C0                    	xor ax, ax
   517 0000012C F3AB                    	rep stosw
   518 0000012E 26C70603007F00          	mov word [es:3], paras(app_env_size - 16)
   519                                    %endif
   520                                  
   521                                    %if _EXTENSIONS
   522                                     %if _HISTORY_SEPARATE_FIXED && _HISTORY || _APP_ENV_SIZE
   523 00000135 8CC0                    	mov ax, es
   524                                      %if _APP_ENV_SIZE
   525 00000137 058000                  	add ax, paras(app_env_size)
   526                                      %else
   527                                  	add ax, paras(historysegment_size)
   528                                      %endif
   529                                     %endif
   530 0000013A A3[0000]                	mov word [extseg], ax
   531 0000013D 8EC0                    	mov es, ax
   532 0000013F 31FF                    	xor di, di
   533 00000141 B90010                  	mov cx, extsegment_size >> 1
   534 00000144 31C0                    	xor ax, ax
   535 00000146 F3AB                    	rep stosw
   536                                    %endif
   537                                   %endif
   538                                  
   539 00000148 89D8                    	mov ax, bx
   540                                  
   541 0000014A A3[0000]                	mov word [auxbuff_segorsel + soaSegSel], ax
   542                                  %if _PM
   543                                  	mov word [auxbuff_segorsel + soaSegment], ax
   544                                  					; initialise auxbuff references
   545                                  %endif
   546                                  %if _IMMASM  && _IMMASM_AUXBUFF
   547                                  	mov word [immseg], ax
   548                                  %endif
   549                                  
   550 0000014D 8EC0                    	mov es, ax
   551 0000014F 31FF                    	xor di, di
   552 00000151 B90810                  	mov cx, _AUXBUFFSIZE >> 1
   553 00000154 31C0                    	xor ax, ax
   554 00000156 F3AB                    	rep stosw			; initialise auxbuff
   555                                  
   556 00000158 FA                      	cli
   557 00000159 8CD8                    	mov ax, ds
   558 0000015B 8EC0                    	mov es, ax
   559 0000015D 8ED0                    	mov ss, ax
   560 0000015F BC[0000]                	mov sp, stack_end		; application mode stack switch
   561 00000162 FB                      	sti
   562                                  
   563 00000163 B44A                    	mov ah, 4Ah
   564                                  %ifn _LINK
   565                                  	mov bx, paras(APPINITSTACK_START)
   566                                  %else
   567 00000165 BB[8208]                	mov bx, strict word relocatedzero + paras( 		+ auxbuff_size + auxbuff_init_size 		+ historysegment_size 		+ app_env_size 		+ extsegment_size)
   572                                   wlcalc word_segrel_INIT, equ $ - 2
   573                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
   574                                   wlcalc word_wrt_INIT_extpara_behind_init, equ $ - 2
   575                                  %endif
   576 00000168 2E891E[220E]            	mov word [cs:init_target_size], bx
   577 0000016D 2E891E[200E]            	mov word [cs:init_base_size], bx
   578 00000172 CD21                    	int 21h				; shrink to drop init stack
   579                                  
   580                                  %if _CONFIG
   581                                  find_config_application:
   582 00000174 C606[0000]00            	mov byte [configpath], 0
   583 00000179 A12C00                  	mov ax, [2Ch]
   584 0000017C BF[260F]                	mov di, imsg.varconfig
   585 0000017F B90D00                  	mov cx, imsg.varconfig.length
   586 00000182 BA[0000]                	mov dx, configpath
   587 00000185 E8A230                  	call init_copyvar
   588 00000188 7303                    	jnc .done
   589 0000018A E82200                  	call find_executable_application
   590                                  .done:
   591                                  
   592                                  
   593                                  find_scripts_application:
   594 0000018D 36C606[0000]00          	mov byte [ss:scriptspath], 0
   595 00000193 36A12C00                	mov ax, [ss:2Ch]
   596 00000197 BF[330F]                	mov di, imsg.varscripts
   597 0000019A B90E00                  	mov cx, imsg.varscripts.length
   598 0000019D BA[0000]                	mov dx, scriptspath
   599 000001A0 E88730                  	call init_copyvar
   600 000001A3 7303                    	jnc .done
   601 000001A5 E80700                  	call find_executable_application
   602                                  .done:
   603                                  
   604 000001A8 16                      	push ss
   605 000001A9 1F                      	pop ds
   606 000001AA 16                      	push ss
   607 000001AB 07                      	pop es
   608                                  %endif
   609                                  
   610 000001AC E9001A                  	jmp old_initcode
   611                                  
   612                                  
   613                                  %if _CONFIG
   614                                  		; INP:	dx -> buffer
   615                                  		;	ds => PSP
   616                                  find_executable_application:
   617 000001AF A12C00                  	mov ax, [2Ch]
   618 000001B2 85C0                    	test ax, ax
   619 000001B4 743E                    	jz .noexec
   620 000001B6 8ED8                    	mov ds, ax
   621 000001B8 31F6                    	xor si, si
   622                                  @@:
   623 000001BA E80930                  	call init_nextvar
   624 000001BD 75FB                    	jne @B
   625 000001BF 46                      	inc si
   626 000001C0 AD                      	lodsw
   627 000001C1 83F801                  	cmp ax, 1
   628 000001C4 752E                    	jne .noexec
   629 000001C6 1E                      	push ds
   630 000001C7 07                      	pop es
   631 000001C8 89F7                    	mov di, si
   632 000001CA B97F00                  	mov cx, 127
   633 000001CD B000                    	mov al, 0
   634 000001CF F2AE                    	repne scasb
   635 000001D1 7521                    	jne .noexec
   636 000001D3 4F                      	dec di
   637                                  
   638 000001D4 B90000                  	mov cx, 0
   639                                  @@:
   640 000001D7 39F7                    	cmp di, si
   641 000001D9 7610                    	jbe @F
   642 000001DB 4F                      	dec di
   643 000001DC 803D2F                  	cmp byte [di], '/'
   644 000001DF 7405                    	je .slash
   645 000001E1 803D5C                  	cmp byte [di], '\'
   646 000001E4 75F1                    	jne @B
   647                                  .slash:
   648 000001E6 89F9                    	mov cx, di
   649 000001E8 41                      	inc cx
   650 000001E9 29F1                    	sub cx, si
   651                                  @@:
   652                                  
   653 000001EB 16                      	push ss
   654 000001EC 07                      	pop es
   655 000001ED 89D7                    	mov di, dx
   656 000001EF F3A4                    	rep movsb
   657 000001F1 B000                    	mov al, 0
   658 000001F3 AA                      	stosb
   659                                  
   660                                  .noexec:
   661                                  .done:
   662 000001F4 C3                      	retn
   663                                  %endif
   664                                  
   665                                  %endif
   666                                  
   667                                  
   668                                  %if _APPLICATION || _DEVICE
   669                                  		; INP:	ds => (pseudo) PSP, data/entry segment
   670                                  		; OUT:	word [code_seg] set
   671                                  		;	code segments placed
   672                                  		; CHG:	ax, cx, dx
   673                                  		; STT:	UP
   674                                  place_code_segments:
   675 000001F5 8CD8                    	mov ax, ds
   676                                  %ifn _LINK
   677                                  	add ax, paras(CODESECTIONOFFSET)
   678                                  %else
   679 000001F7 05[0000]                	add ax, strict word relocatedzero + 0
   680                                   wlcalc word_segrel_lDEBUG_CODE, equ $ - 2
   681                                  %endif
   682                                  				; => code1 image, then code2 image
   683                                   %if _BOOTLDR_DISCARD
   684                                  %ifn _LINK
   685                                  	mov word [code_size], ldebug_code_bootldr_truncated_size
   686                                  	mov cx, ldebug_code_bootldr_truncated_size_p
   687                                  %else
   688 000001FA C706[0000][0F00]        	mov word [code_size], behind_code_truncated + 15 wrt lDEBUG_CODE
   689                                   wlcalc word_clr_15, equ $ - 2
   690 00000200 B9[0000]                	mov cx, relocatedzero + 0
   691                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code_truncated, equ $ - 2
   692                                  %endif
   693                                  				; prepare for code1 segment move
   694                                    %if _DUALCODE
   695                                  	cmp ax, dx		; source above destination ?
   696                                  	jae @F			; yes -->
   697                                  	call .place_code2	; source is below, move "backward" (high first)
   698                                    %endif
   699 00000203 E89E18                  	call init_movp		; low last
   700                                    %if _DUALCODE
   701                                  	jmp @FF
   702                                  
   703                                  @@:
   704                                  	call init_movp		; source is above, move "forward" (low first)
   705                                  	call .place_code2	; high last
   706                                  @@:
   707                                    %endif
   708                                   %else
   709                                  %ifn _LINK
   710                                  	mov cx, ldebug_code_size_p + ldebug_code2_size_p	; untruncated
   711                                  %else
   712                                  	mov cx, 0
   713                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code2, equ $ - 2
   714                                  %endif
   715                                  	call init_movp
   716                                   %endif
   717 00000206 8916[0000]              	mov word [code_seg], dx	; initialise code segment reference
   718 0000020A C3                      	retn
   719                                  
   720                                   %if _BOOTLDR_DISCARD && _DUALCODE
   721                                  .place_code2:
   722                                  	push ax
   723                                  	push cx
   724                                  	push dx
   725                                  	add dx, cx		; => behind truncated code1 segment
   726                                  %ifn _LINK
   727                                  	add ax, ldebug_code_size_p	; untruncated
   728                                  				; => at code2 image
   729                                  	mov cx, ldebug_code2_size_p
   730                                  				; = size of code2 segment
   731                                  %else
   732                                  	add ax, strict word relocatedzero + 0
   733                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code, equ $ - 2
   734                                  	mov cx, relocatedzero + 0
   735                                   wlcalc word_wrt_@@lDEBUG_CODE2@_extpara_behind_code2, equ $ - 2
   736                                  %endif
   737                                  	call init_movp
   738                                  	pop dx
   739                                  	pop cx
   740                                  	pop ax
   741                                  	retn
   742                                   %endif
   743                                  %endif
   744                                  
   745                                  
   746                                  init_retf:
   747 0000020B CB                      	retf
   748                                  
   749                                  
   750                                  		; INP:	bx => destination for auxbuff
   751                                  		;	(The following are not actually used by this function,
   752                                  		;	 they're just what is passed in and preserved to
   753                                  		;	 be used by the caller after returning.)
   754                                  		;	dx => destination for code image
   755                                  		;	(if boot-loaded:) cx => destination for pseudo-PSP
   756                                  		;		(implies cx+10h => destination for data_entry)
   757                                  		;	ax => segment for history buffer
   758                                  		; OUT:	ZR if this destination for auxbuff doesn't cross
   759                                  		; 	 a 64 KiB boundary
   760                                  		;	NZ else
   761                                  		; CHG:	si, di
   762                                  init_check_auxbuff:
   763 0000020C 89DE                    	mov si, bx		; => auxbuff
   764                                  %if _AUXBUFFSIZE < 8192
   765                                   %error Expected full sector length auxbuff
   766                                  %endif
   767 0000020E 8DBC0002                	lea di, [si + (8192 >> 4)]; => behind auxbuff (at additional paragraph)
   768 00000212 81E600F0                	and si, 0F000h		; => 64 KiB chunk of first paragraph of auxbuff
   769 00000216 81E700F0                	and di, 0F000h		; => 64 KiB chunk of additional paragraph
   770 0000021A 39F7                    	cmp di, si		; same ?
   771                                  				; ZR if they are the same
   772 0000021C C3                      	retn
   773                                  
   774                                  
   775                                  %if _BOOTLDR
   776                                  		; Our loader transfers control to us with these registers:
   777                                  		; INP:	ss:bp -> BPB
   778                                  		;	ss:bp - 16 -> loadstackvars
   779                                  		;	ss:bp - 32 -> loaddata
   780                                  		;	(loader enters at) cs:0 -> loaded payload
   781                                  		;	(loader enters at) cs:32 -> entry point
   782                                  		;	(entrypoint sets up) ds:100h -> loaded payload
   783                                  		; STT:	EI, UP
   784                                  		;	all interrupts left from BIOS
   785                                  boot_initcode:
   786 0000021D FC                      	cld
   787                                  
   788                                  d4	call init_d4message
   789                                  d4	asciz "In boot_initcode",13,10
   790                                  
   791 0000021E 8B56E0                  	mov dx, word [bp + ldMemoryTop]
   792                                  
   793                                  		; initialise sdp
   794 00000221 8B461E                  	mov ax, word [bp + bsBPB + bpbHiddenSectors + 2]
   795 00000224 A3[4E00]                	mov word [load_data - LOADDATA2 + bsBPB + bpbHiddenSectors + 2], ax
   796 00000227 8B461C                  	mov ax, word [bp + bsBPB + bpbHiddenSectors]
   797 0000022A A3[4C00]                	mov word [load_data - LOADDATA2 + bsBPB + bpbHiddenSectors], ax
   798                                  
   799 0000022D 31DB                    	xor bx, bx
   800 0000022F 8A4640                  	mov al, byte [bp + bsBPB + ebpbNew + bpbnBootUnit]
   801 00000232 A2[7000]                	mov byte [load_data - LOADDATA2 + bsBPB + ebpbNew + bpbnBootUnit], al
   802 00000235 88C3                    	mov bl, al			; bx = LD unit
   803 00000237 84C0                    	 test al, al			; hdd or diskette ?
   804 00000239 8B46EC                  	mov ax, word [bp + ldQueryPatchValue]
   805 0000023C 7902                    	 jns @F				; diskette -->
   806 0000023E 86C4                    	xchg al, ah			; get high word of query patch value
   807                                  @@:
   808 00000240 84C0                    	test al, al			; use for our access to this unit ?
   809 00000242 7906                    	jns @F				; no -->
   810 00000244 2407                    	and al, luf_mask_writable	; clear unused bits
   811 00000246 8887[0000]              	mov byte [load_unit_flags + bx], al
   812                                  					; save here
   813                                  @@:
   814                                  
   815                                  
   816 0000024A 8CDB                    	mov bx, ds
   817 0000024C 8EC3                    	mov es, bx			; => data entry image
   818 0000024E BF[0000]                	mov di, loaddata_loadedfrom	; -> loaded from data (ldp)
   819                                  
   820                                  		; initialise LOADDATA, LOADSTACKVARS, and BPB
   821 00000251 16                      	push ss
   822 00000252 1F                      	pop ds
   823 00000253 8D76E0                  	lea si, [bp + LOADDATA]		; -> LOADDATA on stack
   824 00000256 B97A00                  	mov cx, (-LOADDATA + bsBPB + ebpbNew + BPBN_size)
   825 00000259 F3A4                    	rep movsb
   826                                  
   827                                  		; initialise cmdline_buffer from below LOADDATA
   828 0000025B 8DB6E0FE                	lea si, [bp + ldCommandLine.start]
   829 0000025F BF[0000]                	mov di, cmdline_buffer		; -> our buffer in data entry
   830                                  
   831 00000262 813C00FF                	cmp word [si], 0FF00h
   832 00000266 7505                    	jne @F
   833                                  
   834 00000268 0E                      	 push cs
   835 00000269 1F                      	 pop ds
   836 0000026A BE[7417]                	mov si, imsg.default_cmdline.boot
   837                                  
   838                                  @@:
   839 0000026D AC                      	lodsb
   840 0000026E 84C0                    	test al, al
   841 00000270 7423                    	jz @FF
   842                                  
   843 00000272 26800E[0100]01          	setopt [es:internalflags3], dif3_input_cmdline
   844 00000278 A9                      	db __TEST_IMM16
   845                                  .switch_c_loop:
   846 00000279 AA                      	stosb
   847 0000027A AC                      	lodsb
   848                                  .switch_c_loop_after_semicolon:
   849 0000027B 3C00                    	cmp al, 0
   850 0000027D 7415                    	je @F
   851 0000027F 3C3B                    	cmp al, ';'
   852 00000281 7508                    	jne .switch_c_not_semicolon
   853 00000283 B00D                    	mov al, 13
   854 00000285 AA                      	stosb
   855 00000286 E86030                  	call init_skipwhite
   856 00000289 EBF0                    	jmp .switch_c_loop_after_semicolon
   857                                  
   858                                  .switch_c_not_semicolon:
   859 0000028B 3C5C                    	cmp al, '\'
   860 0000028D 75EA                    	jne .switch_c_loop
   861 0000028F AC                      	lodsb
   862 00000290 3C00                    	cmp al, 0
   863 00000292 75E5                    	jne .switch_c_loop
   864                                  
   865                                  @@:
   866 00000294 AA                      	stosb
   867                                  @@:
   868                                  
   869                                  		; es => data entry image
   870 00000295 16                      	push ss
   871 00000296 1F                      	pop ds
   872 00000297 8D765A                  	lea si, [bp + bsBPB + ebpbNew + BPBN_size]	; -> tail (FAT32 style)
   873                                  		; ds:si -> tail. this is the same for FAT12/FAT16 as FAT32
   874 0000029A B9C201                  	mov cx, 512 - (bsBPB + bpbNew + BPBN_size)	; tail size FAT12/FAT16
   875 0000029D 837E1600                	cmp word [bp + bsBPB + bpbSectorsPerFAT], 0
   876 000002A1 7503                    	jne @F
   877 000002A3 B9A601                  	mov cx, 512 - (bsBPB + ebpbNew + BPBN_size)	; tail size FAT32
   878                                  @@:
   879 000002A6 E8C704                  	call findname
   880                                  
   881                                  %if _EXECUTABLE
   882 000002A9 53                      	push bx
   883 000002AA 06                      	push es
   884 000002AB 1F                      	pop ds
   885 000002AC BE[0000]                	mov si, boot_init_foundname
   886 000002AF BF[0000]                	mov di, init_executable_pathname
   887 000002B2 803C00                  	cmp byte [si], 0
   888 000002B5 7415                    	je .unable
   889                                  
   890 000002B7 31C9                    	xor cx, cx
   891 000002B9 89F3                    	mov bx, si
   892                                  @@:
   893 000002BB AC                      	lodsb
   894 000002BC 41                      	inc cx
   895 000002BD 84C0                    	test al, al
   896 000002BF 75FA                    	jnz @B
   897                                  
   898 000002C1 BE[C217]                	mov si, imsg.ldpslash
   899                                  
   900 000002C4 2EA5                    	cs movsw
   901 000002C6 2EA5                    	cs movsw
   902                                  
   903 000002C8 89DE                    	mov si, bx
   904 000002CA F3A4                    	rep movsb
   905                                  
   906                                  .unable:
   907 000002CC BF[0000]                	mov di, init_executable_pathname
   908 000002CF 31C0                    	xor ax, ax
   909 000002D1 B98000                  	mov cx, 128
   910 000002D4 F2AE                    	repne scasb
   911 000002D6 4F                      	dec di
   912 000002D7 893E[0000]              	mov word [init_executable_pathname.end], di
   913 000002DB 5B                      	pop bx
   914                                  %endif
   915                                  
   916 000002DC 89D0                    	mov ax, dx
   917                                  %ifn _LINK
   918                                  	sub ax, paras(BOOTDELTA)
   919                                  %else
   920                                   %if 0
   921                                  %define BOOTDELTA	(fromkib(kib(auxbuff_size * 2 				+ historysegment_boot_size 				+ boot_env_size 				+ extsegment_boot_size 				+ datastack_size 				+ INITSECTIONOFFSET + 16)))
   927                                   %endif
   928 000002DE 2D[830A]                	sub ax, strict word relocatedzero + paras( 		+ auxbuff_size * 2 		+ historysegment_boot_size 		+ boot_env_size 		+ extsegment_boot_size 		+ 16)
   934                                   wlcalc word_segrel_INIT, equ $ - 2
   935                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
   936                                   wlcalc word_add_63, equ $ - 2		; 1023 >> 4
   937                                   wlcalc word_clr_63, equ $ - 2		; 1023 >> 4
   938                                  %endif
   939 000002E1 7303E96101              	jc .error_out_of_memory
   940                                  		; We exaggerate the target size (BOOTDELTA) for the
   941                                  		;  worst case, thus we do not need to check for narrower
   942                                  		;  fits later on. BOOTDELTA includes the pseudo-PSP size,
   943                                  		;  data_entry size, asmtable1_size, asmtable2_size,
   944                                  		;  datastack_size, code_size, 2 times auxbuff_size,
   945                                  		;  historysegment_boot_size, boot_env_size,
   946                                  		;  extsegment_boot_size,
   947                                  		;  plus 16 bytes for the image ident prefix paragraph,
   948                                  		;  and all of that rounded to a kibibyte boundary.
   949                                  
   950 000002E6 8CC9                    	mov cx, cs
   951                                  %ifn _LINK
   952                                  	add cx, paras(init_size + BOOTINITSTACK_SIZE)
   953                                  %else
   954 000002E8 81C1[2000]              	add cx, strict word relocatedzero + paras(BOOTINITSTACK_SIZE)
   955                                   wlcalc word_wrt_INIT_extpara_behind_init, equ $ - 2
   956                                  %endif
   957 000002EC 7303E95601              	jc .error_out_of_memory
   958 000002F1 39D1                    	cmp cx, dx
   959 000002F3 7603E94F01              	ja .error_out_of_memory
   960                                  		; This requires that above the image (including init)
   961                                  		;  there is some 512 bytes free. That could be a problem
   962                                  		;  except we've already exhausted the iniload-internally
   963                                  		;  used buffers + stack, and do not need to preserve any
   964                                  		;  of those. Recall that dx holds MemoryTop, *not* the
   965                                  		;  lower LoadTop which could be right behind the image.
   966                                  		; The sector buffer alone is documented as being 8 KiB
   967                                  		;  sized, not to mention the FAT buffer and stack and
   968                                  		;  LOADDATA/LOADSTACKVARS/BPB/boot sector.
   969                                  
   970 000002F8 F646E704                	testopt [bp + ldHasLBA], ldhlfPreserveLoader
   971                                  		; set NZ if loader resident
   972                                  
   973 000002FC 8CCF                    	mov di, cs
   974 000002FE FA                      	cli
   975 000002FF 8ED7                    	mov ss, di
   976                                  %ifn _LINK
   977                                  	mov sp, init_size + BOOTINITSTACK_SIZE
   978                                  %else
   979 00000301 BC[0002]                	mov sp, BOOTINITSTACK_SIZE + behind_init wrt INIT
   980                                  %endif
   981 00000304 FB                      	sti
   982                                  
   983                                  d4	call init_d4message
   984                                  d4	asciz "Switched to init stack",13,10
   985                                  
   986                                  	lframe none
   987                                  	lvar word,	target
   988 00000305 5589E550                	lenter
   989                                  	lvar word,	targetstart
   990 00000309 50                      	 push ax
   991                                  	lvar word,	memtop
   992 0000030A 52                      	 push dx
   993 0000030B 8D7F10                  	lea di, [bx + 10h]
   994                                  	lvar word,	data
   995 0000030E 57                      	 push di
   996                                  	lvar word,	lowestused
   997 0000030F 57                      	 push di
   998                                  %ifn _LINK
   999                                  	lea di, [bx + paras(CODESECTIONOFFSET)]
  1000                                  %else
  1001 00000310 8DBF[0000]              	lea di, [word relocatedzero + bx + 0]
  1002                                   wlcalc word_segrel_lDEBUG_CODE, equ $ - 2
  1003                                  %endif
  1004                                  	lvar word,	code
  1005 00000314 57                      	 push di
  1006                                  	lvar dword,	loaderentry
  1007 00000315 50                      	 push ax
  1008 00000316 50                      	 push ax
  1009 00000317 BF6000                  	mov di, 60h
  1010                                  	lvar word,	lowlimit
  1011 0000031A 57                      	 push di
  1012                                  
  1013                                  %if !_LOADER
  1014 0000031B 51                      	push cx
  1015 0000031C 50                      	push ax
  1016                                  
  1017                                  		; had set NZ if loader resident
  1018 0000031D 745B                    	jz .no_loader
  1019 0000031F E80705                  	call get_size_and_ebda
  1020 00000322 8B5EFA                  	mov bx, word [bp + ?memtop]
  1021 00000325 2E031E[340E]            	add bx, [cs:init_boot_ebdasize]
  1022 0000032A 8EC3                    	mov es, bx
  1023 0000032C 31FF                    	xor di, di
  1024 0000032E 0E                      	 push cs
  1025 0000032F 1F                      	 pop ds
  1026 00000330 BE[000E]                	mov si, loader_imageident
  1027 00000333 B90300                  	mov cx, words(loader_imageident.size)
  1028 00000336 BA[D818]                	mov dx, imsg.boot_warn_no_loader
  1029 00000339 F3A7                    	repe cmpsw
  1030 0000033B 7532                    	jne .loaderwarning
  1031 0000033D 31F6                    	xor si, si
  1032 0000033F 31D2                    	xor dx, dx
  1033 00000341 B90800                  	mov cx, 8
  1034                                  @@:
  1035 00000344 26AD                    	es lodsw
  1036 00000346 01C2                    	add dx, ax
  1037 00000348 E2FA                    	loop @B
  1038 0000034A BA[F518]                	mov dx, imsg.boot_warn_invalid_loader
  1039 0000034D 7520                    	jnz .loaderwarning
  1040                                  
  1041 0000034F 895EF2                  	mov word [bp + ?loaderentry + 2], bx
  1042 00000352 2EF616[3B0E]            	not byte [cs:init_preserveloader]
  1043 00000357 BA[1319]                	mov dx, imsg.boot_warn_lazy_loader
  1044 0000035A 268B0E1000              	mov cx, word [es:liiEntryQuerySize]
  1045 0000035F E30E                    	jcxz .loaderwarning
  1046 00000361 894EF0                  	mov word [bp + ?loaderentry], cx
  1047 00000364 B86000                  	mov ax, 60h
  1048 00000367 FF5EF0                  	call far [bp + ?loaderentry]
  1049 0000036A 8946EE                  	mov word [bp + ?lowlimit], ax
  1050 0000036D EB0B                    	jmp @F
  1051                                  
  1052                                  .loaderwarning:
  1053 0000036F 52                      	push dx
  1054 00000370 BA[BA18]                	mov dx, imsg.bootwarn
  1055 00000373 E8E117                  	call init_putsz_cs_bootldr
  1056 00000376 5A                      	pop dx
  1057 00000377 E8DD17                  	call init_putsz_cs_bootldr
  1058                                  @@:
  1059                                  
  1060                                  .no_loader:
  1061 0000037A 58                      	pop ax
  1062 0000037B 59                      	pop cx
  1063                                  %endif
  1064                                  
  1065 0000037C 39C1                    	cmp cx, ax			; does init end below-or-equal target ?
  1066 0000037E 7703E9DF00              	jbe .no_relocation		; yes, no relocation needed -->
  1067                                  
  1068                                  d4	call init_d4message
  1069                                  d4	asciz "Needs relocation of init segment",13,10
  1070                                  
  1071 00000383 8B46F8                  	mov ax, word [bp + ?data]
  1072                                  %ifn _LINK
  1073                                  	sub ax, strict word paras(init_size + BOOTINITSTACK_SIZE)
  1074                                  %else
  1075 00000386 2D[2000]                	sub ax, strict word relocatedzero + paras(BOOTINITSTACK_SIZE)
  1076                                   wlcalc word_wrt_INIT_extpara_behind_init, equ $ - 2
  1077                                  %endif
  1078 00000389 7303E9B900              	jc .error_out_of_memory		; already at start of memory -->
  1079 0000038E 3B46EE                  	cmp ax, [bp + ?lowlimit]
  1080 00000391 7303E9B100              	jb .error_out_of_memory		; already at start of memory -->
  1081                                  
  1082                                  		; The relocation never overlaps, as we move init
  1083                                  		;  and its stack to the space before the image.
  1084                                  		;  Therefore we can move UP. And only a single
  1085                                  		;  rep movsw instruction is needed as init and
  1086                                  		;  its stack always fit in a single segment.
  1087 00000396 0E                      	push cs
  1088 00000397 1F                      	pop ds
  1089 00000398 31F6                    	xor si, si			; -> init source
  1090 0000039A 8EC0                    	mov es, ax
  1091 0000039C 8946F6                  	mov word [bp + ?lowestused], ax
  1092 0000039F 31FF                    	xor di, di			; -> init destination
  1093                                  %ifn _LINK
  1094                                  	mov cx, words(init_size + BOOTINITSTACK_SIZE)
  1095                                  %else
  1096 000003A1 B9[0102]                	mov cx, BOOTINITSTACK_SIZE + 1 + behind_init wrt INIT
  1097                                   wlcalc word_shr_1, equ $ - 2
  1098                                  %endif
  1099 000003A4 F3A5                    	rep movsw			; relocate only init
  1100                                  		; Must not modify the data already on the stack here,
  1101                                  		;  until after either .done_relocation or
  1102                                  		;  .entire_relocation_done (which both relocate ss).
  1103                                  
  1104 000003A6 50                      	push ax
  1105 000003A7 E861FE                  	call init_retf			; jump to new init
  1106                                  
  1107                                  	; mov ss, ax
  1108                                  		; Logic error: The entire load image relocation would
  1109                                  		;  make it so that the stack would corrupt part of the
  1110                                  		;  load image that had been relocated the first time
  1111                                  		;  already here. We want to keep using the high stack
  1112                                  		;  here until both relocations are done, at which point
  1113                                  		;  we *must* relocate ss so as to get the stack out of
  1114                                  		;  the way of installing the final image components.
  1115                                  		; Avoid modifying the stack frame variables until after
  1116                                  		;  we have relocated the stack. However, temporary use
  1117                                  		;  of the stack is okay before relocating it. (It must
  1118                                  		;  be because IRQs and debugger tracing will use it.)
  1119 000003AA 8B4EF4                  	mov cx, word [bp + ?code]
  1120                                  %ifn _LINK
  1121                                  	add cx, paras(ldebug_code_size + ldebug_code2_size)	; untruncated
  1122                                  %else
  1123 000003AD 81C1[0000]              	add cx, strict word relocatedzero + 0
  1124                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code2, equ $ - 2
  1125                                  %endif
  1126 000003B1 3B4EFC                  	cmp cx, word [bp + ?targetstart]
  1127                                  					; does code end below-or-equal target ?
  1128 000003B4 7703E99C00              	jbe .done_relocation		; yes, relocated enough -->
  1129                                  
  1130                                  .entire_relocation_needed:
  1131                                  d4	call init_d4message
  1132                                  d4	asciz "Needs relocation of entire load image",13,10
  1133                                  
  1134 000003B9 8B56EE                  	mov dx, [bp + ?lowlimit]
  1135 000003BC 8EC2                    	mov es, dx
  1136 000003BE 8CC8                    	mov ax, cs
  1137 000003C0 39C2                    	cmp dx, ax			; already at start of memory ?
  1138 000003C2 7203E98000              	jae .error_out_of_memory	; then error -->
  1139                                  		; This move is always downwards, that is, we can
  1140                                  		;  move UP. Multiple instructions operating on
  1141                                  		;  different segments may be needed as the image
  1142                                  		;  can be larger than 64 KiB.
  1143                                  		; However, init was already moved to before the
  1144                                  		;  remainder of the image, so the first 64 KiB
  1145                                  		;  move will always leave init finished and
  1146                                  		;  ready to use. So only move the first chunk
  1147                                  		;  in the special relocator, then jump into the
  1148                                  		;  final relocated init to do the remainder.
  1149                                  
  1150 000003C7 42                      	inc dx
  1151                                  	; cmp dx, ax
  1152                                  	; ja .error_out_of_memory
  1153 000003C8 B9[0104]                	mov cx, .relocated
  1154 000003CB 52                      	 push dx
  1155 000003CC 51                      	 push cx			; on stack: far address of .relocated
  1156                                  
  1157 000003CD 89C1                    	mov cx, ax			; source
  1158 000003CF 29D1                    	sub cx, dx			; source - target = how far to relocate
  1159                                  
  1160 000003D1 31FF                    	xor di, di			; es:di -> where to put relocator
  1161 000003D3 06                      	push es
  1162 000003D4 57                      	push di				; on stack: relocator destination
  1163 000003D5 51                      	push cx				; on stack: how far to relocate
  1164 000003D6 0E                      	 push cs
  1165 000003D7 1F                      	 pop ds
  1166 000003D8 BE[FE03]                	mov si, .relocator		; -> relocator source
  1167 000003DB B90800                  	mov cx, 8
  1168 000003DE F3A5                    	rep movsw			; put relocator stub
  1169                                  
  1170 000003E0 8EC2                    	mov es, dx
  1171 000003E2 5A                      	pop dx				; dx = how far to relocate
  1172                                  
  1173 000003E3 31FF                    	xor di, di			; -> where to relocate to
  1174 000003E5 31F6                    	xor si, si			; -> relocate start
  1175                                  
  1176                                  %ifn _LINK
  1177                                  BOOTRELOC1 equ	paras( init_size + BOOTINITSTACK_SIZE 			+ DATAENTRYTABLESIZE 			+ messagesegment_size 			+ ldebug_code_size + ldebug_code2_size)	; untruncated
  1181                                  %endif
  1182                                  
  1183                                  %if _LINK_COMPAT || _LINK
  1184                                   %ifn _LINK
  1185                                  	mov cx, BOOTRELOC1		; how much to relocate
  1186                                   %else
  1187 000003E7 B9[1000]                	mov cx, relocatedzero + paras(BOOTINITSTACK_SIZE - 256)
  1188                                   wlcalc word_wrt_INIT_extpara_behind_init, equ $ - 2
  1189                                   wlcalc word_wrt_@@lDEBUG_DATA_ENTRY@_extpara_behind_progbits_dataentry, equ $ - 2
  1190                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment, equ $ - 2
  1191                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code2, equ $ - 2
  1192                                   %endif
  1193 000003EA BB0010                  	mov bx, 1000h
  1194 000003ED 89C8                    	mov ax, cx
  1195 000003EF 39D8                    	cmp ax, bx			; > 64 KiB?
  1196 000003F1 7602                    	jbe @F
  1197 000003F3 89D9                    	mov cx, bx			; first relocate the first 64 KiB
  1198                                  @@:
  1199 000003F5 29C8                    	sub ax, cx			; how much to relocate later
  1200 000003F7 D1E1                    	shl cx, 1
  1201 000003F9 D1E1                    	shl cx, 1
  1202 000003FB D1E1                    	shl cx, 1			; how much to relocate first,
  1203                                  					;  << 3 == convert paragraphs to words
  1204                                  %else
  1205                                  	mov bx, 1000h
  1206                                   %if BOOTRELOC1 > 1000h
  1207                                  	mov cx, 8000h
  1208                                  	mov ax, BOOTRELOC1 - 1000h
  1209                                   %else
  1210                                  	mov cx, BOOTRELOC1 << 3
  1211                                  	xor ax, ax
  1212                                   %endif
  1213                                  %endif
  1214 000003FD CB                      	retf				; jump to relocator
  1215                                  
  1216                                  		; ds:si -> first chunk of to be relocated data
  1217                                  		; es:di -> first chunk of relocation destination
  1218                                  		;  (si = di = 0, and es always <= ds)
  1219                                  		; cx = number of words in first chunk
  1220                                  		; ax = how many paragraphs remain after first chunk is done
  1221                                  		; dx = how far to relocate in paragraphs
  1222                                  		; bx = 1000h
  1223                                  		; ss:sp -> far return address into relocated init section
  1224                                  		;  (this always points into the first chunk)
  1225                                  .relocator:
  1226 000003FE F3A5                    	rep movsw
  1227 00000400 CB                      	retf				; jump to relocated cs : .relocated
  1228                                  .relocator_size equ $ - .relocator
  1229                                  %if .relocator_size > 16
  1230                                   %error Unexpected large relocator
  1231                                  %endif
  1232                                  
  1233                                  .relocated:
  1234                                  		; ds => prior chunk of relocation source (may be corrupted)
  1235                                  		; es => prior chunk of relocation destination
  1236                                  		; cx = 0
  1237                                  		; ax = how many paragraphs remain
  1238                                  		; dx = how far to relocate in paragraphs
  1239                                  		; bx = 1000h
  1240                                  @@:
  1241 00000401 8CC1                    	mov cx, es
  1242 00000403 01D9                    	add cx, bx
  1243 00000405 8EC1                    	mov es, cx	; => next segment
  1244                                  
  1245 00000407 8CD9                    	mov cx, ds
  1246 00000409 01D9                    	add cx, bx
  1247 0000040B 8ED9                    	mov ds, cx	; => next segment
  1248                                  
  1249 0000040D 29D8                    	sub ax, bx	; = how much to relocate after this round
  1250 0000040F B90080                  	mov cx, 1000h << 3	; in case another full 64 KiB to relocate
  1251 00000412 730B                    	jae @F		; another full 64 KiB to relocate this round -->
  1252 00000414 01D8                    	add ax, bx	; restore (possibly zero)
  1253 00000416 D1E0                    	shl ax, 1
  1254 00000418 D1E0                    	shl ax, 1
  1255 0000041A D1E0                    	shl ax, 1	; convert paragraphs to words
  1256 0000041C 91                      	xchg cx, ax	; cx = that many words (possibly zero)
  1257 0000041D 31C0                    	xor ax, ax	; no more to relocate after this round
  1258                                  
  1259                                  @@:
  1260                                  		; ds:0 -> next chunk of source
  1261                                  		; es:0 -> next chunk of destination
  1262                                  		; cx = how many words in this chunk, may be zero
  1263                                  		; ax = how many paragraphs remain for next round
  1264                                  		; (if ax is nonzero then cx is 8000h for a full 64 KiB)
  1265                                  		; dx = how far to relocate in paragraphs
  1266                                  		; bx = 1000h
  1267 0000041F 31F6                    	xor si, si	; -> source
  1268 00000421 31FF                    	xor di, di	; -> destination
  1269 00000423 F3A5                    	rep movsw	; relocate next chunk
  1270 00000425 85C0                    	test ax, ax	; another round needed?
  1271 00000427 75D8                    	jnz @BB		; yes -->
  1272                                  
  1273                                  .entire_relocation_done:
  1274 00000429 8CC8                    	mov ax, cs
  1275 0000042B 8ED0                    	mov ss, ax			; relocate the stack
  1276 0000042D 90                      	nop
  1277                                  		; The stack frame variables have been relocated here
  1278                                  		;  along with the INIT segment data.
  1279                                  
  1280                                  		; Now okay to modify relocated stack frame variables.
  1281 0000042E 8946F6                  	mov word [bp + ?lowestused], ax
  1282 00000431 2956F8                  	sub word [bp + ?data], dx
  1283 00000434 721A                    	jc .error_internal
  1284 00000436 2956F4                  	sub word [bp + ?code], dx
  1285 00000439 7215                    	jc .error_internal
  1286                                  
  1287 0000043B 8B4EF4                  	mov cx, word [bp + ?code]
  1288                                   %ifn _LINK
  1289                                  	add cx, paras(ldebug_code_size + ldebug_code2_size)	; untruncated
  1290                                   %else
  1291 0000043E 81C1[0000]              	add cx, strict word relocatedzero + 0
  1292                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code2, equ $ - 2
  1293                                   %endif
  1294 00000442 3B4EFC                  	cmp cx, word [bp + ?targetstart]
  1295                                  					; does code end below-or-equal target ?
  1296 00000445 760E                    	jbe .done_relocation		; yes -->
  1297                                  
  1298                                  .error_out_of_memory:
  1299 00000447 BA[4018]                	mov dx, imsg.boot_error_out_of_memory
  1300                                  .putsz_error:
  1301 0000044A E80A17                  	call init_putsz_cs_bootldr
  1302 0000044D E95A04                  	jmp init_booterror.soft
  1303                                  
  1304                                  .error_internal:
  1305 00000450 BA[5118]                	mov dx, imsg.boot_error_internal
  1306 00000453 EBF5                    	jmp .putsz_error
  1307                                  
  1308                                  
  1309                                  .done_relocation:
  1310 00000455 8CC8                    	mov ax, cs
  1311 00000457 8ED0                    	mov ss, ax			; relocate the stack
  1312 00000459 90                      	nop
  1313                                  		; Not needed if we got here after having executed
  1314                                  		;  .entire_relocation_done or by branching to this
  1315                                  		;  place through the .no_relocation label, but
  1316                                  		;  doesn't hurt in those cases either.
  1317                                  		; The stack frame variables have been relocated here
  1318                                  		;  along with the INIT segment data.
  1319 0000045A 8B46F6                  	mov ax, word [bp + ?lowestused]
  1320 0000045D 3B46EE                  	cmp ax, word [bp + ?lowlimit]
  1321 00000460 72E5                    	jb .error_out_of_memory
  1322                                  
  1323                                  .no_relocation:
  1324 00000462 2EC606[AF08]A8          	mov byte [cs:init_booterror.patch_switch_stack], __TEST_IMM8
  1325                                  					; SMC in section INIT
  1326                                  
  1327                                  		; Due to the prior check in .done_relocation,
  1328                                  		;  we only go to .relocatehigh if the init is
  1329                                  		;  still at its initial position (*above* the
  1330                                  		;  data and code images). We depend on this
  1331                                  		;  in order to relocate init first, then do
  1332                                  		;  the remaining (image) relocation from init.
  1333 00000468 8B46F6                  	mov ax, word [bp + ?lowestused]
  1334 0000046B 2B46EE                  	sub ax, word [bp + ?lowlimit]
  1335 0000046E 735E                    	jae .highenough
  1336                                  .relocatehigh:
  1337 00000470 F7D8                    	neg ax				; how much to relocate higher
  1338 00000472 8CC9                    	mov cx, cs
  1339                                  %ifn _LINK
  1340                                  	add cx, paras(init_size + BOOTINITSTACK_SIZE + 256)
  1341                                  %else
  1342 00000474 81C1[3000]              	add cx, strict word relocatedzero + paras(BOOTINITSTACK_SIZE + 256)
  1343                                   wlcalc word_wrt_INIT_extpara_behind_init, equ $ - 2
  1344                                  %endif
  1345 00000478 72CD                    	jc .error_out_of_memory
  1346 0000047A 01C1                    	add cx, ax			; => past wanted init
  1347 0000047C 72C9                    	jc .error_out_of_memory
  1348 0000047E 3B4EFC                  	cmp cx, word [bp + ?targetstart]
  1349 00000481 73C4                    	jae .error_out_of_memory	; if too little left -->
  1350                                  
  1351 00000483 8CCA                    	mov dx, cs
  1352 00000485 01C2                    	add dx, ax			; => destination init
  1353 00000487 89E3                    	mov bx, sp			; preserve sp
  1354 00000489 FA                      	cli
  1355 0000048A 8ED2                    	mov ss, dx
  1356                                  %ifn _LINK
  1357                                  	mov sp, fromwords(words(init_size + BOOTINITSTACK_SIZE + 256 - 1))
  1358                                  %else
  1359 0000048C BC[0003]                	mov sp, behind_init + BOOTINITSTACK_SIZE + 256 wrt INIT
  1360                                   wlcalc word_clr_1, equ $ - 2
  1361                                  %endif
  1362                                  					; go to temporary stack
  1363 0000048F FB                      	sti
  1364 00000490 BF[B204]                	mov di, .relocatedhigh
  1365 00000493 52                      	  push dx
  1366 00000494 57                      	  push di			; -> relocated .relocatedhigh (temp stack)
  1367 00000495 41                      	inc cx
  1368 00000496 8EC1                    	mov es, cx			; => relocator destination
  1369 00000498 31FF                    	xor di, di
  1370 0000049A 06                      	  push es
  1371 0000049B 57                      	  push di			; -> relocator destination (temp stack)
  1372 0000049C 0E                      	 push cs
  1373 0000049D 1F                      	 pop ds
  1374 0000049E BE[FE03]                	mov si, .relocator		; -> relocator source
  1375 000004A1 B90800                  	mov cx, 8
  1376 000004A4 F3A5                    	rep movsw			; put relocator stub
  1377 000004A6 8EC2                    	mov es, dx
  1378                                  %ifn _LINK
  1379                                  	mov cx, words(init_size + BOOTINITSTACK_SIZE)
  1380                                  	mov si, fromwords(words(init_size + BOOTINITSTACK_SIZE)) - 2
  1381                                  %else
  1382 000004A8 B9[0102]                	mov cx, behind_init + BOOTINITSTACK_SIZE + 1 wrt INIT
  1383                                   wlcalc word_shr_1, equ $ - 2
  1384 000004AB BE[FF01]                	mov si, behind_init + BOOTINITSTACK_SIZE + 1 - 2 wrt INIT
  1385                                   wlcalc word_clr_1, equ $ - 2
  1386                                  %endif
  1387 000004AE 89F7                    	mov di, si			; -> last word
  1388 000004B0 FD                      	std
  1389 000004B1 CB                      	retf				; (uses temp stack)
  1390                                  
  1391                                  .relocatedhigh:
  1392 000004B2 FC                      	cld
  1393                                  %if 0		; ss already == dx
  1394                                  	cli
  1395                                  	mov ss, dx
  1396                                  	mov sp, bx
  1397                                  	sti
  1398                                  %else
  1399 000004B3 89DC                    	mov sp, bx			; restore original stack
  1400                                  %endif
  1401 000004B5 8B56F8                  	mov dx, word [bp + ?data]	; => data source
  1402 000004B8 0146F8                  	add word [bp + ?data], ax
  1403 000004BB 7293                    	jc .error_internal
  1404 000004BD 0146F4                  	add word [bp + ?code], ax
  1405 000004C0 728E                    	jc .error_internal
  1406                                  
  1407 000004C2 52                      	push dx
  1408 000004C3 01C2                    	add dx, ax			; => data destination
  1409 000004C5 7289                    	jc .error_internal
  1410 000004C7 58                      	pop ax				; => data source
  1411                                  %ifn _LINK
  1412                                  	mov cx, paras(CODESECTIONOFFSET 		+ ldebug_code_size + ldebug_code2_size)	; untruncated
  1414                                  %else
  1415 000004C8 B9[0000]                	mov cx, relocatedzero + 0
  1416                                   wlcalc word_wrt_@@lDEBUG_DATA_ENTRY@_extpara_behind_code2, equ $ - 2
  1417                                  %endif
  1418                                  					; = data + code size
  1419 000004CB E8D615                  	call init_movp
  1420                                  
  1421                                  .highenough:
  1422                                  
  1423                                  
  1424                                  d4	call init_d4message
  1425                                  d4	asciz "Relocated enough",13,10
  1426                                  
  1427                                  
  1428                                  %if !_LOADER
  1429 000004CE 2ED006[3B0E]            	rol byte [cs:init_preserveloader], 1
  1430 000004D3 7326                    	jnc @F
  1431                                  
  1432 000004D5 BA[4419]                	mov dx, imsg.boot_warn_loader_no_reloc
  1433 000004D8 8E46F2                  	mov es, word [bp + ?loaderentry + 2]
  1434 000004DB 268B0E1200              	mov cx, word [es:liiEntryRelocate]
  1435 000004E0 E30E                    	jcxz .reloc_loaderwarning
  1436 000004E2 894EF0                  	mov word [bp + ?loaderentry], cx
  1437 000004E5 B86000                  	mov ax, 60h
  1438 000004E8 FF5EF0                  	call far [bp + ?loaderentry]
  1439 000004EB 8946F2                  	mov word [bp + ?loaderentry + 2], ax
  1440                                  					; update our reference
  1441 000004EE EB0B                    	jmp @F
  1442                                  
  1443                                  .reloc_loaderwarning:
  1444 000004F0 52                      	push dx
  1445 000004F1 BA[BA18]                	mov dx, imsg.bootwarn
  1446 000004F4 E86016                  	call init_putsz_cs_bootldr
  1447 000004F7 5A                      	pop dx
  1448 000004F8 E85C16                  	call init_putsz_cs_bootldr
  1449                                  @@:
  1450                                  %endif
  1451                                  
  1452 000004FB E82B03                  	call get_size_and_ebda
  1453                                  
  1454 000004FE 8B4EFA                  	mov cx, word [bp + ?memtop]
  1455 00000501 2E030E[340E]            	add cx, [cs:init_boot_ebdasize]
  1456                                  %ifn _LINK
  1457                                  	sub cx, paras(INITSECTIONOFFSET - messagesegment_size + messagesegment_nobits_size + datastack_size + auxbuff_size + historysegment_boot_size + boot_env_size + extsegment_boot_size)
  1458                                  %else
  1459 00000506 81E9[8108]              	sub cx, relocatedzero + paras( 		+ auxbuff_size 		+ historysegment_boot_size 		+ boot_env_size 		+ extsegment_boot_size)
  1464                                   wlcalc word_segrel_INIT, equ $ - 2
  1465                                   wlcalc word_wrt_MESSAGESEGMENT_minusextpara_behind_messagesegment, equ $ - 2
  1466                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits, equ $ - 2
  1467                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  1468                                  %endif
  1469                                  
  1470                                  					; cx = paragraph of pseudo-PSP if here
  1471                                  %if !_LOADER
  1472 0000050A 49                      	dec cx				; => paragraph of image ident
  1473 0000050B 83E1C0                  	and cx, ~ (paras(1024) - 1)	; round down to kibibyte boundary
  1474 0000050E 41                      	inc cx				; => paragraph of pseudo-PSP if here
  1475                                  %else
  1476                                  	and cx, ~ (paras(1024) - 1)	; round down to kibibyte boundary
  1477                                  %endif
  1478                                  
  1479 0000050F 89CB                    	mov bx, cx
  1480 00000511 89DA                    	mov dx, bx
  1481                                  %ifn _LINK
  1482                                  	add bx, paras(BOOTAUXTARGET1)	; => auxbuff target if here
  1483                                  	add dx, paras(BOOTCODETARGET1)	; => code target if here
  1484                                   %if _EXTENSIONS || _HISTORY_SEPARATE_FIXED && _HISTORY || _BOOT_ENV_SIZE
  1485                                  	mov ax, bx
  1486                                  	add ax, paras(auxbuff_size)
  1487                                    %if BOOTAUXTARGET1_equate <= BOOTCODETARGET1_equate
  1488                                     %error Unexpected layout
  1489                                    %endif
  1490                                   %endif
  1491                                  %else	; _LINK
  1492                                  %if 0
  1493                                  %define BOOTCODETARGET1 (MESSAGESECTIONOFFSET + messagesegment_nobits_size + datastack_size)
  1494                                  %define BOOTCODETARGET2 (BOOTCODETARGET1+auxbuff_size)
  1495                                  %define BOOTAUXTARGET1 (BOOTCODETARGET1+ldebug_code_size+ldebug_code2_size)
  1496                                  %define BOOTAUXTARGET2 BOOTCODETARGET1
  1497                                  %define BOOTAUXTARGET3 (BOOTAUXTARGET1+auxbuff_size)
  1498                                  %endif
  1499                                  	; add bx, paras(BOOTAUXTARGET1)
  1500 00000513 81C3[0000]              	add bx, strict word relocatedzero + 0
  1501                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
  1502                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits, equ $ - 2
  1503                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  1504                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code, equ $ - 2
  1505                                   wlcalc word_wrt_@@lDEBUG_CODE2@_extpara_behind_code2, equ $ - 2
  1506                                  	; add dx, paras(BOOTCODETARGET1)
  1507 00000517 81C2[0000]              	add dx, strict word relocatedzero + 0
  1508                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
  1509                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits, equ $ - 2
  1510                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  1511                                   %if _EXTENSIONS || _HISTORY_SEPARATE_FIXED && _HISTORY || _BOOT_ENV_SIZE
  1512 0000051B 89D8                    	mov ax, bx
  1513 0000051D 050102                  	add ax, paras(auxbuff_size)
  1514                                   %endif
  1515                                  %endif	; _LINK
  1516 00000520 E8E9FC                  	call init_check_auxbuff
  1517 00000523 743E                    	jz @F
  1518                                  
  1519                                  d4	call init_d4message
  1520                                  d4	asciz "First layout rejected",13,10
  1521                                  
  1522 00000525 89CB                    	mov bx, cx			; attempt same target again
  1523 00000527 89DA                    	mov dx, bx
  1524                                  %ifn _LINK
  1525                                  	add bx, paras(BOOTAUXTARGET2)	; => auxbuff target if here
  1526                                  	add dx, paras(BOOTCODETARGET2)	; => code target if here
  1527                                   %if _EXTENSIONS || _HISTORY_SEPARATE_FIXED && _HISTORY || _BOOT_ENV_SIZE
  1528                                    %if (paras(BOOTAUXTARGET1_equate) + paras(auxbuff_size_equate)) 	!= (paras(BOOTCODETARGET2_equate) + paras(ldebug_codes_size_equate))
  1530                                     %error Unexpected layout
  1531                                    %endif
  1532                                   %endif
  1533                                  %else	; _LINK
  1534                                  %if 0
  1535                                  %define BOOTCODETARGET1 (MESSAGESECTIONOFFSET + messagesegment_nobits_size + datastack_size)
  1536                                  %define BOOTCODETARGET2 (BOOTCODETARGET1+auxbuff_size)
  1537                                  %define BOOTAUXTARGET1 (BOOTCODETARGET1+ldebug_code_size+ldebug_code2_size)
  1538                                  %define BOOTAUXTARGET2 BOOTCODETARGET1
  1539                                  %define BOOTAUXTARGET3 (BOOTAUXTARGET1+auxbuff_size)
  1540                                  %endif
  1541                                  	; add bx, paras(BOOTAUXTARGET2)
  1542 00000529 81C3[0000]              	add bx, strict word relocatedzero + 0
  1543                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
  1544                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits, equ $ - 2
  1545                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  1546                                  	; add dx, paras(BOOTCODETARGET2)
  1547 0000052D 81C2[0102]              	add dx, strict word relocatedzero + paras(auxbuff_size)
  1548                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
  1549                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits, equ $ - 2
  1550                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  1551                                  %endif	; _LINK
  1552 00000531 E8D8FC                  	call init_check_auxbuff
  1553 00000534 742D                    	jz @F
  1554                                  
  1555                                  d4	call init_d4message
  1556                                  d4	asciz "Second layout rejected",13,10
  1557                                  
  1558                                  		; If both prior attempts failed, we allocate
  1559                                  		;  an additional 8 KiB and move the buffer to
  1560                                  		;  that. This should always succeed.
  1561 00000536 8B4EFA                  	mov cx, word [bp + ?memtop]
  1562 00000539 2E030E[340E]            	add cx, [cs:init_boot_ebdasize]
  1563                                  %ifn _LINK
  1564                                  	sub cx, paras(INITSECTIONOFFSET - messagesegment_size + messagesegment_nobits_size + datastack_size + auxbuff_size*2 + historysegment_boot_size + boot_env_size + extsegment_boot_size)
  1565                                  %else	; _LINK
  1566 0000053E 81E9[820A]              	sub cx, relocatedzero + paras( 		+ auxbuff_size * 2 		+ historysegment_boot_size 		+ boot_env_size 		+ extsegment_boot_size)
  1571                                   wlcalc word_segrel_INIT, equ $ - 2
  1572                                   wlcalc word_wrt_MESSAGESEGMENT_minusextpara_behind_messagesegment, equ $ - 2
  1573                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits, equ $ - 2
  1574                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  1575                                  %endif	; _LINK
  1576                                  					; cx = paragraph of pseudo-PSP if here
  1577                                  %if !_LOADER
  1578 00000542 49                      	dec cx				; => paragraph of image ident
  1579 00000543 83E1C0                  	and cx, ~ (paras(1024) - 1)	; round down to kibibyte boundary
  1580 00000546 41                      	inc cx				; => paragraph of pseudo-PSP if here
  1581                                  %else
  1582                                  	and cx, ~ (paras(1024) - 1)	; round down to kibibyte boundary
  1583                                  %endif
  1584 00000547 89CB                    	mov bx, cx
  1585 00000549 89DA                    	mov dx, bx
  1586                                  %ifn _LINK
  1587                                  	add bx, paras(BOOTAUXTARGET1)	; => auxbuff target if here
  1588                                  ; Note that we use BOOTAUXTARGET1 here, not BOOTAUXTARGET3, because
  1589                                  ;  we move where the debugger starts rather than where it ends.
  1590                                  	add dx, paras(BOOTCODETARGET1)	; => code target if here
  1591                                  %else	; _LINK
  1592                                  %if 0
  1593                                  %define BOOTCODETARGET1 (MESSAGESECTIONOFFSET + messagesegment_nobits_size + datastack_size)
  1594                                  %define BOOTCODETARGET2 (BOOTCODETARGET1+auxbuff_size)
  1595                                  %define BOOTAUXTARGET1 (BOOTCODETARGET1+ldebug_code_size+ldebug_code2_size)
  1596                                  %define BOOTAUXTARGET2 BOOTCODETARGET1
  1597                                  %define BOOTAUXTARGET3 (BOOTAUXTARGET1+auxbuff_size)
  1598                                  %endif
  1599                                  	; add bx, paras(BOOTAUXTARGET1)
  1600 0000054B 81C3[0000]              	add bx, strict word relocatedzero + 0
  1601                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
  1602                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits, equ $ - 2
  1603                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  1604                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code, equ $ - 2
  1605                                   wlcalc word_wrt_@@lDEBUG_CODE2@_extpara_behind_code2, equ $ - 2
  1606                                  ; Note that we use BOOTAUXTARGET1 here, not BOOTAUXTARGET3, because
  1607                                  ;  we move where the debugger starts rather than where it ends.
  1608                                  	; add dx, paras(BOOTCODETARGET1)
  1609 0000054F 81C2[0000]              	add dx, strict word relocatedzero + 0
  1610                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
  1611                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits, equ $ - 2
  1612                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  1613                                  %endif	; _LINK
  1614                                   %if _EXTENSIONS || _HISTORY_SEPARATE_FIXED && _HISTORY || _BOOT_ENV_SIZE
  1615 00000553 89D8                    	mov ax, bx
  1616 00000555 050102                  	add ax, paras(auxbuff_size)
  1617                                   %endif
  1618 00000558 E8B1FC                  	call init_check_auxbuff
  1619 0000055B 7406                    	jz @F
  1620                                  
  1621                                  		; Because this shouldn't happen, this is
  1622                                  		;  considered an internal error.
  1623 0000055D BA[1D10]                	mov dx, imsg.early_reloc_fail
  1624 00000560 E9E7FE                  	jmp .putsz_error
  1625                                  
  1626                                  
  1627                                  		; cx => data_entry target
  1628                                  		; dx => code target
  1629                                  		; bx => auxbuff target
  1630                                  		; ax => history segment
  1631                                  @@:
  1632                                  d4	call init_d4message
  1633                                  d4	asciz "Layout found"
  1634                                  d4	call init_d4dumpregs
  1635                                  d4	call init_d4message
  1636                                  d4	asciz 13,10
  1637                                  
  1638                                   %if _EXTENSIONS || _HISTORY_SEPARATE_FIXED && _HISTORY || _BOOT_ENV_SIZE
  1639 00000563 50                      	push ax
  1640                                   %endif
  1641 00000564 894EFE                  	mov word [bp + ?target], cx
  1642 00000567 52                      	push dx
  1643 00000568 2E803E[3A0E]00          	cmp byte [cs:init_boot_ebdaflag], 0
  1644 0000056E 742F                    	jz .reloc_memtop_no_ebda
  1645                                  %if !_LOADER
  1646 00000570 49                      	dec cx
  1647                                  %endif
  1648 00000571 2E2B0E[340E]            	sub cx, word [cs:init_boot_ebdasize]
  1649 00000576 2EA1[360E]              	mov ax, word [cs:init_boot_ebdasource]
  1650 0000057A 89CA                    	mov dx, cx
  1651 0000057C 2E890E[380E]            	mov word [cs:init_boot_ebdadest], cx
  1652 00000581 2E8B0E[340E]            	mov cx, word [cs:init_boot_ebdasize]
  1653 00000586 FA                      	cli
  1654 00000587 E81A15                  	call init_movp
  1655 0000058A 014EFA                  	add word [bp + ?memtop], cx
  1656 0000058D 2E800E[3A0E]02          	or byte [cs:init_boot_ebdaflag], 2
  1657 00000593 B84000                  	mov ax, 40h
  1658 00000596 8EC0                    	mov es, ax
  1659 00000598 2689160E00              	mov word [es:0Eh], dx	; relocate EBDA
  1660                                  
  1661                                  d4	call init_d4message
  1662                                  d4	asciz "EBDA relocated",13,10
  1663                                  
  1664 0000059D EB02                    	jmp @F
  1665                                  
  1666                                  .reloc_memtop_no_ebda:
  1667 0000059F 89CA                    	mov dx, cx
  1668                                  @@:
  1669 000005A1 B106                    	mov cl, 6
  1670 000005A3 D3EA                    	shr dx, cl
  1671 000005A5 B84000                  	mov ax, 40h
  1672 000005A8 8EC0                    	mov es, ax
  1673 000005AA 2E8916[300E]            	mov word [ cs:init_boot_new_memsizekib ], dx
  1674 000005AF 2687161300              	xchg word [es:13h], dx
  1675 000005B4 2E8916[320E]            	mov word [ cs:init_boot_old_memsizekib ], dx
  1676 000005B9 5A                      	pop dx
  1677 000005BA FB                      	sti
  1678                                  d4	call init_d4message
  1679                                  d4	asciz "Memory top relocated",13,10
  1680                                  
  1681 000005BB 8B4EFE                  	mov cx, word [bp + ?target]
  1682 000005BE 8ED9                    	mov ds, cx
  1683 000005C0 8B7EFA                  	mov di, word [bp + ?memtop]	; => memory top
  1684 000005C3 81EF4002                	sub di, paras(1024+8192)
  1685 000005C7 8EC7                    	mov es, di
  1686 000005C9 39CF                    	cmp di, cx			; max padding starts below target PSP ?
  1687 000005CB 7209                    	jb @F				; yes, do not initialise padding
  1688 000005CD 31FF                    	xor di, di			; -> padding
  1689 000005CF B90012                  	mov cx, words(1024+8192)
  1690 000005D2 31C0                    	xor ax, ax
  1691 000005D4 F3AB                    	rep stosw			; initialise padding
  1692                                  @@:
  1693                                  
  1694 000005D6 8B46F4                  	mov ax, word [bp + ?code]	; => code source
  1695                                  					; dx => code target
  1696                                  %ifn _LINK
  1697                                  	mov cx, ldebug_code_size_p + ldebug_code2_size_p	; untruncated
  1698                                  					; = size
  1699                                  %else
  1700 000005D9 B9[0000]                	mov cx, relocatedzero + 0
  1701                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code2, equ $ - 2
  1702                                  %endif
  1703 000005DC E8C514                  	call init_movp			; relocate code to target
  1704                                  d4	call init_d4message
  1705                                  d4	asciz "Code segment relocated",13,10
  1706                                  
  1707 000005DF 52                      		push dx			; (code segment)
  1708 000005E0 8B46F8                  	mov ax, word [bp + ?data]	; => data_entry source
  1709 000005E3 8CDA                    	mov dx, ds
  1710 000005E5 83C210                  	add dx, paras(100h)		; => data_entry target
  1711                                  %ifn _LINK
  1712                                  	mov cx, paras(DATAENTRYTABLESIZE)
  1713                                  %else
  1714 000005E8 B9[F0FF]                	mov cx, relocatedzero + - paras(256)
  1715                                   wlcalc word_wrt_@@lDEBUG_DATA_ENTRY@_extpara_behind_progbits_dataentry, equ $ - 2
  1716                                  %endif
  1717 000005EB E8B614                  	call init_movp			; relocate data_entry to target
  1718 000005EE 8F06[0000]              		pop word [code_seg]	; initialise code reference
  1719                                  d4	call init_d4message
  1720                                  d4	asciz "Data segment relocated",13,10
  1721                                  
  1722                                  %if _MESSAGESEGMENT
  1723 000005F2 8B46F8                  	mov ax, word [bp + ?data]	; => data_entry source
  1724                                  %ifn _LINK
  1725                                  	add ax, paras(MESSAGESECTIONOFFSET - 100h)
  1726                                  	mov dx, ds
  1727                                  	add dx, paras(100h + DATAENTRYTABLESIZE + datastack_size)
  1728                                  	mov cx, paras(messagesegment_size)
  1729                                  %else
  1730 000005F5 05[F0FF]                	add ax, strict word relocatedzero + - paras(100h)
  1731                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
  1732 000005F8 8CDA                    	mov dx, ds
  1733 000005FA 81C2[0000]              	add dx, strict word relocatedzero + 0
  1734                                   wlcalc word_wrt_@@lDEBUG_DATA_ENTRY@_extpara_end_of_datastack, equ $ - 2
  1735 000005FE B9[0000]                	mov cx, relocatedzero + 0
  1736                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment, equ $ - 2
  1737                                  %endif
  1738 00000601 E8A014                  	call init_movp
  1739 00000604 8916[0000]              	mov word [messageseg], dx
  1740                                   %if _HELP_COMPRESSED && ! _PM
  1741 00000608 8916[0000]              	mov [hshrink_memory_source.segment], dx
  1742                                   %endif
  1743 0000060C 8EC2                     	mov es, dx
  1744                                  %ifn _LINK
  1745                                  	mov di, messagesegment_size
  1746                                  	xor ax, ax
  1747                                  	mov cx, words(messagesegment_nobits_size - messagesegment_size)
  1748                                  %else
  1749 0000060E BF[0000]                	mov di, relocatedzero + 0
  1750                                   wlcalc word_wrt_MESSAGESEGMENT_ext_behind_messagesegment, equ $ - 2
  1751 00000611 31C0                    	xor ax, ax
  1752 00000613 B9[0100]                	mov cx, behind_messagesegment_nobits + 1 wrt MESSAGESEGMENT
  1753                                   wlcalc word_wrt_MESSAGESEGMENT_minusext_behind_messagesegment, equ $ - 2
  1754                                   wlcalc word_shr_1, equ $ - 2
  1755                                  %endif
  1756 00000616 F3AB                    	rep stosw
  1757                                  %endif
  1758                                  
  1759                                   %if _EXTENSIONS || _HISTORY_SEPARATE_FIXED && _HISTORY || _BOOT_ENV_SIZE
  1760 00000618 58                      	pop ax
  1761                                    %if _HISTORY_SEPARATE_FIXED && _HISTORY
  1762 00000619 A3[0000]                	mov word [history.segorsel + soaSegSel], ax
  1763                                  %if _PM
  1764                                  	mov word [history.segorsel + soaSegment], ax
  1765                                  %endif
  1766 0000061C 8EC0                    	mov es, ax
  1767 0000061E 31FF                    	xor di, di
  1768 00000620 B90010                  	mov cx, historysegment_boot_size >> 1
  1769 00000623 31C0                    	xor ax, ax
  1770 00000625 F3AB                    	rep stosw
  1771                                    %endif
  1772                                  
  1773                                    %if _BOOT_ENV_SIZE
  1774                                     %if _HISTORY_SEPARATE_FIXED && _HISTORY
  1775 00000627 8CC0                    	mov ax, es
  1776 00000629 050002                  	add ax, paras(historysegment_boot_size)
  1777                                     %endif
  1778 0000062C A3[0000]                	mov word [envseg], ax
  1779 0000062F 8EC0                    	mov es, ax
  1780 00000631 89C2                    	mov dx, ax
  1781 00000633 42                      	inc dx
  1782 00000634 31FF                    	xor di, di
  1783 00000636 B90004                  	mov cx, boot_env_size >> 1
  1784 00000639 C706[0000]0008          	mov word [env_size], boot_env_size
  1785 0000063F 31C0                    	xor ax, ax
  1786 00000641 F3AB                    	rep stosw
  1787 00000643 26C70603007F00          	mov word [es:3], paras(boot_env_size - 16)
  1788                                    %endif
  1789                                  
  1790                                    %if _EXTENSIONS
  1791                                     %if _HISTORY_SEPARATE_FIXED && _HISTORY || _BOOT_ENV_SIZE
  1792 0000064A 8CC0                    	mov ax, es
  1793                                      %if _BOOT_ENV_SIZE
  1794 0000064C 058000                  	add ax, paras(boot_env_size)
  1795                                      %else
  1796                                  	add ax, paras(historysegment_boot_size)
  1797                                      %endif
  1798                                     %endif
  1799 0000064F A3[0000]                	mov word [extseg], ax
  1800 00000652 8EC0                    	mov es, ax
  1801 00000654 31FF                    	xor di, di
  1802 00000656 B90020                  	mov cx, extsegment_boot_size >> 1
  1803 00000659 C706[0000]0040          	mov word [extseg_size], extsegment_boot_size
  1804 0000065F 31C0                    	xor ax, ax
  1805 00000661 F3AB                    	rep stosw
  1806                                    %endif
  1807                                   %endif
  1808                                  
  1809 00000663 89D8                    	mov ax, bx
  1810 00000665 A3[0000]                	mov word [auxbuff_segorsel + soaSegSel], ax
  1811                                  %if _PM
  1812                                  	mov word [auxbuff_segorsel + soaSegment], ax
  1813                                  					; initialise auxbuff references
  1814                                  %endif
  1815                                  %if _IMMASM  && _IMMASM_AUXBUFF
  1816                                  	mov word [immseg], ax
  1817                                  %endif
  1818                                  
  1819 00000668 8EC0                    	mov es, ax
  1820 0000066A 31FF                    	xor di, di
  1821 0000066C B90810                  	mov cx, _AUXBUFFSIZE >> 1
  1822 0000066F 31C0                    	xor ax, ax
  1823 00000671 F3AB                    	rep stosw			; initialise auxbuff
  1824                                  d4	call init_d4message
  1825                                  d4	asciz "auxbuff initialised",13,10
  1826                                  
  1827 00000673 1E                      	push ds
  1828 00000674 07                      	pop es
  1829 00000675 31FF                    	xor di, di
  1830 00000677 B98000                  	mov cx, words(100h)
  1831 0000067A F3AB                    	rep stosw			; initialise pseudo-PSP
  1832                                  %if _BOOT_ENV_SIZE
  1833 0000067C 89162C00                	mov word [2Ch], dx
  1834                                  %endif
  1835                                  %if _EXTENSIONS
  1836 00000680 8B0E[0000]              	mov cx, word [extdata_size]
  1837 00000684 BF[0000]                	mov di, ext_data_area
  1838 00000687 B000                    	mov al, 0
  1839 00000689 F3AA                    	rep stosb			; init ext data area
  1840                                  %endif
  1841                                  
  1842                                  init_boot_imageident:
  1843 0000068B 8CD8                    	mov ax, ds
  1844                                  %if !_LOADER
  1845 0000068D 48                      	dec ax
  1846                                  %endif
  1847 0000068E 8EC0                    	mov es, ax			; => paragraph for imageident
  1848 00000690 31FF                    	xor di, di			; -> imageident target
  1849 00000692 8B5EFA                  	mov bx, word [bp + ?memtop]
  1850 00000695 29C3                    	sub bx, ax			; = how many paragraphs do we use ?
  1851                                  
  1852 00000697 891E[0000]              	mov word [alloc_size], bx
  1853 0000069B A3[0000]                	mov word [alloc_seg], ax
  1854                                  
  1855 0000069E 0E                      	 push cs
  1856 0000069F 1F                      	 pop ds
  1857 000006A0 891E[680D]              	mov word [imageident.size], bx	; set image ident size
  1858                                  
  1859 000006A4 BE[600D]                	mov si, imageident
  1860 000006A7 56                      	push si
  1861 000006A8 B90800                  	mov cx, 8
  1862 000006AB 31D2                    	xor dx, dx
  1863                                  .loop:
  1864 000006AD AD                      	lodsw
  1865 000006AE 01C2                    	add dx, ax
  1866 000006B0 E2FB                    	loop .loop
  1867 000006B2 5E                      	pop si
  1868                                  
  1869 000006B3 F7DA                    	neg dx
  1870 000006B5 8916[660D]              	mov word [imageident.check], dx	; set image ident checksum
  1871                                  
  1872                                  %if !_LOADER
  1873 000006B9 B108                    	mov cl, 8
  1874                                  %else
  1875                                  	mov cl, words(2Ch)
  1876                                  %endif
  1877 000006BB F3A5                    	rep movsw			; write image ident paragraph
  1878                                  		; cx = 0
  1879                                  
  1880                                  %if !_LOADER
  1881 000006BD 2ED006[3B0E]            	rol byte [cs:init_preserveloader], 1
  1882 000006C2 730F                    	jnc @F
  1883 000006C4 8B56F2                  	mov dx, word [bp + ?loaderentry + 2]
  1884 000006C7 8EC2                    	mov es, dx
  1885 000006C9 268B0E1400              	mov cx, word [es:liiEntryDebug]	; cx nonzero if it has an entry
  1886 000006CE 268B1E1600              	mov bx, word [es:liiStackPointer]
  1887                                  					; fallback as zero if not supported
  1888                                  @@:
  1889                                  %endif
  1890                                  
  1891 000006D3 8B46FE                  	mov ax, word [bp + ?target]
  1892                                  
  1893                                  	; lleave ctx			; dropping this frame for stack switch
  1894                                  		; Frame context still used by get_size_and_ebda
  1895                                  
  1896 000006D6 FA                      	cli
  1897 000006D7 8ED8                    	mov ds, ax
  1898 000006D9 8EC0                    	mov es, ax
  1899 000006DB 8ED0                    	mov ss, ax
  1900 000006DD BC[0000]                	mov sp, stack_end		; boot mode stack switch
  1901 000006E0 FB                      	sti
  1902                                  
  1903                                  %if !_LOADER
  1904 000006E1 E337                    	jcxz init_boot_noloader
  1905 000006E3 890E[0000]              	mov word [reg_eip], cx
  1906 000006E7 891E[0000]              	mov word [reg_esp], bx
  1907                                  
  1908 000006EB 31C0                    	xor ax, ax		; initialise ax = 0 and FL = ZR NC etc
  1909 000006ED 9C                      	pushf
  1910 000006EE 8F06[0000]              	pop word [reg_efl]	; set to FL
  1911                                  
  1912 000006F2 92                      	xchg ax, dx
  1913 000006F3 BF[0000]                	mov di, reg_ds
  1914 000006F6 AB                      	stosw
  1915 000006F7 AF                      	scasw			; (skip dummy high word)
  1916 000006F8 AB                      	stosw
  1917 000006F9 AF                      	scasw
  1918 000006FA AB                      	stosw
  1919 000006FB AF                      	scasw
  1920 000006FC AB                      	stosw
  1921                                  
  1922                                  		; Set up initial addresses for 'a', 'd', and 'u' commands.
  1923                                  init_loader_adusetup:
  1924 000006FD A1[0000]                	mov ax, word [reg_eip]
  1925 00000700 8B0E[0200]              	mov cx, word [reg_eip+2]
  1926 00000704 8B1E[0000]              	mov bx, word [reg_cs]
  1927 00000708 BA[0000]                	mov dx, var_addr_entries.amount
  1928 0000070B BF[0000]                	mov di, var_addr_entries
  1929                                  
  1930                                  .loop:
  1931 0000070E AB                      	stosw			; IP
  1932                                  %if saSegSel == 4
  1933 0000070F 890D                    	mov word [di], cx
  1934 00000711 AF                      	scasw			; skip this word
  1935                                  %endif
  1936 00000712 93                      	xchg ax, bx
  1937 00000713 AB                      	stosw			; CS
  1938                                  %if _PM
  1939                                   %if SEGADR_size != 10
  1940                                    %error Unexpected SEGADR size
  1941                                   %endif
  1942                                  .86m:
  1943                                  	stosw			; store saSegment
  1944                                  	scasw			; skip saSelector
  1945                                  %else
  1946                                   %if SEGADR_size == 10
  1947                                    %error Unexpected SEGADR size
  1948                                   %endif
  1949                                  %endif
  1950 00000714 93                      	xchg ax, bx		; d_addr
  1951                                  
  1952 00000715 4A                      	dec dx
  1953 00000716 75F6                    	jnz .loop
  1954 00000718 EB05                    	jmp @F
  1955                                  %endif
  1956                                  
  1957                                  init_boot_noloader:
  1958 0000071A 800E[0200]20            	setopt [internalflags3], dif3_gotint19
  1959                                  @@:
  1960                                  
  1961 0000071F 2EFF36[320E]            	push word [cs:init_boot_old_memsizekib]
  1962 00000724 8F06[0000]              	pop word [boot_old_memsizekib]
  1963 00000728 2EFF36[300E]            	push word [cs:init_boot_new_memsizekib]
  1964 0000072D 8F06[0000]              	pop word [boot_new_memsizekib]
  1965 00000731 2EA0[3A0E]              	mov al, byte [cs:init_boot_ebdaflag]
  1966 00000735 2401                    	and al, 1
  1967 00000737 A2[0000]                	mov byte [boot_ebdaflag], al
  1968                                  
  1969 0000073A 800E[0100]40            	setopt [internalflags], nodosloaded
  1970 0000073F 8026[0000]0F            	clropt [internalflags], notstdinput|inputfile|notstdoutput|outputfile
  1971 00000744 C606[0000]00            	mov byte [notatty], 0	; it _is_ a tty
  1972                                  
  1973 00000749 BA[AF0F]                	mov dx, imsg.crlf
  1974 0000074C E8E613                  	call init_putsz_cs
  1975                                  
  1976                                  d4	call init_d4message
  1977                                  d4	asciz "New boot_initcode done",13,10
  1978                                  
  1979                                  %if _CONFIG
  1980                                  write_config_boot:
  1981 0000074F BF[0000]                	mov di, configpath
  1982 00000752 B86C64                  	mov ax, "ld"
  1983 00000755 AB                      	stosw
  1984 00000756 B8702F                  	mov ax, "p/"
  1985 00000759 AB                      	stosw
  1986 0000075A 893E[0000]              	mov word [configpath.dir_end], di
  1987 0000075E BF[0000]                	mov di, scriptspath
  1988 00000761 B86C64                  	mov ax, "ld"
  1989 00000764 AB                      	stosw
  1990 00000765 B8702F                  	mov ax, "p/"
  1991 00000768 AB                      	stosw
  1992 00000769 893E[0000]              	mov word [scriptspath.dir_end], di
  1993                                  %endif
  1994                                  
  1995 0000076D E92E14                  	jmp boot_old_initcode
  1996                                  
  1997                                  
  1998                                  		; INP:	ds:si -> first byte to check for name
  1999                                  		;	cx = number of bytes left
  2000                                  		; OUT:	(8+1+3+1)bytes[es:boot_init_foundname] = found name,
  2001                                  		;	 converted to 8.3 ASCIZ format,
  2002                                  		;	 not written if none
  2003                                  		;	CY if no filename found,
  2004                                  		;	 si = INP:si + INP:cx
  2005                                  		;	 cx = 0
  2006                                  		;	NC if filename found,
  2007                                  		;	 ds:si -> byte behind the name, thus ds:(si-11)-> name
  2008                                  		;	 cx = number of bytes left
  2009                                  		; CHG:	di, ax
  2010                                  findname:
  2011                                  .:
  2012 00000770 83F90B                  	cmp cx, 11		; enough for another name ?
  2013 00000773 7275                    	jb .none		; no -->
  2014                                  				; (cx == 0 jumps here too)
  2015                                  .check:
  2016 00000775 51                      	push cx
  2017 00000776 56                      	push si
  2018 00000777 B90B00                  	mov cx, 11
  2019 0000077A AC                      	lodsb
  2020 0000077B 88C4                    	mov ah, al		; check for same char in all 11 places
  2021 0000077D 3C20                    	cmp al, 32		; first character must not be blank
  2022 0000077F 740D                    	je .check_fail		; if it is -->
  2023                                  ;	cmp al, 5		; first character may be 05h to indicate 0E5h
  2024                                  ;	je .check_pass
  2025 00000781 A8                      	db __TEST_IMM8		; (skip lodsb)
  2026                                  .check_loop_same:
  2027 00000782 AC                      	lodsb
  2028 00000783 38C4                    	cmp ah, al
  2029 00000785 752E                    	jne .check_loop_differs
  2030 00000787 E80A00                  	call .check_character
  2031 0000078A 7202                    	jc .check_fail
  2032 0000078C E2F4                    	loop .check_loop_same
  2033                                  		; if we arrive here, all characters (while valid) are the
  2034                                  		;  same character repeated 11 times. we disallow this in case
  2035                                  		;  that the padding character is an allowed one (eg '&' 26h).
  2036                                  .check_fail:
  2037 0000078E 5E                      	pop si
  2038 0000078F 59                      	pop cx
  2039 00000790 49                      	dec cx			; lessen the counter
  2040 00000791 46                      	inc si			; -> next position to check
  2041 00000792 EBDC                    	jmp .
  2042                                  
  2043                                  .check_character:
  2044 00000794 3C20                    	cmp al, 32
  2045 00000796 7218                    	jb .check_character_fail
  2046 00000798 3C7F                    	cmp al, 127
  2047                                  ;	je .check_character_fail
  2048 0000079A 7314                    	jae .check_character_fail
  2049                                  		; note: with all characters >= 128 allowed,
  2050                                  		;  we get false positives in our sectors.
  2051 0000079C 3C2E                    	cmp al, '.'
  2052 0000079E 7410                    	je .check_character_fail
  2053 000007A0 3C2F                    	cmp al, '/'
  2054 000007A2 740C                    	je .check_character_fail
  2055 000007A4 3C5C                    	cmp al, '\'
  2056 000007A6 7408                    	je .check_character_fail
  2057 000007A8 3C61                    	cmp al, 'a'
  2058 000007AA 7206                    	jb .check_character_pass
  2059 000007AC 3C7A                    	cmp al, 'z'
  2060 000007AE 7702                    	ja .check_character_pass
  2061                                  .check_character_fail:
  2062 000007B0 F9                      	stc
  2063 000007B1 C3                      	retn
  2064                                  
  2065                                  .check_character_pass:
  2066 000007B2 F8                      	clc
  2067 000007B3 C3                      	retn
  2068                                  
  2069                                  .check_loop:
  2070 000007B4 AC                      	lodsb
  2071                                  .check_loop_differs:
  2072 000007B5 E8DCFF                  	call .check_character
  2073 000007B8 72D4                    	jc .check_fail
  2074 000007BA 3C20                    	cmp al, 32
  2075 000007BC 740F                    	je .check_loop_is_blank
  2076                                  .check_pass:
  2077 000007BE E2F4                    	loop .check_loop
  2078                                  
  2079 000007C0 58                      	pop ax			; (discard si)
  2080 000007C1 83EE0B                  	sub si, 11		; -> at name
  2081                                  
  2082 000007C4 E82900                  	call convert_name_to_asciz
  2083                                  				; si -> behind name
  2084 000007C7 59                      	pop cx
  2085 000007C8 83E90B                  	sub cx, 11		; lessen the counter
  2086 000007CB F8                      	clc
  2087 000007CC C3                      	retn
  2088                                  
  2089                                  .check_loop_is_blank:
  2090 000007CD 88CC                    	mov ah, cl		; = how many remaining in ext (1 to 3)
  2091                                  				;  or name+ext (1 to 10, cannot be 11)
  2092 000007CF 80FC03                  	cmp ah, 3		; in ext ?
  2093 000007D2 7605                    	jbe @F			; yes -->
  2094 000007D4 80EC03                  	sub ah, 3		; 1 to 7 name field remaining
  2095 000007D7 A8                      	db __TEST_IMM8		; (skip lodsb)
  2096                                  .check_loop_blank:
  2097 000007D8 AC                      	lodsb
  2098                                  @@:
  2099 000007D9 E8B8FF                  	call .check_character	; general check
  2100 000007DC 72B0                    	jc .check_fail
  2101 000007DE 3C20                    	cmp al, 32		; non-blank ?
  2102 000007E0 75AC                    	jne .check_fail		; yes, fails -->
  2103 000007E2 FECC                    	dec ah			; at end of field ?
  2104 000007E4 74D8                    	jz .check_pass		; yes -->
  2105                                  				; no, still in field after blank.
  2106                                  				;  check that next trail is all blanks too.
  2107 000007E6 E2F0                    	loop .check_loop_blank
  2108 000007E8 EBA4                    	jmp .check_fail		; (never reached)
  2109                                  
  2110                                  .none:
  2111 000007EA 01CE                    	 add si, cx
  2112 000007EC 31C9                    	 xor cx, cx
  2113 000007EE F9                      	stc
  2114 000007EF C3                      	retn
  2115                                  
  2116                                  
  2117                                  		; INP:	ds:si -> 11-byte blank-padded name
  2118                                  		;	es:boot_init_foundname -> (8+1+3+1)-byte buffer
  2119                                  		; OUT:	ds:si -> behind 11-byte blank-padded name
  2120                                  		;	es:boot_init_foundname filled
  2121                                  		; CHG:	cx, di, ax
  2122                                  convert_name_to_asciz:
  2123 000007F0 BF[0000]                	mov di, boot_init_foundname
  2124 000007F3 B90800                  	mov cx, 8
  2125 000007F6 F3A4                    	rep movsb		; copy over base name, si -> extension
  2126 000007F8 26807DF805              	cmp byte [es:di - 8], 05h	; is it 05h ?
  2127 000007FD 7505                    	jne @F			; no -->
  2128 000007FF 26C645F8E5              	mov byte [es:di - 8], 0E5h	; yes, convert to 0E5h
  2129                                  @@:
  2130                                  
  2131 00000804 A8                      	db __TEST_IMM8		; (skip dec)
  2132                                  @@:
  2133 00000805 4F                      	dec di			; decrement -> at previous trailing blank
  2134 00000806 26807DFF20              	cmp byte [es:di - 1], 32	; trailing blank ?
  2135 0000080B 74F8                    	je @B			; yes -->
  2136                                  
  2137 0000080D B02E                    	mov al, '.'
  2138 0000080F AA                      	stosb			; store dot (if needed)
  2139 00000810 B103                    	mov cl, 3
  2140 00000812 F3A4                    	rep movsb		; copy over extension, si -> behind name
  2141                                  
  2142 00000814 A8                      	db __TEST_IMM8		; (skip dec)
  2143                                  @@:
  2144 00000815 4F                      	dec di			; decrement -> at previous trailing blank
  2145 00000816 26807DFF20              	cmp byte [es:di - 1], 32	; trailing blank ?
  2146 0000081B 74F8                    	je @B			; yes -->
  2147                                  
  2148 0000081D 26807DFF2E              	cmp byte [es:di - 1], '.'	; trailing dot ? (only occurs if all-blank ext)
  2149 00000822 7501                    	jne @F			; no -->
  2150 00000824 4F                      	dec di			; -> at the dot
  2151                                  @@:
  2152 00000825 B000                    	mov al, 0
  2153 00000827 AA                      	stosb			; store filename terminator
  2154 00000828 C3                      	retn
  2155                                  
  2156                                  
  2157                                  get_size_and_ebda:
  2158 00000829 CD12                    	int 12h
  2159 0000082B B106                    	mov cl, 6
  2160 0000082D D3E0                    	shl ax, cl
  2161                                  
  2162 0000082F 50                      	push ax
  2163 00000830 1E                      	push ds
  2164 00000831 31F6                    	xor si, si
  2165 00000833 92                      	xchg dx, ax
  2166 00000834 8EDE                    	mov ds, si
  2167 00000836 C536BC00                	lds si, [4 * 2Fh]
  2168 0000083A 83C603                  	add si, 3
  2169 0000083D AC                      	lodsb
  2170 0000083E 3C52                    	cmp al, 'R'
  2171 00000840 750F                    	jne .no_rpl
  2172 00000842 AC                      	lodsb
  2173 00000843 3C50                    	cmp al, 'P'
  2174 00000845 750A                    	jne .no_rpl
  2175 00000847 AC                      	lodsb
  2176 00000848 3C4C                    	cmp al, 'L'
  2177 0000084A 7505                    	jne .no_rpl
  2178 0000084C B8064A                  	mov ax, 4A06h
  2179 0000084F CD2F                    	int 2Fh
  2180                                  .no_rpl:
  2181 00000851 92                      	xchg ax, dx
  2182 00000852 1F                      	pop ds
  2183 00000853 5A                      	pop dx
  2184                                  
  2185 00000854 39D0                    	cmp ax, dx
  2186 00000856 7406                    	je .no_error_rpl
  2187                                  		; in case RPL is present, error out (for now)
  2188                                  
  2189                                  		; notes for +RPL installation:
  2190                                  		; 1. Allocate enough memory for our MCB + an PSP + our image + the last and the RPL MCB
  2191                                  		; 2. Create the RPL's MCB + a last MCB
  2192                                  		; 3. Relocate, initialise PSP
  2193                                  		; 4. Hook Int2F as RPLOADER to report DOS our new size
  2194                                  
  2195 00000858 BA[C617]                	mov dx, imsg.rpl_detected
  2196 0000085B E9ECFB                  	jmp .putsz_error
  2197                                  
  2198                                  .no_error_rpl:
  2199                                  d4	call init_d4message
  2200                                  d4	asciz "Loader past RPL detection",13,10
  2201                                  
  2202 0000085E 8B5EFA                  	mov bx, word [bp + ?memtop]
  2203 00000861 39C3                    	cmp bx, ax
  2204 00000863 740D                    	je @F
  2205                                  
  2206                                  		; Special debugging support: If memtop is below
  2207                                  		;  what we detected using int 12h then update
  2208                                  		;  memtop and continue with the changed memtop.
  2209                                  		; The relocations done will suffice in any case.
  2210 00000865 8946FA                  	mov word [bp + ?memtop], ax
  2211 00000868 89C3                    	mov bx, ax
  2212 0000086A 7206                    	jb @F
  2213                                  
  2214 0000086C BA[ED17]                	mov dx, imsg.mismatch_detected
  2215 0000086F E9D8FB                  	jmp .putsz_error
  2216                                  
  2217                                  @@:					; bx => behind usable memory
  2218                                  %if 0
  2219                                  	mov ah, 0C1h
  2220                                  	stc
  2221                                  	int 15h				; BIOS, do you have an EBDA?
  2222                                  	mov ax, es
  2223                                  	jnc .ebda			; segment in ax -->
  2224                                  					; I don't believe you, let's check
  2225                                  %endif	; Enabling this would enable the BIOS to return an EBDA even if it isn't
  2226                                  	; noted at 40h:0Eh, which would be useless because we have to relocate it.
  2227                                  
  2228 00000872 31D2                    	xor dx, dx			; initialise dx to zero if no EBDA
  2229 00000874 B84000                  	mov ax, 40h
  2230 00000877 8EC0                    	mov es, ax
  2231 00000879 26A10E00                	mov ax, word [ es:0Eh ]		; EBDA segment (unless zero) or LPT4 base I/O address (200h..3FCh)
  2232 0000087D 3D0004                  	cmp ax, 400h
  2233 00000880 7227                    	jb .noebda			; -->
  2234                                  .ebda:
  2235                                  d4	call init_d4message
  2236                                  d4	asciz "EBDA detected",13,10
  2237                                  
  2238 00000882 39D8                    	cmp ax, bx
  2239                                  	;jb init_booterror.soft		; uhh, the EBDA is inside our memory?
  2240                                  	;ja init_booterror.soft		; EBDA higher than top of memory. This is just as unexpected.
  2241 00000884 7723                    	ja .noebda
  2242                                  		; MEMDISK can allocate memory *below* the EBDA.
  2243                                  		;  just pretend we don't see any EBDA.
  2244 00000886 7406                    	je @F
  2245 00000888 BA[2118]                	mov dx, imsg.boot_ebda_unexpected
  2246 0000088B E9BCFB                  	jmp .putsz_error
  2247                                  
  2248                                  @@:
  2249 0000088E 2E800E[3A0E]01          	or byte [cs:init_boot_ebdaflag], 1
  2250                                  
  2251 00000894 8ED8                    	mov ds, ax
  2252 00000896 31D2                    	xor dx, dx
  2253 00000898 8A160000                	mov dl, byte [ 0 ]		; EBDA size in KiB
  2254 0000089C B106                    	mov cl, 6
  2255 0000089E D3E2                    	shl dx, cl			; *64, to paragraphs
  2256 000008A0 2E8916[340E]            	mov word [cs:init_boot_ebdasize], dx
  2257 000008A5 2EA3[360E]              	mov word [cs:init_boot_ebdasource], ax
  2258                                  d4	jmp @F
  2259                                  .noebda:
  2260                                  d4	call init_d4message
  2261                                  d4	asciz "No EBDA detected",13,10
  2262                                  @@:
  2263 000008A9 C3                      	retn
  2264                                  
  2265                                  .putsz_error: equ boot_initcode.putsz_error
  2266                                  
  2267                                  	lleave ctx			; dropping early boot_initcode frame
  2268                                  
  2269                                  
  2270                                  init_booterror:
  2271                                  .soft:
  2272 000008AA 31C0                    	xor ax, ax
  2273 000008AC A9                      	db __TEST_IMM16			; (skip mov)
  2274                                  .hard:
  2275 000008AD B001                    	mov al, 1
  2276                                  
  2277                                  ;d4	call init_d4pocketdosmemdump
  2278                                  d4	call init_d4dumpregs
  2279                                  
  2280                                  .patch_switch_stack:
  2281 000008AF EB09                    	jmp strict short .no_switch_stack
  2282                                  
  2283 000008B1 8CCB                    	mov bx, cs
  2284 000008B3 FA                      	cli
  2285 000008B4 8ED3                    	mov ss, bx
  2286                                  %ifn _LINK
  2287                                  	mov sp, init_size + BOOTINITSTACK_SIZE
  2288                                  %else
  2289 000008B6 BC[0002]                	mov sp, BOOTINITSTACK_SIZE + behind_init wrt INIT
  2290                                  %endif
  2291 000008B9 FB                      	sti
  2292                                  
  2293                                  .no_switch_stack:
  2294 000008BA 50                      	push ax
  2295                                  
  2296 000008BB B84000                  	mov ax, 40h
  2297 000008BE 8EC0                    	mov es, ax
  2298                                  
  2299 000008C0 2EF606[3A0E]02          	test byte [cs:init_boot_ebdaflag], 2
  2300 000008C6 7417                    	jz @F
  2301                                  
  2302 000008C8 FA                      	cli
  2303 000008C9 2E8B16[360E]            	mov dx, [cs:init_boot_ebdasource]
  2304 000008CE 2EA1[380E]              	mov ax, [cs:init_boot_ebdadest]
  2305 000008D2 2E8B0E[340E]            	mov cx, [cs:init_boot_ebdasize]
  2306 000008D7 E8CA11                  	call init_movp
  2307                                  
  2308 000008DA 2689160E00              	mov word [es:0Eh], dx
  2309                                  @@:
  2310                                  
  2311 000008DF 2E8B16[320E]            	mov dx, [cs:init_boot_old_memsizekib]
  2312 000008E4 85D2                    	test dx, dx
  2313 000008E6 7405                    	jz @F
  2314 000008E8 2689161300              	mov word [es:13h], dx
  2315                                  @@:
  2316 000008ED FB                      	sti
  2317                                  
  2318 000008EE BA[7F18]                	mov dx, imsg.booterror
  2319 000008F1 E86312                  	call init_putsz_cs_bootldr
  2320 000008F4 E83912                  	call init_getc_bootldr
  2321 000008F7 58                      	pop ax
  2322 000008F8 85C0                    	test ax, ax
  2323 000008FA 7502                    	jnz @F
  2324 000008FC CD19                    	int 19h
  2325                                  @@:
  2326 000008FE EA0000FFFF              	jmp 0FFFFh:0
  2327                                  %endif	; _BOOTLDR
  2328                                  
  2329                                  %if _DEVICE
  2330                                  		; Our entrypoint transfers control to us with these registers:
  2331                                  		; INP:	ss:sp -> bx, fl, ds, ax, far return address to DOS
  2332                                  		;	ds:100h -> loaded payload
  2333                                  device_initcode:
  2334 00000903 FC                      	cld
  2335                                  
  2336 00000904 830E[0000]FF            	or word [device_header.next], -1
  2337                                  		; ! this uses offset 100h in the adjusted ds
  2338                                  
  2339 00000909 5B                      	pop bx
  2340 0000090A 06                      	push es
  2341 0000090B 53                      	push bx
  2342 0000090C 51                      	push cx
  2343 0000090D 52                      	push dx
  2344 0000090E 56                      	push si
  2345 0000090F 57                      	push di
  2346                                  
  2347 00000910 268B470E                	mov ax, word [es:bx + 0Eh]	; ax = amount bytes in last segment
  2348 00000914 B104                    	mov cl, 4
  2349 00000916 D3E8                    	shr ax, cl			; = paragraphs, rounding down
  2350 00000918 26034710                	add ax, word [es:bx + 0Eh + 2]	; => behind available memory
  2351 0000091C 7212                    	jc .memorybad
  2352 0000091E 2EA3[0E0E]              	mov word [cs:dev_memory_end], ax
  2353 00000922 8CDA                    	mov dx, ds
  2354 00000924 83C210                  	add dx, 10h			; => our memory
  2355 00000927 29D0                    	sub ax, dx			; ax = amount available paragraphs
  2356 00000929 7205                    	jc .memorybad
  2357                                  
  2358                                  %ifn _LINK
  2359                                  	cmp ax, (DEVICEINITSIZE + 15) >> 4
  2360                                  %else
  2361                                   %if 0
  2362                                  %define DEVICEADJUST	(deviceshim_size + 110h)
  2363                                  %define DEVICEINITTARGET (INITSECTIONOFFSET 			+ DEVICEADJUST 			+ datastack_size 			+ ext_data_nonboot_add_size 			+ auxbuff_size + auxbuff_init_size 			+ historysegment_size 			+ dev_env_size 			+ extsegment_size 			+ 10h)
  2372                                  %define DEVICEINITSIZE (DEVICEINITTARGET - 100h 			+ init_size 			+ deviceshim_size)
  2375                                   %endif
  2376 0000092B 3D[8408]                	cmp ax, strict word relocatedzero + paras( 		+ auxbuff_size 		+ auxbuff_init_size 		+ historysegment_size 		+ dev_env_size 		+ extsegment_size 		+ 20h)
  2383                                   wlcalc word_segrel_INIT, equ $ - 2
  2384                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  2385                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2386                                  ; wlcalc word_wrt_@@lDEBUG_DATA_ENTRY@_minusextpara_end_of_datastack, equ $ - 2
  2387                                   wlcalc word_wrt_INIT_extpara_behind_init, equ $ - 2
  2388                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2389                                  %endif
  2390 0000092E 7333                    	jae .memorygood
  2391                                  
  2392                                  .memorybad:
  2393 00000930 BA[820F]                	mov dx, imsg.early_mem_fail
  2394 00000933 E8FF11                  	call init_putsz_cs
  2395                                  
  2396 00000936 B80030                  	mov ax, 3000h
  2397 00000939 CD21                    	int 21h
  2398 0000093B 3C05                    	cmp al, 5
  2399 0000093D 7306                    	jae @F
  2400 0000093F BA[5610]                	mov dx, imsg.dos_below_5
  2401                                  .earlyfail:
  2402 00000942 E8F011                  	call init_putsz_cs
  2403                                  @@:
  2404                                  
  2405 00000945 5F                      	pop di
  2406 00000946 5E                      	pop si
  2407 00000947 5A                      	pop dx
  2408 00000948 59                      	pop cx
  2409 00000949 5B                      	pop bx
  2410 0000094A 07                      	pop es
  2411                                  
  2412 0000094B 8CD8                    	mov ax, ds
  2413 0000094D 83C010                  	add ax, paras(100h)
  2414 00000950 26C747030581            	mov word [es:bx + 3], 8105h	; error, done, code: bad structure length
  2415 00000956 2683670E00              	and word [es:bx + 0Eh], 0
  2416 0000095B 26894710                	mov word [es:bx + 0Eh + 2], ax	; -> behind memory in use
  2417                                  
  2418 0000095F 9D                      	popf
  2419 00000960 1F                      	pop ds
  2420 00000961 58                      	pop ax
  2421 00000962 CB                      	retf
  2422                                  
  2423                                  .memorygood:
  2424 00000963 8CD8                    	mov ax, ds
  2425                                  %ifn _LINK
  2426                                  	add ax, paras(INITSECTIONOFFSET)
  2427                                  %else
  2428 00000965 05[0000]                	add ax, strict word relocatedzero + 0
  2429                                   wlcalc word_segrel_INIT, equ $ - 2
  2430                                  %endif
  2431 00000968 8CDA                    	mov dx, ds
  2432                                  %ifn _LINK
  2433                                  	add dx, paras(DEVICEINITTARGET)
  2434                                  	mov cx, init_size_p + deviceshim_size_p
  2435                                  %else
  2436                                   %if 0
  2437                                  %define DEVICEADJUST	(deviceshim_size + 110h)
  2438                                  %define DEVICEINITTARGET (INITSECTIONOFFSET 			+ DEVICEADJUST 			+ datastack_size 			+ ext_data_nonboot_add_size 			+ auxbuff_size + auxbuff_init_size 			+ historysegment_size 			+ dev_env_size 			+ extsegment_size 			+ 10h)
  2447                                  %define DEVICEINITSIZE (DEVICEINITTARGET - 100h 			+ init_size 			+ deviceshim_size)
  2450                                   %endif
  2451 0000096A 81C2[9408]              	add dx, strict word relocatedzero + paras( 		+ auxbuff_size 		+ auxbuff_init_size 		+ historysegment_size 		+ dev_env_size 		+ extsegment_size 		+ 120h)
  2458                                   wlcalc word_segrel_INIT, equ $ - 2
  2459                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  2460                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2461                                  ; wlcalc word_wrt_@@lDEBUG_DATA_ENTRY@_minusextpara_end_of_datastack, equ $ - 2
  2462 0000096E B9[0000]                	mov cx, relocatedzero + 0
  2463                                   wlcalc word_wrt_INIT_extpara_behind_deviceshim, equ $ - 2
  2464                                  %endif
  2465 00000971 E83011                  	call init_movp
  2466                                  %ifn _LINK
  2467                                  init_plus_deviceshim_size_p_equate equ init_size_p + deviceshim_size_p
  2468                                  deviceinittarget_p_equate equ paras(DEVICEINITTARGET)
  2469                                  %if initsectionoffset_p_equate + init_plus_deviceshim_size_p_equate 	> deviceinittarget_p_equate
  2471                                   %error Overlap detected
  2472                                  %endif
  2473                                  %endif
  2474                                  
  2475 00000974 52                      	push dx
  2476 00000975 E893F8                  	call init_retf
  2477                                  
  2478                                  %if _DEV_ENV_SIZE
  2479                                   %ifn _LINK
  2480                                  	mov word [cs:memsize], paras(CODETARGET2 			+ ldebug_code_bootldr_truncated_size 			+ ldebug_code2_size 			+ historysegment_size 			+ dev_env_size 			+ extsegment_size)
  2486                                   %else
  2487                                   %if 0
  2488                                  %define CODETARGET1 (MESSAGESECTIONOFFSET + messagesegment_nobits_truncated_size + datastack_size)
  2489                                  %define CODETARGET2 (CODETARGET1+auxbuff_size)
  2490                                  %define AUXTARGET1 (CODETARGET1+ldebug_code_bootldr_truncated_size+ldebug_code2_size)
  2491                                  %define AUXTARGET2 CODETARGET1
  2492                                  %define AUXTARGET3 (AUXTARGET1+auxbuff_size)
  2493                                   %endif
  2494 00000978 2EC706[060E][8106]      	mov word [cs:memsize], relocatedzero + paras(auxbuff_size 			+ historysegment_size 			+ dev_env_size 			+ extsegment_size)
  2498                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
  2499                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits_truncated, equ $ - 2
  2500                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  2501                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code_truncated, equ $ - 2
  2502                                   wlcalc word_wrt_@@lDEBUG_CODE2@_extpara_behind_code2, equ $ - 2
  2503                                   %endif
  2504 0000097F 2EC706[080E]8000        	mov word [cs:mem_envsize], paras(dev_env_size)
  2505                                  %endif
  2506                                  
  2507 00000986 8CDB                    	mov bx, ds
  2508                                   %ifn _LINK
  2509                                  	add bx, FORCESTRICTWORD paras(DEVICEADJUST)
  2510                                   %else
  2511                                  ;%define DEVICEADJUST	(deviceshim_size + 110h)
  2512 00000988 81C3[1100]              	add bx, strict word relocatedzero + paras(110h)
  2513                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2514                                   %endif
  2515 0000098C 89DA                    	mov dx, bx
  2516                                   %ifn _LINK
  2517                                  	add bx, paras(AUXTARGET1)
  2518                                  	add dx, paras(CODETARGET1)
  2519                                   %else
  2520                                  	; add bx, paras(AUXTARGET1)
  2521 0000098E 81C3[0000]              	add bx, strict word relocatedzero + 0
  2522                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
  2523                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits_truncated, equ $ - 2
  2524                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  2525                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code_truncated, equ $ - 2
  2526                                   wlcalc word_wrt_@@lDEBUG_CODE2@_extpara_behind_code2, equ $ - 2
  2527                                  	; add dx, paras(CODETARGET1)
  2528 00000992 81C2[0000]              	add dx, strict word relocatedzero + 0
  2529                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
  2530                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits_truncated, equ $ - 2
  2531                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  2532                                   %endif
  2533                                   %if _EXTENSIONS || _HISTORY_SEPARATE_FIXED && _HISTORY || _DEV_ENV_SIZE
  2534 00000996 89D8                    	mov ax, bx
  2535 00000998 050102                  	add ax, paras(auxbuff_size)
  2536                                   %endif
  2537 0000099B 89D1                    	mov cx, dx
  2538 0000099D 2EC706[0C0E][5833]      	mov word [cs:init_layout], init_dev_layout_1
  2539 000009A4 E865F8                  	call init_check_auxbuff
  2540 000009A7 7446                    	jz @F
  2541                                  
  2542 000009A9 8CDB                    	mov bx, ds
  2543                                   %ifn _LINK
  2544                                  	add bx, FORCESTRICTWORD paras(DEVICEADJUST)
  2545                                   %else
  2546                                  ;%define DEVICEADJUST	(deviceshim_size + 110h)
  2547 000009AB 81C3[1100]              	add bx, strict word relocatedzero + paras(110h)
  2548                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2549                                   %endif
  2550 000009AF 89DA                    	mov dx, bx
  2551                                   %ifn _LINK
  2552                                  	add bx, paras(AUXTARGET2)
  2553                                  	add dx, paras(CODETARGET2)
  2554                                   %else
  2555                                  	; add bx, paras(AUXTARGET2)
  2556 000009B1 81C3[0000]              	add bx, strict word relocatedzero + 0
  2557                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
  2558                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits_truncated, equ $ - 2
  2559                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  2560                                  	; add dx, paras(CODETARGET2)
  2561 000009B5 81C2[0102]              	add dx, strict word relocatedzero + paras(auxbuff_size)
  2562                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
  2563                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits_truncated, equ $ - 2
  2564                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  2565                                   %endif
  2566 000009B9 2EC706[0C0E][5D33]      	mov word [cs:init_layout], init_dev_layout_2
  2567 000009C0 E849F8                  	call init_check_auxbuff
  2568 000009C3 742A                    	jz @F
  2569                                  
  2570                                  		; If both prior attempts failed, we allocate
  2571                                  		;  an additional 8 KiB and move the buffer to
  2572                                  		;  that. This should always succeed.
  2573                                  %ifn _LINK
  2574                                  	mov word [cs:memsize], paras(AUXTARGET3 			+ auxbuff_size 			+ historysegment_size 			+ dev_env_size 			+ extsegment_size)
  2579                                  				; enlarge the final memory block size
  2580                                  %else
  2581 000009C5 2EC706[060E][8208]      	mov word [cs:memsize], relocatedzero + paras(auxbuff_size 			+ auxbuff_size 			+ historysegment_size 			+ dev_env_size 			+ extsegment_size)
  2586                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
  2587                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits_truncated, equ $ - 2
  2588                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  2589                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code_truncated, equ $ - 2
  2590                                   wlcalc word_wrt_@@lDEBUG_CODE2@_extpara_behind_code2, equ $ - 2
  2591                                  %endif
  2592                                  
  2593 000009CC 8CDB                    	mov bx, ds
  2594                                   %ifn _LINK
  2595                                  	add bx, FORCESTRICTWORD paras(DEVICEADJUST)
  2596                                   %else
  2597                                  ;%define DEVICEADJUST	(deviceshim_size + 110h)
  2598 000009CE 81C3[1100]              	add bx, strict word relocatedzero + paras(110h)
  2599                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2600                                   %endif
  2601                                  %ifn _LINK
  2602                                  	add bx, paras(AUXTARGET3)
  2603                                  %else
  2604 000009D2 81C3[0102]              	add bx, strict word relocatedzero + paras(auxbuff_size)
  2605                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
  2606                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits_truncated, equ $ - 2
  2607                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  2608                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code_truncated, equ $ - 2
  2609                                   wlcalc word_wrt_@@lDEBUG_CODE2@_extpara_behind_code2, equ $ - 2
  2610                                  %endif	; _LINK
  2611 000009D6 89CA                    	mov dx, cx
  2612                                   %if _EXTENSIONS || _HISTORY_SEPARATE_FIXED && _HISTORY || _DEV_ENV_SIZE
  2613 000009D8 89D8                    	mov ax, bx
  2614 000009DA 050102                  	add ax, paras(auxbuff_size)
  2615                                   %endif
  2616 000009DD 2EC706[0C0E][6233]      	mov word [cs:init_layout], init_dev_layout_3
  2617 000009E4 E825F8                  	call init_check_auxbuff
  2618 000009E7 7406                    	jz @F
  2619                                  
  2620                                  		; Because this shouldn't happen, this is
  2621                                  		;  considered an internal error.
  2622 000009E9 BA[1D10]                	mov dx, imsg.early_reloc_fail
  2623 000009EC E953FF                  	jmp .earlyfail
  2624                                  
  2625                                  @@:
  2626                                   %if _EXTENSIONS || _HISTORY_SEPARATE_FIXED && _HISTORY || _DEV_ENV_SIZE
  2627 000009EF 50                      	push ax
  2628                                   %endif
  2629 000009F0 E802F8                  	call place_code_segments
  2630                                  
  2631                                  %if _MESSAGESEGMENT
  2632 000009F3 8CD8                    	mov ax, ds
  2633                                  %ifn _LINK
  2634                                  	add ax, paras(MESSAGESECTIONOFFSET)
  2635                                  %else
  2636 000009F5 05[0000]                	add ax, strict word relocatedzero + 0
  2637                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
  2638                                  %endif
  2639 000009F8 8CDA                    	mov dx, ds
  2640                                  %ifn _LINK
  2641                                  	add dx, 10h 		+ paras(deviceshim_size + 110h 		+ DATAENTRYTABLESIZE + datastack_size)
  2644                                  	mov cx, paras(messagesegment_truncated_size)
  2645                                  %else
  2646 000009FA 81C2[1100]              	add dx, strict word relocatedzero + 10h + paras(110h - 100h)
  2647                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2648                                   wlcalc word_wrt_@@lDEBUG_DATA_ENTRY@_extpara_end_of_datastack, equ $ - 2
  2649 000009FE B9[0000]                	mov cx, relocatedzero + 0
  2650                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_truncated, equ $ - 2
  2651                                  %endif
  2652 00000A01 E8A010                  	call init_movp
  2653                                   %if _BOOTLDR_DISCARD_HELP
  2654                                  %ifn _LINK
  2655                                  	mov word [messageseg_size], messagesegment_nobits_truncated_size
  2656                                  %else
  2657 00000A04 C706[0000][0000]        	mov word [messageseg_size], behind_messagesegment_nobits_truncated wrt MESSAGESEGMENT
  2658                                  %endif
  2659                                    %if _HELP_COMPRESSED
  2660 00000A0A C706[0000][0000]        	mov word [indirect_hshrink_message_buffer], truncated_hshrink_message_buffer
  2661                                     %if _LINK || _LINK_COMPAT
  2662 00000A10 8E06[0000]              	mov es, [code_seg]
  2663 00000A14 26800E[0000]01          	setopt [es:patch_boothelp_uncompressed], NONCOMPRESSEDFLAG
  2664                                     %endif
  2665                                    %endif
  2666 00000A1A 1E                      	push ds
  2667 00000A1B 0E                      	 push cs
  2668 00000A1C 1F                      	 pop ds
  2669 00000A1D BE[4016]                	mov si, imsg.boothelp_replacement
  2670 00000A20 8EC2                    	mov es, dx
  2671 00000A22 BF[0000]                	mov di, msg.boothelp
  2672 00000A25 B91C00                  	mov cx, imsg.boothelp_replacement_size_w
  2673 00000A28 F3A5                    	rep movsw
  2674 00000A2A 31C0                    	xor ax, ax
  2675                                     %ifn _LINK
  2676                                  	mov cx, words(messagesegment_nobits_truncated_size 		- (msg.boothelp - messagesegment_start 			+ fromwords(imsg.boothelp_replacement_size_w)))
  2679                                     %else
  2680 00000A2C B9[3800]                	mov cx, relocatedzero + fromwords(imsg.boothelp_replacement_size_w)
  2681                                   wlcalc word_ext_msg.boothelp, equ $ - 2	; length + start
  2682                                   wlcalc word_subr_0, equ $ - 2			; - (length + start)
  2683                                   wlcalc word_wrt_MESSAGESEGMENT_ext_behind_messagesegment_nobits_truncated, equ $ - 2
  2684                                   						; behind - (length + start)
  2685                                   wlcalc word_shr_1, equ $ - 2			; above >> 1
  2686                                     %endif
  2687 00000A2F F3AB                    	rep stosw
  2688 00000A31 1F                      	pop ds
  2689                                   %endif
  2690 00000A32 52                      	push dx
  2691                                  %endif
  2692                                  
  2693 00000A33 8CD8                    	mov ax, ds
  2694 00000A35 83C010                  	add ax, 10h
  2695 00000A38 89C2                    	mov dx, ax
  2696                                  %ifn _LINK
  2697                                  	add dx, FORCESTRICTWORD paras(deviceshim_size + 110h)
  2698                                  %else
  2699 00000A3A 81C2[1100]              	add dx, strict word relocatedzero + paras(110h)
  2700                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2701                                  %endif
  2702                                  %ifn _LINK
  2703                                  	mov cx, paras(DATAENTRYTABLESIZE)
  2704                                  %else
  2705 00000A3E B9[F0FF]                	mov cx, relocatedzero + - paras(256)
  2706                                   wlcalc word_wrt_@@lDEBUG_DATA_ENTRY@_extpara_behind_progbits_dataentry, equ $ - 2
  2707                                  %endif
  2708 00000A41 E86010                  	call init_movp
  2709                                  
  2710 00000A44 8CC8                    	mov ax, cs
  2711                                  %ifn _LINK
  2712                                  	add ax, init_size_p
  2713                                  %else
  2714 00000A46 05[0000]                	add ax, strict word relocatedzero + 0
  2715                                   wlcalc word_wrt_INIT_extpara_behind_init, equ $ - 2
  2716                                  %endif
  2717 00000A49 8CDA                    	mov dx, ds
  2718 00000A4B 83C210                  	add dx, paras(100h)
  2719                                  %ifn _LINK
  2720                                  	mov cx, deviceshim_size_p
  2721                                  %else
  2722 00000A4E B9[0000]                	mov cx, relocatedzero + 0
  2723                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2724                                  %endif
  2725 00000A51 E85010                  	call init_movp
  2726                                  
  2727 00000A54 8CDA                    	mov dx, ds
  2728                                  %ifn _LINK
  2729                                  	add dx, FORCESTRICTWORD paras(100h) + deviceshim_size_p
  2730                                  %else
  2731 00000A56 81C2[1000]              	add dx, strict word relocatedzero + paras(100h)
  2732                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2733                                  %endif
  2734 00000A5A 8EC2                    	mov es, dx
  2735 00000A5C 1E                      	push ds
  2736                                  %ifn _LINK
  2737                                  	sub dx, FORCESTRICTWORD deviceshim_size_p + 1
  2738                                  %else
  2739 00000A5D 81EA[0100]              	sub dx, strict word relocatedzero + 1
  2740                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2741                                  %endif
  2742 00000A61 8EDA                    	mov ds, dx
  2743 00000A63 31C0                    	xor ax, ax
  2744 00000A65 31FF                    	xor di, di
  2745 00000A67 B90400                  	mov cx, 4
  2746 00000A6A F3AB                    	rep stosw
  2747 00000A6C BE0800                  	mov si, 8
  2748 00000A6F B104                    	mov cl, 4
  2749 00000A71 F3A5                    	rep movsw
  2750 00000A73 1F                      	pop ds
  2751                                  
  2752 00000A74 8CDA                    	mov dx, ds
  2753                                   %ifn _LINK
  2754                                  	add dx, FORCESTRICTWORD paras(DEVICEADJUST)
  2755                                   %else
  2756                                  ;%define DEVICEADJUST	(deviceshim_size + 110h)
  2757 00000A76 81C2[1100]              	add dx, strict word relocatedzero + paras(110h)
  2758                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2759                                   %endif
  2760 00000A7A 8EDA                    	mov ds, dx
  2761                                  
  2762                                  %if _MESSAGESEGMENT
  2763                                   %if _HELP_COMPRESSED && ! _PM
  2764 00000A7C 58                      	pop ax
  2765 00000A7D A3[0000]                	mov [hshrink_memory_source.segment], ax
  2766 00000A80 A3[0000]                	mov [messageseg], ax
  2767                                   %else
  2768                                  	pop word [messageseg]
  2769                                   %endif
  2770                                  %endif
  2771                                  
  2772 00000A83 53                      	push bx
  2773 00000A84 B451                    	mov ah, 51h
  2774 00000A86 CD21                    	int 21h
  2775 00000A88 891E[0000]              	mov word [pspdbe], bx
  2776 00000A8C 5B                      	pop bx
  2777                                  
  2778 00000A8D 8EC2                    	mov es, dx
  2779 00000A8F B98000                  	mov cx, words(256)
  2780 00000A92 31FF                    	xor di, di
  2781 00000A94 31C0                    	xor ax, ax
  2782 00000A96 F3AB                    	rep stosw		; clear buffer for PSP + command line tail
  2783                                  
  2784                                  		; PSP creation moved to later, after command line parsing
  2785                                  
  2786                                   %if _EXTENSIONS || _HISTORY_SEPARATE_FIXED && _HISTORY || _DEV_ENV_SIZE
  2787 00000A98 58                      	pop ax
  2788                                    %if _HISTORY_SEPARATE_FIXED && _HISTORY
  2789 00000A99 A3[0000]                	mov word [history.segorsel + soaSegSel], ax
  2790                                  %if _PM
  2791                                  	mov word [history.segorsel + soaSegment], ax
  2792                                  %endif
  2793 00000A9C 8EC0                    	mov es, ax
  2794 00000A9E 31FF                    	xor di, di
  2795 00000AA0 B90010                  	mov cx, historysegment_size >> 1
  2796 00000AA3 31C0                    	xor ax, ax
  2797 00000AA5 F3AB                    	rep stosw
  2798                                    %endif
  2799                                  
  2800                                    %if _DEV_ENV_SIZE
  2801                                     %if _HISTORY_SEPARATE_FIXED && _HISTORY
  2802 00000AA7 8CC0                    	mov ax, es
  2803 00000AA9 050002                  	add ax, paras(historysegment_size)
  2804                                     %endif
  2805 00000AAC A3[0000]                	mov word [envseg], ax
  2806 00000AAF 8EC0                    	mov es, ax
  2807 00000AB1 89C2                    	mov dx, ax
  2808 00000AB3 42                      	inc dx
  2809 00000AB4 31FF                    	xor di, di
  2810 00000AB6 B90004                  	mov cx, dev_env_size >> 1
  2811 00000AB9 C706[0000]0008          	mov word [env_size], dev_env_size
  2812 00000ABF 31C0                    	xor ax, ax
  2813 00000AC1 F3AB                    	rep stosw
  2814 00000AC3 26C70603007F00          	mov word [es:3], paras(dev_env_size - 16)
  2815                                    %endif
  2816                                  
  2817                                    %if _EXTENSIONS
  2818                                     %if _HISTORY_SEPARATE_FIXED && _HISTORY || _DEV_ENV_SIZE
  2819 00000ACA 8CC0                    	mov ax, es
  2820                                      %if _DEV_ENV_SIZE
  2821 00000ACC 058000                  	add ax, paras(dev_env_size)
  2822                                      %else
  2823                                  	add ax, paras(historysegment_size)
  2824                                      %endif
  2825                                     %endif
  2826 00000ACF A3[0000]                	mov word [extseg], ax
  2827 00000AD2 8EC0                    	mov es, ax
  2828 00000AD4 31FF                    	xor di, di
  2829 00000AD6 B90010                  	mov cx, extsegment_size >> 1
  2830 00000AD9 31C0                    	xor ax, ax
  2831 00000ADB F3AB                    	rep stosw
  2832                                    %endif
  2833                                   %endif
  2834                                  
  2835 00000ADD 89D8                    	mov ax, bx
  2836                                  
  2837 00000ADF A3[0000]                	mov word [auxbuff_segorsel + soaSegSel], ax
  2838                                  %if _PM
  2839                                  	mov word [auxbuff_segorsel + soaSegment], ax
  2840                                  					; initialise auxbuff references
  2841                                  %endif
  2842                                  %if _IMMASM  && _IMMASM_AUXBUFF
  2843                                  	mov word [immseg], ax
  2844                                  %endif
  2845                                  
  2846 00000AE2 8EC0                    	mov es, ax
  2847 00000AE4 31FF                    	xor di, di
  2848 00000AE6 B90810                  	mov cx, _AUXBUFFSIZE >> 1
  2849 00000AE9 31C0                    	xor ax, ax
  2850 00000AEB F3AB                    	rep stosw			; initialise auxbuff
  2851                                  
  2852                                  %if _DEV_ENV_SIZE
  2853 00000AED 89162C00                	mov word [2Ch], dx
  2854 00000AF1 1E                      	push ds
  2855 00000AF2 E87701                  	call init_device_get_environment
  2856 00000AF5 85C0                    	test ax, ax
  2857 00000AF7 7425                    	jz @F
  2858 00000AF9 8ED8                    	mov ds, ax
  2859 00000AFB 8EC2                    	mov es, dx
  2860 00000AFD 31FF                    	xor di, di
  2861 00000AFF 31F6                    	xor si, si
  2862                                  .loop_env:
  2863 00000B01 E8C226                  	call init_nextvar
  2864 00000B04 75FB                    	jne .loop_env
  2865 00000B06 46                      	inc si
  2866 00000B07 81FEEE07                	cmp si, dev_env_size - 16 - 2
  2867 00000B0B 7608                    	jbe .copy_env
  2868 00000B0D BA[410F]                	mov dx, imsg.dev_env_too_large
  2869 00000B10 E82210                  	call init_putsz_cs
  2870 00000B13 EB09                    	jmp @F
  2871                                  
  2872                                  .copy_env:
  2873 00000B15 89F1                    	mov cx, si
  2874 00000B17 31F6                    	xor si, si
  2875 00000B19 F3A4                    	rep movsb
  2876 00000B1B 31C0                    	xor ax, ax
  2877 00000B1D AB                      	stosw
  2878                                  @@:
  2879 00000B1E 1F                      	pop ds
  2880                                  %endif
  2881                                  
  2882 00000B1F 8CD8                    	mov ax, ds			; => PSP
  2883                                  %ifn _LINK
  2884                                  	sub ax, strict word deviceshim_size_p + paras(10h)
  2885                                  %else
  2886 00000B21 2D[0100]                	sub ax, strict word relocatedzero + paras(10h)
  2887                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2888                                  %endif
  2889 00000B24 A3[0200]                	mov word [device_header_address + 2], ax
  2890 00000B27 A3[0000]                	mov word [alloc_seg], ax
  2891                                  
  2892 00000B2A 8CD8                    	mov ax, ds			; => PSP
  2893 00000B2C 2E8B1E[060E]            	mov bx, word [cs:memsize]
  2894                                  		; = amount paragraphs for PSP + DATA ENTRY + TABLE
  2895                                  		;  + DATA STACK + CODE + AUXBUFF + HISTORY + dev ENV + EXT
  2896 00000B31 01D8                    	add ax, bx			; => placeholder for trailing container
  2897                                  %ifn _LINK
  2898                                  	add bx, FORCESTRICTWORD deviceshim_size_p + paras(10h) + paras(10h)
  2899                                  %else
  2900 00000B33 81C3[0200]              	add bx, strict word relocatedzero + paras(10h + 10h)
  2901                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2902                                  %endif
  2903                                  		; (layout is deviceshim, MCB placeholder, debugger segments,
  2904                                  		;  placeholder for trailing container MCB)
  2905                                  					; = amount paragraphs expected in MCB
  2906 00000B37 891E[0000]              	mov word [device_mcb_paragraphs], bx
  2907 00000B3B 891E[0000]              	mov word [alloc_size], bx
  2908                                  
  2909                                  					; ax => where to place container sig
  2910 00000B3F E80200                  	call init_dev_place_container_signature
  2911                                  					; ax => behind memory used for device
  2912 00000B42 EB12                    	jmp @F
  2913                                  
  2914                                  		; INP:	ax => where to place container signature
  2915                                  		; OUT:	ax => behind memory used for device
  2916                                  		;	ax = INP:ax + 1
  2917                                  		; CHG:	es, di, cx, si
  2918                                  init_dev_place_container_signature:
  2919 00000B44 8EC0                    	mov es, ax
  2920 00000B46 31FF                    	xor di, di			; -> buffer for trailing container MCB
  2921 00000B48 B90800                  	mov cx, words(10h)		; = amount words
  2922 00000B4B 1E                      	push ds
  2923 00000B4C 0E                      	 push cs
  2924 00000B4D 1F                      	 pop ds
  2925 00000B4E BE[700D]                	 mov si, init_container_signature	; -> init string
  2926 00000B51 F3A5                    	rep movsw
  2927 00000B53 1F                      	pop ds
  2928 00000B54 40                      	inc ax				; => behind memory used for device
  2929 00000B55 C3                      	retn
  2930                                  
  2931                                  
  2932                                  @@:
  2933 00000B56 8F06[0000]              	pop word [reg_edi]
  2934 00000B5A 8F06[0000]              	pop word [reg_esi]
  2935 00000B5E 8F06[0000]              	pop word [reg_edx]
  2936 00000B62 8F06[0000]              	pop word [reg_ecx]
  2937 00000B66 892E[0000]              	mov word [reg_ebp], bp
  2938 00000B6A 5B                      	pop bx
  2939 00000B6B 07                      	pop es
  2940 00000B6C 891E[0000]              	mov word [reg_ebx], bx
  2941 00000B70 8C06[0000]              	mov word [reg_es], es
  2942                                  
  2943 00000B74 26C747030001            	mov word [es:bx + 3], 100h	; no error, done
  2944 00000B7A 2683670E00              	and word [es:bx + 0Eh], 0
  2945 00000B7F 26894710                	mov word [es:bx + 0Eh + 2], ax	; -> behind memory in use
  2946                                  
  2947 00000B83 8F06[0000]              	pop word [reg_efl]
  2948 00000B87 8F06[0000]              	pop word [reg_ds]
  2949 00000B8B 8F06[0000]              	pop word [reg_eax]
  2950 00000B8F 8C16[0000]              	mov word [reg_ss], ss
  2951 00000B93 8926[0000]              	mov word [reg_esp], sp
  2952                                  
  2953 00000B97 8C1E[0000]              	mov word [reg_cs], ds
  2954 00000B9B C706[0000][0000]        	mov word [reg_eip], entry_retf
  2955                                  
  2956                                  .cmdline:
  2957 00000BA1 1E                      	push ds
  2958 00000BA2 26C57712                	lds si, [es:bx + 12h]		; ds:si -> device command line
  2959 00000BA6 07                      	pop es
  2960                                  %if _CONFIG
  2961 00000BA7 1E                      	push ds
  2962 00000BA8 56                      	push si
  2963                                  %endif
  2964 00000BA9 BF8100                  	mov di, 81h			; es:di -> PSP command line tail
  2965                                  
  2966                                  		; Writing MS-DOS Device Drivers, second edition, page 349
  2967                                  		;  specifies the following as to the command line termination:
  2968                                  		; "Note that the DEVICE= command string is terminated by an
  2969                                  		;  Ah when there are no arguments. When there are arguments,
  2970                                  		;  the string is terminated with the following sequence:
  2971                                  		;  0h, Dh, Ah."
  2972                                  
  2973                                  		; First skip past name.
  2974                                  @@:
  2975 00000BAC AC                      	lodsb
  2976 00000BAD 3C20                    	cmp al, 32			; blank ?
  2977 00000BAF 7412                    	je @F
  2978 00000BB1 3C09                    	cmp al, 9
  2979 00000BB3 740E                    	je @F				; yes, got past executable filename -->
  2980 00000BB5 3C00                    	cmp al, 0
  2981 00000BB7 7448                    	je .cmdline_end
  2982 00000BB9 3C0D                    	cmp al, 13
  2983 00000BBB 7444                    	je .cmdline_end
  2984 00000BBD 3C0A                    	cmp al, 10
  2985 00000BBF 7440                    	je .cmdline_end			; if empty tail -->
  2986 00000BC1 EBE9                    	jmp @B
  2987                                  @@:
  2988 00000BC3 81FFFF00                	cmp di, 0FFh			; can store and still have space for CR ?
  2989 00000BC7 7430                    	je .cmdline_end_truncate	; no -->
  2990 00000BC9 AA                      	stosb				; store it
  2991 00000BCA 3C00                    	cmp al, 0			; EOL ?
  2992 00000BCC 7432                    	je .cmdline_end_dec
  2993 00000BCE 3C0D                    	cmp al, 13
  2994 00000BD0 742E                    	je .cmdline_end_dec
  2995 00000BD2 3C0A                    	cmp al, 10
  2996 00000BD4 742A                    	je .cmdline_end_dec		; yes -->
  2997 00000BD6 AC                      	lodsb
  2998 00000BD7 3C21                    	cmp al, '!'			; escape for small letters ?
  2999 00000BD9 75E8                    	jne @B				; no -->
  3000 00000BDB AC                      	lodsb
  3001 00000BDC 3C00                    	cmp al, 0
  3002 00000BDE 7414                    	je .cmdline_end_escaped
  3003 00000BE0 3C0D                    	cmp al, 13
  3004 00000BE2 7410                    	je .cmdline_end_escaped
  3005 00000BE4 3C0A                    	cmp al, 10
  3006 00000BE6 740C                    	je .cmdline_end_escaped
  3007                                  	; cmp al, '!'			; (automatically supported)
  3008 00000BE8 3C41                    	cmp al, 'A'			; is it a capital letter ?
  3009 00000BEA 72D7                    	jb @B
  3010 00000BEC 3C5A                    	cmp al, 'Z'
  3011 00000BEE 77D3                    	ja @B
  3012 00000BF0 3420                    	xor al, 'a' ^ 'A'		; get the small letter
  3013 00000BF2 EBCF                    	jmp @B
  3014                                  
  3015                                  .cmdline_end_escaped:
  3016 00000BF4 BA[7F10]                	mov dx, imsg.device_end_escaped
  3017 00000BF7 EB03                    	jmp @F
  3018                                  
  3019                                  .cmdline_end_truncate:
  3020 00000BF9 BA[B910]                	mov dx, imsg.device_end_truncate
  3021                                   @@:
  3022 00000BFC E8360F                  	call init_putsz_cs
  3023 00000BFF A8                      	db __TEST_IMM8			; skip dec
  3024                                  .cmdline_end_dec:
  3025 00000C00 4F                      	dec di
  3026                                  .cmdline_end:
  3027 00000C01 B00D                    	mov al, 13
  3028 00000C03 AA                      	stosb				; store CR
  3029 00000C04 97                      	xchg ax, di
  3030 00000C05 8CC3                    	 mov bx, es
  3031 00000C07 8EDB                    	 mov ds, bx
  3032 00000C09 2C82                    	sub al, 82h			; if -> 82h (CR at 81h). get 0
  3033 00000C0B A28000                  	mov byte [80h], al		; store length
  3034                                  
  3035                                  %if _CONFIG
  3036 00000C0E 5E                      	pop si
  3037 00000C0F 5A                      	pop dx
  3038                                  %endif
  3039                                  
  3040 00000C10 FA                      	cli
  3041 00000C11 8ED3                    	 mov ss, bx
  3042 00000C13 BC[0000]                	 mov sp, stack_end		; device mode stack switch
  3043 00000C16 FB                      	sti
  3044                                  
  3045 00000C17 800E[0200]40            	setopt [internalflags], tsrmode
  3046 00000C1C 8026[0200]7F            	clropt [internalflags], attachedterm
  3047 00000C21 800E[0200]40            	setopt [internalflags6], dif6_device_mode
  3048                                  
  3049                                  %if _CONFIG
  3050                                  find_config_device:
  3051 00000C26 E84300                  	call init_device_get_environment
  3052                                  
  3053 00000C29 36C606[0000]00          	mov byte [ss:configpath], 0
  3054 00000C2F 50                      	push ax
  3055 00000C30 52                      	push dx
  3056 00000C31 56                      	push si
  3057 00000C32 BF[260F]                	mov di, imsg.varconfig
  3058 00000C35 B90D00                  	mov cx, imsg.varconfig.length
  3059 00000C38 BA[0000]                	mov dx, configpath
  3060 00000C3B E8EC25                  	call init_copyvar
  3061 00000C3E 5E                      	pop si
  3062 00000C3F 1F                      	pop ds			; -> command line
  3063 00000C40 1E                      	push ds
  3064 00000C41 56                      	push si
  3065 00000C42 7303                    	jnc .done
  3066 00000C44 E84A00                  	call find_executable_device
  3067                                  .done:
  3068 00000C47 5E                      	pop si
  3069 00000C48 1F                      	pop ds			; -> command line
  3070 00000C49 58                      	pop ax
  3071                                  
  3072                                  find_scripts_device:
  3073 00000C4A 36C606[0000]00          	mov byte [ss:scriptspath], 0
  3074 00000C50 1E                      	push ds
  3075 00000C51 56                      	push si
  3076 00000C52 BF[330F]                	mov di, imsg.varscripts
  3077 00000C55 B90E00                  	mov cx, imsg.varscripts.length
  3078 00000C58 BA[0000]                	mov dx, scriptspath
  3079 00000C5B E8CC25                  	call init_copyvar
  3080 00000C5E 5E                      	pop si
  3081 00000C5F 1F                      	pop ds			; -> command line
  3082 00000C60 7303                    	jnc .done
  3083 00000C62 E82C00                  	call find_executable_device
  3084                                  .done:
  3085                                  
  3086 00000C65 16                      	push ss
  3087 00000C66 1F                      	pop ds
  3088 00000C67 16                      	push ss
  3089 00000C68 07                      	pop es
  3090                                  %endif
  3091                                  
  3092 00000C69 E9430F                  	jmp old_initcode
  3093                                  
  3094                                  
  3095                                  init_device_get_environment:
  3096 00000C6C B451                    	mov ah, 51h
  3097 00000C6E CD21                    	int 21h
  3098 00000C70 8EDB                    	mov ds, bx
  3099 00000C72 A12C00                  	mov ax, [2Ch]
  3100 00000C75 85C0                    	test ax, ax
  3101 00000C77 7517                    	jnz @F
  3102 00000C79 A11600                  	mov ax, [16h]
  3103 00000C7C 85C0                    	test ax, ax
  3104 00000C7E 740E                    	jz .zero
  3105 00000C80 83F8FF                  	cmp ax, -1
  3106 00000C83 7409                    	je .zero
  3107 00000C85 39D8                    	cmp ax, bx
  3108 00000C87 8ED8                    	mov ds, ax
  3109 00000C89 A12C00                  	mov ax, [2Ch]
  3110 00000C8C 7502                    	jne @F
  3111                                  .zero:
  3112 00000C8E 31C0                    	xor ax, ax
  3113                                  @@:
  3114 00000C90 C3                      	retn
  3115                                  
  3116                                  
  3117                                  %if _CONFIG
  3118                                  		; INP:	ss:dx -> buffer
  3119                                  		;	ds:si -> device driver command line
  3120                                  find_executable_device:
  3121                                  @@:
  3122 00000C91 AC                      	lodsb
  3123 00000C92 3C20                    	cmp al, 32
  3124 00000C94 74FB                    	je @B
  3125 00000C96 3C09                    	cmp al, 9
  3126 00000C98 74F7                    	je @B
  3127 00000C9A 4E                      	dec si
  3128 00000C9B 89F7                    	mov di, si
  3129                                  @@:
  3130 00000C9D AC                      	lodsb
  3131 00000C9E 3C09                    	cmp al, 9
  3132 00000CA0 7410                    	je @F
  3133 00000CA2 3C20                    	cmp al, 32
  3134 00000CA4 740C                    	je @F
  3135 00000CA6 3C0D                    	cmp al, 13
  3136 00000CA8 7408                    	je @F
  3137 00000CAA 3C0A                    	cmp al, 10
  3138 00000CAC 7404                    	je @F
  3139 00000CAE 84C0                    	test al, al
  3140 00000CB0 75EB                    	jnz @B
  3141                                  @@:
  3142 00000CB2 4E                      	dec si
  3143 00000CB3 1E                      	push ds
  3144 00000CB4 07                      	pop es
  3145 00000CB5 89F1                    	mov cx, si
  3146 00000CB7 29F9                    	sub cx, di
  3147 00000CB9 83F97F                  	cmp cx, 127
  3148 00000CBC 7722                    	ja .nodevice
  3149 00000CBE 87FE                    	xchg di, si
  3150                                  
  3151 00000CC0 B90000                  	mov cx, 0
  3152                                  @@:
  3153 00000CC3 39F7                    	cmp di, si
  3154 00000CC5 7610                    	jbe @F
  3155 00000CC7 4F                      	dec di
  3156 00000CC8 803D2F                  	cmp byte [di], '/'
  3157 00000CCB 7405                    	je .slash
  3158 00000CCD 803D5C                  	cmp byte [di], '\'
  3159 00000CD0 75F1                    	jne @B
  3160                                  .slash:
  3161 00000CD2 89F9                    	mov cx, di
  3162 00000CD4 41                      	inc cx
  3163 00000CD5 29F1                    	sub cx, si
  3164                                  @@:
  3165                                  
  3166 00000CD7 16                      	push ss
  3167 00000CD8 07                      	pop es
  3168 00000CD9 89D7                    	mov di, dx
  3169 00000CDB F3A4                    	rep movsb
  3170 00000CDD B000                    	mov al, 0
  3171 00000CDF AA                      	stosb
  3172                                  
  3173                                  .nodevice:
  3174                                  .done:
  3175 00000CE0 C3                      	retn
  3176                                  %endif
  3177                                  
  3178                                  
  3179                                  init_device_error_late:
  3180 00000CE1 F606[0100]80            	testopt [internalflags], has386
  3181 00000CE6 7431                    	jz .16
  3182                                  
  3183                                  subcpu 386
  3184 00000CE8 66A1[0000]              	mov eax, [reg_eax]
  3185 00000CEC 668B1E[0000]            	mov ebx, [reg_ebx]
  3186 00000CF1 668B0E[0000]            	mov ecx, [reg_ecx]
  3187 00000CF6 668B16[0000]            	mov edx, [reg_edx]
  3188 00000CFB 668B36[0000]            	mov esi, [reg_esi]
  3189 00000D00 668B3E[0000]            	mov edi, [reg_edi]
  3190 00000D05 668B2E[0000]            	mov ebp, [reg_ebp]
  3191 00000D0A 66FF36[0000]            	push dword [reg_efl]
  3192 00000D0F 669D                    	popfd
  3193 00000D11 8E26[0000]              	mov fs, [reg_fs]
  3194 00000D15 8E2E[0000]              	mov gs, [reg_gs]
  3195                                  subcpureset
  3196                                  
  3197                                  .16:
  3198                                  		; ax done last
  3199 00000D19 8B1E[0000]              	mov bx, [reg_ebx]
  3200 00000D1D 8B0E[0000]              	mov cx, [reg_ecx]
  3201 00000D21 8B16[0000]              	mov dx, [reg_edx]
  3202 00000D25 8B36[0000]              	mov si, [reg_esi]
  3203 00000D29 8B3E[0000]              	mov di, [reg_edi]
  3204 00000D2D 8B2E[0000]              	mov bp, [reg_ebp]
  3205 00000D31 FF36[0000]              	push word [reg_efl]
  3206 00000D35 9D                      	popf
  3207 00000D36 8E06[0000]              	mov es, [reg_es]
  3208 00000D3A 8E16[0000]              	mov ss, [reg_ss]
  3209 00000D3E 8B26[0000]              	mov sp, [reg_esp]
  3210 00000D42 FF36[0000]              	push word [reg_eax]
  3211 00000D46 8CD8                    	mov ax, ds
  3212 00000D48 8E1E[0000]              	mov ds, [reg_ds]
  3213                                  
  3214                                  %ifn _LINK
  3215                                  	sub ax, strict word paras(deviceshim_size + 10h)
  3216                                  %else
  3217 00000D4C 2D[0100]                	sub ax, strict word relocatedzero + paras(10h)
  3218                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  3219                                  %endif
  3220 00000D4F 26C747030381            	mov word [es:bx + 3], 8103h	; error, done, code: unknown command
  3221 00000D55 2683670E00              	and word [es:bx + 0Eh], 0
  3222 00000D5A 26894710                	mov word [es:bx + 0Eh + 2], ax	; -> behind memory in use
  3223 00000D5E 58                      	pop ax
  3224 00000D5F CB                      	retf
  3225                                  %endif
  3226                                  
  3227                                  
  3228                                  %if _DEBUG4 || _DEBUG5
  3229                                  %define _DEB_ASM_PREFIX init_
  3230                                  %include "deb.asm"
  3231                                  %endif
  3232                                  
  3233                                  
  3234                                  %if ! _LINK && ! _LINK_COMPAT
  3235                                  	align 2, db 0				; align on word boundary
  3236                                  		; Table of patches that are to be set NOP if not running on a 386.
  3237                                  writepatchtable patch_no386_table, PATCH_NO386_TABLE
  3238                                  %undef PATCH_NO386_TABLE
  3239                                  
  3240                                  	align 2, db 0
  3241                                  		; Table of patches that are to be set NOP if running on a 386.
  3242                                  writepatchtable patch_386_table, PATCH_386_TABLE
  3243                                  %undef PATCH_386_TABLE
  3244                                  
  3245                                  %if _DUALCODE
  3246                                  	align 2, db 0				; align on word boundary
  3247                                  		; Table of patches that are to be set NOP if not running on a 386.
  3248                                  writepatchtable patch_no386_table2, PATCH_NO386_TABLE2
  3249                                  %undef PATCH_NO386_TABLE2
  3250                                  
  3251                                  	align 2, db 0
  3252                                  		; Table of patches that are to be set NOP if running on a 386.
  3253                                  writepatchtable patch_386_table2, PATCH_386_TABLE2
  3254                                  %undef PATCH_386_TABLE2
  3255                                  %else
  3256                                   %assign __patch_no386_table2_method 0
  3257                                   %assign __patch_386_table2_method 0
  3258                                  %endif
  3259                                  
  3260                                  	align 2, db 0				; align on word boundary
  3261                                  		; Table of patches that are to be set NOP if not running on a 386.
  3262                                  writepatchtable patch_no386_tableentry, PATCH_NO386_TABLEENTRY
  3263                                  %undef PATCH_NO386_TABLEENTRY
  3264                                  
  3265                                  	align 2, db 0
  3266                                  		; Table of patches that are to be set NOP if running on a 386.
  3267                                  writepatchtable patch_386_tableentry, PATCH_386_TABLEENTRY
  3268                                  %undef PATCH_386_TABLEENTRY
  3269                                  %elif _LINK
  3270                                  %ifn _ONLY386 || _ONLYNON386
  3271                                   extern patch_no386_table
  3272                                   extern patch_no386_table.amount
  3273                                  %assign __patch_no386_table_method 1
  3274                                   extern patch_386_table
  3275                                   extern patch_386_table.amount
  3276                                  %assign __patch_386_table_method 1
  3277                                  %if _DUALCODE
  3278                                   extern patch_no386_table2
  3279                                   extern patch_no386_table2.amount
  3280                                  %assign __patch_no386_table2_method 1
  3281                                   extern patch_386_table2
  3282                                   extern patch_386_table2.amount
  3283                                  %assign __patch_386_table2_method 1
  3284                                  %else
  3285                                  %assign __patch_no386_table2_method 0
  3286                                  %assign __patch_386_table2_method 0
  3287                                  %endif
  3288                                   extern patch_no386_tableentry
  3289                                   extern patch_no386_tableentry.amount
  3290                                  %assign __patch_no386_tableentry_method 1
  3291                                   extern patch_386_tableentry
  3292                                   extern patch_386_tableentry.amount
  3293                                  %assign __patch_386_tableentry_method 1
  3294                                  %assign patch_386_tableentry_size 1	; placeholder
  3295                                  %assign patch_no386_tableentry_size 1	; placeholder
  3296                                  %endif
  3297                                  %endif
  3298                                  
  3299                                  %if !_LINK && _LINK_COMPAT
  3300                                  %assign _patch_no386_table_FORCE_METHOD 1
  3301                                  %assign _patch_386_table_FORCE_METHOD 1
  3302                                  %assign _patch_no386_table2_FORCE_METHOD 1
  3303                                  %assign _patch_386_table2_FORCE_METHOD 1
  3304                                  %assign _patch_no386_tableentry_FORCE_METHOD 1
  3305                                  %assign _patch_386_tableentry_FORCE_METHOD 1
  3306                                  
  3307                                   %ifn _ONLY386 || _ONLYNON386
  3308                                  %assign __patch_no386_table_method 1
  3309                                  %assign __patch_386_table_method 1
  3310                                    %if _DUALCODE
  3311                                  %assign __patch_no386_table2_method 1
  3312                                  %assign __patch_386_table2_method 1
  3313                                    %else
  3314                                  %assign __patch_no386_table2_method 0
  3315                                  %assign __patch_386_table2_method 0
  3316                                    %endif
  3317                                  %assign __patch_no386_tableentry_method 1
  3318                                  %assign __patch_386_tableentry_method 1
  3319                                   %endif
  3320                                  %endif
  3321                                  
  3322                                  
  3323                                  %ifn _LINK || _LINK_COMPAT
  3324                                  %if _DUALCODE && ! _PM
  3325                                  	align 2, db 0
  3326                                  relocate_from_code:
  3327                                  	dw  PATCH_RELOCATE_FROM_lDEBUG_CODE
  3328                                  .end:
  3329                                  	align 2, db 0
  3330                                  relocate_from_code2:
  3331                                  	dw  PATCH_RELOCATE_FROM_lDEBUG_CODE2
  3332                                  .end:
  3333                                  
  3334                                  %unimacro dualcall 1.nolist
  3335                                  	; make sure we do not allow later uses
  3336                                  %endif
  3337                                  %endif
  3338                                  
  3339                                  
  3340                                  %if _BOOTLDR
  3341                                  	align 16, db 0
  3342                                  	; Image identification
  3343                                  	; First dword: signature
  3344                                  	; Next word: version, two ASCII digits
  3345                                  	; Next word: checksum. adding up all words of the paragraph gives zero
  3346                                  	; Next word: size of image (including this paragraph)
  3347                                  	; Three words reserved, zero.
  3348                                  imageident:
  3349                                  %if !_LOADER
  3350 00000D60 4E4445423030            	db "NDEB00"
  3351 00000D66 0000                    .check:	dw 0
  3352 00000D68 0000                    .size:	dw 0
  3353 00000D6A 0000<rep 3h>            	times 3 dw 0
  3354                                  %else
  3355                                  	istruc LOADERIMAGEIDENT
  3356                                  at liiSignature
  3357                                  	db "NLDR00"
  3358                                  at liiChecksum
  3359                                  .check:	dw 0
  3360                                  at liiAmountParagraphs
  3361                                  .size:	dw 0
  3362                                  at liiReserved
  3363                                  	times 3 dw 0
  3364                                  at liiEntryQuerySize
  3365                                  	dw loader_query
  3366                                  at liiEntryRelocate
  3367                                  	dw loader_transfer_relocate
  3368                                  at liiEntryDebug
  3369                                  	dw loader_transfer_cmd3
  3370                                  at liiStackPointer
  3371                                  	dw stack_end
  3372                                  	iend
  3373                                  	times (2Ch - ($ - imageident)) / 2 dw 0
  3374                                  %endif
  3375                                  %endif
  3376                                  %if _DEVICE
  3377                                  	align 16, db 0
  3378                                  init_container_signature:
  3379 00000D70 464F525F53445F434F-     	fill 16, 0, db "FOR_SD_CONTAINER"
  3379 00000D79 4E5441494E4552     
  3380                                  %endif
  3381                                  %if _EXTENSIONS
  3382                                  	align 16, db 0
  3383                                  eld_linkcall:
  3384                                  .:
  3385                                  	istruc ELD_INSTANCE
  3386 00000D80 0000                    at eldiStartCode,	dw 0
  3387 00000D82 8000                    at eldiEndCode,		dw .end - .
  3388 00000D84 0000                    at eldiStartData,	dw 0
  3389 00000D86 0000                    at eldiEndData,		dw 0
  3390 00000D88 4C494E4B43414C4C        at eldiIdentifier,	fill 8, 32, db "LINKCALL"
  3391 00000D90 0100                    at eldiFlags,		dw eldifResident
  3392 00000D92 00<rep Eh>              	iend
  3393                                  .to_entry:
  3394 00000DA0 53                      	push bx
  3395 00000DA1 B300                    	mov bl, 0 * (1 + !!_PM)
  3396 00000DA3 EB06                    	jmp @F
  3397 00000DA5 90<rep 3h>              	align 8
  3398                                  .to_code1:
  3399 00000DA8 53                      	push bx
  3400 00000DA9 B302                    	mov bl, 2 * (1 + !!_PM)
  3401                                  %if _DUALCODE
  3402                                  	jmp @F
  3403                                  	align 8
  3404                                  .to_code2:
  3405                                  	push bx
  3406                                  	mov bl, 4 * (1 + !!_PM)
  3407                                  %endif
  3408                                  @@:
  3409                                  	lframe 0
  3410                                  	lpar word, origret_farret_seg
  3411                                  	lpar word, origbx_farret_ofs
  3412                                  	lpar word, restore_back_nearret
  3413 00000DAB 50                      	 push ax
  3414                                  	lpar dword, transfer
  3415 00000DAC 50                      	 push ax
  3416 00000DAD 50                      	 push ax
  3417 00000DAE 5589E5                  	lenter
  3418                                  	lvar word, restorebx
  3419 00000DB1 FF7608                  	 push word [bp + ?origbx_farret_ofs]
  3420                                   %if _PM
  3421                                  	lvar word, restoredi
  3422                                  	 push di
  3423                                   %endif
  3424 00000DB4 B700                    	mov bh, 0
  3425 00000DB6 36FFB7[0000]            	push word [ss:extcall_table.ret + bx]
  3426 00000DBB 8F4606                  	pop word [bp + ?restore_back_nearret]
  3427                                   %if _PM
  3428                                  	mov di, [ss:pm_2_86m_0]
  3429                                  	mov bx, word [ss:extcall_table.segsel + bx + di]
  3430                                   %else
  3431 00000DBE 368B9F[0000]            	mov bx, word [ss:extcall_table.segsel + bx]
  3432                                   %endif
  3433 00000DC3 368B1F                  	mov bx, word [ss:bx]
  3434 00000DC6 895E04                  	mov word [bp + ?transfer + 2], bx
  3435                                  
  3436 00000DC9 8B5E0A                  	mov bx, word [bp + ?origret_farret_seg]
  3437 00000DCC 2EFF7702                	push word [cs:bx + 2]
  3438 00000DD0 8F4602                  	pop word [bp + ?transfer]
  3439 00000DD3 895E08                  	mov word [bp + ?origbx_farret_ofs], bx
  3440                                   %ifn _PM
  3441 00000DD6 8C4E0A                  	mov word [bp + ?origret_farret_seg], cs
  3442                                   %endif
  3443                                   %if _PM
  3444                                  	pop di		; ?restoredi
  3445                                   %endif
  3446 00000DD9 5B                      	pop bx		; ?restorebx
  3447                                  	lleave ctx
  3448 00000DDA 5D                      	pop bp		; ?frame_bp
  3449 00000DDB CB                      	retf		; ?transfer
  3450                                  			; still on stack: near return address, far return address
  3451                                  
  3452 00000DDC 90<rep 1Dh>             	times 79h - ($ - .) nop
  3453                                  .call_cmd3:
  3454 00000DF9 E8ACFF                  	call .to_code1
  3455 00000DFC EBFE                    	jmp strict short $
  3456 00000DFE [0000]                  	dw cmd3
  3457                                  
  3458                                  	align 16
  3459                                  	times 128 - ($ - .) nop
  3460                                  .end:
  3461                                  	endarea eld_linkcall
  3462                                  %endif
  3463                                  
  3464                                  %if _BOOTLDR
  3465                                  	align 2, db 0
  3466                                  loader_imageident:
  3467                                  .:
  3468 00000E00 4E4C44523030            	db "NLDR00"
  3469                                  .size equ $ - .
  3470                                  %endif
  3471                                  
  3472                                  	align 2, db 0
  3473                                  memsize:
  3474                                  %ifn _LINK
  3475                                  		dw paras(CODETARGET2 			+ ldebug_code_bootldr_truncated_size 			+ ldebug_code2_size 			+ historysegment_size 			+ extsegment_size)
  3480                                  	; same as paras(AUXTARGET1
  3481                                  	;	+ auxbuff_size
  3482                                  	;	+ historysegment_size
  3483                                  	;	+ extsegment_size)
  3484                                  %else
  3485                                   %if 0
  3486                                  %define CODETARGET1 (MESSAGESECTIONOFFSET + messagesegment_nobits_truncated_size + datastack_size)
  3487                                  %define CODETARGET2 (CODETARGET1+auxbuff_size)
  3488                                  %define AUXTARGET1 (CODETARGET1+ldebug_code_bootldr_truncated_size+ldebug_code2_size)
  3489                                  %define AUXTARGET2 CODETARGET1
  3490                                  %define AUXTARGET3 (AUXTARGET1+auxbuff_size)
  3491                                   %endif
  3492 00000E06 [0106]                  		dw  relocatedzero + paras(auxbuff_size 			+ historysegment_size 			+ extsegment_size)
  3495                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
  3496                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits_truncated, equ $ - 2
  3497                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  3498                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code_truncated, equ $ - 2
  3499                                   wlcalc word_wrt_@@lDEBUG_CODE2@_extpara_behind_code2, equ $ - 2
  3500                                  %endif
  3501                                  
  3502                                  %if _DEV_ENV_SIZE || _APP_ENV_SIZE
  3503 00000E08 0000                    mem_envsize:	dw 0
  3504                                  %endif
  3505                                  cmdline_buffer_start:
  3506 00000E0A [0000]                  		dw cmdline_buffer
  3507                                  init_layout:
  3508 00000E0C [8533]                  		dw init_layout_none
  3509                                  %if _DEVICE
  3510 00000E0E 0000                    dev_memory_end:	dw 0
  3511                                  %endif
  3512                                  init_auxbuff_want:
  3513 00000E10 1020                    		dw _AUXBUFFSIZE
  3514                                  %if _EXTENSIONS
  3515 00000E12 0040                    init_ext_want:	dw _EXT_CODE_DEFAULT_SIZE
  3516 00000E14 0040                    init_extdata_want:	dw _EXT_DATA_DEFAULT_SIZE
  3517                                  %endif
  3518                                  %if _HISTORY_SEPARATE_FIXED && _HISTORY
  3519 00000E16 0020                    init_history_want:	dw _HISTORY_WANT_SIZE
  3520                                  %endif
  3521                                  
  3522                                  init_switch_p_low_pathsearch_high_guessextension:
  3523 00000E18 00                      init_switch_p_pathsearch:	db 0
  3524 00000E19 00                      init_switch_p_guessextension:	db 0
  3525 00000E1A 0000                    relocate_source:	dw 0
  3526 00000E1C 0000                    relocate_down:		dw 0
  3527 00000E1E 0000                    init_switch_r:		dw 0
  3528 00000E20 0000                    init_base_size:		dw 0
  3529 00000E22 0000                    init_target_size:	dw 0
  3530 00000E24 0100                    init_switch_t_umblink:	dw 1		; Add UMBs to memory chain
  3531 00000E26 FFFF                    			dw -1
  3532 00000E28 FFFF                    			dw -1
  3533 00000E2A 8200                    init_switch_t_strategy:	dw 82h		; Last fit, high then low
  3534 00000E2C 8200                    			dw 82h
  3535 00000E2E 8200                    			dw 82h
  3536                                  %if _BOOTLDR
  3537 00000E30 0000                    init_boot_new_memsizekib:	dw 0
  3538 00000E32 0000                    init_boot_old_memsizekib:	dw 0
  3539                                  
  3540 00000E34 0000                    init_boot_ebdasize:	dw 0
  3541 00000E36 0000                    init_boot_ebdasource:	dw 0
  3542 00000E38 0000                    init_boot_ebdadest:	dw 0
  3543 00000E3A 00                      init_boot_ebdaflag:	db 0
  3544 00000E3B 00                      init_preserveloader:	db 0
  3545                                  %endif
  3546 00000E3C FF                      init_switch_pw:		db 0FFh
  3547 00000E3D 00                      init_switch_t:		db 0
  3548 00000E3E 00                      init_switch_t_ignore:	db 0
  3549 00000E3F 00                      init_switch_t_break:	db 0
  3550 00000E40 00                      init_switch_t_variable:	db 0		; /TV: do not relocate environment
  3551                                  %if _APP_ENV_SIZE || _DEV_ENV_SIZE
  3552 00000E41 00                      app_env_allocation:	db 0		; set to 0FFh if app's environment
  3553                                  					;  *is* in its own separate memory block
  3554                                  					;  (like it used to be always)
  3555                                  %endif
  3556                                  
  3557                                  
  3558                                  imsg:
  3559                                  
  3560                                  %if _APPLICATION || _DEVICE
  3561                                  %assign ELD 0
  3562                                  %assign INTERC3 0
  3563                                  %assign PART1 0
  3564                                  %assign PART2 0
  3565                                  %assign PART3 1
  3566                                  
  3567                                  %include "pathshar.asm"
     1                              <1> 
     2                              <1> %if 0
     3                              <1> 
     4                              <1> lDebug initialisation - Path analyse and search
     5                              <1> 
     6                              <1> Copyright (C) 2008-2025 E. C. Masloch
     7                              <1> 
     8                              <1> Usage of the works is permitted provided that this
     9                              <1> instrument is retained with the works, so that any entity
    10                              <1> that uses the works is notified of this instrument.
    11                              <1> 
    12                              <1> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <1> 
    14                              <1> %endif
    15                              <1> 
    16                              <1> 
    17                              <1> ; defines used:
    18                              <1> ; ELD = nonzero iff included by Extension for lDebug path.asm (for path.eld)
    19                              <1> ; INTERC3 = nonzero iff included by INTERC3 intercep.asm
    20                              <1> ; else included by lDebug init.asm
    21                              <1> ; PART1 = nonzero if to embed main code
    22                              <1> ; PART2 = nonzero if to embed subfunctions
    23                              <1> ; PART3 = nonzero if to embed imsg messages
    24                              <1> 
    25                              <1> %if PART1
    26                              <1> 		; INP:	si -> pathname followed by command line
    27                              <1> 		;	word [ss:sp] = si
    28                              <1> 		; OUT:	word [ss:sp] -> final buffer
    29                              <1> init_analyse_pathname:
    30                              <1> 	mov bx, si
    31                              <1> 	xor dx, dx
    32                              <1> 	mov al, 0
    33                              <1> @@:
    34                              <1> 	cmp al, '/'
    35                              <1> 	je .slash
    36                              <1> 	cmp al, '\'
    37                              <1> 	je .slash
    38                              <1> 	cmp al, ':'
    39                              <1> 	je .colon
    40                              <1> 	cmp al, '.'
    41                              <1> 	jne .next
    42                              <1> .dot:
    43                              <1> 	mov dl, 1		; set dl (fn with dot)
    44                              <1> 	jmp .next
    45                              <1> 
    46                              <1> .slash:
    47                              <1> .colon:
    48                              <1> 	mov dx, 100h		; set dh (is a pathname), reset dl (fn with dot)
    49                              <1> .next:
    50                              <1> 	lodsb
    51                              <1> 	call init_ifsep
    52                              <1> 	jne @B
    53                              <1> 	dec si			; bx -> name, si -> terminator
    54                              <1> 				; dh = nonzero if a pathname not just filename
    55                              <1> 				; dl = nonzero if filename contains a dot
    56                              <1> 	push ss
    57                              <1> 	pop es
    58                              <1> 	mov cx, si
    59                              <1> 	sub cx, bx		; es:bx -> name, cx = length
    60                              <1> 
    61                              <1> 
    62                              <1> init_check_warn_extension:
    63                              <1> 	push dx
    64                              <1> 	push es
    65                              <1> 
    66                              <1> 	test dl, dl		; last component has a dot ?
    67                              <1> 	jz .done		; no, do not warn -->
    68                              <1> 
    69                              <1> 	rol byte [init_data_segment:init_switch_pw], 1
    70                              <1> internaldatarelocation
    71                              <1> 	jnc .done		; warning disabled -->
    72                              <1> 
    73                              <1> 	cmp cx, 4		; can fit an expected extension ?
    74                              <1> 	jb .warn		; no, warn -->
    75                              <1> 
    76                              <1> 	sub si, 4		; -> possible extension
    77                              <1> 	push init_data_segment
    78                              <1> 	pop es
    79                              <1> 	mov di, imsg.no_warn_extensions
    80                              <1> internaldatarelocation		; es:di -> allowed extensions
    81                              <1> .loop:
    82                              <1> 	mov al, 0
    83                              <1> 	xchg byte [init_data_segment:di+4], al
    84                              <1> 				; NUL-terminate the candidate extension
    85                              <1> 	push ax
    86                              <1> 	mov dx, di
    87                              <1> 	call init_isstring?	; is it this one ?
    88                              <1> 	pop ax
    89                              <1> 	mov byte [init_data_segment:di+4], al
    90                              <1> 				; restore next extension text
    91                              <1> 	je .done		; yes, do not warn -->
    92                              <1> 	scasw
    93                              <1> 	scasw			; di += 4
    94                              <1> 	test al, al		; was last ?
    95                              <1> 	jnz .loop
    96                              <1> .warn:
    97                              <1> 	mov dx, imsg.extension_warning
    98                              <1> internaldatarelocation
    99                              <1> 	call init_putsz_cs
   100                              <1> 
   101                              <1> .done:
   102                              <1> 	pop es
   103                              <1> 	pop dx
   104                              <1> 
   105                              <1> 
   106                              <1> init_find_path:
   107                              <1> %if ELD
   108                              <1> 	extcallcall InDOS
   109                              <1> 	jnz .done_j
   110                              <1> 	testopt [relocateddata], tt_while
   111                              <1> linkdatarelocation internalflags_with_tt_while, -3
   112                              <1> 	jnz .done_j
   113                              <1> %endif
   114                              <1> 	cmp word [init_data_segment:		init_switch_p_low_pathsearch_high_guessextension], strict byte 0
   116                              <1> internaldatarelocation -3
   117                              <1> 	je .done_j
   118                              <1> 
   119                              <1> 	jcxz .done_j		; if no filename given -->
   120                              <1> 
   121                              <1> 				; es:bx -> name, cx = length
   122                              <1> 	mov di, relocated(while_buffer)
   123                              <1> linkdatarelocation while_buffer	; ss:while_buffer -> prefix, ss:di -> after end
   124                              <1> 
   125                              <1> 	call init_check_filename
   126                              <1> 	jnc .found
   127                              <1> 
   128                              <1> 	test dh, dh
   129                              <1> 	jz @F
   130                              <1> .done_j:
   131                              <1> 	jmp .done
   132                              <1> @@:
   133                              <1> 	rol byte [init_data_segment:init_switch_p_pathsearch], 1
   134                              <1> internaldatarelocation
   135                              <1> 	jnc .done_j
   136                              <1> 
   137                              <1> %if _DEVICE && _APPLICATION && ! ELD && ! INTERC3
   138                              <1> 	testopt [internalflags6], dif6_device_mode
   139                              <1> 	jnz .device
   140                              <1> %endif
   141                              <1> %if _APPLICATION || ELD || INTERC3
   142                              <1> 	mov ax, [2Ch]
   143                              <1>  %if _DEVICE && ! ELD && ! INTERC3
   144                              <1> 	jmp @F
   145                              <1>  %endif
   146                              <1> %endif
   147                              <1> 
   148                              <1> %if _DEVICE && ! ELD && ! INTERC3
   149                              <1> .device:
   150                              <1> 	call init_device_get_environment
   151                              <1> @@:
   152                              <1> %endif
   153                              <1> 
   154                              <1> 	push cx
   155                              <1> 	mov di, imsg.varpath
   156                              <1> internaldatarelocation
   157                              <1> 	mov cx, imsg.varpath.length
   158                              <1> 	call init_findvar
   159                              <1> 	jc .done_pop
   160                              <1> 
   161                              <1> .pathloop:
   162                              <1> 	push si
   163                              <1> 	mov cx, 128		; put a limit
   164                              <1> @@:
   165                              <1> 	lodsb			; get next text
   166                              <1> 	cmp al, ';'		; separator ?
   167                              <1> 	je @F			; yes -->
   168                              <1> 	cmp al, 0		; separator ?
   169                              <1> 	je @F			; yes -->
   170                              <1> 	loop @B			; loop up to limit
   171                              <1> 	jmp .pathtoolong	; error -->
   172                              <1> @@:
   173                              <1> 	mov cx, si
   174                              <1> 	dec cx			; -> terminator
   175                              <1> 	pop si			; -> content text
   176                              <1> 	sub cx, si		; = length excluding terminator
   177                              <1> 	 push ss
   178                              <1> 	 pop es
   179                              <1> 	mov di, relocated(while_buffer)
   180                              <1> linkdatarelocation while_buffer	; es:di -> buffer
   181                              <1> 
   182                              <1> 	mov al, 0		; no backslash if empty
   183                              <1> 	jcxz @FFF		; skip loop if empty -->
   184                              <1> @@:
   185                              <1> 	lodsb			; load from variable
   186                              <1> 	cmp al, '/'		; forward slash ?
   187                              <1> 	jne @F			; no -->
   188                              <1> 	mov al, '\'		; replace by backslash
   189                              <1> @@:
   190                              <1> 	stosb			; store
   191                              <1> 	loop @BB		; loop for cx = count
   192                              <1> @@:
   193                              <1> 	cmp al, '\'		; trailing backslash ?
   194                              <1> 	je @F			; yes -->
   195                              <1> 	mov al, '\'
   196                              <1> 	stosb			; append it
   197                              <1> @@:
   198                              <1> 	pop cx
   199                              <1> 
   200                              <1> 	push ds
   201                              <1> 	push si
   202                              <1> 				; ss = es, es:bx -> name, cx = length
   203                              <1> 				; ss:while_buffer -> prefix, ss:di -> after end
   204                              <1> 	call init_check_filename
   205                              <1> 	pop si
   206                              <1> 	pop ds			; ds:si -> terminator of path element
   207                              <1> 	jnc .found
   208                              <1> 
   209                              <1> 	lodsb			; get terminator
   210                              <1> 	cmp al, ';'		; semicolon ?
   211                              <1> 	jne .done		; no -->
   212                              <1> 	push cx
   213                              <1> 	jmp .pathloop		; try next -->
   214                              <1> 
   215                              <1> 
   216                              <1> .found:
   217                              <1> 	push ss
   218                              <1> 	pop ds			; ds => PSP
   219                              <1> 	 pop si
   220                              <1> 	add si, cx		; ds:si -> behind original name
   221                              <1> 	push ss
   222                              <1> 	pop es
   223                              <1> 	dec di			; es:di -> NUL
   224                              <1> %if INTERC3
   225                              <1> 	mov al, 32		; blank codepoint
   226                              <1> 	cmp byte [si], al	; <= 32 ?
   227                              <1> 	ja @F			; no, store a blank first -->
   228                              <1> %endif
   229                              <1> 	jmp @FF			; skip store on first iteration
   230                              <1> 
   231                              <1> @@:
   232                              <1> 	cmp di, relocated(while_buffer.end) - 2
   233                              <1> linkdatarelocation while_buffer.end
   234                              <1> 	ja .toolong
   235                              <1> 	stosb
   236                              <1> @@:
   237                              <1> 	lodsb
   238                              <1> 	cmp al, 0
   239                              <1> 	je @F
   240                              <1> 	cmp al, 13
   241                              <1> 	jne @BB
   242                              <1> @@:			; (targeted from both directions)
   243                              <1> 	mov al, 13
   244                              <1> 	stosb
   245                              <1> 	mov si, relocated(while_buffer)
   246                              <1> linkdatarelocation while_buffer
   247                              <1> 	 push si		; offset for N/K command (kk)
   248                              <1> 	jmp .done
   249                              <1> 
   250                              <1> .toolong:
   251                              <1> 	mov dx, imsg.kktoolong
   252                              <1> internaldatarelocation
   253                              <1> 	call init_putsz_cs
   254                              <1> 	jmp @B
   255                              <1> 
   256                              <1> .pathtoolong:
   257                              <1>  %if ELD
   258                              <1> 	push ss
   259                              <1> 	pop ds
   260                              <1>  %endif
   261                              <1> 	mov dx, imsg.pathtoolong
   262                              <1> internaldatarelocation
   263                              <1> 	call init_putsz_cs
   264                              <1> 
   265                              <1> 	pop ax			; (discard si)
   266                              <1> .done_pop:
   267                              <1> 	pop ax			; (discard cx)
   268                              <1> .done:
   269                              <1> %endif
   270                              <1> 
   271                              <1> 
   272                              <1> %if PART2
   273                              <1> 		; Compare character with separators
   274                              <1> 		;
   275                              <1> 		; INP:	al = character
   276                              <1> 		; OUT:	ZR if al is CR, NUL, blank, tab, comma, semicolon, or equal sign
   277                              <1> 		;	ZR if switch character is a slash and al is a slash
   278                              <1> 		;	NZ else
   279                              <1> 		; REM:	This is only used for parsing FCBs.
   280                              <1> init_ifsep:
   281                              <1> 	cmp al, 0
   282                              <1> 	je .return
   283                              <1> 	cmp al, 13
   284                              <1> 	je .return
   285                              <1> 	cmp al, ';'
   286                              <1> 	je .return
   287                              <1> 	cmp al, 32
   288                              <1> 	je .return
   289                              <1> 	cmp al, 9
   290                              <1> 	je .return
   291                              <1> 	cmp al, ','
   292                              <1> 	je .return
   293                              <1> 	cmp al, '='
   294                              <1> 	je .return
   295                              <1> 	cmp al, byte [ss:relocated(swch1)]
   296                              <1> linkdatarelocation swch1
   297                              <1> .return:
   298                              <1> 	retn
   299                              <1> 
   300                              <1> 
   301                              <1> %if _APPLICATION || _DEVICE
   302                              <1> 		; INP:	es:bx -> name to try, cx = length
   303                              <1> 		;	dl = zero if to attempt filename extensions
   304                              <1> 		;	ss:while_buffer -> prefix, ss:di -> after
   305                              <1> 		; OUT:	NC if file found,
   306                              <1> 		;	 ss:while_buffer = name, ss:di -> after NUL
   307                              <1> 		;	CY if file not found
   308                              <1> 		;	ds = ss
   309                              <1> 		; CHG:	si, ax
   310                              <1> init_check_filename:
   311                              <1> 	push es
   312                              <1> 	push cx
   313                              <1> 
   314                              <1> 	push es
   315                              <1> 	pop ds
   316                              <1> 	mov si, bx		; ds:si -> name
   317                              <1> 	 push ss
   318                              <1> 	 pop es			; es:di -> where to append name
   319                              <1> 	rep movsb		; append the name
   320                              <1> 	push di			; on stack: at initial terminator
   321                              <1> 	mov si, imsg.p_extensions
   322                              <1> internaldatarelocation
   323                              <1> 				; cs:si -> extensions to try
   324                              <1> .loop:
   325                              <1> 	mov al, 0
   326                              <1> 	stosb			; zero-terminate name
   327                              <1> 	mov ax, 4300h		; get attributes
   328                              <1> 	push dx
   329                              <1> 	 push ss
   330                              <1> 	 pop ds
   331                              <1> 	mov dx, relocated(while_buffer)	; ds:dx -> pathname to try
   332                              <1> linkdatarelocation while_buffer
   333                              <1> 	stc
   334                              <1> %if ELD
   335                              <1> 	extcallcall _doscall
   336                              <1> %else
   337                              <1> 	int 21h			; try to get attributes
   338                              <1> %endif
   339                              <1> 	jc @F			; not found --> CY
   340                              <1> 	test cl, 10h		; directory ?
   341                              <1> 	jz @F			; no --> NC
   342                              <1> 	stc			; yes, handle as not found: CY
   343                              <1> @@:
   344                              <1> 	pop dx
   345                              <1> 	jnc .ret		; --> (NC)
   346                              <1> 	test dl, dl		; had an extension originally ?
   347                              <1> 	jnz .ret_CY		; yes, do not try to append one -->
   348                              <1> 	rol byte [init_data_segment:init_switch_p_guessextension], 1
   349                              <1> internaldatarelocation
   350                              <1> 	jnc .ret_CY		; if no guessing extension -->
   351                              <1> 	pop di
   352                              <1> 	push di
   353                              <1> 	cmp byte [init_data_segment:si], 0
   354                              <1> 				; last attempt done ?
   355                              <1> 	je .ret_CY		; yes -->
   356                              <1> 	init_data_segment movsw	; ".C"
   357                              <1> 	init_data_segment movsw	; "OM"
   358                              <1> 	jmp .loop
   359                              <1> 
   360                              <1> .ret_CY:
   361                              <1> 	stc			; CY
   362                              <1> .ret:
   363                              <1> 	pop ax			; (discard)
   364                              <1> 	pop cx
   365                              <1> 	pop es
   366                              <1> 	retn
   367                              <1> %endif
   368                              <1> 
   369                              <1> 
   370                              <1> 		; INP:	ax => environment, zero if none
   371                              <1> 		;	cs:di -> variable name, including '=' terminator
   372                              <1> 		;	cx = variable name length, including '=' terminator
   373                              <1> 		; OUT:	CY if not found
   374                              <1> 		;	NC if found,
   375                              <1> 		;	 ds:si -> behind '=' of found variable
   376                              <1> 		; CHG:	ax, es, di, ds, si, cx
   377                              <1> init_findvar:
   378                              <1> 	test ax, ax
   379                              <1> 	jz .notvar
   380                              <1> 	mov ds, ax
   381                              <1> 	xor si, si
   382                              <1> 
   383                              <1> @@:
   384                              <1> 	push init_data_segment
   385                              <1> 	pop es
   386                              <1> 	push cx
   387                              <1> 	push di
   388                              <1> 	push si
   389                              <1> 	repe cmpsb
   390                              <1> 	je .foundvar		; --> (NC)
   391                              <1> 	pop si
   392                              <1> 	pop di
   393                              <1> 	pop cx
   394                              <1> 	call init_nextvar
   395                              <1> 	jnz @B
   396                              <1> .notvar:
   397                              <1> 	stc
   398                              <1> 	retn
   399                              <1> 
   400                              <1> .foundvar:
   401                              <1> 	pop ax
   402                              <1> 	pop ax
   403                              <1> 	pop ax
   404                              <1> 	retn
   405                              <1> 
   406                              <1> 
   407                              <1> init_nextvar:
   408                              <1> @@:
   409                              <1> 	lodsb
   410                              <1> 	test al, al
   411                              <1> 	jnz @B
   412                              <1> 	cmp byte [si], 0
   413                              <1> 	retn
   414                              <1> %endif
   415                              <1> 
   416                              <1> 
   417                              <1> %if PART3
   418                              <1>  %if INTERC3
   419                              <1>   %define _PROGNAME ""
   420                              <1>  %endif
   421                              <1> 	align 2, db 0
   422                              <1> .no_warn_extensions:
   423                              <1>  %ifn INTERC3
   424 00000E42 2E4845582E524F4D    <1> 		db ".HEX",".ROM"
   425                              <1>  %endif
   426                              <1> %if (($ - .no_warn_extensions) % 4) != 0
   427                              <1>  %error Wrong extensions length
   428                              <1> %endif
   429 00000E4A 2E434F4D            <1> .p_extensions:	db ".COM"
   430 00000E4E 2E455845            <1> 		db ".EXE"
   431                              <1>  %ifn INTERC3
   432 00000E52 2E42494E            <1> 		db ".BIN"
   433                              <1>  %endif
   434 00000E56 00                  <1> 		asciz
   435                              <1> %if (($ - 1 - .p_extensions) % 4) != 0
   436                              <1>  %error Wrong extensions length
   437                              <1> %endif
   438 00000E57 504154483D          <1> .varpath:	db "PATH="
   439                              <1> .varpath.length equ $ - .varpath
   440                              <1> .extension_warning:
   441                              <1> %ifn ELD
   442 00000E5C 44656275676761626C- <1> 	db _PROGNAME,": "
   442 00000E65 65206C44656275673A- <1>
   442 00000E6E 20                  <1>
   443                              <1> %endif
   444 00000E6F 5761726E696E672C20- <1> 	asciz "Warning, unknown filename extension specified!",13,10
   444 00000E78 756E6B6E6F776E2066- <1>
   444 00000E81 696C656E616D652065- <1>
   444 00000E8A 7874656E73696F6E20- <1>
   444 00000E93 737065636966696564- <1>
   444 00000E9C 210D0A00            <1>
   445                              <1> .kktoolong:
   446                              <1> %ifn ELD
   447 00000EA0 44656275676761626C- <1> 	db _PROGNAME,": "
   447 00000EA9 65206C44656275673A- <1>
   447 00000EB2 20                  <1>
   448                              <1> %endif
   449 00000EB3 4572726F722C20746F- <1> 	asciz "Error, too long command line tail!",13,10
   449 00000EBC 6F206C6F6E6720636F- <1>
   449 00000EC5 6D6D616E64206C696E- <1>
   449 00000ECE 65207461696C210D0A- <1>
   449 00000ED7 00                  <1>
   450                              <1> .pathtoolong:
   451                              <1> %ifn ELD
   452 00000ED8 44656275676761626C- <1> 	db _PROGNAME,": "
   452 00000EE1 65206C44656275673A- <1>
   452 00000EEA 20                  <1>
   453                              <1> %endif
   454 00000EEB 4572726F722C20746F- <1> 	asciz "Error, too long %PATH% variable element!",13,10
   454 00000EF4 6F206C6F6E67202550- <1>
   454 00000EFD 415448252076617269- <1>
   454 00000F06 61626C6520656C656D- <1>
   454 00000F0F 656E74210D0A00      <1>
   455                              <1> %endif
  3568                                  %endif
  3569                                  
  3570 00000F16 4D415800                .max:	asciz "MAX"
  3571 00000F1A 4D494E00                .min:	asciz "MIN"
  3572                                  .default:
  3573 00000F1E 44454641554C5400        	asciz "DEFAULT"
  3574                                  %if _CONFIG
  3575 00000F26 4C4445425547434F4E-     .varconfig:	db "LDEBUGCONFIG="
  3575 00000F2F 4649473D           
  3576                                  .varconfig.length equ $ - .varconfig
  3577 00000F33 4C4445425547534352-     .varscripts:	db "LDEBUGSCRIPTS="
  3577 00000F3C 495054533D         
  3578                                  .varscripts.length equ $ - .varscripts
  3579                                  %endif
  3580                                  %if _DEVICE && _DEV_ENV_SIZE || _APPLICATION && _APP_ENV_SIZE
  3581                                  .app_env_too_large:
  3582                                  .dev_env_too_large:
  3583 00000F41 44656275676761626C-     	asciz _PROGNAME,": Warning, too long environment! Not copying.",13,10
  3583 00000F4A 65206C44656275673A-
  3583 00000F53 205761726E696E672C-
  3583 00000F5C 20746F6F206C6F6E67-
  3583 00000F65 20656E7669726F6E6D-
  3583 00000F6E 656E7421204E6F7420-
  3583 00000F77 636F7079696E672E0D-
  3583 00000F80 0A00               
  3584                                  %endif
  3585                                  %if _APPLICATION || _DEVICE
  3586                                  .early_mem_fail:
  3587 00000F82 44656275676761626C-     	db _PROGNAME,": Failed to allocate memory!"
  3587 00000F8B 65206C44656275673A-
  3587 00000F94 204661696C65642074-
  3587 00000F9D 6F20616C6C6F636174-
  3587 00000FA6 65206D656D6F727921 
  3588                                  %endif
  3589                                  .crlf:
  3590 00000FAF 0D0A00                  	asciz 13,10
  3591                                  .relocate_failure:
  3592 00000FB2 44656275676761626C-     	asciz _PROGNAME,": Relocation failed.",13,10
  3592 00000FBB 65206C44656275673A-
  3592 00000FC4 2052656C6F63617469-
  3592 00000FCD 6F6E206661696C6564-
  3592 00000FD6 2E0D0A00           
  3593                                  .init_relocate_failure:
  3594 00000FDA 44656275676761626C-     	asciz _PROGNAME,": Second init relocation failed, out of memory.",13,10
  3594 00000FE3 65206C44656275673A-
  3594 00000FEC 205365636F6E642069-
  3594 00000FF5 6E69742072656C6F63-
  3594 00000FFE 6174696F6E20666169-
  3594 00001007 6C65642C206F757420-
  3594 00001010 6F66206D656D6F7279-
  3594 00001019 2E0D0A00           
  3595                                  .early_reloc_fail:
  3596 0000101D 44656275676761626C-     	asciz _PROGNAME,": Failed to relocate, internal error!",13,10
  3596 00001026 65206C44656275673A-
  3596 0000102F 204661696C65642074-
  3596 00001038 6F2072656C6F636174-
  3596 00001041 652C20696E7465726E-
  3596 0000104A 616C206572726F7221-
  3596 00001053 0D0A00             
  3597                                  %if _DEVICE
  3598                                  .dos_below_5:
  3599 00001056 204E6F74653A20444F-     	asciz " Note: DOS must be at least version 5.",13,10
  3599 0000105F 53206D757374206265-
  3599 00001068 206174206C65617374-
  3599 00001071 2076657273696F6E20-
  3599 0000107A 352E0D0A00         
  3600                                  .device_end_escaped:
  3601 0000107F 44656275676761626C-     	asciz _PROGNAME,": Error, got escaped command line end!",13,10
  3601 00001088 65206C44656275673A-
  3601 00001091 204572726F722C2067-
  3601 0000109A 6F7420657363617065-
  3601 000010A3 6420636F6D6D616E64-
  3601 000010AC 206C696E6520656E64-
  3601 000010B5 210D0A00           
  3602                                  .device_end_truncate:
  3603 000010B9 44656275676761626C-     	asciz _PROGNAME,": Error, truncating too long command line!",13,10
  3603 000010C2 65206C44656275673A-
  3603 000010CB 204572726F722C2074-
  3603 000010D4 72756E636174696E67-
  3603 000010DD 20746F6F206C6F6E67-
  3603 000010E6 20636F6D6D616E6420-
  3603 000010EF 6C696E65210D0A00   
  3604                                  %endif
  3605                                  %ifn _APPLICATION
  3606                                  .not_an_application:
  3607                                  	ascic _PROGNAME,": Error, no application mode included!",13,10
  3608                                  %endif
  3609                                  %if _APPLICATION || _DEVICE
  3610                                  %if _ALTVID
  3611                                  .noaltvid:
  3612 000010F7 44656275676761626C-     	asciz _PROGNAME,": Error, no alternative video adapter detected!",13,10
  3612 00001100 65206C44656275673A-
  3612 00001109 204572726F722C206E-
  3612 00001112 6F20616C7465726E61-
  3612 0000111B 746976652076696465-
  3612 00001124 6F2061646170746572-
  3612 0000112D 206465746563746564-
  3612 00001136 210D0A00           
  3613                                  %endif
  3614                                  	align 2, db 0
  3615                                  .help.defaultfilename:
  3616 0000113A 444445425547            	db _FILENAME
  3617                                  .help.defaultfilename.length equ $ - .help.defaultfilename
  3618                                  
  3619                                  	align 2, db 0
  3620                                  .help.1:
  3621 00001140 44656275676761626C-     	fill_at_least 80, 0, asciz _PROGNAME,_VERSION,", debugger.",13,10
  3621 00001149 65206C446562756720-
  3621 00001152 28323032362D30342D-
  3621 0000115B 3132292C2064656275-
  3621 00001164 676765722E0D0A0000-
  3621 00001164 <rep 24h>          
  3622                                  
  3623                                  .help.1a:
  3624 00001190 0D0A                    	db 13,10
  3625 00001192 55736167653A20          	db "Usage: "
  3626 00001199 00                      	asciz
  3627                                  .help.2:
  3628 0000119A 5B2E434F4D5D205B2F-     	db "[.COM] [/C=commands] [[drive:][path]progname.ext [parameters]]",13,10
  3628 000011A3 433D636F6D6D616E64-
  3628 000011AC 735D205B5B64726976-
  3628 000011B5 653A5D5B706174685D-
  3628 000011BE 70726F676E616D652E-
  3628 000011C7 657874205B70617261-
  3628 000011D0 6D65746572735D5D0D-
  3628 000011D9 0A                 
  3629 000011DA 0D0A                    	db 13,10
  3630 000011DC 20202F433D636F6D6D-     	db "  /C=commands",9,9,	"semicolon-separated list of commands (quote spaces)",13,10
  3630 000011E5 616E6473090973656D-
  3630 000011EE 69636F6C6F6E2D7365-
  3630 000011F7 70617261746564206C-
  3630 00001200 697374206F6620636F-
  3630 00001209 6D6D616E6473202871-
  3630 00001212 756F74652073706163-
  3630 0000121B 6573290D0A         
  3631                                  %if _CONFIG
  3632 00001220 20202F494E09090964-     	db "  /IN",9,9,9,	"discard command line buffer, do not run config",13,10
  3632 00001229 69736361726420636F-
  3632 00001232 6D6D616E64206C696E-
  3632 0000123B 65206275666665722C-
  3632 00001244 20646F206E6F742072-
  3632 0000124D 756E20636F6E666967-
  3632 00001256 0D0A               
  3633                                  %endif
  3634                                  %if _AUXBUFFSIZE != _AUXBUFFMAXSIZE
  3635 00001258 20202F413D4D415809-     	db "  /A=MAX",9,9,	"expand auxiliary buffer to maximum, #"
  3635 00001261 09657870616E642061-
  3635 0000126A 7578696C6961727920-
  3635 00001273 62756666657220746F-
  3635 0000127C 206D6178696D756D2C-
  3635 00001285 2023               
  3636 00001287 32345F353736            		_autodigits _AUXBUFFMAXSIZE, 1, 1
  3637 0000128D 2042797465730D0A        		db " Bytes",13,10
  3638 00001295 20202F413D4D494E09-     	db "  /A=MIN",9,9,	"restrict auxiliary buffer to minimum, #"
  3638 0000129E 097265737472696374-
  3638 000012A7 20617578696C696172-
  3638 000012B0 792062756666657220-
  3638 000012B9 746F206D696E696D75-
  3638 000012C2 6D2C2023           
  3639 000012C6 385F323038              		_autodigits _AUXBUFFSIZE, 1, 1
  3640 000012CB 2042797465730D0A        		db " Bytes",13,10
  3641 000012D3 20202F413D6E756D62-     	db "  /A=number",9,9,	"set auxiliary buffer size to hex number of bytes",13,10
  3641 000012DC 657209097365742061-
  3641 000012E5 7578696C6961727920-
  3641 000012EE 627566666572207369-
  3641 000012F7 7A6520746F20686578-
  3641 00001300 206E756D626572206F-
  3641 00001309 662062797465730D0A 
  3642 00001312 20202F413D236E756D-     	db "  /A=#number",9,9,	"set auxiliary buffer size to decimal number of bytes",13,10
  3642 0000131B 626572090973657420-
  3642 00001324 617578696C69617279-
  3642 0000132D 206275666665722073-
  3642 00001336 697A6520746F206465-
  3642 0000133F 63696D616C206E756D-
  3642 00001348 626572206F66206279-
  3642 00001351 7465730D0A         
  3643 00001356 20202F41090909616C-     	db "  /A",9,9,9,	"alias for /A=MAX",13,10
  3643 0000135F 69617320666F72202F-
  3643 00001368 413D4D41580D0A     
  3644                                  %endif
  3645                                  %if _EXTENSIONS
  3646 0000136F 20202F583D5B4D4158-     	db "  /X=[MAX|MIN|number]",9,	"change ELD code buffer size, 0 to #65_520 Bytes",13,10
  3646 00001378 7C4D494E7C6E756D62-
  3646 00001381 65725D096368616E67-
  3646 0000138A 6520454C4420636F64-
  3646 00001393 652062756666657220-
  3646 0000139C 73697A652C20302074-
  3646 000013A5 6F202336355F353230-
  3646 000013AE 2042797465730D0A   
  3647 000013B6 20202F593D5B4D4158-     	db "  /Y=[MAX|MIN|number]",9,	"change ELD data buffer size, 0 to #"
  3647 000013BF 7C4D494E7C6E756D62-
  3647 000013C8 65725D096368616E67-
  3647 000013D1 6520454C4420646174-
  3647 000013DA 612062756666657220-
  3647 000013E3 73697A652C20302074-
  3647 000013EC 6F2023             
  3648                                   %ifn _LINK
  3649                                  %assign NUMBER ext_data_max_size_equate_early
  3650                                  		_autodigits NUMBER, 5, 1
  3651                                  	db " Bytes",13,10
  3652                                   %else
  3653                                   wlcalc word_minusext_ext_data_area, equ $
  3654                                   wlcalc word_itoa_31_06_0Ah, equ $
  3655 000013EF [F0FF]                  	dw  relocatedzero + 0FFF0h
  3656 000013F1 00<rep 4h>              	times 4 db 0
  3657 000013F5 2042797465730D0A        	db " Bytes",13,10
  3658                                   %endif
  3659                                  %endif
  3660                                  %if _HISTORY_SEPARATE_FIXED && _HISTORY
  3661 000013FD 20202F483D5B4D4158-     	db "  /H=[MAX|MIN|number]",9,	"change history buffer size, #260 to #65_520 Bytes",13,10
  3661 00001406 7C4D494E7C6E756D62-
  3661 0000140F 65725D096368616E67-
  3661 00001418 6520686973746F7279-
  3661 00001421 206275666665722073-
  3661 0000142A 697A652C2023323630-
  3661 00001433 20746F202336355F35-
  3661 0000143C 32302042797465730D-
  3661 00001445 0A                 
  3662                                  %endif
  3663 00001446 20202F420909097275-     	db "  /B",9,9,9,	"run a breakpoint within initialisation",13,10
  3663 0000144F 6E206120627265616B-
  3663 00001458 706F696E7420776974-
  3663 00001461 68696E20696E697469-
  3663 0000146A 616C69736174696F6E-
  3663 00001473 0D0A               
  3664 00001475 20202F505B2B7C2D5D-     	db "  /P[+|-]",9,9,	"append ext to initial filename and search path",13,10
  3664 0000147E 0909617070656E6420-
  3664 00001487 65787420746F20696E-
  3664 00001490 697469616C2066696C-
  3664 00001499 656E616D6520616E64-
  3664 000014A2 207365617263682070-
  3664 000014AB 6174680D0A         
  3665 000014B0 20202F465B2B7C2D5D-     	db "  /F[+|-]",9,9,	"always treat executable file as a flat binary",13,10
  3665 000014B9 0909616C7761797320-
  3665 000014C2 747265617420657865-
  3665 000014CB 63757461626C652066-
  3665 000014D4 696C65206173206120-
  3665 000014DD 666C61742062696E61-
  3665 000014E6 72790D0A           
  3666 000014EA 20202F455B2B7C2D5D-     	db "  /E[+|-]",9,9,	"for flat binaries set up Stack Segment != PSP",13,10
  3666 000014F3 0909666F7220666C61-
  3666 000014FC 742062696E61726965-
  3666 00001505 732073657420757020-
  3666 0000150E 537461636B20536567-
  3666 00001517 6D656E7420213D2050-
  3666 00001520 53500D0A           
  3667                                  %if _VXCHG
  3668 00001524 20202F565B2B7C2D5D-     	db "  /V[+|-]",9,9,	"enable/disable video screen swapping",13,10
  3668 0000152D 0909656E61626C652F-
  3668 00001536 64697361626C652076-
  3668 0000153F 6964656F2073637265-
  3668 00001548 656E20737761707069-
  3668 00001551 6E670D0A           
  3669                                  %endif
  3670                                  %if _DEBUG && _DEBUG_COND
  3671                                  	db "  /D[+|-]",9,9,	"enable/disable debuggable mode",13,10
  3672                                  %endif
  3673                                  %if _ALTVID
  3674 00001555 20202F325B2B7C2D5D-     	db "  /2[+|-]",9,9,	"enable/disable use alternate video adapter for output",13,10
  3674 0000155E 0909656E61626C652F-
  3674 00001567 64697361626C652075-
  3674 00001570 736520616C7465726E-
  3674 00001579 61746520766964656F-
  3674 00001582 206164617074657220-
  3674 0000158B 666F72206F75747075-
  3674 00001594 740D0A             
  3675                                  %endif
  3676 00001597 202070726F676E616D-     	db "  progname.ext",9,9,"(executable) file to debug or examine",13,10
  3676 000015A0 652E65787409092865-
  3676 000015A9 786563757461626C65-
  3676 000015B2 292066696C6520746F-
  3676 000015BB 206465627567206F72-
  3676 000015C4 206578616D696E650D-
  3676 000015CD 0A                 
  3677 000015CE 2020706172616D6574-     	db "  parameters",9,9,	"parameters given to program",13,10
  3677 000015D7 657273090970617261-
  3677 000015E0 6D6574657273206769-
  3677 000015E9 76656E20746F207072-
  3677 000015F2 6F6772616D0D0A     
  3678 000015F9 0D0A                    	db 13,10
  3679 000015FB 466F722061206C6973-     	db "For a list of debugging commands, run "
  3679 00001604 74206F662064656275-
  3679 0000160D 6767696E6720636F6D-
  3679 00001616 6D616E64732C207275-
  3679 0000161F 6E20               
  3680 00001621 00                      	asciz
  3681                                  .help.3:
  3682 00001622 20616E642074797065-     	db " and type ? at the prompt.",13,10
  3682 0000162B 203F20617420746865-
  3682 00001634 2070726F6D70742E0D-
  3682 0000163D 0A                 
  3683 0000163E 00                      	asciz
  3684                                  %endif
  3685                                  %if _ONLY386
  3686                                  .no386:	ascizline "Error: This ",_PROGNAME," build requires a 386 CPU or higher."
  3687                                  %elif _ONLYNON386
  3688                                  .386:	asciiline "Warning: This ",_PROGNAME," build is ignorant of 386 CPU specifics."
  3689                                  	ascizline 9," It does not allow access to the available 386-specific registers!"
  3690                                  %endif
  3691                                  
  3692                                  %if _BOOTLDR_DISCARD_HELP
  3693 0000163F 00                      	align 2, db 0
  3694                                   %ifn _LINK || _LINK_COMPAT
  3695                                  .boothelp_replacement: helppage bootdisc
  3696                                   %else
  3697                                  .boothelp_replacement:
  3698                                  %define MESSAGE_INLINE
  3699                                  	%include "help/bootdisc.asm"
     1                              <1> %if 0
     2                              <1> 
     3                              <1> lDebug help message pages
     4                              <1> 
     5                              <1> Copyright (C) 1995-2003 Paul Vojta
     6                              <1> Copyright (C) 2008-2023 E. C. Masloch
     7                              <1> 
     8                              <1> Usage of the works is permitted provided that this
     9                              <1> instrument is retained with the works, so that any entity
    10                              <1> that uses the works is notified of this instrument.
    11                              <1> 
    12                              <1> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <1> 
    14                              <1> %endif
    15                              <1> 
    16                              <1> %define MESSAGE "This help page is only available in boot loaded mode.",13,10
    17                              <1> 
    18                              <1> %ifndef GET_MESSAGE_LENGTH
    19                              <1> %ifndef MESSAGE_INLINE
    20                              <1>  %include "debug.mac"
    21                              <1> %endif
    22                              <1> 
    23 00001640 546869732068656C70- <1> 	db MESSAGE
    23 00001649 207061676520697320- <1>
    23 00001652 6F6E6C792061766169- <1>
    23 0000165B 6C61626C6520696E20- <1>
    23 00001664 626F6F74206C6F6164- <1>
    23 0000166D 6564206D6F64652E0D- <1>
    23 00001676 0A                  <1>
    24                              <1> %else
    25                              <1> 	_strlen MESSAGE,0
    26                              <1> %endif
  3700                                  %undef MESSAGE_INLINE
  3701 00001677 00                      	asciz
  3702                                   %endif
  3703                                  	endarea .boothelp_replacement
  3704                                  %endif
  3705                                  
  3706                                  %if _APPLICATION || _DEVICE
  3707                                  %if _SYMBOLIC
  3708                                  .switch_s_garbage:
  3709                                  	asciz "Ignoring garbage at end of /S switch!",13,10
  3710                                  .switch_s_error:
  3711                                  	asciz "Switch /S invalid content",13,10
  3712                                  %endif
  3713                                  .invalidswitch:
  3714 00001678 496E76616C69642073-     	db "Invalid switch - "
  3714 00001681 7769746368202D20   
  3715                                  .invalidswitch_a:
  3716 00001689 780D0A00                	asciz "x",13,10
  3717                                  .switch_x_error:
  3718 0000168D 537769746368202F        	db "Switch /"
  3719                                  .switch_x_error_a:
  3720 00001695 7820696E76616C6964-     	asciz "x invalid content",13,10
  3720 0000169E 20636F6E74656E740D-
  3720 000016A7 0A00               
  3721                                  %endif
  3722                                  %if _CONFIG
  3723                                   %if _APPLICATION
  3724 000016A9 00                      	align 2, db 0
  3725                                  .default_cmdline.app:
  3726                                  	db _APPSCRIPTPREFIX
  3727 000016AA 406966206578697374-     	db "@if exists y ::CONFIG::",_APPSCRIPTNAME," :",_APPSCRIPTLABEL
  3727 000016B3 732079203A3A434F4E-
  3727 000016BC 4649473A3A4C444445-
  3727 000016C5 4255472E534C44203A-
  3727 000016CE 6170706C6963617469-
  3727 000016D7 6F6E73746172747570 
  3728 000016E0 207468656E2079203A-     	db " then y ::CONFIG::",_APPSCRIPTNAME," :",_APPSCRIPTLABEL
  3728 000016E9 3A434F4E4649473A3A-
  3728 000016F2 4C4444454255472E53-
  3728 000016FB 4C44203A6170706C69-
  3728 00001704 636174696F6E737461-
  3728 0000170D 72747570           
  3729 00001711 0D                      	db 13
  3730                                  .default_cmdline.app.length equ $ - .default_cmdline.app
  3731 00001712 00                      	db 0
  3732                                    %if .default_cmdline.app.length + 128 + 8 > _RC_BUFFER_SIZE
  3733                                     %error Too large default app cmdline
  3734                                    %endif
  3735                                   %endif
  3736                                   %if _DEVICE
  3737 00001713 00                      	align 2, db 0
  3738                                  .default_cmdline.dev:
  3739                                  	db _DEVSCRIPTPREFIX
  3740 00001714 406966206578697374-     	db "@if exists y ::CONFIG::",_DEVSCRIPTNAME," :",_DEVSCRIPTLABEL
  3740 0000171D 732079203A3A434F4E-
  3740 00001726 4649473A3A4C444445-
  3740 0000172F 4255472E534C44203A-
  3740 00001738 646576696365737461-
  3740 00001741 72747570           
  3741 00001745 207468656E2079203A-     	db " then y ::CONFIG::",_DEVSCRIPTNAME," :",_DEVSCRIPTLABEL
  3741 0000174E 3A434F4E4649473A3A-
  3741 00001757 4C4444454255472E53-
  3741 00001760 4C44203A6465766963-
  3741 00001769 6573746172747570   
  3742 00001771 0D                      	db 13
  3743                                  .default_cmdline.dev.length equ $ - .default_cmdline.dev
  3744 00001772 00                      	db 0
  3745                                    %if .default_cmdline.dev.length + 128 + 8 > _RC_BUFFER_SIZE
  3746                                     %error Too large default dev cmdline
  3747                                    %endif
  3748                                   %endif
  3749                                  %endif
  3750                                  %if _BOOTLDR
  3751 00001773 00                      	align 2, db 0
  3752                                  .default_cmdline.boot:
  3753                                  	db _BOOTSCRIPTPREFIX
  3754 00001774 406966206578697374-     	db "@if exists y ldp/",_BOOTSCRIPTNAME," :",_BOOTSCRIPTLABEL
  3754 0000177D 732079206C64702F4C-
  3754 00001786 4444454255472E534C-
  3754 0000178F 44203A626F6F747374-
  3754 00001798 6172747570         
  3755 0000179D 207468656E2079206C-     	db " then y ldp/",_BOOTSCRIPTNAME," :",_BOOTSCRIPTLABEL
  3755 000017A6 64702F4C4444454255-
  3755 000017AF 472E534C44203A626F-
  3755 000017B8 6F7473746172747570 
  3756 000017C1 00                      	asciz
  3757                                  .default_cmdline.boot.length equ $ - .default_cmdline.boot
  3758                                    %if .default_cmdline.boot.length + 8 > _RC_BUFFER_SIZE
  3759                                     %error Too large default boot cmdline
  3760                                    %endif
  3761                                  
  3762                                  %if _EXECUTABLE
  3763                                  .ldpslash:
  3764 000017C2 6C64702F                	db "ldp/"
  3765                                  %endif
  3766                                  .rpl_detected:
  3767 000017C6 52504C206465746563-     	asciz "RPL detected! Currently unsupported.",13,10
  3767 000017CF 746564212043757272-
  3767 000017D8 656E746C7920756E73-
  3767 000017E1 7570706F727465642E-
  3767 000017EA 0D0A00             
  3768                                  .mismatch_detected:
  3769 000017ED 4D69736D6174636820-     	asciz "Mismatch in memory size detected! Internal error!",13,10
  3769 000017F6 696E206D656D6F7279-
  3769 000017FF 2073697A6520646574-
  3769 00001808 65637465642120496E-
  3769 00001811 7465726E616C206572-
  3769 0000181A 726F72210D0A00     
  3770                                  .boot_ebda_unexpected:
  3771 00001821 454244412061742075-     	asciz "EBDA at unexpected position.",13,10
  3771 0000182A 6E6578706563746564-
  3771 00001833 20706F736974696F6E-
  3771 0000183C 2E0D0A00           
  3772                                  .boot_error_out_of_memory:
  3773 00001840 4F7574206F66206D65-     	asciz "Out of memory!",13,10
  3773 00001849 6D6F7279210D0A00   
  3774                                  .boot_error_internal:
  3775 00001851 496E7465726E616C20-     	asciz "Internal error while relocating load image!",13,10
  3775 0000185A 6572726F7220776869-
  3775 00001863 6C652072656C6F6361-
  3775 0000186C 74696E67206C6F6164-
  3775 00001875 20696D616765210D0A-
  3775 0000187E 00                 
  3776                                  .booterror:
  3777 0000187F 0D0A44656275676761-     	asciz 13,10,_PROGNAME," boot error. Press any key to reboot.",13,10
  3777 00001888 626C65206C44656275-
  3777 00001891 6720626F6F74206572-
  3777 0000189A 726F722E2050726573-
  3777 000018A3 7320616E79206B6579-
  3777 000018AC 20746F207265626F6F-
  3777 000018B5 742E0D0A00         
  3778                                  .bootwarn:
  3779 000018BA 0D0A44656275676761-     	asciz 13,10,_PROGNAME," warning: "
  3779 000018C3 626C65206C44656275-
  3779 000018CC 67207761726E696E67-
  3779 000018D5 3A2000             
  3780                                  .boot_warn_no_loader:
  3781 000018D8 457870656374656420-     	asciz "Expected loader not found!",13,10
  3781 000018E1 6C6F61646572206E6F-
  3781 000018EA 7420666F756E64210D-
  3781 000018F3 0A00               
  3782                                  .boot_warn_invalid_loader:
  3783 000018F5 457870656374656420-     	asciz "Expected loader is invalid!",13,10
  3783 000018FE 6C6F61646572206973-
  3783 00001907 20696E76616C696421-
  3783 00001910 0D0A00             
  3784                                  .boot_warn_lazy_loader:
  3785 00001913 457870656374656420-     	asciz "Expected loader doesn't have a query function!",13,10
  3785 0000191C 6C6F6164657220646F-
  3785 00001925 65736E277420686176-
  3785 0000192E 652061207175657279-
  3785 00001937 2066756E6374696F6E-
  3785 00001940 210D0A00           
  3786                                  .boot_warn_loader_no_reloc:
  3787 00001944 4C6F6164657220646F-     	asciz "Loader doesn't provide a relocation function!",13,10
  3787 0000194D 65736E27742070726F-
  3787 00001956 766964652061207265-
  3787 0000195F 6C6F636174696F6E20-
  3787 00001968 66756E6374696F6E21-
  3787 00001971 0D0A00             
  3788                                  %endif
  3789                                  %if _DOSEMU
  3790 00001974 30322F32352F3933        .dosemudate:	db "02/25/93"
  3791                                  %endif
  3792                                  %if _VDD && (_APPLICATION || _DEVICE)
  3793 0000197C 44454258585644442E-     .vdd:		asciz "DEBXXVDD.DLL"
  3793 00001985 444C4C00           
  3794 00001989 446973706174636800      .dispatch:	asciz "Dispatch"
  3795 00001992 496E697400              .init:		asciz "Init"
  3796 00001997 4D4F555345202020        .mouse:		db "MOUSE",32,32,32		; Looks like a device name
  3797 0000199F 416E64792057617473-     .andy:		db "Andy Watson"		; I don't know him and why he's inside the NTVDM mouse driver
  3797 000019A8 6F6E               
  3798                                  	endarea .andy
  3799 000019AA 57696E646F7773204E-     .ntdos:		db "Windows NT MS-DOS subsystem Mouse Driver"	; Int33.004D mouse driver copyright string (not ASCIZ)
  3799 000019B3 54204D532D444F5320-
  3799 000019BC 73756273797374656D-
  3799 000019C5 204D6F757365204472-
  3799 000019CE 69766572           
  3800                                  	endarea .ntdos
  3801                                  
  3802                                  		; INP:	-
  3803                                  		; OUT:	CY if not NTVDM
  3804                                  		;	NC if NTVDM
  3805                                  		;	ds = es = cs
  3806                                  		; CHG:	ax, bx, cx, dx, di, si, bp, es, ds
  3807                                  isnt:
  3808 000019D2 B80258                  		mov ax, 5802h			; Get UMB link state
  3809 000019D5 CD21                    		int 21h
  3810 000019D7 30E4                    		xor ah, ah
  3811 000019D9 50                      		push ax				; Save UMB link state
  3812 000019DA B80358                  		mov ax, 5803h			; Set UMB link state:
  3813 000019DD BB0100                  		mov bx, 1			;  Add UMBs to memory chain
  3814 000019E0 CD21                    		int 21h
  3815 000019E2 B452                    		mov ah, 52h
  3816 000019E4 BBFFFF                  		mov bx, -1
  3817 000019E7 CD21                    		int 21h				; Get list of lists
  3818 000019E9 43                      		inc bx				; 0FFFFh ?
  3819 000019EA 7503E98E00              		jz .notnt			; invalid -->
  3820 000019EF 83FB02                  		cmp bx, 2			; would access word at 0FFFFh ?
  3821 000019F2 7503E98600              		je .notnt			; yes, invalid -->
  3822 000019F7 268B47FD                		mov ax, word [es:bx-3]		; First MCB
  3823 000019FB 0E                      		push cs
  3824 000019FC 07                      		pop es				; reset es
  3825                                  .loop:
  3826 000019FD 8ED8                    		mov ds, ax			; ds = MCB
  3827 000019FF 40                      		inc ax				; Now segment of memory block itself
  3828 00001A00 31D2                    		xor dx, dx
  3829 00001A02 31DB                    		xor bx, bx
  3830 00001A04 803F5A                  		cmp byte [bx], 'Z'		; End of MCB chain?
  3831 00001A07 7503                    		jne .notlast
  3832 00001A09 42                      		inc dx
  3833 00001A0A EB05                    		jmp short .notchain
  3834                                   .notlast:
  3835 00001A0C 803F4D                  		cmp byte [bx], 'M'		; Valid MCB chain?
  3836 00001A0F 756C                    		jne .error
  3837                                   .notchain:
  3838 00001A11 8B4F03                  		mov cx, [bx+3]			; MCB size in paragraphs
  3839                                  				; ax = current memory block
  3840                                  				; cx = size of current memory block in paragraphs
  3841                                  				; dx = flag whether this is the last MCB
  3842                                  				; ds = current MCB (before memory block)
  3843 00001A14 837F0108                		cmp word [bx+1], 8		; MCB owner DOS?
  3844 00001A18 755D                    		jne .notfound_1
  3845 00001A1A 817F085344              		cmp word [bx+8], "SD"		; MCB name "SD"?
  3846 00001A1F 7556                    		jne .notfound_1
  3847                                  .loopsub:
  3848 00001A21 8ED8                    		mov ds, ax			; SD sub-segment inside memory block
  3849 00001A23 40                      		inc ax
  3850 00001A24 49                      		dec cx
  3851 00001A25 8B6F03                  		mov bp, word [bx+3]		; Paragraphs 'til end of SD sub-segment
  3852                                  				; ax = current SD sub-segment
  3853                                  				; cx = paragraphs from SD sub-segment start (ax) to current memory block end
  3854                                  				; ds = current SD sub-MCB (like MCB, but for SD sub-segment)
  3855                                  				; bp = current SD sub-segment size in paragraphs
  3856 00001A28 39E9                    		cmp cx, bp
  3857 00001A2A 724B                    		jb .notfound_1			; Goes beyond memory block, invalid -->
  3858 00001A2C 803F51                  		cmp byte [bx], 'Q'		; NTVDM type 51h sub-segment ?
  3859 00001A2F 753C                    		jne .notfound_2			; no -->
  3860 00001A31 BE0800                  		mov si, 8			; Offset of device name (if SD device driver sub-segment)
  3861 00001A34 BF[9719]                		mov di, imsg.mouse
  3862 00001A37 51                      		push cx
  3863 00001A38 89F1                    		mov cx, si			; length of name
  3864 00001A3A F3A6                    		repe cmpsb			; blank-padded device name "MOUSE" ?
  3865 00001A3C 59                      		pop cx
  3866 00001A3D 752E                    		jne .notfound_2			;  Device name doesn't match, try next SD sub-segment
  3867 00001A3F 8CD8                    		mov ax, ds
  3868 00001A41 40                      		inc ax
  3869 00001A42 8ED8                    		mov ds, ax			; Segment of SD sub-segment
  3870                                  				; ds = current SD sub-segment
  3871 00001A44 89E8                    		mov ax, bp			; Leave paragraph value in bp
  3872 00001A46 A900F0                  		test ax, 0F000h			; Would *16 cause an overflow?
  3873 00001A49 7520                    		jnz .notfound_3			;  Then too large -->
  3874 00001A4B 51                      		push cx
  3875 00001A4C B104                    		mov cl, 4
  3876 00001A4E D3E0                    		shl ax, cl			; *16
  3877 00001A50 59                      		pop cx
  3878                                  				; ax = current SD sub-segment size in byte
  3879                                  .andy:
  3880 00001A51 BF[9F19]                		mov di, imsg.andy
  3881 00001A54 51                      		push cx
  3882 00001A55 B90B00                  		mov cx, imsg.andy_size
  3883 00001A58 E82E00                  		call findstring			; String "Andy Watson"?
  3884 00001A5B 59                      		pop cx
  3885 00001A5C 720D                    		jc .notfound_3
  3886                                  .ntdos:
  3887 00001A5E BF[AA19]                		mov di, imsg.ntdos
  3888 00001A61 51                      		push cx
  3889 00001A62 B92800                  		mov cx, imsg.ntdos_size
  3890 00001A65 E82100                  		call findstring			; String "Windows NT MS-DOS subsystem Mouse Driver"?
  3891 00001A68 59                      		pop cx
  3892 00001A69 7313                    		jnc .found			; (NC)
  3893                                  .notfound_3:
  3894 00001A6B 8CD8                    		mov ax, ds
  3895                                  .notfound_2:
  3896 00001A6D 39E9                    		cmp cx, bp
  3897 00001A6F 7406                    		je .notfound_1			; End of SD memory block, get next MCB
  3898 00001A71 01E8                    		add ax, bp			; Address next SD sub-MCB
  3899 00001A73 29E9                    		sub cx, bp
  3900 00001A75 EBAA                    		jmp short .loopsub		; Try next SD sub-segment
  3901                                  .notfound_1:
  3902 00001A77 01C8                    		add ax, cx			; Address next MCB
  3903 00001A79 85D2                    		test dx, dx			; Non-zero if 'Z' MCB
  3904 00001A7B 7480                    		jz .loop			; If not at end of MCB chain, try next
  3905                                  		; jmp short .notnt		;  Otherwise, not found
  3906                                   .error:
  3907                                   .notnt:
  3908 00001A7D F9                      		stc
  3909                                  .found:
  3910 00001A7E 0E                      		push cs
  3911 00001A7F 1F                      		pop ds				; restore ds
  3912                                  
  3913 00001A80 5B                      		pop bx				; saved UMB link state
  3914 00001A81 B80358                  		mov ax, 5803h
  3915 00001A84 9C                      		pushf
  3916 00001A85 CD21                    		int 21h				; Set UMB link state
  3917 00001A87 9D                      		popf
  3918 00001A88 C3                      		retn
  3919                                  
  3920                                  findstring:
  3921 00001A89 31F6                    		xor si, si
  3922                                  .loop:
  3923 00001A8B 56                      		push si
  3924 00001A8C 01CE                    		add si, cx
  3925 00001A8E 7203                    		jc .notfound_c
  3926 00001A90 4E                      		dec si				; The largest offset we need for this compare
  3927 00001A91 39F0                    		cmp ax, si
  3928                                   .notfound_c:
  3929 00001A93 5E                      		pop si
  3930 00001A94 720D                    		jb .return			; Not found if at top of memory block -->
  3931 00001A96 57                      		push di
  3932 00001A97 56                      		push si
  3933 00001A98 51                      		push cx
  3934 00001A99 F3A6                    		repe cmpsb			; String somewhere inside program?
  3935 00001A9B 59                      		pop cx
  3936 00001A9C 5E                      		pop si
  3937 00001A9D 5F                      		pop di
  3938 00001A9E 7403                    		je .return			;  Yes, proceed --> (if ZR, NC)
  3939 00001AA0 46                      		inc si				; Increase pointer by one
  3940 00001AA1 EBE8                    		jmp short .loop			;  Try next address
  3941                                  .return:
  3942 00001AA3 C3                      		retn
  3943                                  %endif
  3944                                  
  3945                                  
  3946                                  		; Move paragraphs
  3947                                  		;
  3948                                  		; INP:	ax:0-> source
  3949                                  		;	dx:0-> destination
  3950                                  		;	cx = number of paragraphs
  3951                                  		; CHG:	-
  3952                                  		; Note:	Doesn't work correctly on HMA; doesn't always wrap to LMA either.
  3953                                  		;	Do not provide a wrapped/HMA source or destination!
  3954                                  init_movp:
  3955 00001AA4 51                      	push cx
  3956 00001AA5 1E                      	push ds
  3957 00001AA6 56                      	push si
  3958 00001AA7 06                      	push es
  3959 00001AA8 57                      	push di
  3960                                  
  3961 00001AA9 39D0                    	cmp ax, dx		; source above destination ?
  3962 00001AAB 770A                    	ja .up			; yes, move up (forwards) -->
  3963 00001AAD 747B                    	je .return		; same, no need to move -->
  3964 00001AAF 50                      	push ax
  3965 00001AB0 01C8                    	add ax, cx		; (expected not to carry)
  3966 00001AB2 39D0                    	cmp ax, dx		; end of source is above destination ?
  3967 00001AB4 58                      	pop ax
  3968 00001AB5 7730                    	ja .down		; yes, move from top down -->
  3969                                  	; Here, the end of source is below-or-equal the destination,
  3970                                  	;  so they do not overlap. In this case we prefer moving up.
  3971                                  
  3972                                  .up:
  3973 00001AB7 50                      	push ax
  3974 00001AB8 52                      	push dx
  3975                                  .uploop:
  3976 00001AB9 8ED8                    	mov ds, ax
  3977 00001ABB 8EC2                    	mov es, dx
  3978 00001ABD 31FF                    	xor di, di
  3979 00001ABF 31F6                    	xor si, si		; -> start of segment
  3980 00001AC1 81E90010                	sub cx, 1000h		; 64 KiB left ?
  3981 00001AC5 7610                    	jbe .uplast		; no -->
  3982 00001AC7 51                      	push cx
  3983 00001AC8 B90080                  	mov cx, 10000h /2
  3984 00001ACB F3A5                    	rep movsw		; move 64 KiB
  3985 00001ACD 59                      	pop cx
  3986 00001ACE 050010                  	add ax, 1000h
  3987 00001AD1 81C20010                	add dx, 1000h		; -> next segment
  3988 00001AD5 EBE2                    	jmp short .uploop	; proceed for more -->
  3989                                  .uplast:
  3990 00001AD7 81C10010                	add cx, 1000h		; restore counter
  3991 00001ADB D1E1                    	shl cx, 1
  3992 00001ADD D1E1                    	shl cx, 1
  3993 00001ADF D1E1                    	shl cx, 1		; *8, paragraphs to words
  3994 00001AE1 F3A5                    	rep movsw		; move last part
  3995 00001AE3 5A                      	pop dx
  3996 00001AE4 58                      	pop ax
  3997 00001AE5 EB43                    	jmp short .return
  3998                                  
  3999                                  .down:
  4000 00001AE7 FD                      	std			; _AMD_ERRATUM_109_WORKAROUND as below
  4001                                  .dnloop:
  4002 00001AE8 81E90010                	sub cx, 1000h		; 64 KiB left ?
  4003 00001AEC 761A                    	jbe .dnlast		; no -->
  4004 00001AEE 50                      	push ax
  4005 00001AEF 52                      	push dx
  4006 00001AF0 01C8                    	add ax, cx
  4007 00001AF2 01CA                    	add dx, cx
  4008 00001AF4 8ED8                    	mov ds, ax		; -> 64 KiB not yet moved
  4009 00001AF6 8EC2                    	mov es, dx
  4010 00001AF8 5A                      	pop dx
  4011 00001AF9 58                      	pop ax
  4012 00001AFA BFFEFF                  	mov di, -2
  4013 00001AFD 89FE                    	mov si, di		; moved from last word down
  4014 00001AFF 51                      	push cx
  4015 00001B00 B90080                  	mov cx, 10000h /2
  4016 00001B03 F3A5                    	rep movsw		; move 64 KiB
  4017 00001B05 59                      	pop cx
  4018 00001B06 EBE0                    	jmp short .dnloop	; proceed for more -->
  4019                                  .dnlast:
  4020 00001B08 81C10010                	add cx, 1000h		; restore counter
  4021 00001B0C D1E1                    	shl cx, 1
  4022 00001B0E D1E1                    	shl cx, 1
  4023 00001B10 D1E1                    	shl cx, 1		; *8, paragraphs to words
  4024 00001B12 89CF                    	mov di, cx
  4025 00001B14 4F                      	dec di
  4026 00001B15 D1E7                    	shl di, 1		; words to offset, -> last word
  4027 00001B17 89FE                    	mov si, di
  4028 00001B19 8ED8                    	mov ds, ax
  4029 00001B1B 8EC2                    	mov es, dx		; first segment correct
  4030                                  
  4031                                  
  4032                                  	numdef AMD_ERRATUM_109_WORKAROUND, 1
  4033                                  %if 0
  4034                                  
  4035                                  Jack R. Ellis pointed out this erratum:
  4036                                  
  4037                                  Quoting from https://www.amd.com/system/files/TechDocs/25759.pdf page 69:
  4038                                  
  4039                                  109   Certain Reverse REP MOVS May Produce Unpredictable Behavior
  4040                                  
  4041                                  Description
  4042                                  
  4043                                  In certain situations a REP MOVS instruction may lead to
  4044                                  incorrect results. An incorrect address size, data size
  4045                                  or source operand segment may be used or a succeeding
  4046                                  instruction may be skipped. This may occur under the
  4047                                  following conditions:
  4048                                  
  4049                                  * EFLAGS.DF=1 (the string is being moved in the reverse direction).
  4050                                  
  4051                                  * The number of items being moved (RCX) is between 1 and 20.
  4052                                  
  4053                                  * The REP MOVS instruction is preceded by some microcoded instruction
  4054                                    that has not completely retired by the time the REP MOVS begins
  4055                                    execution. The set of such instructions includes BOUND, CLI, LDS,
  4056                                    LES, LFS, LGS, LSS, IDIV, and most microcoded x87 instructions.
  4057                                  
  4058                                  Potential Effect on System
  4059                                  
  4060                                  Incorrect results may be produced or the system may hang.
  4061                                  
  4062                                  Suggested Workaround
  4063                                  
  4064                                  Contact your AMD representative for information on a BIOS update.
  4065                                  
  4066                                  %endif
  4067                                  
  4068                                  %if _AMD_ERRATUM_109_WORKAROUND
  4069 00001B1D E308                    	jcxz @FF
  4070 00001B1F 83F914                  	cmp cx, 20
  4071 00001B22 7703                    	ja @FF
  4072                                  @@:
  4073 00001B24 A5                      	movsw
  4074 00001B25 E2FD                    	loop @B
  4075                                  @@:
  4076                                  %endif
  4077 00001B27 F3A5                    	rep movsw		; move first part
  4078 00001B29 FC                      	cld
  4079                                  .return:
  4080 00001B2A 5F                      	pop di
  4081 00001B2B 07                      	pop es
  4082 00001B2C 5E                      	pop si
  4083 00001B2D 1F                      	pop ds
  4084 00001B2E 59                      	pop cx
  4085 00001B2F C3                      	retn
  4086                                  
  4087                                  
  4088                                  %if _BOOTLDR
  4089                                  		; only called for boot-loaded mode
  4090                                  init_getc_bootldr:
  4091 00001B30 31C0                    	xor ax, ax
  4092 00001B32 CD16                    	int 16h
  4093 00001B34 C3                      	retn
  4094                                  %endif
  4095                                  
  4096                                  init_putsz_cs:
  4097 00001B35 50                      	push ax
  4098 00001B36 53                      	push bx
  4099 00001B37 51                      	push cx
  4100 00001B38 52                      	push dx
  4101 00001B39 1E                      	push ds
  4102 00001B3A 06                      	push es
  4103 00001B3B 57                      	push di
  4104 00001B3C 0E                      	 push cs
  4105 00001B3D 07                      	 pop es
  4106 00001B3E 0E                      	 push cs
  4107 00001B3F 1F                      	 pop ds
  4108 00001B40 89D7                    	mov di, dx			; es:di-> string
  4109 00001B42 30C0                    	xor al, al
  4110 00001B44 B9FFFF                  	mov cx, -1
  4111 00001B47 F2AE                    	repne scasb			; search zero
  4112 00001B49 F7D1                    	not cx
  4113 00001B4B 49                      	dec cx				; cx = length of message
  4114 00001B4C 5F                      	pop di
  4115 00001B4D E82900                  	call init_puts_ds
  4116 00001B50 07                      	pop es
  4117 00001B51 1F                      	pop ds
  4118 00001B52 5A                      	pop dx
  4119 00001B53 59                      	pop cx
  4120 00001B54 5B                      	pop bx
  4121 00001B55 58                      	pop ax
  4122 00001B56 C3                      	retn
  4123                                  
  4124                                  %if _BOOTLDR
  4125                                  init_putsz_cs_bootldr:
  4126 00001B57 50                      	push ax
  4127 00001B58 53                      	push bx
  4128 00001B59 51                      	push cx
  4129 00001B5A 52                      	push dx
  4130 00001B5B 1E                      	push ds
  4131 00001B5C 06                      	push es
  4132 00001B5D 57                      	push di
  4133 00001B5E 0E                      	 push cs
  4134 00001B5F 07                      	 pop es
  4135 00001B60 0E                      	 push cs
  4136 00001B61 1F                      	 pop ds
  4137 00001B62 89D7                    	mov di, dx			; es:di-> string
  4138 00001B64 30C0                    	xor al, al
  4139 00001B66 B9FFFF                  	mov cx, -1
  4140 00001B69 F2AE                    	repne scasb			; search zero
  4141 00001B6B F7D1                    	not cx
  4142 00001B6D 49                      	dec cx				; cx = length of message
  4143 00001B6E 5F                      	pop di
  4144 00001B6F E80F00                  	call init_puts_ds_bootldr
  4145 00001B72 07                      	pop es
  4146 00001B73 1F                      	pop ds
  4147 00001B74 5A                      	pop dx
  4148 00001B75 59                      	pop cx
  4149 00001B76 5B                      	pop bx
  4150 00001B77 58                      	pop ax
  4151 00001B78 C3                      	retn
  4152                                  %endif
  4153                                  
  4154                                  init_puts_ds:
  4155                                  %if _BOOTLDR
  4156                                   %if _APPLICATION || _DEVICE
  4157 00001B79 36F606[0100]40          	testopt [ss:internalflags], nodosloaded
  4158 00001B7F 7413                    	jz @F
  4159                                   %endif
  4160                                  
  4161                                  init_puts_ds_bootldr:
  4162 00001B81 56                      	push si
  4163 00001B82 55                      	push bp
  4164 00001B83 89D6                    	mov si, dx
  4165 00001B85 E30A                    	jcxz .return
  4166                                  .loop:
  4167 00001B87 AC                      	lodsb
  4168 00001B88 BB0700                  	mov bx, 0007
  4169 00001B8B B40E                    	mov ah, 0Eh
  4170 00001B8D CD10                    	int 10h
  4171 00001B8F E2F6                    	loop .loop
  4172                                  .return:
  4173 00001B91 5D                      	pop bp
  4174 00001B92 5E                      	pop si
  4175 00001B93 C3                      	retn
  4176                                  
  4177                                  @@:
  4178                                  %endif
  4179                                  %if _APPLICATION || _DEVICE
  4180 00001B94 BB0100                  	mov bx, 1			; standard output
  4181 00001B97 B440                    	mov ah, 40h			; write to file
  4182 00001B99 E302                    	jcxz @F
  4183 00001B9B CD21                    	int 21h
  4184                                  @@:
  4185 00001B9D C3                      	retn
  4186                                  %endif
  4187                                  
  4188                                  
  4189                                  %if _BOOTLDR
  4190                                  		; ds = ss = debugger data segment
  4191                                  		; (ds - 1) = image ident prefix paragraph
  4192                                  boot_old_initcode:
  4193 00001B9E FC                      	cld
  4194                                  
  4195                                  d4	call init_d4message
  4196                                  d4	asciz "In boot loader; press any key",13,10
  4197                                  d4	call init_d4pauseforkey
  4198                                  
  4199                                  %if !_LOADER
  4200 00001B9F C706[0000]8000          	mov word [execblk.cmdline], 80h
  4201 00001BA5 C60681000D              	mov byte [81h], 0Dh
  4202 00001BAA C606[0000]01            	mov byte [fileext], EXT_OTHER	; empty file name and command line as per N
  4203                                  %endif
  4204                                  %endif	; _BOOTLDR
  4205                                  
  4206                                  old_initcode:
  4207 00001BAF FC                      	cld
  4208                                  	d0bp
  4209 00001BB0 8CD8                    	mov ax, ds
  4210                                  %if !_LOADER
  4211 00001BB2 A3[0200]                	mov word [execblk.cmdline + 2], ax
  4212 00001BB5 A3[0200]                	mov word [execblk.fcb1 + 2], ax
  4213 00001BB8 A3[0200]                	mov word [execblk.fcb2 + 2], ax	; set up parameter block for exec command
  4214                                  %endif
  4215 00001BBB A3[0000]                	mov word [pspdbg], ax
  4216                                  
  4217                                  %if _IMMASM  && !_IMMASM_AUXBUFF
  4218                                   %ifn _LINK
  4219                                  	add ax, (immasm_buffer + DATASECTIONFIXUP) >> 4
  4220                                   %else
  4221 00001BBE 05[0000]                	add ax, strict word immasm_buffer
  4222                                   wlcalc word_shr_4, equ $ - 2
  4223                                   %endif
  4224 00001BC1 A3[0000]                	mov word [immseg], ax
  4225                                  %endif
  4226                                  
  4227 00001BC4 1E                      	push ds
  4228 00001BC5 B84000                  	mov ax, 40h
  4229 00001BC8 8ED8                    	mov ds, ax
  4230 00001BCA A18200                  	mov ax, word [82h]	; end of circular keypress buffer
  4231 00001BCD 8B168000                	mov dx, word [80h]	; start of circular buffer
  4232 00001BD1 85C0                    	test ax, ax
  4233 00001BD3 7431                    	jz .forcekeybuffer
  4234 00001BD5 85D2                    	test dx, dx
  4235 00001BD7 742D                    	jz .forcekeybuffer
  4236 00001BD9 89C3                    	mov bx, ax
  4237 00001BDB 29D3                    	sub bx, dx		; cmp end, start
  4238 00001BDD 7627                    	jbe .forcekeybuffer	; below or equal is invalid -->
  4239 00001BDF F6C301                  	test bl, 1		; even amount of bytes ?
  4240 00001BE2 7522                    	jnz .forcekeybuffer	; no, invalid -->
  4241 00001BE4 8B1E1A00                	mov bx, word [1Ah]	; current head of circular buffer
  4242 00001BE8 39C3                    	cmp bx, ax
  4243 00001BEA 731A                    	jae .forcekeybuffer
  4244 00001BEC 29D3                    	sub bx, dx
  4245 00001BEE 7216                    	jb .forcekeybuffer
  4246 00001BF0 F6C301                  	test bl, 1
  4247 00001BF3 7511                    	jnz .forcekeybuffer	; invalid -->
  4248 00001BF5 8B1E1C00                	mov bx, word [1Ch]	; current tail of circular buffer
  4249 00001BF9 39C3                    	cmp bx, ax
  4250 00001BFB 7309                    	jae .forcekeybuffer
  4251 00001BFD 29D3                    	sub bx, dx
  4252 00001BFF 7205                    	jb .forcekeybuffer
  4253 00001C01 F6C301                  	test bl, 1
  4254 00001C04 740E                    	jz @F			; valid -->
  4255                                  .forcekeybuffer:
  4256 00001C06 1F                      	pop ds
  4257 00001C07 C706[0000]3E00          	mov word [io_end_buffer], 3Eh
  4258 00001C0D C706[0000]1E00          	mov word [io_start_buffer], 1Eh
  4259 00001C13 A8                      	db __TEST_IMM8		; (skip pop)
  4260                                  @@:
  4261 00001C14 1F                      	pop ds
  4262                                  
  4263                                  %if _BOOTLDR
  4264                                   %if _APPLICATION || _DEVICE
  4265 00001C15 F606[0100]40            	testopt [internalflags], nodosloaded
  4266 00001C1A 7403                    	jz .checkio
  4267                                   %endif
  4268                                  d4	call init_d4message
  4269                                  d4	asciz "Common initialisation, determining processor type now",13,10
  4270 00001C1C E9BB00                  	jmp init_determineprocessor
  4271                                  .checkio:
  4272                                  %endif
  4273                                  
  4274                                  %if _APPLICATION || _DEVICE
  4275                                  		; Check for console input vs. input from a file or other device.
  4276                                  		; This has to be done early because MS-DOS seems to switch CON
  4277                                  		; to cooked I/O mode only then.
  4278 00001C1F B80044                  	mov ax, 4400h		; IOCTL get device information
  4279 00001C22 31DB                    	xor bx, bx		; StdIn
  4280 00001C24 B283                    	mov dl, 83h		; default if 21.4400 fails
  4281 00001C26 CD21                    	int 21h
  4282 00001C28 F6C280                  	test dl, 80h
  4283 00001C2B 7414                    	jz .inputfile
  4284 00001C2D 8026[0000]DF            	clropt [internalflags], inputfile
  4285 00001C32 F6C203                  	test dl, 3
  4286 00001C35 740A                    	jz .inputdevice		; if not the console input
  4287 00001C37 8026[0000]EF            	clropt [internalflags], notstdinput
  4288 00001C3C C606[0000]00            	mov byte [notatty], 0	; it _is_ a tty
  4289                                  .inputdevice:
  4290                                  .inputfile:
  4291 00001C41 B80044                  	mov ax, 4400h		; IOCTL get device information
  4292 00001C44 43                      	inc bx			; StdOut
  4293 00001C45 B283                    	mov dl, 83h		; default if 21.4400 fails
  4294 00001C47 CD21                    	int 21h
  4295 00001C49 F6C280                  	test dl, 80h
  4296 00001C4C 740F                    	jz .outputfile
  4297 00001C4E 8026[0000]7F            	clropt [internalflags], outputfile
  4298 00001C53 F6C203                  	test dl, 3
  4299 00001C56 7405                    	jz .outputdevice	; if not the console output
  4300 00001C58 8026[0000]BF            	clropt [internalflags], notstdoutput
  4301                                  .outputdevice:
  4302                                  .outputfile:
  4303                                  
  4304                                  		; Check DOS version
  4305                                  %if _VDD
  4306 00001C5D 1E                      	push ds
  4307 00001C5E 0E                      	 push cs
  4308 00001C5F 1F                      	 pop ds
  4309 00001C60 0E                      	 push cs
  4310 00001C61 07                      	 pop es
  4311 00001C62 E86DFD                  	call isnt		; NTVDM ?
  4312 00001C65 1F                      	pop ds
  4313 00001C66 7205                    	jc .isnotnt		; no -->
  4314 00001C68 800E[0200]02            	setopt [internalflags], runningnt
  4315                                  .isnotnt:
  4316                                  %endif
  4317                                  
  4318 00001C6D B80030                  	mov ax, 3000h		; check DOS version
  4319 00001C70 CD21                    	int 21h
  4320 00001C72 86C4                    	xchg al, ah
  4321 00001C74 3D1F03                  	cmp ax, ver(3,31)	; MS-DOS version > 3.30 ?
  4322 00001C77 7205                    	jb .notoldpacket	; no -->
  4323 00001C79 800E[0000]01            	setopt [internalflags], oldpacket	; assume Int25/Int26 packet method available
  4324                                  .notoldpacket:
  4325 00001C7E 50                      	push ax
  4326 00001C7F 31DB                    	xor bx, bx		; preset to invalid value
  4327 00001C81 B80633                  	mov ax, 3306h
  4328 00001C84 CD21                    	int 21h
  4329 00001C86 84C0                    	test al, al		; invalid, DOS 1.x error -->
  4330 00001C88 7402                    	jz .213306invalid
  4331 00001C8A 3CFF                    	cmp al, -1		; invalid
  4332                                  .213306invalid:
  4333 00001C8C 58                      	pop ax
  4334 00001C8D 7407                    	je .useoldver
  4335 00001C8F 85DB                    	test bx, bx		; 0.0 ?
  4336 00001C91 7403                    	jz .useoldver		; assume invalid -->
  4337 00001C93 93                      	xchg ax, bx		; get version to ax
  4338 00001C94 86C4                    	xchg al, ah		; strange Microsoft version format
  4339                                  .useoldver:
  4340 00001C96 3D0107                  	cmp ax, ver(7,01)	; MS-DOS version > 7.00 ?
  4341 00001C99 7205                    	jb .notnewpacket	; no -->
  4342 00001C9B 800E[0000]03            	setopt [internalflags], newpacket| oldpacket	; assume both packet methods available
  4343                                  .notnewpacket:
  4344                                  %if _VDD
  4345 00001CA0 F606[0200]02            	testopt [internalflags], runningnt
  4346 00001CA5 741F                    	jz .novdd
  4347 00001CA7 1E                      	push ds
  4348 00001CA8 0E                      	 push cs
  4349 00001CA9 1F                      	 pop ds
  4350 00001CAA 0E                      	 push cs
  4351 00001CAB 07                      	 pop es
  4352 00001CAC BE[7C19]                	mov si, imsg.vdd	; ds:si-> ASCIZ VDD filename
  4353 00001CAF BB[8919]                	mov bx, imsg.dispatch	; ds:bx-> ASCIZ dispatching entry
  4354 00001CB2 BF[9219]                	mov di, imsg.init	; es:di-> ASCIZ init entry
  4355 00001CB5 F8                      	clc			; !
  4356 00001CB6 C4C4580090              	RegisterModule		; register VDD
  4357 00001CBB 1F                      	pop ds
  4358 00001CBC 7208                    	jc .novdd		; error ? -->
  4359 00001CBE A3[0000]                	mov word [hVdd], ax
  4360 00001CC1 800E[0000]05            	setopt [internalflags], ntpacket| oldpacket	; assume old packet method also available
  4361                                  .novdd:
  4362                                  %endif
  4363                                  %endif
  4364                                  
  4365                                  
  4366                                  %if _CONFIG
  4367                                  do_truename_config:
  4368 00001CC6 BA[0000]                	mov dx, configpath
  4369 00001CC9 E8BB16                  	call do_truename
  4370 00001CCC 893E[0000]              	mov word [configpath.dir_end], di
  4371                                  do_truename_scripts:
  4372 00001CD0 BA[0000]                	mov dx, scriptspath
  4373 00001CD3 E8B116                  	call do_truename
  4374 00001CD6 893E[0000]              	mov word [scriptspath.dir_end], di
  4375                                  %endif
  4376                                  
  4377                                  
  4378                                  init_determineprocessor:
  4379                                  d4	call init_d4message
  4380                                  d4	asciz "Determining processor type",13,10
  4381                                  
  4382 00001CDA B92101                  	mov cx, 0121h
  4383 00001CDD D2E5                    	shl ch, cl
  4384 00001CDF 7514                    	jnz .found_186_plus	; normal 186 masks shift count with 31 -->
  4385                                  
  4386                                  		; To make it easier to trace past the long-form pop cx
  4387                                  		;  instruction, we now run it in a subfunction.
  4388 00001CE1 E80500                  	call .detect_nec
  4389 00001CE4 E30F                    	jcxz .found_186_plus	; if it was a nop -->
  4390 00001CE6 E9F700                  	jmp .cpudone		; is an actual 8088/8086 -->
  4391                                  
  4392                                  
  4393                                  		; INP:	-
  4394                                  		; OUR:	cx = 0 if NEC V20 or NEC V30
  4395                                  		;	cx = 1 else
  4396                                  		; CHG:	ax, cx
  4397                                  .detect_nec:
  4398                                  		; The NEC V20/V30 processors do support the 186 extensions
  4399                                  		;  to the instruction set but do not mask the shift count.
  4400                                  		;  Therefore, specifically detect them here. Based on the
  4401                                  		;  text in http://www.textfiles.com/hamradio/v20_bug.txt
  4402 00001CE9 89E0                    	mov ax, sp
  4403 00001CEB B90100                  	mov cx, 1		; = 1 if on actual 8088/8086
  4404 00001CEE 51                      	push cx
  4405 00001CEF 49                      	dec cx			; = 0 if on NEC V20/V30
  4406                                  
  4407                                  		; NB: Do *NOT* trace this instruction with Trace Flag = 1 and
  4408                                  		;  do *NOT* write a breakpoint at the mov sp instruction,
  4409                                  		;  that is the very next instruction after the pop cx.
  4410                                  		; Doing either leads to locking up the HP 95LX, requiring to
  4411                                  		;  reset the system using Ctrl-Shift-On (which zeroes the
  4412                                  		;  system date and time).
  4413 00001CF0 8FC1                    	db 8Fh, 0C1h		; pop r/m16 with cx as operand
  4414                                  				;  (reportedly a nop on the NECs)
  4415 00001CF2 89C4                    	mov sp, ax		; reset stack to known state
  4416 00001CF4 C3                      	retn
  4417                                  
  4418                                  .found_186_plus:
  4419                                  d4	call init_d4message
  4420                                  d4	asciz "Found 186+ processor",13,10
  4421 00001CF5 FE06[0000]              	inc byte [ machine ]	; 1
  4422 00001CF9 54                      	push sp
  4423 00001CFA 58                      	pop ax
  4424 00001CFB 39E0                    	cmp ax, sp
  4425 00001CFD 7403E9DE00              	jne .cpudone		; 80186 pushes the adjusted value of sp -->
  4426                                  
  4427                                  d4	call init_d4message
  4428                                  d4	asciz "Found 286+ processor",13,10
  4429                                  		; Determine the processor type.  This is adapted from code in the
  4430                                  		; Pentium<tm> Family User's Manual, Volume 3:  Architecture and
  4431                                  		; Programming Manual, Intel Corp., 1994, Chapter 5.  That code contains
  4432                                  		; the following comment:
  4433                                  		;
  4434                                  		; This program has been developed by Intel Corporation.
  4435                                  		; Software developers have Intel's permission to incorporate
  4436                                  		; this source code into your software royalty free.
  4437                                  		;
  4438                                  		; Intel 286 CPU check.
  4439                                  		; Bits 12-15 of the flags register are always clear on the
  4440                                  		; 286 processor in real-address mode.
  4441                                  		; Bits 12-15 of the FLAGS register are always set on the
  4442                                  		; 8086 and 186 processor.
  4443 00001D02 FE06[0000]              	inc byte [ machine ]	; 2
  4444 00001D06 9C                      	 pushf			; save IF
  4445 00001D07 9C                      	pushf			; get original flags into ax
  4446 00001D08 58                      	pop ax
  4447 00001D09 0D00F0                  	or ax, 0F000h		; try to set bits 12-15
  4448 00001D0C 25FFFD                  	and ax, ~0200h		; clear IF
  4449 00001D0F 50                      	push ax			; save new flags value on stack
  4450 00001D10 9D                      	popf			; replace current flags value; DI
  4451 00001D11 9C                      	pushf			; get new flags
  4452 00001D12 58                      	pop ax			; store new flags in ax
  4453 00001D13 9D                      	 popf			; restore IF (in 86 Mode)
  4454 00001D14 A900F0                  	test ax, 0F000h		; if bits 12-15 clear, CPU = 80286
  4455 00001D17 7503E9C400              	jz .cpudone		; if 80286 -->
  4456                                  
  4457                                  d4	call init_d4message
  4458                                  d4	asciz "Found 386+ processor",13,10
  4459                                  		; Intel 386 CPU check.
  4460                                  		; The AC bit, bit #18, is a new bit introduced in the EFLAGS
  4461                                  		; register on the Intel486 DX cpu to generate alignment faults.
  4462                                  		; This bit cannot be set on the Intel386 CPU.
  4463                                  		;
  4464                                  		; It is now safe to use 32-bit opcode/operands.
  4465                                  subcpu 386
  4466 00001D1C 800E[0100]80            	setopt [internalflags], has386
  4467 00001D21 FE06[0000]              	inc byte [ machine ]	; 3
  4468                                  
  4469                                  %if _DEVICE
  4470                                   %if _APPLICATION || _BOOTLDR
  4471 00001D25 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  4472 00001D2A 7440                    	jz @F
  4473                                   %endif
  4474                                  
  4475 00001D2C 8C26[0000]              	mov word [reg_fs], fs
  4476 00001D30 8C2E[0000]              	mov word [reg_gs], gs
  4477                                  %macro set_gpr_h 1
  4478                                  	push e %+ %1
  4479                                  	pop %1
  4480                                  	pop word [reg_e %+ %1 + 2]
  4481                                  %endmacro
  4482                                  	set_gpr_h ax
  4478 00001D34 6650                <1>  push e %+ %1
  4479 00001D36 58                  <1>  pop %1
  4480 00001D37 8F06[0200]          <1>  pop word [reg_e %+ %1 + 2]
  4483                                  	set_gpr_h bx
  4478 00001D3B 6653                <1>  push e %+ %1
  4479 00001D3D 5B                  <1>  pop %1
  4480 00001D3E 8F06[0200]          <1>  pop word [reg_e %+ %1 + 2]
  4484                                  	set_gpr_h cx
  4478 00001D42 6651                <1>  push e %+ %1
  4479 00001D44 59                  <1>  pop %1
  4480 00001D45 8F06[0200]          <1>  pop word [reg_e %+ %1 + 2]
  4485                                  	set_gpr_h dx
  4478 00001D49 6652                <1>  push e %+ %1
  4479 00001D4B 5A                  <1>  pop %1
  4480 00001D4C 8F06[0200]          <1>  pop word [reg_e %+ %1 + 2]
  4486                                  	set_gpr_h bp
  4478 00001D50 6655                <1>  push e %+ %1
  4479 00001D52 5D                  <1>  pop %1
  4480 00001D53 8F06[0200]          <1>  pop word [reg_e %+ %1 + 2]
  4487                                  	set_gpr_h si
  4478 00001D57 6656                <1>  push e %+ %1
  4479 00001D59 5E                  <1>  pop %1
  4480 00001D5A 8F06[0200]          <1>  pop word [reg_e %+ %1 + 2]
  4488                                  	set_gpr_h di
  4478 00001D5E 6657                <1>  push e %+ %1
  4479 00001D60 5F                  <1>  pop %1
  4480 00001D61 8F06[0200]          <1>  pop word [reg_e %+ %1 + 2]
  4489                                  		; esph and eiph remain zero
  4490 00001D65 669C                    	pushfd
  4491 00001D67 9D                      	popfw
  4492 00001D68 8F06[0200]              	pop word [reg_efl + 2]
  4493                                  %endif
  4494                                  @@:
  4495                                  
  4496 00001D6C 89E3                    	mov bx, sp		; save current stack pointer to align
  4497 00001D6E 83E4FC                  	and sp, ~3		; align stack to avoid AC fault
  4498 00001D71 669C                    	pushfd			; push original EFLAGS
  4499 00001D73 6658                    	pop eax			; get original EFLAGS
  4500 00001D75 6689C1                  	mov ecx, eax		; save original EFLAGS in ECX (including IF)
  4501                                  
  4502 00001D78 663500000400            	xor eax, 40000h		; flip AC bit in EFLAGS
  4503 00001D7E 25FFFD                  	and ax, ~0200h		; clear IF
  4504 00001D81 6650                    	push eax		; put new EFLAGS value on stack
  4505 00001D83 669D                    	popfd			; replace EFLAGS value; DI
  4506 00001D85 669C                    	pushfd			; get new EFLAGS
  4507 00001D87 6658                    	pop eax			; store new EFLAGS value in EAX
  4508 00001D89 89C8                    	mov ax, cx		; ignore low bits (including IF)
  4509 00001D8B 6639C8                  	cmp eax, ecx
  4510 00001D8E 741A                    	je .cpudone_stack_eax_equals_ecx	; if 80386 -->
  4511                                  
  4512                                  d4	call init_d4message
  4513                                  d4	asciz "Found 486+ processor",13,10
  4514                                  		; Intel486 DX CPU, Intel487 SX NDP, and Intel486 SX CPU check.
  4515                                  		; Checking for ability to set/clear ID flag (bit 21) in EFLAGS
  4516                                  		; which indicates the presence of a processor with the ability
  4517                                  		; to use the CPUID instruction.
  4518 00001D90 FE06[0000]              	inc byte [ machine ]	; 4
  4519 00001D94 6689C8                  	mov eax, ecx		; get original EFLAGS
  4520 00001D97 663500002000            	xor eax, 200000h	; flip ID bit in EFLAGS
  4521 00001D9D 25FFFD                  	and ax, ~0200h		; clear IF
  4522 00001DA0 6650                    	push eax		; save new EFLAGS value on stack
  4523 00001DA2 669D                    	popfd			; replace current EFLAGS value; DI
  4524 00001DA4 669C                    	pushfd			; get new EFLAGS
  4525 00001DA6 6658                    	pop eax			; store new EFLAGS in EAX
  4526 00001DA8 89C8                    	mov ax, cx		; ignore low bits (including IF)
  4527                                  
  4528                                  .cpudone_stack_eax_equals_ecx:
  4529 00001DAA 6651                    	push ecx
  4530 00001DAC 669D                    	popfd			; restore AC,ID bits and IF in EFLAGS (86 Mode)
  4531 00001DAE 89DC                    	mov sp, bx		; restore sp
  4532                                  
  4533 00001DB0 6639C8                  	cmp eax, ecx		; check if it's changed
  4534 00001DB3 742B                    	je .cpudone		; if it's a 486 (can't toggle ID bit) -->
  4535                                  
  4536                                  d4	call init_d4message
  4537                                  d4	asciz "Found processor with CPUID support",13,10
  4538                                  		; Execute CPUID instruction.
  4539                                  subcpu 486		; NASM (at least 2.10rc1) handles cpuid itself as a
  4540                                  			;  586+ instruction, but we know better. So this
  4541                                  			;  part is declared for 486 compatibility, and only
  4542                                  			;  the cpuid instructions are emitted with 586
  4543                                  			;  compatibility to appease NASM.
  4544                                  %if 0
  4545                                  d4	call init_d4message
  4546                                  d4	asciz "CPUID will NOT be executed, to work around official DOSBox releases",13,10
  4547                                  d4	jmp .cpudone
  4548                                  %endif
  4549 00001DB5 6631C0                  	xor eax, eax		; set up input for CPUID instruction
  4550                                  d4	call init_d4message
  4551                                  d4	asciz "Executing CPUID 0",13,10
  4552                                  	  [cpu 586]
  4553 00001DB8 0FA2                    	 cpuid
  4554                                  	  __CPU__
  4555                                  d4	call init_d4message
  4556                                  d4	asciz "CPUID 0 executed",13,10
  4557 00001DBA 6683F801                	cmp eax, byte 1
  4558 00001DBE 7220                    	jb .cpudone		; if 1 is not a valid input value for CPUID
  4559 00001DC0 6631C0                  	xor eax, eax		; otherwise, run CPUID with eax = 1
  4560 00001DC3 6640                    	inc eax
  4561                                  d4	call init_d4message
  4562                                  d4	asciz "Executing CPUID 1",13,10
  4563                                  	  [cpu 586]
  4564 00001DC5 0FA2                    	 cpuid
  4565                                  	  __CPU__
  4566                                  d4	call init_d4message
  4567                                  d4	asciz "CPUID 1 executed",13,10
  4568                                  %if _MMXSUPP
  4569 00001DC7 66F7C200008000          	test edx, 80_0000h
  4570 00001DCE 0F9506[0000]            	setnz byte [has_mmx]
  4571                                  %endif
  4572                                  
  4573 00001DD3 88E0                    	mov al, ah
  4574 00001DD5 240F                    	and al, 0Fh		; bits 8..11 are the model number
  4575 00001DD7 3C06                    	cmp al, 6
  4576 00001DD9 7202                    	jb .below686		; if < 6
  4577 00001DDB B006                    	mov al, 6		; if >= 6, set it to 6
  4578                                  .below686:
  4579 00001DDD A2[0000]                	mov byte [ machine ], al; save machine type (486, 586, 686+)
  4580                                  
  4581                                  .cpudone:
  4582                                  subcpureset			; subcpu 486
  4583                                  subcpureset			; subcpu 386
  4584                                  d4	call init_d4message
  4585                                  d4	asciz "Determining floating-point unit",13,10
  4586                                  
  4587                                  		; Next determine the type of FPU in a system and set the mach_87
  4588                                  		; variable with the appropriate value.  All registers are used by
  4589                                  		; this code; none are preserved.
  4590                                  		;
  4591                                  		; Coprocessor check.
  4592                                  		; The algorithm is to determine whether the floating-point
  4593                                  		; status and control words can be written to.  If not, no
  4594                                  		; coprocessor exists.  If the status and control words can be
  4595                                  		; written to, the correct coprocessor is then determined
  4596                                  		; depending on the processor ID.  The Intel 386 CPU can
  4597                                  		; work with either an Intel 287 NDP or an Intel 387 NDP.
  4598                                  		; The infinity of the coprocessor must be checked
  4599                                  		; to determine the correct coprocessor ID.
  4600 00001DE0 A0[0000]                	mov al, byte [ machine ]
  4601 00001DE3 A2[0000]                	mov byte [ mach_87 ], al	; by default, set mach_87 to machine
  4602 00001DE6 FE06[0000]              	inc byte [ has_87 ]
  4603 00001DEA C606[0000]0C            	mov byte [encodedmach87], 0Ch
  4604 00001DEF 3C05                    	cmp al, 5			; a Pentium or above always will have a FPU
  4605 00001DF1 7350                    	jae .fpudone
  4606 00001DF3 FE0E[0000]              	dec byte [ has_87 ]		; assume no FPU
  4607 00001DF7 C606[0000]C0            	mov byte [encodedmach87], 0C0h
  4608                                  
  4609 00001DFC DBE3                    	fninit				; reset FPU
  4610 00001DFE B0FF                    	mov al, -1			; initialise with a non-zero value
  4611 00001E00 50                      	push ax
  4612 00001E01 89E3                    	mov bx, sp
  4613 00001E03 36DD3F                  	fnstsw word [ss:bx]		; save FP status word
  4614 00001E06 58                      	pop ax				; retrieve it
  4615 00001E07 84C0                    	test al, al
  4616 00001E09 7538                    	jnz .fpudone			; if no FPU present
  4617                                  
  4618                                  		; al = 0 here
  4619 00001E0B 50                      	push ax
  4620 00001E0C 36D93F                  	fnstcw word [ss:bx]		; save FP control word
  4621 00001E0F 58                      	pop ax				; retrieve it
  4622 00001E10 253F10                  	and ax, 103Fh			; see if selected parts look OK
  4623 00001E13 83F83F                  	cmp ax, byte 3Fh
  4624 00001E16 752B                    	jne .fpudone			; if no FPU present
  4625 00001E18 FE06[0000]              	inc byte [ has_87 ]		; there's an FPU
  4626 00001E1C C606[0000]0C            	mov byte [encodedmach87], 0Ch
  4627                                  
  4628                                  		; If we're using a 386, check for 287 vs. 387 by checking whether
  4629                                  		; +infinity = -infinity.
  4630 00001E21 803E[0000]03            	cmp byte [ machine ], 3
  4631 00001E26 751B                    	jne .fpudone			; if not a 386
  4632                                  [cpu 386]
  4633 00001E28 D9E8                    	fld1				; must use default control from FNINIT
  4634 00001E2A D9EE                    	fldz				; form infinity
  4635 00001E2C DEF9                    	fdivp ST1			; 1 / 0 = infinity
  4636 00001E2E D9C0                    	fld ST0
  4637 00001E30 D9E0                    	fchs				; form negative infinity
  4638 00001E32 DED9                    	fcompp				; see if they are the same and remove them
  4639 00001E34 9BDFE0                  	fstsw ax
  4640 00001E37 9E                      	sahf				; look at status from FCOMPP
  4641 00001E38 7509                    	jne .fpudone			; if they are different, then it's a 387
  4642 00001E3A FE0E[0000]              	dec byte [ mach_87 ]		; otherwise, it's a 287
  4643 00001E3E C606[0000]C2            	mov byte [encodedmach87], 0C2h
  4644                                  __CPU__
  4645                                  .fpudone:
  4646                                  
  4647                                  apply_patches:
  4648                                  %if _ONLY386
  4649                                  	testopt [internalflags], has386
  4650                                  	jnz @F				; okay -->
  4651                                  
  4652                                   %if _BOOTLDR && (_APPLICATION || _DEVICE)
  4653                                  	testopt [internalflags], nodosloaded
  4654                                  	lahf				; remember status
  4655                                   %endif
  4656                                  	mov dx, imsg.no386
  4657                                  	call init_putsz_cs		; display the error
  4658                                   %if _BOOTLDR && (_APPLICATION || _DEVICE)
  4659                                  	sahf
  4660                                  	jnz init_booterror.soft		; abort for loader -->
  4661                                   %elif _BOOTLDR
  4662                                  	jmp init_booterror.soft
  4663                                   %endif
  4664                                  %if _DEVICE && _APPLICATION
  4665                                  	testopt [internalflags6], dif6_device_mode
  4666                                  	jnz init_device_error_late
  4667                                  %elif _DEVICE
  4668                                  	jmp init_device_error_late
  4669                                  %endif
  4670                                  %if _APPLICATION
  4671                                  	mov ax, 4C01h
  4672                                  	int 21h				; abort our process
  4673                                  %endif
  4674                                  
  4675                                  @@:
  4676                                  %elif _ONLYNON386
  4677                                  	testopt [internalflags], has386
  4678                                  	jz @F				; okay -->
  4679                                  	mov dx, imsg.386
  4680                                  	call init_putsz_cs		; display the warning
  4681                                  @@:
  4682                                  %endif
  4683                                  
  4684                                  		; Determine which patch table to use, then patch
  4685                                  		; out either the 386+ or non-386 code as appropriate.
  4686 00001E43 8E06[0000]              	mov es, [code_seg]
  4687 00001E47 F606[0100]80            	testopt [internalflags], has386
  4688 00001E4C 740B                    	jz @F
  4689 00001E4E BE[0000]                	mov si, patch_386_table		; table of patches to set for 386+
  4690                                  %if __patch_386_table_method == 1
  4691 00001E51 B9[0000]                	mov cx, patch_386_table.amount
  4692 00001E54 E81C00                  	call .patch1
  4693                                  %else
  4694                                  	call .patch2
  4695                                  %endif
  4696 00001E57 EB26                    	jmp .patch_code1_end
  4697                                  
  4698                                  @@:
  4699                                  %ifn _ONLYNON386
  4700                                  
  4701                                  %if _RUN2_ENTRY_SECTION
  4702 00001E59 C606[0000]3E            	mov byte [..@patch_no386_ds_code_or_entry], 3Eh
  4703                                  					; write a ds prefix
  4704 00001E5E C606[0000]CF            	mov byte [..@patch_no386_iret_code_or_entry], 0CFh
  4705                                  					; write an iret instruction
  4706                                  %else
  4707                                  	mov byte [es:..@patch_no386_ds_code_or_entry], 3Eh
  4708                                  					; write a ds prefix
  4709                                  	mov byte [es:..@patch_no386_iret_code_or_entry], 0CFh
  4710                                  					; write an iret instruction
  4711                                  %endif
  4712                                   %if _PM && _CATCHPMINT214C
  4713                                  	mov byte [..@patch_no386_ds_entry_pmint21_1], 3Eh
  4714                                  	mov byte [..@patch_no386_ds_entry_pmint21_2], 3Eh
  4715                                  					; write ds prefixes (note the segment!)
  4716                                   %endif
  4717                                   %if _PM
  4718                                  	mov byte [es:..@patch_no386_ds_4], 3Eh
  4719                                  	mov byte [es:..@patch_no386_ds_5], 3Eh	; write some more ds prefixes
  4720                                   %endif
  4721                                   %if _CATCHINT07 || _CATCHINT0C || _CATCHINT0D
  4722 00001E63 C606[0000]3E            	mov byte [..@patch_no386_ds_6_DATA_ENTRY], 3Eh
  4723                                  					; write a ds prefix (note the segment!)
  4724                                   %endif
  4725                                  %endif
  4726 00001E68 BE[0000]                	mov si, patch_no386_table	; table of patches to set for 16-bit CPU
  4727                                  %if __patch_no386_table_method == 1
  4728 00001E6B B9[0000]                	mov cx, patch_no386_table.amount
  4729 00001E6E E80200                  	call .patch1
  4730                                  %else
  4731                                  	call .patch2
  4732                                  %endif
  4733 00001E71 EB0C                    	jmp .patch_code1_end
  4734                                  
  4735                                  		; Complicated table patch code.
  4736                                  %if __patch_no386_table_method == 2 || __patch_386_table_method == 2 	|| __patch_no386_table2_method == 2 || __patch_386_table2_method == 2 	|| __patch_no386_tableentry_method == 2 || __patch_386_tableentry_method == 2
  4739                                  .patch2:
  4740                                  	mov di, code_start		; initialise offset
  4741                                  	xor ax, ax			; initialise ah
  4742                                  .looppatch2:
  4743                                  	cs lodsb
  4744                                  	add di, ax			; skip number of bytes to skip
  4745                                  	cmp al, 255			; really repositioning?
  4746                                  	jne .l2patch			; no -->
  4747                                  	xchg ax, di			; (to preserve ah)
  4748                                  	cs lodsw			; ax = new address
  4749                                  	xchg ax, di			; di = new address
  4750                                  .l2patch:
  4751                                  	cs lodsb
  4752                                  	mov cx, ax			; cx = number of bytes to patch
  4753                                  	jcxz .patchesdone		; end of table -->
  4754                                  	mov al, 90h			; patch to NOP
  4755                                  	rep stosb			; patch as many bytes as specified
  4756                                  	jmp short .looppatch2
  4757                                  %endif
  4758                                  
  4759                                  		; Simple table patch code.
  4760                                  %if __patch_no386_table_method == 1 || __patch_386_table_method == 1 	|| __patch_no386_table2_method == 1 || __patch_386_table2_method == 1 	|| __patch_no386_tableentry_method == 1 || __patch_386_tableentry_method == 1
  4763                                  .patch1:
  4764 00001E73 E309                    	jcxz .patchesdone
  4765                                  .looppatch1:
  4766 00001E75 2EAD                    	cs lodsw			; load address of patch
  4767 00001E77 93                      	xchg bx, ax			; (set bx = ax, CHG ax)
  4768 00001E78 26C60790                	mov byte [es:bx], 90h		; patch
  4769 00001E7C E2F7                    	loop .looppatch1
  4770                                  %endif
  4771                                  .patchesdone:
  4772 00001E7E C3                      	retn
  4773                                  
  4774                                  .patch_code1_end:
  4775                                  
  4776                                  %if _DUALCODE
  4777                                  	mov dx, es			; dx => code1 seg
  4778                                  %endif
  4779                                   %if _BOOTLDR_DISCARD
  4780 00001E7F F606[0100]40            	testopt [internalflags], nodosloaded
  4781 00001E84 7500                    	jnz @F
  4782                                  
  4783                                    %if _AREAS && _AREAS_HOOK_CLIENT
  4784                                     %ifn _LINK
  4785                                  	mov ax, ldebug_code_bootldr_truncated_size
  4786                                     %else
  4787                                  	mov ax, behind_code_truncated wrt lDEBUG_CODE
  4788                                   wlcalc word_add_15, equ $ - 2
  4789                                   wlcalc word_clr_15, equ $ - 2
  4790                                     %endif
  4791                                  	mov word [areas_sub + areastrucfunLinearEnd], ax
  4792                                  	mov word [areas_fun + areastrucfunLinearEnd], ax
  4793                                    %endif
  4794                                   %endif
  4795                                  %ifn _DUALCODE
  4796                                  @@:					; if bootloaded
  4797                                  %else
  4798                                   %if _BOOTLDR_DISCARD
  4799                                    %ifn _LINK
  4800                                  	add dx, ldebug_code_bootldr_truncated_size_p
  4801                                    %else
  4802                                  	add dx, strict word relocatedzero + 0
  4803                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code_truncated, equ $ - 2
  4804                                    %endif
  4805                                  					; if not bootloaded, use truncated
  4806                                  	jmp @FF
  4807                                  @@:					; if bootloaded
  4808                                   %endif
  4809                                    %ifn _LINK
  4810                                  	add dx, ldebug_code_size_p	; use untruncated
  4811                                    %else
  4812                                  	add dx, strict word relocatedzero + 0
  4813                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code, equ $ - 2
  4814                                    %endif
  4815                                  @@:
  4816                                  	mov word [code2_seg], dx
  4817                                  patch_relocate:
  4818                                  
  4819                                   %if ! _PM
  4820                                  	mov si, relocate_from_code
  4821                                  	mov di, relocate_from_code.end
  4822                                  	call .patch
  4823                                  	mov si, relocate_from_code2
  4824                                  	mov di, relocate_from_code2.end
  4825                                   %endif
  4826                                  	push es
  4827                                  	mov es, dx
  4828                                  	pop dx
  4829                                   %if ! _PM
  4830                                  	call .patch
  4831                                  	jmp .done
  4832                                  
  4833                                  .loop:
  4834                                  	cs lodsw
  4835                                  	xchg bx, ax
  4836                                  	mov word [es:bx], dx
  4837                                  .patch:
  4838                                  	cmp si, di
  4839                                  	jb .loop
  4840                                  	retn
  4841                                  
  4842                                  .done:
  4843                                   %endif
  4844                                  
  4845                                  	testopt [internalflags], has386
  4846                                  	jz @F
  4847                                  	mov si, patch_386_table2	; table of patches to set for 386+
  4848                                  %if __patch_386_table2_method == 1
  4849                                  	mov cx, patch_386_table2.amount
  4850                                  	call apply_patches.patch1
  4851                                  %else
  4852                                  	call apply_patches.patch2
  4853                                  %endif
  4854                                  	jmp .patch_code2_end
  4855                                  
  4856                                  @@:
  4857                                  	mov si, patch_no386_table2	; table of patches to set for 16-bit CPU
  4858                                  %if __patch_no386_table2_method == 1
  4859                                  	mov cx, patch_no386_table2.amount
  4860                                  	call apply_patches.patch1
  4861                                  %else
  4862                                  	call apply_patches.patch2
  4863                                  %endif
  4864                                  .patch_code2_end:
  4865                                  %endif
  4866                                  
  4867                                  
  4868                                  patch_entry:
  4869                                  	numdef EMIT_ENTRY_PATCH, _LINK || _LINK_COMPAT
  4870                                  %ifn _EMIT_ENTRY_PATCH
  4871                                   %if patch_386_tableentry_size != 0 || patch_no386_tableentry_size != 0
  4872                                    %assign _EMIT_ENTRY_PATCH 1
  4873                                   %endif
  4874                                  %endif
  4875                                  %if _EMIT_ENTRY_PATCH
  4876 00001E86 1E                      	push ds
  4877 00001E87 07                      	pop es
  4878 00001E88 F606[0100]80            	testopt [internalflags], has386
  4879 00001E8D 740B                    	jz @F
  4880 00001E8F BE[0000]                	mov si, patch_386_tableentry	; table of patches to set for 386+
  4881                                  %if __patch_386_tableentry_method == 1
  4882 00001E92 B9[0000]                	mov cx, patch_386_tableentry.amount
  4883 00001E95 E8DBFF                  	call apply_patches.patch1
  4884                                  %else
  4885                                  	call apply_patches.patch2
  4886                                  %endif
  4887 00001E98 EB09                    	jmp .patch_entry_end
  4888                                  
  4889                                  @@:
  4890 00001E9A BE[0000]                	mov si, patch_no386_tableentry	; table of patches to set for 16-bit CPU
  4891                                  %if __patch_no386_tableentry_method == 1
  4892 00001E9D B9[0000]                	mov cx, patch_no386_tableentry.amount
  4893 00001EA0 E8D0FF                  	call apply_patches.patch1
  4894                                  %else
  4895                                  	call apply_patches.patch2
  4896                                  %endif
  4897                                  .patch_entry_end:
  4898                                  %endif
  4899                                  
  4900                                  
  4901                                  %if _DEVICE
  4902                                  		; This must be done after CPU detection
  4903                                  		;  because we want to get the high parts
  4904                                  		;  of the registers only initialised here.
  4905 00001EA3 1E                      	push ds
  4906 00001EA4 07                      	pop es
  4907 00001EA5 BE[0000]                	mov si, regs
  4908 00001EA8 BF[0000]                	mov di, device_quittable_regs
  4909                                   %ifn _LINK
  4910                                  	mov cx, words(regs.size)
  4911                                   %else
  4912 00001EAB B9[0100]                	mov cx, regs.size + 1
  4913                                   wlcalc word_shr_1, equ $ - 2
  4914                                   %endif
  4915 00001EAE F3A5                    	rep movsw
  4916                                  %endif
  4917                                  
  4918                                  
  4919                                  		; Check for dosemu. This is done for the boot loaded instance
  4920                                  		; too, as we might be running as DOS inside dosemu.
  4921                                  %if _DOSEMU
  4922 00001EB0 B800F0                  	mov ax, 0F000h
  4923 00001EB3 8EC0                    	mov es, ax
  4924 00001EB5 1E                      	push ds
  4925 00001EB6 0E                      	 push cs
  4926 00001EB7 1F                      	 pop ds			; avoid "repe cs cmpsw" (8086 bug)
  4927 00001EB8 BFF5FF                  	mov di, 0FFF5h
  4928 00001EBB BE[7419]                	mov si, imsg.dosemudate
  4929 00001EBE B90400                  	mov cx, 4
  4930 00001EC1 F3A7                    	repe cmpsw		; running in DosEmu?
  4931 00001EC3 1F                      	pop ds
  4932 00001EC4 750A                    	jne .dosemuchecked
  4933 00001EC6 800E[0300]01            	setopt [internalflags], runningdosemu
  4934                                   %if _DOSEMU_PRESTROKES_HELP
  4935 00001ECB B80900                  	mov ax, 0009h
  4936 00001ECE CDE6                    	int 0E6h		; run dosemu2 start_pre_strokes function
  4937                                  ; dosemu2 recently gained a feature that tries to avoid
  4938                                  ;  a kernel from eating the first text byte of an -input
  4939                                  ;  string. However, this interferes with our use because
  4940                                  ;  the strokes are only enabled in dos_post_boot (int.c).
  4941                                  ; There is a new int 0E6h helper function now to enable
  4942                                  ;  the strokes right away, which is made for lDebug to work
  4943                                  ;  when the debugger is booted and wants the input. This
  4944                                  ;  is called DOS_HELPER_PRESTROKES_START (also int.c).
  4945                                  ; Reference: https://github.com/dosemu2/dosemu2/issues/2071
  4946                                   %endif
  4947                                  .dosemuchecked:
  4948                                  %endif
  4949                                  
  4950 00001ED0 1E                      	push ds
  4951 00001ED1 07                      	pop es			; => lDEBUG_DATA_ENTRY
  4952                                  
  4953 00001ED2 BF[0000]                	mov di, line_in
  4954 00001ED5 B0FF                    	mov al, 255
  4955 00001ED7 AA                      	stosb
  4956 00001ED8 B000                    	mov al, 0
  4957 00001EDA AA                      	stosb
  4958 00001EDB B00D                    	mov al, 13
  4959 00001EDD AA                      	stosb				; overwrite line_in beginning
  4960                                  
  4961 00001EDE BC[0000]                	mov sp, stack_end		; stack pointer (paragraph aligned)
  4962 00001EE1 BF[0000]                	mov di, ..@init_first
  4963                                  %ifn _LINK
  4964                                  	mov cx, ..@init_behind - ..@init_first
  4965                                  %else
  4966 00001EE4 B9[0000]                	mov cx, ..@init_behind
  4967                                   wlcalc word_minusext_..@init_first, equ $ - 2
  4968                                  %endif
  4969 00001EE7 31C0                    	xor ax, ax
  4970 00001EE9 F3AA                    	rep stosb			; initialise breakpoint lists, line_out
  4971                                  %if 1
  4972                                  ..@init_behind_equate equ ..@init_behind
  4973                                  stack_equate equ stack
  4974                                  %if ..@init_behind_equate != stack_equate
  4975 00001EEB BF[0000]                	mov di, stack
  4976                                  %endif
  4977                                  %ifn _LINK
  4978                                  	mov cx, stack_end - stack
  4979                                  %else
  4980 00001EEE B9[0000]                	mov cx, stack_end
  4981                                   wlcalc word_minusext_stack, equ $ - 2
  4982                                  %endif
  4983 00001EF1 B05E                    	mov al, 5Eh
  4984 00001EF3 F3AA                    	rep stosb			; initialise the stack
  4985                                  %endif
  4986                                  
  4987 00001EF5 C606[0000]30            	mov byte [ trim_overflow ], '0'	; initialise line_out so the trimputs loop doesn't overflow
  4988 00001EFA C706[0000]4226          	mov word [line_out_overflow], 2642h
  4989                                  
  4990                                  
  4991                                  %if _AREAS_HOOK_SERVER
  4992                                  	mov ax, ds
  4993                                  	mov word [ddebugareas.next + 2], ax
  4994                                  	mov word [ddebugareas.prev + 2], ax
  4995                                  	mov word [..@patch_entry_seg], ax
  4996                                  %endif
  4997                                  
  4998                                  %if _AREAS && _AREAS_HOOK_CLIENT
  4999                                  	mov ax, word [code_seg]
  5000                                  	call add_to_areas_linear_code1
  5001                                  
  5002                                   %if _DUALCODE && _EXPRDUALCODE
  5003                                  	mov ax, word [code2_seg]
  5004                                  	call add_to_areas_linear_code2
  5005                                   %endif
  5006                                  %endif
  5007                                  
  5008                                  
  5009                                  %if _DEBUG && _DEBUG_COND && _DEBUG_COND_DEFAULT_ON
  5010                                  	setopt [internalflags6], dif6_debug_mode
  5011                                  	setopt [options6], opt6_debug_mode
  5012                                  	setopt [startoptions6], opt6_debug_mode
  5013                                  %endif
  5014                                  
  5015                                  %if _CATCHINT06 && _DETECT95LX
  5016 00001F00 B8D44D                  	mov ax, 4DD4h
  5017 00001F03 31DB                    	xor bx, bx
  5018 00001F05 CD15                    	int 15h				; HP 95LX/100LX/200LX detect
  5019 00001F07 81FB5048                	cmp bx, 4850h			; "HP" reversed
  5020 00001F0B 7516                    	jne @F
  5021 00001F0D 81F90101                	cmp cx, 0101h			; 95LX ?
  5022 00001F11 7510                    	jne @F				; no -->
  5023                                  
  5024                                   %if _CATCHINT2D
  5025 00001F13 A1[0100]                	mov ax, word [inttab.i2D + 1]
  5026 00001F16 A3[0100]                	mov word [inttab.i06 + 1], ax	; overwrite i06 entry with i2D
  5027 00001F19 A0[0000]                	mov al, byte [inttab.i2D]
  5028 00001F1C A2[0000]                	mov byte [inttab.i06], al	; interrupt number too
  5029                                   %endif
  5030 00001F1F FF0E[0000]              	dec word [inttab_number_variable]	; remember one less in use
  5031                                  @@:
  5032                                  %endif
  5033                                  
  5034 00001F23 B40F                    	mov ah, 0Fh
  5035 00001F25 CD10                    	int 10h
  5036 00001F27 883E[0000]              	mov byte [vpage], bh
  5037                                  
  5038                                  
  5039                                  %if _BOOTLDR
  5040                                   %if _APPLICATION || _DEVICE
  5041 00001F2B F606[0100]40            	testopt [internalflags], nodosloaded
  5042 00001F30 7427                    	jz initdos
  5043                                   %endif
  5044                                  d4	call init_d4message
  5045                                  d4	asciz "386-related patches applied, boot initialisation proceeding",13,10
  5046                                  
  5047                                  
  5048                                  %if CATCHINTAMOUNT
  5049                                  		; Set up interrupt vectors.
  5050                                  
  5051                                  		; ds still => lDEBUG_DATA_ENTRY
  5052                                  %if _CATCHINT06 && _DETECT95LX
  5053 00001F32 8B0E[0000]              	mov cx, word [inttab_number_variable]
  5054                                  %else
  5055                                  	mov cx, inttab_number
  5056                                  %endif
  5057 00001F36 E315                    	jcxz .bootintend
  5058 00001F38 BE[0000]                	mov si, inttab
  5059                                  .bootintloop:
  5060                                  
  5061                                  		; assumes ss = lDEBUG_DATA_ENTRY
  5062 00001F3B 36AC                    	ss lodsb
  5063 00001F3D 31DB                    	xor bx, bx
  5064 00001F3F 8EDB                    	mov ds, bx
  5065 00001F41 88C3                    	mov bl, al
  5066 00001F43 01DB                    	add bx, bx
  5067 00001F45 01DB                    	add bx, bx
  5068 00001F47 97                      	xchg ax, di
  5069 00001F48 36AD                    	ss lodsw		; get address of IISP header
  5070 00001F4A 97                      	xchg ax, di
  5071                                  %if _DEBUG && !_DEBUG_COND
  5072                                  				; vectors are set only when debuggee runs
  5073                                  %else
  5074                                   %if _DEBUG
  5075                                  	testopt [ss:internalflags6], dif6_debug_mode
  5076                                  	jnz @F
  5077                                   %endif
  5078                                  	push word [ bx+2 ]
  5079                                  	push word [ bx ]	; get vector
  5080                                  	pop word [ ss:di + ieNext ]
  5081                                  	pop word [ ss:di + ieNext + 2 ]
  5082                                  				; store it
  5083                                  	mov word [ bx+2 ], ss
  5084                                  	mov word [ bx ], di	; set interrupt vector
  5085                                  @@:
  5086                                  %endif
  5087 00001F4B E2EE                    	loop .bootintloop
  5088                                  
  5089                                  .bootintend:
  5090                                  %endif
  5091                                  
  5092                                  %if _EXTENSIONS
  5093                                  init_eld_boot:
  5094 00001F4D E86B14                  	call init_eld
  5095                                  %else
  5096                                  	push ss
  5097                                  	pop ds
  5098                                  	push ss
  5099                                  	pop es
  5100                                  %endif
  5101                                  
  5102                                  d4	call init_d4message
  5103                                  d4	asciz "Jumping to final boot initialisation code",13,10
  5104 00001F50 BE[0000]                	mov si, initcont.boot_entry
  5105 00001F53 FF36[0000]              	push word [code_seg]
  5106 00001F57 56                      	push si
  5107 00001F58 CB                      	retf
  5108                                  %endif
  5109                                  
  5110                                  %if _APPLICATION || _DEVICE
  5111                                  initdos:
  5112                                  %if _MCB || _INT || _EXTENSIONS
  5113 00001F59 B80258                  	mov ax, 5802h
  5114 00001F5C CD21                    	int 21h
  5115 00001F5E 30E4                    	xor ah, ah		; some "DOS" only return al
  5116 00001F60 50                      	push ax			; save UMB link
  5117                                  
  5118                                  getfirstmcb:
  5119 00001F61 B452                    	mov ah, 52h		; get list of lists
  5120 00001F63 BBFFFF                  	mov bx, -1
  5121 00001F66 CD21                    	int 21h
  5122 00001F68 83FBFF                  	cmp bx, -1
  5123 00001F6B 7503E98800              	je mcb_not_found
  5124 00001F70 83FB01                  	cmp bx, 1
  5125 00001F73 7503E98000              	je mcb_not_found
  5126 00001F78 268B47FE                	mov ax, word [ es:bx-2 ]; start of MCBs
  5127 00001F7C A3[0000]                	mov word [firstmcb], ax
  5128                                  
  5129                                  getfirstumcb:
  5130 00001F7F 1E                      	push ds
  5131                                  			; We try to get the first UMCB for gateout
  5132                                  			;  for now. To harden our code it should
  5133                                  			;  not be assumed that the address is of
  5134                                  			;  a valid MCB. However, it is fine to
  5135                                  			;  compare an actual MCB address with it.
  5136                                    %if _GUARD_86M_INT2F
  5137 00001F80 06                      	push es
  5138 00001F81 31C0                    	xor ax, ax
  5139 00001F83 8EC0                    	mov es, ax		; (only used in 86 Mode)
  5140 00001F85 26A1BC00                	mov ax, [es:2Fh * 4]
  5141 00001F89 83F8FF                  	cmp ax, -1
  5142 00001F8C 7405                    	je @F			; --> (ZR)
  5143 00001F8E 260B06BE00              	or ax, [es:2Fh * 4 + 2]
  5144                                  @@:
  5145 00001F93 07                      	pop es
  5146 00001F94 7414                    	jz .determine
  5147                                    %endif
  5148 00001F96 B86112                  	mov ax, 1261h		; PTS-DOS: Get first UMCB
  5149 00001F99 F9                      	stc
  5150 00001F9A CD2F                    	int 2Fh
  5151 00001F9C 720C                    	jc .determine		; not supported -->
  5152 00001F9E 40                      	inc ax
  5153 00001F9F 83F802                  	cmp ax, byte 2		; -1, 0, 1 ?
  5154 00001FA2 7606                    	jbe .determine		; not supported (or none) -->
  5155 00001FA4 48                      	dec ax
  5156 00001FA5 A3[0000]                	mov word [ firstumcb ], ax	; set UMB
  5157 00001FA8 EB4D                    	jmp short .got		; got it -->
  5158                                  
  5159                                  .determine:
  5160 00001FAA B80358                  	mov ax, 5803h
  5161 00001FAD 31DB                    	xor bx, bx
  5162 00001FAF CD21                    	int 21h			; disable UMB link, leave only LMA chain
  5163 00001FB1 7244                    	jc .none		; that isn't supported either -->
  5164                                  
  5165 00001FB3 A1[0000]                	mov ax, word [firstmcb]
  5166 00001FB6 89C2                    	mov dx, ax		; first MCB
  5167 00001FB8 31DB                    	xor bx, bx		; use offsets from bx, not addresses
  5168                                  .looplmb:
  5169 00001FBA 8ED8                    	mov ds, ax
  5170 00001FBC 40                      	inc ax
  5171 00001FBD 034703                  	add ax, word [ bx + 3 ]	; next MCB's address
  5172 00001FC0 803F4D                  	cmp byte [ bx ], 'M'
  5173 00001FC3 74F5                    	je .looplmb		; not last -->
  5174 00001FC5 803F5A                  	cmp byte [ bx ], 'Z'
  5175 00001FC8 752D                    	jne .none		; corrupted -->
  5176 00001FCA 92                      	xchg ax, dx		; dx = what we assume to be the first UMA chain MCB
  5177                                  				; ax = first MCB
  5178                                  
  5179 00001FCB 50                      	push ax
  5180 00001FCC 43                      	inc bx			; = 1
  5181 00001FCD B80358                  	mov ax, 5803h
  5182 00001FD0 CD21                    	int 21h			; enable UMB link, include UMA chain
  5183 00001FD2 58                      	pop ax
  5184 00001FD3 7222                    	jc .none		; so we can disable it but not enable? -->
  5185                                  
  5186 00001FD5 4B                      	dec bx			; = 0
  5187 00001FD6 31C9                    	xor cx, cx		; flag if assumed first UMCB found
  5188                                  .loopumb:
  5189 00001FD8 39D0                    	cmp ax, dx
  5190 00001FDA 7501                    	jne .notlastlmb
  5191 00001FDC 41                      	inc cx			; there it is
  5192                                  .notlastlmb:
  5193 00001FDD 8ED8                    	mov ds, ax
  5194 00001FDF 803F4D                  	cmp byte [ bx ], 'M'
  5195 00001FE2 7506                    	jne .islastumb?		; last or corrupted -->
  5196 00001FE4 40                      	inc ax
  5197 00001FE5 034703                  	add ax, word [ bx + 3 ]
  5198 00001FE8 EBEE                    	jmp short .loopumb	; process next -->
  5199                                  .islastumb?:
  5200 00001FEA 803F5A                  	cmp byte [ bx ], 'Z'
  5201 00001FED 7508                    	jne .none		; corrupted -->
  5202 00001FEF E306                    	jcxz .none		; didn't find that UMCB -->
  5203                                  			; The MCB at dx which was behind the one that contained the 'Z'
  5204                                  			; signature when we disabled the UMB link is now a valid MCB in
  5205                                  			; the MCB chain after we enabled the UMB link. All previous MCBs
  5206                                  			; are now 'M'.
  5207 00001FF1 1F                      	pop ds
  5208 00001FF2 8916[0000]              	mov word [ firstumcb ], dx
  5209 00001FF6 A8                      	db __TEST_IMM8		; (skip pop)
  5210                                  .none:
  5211                                  .got:
  5212 00001FF7 1F                      	pop ds
  5213                                  mcb_not_found:
  5214 00001FF8 5B                      	pop bx
  5215 00001FF9 B80358                  	mov ax, 5803h
  5216 00001FFC CD21                    	int 21h			; restore UMB link
  5217                                  %endif
  5218                                  
  5219                                  getindosflag:
  5220 00001FFE B434                    	mov ah, 34h
  5221 00002000 CD21                    	int 21h
  5222 00002002 891E[0000]              	mov word [pInDOS + so16aOffset], bx
  5223 00002006 8C06[0200]              	mov word [pInDOS + so16aSegSel], es
  5224                                  %if _PM
  5225                                  	mov word [pInDOS + so16aSegment], es
  5226                                  %endif
  5227                                  
  5228                                  		; get address of DOS swappable DATA area
  5229                                  		; to be used to get/set PSP and thus avoid DOS calls
  5230                                  		; will not work for DOS < 3
  5231                                  %if _USESDA
  5232                                  getsda:
  5233 0000200A 1E                      	push ds
  5234 0000200B B8065D                  	mov ax, 5D06h
  5235 0000200E F9                      	stc				; initialise to CY
  5236 0000200F CD21                    	int 21h
  5237 00002011 8CD8                    	mov ax, ds
  5238 00002013 1F                      	pop ds
  5239 00002014 7215                    	jc .noSDA			; if CY returned, not supported -->
  5240 00002016 8EC0                    	mov es, ax			; es:si -> SDA
  5241                                   %if _DEVICE
  5242 00002018 50                      	push ax
  5243 00002019 B451                    	mov ah, 51h
  5244 0000201B CD21                    	int 21h				; bx = current PSP
  5245 0000201D 58                      	pop ax
  5246                                   %else
  5247                                  	mov bx, ds			; bx = our PSP (= current PSP in app mode)
  5248                                   %endif
  5249 0000201E 26395C10                	cmp word [es:si + 10h], bx	; does this seem like the current PSP field ?
  5250 00002022 7507                    	jne .noSDA			; no -->
  5251 00002024 8936[0000]              	mov word [pSDA + so16aOffset], si
  5252 00002028 A3[0200]                	mov word [pSDA + so16aSegSel], ax
  5253                                  %if _PM
  5254                                  	mov word [pSDA + so16aSegment], ax
  5255                                  %endif
  5256                                  .noSDA:
  5257                                  %endif
  5258                                  
  5259 0000202B B83135                  	mov ax, 3531h
  5260 0000202E CD21                    	int 21h
  5261 00002030 8CC3                    	mov bx, es
  5262                                  %if _USESDA
  5263 00002032 3B1E[0200]              	cmp bx, word [pSDA + so16aSegSel]
  5264 00002036 750B                    	jne @F
  5265                                  %endif
  5266 00002038 3B1E[0200]              	cmp bx, word [pInDOS + so16aSegSel]
  5267 0000203C 7505                    	jne @F
  5268                                  
  5269 0000203E 800E[0300]20            	setopt [internalflags2], dif2_int31_segment
  5270                                  @@:
  5271                                  
  5272                                  
  5273                                  commandline:
  5274 00002043 16                      	push ss
  5275 00002044 07                      	pop es
  5276                                  
  5277                                  %if _CONFIG
  5278                                  %if _APPLICATION
  5279 00002045 BE[AA16]                	mov si, imsg.default_cmdline.app
  5280 00002048 B93400                  	mov cx, words(imsg.default_cmdline.app.length)
  5281                                  %endif
  5282                                  %if _DEVICE
  5283                                   %if _APPLICATION
  5284 0000204B F606[0200]40            	testopt [internalflags6], dif6_device_mode
  5285 00002050 7406                    	jz @F
  5286                                   %endif
  5287 00002052 BE[1417]                	mov si, imsg.default_cmdline.dev
  5288 00002055 B92F00                  	mov cx, words(imsg.default_cmdline.dev.length)
  5289                                  %endif
  5290                                  @@:
  5291                                  
  5292 00002058 0E                      	push cs
  5293 00002059 1F                      	pop ds
  5294 0000205A BF[0000]                	mov di, cmdline_buffer
  5295 0000205D F3A5                    	rep movsw
  5296 0000205F 26807DFF00              	cmp byte [es:di - 1], 0
  5297 00002064 7501                    	jne @F
  5298 00002066 4F                      	dec di
  5299                                  @@:
  5300 00002067 893E[0A0E]              	mov [cmdline_buffer_start], di
  5301 0000206B B000                    	mov al, 0
  5302 0000206D AA                      	stosb
  5303 0000206E 16                      	push ss
  5304 0000206F 1F                      	pop ds
  5305 00002070 800E[0100]01            	setopt [internalflags3], dif3_input_cmdline
  5306                                  %endif
  5307                                  
  5308                                  		; Interpret switches and erase them from the command line.
  5309 00002075 B80037                  	mov ax, 3700h			; get switch character
  5310 00002078 B22F                    	mov dl, '/'			; preset with default value
  5311 0000207A CD21                    	int 21h
  5312 0000207C 8816[0000]              	mov byte [ switchar ], dl
  5313 00002080 80FA2F                  	cmp dl, '/'
  5314 00002083 7504                    	jne .notslash
  5315 00002085 8816[0000]              	mov byte [ swch1 ], dl
  5316                                  .notslash:
  5317 00002089 BE8100                  	mov si, DTA+1
  5318                                  %if _MS_N_COMPAT
  5319 0000208C C644FF30                	mov byte [si - 1], '0'	; avoid kk underflow before start of tail
  5320                                  %endif
  5321                                  .blankloop:
  5322 00002090 AC                      	lodsb
  5323 00002091 3C20                    	cmp al, 32
  5324 00002093 74FB                    	je .blankloop
  5325 00002095 3C09                    	cmp al, 9
  5326 00002097 74F7                    	je .blankloop
  5327                                  
  5328                                  		; Process the /? switch (or the [switchar]? switch).
  5329                                  		; If switchar != / and /? occurs, make sure nothing follows.
  5330 00002099 3A06[0000]              	cmp al, byte [switchar]
  5331 0000209D 7503E9DB00              	je .switch		; if switch character -->
  5332 000020A2 3C2F                    	cmp al, '/'
  5333 000020A4 7403E93708              	jne .noswitches		; if not the help switch -->
  5334 000020A9 8A04                    	mov al, byte [ si ]
  5335 000020AB 3C3F                    	cmp al, '?'
  5336 000020AD 7403E92E08              	jne .noswitches		; if not /?
  5337 000020B2 8A4401                  	mov al, byte [ si+1 ]
  5338 000020B5 3C20                    	cmp al, 32
  5339 000020B7 740B                    	je .help		; if nothing after /?
  5340 000020B9 3C09                    	cmp al, 9
  5341 000020BB 7407                    	je .help		; ditto
  5342 000020BD 3C0D                    	cmp al, 13
  5343 000020BF 7403E91C08              	jne .noswitches		; if something after /? -->
  5344                                  
  5345                                  		; Print a help message
  5346                                  .help:
  5347 000020C4 1E                      	push ds
  5348                                  %if _DEVICE
  5349                                   %if _APPLICATION
  5350 000020C5 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  5351 000020CA 742A                    	jz .help_not_device
  5352                                   %endif
  5353                                  
  5354                                  		; We modify the device command line here.
  5355                                  		;  Is that wise? Seems to work though.
  5356 000020CC 8B36[0000]              	mov si, word [reg_ebx]
  5357 000020D0 8E1E[0000]              	mov ds, word [reg_es]
  5358 000020D4 C57412                  	lds si, [si + 12h]
  5359 000020D7 56                      	push si
  5360                                  @@:
  5361 000020D8 AC                      	lodsb
  5362 000020D9 3C20                    	cmp al, 32
  5363 000020DB 7412                    	je @F
  5364 000020DD 3C09                    	cmp al, 9
  5365 000020DF 740E                    	je @F
  5366 000020E1 3C00                    	cmp al, 0
  5367 000020E3 740A                    	je @F
  5368 000020E5 3C0D                    	cmp al, 13
  5369 000020E7 7406                    	je @F
  5370 000020E9 3C0A                    	cmp al, 10
  5371 000020EB 7402                    	je @F
  5372 000020ED EBE9                    	jmp @B
  5373                                  
  5374                                  @@:
  5375 000020EF C644FF00                	mov byte [si - 1], 0
  5376 000020F3 5E                      	pop si
  5377 000020F4 EB1B                    	jmp .help_common
  5378                                  
  5379                                  .help_not_device:
  5380                                  %endif
  5381                                  %if _APPLICATION
  5382 000020F6 A12C00                  	mov ax, word [2Ch]	; => environment
  5383 000020F9 85C0                    	test ax, ax
  5384 000020FB 7476                    	jz .help.no_name
  5385 000020FD 8ED8                    	mov ds, ax
  5386 000020FF 31F6                    	xor si, si
  5387                                  @@:
  5388 00002101 AC                      	lodsb
  5389 00002102 84C0                    	test al, al
  5390 00002104 75FB                    	jnz @B
  5391 00002106 AC                      	lodsb
  5392 00002107 84C0                    	test al, al
  5393 00002109 75F6                    	jnz @B
  5394 0000210B AD                      	lodsw
  5395 0000210C 83F801                  	cmp ax, 1
  5396 0000210F 7562                    	jne .help.no_name
  5397                                  %endif
  5398                                  .help_common:
  5399                                  @@:
  5400 00002111 89F3                    	mov bx, si
  5401                                  @@:
  5402 00002113 AC                      	lodsb
  5403 00002114 3C61                    	cmp al, 'a'
  5404 00002116 7208                    	jb @F
  5405 00002118 3C7A                    	cmp al, 'z'
  5406 0000211A 7704                    	ja @F
  5407 0000211C 806CFF20                	sub byte [si - 1], 'a' - 'A'
  5408                                  @@:
  5409 00002120 3C5C                    	cmp al, '\'
  5410 00002122 74ED                    	je @BBB
  5411 00002124 3C2F                    	cmp al, '/'
  5412 00002126 74E9                    	je @BBB
  5413 00002128 84C0                    	test al, al
  5414 0000212A 75E7                    	jnz @BB
  5415                                  
  5416 0000212C 89F1                    	mov cx, si
  5417 0000212E 49                      	dec cx
  5418 0000212F 29D9                    	sub cx, bx
  5419                                  
  5420                                  @@:
  5421 00002131 4E                      	dec si
  5422 00002132 39DE                    	cmp si, bx
  5423 00002134 7209                    	jb @F
  5424 00002136 803C2E                  	cmp byte [si], '.'
  5425 00002139 75F6                    	jne @B
  5426                                  
  5427 0000213B 89F1                    	mov cx, si
  5428 0000213D 29D9                    	sub cx, bx
  5429                                  @@:
  5430 0000213F E332                    	jcxz .help.no_name
  5431                                  @@:
  5432 00002141 BA[4011]                	mov dx, imsg.help.1	; command-line help message
  5433 00002144 E8EEF9                  	call init_putsz_cs
  5434 00002147 BA[9011]                	mov dx, imsg.help.1a
  5435 0000214A E8E8F9                  	call init_putsz_cs
  5436 0000214D 53                      	push bx
  5437 0000214E 89DA                    	mov dx, bx
  5438 00002150 E826FA                  	call init_puts_ds
  5439 00002153 BA[9A11]                	mov dx, imsg.help.2
  5440 00002156 E8DCF9                  	call init_putsz_cs
  5441 00002159 5A                      	pop dx
  5442 0000215A E81CFA                  	call init_puts_ds
  5443 0000215D BA[2216]                	mov dx, imsg.help.3
  5444 00002160 E8D2F9                  	call init_putsz_cs
  5445 00002163 1F                      	pop ds
  5446                                  .helpterminate:
  5447                                  %if _DEVICE && _APPLICATION
  5448 00002164 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  5449 00002169 7403E973EB              	jnz init_device_error_late
  5450                                  %elif _DEVICE
  5451                                  	jmp init_device_error_late
  5452                                  %endif
  5453                                  %if _APPLICATION
  5454 0000216E B8004C                  	mov ax, 4C00h
  5455 00002171 CD21                    	int 21h			; done
  5456                                  %endif
  5457                                  
  5458                                  .help.no_name:
  5459 00002173 0E                      	push cs
  5460 00002174 1F                      	pop ds
  5461 00002175 BB[3A11]                	mov bx, imsg.help.defaultfilename
  5462 00002178 B90600                  	mov cx, imsg.help.defaultfilename.length
  5463 0000217B EBC4                    	jmp @B
  5464                                  
  5465                                  
  5466                                  		; Do the (proper) switches.
  5467 0000217D AC                      .switch:lodsb
  5468 0000217E 3C3F                    	cmp al,'?'
  5469 00002180 7503E93FFF              	je .help		; if -?
  5470 00002185 E81C11                  	call init_capitalise
  5471                                  %if _EXTHELP
  5472 00002188 3C55                    	cmp al, 'U'
  5473 0000218A 7503E94010              	je switch_u
  5474                                  %endif
  5475                                  %if _CONFIG
  5476 0000218F 3C49                    	cmp al, 'I'
  5477 00002191 7503E98400              	je .switch_i
  5478                                  %endif
  5479 00002196 3C43                    	cmp al, 'C'
  5480 00002198 7503E99E00              	je .switch_c
  5481 0000219D 3C50                    	cmp al, 'P'
  5482 0000219F 7503E90901              	je .switch_p
  5483 000021A4 3C46                    	cmp al, 'F'
  5484 000021A6 7503E99D01              	je .switch_f
  5485 000021AB 3C45                    	cmp al, 'E'
  5486 000021AD 7503E9C601              	je .switch_e
  5487 000021B2 3C42                    	cmp al, 'B'
  5488 000021B4 7503E9EB00              	je .switch_b
  5489 000021B9 3C41                    	cmp al, 'A'
  5490 000021BB 7503E90406              	je .switch_a
  5491 000021C0 3C54                    	cmp al, 'T'
  5492 000021C2 7503E9B002              	je .switch_t
  5493 000021C7 3C52                    	cmp al, 'R'
  5494 000021C9 7503E9B406              	je .switch_r
  5495                                  %if _VXCHG
  5496 000021CE 3C56                    	cmp al, 'V'
  5497 000021D0 7503E9D001              	je .switch_v
  5498                                  %endif
  5499                                  %if _ALTVID
  5500 000021D5 3C32                    	cmp al, '2'
  5501 000021D7 7503E91102              	je .switch_2
  5502                                  %endif
  5503                                  %if _MCLOPT
  5504                                  	cmp al, 'M'
  5505                                  	je .switch_m
  5506                                  %endif
  5507                                  
  5508                                  %if _SYMBOLIC
  5509                                  	cmp al, 'S'
  5510                                  	je .switch_s
  5511                                  %endif
  5512                                  
  5513                                  %if 1 || (_DEBUG && _DEBUG_COND)
  5514 000021DC 3C44                    	cmp al, 'D'
  5515 000021DE 7503E9EF01              	je .switch_d
  5516                                  %endif
  5517                                  
  5518                                  %if _EXTENSIONS
  5519 000021E3 3C58                    	cmp al, 'X'
  5520 000021E5 7503E9AB03              	je .switch_x
  5521 000021EA 3C59                    	cmp al, 'Y'
  5522 000021EC 7503E95B04              	je .switch_y
  5523                                  %endif
  5524                                  %if _HISTORY_SEPARATE_FIXED && _HISTORY
  5525 000021F1 3C48                    	cmp al, 'H'
  5526 000021F3 7503E90C05              	je .switch_h
  5527                                  %endif
  5528                                  
  5529                                  		; Other switches may go here.
  5530 000021F8 2EA2[8916]              	mov [ cs:imsg.invalidswitch_a ], al
  5531 000021FC BA[7816]                	mov dx, imsg.invalidswitch	; Invalid switch
  5532                                  ..@init_cmdline_error:
  5533 000021FF E833F9                  	call init_putsz_cs	; print string
  5534                                  %if _DEVICE && _APPLICATION
  5535 00002202 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  5536 00002207 7403E9D5EA              	jnz init_device_error_late
  5537                                  %elif _DEVICE
  5538                                  	jmp init_device_error_late
  5539                                  %endif
  5540                                  %if _APPLICATION
  5541 0000220C B8014C                  	mov ax, 4C01h		; Quit and return error status
  5542 0000220F CD21                    	int 21h
  5543                                  %endif
  5544                                  
  5545                                  ..@init_cmdline_switch_error:
  5546 00002211 2EA2[9516]              	mov byte [cs:imsg.switch_x_error_a], al
  5547 00002215 BA[8D16]                	mov dx, imsg.switch_x_error
  5548 00002218 EBE5                    	jmp ..@init_cmdline_error
  5549                                  
  5550                                  
  5551                                  %if _CONFIG
  5552                                  .switch_i:
  5553 0000221A AC                      	lodsb
  5554 0000221B 3C4E                    	cmp al, 'N'
  5555 0000221D 7408                    	je @F
  5556 0000221F 3C6E                    	cmp al, 'n'
  5557 00002221 7404                    	je @F
  5558 00002223 B049                    	mov al, 'I'
  5559 00002225 EBEA                    	jmp ..@init_cmdline_switch_error
  5560                                  
  5561                                  @@:
  5562 00002227 8026[0100]FE            	clropt [internalflags3], dif3_input_cmdline
  5563 0000222C C606[0000]00            	mov byte [cmdline_buffer], 0
  5564 00002231 2EC706[0A0E][0000]      	mov word [cs:cmdline_buffer_start], cmdline_buffer
  5565 00002238 E955FE                  	jmp .blankloop
  5566                                  %endif
  5567                                  
  5568                                  .switch_c:
  5569                                  @@:
  5570 0000223B AC                      	lodsb
  5571 0000223C 3C3D                    	cmp al, '='
  5572 0000223E 74FB                    	je @B
  5573 00002240 3C3A                    	cmp al, ':'
  5574 00002242 74F7                    	je @B
  5575                                  
  5576 00002244 2E8B3E[0A0E]            	mov di, [cs:cmdline_buffer_start]
  5577 00002249 B400                    	mov ah, 0		; initialise to 0 = unquoted
  5578 0000224B A9                      	db __TEST_IMM16
  5579                                  .switch_c_loop:
  5580 0000224C AA                      	stosb
  5581                                  .switch_c_quoted:
  5582 0000224D AC                      	lodsb
  5583                                  .switch_c_loop_after_semicolon:
  5584                                  
  5585 0000224E 3C0D                    	cmp al, 13
  5586 00002250 7442                    	je .switch_c_eol
  5587 00002252 38E0                    	cmp al, ah		; close quote mark ?
  5588 00002254 7508                    	jne @F			; no -->
  5589 00002256 3C00                    	cmp al, 0
  5590 00002258 743A                    	je .switch_c_eol
  5591 0000225A B400                    	mov ah, 0		; continue unquoted
  5592 0000225C EBEF                    	jmp .switch_c_quoted	; and load next character -->
  5593                                  
  5594                                  @@:
  5595 0000225E 84E4                    	test ah, ah		; currently quoted ?
  5596 00002260 7514                    	jnz .switch_c_not_blank	; yes -->
  5597                                  
  5598 00002262 3C22                    	cmp al, '"'		; open quote mark ?
  5599 00002264 7404                    	je @F
  5600 00002266 3C27                    	cmp al, "'"
  5601 00002268 7504                    	jne @FF			; no -->
  5602                                  @@:
  5603 0000226A 88C4                    	mov ah, al		; remember quoted state
  5604 0000226C EBDF                    	jmp .switch_c_quoted	; and load next character -->
  5605                                  
  5606                                  @@:
  5607 0000226E 3C20                    	cmp al, 32		; blank while unquoted ?
  5608 00002270 7426                    	je .unquoted_blank
  5609 00002272 3C09                    	cmp al, 9
  5610 00002274 7422                    	je .unquoted_blank	; yes -->
  5611                                  .switch_c_not_blank:
  5612 00002276 3C3B                    	cmp al, ';'		; unescaped semicolon ?
  5613 00002278 750C                    	jne .switch_c_not_semicolon
  5614 0000227A B00D                    	mov al, 13		; yes, replace by CR
  5615 0000227C AA                      	stosb
  5616 0000227D 84E4                    	test ah, ah
  5617 0000227F 74CC                    	jz .switch_c_quoted
  5618 00002281 E86510                  	call init_skipwhite
  5619 00002284 EBC8                    	jmp .switch_c_loop_after_semicolon
  5620                                  
  5621                                  .switch_c_not_semicolon:
  5622 00002286 3C5C                    	cmp al, '\'		; escape ?
  5623 00002288 75C2                    	jne .switch_c_loop	; no, store literal -->
  5624 0000228A AC                      	lodsb			; load escaped character
  5625                                  				;  (may be backslash, semicolon, quote)
  5626 0000228B 3C0D                    	cmp al, 13		; guard against EOL
  5627 0000228D 75BD                    	jne .switch_c_loop
  5628                                  .switch_c_error:
  5629 0000228F B043                    	mov al, 'C'
  5630 00002291 E97DFF                  	jmp ..@init_cmdline_switch_error
  5631                                  
  5632                                  .switch_c_eol:
  5633 00002294 84E4                    	test ah, ah		; in quoted state ?
  5634 00002296 75F7                    	jnz .switch_c_error	; yes, error -->
  5635                                  .unquoted_blank:
  5636 00002298 B000                    	mov al, 0
  5637 0000229A AA                      	stosb			; terminate command line buffer
  5638 0000229B 800E[0100]01            	setopt [internalflags3], dif3_input_cmdline
  5639 000022A0 4E                      	dec si
  5640 000022A1 E9ECFD                  	jmp .blankloop
  5641                                  
  5642                                  
  5643                                  .switch_b:
  5644 000022A4 2EC606[E028]CC          	mov byte [cs:.breakpoint], 0CCh	; SMC in section init, set point
  5645 000022AA E9E3FD                  	jmp .blankloop
  5646                                  
  5647                                  
  5648                                  .switch_p:
  5649 000022AD AC                      	lodsb
  5650 000022AE E8F30F                  	call init_capitalise
  5651 000022B1 BBFFFF                  	mov bx, 0FFFFh		; or 0FFFFh
  5652 000022B4 89DA                    	mov dx, bx		; and 0FFFFh
  5653 000022B6 4E                      	dec si
  5654 000022B7 3C20                    	cmp al, 32
  5655 000022B9 7478                    	je @F
  5656 000022BB 3C09                    	cmp al, 9
  5657 000022BD 7474                    	je @F
  5658 000022BF 3C0D                    	cmp al, 13
  5659 000022C1 7470                    	je @F
  5660 000022C3 46                      	inc si
  5661 000022C4 3C2B                    	cmp al, '+'
  5662 000022C6 746B                    	je @F
  5663 000022C8 42                      	inc dx			; and 0000h
  5664 000022C9 3C2D                    	cmp al, '-'
  5665 000022CB 7466                    	je @F
  5666                                  
  5667                                  .switch_p_not_plusminus:
  5668 000022CD 3C53                    	cmp al, 'S'
  5669 000022CF 751E                    	jne .switch_p_not_s
  5670 000022D1 B700                    	mov bh, 00h		; or 0FFh
  5671 000022D3 4A                      	dec dx			; and 0FFFFh
  5672 000022D4 AC                      	lodsb
  5673 000022D5 4E                      	dec si
  5674 000022D6 3C20                    	cmp al, 32
  5675 000022D8 7459                    	je @F
  5676 000022DA 3C09                    	cmp al, 9
  5677 000022DC 7455                    	je @F
  5678 000022DE 3C0D                    	cmp al, 13
  5679 000022E0 7451                    	je @F
  5680 000022E2 46                      	inc si
  5681 000022E3 3C2B                    	cmp al, '+'
  5682 000022E5 744C                    	je @F
  5683 000022E7 B200                    	mov dl, 00h		; and 0FF00h
  5684 000022E9 3C2D                    	cmp al, '-'
  5685 000022EB 7446                    	je @F
  5686 000022ED EB3F                    	jmp .switch_p_error
  5687                                  
  5688                                  .switch_p_not_s:
  5689 000022EF 3C45                    	cmp al, 'E'
  5690 000022F1 751E                    	jne .switch_p_not_e
  5691 000022F3 B300                    	mov bl, 00h		; or 0FF00h
  5692 000022F5 4A                      	dec dx			; and 0FFFFh
  5693 000022F6 AC                      	lodsb
  5694 000022F7 4E                      	dec si
  5695 000022F8 3C20                    	cmp al, 32
  5696 000022FA 7437                    	je @F
  5697 000022FC 3C09                    	cmp al, 9
  5698 000022FE 7433                    	je @F
  5699 00002300 3C0D                    	cmp al, 13
  5700 00002302 742F                    	je @F
  5701 00002304 46                      	inc si
  5702 00002305 3C2B                    	cmp al, '+'
  5703 00002307 742A                    	je @F
  5704 00002309 B600                    	mov dh, 00h		; and 00FFh
  5705 0000230B 3C2D                    	cmp al, '-'
  5706 0000230D 7424                    	je @F
  5707 0000230F EB1D                    	jmp .switch_p_error
  5708                                  
  5709                                  .switch_p_not_e:
  5710 00002311 3C57                    	cmp al, 'W'
  5711 00002313 7519                    	jne .switch_p_not_w
  5712                                  		; bl = 0FFh
  5713 00002315 AC                      	lodsb
  5714 00002316 4E                      	dec si
  5715 00002317 3C20                    	cmp al, 32
  5716 00002319 7425                    	je @FF
  5717 0000231B 3C09                    	cmp al, 9
  5718 0000231D 7421                    	je @FF
  5719 0000231F 3C0D                    	cmp al, 13
  5720 00002321 741D                    	je @FF
  5721 00002323 46                      	inc si
  5722 00002324 3C2B                    	cmp al, '+'
  5723 00002326 7418                    	je @FF
  5724 00002328 B300                    	mov bl, 00h
  5725 0000232A 3C2D                    	cmp al, '-'
  5726 0000232C 7412                    	je @FF
  5727                                  	; jmp .switch_p_error
  5728                                  
  5729                                  .switch_p_not_w:
  5730                                  .switch_p_error:
  5731 0000232E B050                    	mov al, 'P'
  5732 00002330 E9DEFE                  	jmp ..@init_cmdline_switch_error
  5733                                  @@:
  5734 00002333 2E091E[180E]            	or [cs:init_switch_p_low_pathsearch_high_guessextension], bx
  5735 00002338 2E2116[180E]            	and [cs:init_switch_p_low_pathsearch_high_guessextension], dx
  5736 0000233D E950FD                  	jmp .blankloop
  5737                                  
  5738                                  @@:
  5739 00002340 2E881E[3C0E]            	mov [cs:init_switch_pw], bl
  5740 00002345 E948FD                  	jmp .blankloop
  5741                                  
  5742                                  
  5743                                  .switch_f:
  5744 00002348 AC                      	lodsb
  5745 00002349 BB000C                  	mov bx, opt6_flat_binary + opt6_big_stack
  5746 0000234C 4E                      	dec si
  5747 0000234D 3C20                    	cmp al, 32
  5748 0000234F 741B                    	je @F
  5749 00002351 3C09                    	cmp al, 9
  5750 00002353 7417                    	je @F
  5751 00002355 3C0D                    	cmp al, 13
  5752 00002357 7413                    	je @F
  5753 00002359 BB0004                  	mov bx, opt6_flat_binary
  5754 0000235C 46                      	inc si
  5755 0000235D 3C2B                    	cmp al, '+'
  5756 0000235F 740B                    	je @F
  5757 00002361 31DB                    	xor bx, bx
  5758 00002363 3C2D                    	cmp al, '-'
  5759 00002365 7405                    	je @F
  5760                                  .switch_f_error:
  5761 00002367 B046                    	mov al, 'F'
  5762 00002369 E9A5FE                  	jmp ..@init_cmdline_switch_error
  5763                                  @@:
  5764 0000236C 8026[0100]FB            	clropt [options6], opt6_flat_binary
  5765 00002371 091E[0000]              	or word [options6], bx
  5766 00002375 E918FD                  	jmp .blankloop
  5767                                  
  5768                                  .switch_e:
  5769 00002378 AC                      	lodsb
  5770 00002379 BB0008                  	mov bx, opt6_big_stack
  5771 0000237C 4E                      	dec si
  5772 0000237D 3C20                    	cmp al, 32
  5773 0000237F 7418                    	je @F
  5774 00002381 3C09                    	cmp al, 9
  5775 00002383 7414                    	je @F
  5776 00002385 3C0D                    	cmp al, 13
  5777 00002387 7410                    	je @F
  5778 00002389 46                      	inc si
  5779 0000238A 3C2B                    	cmp al, '+'
  5780 0000238C 740B                    	je @F
  5781 0000238E 31DB                    	xor bx, bx
  5782 00002390 3C2D                    	cmp al, '-'
  5783 00002392 7405                    	je @F
  5784                                  .switch_e_error:
  5785 00002394 B045                    	mov al, 'E'
  5786 00002396 E978FE                  	jmp ..@init_cmdline_switch_error
  5787                                  @@:
  5788 00002399 8026[0100]F7            	clropt [options6], opt6_big_stack
  5789 0000239E 091E[0000]              	or word [options6], bx
  5790 000023A2 E9EBFC                  	jmp .blankloop
  5791                                  
  5792                                  %if _MCLOPT
  5793                                  .switch_m:
  5794                                  	lodsb
  5795                                  	mov bl, 20h
  5796                                  	dec si
  5797                                  	cmp al, 32
  5798                                  	je @F
  5799                                  	cmp al, 9
  5800                                  	je @F
  5801                                  	cmp al, 13
  5802                                  	je @F
  5803                                  	inc si
  5804                                  	cmp al, '+'
  5805                                  	je @F
  5806                                  	mov bl, 8
  5807                                  	cmp al, '-'
  5808                                  	je @F
  5809                                  .switch_m_error:
  5810                                  	mov al, 'M'
  5811                                  	jmp ..@init_cmdline_switch_error
  5812                                  @@:
  5813                                  	mov byte [master_pic_base], bl
  5814                                  	jmp .blankloop
  5815                                  %endif
  5816                                  
  5817                                  %if _VXCHG
  5818                                  .switch_v:
  5819 000023A5 AC                      	lodsb
  5820 000023A6 BB0100                  	mov bx, opt6_vv_mode
  5821 000023A9 4E                      	dec si
  5822 000023AA 3C20                    	cmp al, 32
  5823 000023AC 7418                    	je @F
  5824 000023AE 3C09                    	cmp al, 9
  5825 000023B0 7414                    	je @F
  5826 000023B2 3C0D                    	cmp al, 13
  5827 000023B4 7410                    	je @F
  5828 000023B6 46                      	inc si
  5829 000023B7 3C2B                    	cmp al, '+'
  5830 000023B9 740B                    	je @F
  5831 000023BB 31DB                    	xor bx, bx
  5832 000023BD 3C2D                    	cmp al, '-'
  5833 000023BF 7405                    	je @F
  5834                                  .switch_v_error:
  5835 000023C1 B056                    	mov al, 'V'
  5836 000023C3 E94BFE                  	jmp ..@init_cmdline_switch_error
  5837                                  @@:
  5838 000023C6 8026[0000]FE            	clropt [options6], opt6_vv_mode
  5839 000023CB 091E[0000]              	or word [options6], bx
  5840 000023CF E9BEFC                  	jmp .blankloop
  5841                                  %endif
  5842                                  
  5843                                  %if _DEBUG && _DEBUG_COND
  5844                                  .switch_d:
  5845                                  	lodsb
  5846                                  	mov bx, dif6_debug_mode
  5847                                  	dec si
  5848                                  	cmp al, 32
  5849                                  	je @F
  5850                                  	cmp al, 9
  5851                                  	je @F
  5852                                  	cmp al, 13
  5853                                  	je @F
  5854                                  	inc si
  5855                                  	cmp al, '+'
  5856                                  	je @F
  5857                                  	xor bx, bx
  5858                                  	cmp al, '-'
  5859                                  	je @F
  5860                                  .switch_d_error:
  5861                                  	mov al, 'D'
  5862                                  	jmp ..@init_cmdline_switch_error
  5863                                  @@:
  5864                                  	clropt [internalflags6], dif6_debug_mode
  5865                                  	clropt [options6], opt6_debug_mode
  5866                                  	or word [internalflags6], bx
  5867                                  	or word [options6], bx
  5868                                   %if dif6_debug_mode != opt6_debug_mode
  5869                                    %error Mismatch of flag and option
  5870                                   %endif
  5871                                  	jmp .blankloop
  5872                                  %else
  5873                                  .switch_d:
  5874 000023D2 AC                      	lodsb
  5875                                   %if _DEBUG
  5876 000023D3 4E                      	dec si
  5877 000023D4 3C20                    	cmp al, 32
  5878 000023D6 740B                    	je @F
  5879 000023D8 3C09                    	cmp al, 9
  5880 000023DA 7407                    	je @F
  5881 000023DC 3C0D                    	cmp al, 13
  5882 000023DE 7403                    	je @F
  5883 000023E0 46                      	inc si
  5884 000023E1 3C2B                    	cmp al, '+'
  5885                                  @@:
  5886                                   %else
  5887                                  	cmp al, '-'
  5888                                   %endif
  5889 000023E3 7503E9A8FC              	je .blankloop
  5890 000023E8 B044                    	mov al, 'D'
  5891 000023EA E924FE                  	jmp ..@init_cmdline_switch_error
  5892                                  %endif
  5893                                  
  5894                                  
  5895                                  %if _ALTVID
  5896                                  .switch_2:
  5897 000023ED AC                      	lodsb
  5898 000023EE B31E                    	mov bl, 1Eh			; "push ds"
  5899 000023F0 4E                      	dec si
  5900 000023F1 3C20                    	cmp al, 32
  5901 000023F3 7418                    	je @F
  5902 000023F5 3C09                    	cmp al, 9
  5903 000023F7 7414                    	je @F
  5904 000023F9 3C0D                    	cmp al, 13
  5905 000023FB 7410                    	je @F
  5906 000023FD 46                      	inc si
  5907 000023FE 3C2B                    	cmp al, '+'
  5908 00002400 740B                    	je @F
  5909 00002402 B3C3                    	mov bl, 0C3h			; "retn"
  5910 00002404 3C2D                    	cmp al, '-'
  5911 00002406 7405                    	je @F
  5912                                  .switch_2_error:
  5913 00002408 B032                    	mov al, '2'
  5914 0000240A E904FE                  	jmp ..@init_cmdline_switch_error
  5915                                  @@:
  5916 0000240D 8E06[0000]              	mov es, [code_seg]
  5917 00002411 26881E[0000]            	mov byte [es:setscreen], bl
  5918 00002416 16                      	push ss
  5919 00002417 07                      	pop es
  5920 00002418 80FBC3                  	cmp bl, 0C3h
  5921 0000241B 7445                    	je .noaltvid
  5922 0000241D B8001A                  	mov ax, 1A00h
  5923 00002420 CD10                    	int 10h
  5924 00002422 3C1A                    	cmp al, 1Ah
  5925 00002424 753C                    	jnz .noaltvid
  5926 00002426 80FF00                  	cmp bh, 0
  5927 00002429 7437                    	jz .noaltvid
  5928                                  
  5929 0000242B 1E                      	push ds
  5930 0000242C B84000                  	mov ax, 40h
  5931 0000242F 8ED8                    	mov ds, ax
  5932 00002431 8B166300                	mov dx, [63h]
  5933 00002435 1F                      	pop ds
  5934 00002436 80F260                  	xor dl, 60h
  5935 00002439 8916[0000]              	mov [oldcrtp], dx
  5936 0000243D B007                    	mov al, 7
  5937 0000243F 80FAB4                  	cmp dl, 0B4h
  5938 00002442 7402                    	jz @F
  5939 00002444 B003                    	mov al, 3
  5940                                  @@:
  5941 00002446 A2[0000]                	mov [oldmode], al
  5942 00002449 B00E                    	mov al, 0Eh
  5943 0000244B EE                      	out dx, al
  5944 0000244C 42                      	inc dx
  5945 0000244D EC                      	in al, dx
  5946 0000244E 88C4                    	mov ah, al
  5947 00002450 4A                      	dec dx
  5948 00002451 B00F                    	mov al, 0Fh
  5949 00002453 EE                      	out dx, al
  5950 00002454 42                      	inc dx
  5951 00002455 EC                      	in al, dx
  5952 00002456 B350                    	mov bl, 80
  5953 00002458 F6F3                    	div bl
  5954 0000245A 86C4                    	xchg al, ah
  5955 0000245C A3[0000]                	mov [oldcsrpos], ax
  5956 0000245F E92EFC                  	jmp .blankloop
  5957                                  
  5958                                  .noaltvid:
  5959 00002462 BA[F710]                	mov dx, imsg.noaltvid
  5960 00002465 E8CDF6                  	call init_putsz_cs
  5961 00002468 8E06[0000]              	mov es, [code_seg]
  5962 0000246C 26C606[0000]C3          	mov byte [es:setscreen], 0C3h
  5963 00002472 16                      	push ss
  5964 00002473 07                      	pop es
  5965 00002474 E919FC                  	jmp .blankloop
  5966                                  %endif
  5967                                  
  5968                                  
  5969                                  %if _SYMBOLIC
  5970                                  .switch_s:
  5971                                  	mov dx, si
  5972                                  	lodsb
  5973                                  	mov ah, 0		; flag for not quoted
  5974                                  	cmp al, '"'
  5975                                  	je .s_quoted
  5976                                  	cmp al, "'"
  5977                                  	jne .s_unquoted
  5978                                  .s_quoted:
  5979                                  	mov ah, al		; save away our quote mark
  5980                                  	inc dx			; -> behind the quote mark
  5981                                  @@:
  5982                                  	lodsb
  5983                                  	cmp al, 13
  5984                                  	je .switch_s_error
  5985                                  	cmp al, 0
  5986                                  	je .switch_s_error
  5987                                  	cmp al, ah		; closing quote mark ?
  5988                                  	jne @B			; not yet -->
  5989                                  	jmp .s_end
  5990                                  
  5991                                  	db __TEST_IMM8		; (skip lodsb)
  5992                                  @@:
  5993                                  	lodsb
  5994                                  .s_unquoted:
  5995                                  	cmp al, 32
  5996                                  	ja @B
  5997                                  
  5998                                  .s_end:
  5999                                  	dec si			; -> blank or terminator or closing quote
  6000                                  	push ax
  6001                                  	push si
  6002                                  	mov byte [si], 13	; put in a CR for good measure
  6003                                  	mov si, dx
  6004                                  
  6005                                  	push word [errret]
  6006                                  	push word [throwret]
  6007                                  	push word [throwsp]
  6008                                  
  6009                                  	push cs
  6010                                  	call .jump
  6011                                  
  6012                                  	pop word [throwsp]
  6013                                  	pop word [throwret]	; restore throw destination
  6014                                  	pop word [errret]
  6015                                  	pop si
  6016                                  	pop ax
  6017                                  	mov byte [si], al	; restore if it wasn't CR
  6018                                  		; si -> next character to process
  6019                                  	test dx, dx
  6020                                  	jz @F
  6021                                  
  6022                                  	cmp dx, si
  6023                                  	je @F
  6024                                  
  6025                                  	mov dx, imsg.switch_s_garbage
  6026                                  	call init_putsz_cs
  6027                                  
  6028                                  @@:
  6029                                  	test ah, ah		; was quoted ?
  6030                                  	jz @F			; no -->
  6031                                  	inc si			; skip closing quote mark
  6032                                  @@:
  6033                                  	jmp .blankloop
  6034                                  
  6035                                  .switch_s_error:
  6036                                  	mov al, 'S'
  6037                                  	jmp ..@init_cmdline_switch_error
  6038                                  
  6039                                  .jump:
  6040                                  	mov word [errret], ..@switch_s_catch
  6041                                  	mov word [throwret], ..@switch_s_catch
  6042                                  	mov word [throwsp], sp
  6043                                  
  6044                                  	mov ax, ..@switch_s_cont
  6045                                  	push word [code_seg]
  6046                                  	push ax
  6047                                  	retf
  6048                                  %endif
  6049                                  
  6050                                  
  6051                                  	usesection INIT
  6051          ------------------       note: usesection INIT
  6052                                  
  6053                                  .switch_t:
  6054 00002477 B3FF                    	mov bl, 0FFh
  6055 00002479 31FF                    	xor di, di
  6056                                  .switch_t_loop:
  6057                                  @@:
  6058 0000247B AC                      	lodsb
  6059 0000247C 3C3D                    	cmp al, '='
  6060 0000247E 74FB                    	je @B
  6061 00002480 3C3A                    	cmp al, ':'
  6062 00002482 74F7                    	je @B
  6063 00002484 3C2C                    	cmp al, ','
  6064 00002486 74F3                    	je @B
  6065 00002488 4E                      	dec si
  6066 00002489 3C20                    	cmp al, 32
  6067 0000248B 7503E9A800              	je @F
  6068 00002490 3C09                    	cmp al, 9
  6069 00002492 7503E9A100              	je @F
  6070 00002497 3C0D                    	cmp al, 13
  6071 00002499 7503E99A00              	je @F
  6072 0000249E 46                      	inc si
  6073 0000249F 3C2B                    	cmp al, '+'
  6074 000024A1 7503E98C00              	je .switch_t_set
  6075 000024A6 3C2D                    	cmp al, '-'
  6076 000024A8 7503E98900              	je .switch_t_clear
  6077                                  
  6078 000024AD 2E8A1E[3D0E]            	mov bl, byte [cs:init_switch_t]
  6079 000024B2 E8EF0D                  	call init_capitalise
  6080 000024B5 3C49                    	cmp al, 'I'		; ignore ?
  6081 000024B7 7508                    	jne .t_notignore
  6082 000024B9 2EC606[3E0E]FF          	mov byte [cs:init_switch_t_ignore], 0FFh
  6083 000024BF EBBA                    	jmp @B
  6084                                  
  6085                                  .t_notignore:
  6086 000024C1 3C4F                    	cmp al, 'O'		; only ?
  6087 000024C3 7508                    	jne .t_notonly
  6088 000024C5 2EC606[3E0E]00          	mov byte [cs:init_switch_t_ignore], 0
  6089 000024CB EBAE                    	jmp @B
  6090                                  
  6091                                  .t_notonly:
  6092 000024CD 3C50                    	cmp al, 'P'		; point ?
  6093 000024CF 7508                    	jne .t_notpoint
  6094 000024D1 2EC606[3F0E]FF          	mov byte [cs:init_switch_t_break], 0FFh
  6095 000024D7 EBA2                    	jmp @B
  6096                                  
  6097                                  .t_notpoint:
  6098 000024D9 3C56                    	cmp al, 'V'		; variable ?
  6099 000024DB 7508                    	jne .t_notvar
  6100 000024DD 2EC606[400E]FF          	mov byte [cs:init_switch_t_variable], 0FFh
  6101 000024E3 EB96                    	jmp @B
  6102                                  
  6103                                  .t_notvar:
  6104 000024E5 3C55                    	cmp al, 'U'		; enable UMA ?
  6105 000024E7 7509                    	jne .t_notupper
  6106 000024E9 2EC785[240E]0100        	mov word [cs:init_switch_t_umblink + di], 1
  6107 000024F0 EB89                    	jmp @B
  6108                                  
  6109                                  .t_notupper:
  6110 000024F2 3C4C                    	cmp al, 'L'		; restrict to LMA ?
  6111 000024F4 750A                    	jne .t_notlower
  6112 000024F6 2EC785[240E]0000        	mov word [cs:init_switch_t_umblink + di], 0
  6113 000024FD E97BFF                  	jmp @B
  6114                                  
  6115                                  .t_notlower:
  6116 00002500 3C58                    	cmp al, 'X'
  6117 00002502 7505                    	jne .t_not_x
  6118 00002504 31FF                    	xor di, di
  6119 00002506 E972FF                  	jmp @B
  6120                                  
  6121                                  .t_not_x:
  6122 00002509 3C59                    	cmp al, 'Y'
  6123 0000250B 7506                    	jne .t_not_y
  6124 0000250D BF0200                  	mov di, 2
  6125 00002510 E968FF                  	jmp @B
  6126                                  
  6127                                  .t_not_y:
  6128 00002513 3C5A                    	cmp al, 'Z'
  6129 00002515 7506                    	jne .t_not_z
  6130 00002517 BF0400                  	mov di, 4
  6131 0000251A E95EFF                  	jmp @B
  6132                                  
  6133                                  .t_not_z:
  6134 0000251D 3C30                    	cmp al, '0'
  6135 0000251F 720C                    	jb .switch_t_error
  6136 00002521 3C39                    	cmp al, '9'
  6137 00002523 7626                    	jbe .switch_t_numeric
  6138 00002525 3C41                    	cmp al, 'A'
  6139 00002527 7204                    	jb .switch_t_error
  6140 00002529 3C46                    	cmp al, 'F'
  6141 0000252B 761E                    	jbe .switch_t_numeric
  6142                                  .switch_t_error:
  6143 0000252D B054                    	mov al, 'T'
  6144 0000252F E9DFFC                  	jmp ..@init_cmdline_switch_error
  6145                                  
  6146                                  .switch_t_set:
  6147 00002532 B3FF                    	mov bl, 0FFh
  6148 00002534 EB02                    	jmp @F
  6149                                  
  6150                                  .switch_t_clear:
  6151 00002536 31DB                    	xor bx, bx
  6152                                  
  6153                                  @@:
  6154                                  %if _DEVICE
  6155 00002538 84DB                    	test bl, bl
  6156 0000253A 7407                    	jz @F
  6157 0000253C F606[0200]40            	testopt [internalflags6], dif6_device_mode
  6158 00002541 75EA                    	jnz .switch_t_error
  6159                                  @@:
  6160                                  %endif
  6161 00002543 2E881E[3D0E]            	mov byte [cs:init_switch_t], bl
  6162 00002548 E945FB                  	jmp .blankloop
  6163                                  
  6164                                  .switch_t_numeric:
  6165 0000254B 31D2                    	xor dx, dx
  6166 0000254D A8                      	db __TEST_IMM8		; (skip lodsb)
  6167                                  @@:
  6168 0000254E AC                      	lodsb
  6169 0000254F 3C2C                    	cmp al, ','
  6170 00002551 7439                    	je @F
  6171 00002553 3C20                    	cmp al, 32
  6172 00002555 7435                    	je @F
  6173 00002557 3C09                    	cmp al, 9
  6174 00002559 7431                    	je @F
  6175 0000255B 3C0D                    	cmp al, 13
  6176 0000255D 742D                    	je @F
  6177 0000255F E8420D                  	call init_capitalise
  6178 00002562 B400                    	mov ah, 0
  6179 00002564 3C30                    	cmp al, '0'			; decimal digit ?
  6180 00002566 72C5                    	jb .switch_t_error
  6181 00002568 3C39                    	cmp al, '9'
  6182 0000256A 7714                    	ja .switch_t_notdec
  6183 0000256C 2C30                    	sub al, '0'			; ax = digit
  6184                                  .switch_t_gotdigit:
  6185 0000256E 81FA0010                	cmp dx, 1000h
  6186 00002572 73B9                    	jae .switch_t_error
  6187 00002574 01D2                    	add dx, dx
  6188 00002576 01D2                    	add dx, dx
  6189 00002578 01D2                    	add dx, dx
  6190 0000257A 01D2                    	add dx, dx			; * 16
  6191 0000257C 01C2                    	add dx, ax
  6192 0000257E EBCE                    	jmp @B
  6193                                  
  6194                                  .switch_t_notdec:
  6195 00002580 3C41                    	cmp al, 'A'			; alphabetic ?
  6196 00002582 72A9                    	jb .switch_t_error
  6197 00002584 3C46                    	cmp al, 'F'
  6198 00002586 77A5                    	ja .switch_t_error
  6199 00002588 04C9                    	add al, 10 - 'A'		; ax = digit
  6200 0000258A EBE2                    	jmp .switch_t_gotdigit
  6201                                  
  6202                                  @@:
  6203 0000258C 2E8995[2A0E]            	mov word [cs:init_switch_t_strategy + di], dx
  6204 00002591 4E                      	dec si
  6205 00002592 E9E6FE                  	jmp .switch_t_loop
  6206                                  
  6207                                  %if _EXTENSIONS
  6208                                  .switch_x:
  6209 00002595 BBF0FF                  	mov bx, _EXT_CODE_SIZE
  6210 00002598 AC                      	lodsb
  6211 00002599 3C09                    	cmp al, 9
  6212 0000259B 7503E9A100              	je .switch_x_got
  6213 000025A0 3C20                    	cmp al, 32
  6214 000025A2 7503E99A00              	je .switch_x_got
  6215 000025A7 3C0D                    	cmp al, 13
  6216 000025A9 7503E99300              	je .switch_x_got
  6217 000025AE 3C3A                    	cmp al, ':'
  6218 000025B0 7404                    	je @F
  6219 000025B2 3C3D                    	cmp al, '='
  6220 000025B4 7501                    	jne @FF
  6221                                  @@:
  6222 000025B6 AC                      	lodsb
  6223                                  @@:
  6224 000025B7 4E                      	dec si
  6225 000025B8 0E                      	push cs
  6226 000025B9 07                      	pop es
  6227 000025BA BA[160F]                	mov dx, imsg.max
  6228 000025BD E88E0C                  	call init_isstring?
  6229 000025C0 747E                    	je .switch_x_got.lodsb
  6230 000025C2 BB0000                  	mov bx, 0
  6231 000025C5 BA[1A0F]                	mov dx, imsg.min
  6232 000025C8 E8830C                  	call init_isstring?
  6233 000025CB 7473                    	je .switch_x_got.lodsb
  6234 000025CD BB0040                  	mov bx, _EXT_CODE_DEFAULT_SIZE
  6235 000025D0 BA[1E0F]                	mov dx, imsg.default
  6236 000025D3 E8780C                  	call init_isstring?
  6237 000025D6 7468                    	je .switch_x_got.lodsb
  6238                                  
  6239 000025D8 BA1000                  	mov dx, 16
  6240 000025DB 803C23                  	cmp byte [si], '#'
  6241 000025DE 7503                    	jne .switch_x_zero
  6242 000025E0 46                      	inc si
  6243 000025E1 B20A                    	mov dl, 10
  6244                                  .switch_x_zero:
  6245 000025E3 31DB                    	xor bx, bx
  6246                                  .switch_x_num:
  6247 000025E5 AC                      	lodsb
  6248 000025E6 3C20                    	cmp al, 32			; end of number ?
  6249 000025E8 7450                    	je .switch_x_check
  6250 000025EA 3C09                    	cmp al, 9
  6251 000025EC 744C                    	je .switch_x_check
  6252 000025EE 3C0D                    	cmp al, 13
  6253 000025F0 7448                    	je .switch_x_check		; yes -->
  6254 000025F2 3C5F                    	cmp al, '_'			; separator ?
  6255 000025F4 74EF                    	je .switch_x_num
  6256 000025F6 3C23                    	cmp al, '#'			; base change ?
  6257 000025F8 7432                    	je .switch_x_base
  6258 000025FA E8A70C                  	call init_capitalise
  6259 000025FD B400                    	mov ah, 0
  6260 000025FF 3C30                    	cmp al, '0'			; decimal digit ?
  6261 00002601 7224                    	jb .switch_x_error
  6262 00002603 3C39                    	cmp al, '9'
  6263 00002605 7712                    	ja .switch_x_notdec
  6264 00002607 2C30                    	sub al, '0'			; ax = digit
  6265                                  .switch_x_gotdigit:
  6266 00002609 93                      	xchg ax, bx			; ax = prior
  6267 0000260A 52                      	push dx
  6268 0000260B F7E2                    	mul dx				; dx:ax = prior * base
  6269 0000260D 85D2                    	test dx, dx			; >= 64 KiB ?
  6270 0000260F 7516                    	jnz .switch_x_error		; error -->
  6271 00002611 5A                      	pop dx
  6272 00002612 93                      	xchg bx, ax			; return bx = prior
  6273 00002613 01C3                    	add bx, ax			; prior += next
  6274 00002615 7210                    	jc .switch_x_error
  6275 00002617 EBCC                    	jmp .switch_x_num
  6276                                  
  6277                                  .switch_x_notdec:
  6278 00002619 3C41                    	cmp al, 'A'			; alphabetic ?
  6279 0000261B 720A                    	jb .switch_x_error
  6280 0000261D 3C5A                    	cmp al, 'Z'
  6281 0000261F 7706                    	ja .switch_x_error
  6282 00002621 04C9                    	add al, 10 - 'A'		; ax = digit
  6283 00002623 39D0                    	cmp ax, dx
  6284 00002625 72E2                    	jb .switch_x_gotdigit
  6285                                  	; jae .switch_x_error
  6286                                  .switch_x_error:
  6287                                  ..@init_cmdline_switch_x_error:
  6288 00002627 B058                    	mov al, 'X'
  6289 00002629 E9E5FB                  	jmp ..@init_cmdline_switch_error
  6290                                  
  6291                                  .switch_x_base:
  6292 0000262C 83FB02                  	cmp bx, 2
  6293 0000262F 72F6                    	jb .switch_x_error
  6294 00002631 83FB24                  	cmp bx, 36
  6295 00002634 77F1                    	ja .switch_x_error
  6296 00002636 89DA                    	mov dx, bx
  6297 00002638 EBA9                    	jmp .switch_x_zero
  6298                                  
  6299                                  .switch_x_check:
  6300 0000263A 83FBF0                  	cmp bx, _EXT_CODE_SIZE
  6301 0000263D 77E8                    	ja .switch_x_error
  6302                                  
  6303 0000263F A8                      	db __TEST_IMM8			; (skip lodsb)
  6304                                  .switch_x_got.lodsb:
  6305 00002640 AC                      	lodsb
  6306                                  .switch_x_got:
  6307 00002641 1E                      	push ds
  6308 00002642 07                      	pop es
  6309 00002643 2E891E[120E]            	mov word [cs:init_ext_want], bx
  6310 00002648 4E                      	dec si
  6311 00002649 E944FA                  	jmp .blankloop
  6312                                  
  6313                                  
  6314                                  .switch_y:
  6315                                  %ifn _LINK
  6316                                  	mov bx, ext_data_max_size_equate
  6317                                  %else
  6318 0000264C BB[F0FF]                	mov bx, relocatedzero + 0FFF0h
  6319                                   wlcalc word_minusext_ext_data_area, equ $ - 2
  6320                                  %endif
  6321 0000264F AC                      	lodsb
  6322 00002650 3C09                    	cmp al, 9
  6323 00002652 7503E9A200              	je .switch_y_got
  6324 00002657 3C20                    	cmp al, 32
  6325 00002659 7503E99B00              	je .switch_y_got
  6326 0000265E 3C0D                    	cmp al, 13
  6327 00002660 7503E99400              	je .switch_y_got
  6328 00002665 3C3A                    	cmp al, ':'
  6329 00002667 7404                    	je @F
  6330 00002669 3C3D                    	cmp al, '='
  6331 0000266B 7501                    	jne @FF
  6332                                  @@:
  6333 0000266D AC                      	lodsb
  6334                                  @@:
  6335 0000266E 4E                      	dec si
  6336 0000266F 0E                      	push cs
  6337 00002670 07                      	pop es
  6338 00002671 BA[160F]                	mov dx, imsg.max
  6339 00002674 E8D70B                  	call init_isstring?
  6340 00002677 747F                    	je .switch_y_got.lodsb
  6341 00002679 BB0000                  	mov bx, 0
  6342 0000267C BA[1A0F]                	mov dx, imsg.min
  6343 0000267F E8CC0B                  	call init_isstring?
  6344 00002682 7474                    	je .switch_y_got.lodsb
  6345 00002684 BB0040                  	mov bx, _EXT_DATA_DEFAULT_SIZE
  6346 00002687 BA[1E0F]                	mov dx, imsg.default
  6347 0000268A E8C10B                  	call init_isstring?
  6348 0000268D 7469                    	je .switch_y_got.lodsb
  6349                                  
  6350 0000268F BA1000                  	mov dx, 16
  6351 00002692 803C23                  	cmp byte [si], '#'
  6352 00002695 7503                    	jne .switch_y_zero
  6353 00002697 46                      	inc si
  6354 00002698 B20A                    	mov dl, 10
  6355                                  .switch_y_zero:
  6356 0000269A 31DB                    	xor bx, bx
  6357                                  .switch_y_num:
  6358 0000269C AC                      	lodsb
  6359 0000269D 3C20                    	cmp al, 32			; end of number ?
  6360 0000269F 7450                    	je .switch_y_check
  6361 000026A1 3C09                    	cmp al, 9
  6362 000026A3 744C                    	je .switch_y_check
  6363 000026A5 3C0D                    	cmp al, 13
  6364 000026A7 7448                    	je .switch_y_check		; yes -->
  6365 000026A9 3C5F                    	cmp al, '_'			; separator ?
  6366 000026AB 74EF                    	je .switch_y_num
  6367 000026AD 3C23                    	cmp al, '#'			; base change ?
  6368 000026AF 7432                    	je .switch_y_base
  6369 000026B1 E8F00B                  	call init_capitalise
  6370 000026B4 B400                    	mov ah, 0
  6371 000026B6 3C30                    	cmp al, '0'			; decimal digit ?
  6372 000026B8 7224                    	jb .switch_y_error
  6373 000026BA 3C39                    	cmp al, '9'
  6374 000026BC 7712                    	ja .switch_y_notdec
  6375 000026BE 2C30                    	sub al, '0'			; ax = digit
  6376                                  .switch_y_gotdigit:
  6377 000026C0 93                      	xchg ax, bx			; ax = prior
  6378 000026C1 52                      	push dx
  6379 000026C2 F7E2                    	mul dx				; dx:ax = prior * base
  6380 000026C4 85D2                    	test dx, dx			; >= 64 KiB ?
  6381 000026C6 7516                    	jnz .switch_y_error		; error -->
  6382 000026C8 5A                      	pop dx
  6383 000026C9 93                      	xchg bx, ax			; return bx = prior
  6384 000026CA 01C3                    	add bx, ax			; prior += next
  6385 000026CC 7210                    	jc .switch_y_error
  6386 000026CE EBCC                    	jmp .switch_y_num
  6387                                  
  6388                                  .switch_y_notdec:
  6389 000026D0 3C41                    	cmp al, 'A'			; alphabetic ?
  6390 000026D2 720A                    	jb .switch_y_error
  6391 000026D4 3C5A                    	cmp al, 'Z'
  6392 000026D6 7706                    	ja .switch_y_error
  6393 000026D8 04C9                    	add al, 10 - 'A'		; ax = digit
  6394 000026DA 39D0                    	cmp ax, dx
  6395 000026DC 72E2                    	jb .switch_y_gotdigit
  6396                                  	; jae .switch_y_error
  6397                                  .switch_y_error:
  6398                                  ..@init_cmdline_switch_y_error:
  6399 000026DE B059                    	mov al, 'Y'
  6400 000026E0 E92EFB                  	jmp ..@init_cmdline_switch_error
  6401                                  
  6402                                  .switch_y_base:
  6403 000026E3 83FB02                  	cmp bx, 2
  6404 000026E6 72F6                    	jb .switch_y_error
  6405 000026E8 83FB24                  	cmp bx, 36
  6406 000026EB 77F1                    	ja .switch_y_error
  6407 000026ED 89DA                    	mov dx, bx
  6408 000026EF EBA9                    	jmp .switch_y_zero
  6409                                  
  6410                                  .switch_y_check:
  6411                                  %ifn _LINK
  6412                                  	cmp bx, ext_data_max_size_equate
  6413                                  %else
  6414 000026F1 81FB[F0FF]              	cmp bx, strict word relocatedzero + 0FFF0h
  6415                                   wlcalc word_minusext_ext_data_area, equ $ - 2
  6416                                  %endif
  6417 000026F5 77E7                    	ja .switch_y_error
  6418                                  
  6419 000026F7 A8                      	db __TEST_IMM8			; (skip lodsb)
  6420                                  .switch_y_got.lodsb:
  6421 000026F8 AC                      	lodsb
  6422                                  .switch_y_got:
  6423 000026F9 1E                      	push ds
  6424 000026FA 07                      	pop es
  6425 000026FB 2E891E[140E]            	mov word [cs:init_extdata_want], bx
  6426 00002700 4E                      	dec si
  6427 00002701 E98CF9                  	jmp .blankloop
  6428                                  %endif
  6429                                  
  6430                                  
  6431                                  %if _HISTORY_SEPARATE_FIXED && _HISTORY
  6432                                  .switch_h:
  6433 00002704 BBF0FF                  	mov bx, 0FFF0h
  6434 00002707 AC                      	lodsb
  6435 00002708 3C09                    	cmp al, 9
  6436 0000270A 7503E9AA00              	je .switch_h_got
  6437 0000270F 3C20                    	cmp al, 32
  6438 00002711 7503E9A300              	je .switch_h_got
  6439 00002716 3C0D                    	cmp al, 13
  6440 00002718 7503E99C00              	je .switch_h_got
  6441 0000271D 3C3A                    	cmp al, ':'
  6442 0000271F 7404                    	je @F
  6443 00002721 3C3D                    	cmp al, '='
  6444 00002723 7501                    	jne @FF
  6445                                  @@:
  6446 00002725 AC                      	lodsb
  6447                                  @@:
  6448 00002726 4E                      	dec si
  6449 00002727 0E                      	push cs
  6450 00002728 07                      	pop es
  6451 00002729 BA[160F]                	mov dx, imsg.max
  6452 0000272C E81F0B                  	call init_isstring?
  6453 0000272F 7503E98400              	je .switch_h_got.lodsb
  6454 00002734 BB0401                  	mov bx, 260
  6455 00002737 BA[1A0F]                	mov dx, imsg.min
  6456 0000273A E8110B                  	call init_isstring?
  6457 0000273D 7479                    	je .switch_h_got.lodsb
  6458 0000273F BB0020                  	mov bx, _HISTORY_WANT_SIZE
  6459 00002742 BA[1E0F]                	mov dx, imsg.default
  6460 00002745 E8060B                  	call init_isstring?
  6461 00002748 746E                    	je .switch_h_got.lodsb
  6462                                  
  6463 0000274A BA1000                  	mov dx, 16
  6464 0000274D 803C23                  	cmp byte [si], '#'
  6465 00002750 7503                    	jne .switch_h_zero
  6466 00002752 46                      	inc si
  6467 00002753 B20A                    	mov dl, 10
  6468                                  .switch_h_zero:
  6469 00002755 31DB                    	xor bx, bx
  6470                                  .switch_h_num:
  6471 00002757 AC                      	lodsb
  6472 00002758 3C20                    	cmp al, 32			; end of number ?
  6473 0000275A 7450                    	je .switch_h_check
  6474 0000275C 3C09                    	cmp al, 9
  6475 0000275E 744C                    	je .switch_h_check
  6476 00002760 3C0D                    	cmp al, 13
  6477 00002762 7448                    	je .switch_h_check		; yes -->
  6478 00002764 3C5F                    	cmp al, '_'			; separator ?
  6479 00002766 74EF                    	je .switch_h_num
  6480 00002768 3C23                    	cmp al, '#'			; base change ?
  6481 0000276A 7432                    	je .switch_h_base
  6482 0000276C E8350B                  	call init_capitalise
  6483 0000276F B400                    	mov ah, 0
  6484 00002771 3C30                    	cmp al, '0'			; decimal digit ?
  6485 00002773 7224                    	jb .switch_h_error
  6486 00002775 3C39                    	cmp al, '9'
  6487 00002777 7712                    	ja .switch_h_notdec
  6488 00002779 2C30                    	sub al, '0'			; ax = digit
  6489                                  .switch_h_gotdigit:
  6490 0000277B 93                      	xchg ax, bx			; ax = prior
  6491 0000277C 52                      	push dx
  6492 0000277D F7E2                    	mul dx				; dx:ax = prior * base
  6493 0000277F 85D2                    	test dx, dx			; >= 64 KiB ?
  6494 00002781 7516                    	jnz .switch_h_error		; error -->
  6495 00002783 5A                      	pop dx
  6496 00002784 93                      	xchg bx, ax			; return bx = prior
  6497 00002785 01C3                    	add bx, ax			; prior += next
  6498 00002787 7210                    	jc .switch_h_error
  6499 00002789 EBCC                    	jmp .switch_h_num
  6500                                  
  6501                                  .switch_h_notdec:
  6502 0000278B 3C41                    	cmp al, 'A'			; alphabetic ?
  6503 0000278D 720A                    	jb .switch_h_error
  6504 0000278F 3C5A                    	cmp al, 'Z'
  6505 00002791 7706                    	ja .switch_h_error
  6506 00002793 04C9                    	add al, 10 - 'A'		; ax = digit
  6507 00002795 39D0                    	cmp ax, dx
  6508 00002797 72E2                    	jb .switch_h_gotdigit
  6509                                  	; jae .switch_h_error
  6510                                  .switch_h_error:
  6511                                  ..@init_cmdline_switch_h_error:
  6512 00002799 B048                    	mov al, 'H'
  6513 0000279B E973FA                  	jmp ..@init_cmdline_switch_error
  6514                                  
  6515                                  .switch_h_base:
  6516 0000279E 83FB02                  	cmp bx, 2
  6517 000027A1 72F6                    	jb .switch_h_error
  6518 000027A3 83FB24                  	cmp bx, 36
  6519 000027A6 77F1                    	ja .switch_h_error
  6520 000027A8 89DA                    	mov dx, bx
  6521 000027AA EBA9                    	jmp .switch_h_zero
  6522                                  
  6523                                  .switch_h_check:
  6524 000027AC 83FBF0                  	cmp bx, 0FFF0h
  6525 000027AF 77E8                    	ja .switch_h_error
  6526 000027B1 81FB0401                	cmp bx, 260
  6527 000027B5 72E2                    	jb .switch_h_error
  6528                                  
  6529 000027B7 A8                      	db __TEST_IMM8			; (skip lodsb)
  6530                                  .switch_h_got.lodsb:
  6531 000027B8 AC                      	lodsb
  6532                                  .switch_h_got:
  6533 000027B9 1E                      	push ds
  6534 000027BA 07                      	pop es
  6535 000027BB 2E891E[160E]            	mov word [cs:init_history_want], bx
  6536 000027C0 4E                      	dec si
  6537 000027C1 E9CCF8                  	jmp .blankloop
  6538                                  %endif
  6539                                  
  6540                                  
  6541                                  .switch_a:
  6542 000027C4 BB0060                  	mov bx, _AUXBUFFMAXSIZE
  6543 000027C7 AC                      	lodsb
  6544 000027C8 3C09                    	cmp al, 9
  6545 000027CA 7503E9A800              	je .switch_a_got
  6546 000027CF 3C20                    	cmp al, 32
  6547 000027D1 7503E9A100              	je .switch_a_got
  6548 000027D6 3C0D                    	cmp al, 13
  6549 000027D8 7503E99A00              	je .switch_a_got
  6550 000027DD 3C3A                    	cmp al, ':'
  6551 000027DF 7404                    	je @F
  6552 000027E1 3C3D                    	cmp al, '='
  6553 000027E3 7501                    	jne @FF
  6554                                  @@:
  6555 000027E5 AC                      	lodsb
  6556                                  @@:
  6557 000027E6 4E                      	dec si
  6558 000027E7 0E                      	push cs
  6559 000027E8 07                      	pop es
  6560 000027E9 BA[160F]                	mov dx, imsg.max
  6561 000027EC E85F0A                  	call init_isstring?
  6562 000027EF 7503E98200              	je .switch_a_got.lodsb
  6563 000027F4 BB1020                  	mov bx, _AUXBUFFSIZE
  6564 000027F7 BA[1A0F]                	mov dx, imsg.min
  6565 000027FA E8510A                  	call init_isstring?
  6566 000027FD 7477                    	je .switch_a_got.lodsb
  6567                                  	; default == minimum
  6568 000027FF BA[1E0F]                	mov dx, imsg.default
  6569 00002802 E8490A                  	call init_isstring?
  6570 00002805 746F                    	je .switch_a_got.lodsb
  6571                                  
  6572 00002807 BA1000                  	mov dx, 16
  6573 0000280A 803C23                  	cmp byte [si], '#'
  6574 0000280D 7503                    	jne .switch_a_zero
  6575 0000280F 46                      	inc si
  6576 00002810 B20A                    	mov dl, 10
  6577                                  .switch_a_zero:
  6578 00002812 31DB                    	xor bx, bx
  6579                                  .switch_a_num:
  6580 00002814 AC                      	lodsb
  6581 00002815 3C20                    	cmp al, 32			; end of number ?
  6582 00002817 7450                    	je .switch_a_check
  6583 00002819 3C09                    	cmp al, 9
  6584 0000281B 744C                    	je .switch_a_check
  6585 0000281D 3C0D                    	cmp al, 13
  6586 0000281F 7448                    	je .switch_a_check		; yes -->
  6587 00002821 3C5F                    	cmp al, '_'			; separator ?
  6588 00002823 74EF                    	je .switch_a_num
  6589 00002825 3C23                    	cmp al, '#'			; base change ?
  6590 00002827 7432                    	je .switch_a_base
  6591 00002829 E8780A                  	call init_capitalise
  6592 0000282C B400                    	mov ah, 0
  6593 0000282E 3C30                    	cmp al, '0'			; decimal digit ?
  6594 00002830 7224                    	jb .switch_a_error
  6595 00002832 3C39                    	cmp al, '9'
  6596 00002834 7712                    	ja .switch_a_notdec
  6597 00002836 2C30                    	sub al, '0'			; ax = digit
  6598                                  .switch_a_gotdigit:
  6599 00002838 93                      	xchg ax, bx			; ax = prior
  6600 00002839 52                      	push dx
  6601 0000283A F7E2                    	mul dx				; dx:ax = prior * base
  6602 0000283C 85D2                    	test dx, dx			; >= 64 KiB ?
  6603 0000283E 7516                    	jnz .switch_a_error		; error -->
  6604 00002840 5A                      	pop dx
  6605 00002841 93                      	xchg bx, ax			; return bx = prior
  6606 00002842 01C3                    	add bx, ax			; prior += next
  6607 00002844 7210                    	jc .switch_a_error
  6608 00002846 EBCC                    	jmp .switch_a_num
  6609                                  
  6610                                  .switch_a_notdec:
  6611 00002848 3C41                    	cmp al, 'A'			; alphabetic ?
  6612 0000284A 720A                    	jb .switch_a_error
  6613 0000284C 3C5A                    	cmp al, 'Z'
  6614 0000284E 7706                    	ja .switch_a_error
  6615 00002850 04C9                    	add al, 10 - 'A'		; ax = digit
  6616 00002852 39D0                    	cmp ax, dx
  6617 00002854 72E2                    	jb .switch_a_gotdigit
  6618                                  	; jae .switch_a_error
  6619                                  .switch_a_error:
  6620                                  ..@init_cmdline_switch_a_error:
  6621 00002856 B041                    	mov al, 'A'
  6622 00002858 E9B6F9                  	jmp ..@init_cmdline_switch_error
  6623                                  
  6624                                  .switch_a_base:
  6625 0000285B 83FB02                  	cmp bx, 2
  6626 0000285E 72F6                    	jb .switch_a_error
  6627 00002860 83FB24                  	cmp bx, 36
  6628 00002863 77F1                    	ja .switch_a_error
  6629 00002865 89DA                    	mov dx, bx
  6630 00002867 EBA9                    	jmp .switch_a_zero
  6631                                  
  6632                                  .switch_a_check:
  6633 00002869 81FB1020                	cmp bx, _AUXBUFFSIZE
  6634 0000286D 72E7                    	jb .switch_a_error
  6635 0000286F 81FB0060                	cmp bx, _AUXBUFFMAXSIZE
  6636 00002873 77E1                    	ja .switch_a_error
  6637                                  
  6638 00002875 A8                      	db __TEST_IMM8			; (skip lodsb)
  6639                                  .switch_a_got.lodsb:
  6640 00002876 AC                      	lodsb
  6641                                  .switch_a_got:
  6642 00002877 1E                      	push ds
  6643 00002878 07                      	pop es
  6644 00002879 2E891E[100E]            	mov word [cs:init_auxbuff_want], bx
  6645 0000287E 4E                      	dec si
  6646 0000287F E90EF8                  	jmp .blankloop
  6647                                  
  6648                                  
  6649                                  .switch_r:
  6650 00002882 AC                      	lodsb
  6651 00002883 3C3A                    	cmp al, ':'
  6652 00002885 7404                    	je @F
  6653 00002887 3C3D                    	cmp al, '='
  6654 00002889 7501                    	jne @FF
  6655                                  @@:
  6656 0000288B A8                      	db __TEST_IMM8			; skip dec
  6657                                  @@:
  6658 0000288C 4E                      	dec si
  6659 0000288D BA1000                  	mov dx, 16
  6660 00002890 31DB                    	xor bx, bx
  6661                                  .switch_r_num:
  6662 00002892 AC                      	lodsb
  6663 00002893 3C20                    	cmp al, 32			; end of number ?
  6664 00002895 743E                    	je .switch_r_check
  6665 00002897 3C09                    	cmp al, 9
  6666 00002899 743A                    	je .switch_r_check
  6667 0000289B 3C0D                    	cmp al, 13
  6668 0000289D 7436                    	je .switch_r_check		; yes -->
  6669 0000289F 3C5F                    	cmp al, '_'			; separator ?
  6670 000028A1 74EF                    	je .switch_r_num
  6671 000028A3 E8FE09                  	call init_capitalise
  6672 000028A6 B400                    	mov ah, 0
  6673 000028A8 3C30                    	cmp al, '0'			; decimal digit ?
  6674 000028AA 7224                    	jb .switch_r_error
  6675 000028AC 3C39                    	cmp al, '9'
  6676 000028AE 7712                    	ja .switch_r_notdec
  6677 000028B0 2C30                    	sub al, '0'			; ax = digit
  6678                                  .switch_r_gotdigit:
  6679 000028B2 93                      	xchg ax, bx			; ax = prior
  6680 000028B3 52                      	push dx
  6681 000028B4 F7E2                    	mul dx				; dx:ax = prior * base
  6682 000028B6 85D2                    	test dx, dx			; >= 64 KiB ?
  6683 000028B8 7516                    	jnz .switch_r_error		; error -->
  6684 000028BA 5A                      	pop dx
  6685 000028BB 93                      	xchg bx, ax			; return bx = prior
  6686 000028BC 01C3                    	add bx, ax			; prior += next
  6687 000028BE 7210                    	jc .switch_r_error
  6688 000028C0 EBD0                    	jmp .switch_r_num
  6689                                  
  6690                                  .switch_r_notdec:
  6691 000028C2 3C41                    	cmp al, 'A'			; alphabetic ?
  6692 000028C4 720A                    	jb .switch_r_error
  6693 000028C6 3C5A                    	cmp al, 'Z'
  6694 000028C8 7706                    	ja .switch_r_error
  6695 000028CA 04C9                    	add al, 10 - 'A'		; ax = digit
  6696 000028CC 39D0                    	cmp ax, dx
  6697 000028CE 72E2                    	jb .switch_r_gotdigit
  6698                                  	; jae .switch_r_error
  6699                                  .switch_r_error:
  6700                                  ..@init_cmdline_switch_r_error:
  6701 000028D0 B052                    	mov al, 'R'
  6702 000028D2 E93CF9                  	jmp ..@init_cmdline_switch_error
  6703                                  
  6704                                  .switch_r_check:
  6705                                  .switch_r_got:
  6706 000028D5 1E                      	push ds
  6707 000028D6 07                      	pop es
  6708 000028D7 2E891E[1E0E]            	mov word [cs:init_switch_r], bx
  6709 000028DC 4E                      	dec si
  6710 000028DD E9B0F7                  	jmp .blankloop
  6711                                  
  6712                                  
  6713                                  .noswitches:
  6714                                  .breakpoint:
  6715 000028E0 90                      	nop			; SMC in section init
  6716                                  		; Feed the remaining command line to the 'n' command.
  6717 000028E1 4E                      	dec si
  6718 000028E2 E8D509                  	call init_skipcomma
  6719 000028E5 4E                      	dec si
  6720 000028E6 56                      	push si
  6721                                  
  6722                                  
  6723                                  %assign ELD 0
  6724                                  %assign INTERC3 0
  6725                                  %assign PART1 1
  6726                                  %assign PART2 0
  6727                                  %assign PART3 0
  6728                                  %define init_data_segment cs
  6729                                  
  6730                                   %imacro internalcoderelocation 0-*.nolist
  6731                                   %endmacro
  6732                                   %imacro internaldatarelocation 0-*.nolist
  6733                                   %endmacro
  6734                                   %imacro linkdatarelocation 0-*.nolist
  6735                                   %endmacro
  6736                                   %define relocated(address) address
  6737                                  
  6738                                  %include "pathshar.asm"
     1                              <1> 
     2                              <1> %if 0
     3                              <1> 
     4                              <1> lDebug initialisation - Path analyse and search
     5                              <1> 
     6                              <1> Copyright (C) 2008-2025 E. C. Masloch
     7                              <1> 
     8                              <1> Usage of the works is permitted provided that this
     9                              <1> instrument is retained with the works, so that any entity
    10                              <1> that uses the works is notified of this instrument.
    11                              <1> 
    12                              <1> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <1> 
    14                              <1> %endif
    15                              <1> 
    16                              <1> 
    17                              <1> ; defines used:
    18                              <1> ; ELD = nonzero iff included by Extension for lDebug path.asm (for path.eld)
    19                              <1> ; INTERC3 = nonzero iff included by INTERC3 intercep.asm
    20                              <1> ; else included by lDebug init.asm
    21                              <1> ; PART1 = nonzero if to embed main code
    22                              <1> ; PART2 = nonzero if to embed subfunctions
    23                              <1> ; PART3 = nonzero if to embed imsg messages
    24                              <1> 
    25                              <1> %if PART1
    26                              <1> 		; INP:	si -> pathname followed by command line
    27                              <1> 		;	word [ss:sp] = si
    28                              <1> 		; OUT:	word [ss:sp] -> final buffer
    29                              <1> init_analyse_pathname:
    30 000028E7 89F3                <1> 	mov bx, si
    31 000028E9 31D2                <1> 	xor dx, dx
    32 000028EB B000                <1> 	mov al, 0
    33                              <1> @@:
    34 000028ED 3C2F                <1> 	cmp al, '/'
    35 000028EF 7410                <1> 	je .slash
    36 000028F1 3C5C                <1> 	cmp al, '\'
    37 000028F3 740C                <1> 	je .slash
    38 000028F5 3C3A                <1> 	cmp al, ':'
    39 000028F7 7408                <1> 	je .colon
    40 000028F9 3C2E                <1> 	cmp al, '.'
    41 000028FB 7507                <1> 	jne .next
    42                              <1> .dot:
    43 000028FD B201                <1> 	mov dl, 1		; set dl (fn with dot)
    44 000028FF EB03                <1> 	jmp .next
    45                              <1> 
    46                              <1> .slash:
    47                              <1> .colon:
    48 00002901 BA0001              <1> 	mov dx, 100h		; set dh (is a pathname), reset dl (fn with dot)
    49                              <1> .next:
    50 00002904 AC                  <1> 	lodsb
    51 00002905 E83708              <1> 	call init_ifsep
    52 00002908 75E3                <1> 	jne @B
    53 0000290A 4E                  <1> 	dec si			; bx -> name, si -> terminator
    54                              <1> 				; dh = nonzero if a pathname not just filename
    55                              <1> 				; dl = nonzero if filename contains a dot
    56 0000290B 16                  <1> 	push ss
    57 0000290C 07                  <1> 	pop es
    58 0000290D 89F1                <1> 	mov cx, si
    59 0000290F 29D9                <1> 	sub cx, bx		; es:bx -> name, cx = length
    60                              <1> 
    61                              <1> 
    62                              <1> init_check_warn_extension:
    63 00002911 52                  <1> 	push dx
    64 00002912 06                  <1> 	push es
    65                              <1> 
    66 00002913 84D2                <1> 	test dl, dl		; last component has a dot ?
    67 00002915 7433                <1> 	jz .done		; no, do not warn -->
    68                              <1> 
    69 00002917 2ED006[3C0E]        <1> 	rol byte [init_data_segment:init_switch_pw], 1
    70                              <1> internaldatarelocation
    71 0000291C 732C                <1> 	jnc .done		; warning disabled -->
    72                              <1> 
    73 0000291E 83F904              <1> 	cmp cx, 4		; can fit an expected extension ?
    74 00002921 7221                <1> 	jb .warn		; no, warn -->
    75                              <1> 
    76 00002923 83EE04              <1> 	sub si, 4		; -> possible extension
    77 00002926 0E                  <1> 	push init_data_segment
    78 00002927 07                  <1> 	pop es
    79 00002928 BF[420E]            <1> 	mov di, imsg.no_warn_extensions
    80                              <1> internaldatarelocation		; es:di -> allowed extensions
    81                              <1> .loop:
    82 0000292B B000                <1> 	mov al, 0
    83 0000292D 2E864504            <1> 	xchg byte [init_data_segment:di+4], al
    84                              <1> 				; NUL-terminate the candidate extension
    85 00002931 50                  <1> 	push ax
    86 00002932 89FA                <1> 	mov dx, di
    87 00002934 E81709              <1> 	call init_isstring?	; is it this one ?
    88 00002937 58                  <1> 	pop ax
    89 00002938 2E884504            <1> 	mov byte [init_data_segment:di+4], al
    90                              <1> 				; restore next extension text
    91 0000293C 740C                <1> 	je .done		; yes, do not warn -->
    92 0000293E AF                  <1> 	scasw
    93 0000293F AF                  <1> 	scasw			; di += 4
    94 00002940 84C0                <1> 	test al, al		; was last ?
    95 00002942 75E7                <1> 	jnz .loop
    96                              <1> .warn:
    97 00002944 BA[5C0E]            <1> 	mov dx, imsg.extension_warning
    98                              <1> internaldatarelocation
    99 00002947 E8EBF1              <1> 	call init_putsz_cs
   100                              <1> 
   101                              <1> .done:
   102 0000294A 07                  <1> 	pop es
   103 0000294B 5A                  <1> 	pop dx
   104                              <1> 
   105                              <1> 
   106                              <1> init_find_path:
   107                              <1> %if ELD
   108                              <1> 	extcallcall InDOS
   109                              <1> 	jnz .done_j
   110                              <1> 	testopt [relocateddata], tt_while
   111                              <1> linkdatarelocation internalflags_with_tt_while, -3
   112                              <1> 	jnz .done_j
   113                              <1> %endif
   114 0000294C 2E833E[180E]00      <1> 	cmp word [init_data_segment:		init_switch_p_low_pathsearch_high_guessextension], strict byte 0
   116                              <1> internaldatarelocation -3
   117 00002952 740E                <1> 	je .done_j
   118                              <1> 
   119 00002954 E30C                <1> 	jcxz .done_j		; if no filename given -->
   120                              <1> 
   121                              <1> 				; es:bx -> name, cx = length
   122 00002956 BF[0000]            <1> 	mov di, relocated(while_buffer)
   123                              <1> linkdatarelocation while_buffer	; ss:while_buffer -> prefix, ss:di -> after end
   124                              <1> 
   125 00002959 E80508              <1> 	call init_check_filename
   126 0000295C 736C                <1> 	jnc .found
   127                              <1> 
   128 0000295E 84F6                <1> 	test dh, dh
   129 00002960 7403                <1> 	jz @F
   130                              <1> .done_j:
   131 00002962 E99800              <1> 	jmp .done
   132                              <1> @@:
   133 00002965 2ED006[180E]        <1> 	rol byte [init_data_segment:init_switch_p_pathsearch], 1
   134                              <1> internaldatarelocation
   135 0000296A 73F6                <1> 	jnc .done_j
   136                              <1> 
   137                              <1> %if _DEVICE && _APPLICATION && ! ELD && ! INTERC3
   138 0000296C F606[0200]40        <1> 	testopt [internalflags6], dif6_device_mode
   139 00002971 7505                <1> 	jnz .device
   140                              <1> %endif
   141                              <1> %if _APPLICATION || ELD || INTERC3
   142 00002973 A12C00              <1> 	mov ax, [2Ch]
   143                              <1>  %if _DEVICE && ! ELD && ! INTERC3
   144 00002976 EB03                <1> 	jmp @F
   145                              <1>  %endif
   146                              <1> %endif
   147                              <1> 
   148                              <1> %if _DEVICE && ! ELD && ! INTERC3
   149                              <1> .device:
   150 00002978 E8F1E2              <1> 	call init_device_get_environment
   151                              <1> @@:
   152                              <1> %endif
   153                              <1> 
   154 0000297B 51                  <1> 	push cx
   155 0000297C BF[570E]            <1> 	mov di, imsg.varpath
   156                              <1> internaldatarelocation
   157 0000297F B90500              <1> 	mov cx, imsg.varpath.length
   158 00002982 E82208              <1> 	call init_findvar
   159 00002985 7275                <1> 	jc .done_pop
   160                              <1> 
   161                              <1> .pathloop:
   162 00002987 56                  <1> 	push si
   163 00002988 B98000              <1> 	mov cx, 128		; put a limit
   164                              <1> @@:
   165 0000298B AC                  <1> 	lodsb			; get next text
   166 0000298C 3C3B                <1> 	cmp al, ';'		; separator ?
   167 0000298E 7408                <1> 	je @F			; yes -->
   168 00002990 3C00                <1> 	cmp al, 0		; separator ?
   169 00002992 7404                <1> 	je @F			; yes -->
   170 00002994 E2F5                <1> 	loop @B			; loop up to limit
   171 00002996 EB5D                <1> 	jmp .pathtoolong	; error -->
   172                              <1> @@:
   173 00002998 89F1                <1> 	mov cx, si
   174 0000299A 49                  <1> 	dec cx			; -> terminator
   175 0000299B 5E                  <1> 	pop si			; -> content text
   176 0000299C 29F1                <1> 	sub cx, si		; = length excluding terminator
   177 0000299E 16                  <1> 	 push ss
   178 0000299F 07                  <1> 	 pop es
   179 000029A0 BF[0000]            <1> 	mov di, relocated(while_buffer)
   180                              <1> linkdatarelocation while_buffer	; es:di -> buffer
   181                              <1> 
   182 000029A3 B000                <1> 	mov al, 0		; no backslash if empty
   183 000029A5 E30A                <1> 	jcxz @FFF		; skip loop if empty -->
   184                              <1> @@:
   185 000029A7 AC                  <1> 	lodsb			; load from variable
   186 000029A8 3C2F                <1> 	cmp al, '/'		; forward slash ?
   187 000029AA 7502                <1> 	jne @F			; no -->
   188 000029AC B05C                <1> 	mov al, '\'		; replace by backslash
   189                              <1> @@:
   190 000029AE AA                  <1> 	stosb			; store
   191 000029AF E2F6                <1> 	loop @BB		; loop for cx = count
   192                              <1> @@:
   193 000029B1 3C5C                <1> 	cmp al, '\'		; trailing backslash ?
   194 000029B3 7403                <1> 	je @F			; yes -->
   195 000029B5 B05C                <1> 	mov al, '\'
   196 000029B7 AA                  <1> 	stosb			; append it
   197                              <1> @@:
   198 000029B8 59                  <1> 	pop cx
   199                              <1> 
   200 000029B9 1E                  <1> 	push ds
   201 000029BA 56                  <1> 	push si
   202                              <1> 				; ss = es, es:bx -> name, cx = length
   203                              <1> 				; ss:while_buffer -> prefix, ss:di -> after end
   204 000029BB E8A307              <1> 	call init_check_filename
   205 000029BE 5E                  <1> 	pop si
   206 000029BF 1F                  <1> 	pop ds			; ds:si -> terminator of path element
   207 000029C0 7308                <1> 	jnc .found
   208                              <1> 
   209 000029C2 AC                  <1> 	lodsb			; get terminator
   210 000029C3 3C3B                <1> 	cmp al, ';'		; semicolon ?
   211 000029C5 7536                <1> 	jne .done		; no -->
   212 000029C7 51                  <1> 	push cx
   213 000029C8 EBBD                <1> 	jmp .pathloop		; try next -->
   214                              <1> 
   215                              <1> 
   216                              <1> .found:
   217 000029CA 16                  <1> 	push ss
   218 000029CB 1F                  <1> 	pop ds			; ds => PSP
   219 000029CC 5E                  <1> 	 pop si
   220 000029CD 01CE                <1> 	add si, cx		; ds:si -> behind original name
   221 000029CF 16                  <1> 	push ss
   222 000029D0 07                  <1> 	pop es
   223 000029D1 4F                  <1> 	dec di			; es:di -> NUL
   224                              <1> %if INTERC3
   225                              <1> 	mov al, 32		; blank codepoint
   226                              <1> 	cmp byte [si], al	; <= 32 ?
   227                              <1> 	ja @F			; no, store a blank first -->
   228                              <1> %endif
   229 000029D2 EB07                <1> 	jmp @FF			; skip store on first iteration
   230                              <1> 
   231                              <1> @@:
   232 000029D4 81FF[FEFF]          <1> 	cmp di, relocated(while_buffer.end) - 2
   233                              <1> linkdatarelocation while_buffer.end
   234 000029D8 7713                <1> 	ja .toolong
   235 000029DA AA                  <1> 	stosb
   236                              <1> @@:
   237 000029DB AC                  <1> 	lodsb
   238 000029DC 3C00                <1> 	cmp al, 0
   239 000029DE 7404                <1> 	je @F
   240 000029E0 3C0D                <1> 	cmp al, 13
   241 000029E2 75F0                <1> 	jne @BB
   242                              <1> @@:			; (targeted from both directions)
   243 000029E4 B00D                <1> 	mov al, 13
   244 000029E6 AA                  <1> 	stosb
   245 000029E7 BE[0000]            <1> 	mov si, relocated(while_buffer)
   246                              <1> linkdatarelocation while_buffer
   247 000029EA 56                  <1> 	 push si		; offset for N/K command (kk)
   248 000029EB EB10                <1> 	jmp .done
   249                              <1> 
   250                              <1> .toolong:
   251 000029ED BA[A00E]            <1> 	mov dx, imsg.kktoolong
   252                              <1> internaldatarelocation
   253 000029F0 E842F1              <1> 	call init_putsz_cs
   254 000029F3 EBEF                <1> 	jmp @B
   255                              <1> 
   256                              <1> .pathtoolong:
   257                              <1>  %if ELD
   258                              <1> 	push ss
   259                              <1> 	pop ds
   260                              <1>  %endif
   261 000029F5 BA[D80E]            <1> 	mov dx, imsg.pathtoolong
   262                              <1> internaldatarelocation
   263 000029F8 E83AF1              <1> 	call init_putsz_cs
   264                              <1> 
   265 000029FB 58                  <1> 	pop ax			; (discard si)
   266                              <1> .done_pop:
   267 000029FC 58                  <1> 	pop ax			; (discard cx)
   268                              <1> .done:
   269                              <1> %endif
   270                              <1> 
   271                              <1> 
   272                              <1> %if PART2
   273                              <1> 		; Compare character with separators
   274                              <1> 		;
   275                              <1> 		; INP:	al = character
   276                              <1> 		; OUT:	ZR if al is CR, NUL, blank, tab, comma, semicolon, or equal sign
   277                              <1> 		;	ZR if switch character is a slash and al is a slash
   278                              <1> 		;	NZ else
   279                              <1> 		; REM:	This is only used for parsing FCBs.
   280                              <1> init_ifsep:
   281                              <1> 	cmp al, 0
   282                              <1> 	je .return
   283                              <1> 	cmp al, 13
   284                              <1> 	je .return
   285                              <1> 	cmp al, ';'
   286                              <1> 	je .return
   287                              <1> 	cmp al, 32
   288                              <1> 	je .return
   289                              <1> 	cmp al, 9
   290                              <1> 	je .return
   291                              <1> 	cmp al, ','
   292                              <1> 	je .return
   293                              <1> 	cmp al, '='
   294                              <1> 	je .return
   295                              <1> 	cmp al, byte [ss:relocated(swch1)]
   296                              <1> linkdatarelocation swch1
   297                              <1> .return:
   298                              <1> 	retn
   299                              <1> 
   300                              <1> 
   301                              <1> %if _APPLICATION || _DEVICE
   302                              <1> 		; INP:	es:bx -> name to try, cx = length
   303                              <1> 		;	dl = zero if to attempt filename extensions
   304                              <1> 		;	ss:while_buffer -> prefix, ss:di -> after
   305                              <1> 		; OUT:	NC if file found,
   306                              <1> 		;	 ss:while_buffer = name, ss:di -> after NUL
   307                              <1> 		;	CY if file not found
   308                              <1> 		;	ds = ss
   309                              <1> 		; CHG:	si, ax
   310                              <1> init_check_filename:
   311                              <1> 	push es
   312                              <1> 	push cx
   313                              <1> 
   314                              <1> 	push es
   315                              <1> 	pop ds
   316                              <1> 	mov si, bx		; ds:si -> name
   317                              <1> 	 push ss
   318                              <1> 	 pop es			; es:di -> where to append name
   319                              <1> 	rep movsb		; append the name
   320                              <1> 	push di			; on stack: at initial terminator
   321                              <1> 	mov si, imsg.p_extensions
   322                              <1> internaldatarelocation
   323                              <1> 				; cs:si -> extensions to try
   324                              <1> .loop:
   325                              <1> 	mov al, 0
   326                              <1> 	stosb			; zero-terminate name
   327                              <1> 	mov ax, 4300h		; get attributes
   328                              <1> 	push dx
   329                              <1> 	 push ss
   330                              <1> 	 pop ds
   331                              <1> 	mov dx, relocated(while_buffer)	; ds:dx -> pathname to try
   332                              <1> linkdatarelocation while_buffer
   333                              <1> 	stc
   334                              <1> %if ELD
   335                              <1> 	extcallcall _doscall
   336                              <1> %else
   337                              <1> 	int 21h			; try to get attributes
   338                              <1> %endif
   339                              <1> 	jc @F			; not found --> CY
   340                              <1> 	test cl, 10h		; directory ?
   341                              <1> 	jz @F			; no --> NC
   342                              <1> 	stc			; yes, handle as not found: CY
   343                              <1> @@:
   344                              <1> 	pop dx
   345                              <1> 	jnc .ret		; --> (NC)
   346                              <1> 	test dl, dl		; had an extension originally ?
   347                              <1> 	jnz .ret_CY		; yes, do not try to append one -->
   348                              <1> 	rol byte [init_data_segment:init_switch_p_guessextension], 1
   349                              <1> internaldatarelocation
   350                              <1> 	jnc .ret_CY		; if no guessing extension -->
   351                              <1> 	pop di
   352                              <1> 	push di
   353                              <1> 	cmp byte [init_data_segment:si], 0
   354                              <1> 				; last attempt done ?
   355                              <1> 	je .ret_CY		; yes -->
   356                              <1> 	init_data_segment movsw	; ".C"
   357                              <1> 	init_data_segment movsw	; "OM"
   358                              <1> 	jmp .loop
   359                              <1> 
   360                              <1> .ret_CY:
   361                              <1> 	stc			; CY
   362                              <1> .ret:
   363                              <1> 	pop ax			; (discard)
   364                              <1> 	pop cx
   365                              <1> 	pop es
   366                              <1> 	retn
   367                              <1> %endif
   368                              <1> 
   369                              <1> 
   370                              <1> 		; INP:	ax => environment, zero if none
   371                              <1> 		;	cs:di -> variable name, including '=' terminator
   372                              <1> 		;	cx = variable name length, including '=' terminator
   373                              <1> 		; OUT:	CY if not found
   374                              <1> 		;	NC if found,
   375                              <1> 		;	 ds:si -> behind '=' of found variable
   376                              <1> 		; CHG:	ax, es, di, ds, si, cx
   377                              <1> init_findvar:
   378                              <1> 	test ax, ax
   379                              <1> 	jz .notvar
   380                              <1> 	mov ds, ax
   381                              <1> 	xor si, si
   382                              <1> 
   383                              <1> @@:
   384                              <1> 	push init_data_segment
   385                              <1> 	pop es
   386                              <1> 	push cx
   387                              <1> 	push di
   388                              <1> 	push si
   389                              <1> 	repe cmpsb
   390                              <1> 	je .foundvar		; --> (NC)
   391                              <1> 	pop si
   392                              <1> 	pop di
   393                              <1> 	pop cx
   394                              <1> 	call init_nextvar
   395                              <1> 	jnz @B
   396                              <1> .notvar:
   397                              <1> 	stc
   398                              <1> 	retn
   399                              <1> 
   400                              <1> .foundvar:
   401                              <1> 	pop ax
   402                              <1> 	pop ax
   403                              <1> 	pop ax
   404                              <1> 	retn
   405                              <1> 
   406                              <1> 
   407                              <1> init_nextvar:
   408                              <1> @@:
   409                              <1> 	lodsb
   410                              <1> 	test al, al
   411                              <1> 	jnz @B
   412                              <1> 	cmp byte [si], 0
   413                              <1> 	retn
   414                              <1> %endif
   415                              <1> 
   416                              <1> 
   417                              <1> %if PART3
   418                              <1>  %if INTERC3
   419                              <1>   %define _PROGNAME ""
   420                              <1>  %endif
   421                              <1> 	align 2, db 0
   422                              <1> .no_warn_extensions:
   423                              <1>  %ifn INTERC3
   424                              <1> 		db ".HEX",".ROM"
   425                              <1>  %endif
   426                              <1> %if (($ - .no_warn_extensions) % 4) != 0
   427                              <1>  %error Wrong extensions length
   428                              <1> %endif
   429                              <1> .p_extensions:	db ".COM"
   430                              <1> 		db ".EXE"
   431                              <1>  %ifn INTERC3
   432                              <1> 		db ".BIN"
   433                              <1>  %endif
   434                              <1> 		asciz
   435                              <1> %if (($ - 1 - .p_extensions) % 4) != 0
   436                              <1>  %error Wrong extensions length
   437                              <1> %endif
   438                              <1> .varpath:	db "PATH="
   439                              <1> .varpath.length equ $ - .varpath
   440                              <1> .extension_warning:
   441                              <1> %ifn ELD
   442                              <1> 	db _PROGNAME,": "
   443                              <1> %endif
   444                              <1> 	asciz "Warning, unknown filename extension specified!",13,10
   445                              <1> .kktoolong:
   446                              <1> %ifn ELD
   447                              <1> 	db _PROGNAME,": "
   448                              <1> %endif
   449                              <1> 	asciz "Error, too long command line tail!",13,10
   450                              <1> .pathtoolong:
   451                              <1> %ifn ELD
   452                              <1> 	db _PROGNAME,": "
   453                              <1> %endif
   454                              <1> 	asciz "Error, too long %PATH% variable element!",13,10
   455                              <1> %endif
  6739                                  
  6740                                   %undef extcall
  6741                                   %undef extcallcall
  6742                                   %unimacro internalcoderelocation 0-*.nolist
  6743                                   %unimacro internaldatarelocation 0-*.nolist
  6744                                   %unimacro linkdatarelocation 0-*.nolist
  6745                                   %undef relocated
  6746                                  
  6747                                  
  6748                                  %if _APP_ENV_SIZE
  6749                                  init_copy_app_env:
  6750 000029FD 16                      	push ss
  6751 000029FE 1F                      	pop ds
  6752                                   %if _DEVICE
  6753 000029FF F606[0200]40            	testopt [internalflags6], dif6_device_mode
  6754 00002A04 755F                    	jnz .skip
  6755                                   %endif
  6756 00002A06 2EC706[080E]8000        	mov word [cs:mem_envsize], paras(app_env_size)
  6757 00002A0D 8B16[0000]              	mov dx, word [envseg]		; => pseudo MCB
  6758 00002A11 42                      	inc dx				; => space for environment
  6759 00002A12 A12C00                  	mov ax, word [2Ch]
  6760 00002A15 1E                      	push ds
  6761 00002A16 85C0                    	test ax, ax
  6762 00002A18 7446                    	jz @F
  6763 00002A1A 8ED8                    	mov ds, ax
  6764 00002A1C 8EC2                    	mov es, dx
  6765 00002A1E 31FF                    	xor di, di
  6766 00002A20 31F6                    	xor si, si
  6767                                  .loop_env:
  6768 00002A22 E8A107                  	call init_nextvar
  6769 00002A25 75FB                    	jne .loop_env
  6770 00002A27 46                      	inc si
  6771 00002A28 AD                      	lodsw
  6772 00002A29 83F801                  	cmp ax, 1
  6773 00002A2C 7504                    	jne .notrail
  6774 00002A2E E89507                  	call init_nextvar
  6775 00002A31 A9                      	db __TEST_IMM16
  6776                                  .notrail:
  6777 00002A32 4E                      	dec si
  6778 00002A33 4E                      	dec si
  6779 00002A34 81FEEE07                	cmp si, app_env_size - 16 - 2
  6780 00002A38 7610                    	jbe .copy_env
  6781 00002A3A BA[410F]                	mov dx, imsg.app_env_too_large
  6782 00002A3D E8F5F0                  	call init_putsz_cs
  6783                                  .no_reloc:
  6784 00002A40 2EC606[410E]FF          	mov byte [cs:app_env_allocation], 0FFh
  6785 00002A46 8CDA                    	mov dx, ds
  6786 00002A48 EB16                    	jmp @F
  6787                                  
  6788                                  .copy_env:
  6789 00002A4A 2ED006[400E]            	rol byte [cs:init_switch_t_variable], 1
  6790 00002A4F 72EF                    	jc .no_reloc
  6791 00002A51 89F1                    	mov cx, si
  6792 00002A53 31F6                    	xor si, si
  6793 00002A55 F3A4                    	rep movsb
  6794 00002A57 31C0                    	xor ax, ax
  6795 00002A59 AB                      	stosw
  6796 00002A5A 1E                      	push ds
  6797 00002A5B 07                      	pop es
  6798 00002A5C B449                    	mov ah, 49h
  6799 00002A5E CD21                    	int 21h
  6800                                  @@:
  6801 00002A60 1F                      	pop ds
  6802 00002A61 89162C00                	mov word [2Ch], dx
  6803                                  
  6804                                  .skip:
  6805                                  %endif
  6806                                  
  6807                                  
  6808                                  init_relocate_init:
  6809 00002A65 16                      	push ss
  6810 00002A66 1F                      	pop ds
  6811 00002A67 16                      	push ss
  6812 00002A68 07                      	pop es
  6813                                  %if _AUXBUFFSIZE != _AUXBUFFMAXSIZE
  6814 00002A69 2EA1[100E]              	mov ax, word [cs:init_auxbuff_want]
  6815 00002A6D 83C00F                  	add ax, 15			; cannot carry, ax <= _AUXBUFFMAXSIZE
  6816 00002A70 24F0                    	and al, 0F0h
  6817 00002A72 B104                    	mov cl, 4
  6818 00002A74 89C3                    	mov bx, ax
  6819 00002A76 D3EB                    	shr bx, cl
  6820 00002A78 BEFFFD                  	mov si, - paras(_AUXBUFFSIZE)
  6821 00002A7B 01DE                    	add si, bx			; want size - init size = how much to add
  6822 00002A7D 31D2                    	xor dx, dx			; always positive
  6823                                  %else
  6824                                  	xor si, si			; = 0
  6825                                  	xor dx, dx
  6826                                  %endif
  6827                                  
  6828                                  %if _EXTENSIONS
  6829 00002A7F 2EA1[140E]              	mov ax, word [cs:init_extdata_want]
  6830 00002A83 83C00F                  	add ax, 15
  6831 00002A86 24F0                    	and al, 0F0h
  6832                                  
  6833 00002A88 B104                    	mov cl, 4
  6834 00002A8A 89C3                    	mov bx, ax
  6835 00002A8C D3EB                    	shr bx, cl
  6836 00002A8E BF00FC                  	mov di, - paras(_EXT_DATA_BOOT_SIZE)
  6837 00002A91 01DF                    	add di, bx			; want size - init size = how much to add
  6838                                  					;  negative if to subtract
  6839 00002A93 19DB                    	sbb bx, bx			; -1 if >= 0 to add
  6840 00002A95 F7D3                    	not bx				; -1 if negative
  6841 00002A97 01FE                    	add si, di
  6842 00002A99 11DA                    	adc dx, bx			; add positive or negative dword
  6843                                  
  6844                                  
  6845 00002A9B 2EA1[120E]              	mov ax, word [cs:init_ext_want]
  6846 00002A9F 83C00F                  	add ax, 15
  6847 00002AA2 24F0                    	and al, 0F0h
  6848                                  
  6849 00002AA4 B104                    	mov cl, 4
  6850 00002AA6 89C3                    	mov bx, ax
  6851 00002AA8 D3EB                    	shr bx, cl
  6852 00002AAA BF00FE                  	mov di, - paras(_EXT_CODE_INIT_SIZE)
  6853 00002AAD 01DF                    	add di, bx			; want size - init size = how much to add
  6854                                  					;  negative if to subtract
  6855 00002AAF 19DB                    	sbb bx, bx			; -1 if >= 0 to add
  6856 00002AB1 F7D3                    	not bx
  6857 00002AB3 01FE                    	add si, di
  6858 00002AB5 11DA                    	adc dx, bx			; add positive or negative dword
  6859                                  %endif
  6860                                  
  6861                                  %if _HISTORY_SEPARATE_FIXED && _HISTORY
  6862 00002AB7 2EA1[160E]              	mov ax, word [cs:init_history_want]
  6863 00002ABB 83C00F                  	add ax, 15
  6864 00002ABE 24F0                    	and al, 0F0h
  6865                                  
  6866 00002AC0 B104                    	mov cl, 4
  6867 00002AC2 89C3                    	mov bx, ax
  6868 00002AC4 D3EB                    	shr bx, cl
  6869 00002AC6 BF00FE                  	mov di, - paras(historysegment_size)
  6870 00002AC9 01DF                    	add di, bx			; want size - init size = how much to add
  6871                                  					;  negative if to subtract
  6872 00002ACB 19DB                    	sbb bx, bx			; -1 if >= 0 to add
  6873 00002ACD F7D3                    	not bx				; -1 if negative
  6874 00002ACF 01FE                    	add si, di
  6875 00002AD1 11DA                    	adc dx, bx			; add positive or negative dword
  6876                                  %endif
  6877                                  
  6878 00002AD3 85D2                    	test dx, dx			; add paras is negative ?
  6879 00002AD5 7567                    	jnz .done			; yes -->
  6880 00002AD7 85F6                    	test si, si
  6881 00002AD9 7463                    	jz .done			; if to add == 0 -->
  6882                                  
  6883                                  .reloc:
  6884 00002ADB 2E0336[060E]            	add si, word [cs:memsize]	; = new memsize
  6885 00002AE0 7256                    	jc .error
  6886 00002AE2 8CD8                    	mov ax, ds
  6887 00002AE4 01C6                    	add si, ax			; => past want alloc
  6888 00002AE6 7250                    	jc .error
  6889                                  %if _DEVICE
  6890 00002AE8 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  6891 00002AED 7403                    	jz @F
  6892 00002AEF 46                      	inc si				; account for container paragraph
  6893 00002AF0 7446                    	jz .error
  6894                                  @@:
  6895                                  %endif
  6896 00002AF2 8CCB                    	mov bx, cs
  6897 00002AF4 39DE                    	cmp si, bx			; below-or-equal cs ?
  6898 00002AF6 7646                    	jbe .done			; yes, no need to relocate -->
  6899                                  
  6900                                  %ifn _LINK
  6901                                  	mov cx, init_size_p		; size of init
  6902                                  %else
  6903 00002AF8 B9[0000]                	mov cx, relocatedzero + 0
  6904                                   wlcalc word_wrt_INIT_extpara_behind_init, equ $ - 2
  6905                                  %endif
  6906 00002AFB 01CB                    	add bx, cx			; => minimum init reloc target
  6907 00002AFD 39DE                    	cmp si, bx
  6908 00002AFF 7602                    	jbe .havetarget
  6909 00002B01 89F3                    	mov bx, si			; => needed init reloc target
  6910                                  
  6911                                  .havetarget:
  6912 00002B03 89DA                    	mov dx, bx			; dx => target
  6913 00002B05 01CB                    	add bx, cx			; bx => behind target
  6914 00002B07 722F                    	jc .error
  6915                                  %if _DEVICE
  6916 00002B09 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  6917 00002B0E 7409                    	jz @F
  6918 00002B10 2E3B1E[0E0E]            	cmp bx, word [cs:dev_memory_end]; enough space ?
  6919 00002B15 7721                    	ja .error			; no -->
  6920 00002B17 EB14                    	jmp .movp
  6921                                  
  6922                                  @@:
  6923                                  %endif
  6924 00002B19 8CD8                    	mov ax, ds
  6925 00002B1B 29C3                    	sub bx, ax			; = amount paragraphs needed
  6926 00002B1D 2E891E[220E]            	mov word [cs:init_target_size], bx
  6927 00002B22 2E891E[200E]            	mov word [cs:init_base_size], bx
  6928 00002B27 B44A                    	mov ah, 4Ah
  6929 00002B29 CD21                    	int 21h				; resize memory block = es
  6930 00002B2B 720B                    	jc .error			; if error -->
  6931                                  
  6932                                  .movp:
  6933 00002B2D 8CC8                    	mov ax, cs
  6934 00002B2F E872EF                  	call init_movp			; move init
  6935 00002B32 52                      	push dx				; => relocated init
  6936 00002B33 E8D5D6                  	call init_retf			; ttansfer control
  6937 00002B36 EB06                    	jmp .done			; done
  6938                                  
  6939                                  .error:
  6940 00002B38 BA[DA0F]                	mov dx, imsg.init_relocate_failure
  6941 00002B3B E9C1F6                  	jmp ..@init_cmdline_error
  6942                                  
  6943                                  .done:
  6944                                  
  6945                                  
  6946                                  init_change_auxbuff_size:
  6947 00002B3E 16                      	push ss
  6948 00002B3F 1F                      	pop ds
  6949 00002B40 16                      	push ss
  6950 00002B41 07                      	pop es
  6951                                  %if _AUXBUFFSIZE != _AUXBUFFMAXSIZE
  6952 00002B42 2EA1[100E]              	mov ax, word [cs:init_auxbuff_want]
  6953 00002B46 83C00F                  	add ax, 15			; cannot carry, ax <= _AUXBUFFMAXSIZE
  6954 00002B49 24F0                    	and al, 0F0h
  6955                                  
  6956 00002B4B 89C7                    	mov di, ax
  6957 00002B4D 83EF18                  	sub di, 8 * 3
  6958 00002B50 A3[0000]                	mov word [auxbuff_current_size], ax
  6959 00002B53 893E[0000]              	mov word [auxbuff_current_size_minus_24], di
  6960                                  
  6961 00002B57 B104                    	mov cl, 4
  6962 00002B59 89C3                    	mov bx, ax
  6963 00002B5B D3EB                    	shr bx, cl
  6964 00002B5D BEFFFD                  	mov si, - paras(_AUXBUFFSIZE)
  6965 00002B60 01DE                    	add si, bx
  6966 00002B62 740E                    	jz @F				; if to keep minimum size
  6967                                  
  6968                                  		; INP:	ax = wanted size (rounded to paragraph boundary)
  6969                                  		;	bx = wanted size paragraphs
  6970                                  		;	si = bx - paragraphs of minimum size = how much to enlarge
  6971                                  		;	ip -> function depending on layout
  6972                                  		; STT:	ss = ds = es
  6973                                  		; OUT:	NC if success
  6974                                  		;	CY if error, branch to command line error
  6975 00002B64 2EFF16[0C0E]            	call near [cs:init_layout]
  6976 00002B69 16                      	push ss
  6977 00002B6A 1F                      	pop ds
  6978 00002B6B 16                      	push ss
  6979 00002B6C 07                      	pop es
  6980 00002B6D 7303E9E4FC              	jc ..@init_cmdline_switch_a_error
  6981                                  @@:
  6982                                  %endif
  6983                                  
  6984                                  
  6985                                  %if _EXTENSIONS
  6986                                  init_change_extdata_size_and_init:
  6987 00002B72 2EA1[140E]              	mov ax, word [cs:init_extdata_want]
  6988 00002B76 83C00F                  	add ax, 15
  6989 00002B79 24F0                    	and al, 0F0h
  6990 00002B7B A3[0000]                	mov word [extdata_size], ax
  6991                                  
  6992 00002B7E 89C1                    	mov cx, ax
  6993 00002B80 81E90040                	sub cx, fromparas(paras(_EXT_DATA_BOOT_SIZE))
  6994 00002B84 010E[0000]              	add word [entryseg_size], cx
  6995                                  
  6996 00002B88 B104                    	mov cl, 4
  6997 00002B8A 89C3                    	mov bx, ax
  6998 00002B8C D3EB                    	shr bx, cl
  6999 00002B8E BE0004                  	mov si, paras(_EXT_DATA_BOOT_SIZE)
  7000 00002B91 29DE                    	sub si, bx			; init size - want
  7001                                  		; negative if larger want than init
  7002 00002B93 7503E98100              	jz .keep			; if to keep init size
  7003 00002B98 19FF                    	sbb di, di			; -1 if negative
  7004 00002B9A F7D7                    	not di				; -1 if positive (smaller want than init)
  7005 00002B9C 2E893E[1C0E]            	mov word [cs:relocate_down], di	; relocating down if smaller want
  7006                                  
  7007 00002BA1 2E8B0E[060E]            	mov cx, word [cs:memsize]	; how many paragraphs do we have
  7008                                   %if _DEVICE
  7009 00002BA6 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  7010 00002BAB 7401                    	jz @F
  7011 00002BAD 41                      	inc cx				; account for container paragraph
  7012                                  @@:
  7013                                   %endif
  7014 00002BAE 2E2936[060E]            	sub word [cs:memsize], si
  7015                                  
  7016 00002BB3 8CD8                    	mov ax, ds
  7017                                  %ifn _LINK
  7018                                  	add ax, paras(100h + DATAENTRYTABLESIZE + datastack_size)
  7019                                  	mov dx, ax
  7020                                  	sub dx, si
  7021                                  	sub cx, paras(100h + DATAENTRYTABLESIZE + datastack_size)
  7022                                  %else
  7023 00002BB5 05[0000]                	add ax, strict word relocatedzero + 0
  7024                                   wlcalc word_wrt_@@lDEBUG_DATA_ENTRY@_extpara_end_of_datastack, equ $ - 2
  7025 00002BB8 89C2                    	mov dx, ax
  7026 00002BBA 29F2                    	sub dx, si
  7027 00002BBC 81E9[0000]              	sub cx, strict word relocatedzero + 0
  7028                                   wlcalc word_wrt_@@lDEBUG_DATA_ENTRY@_extpara_end_of_datastack, equ $ - 2
  7029                                  %endif
  7030 00002BC0 E8E1EE                  	call init_movp
  7031                                  
  7032                                   %if _DEVICE
  7033 00002BC3 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  7034 00002BC8 7416                    	jz @F
  7035                                  
  7036 00002BCA 2936[0000]              	sub word [device_mcb_paragraphs], si
  7037                                  					; fix our variable
  7038 00002BCE 2936[0000]              	sub word [alloc_size], si	; this one too
  7039 00002BD2 8E06[0000]              	mov es, word [reg_es]
  7040 00002BD6 8B1E[0000]              	mov bx, word [reg_ebx]		; -> device request header
  7041 00002BDA 26297710                	sub word [es:bx + 0Eh + 2], si	; -> behind memory in use
  7042 00002BDE 16                      	push ss
  7043 00002BDF 07                      	pop es
  7044                                   %endif
  7045                                  @@:
  7046                                  
  7047 00002BE0 F7DE                    	neg si
  7048                                  
  7049                                  %if _HISTORY_SEPARATE_FIXED && _HISTORY
  7050                                  .relocate_history:
  7051 00002BE2 0136[0000]              	add word [history.segorsel + soaSegSel], si
  7052                                  %if _PM
  7053                                  	add word [history.segorsel + soaSegment], si
  7054                                  %endif
  7055                                  %endif
  7056                                  
  7057                                  %if _APP_ENV_SIZE || _DEV_ENV_SIZE
  7058                                  .relocate_env:
  7059 00002BE6 2ED006[410E]            	rol byte [cs:app_env_allocation], 1
  7060 00002BEB 7204                    	jc @F
  7061 00002BED 01362C00                	add word [2Ch], si
  7062                                  @@:
  7063 00002BF1 833E[0000]00            	cmp word [envseg], 0
  7064 00002BF6 7404                    	je @F
  7065 00002BF8 0136[0000]              	add word [envseg], si
  7066                                  @@:
  7067                                  %endif
  7068                                  
  7069                                  %if _EXTENSIONS
  7070                                  .relocate_ext:
  7071 00002BFC 0136[0000]              	add word [extseg], si
  7072                                  %endif
  7073                                  
  7074                                  .relocate_code:
  7075 00002C00 A1[0000]                	mov ax, word [code_seg]
  7076 00002C03 89C2                    	mov dx, ax
  7077 00002C05 01F2                    	add dx, si
  7078                                  
  7079 00002C07 8EC2                    	mov es, dx
  7080 00002C09 0136[0000]              	add word [code_seg], si
  7081                                  %if _DUALCODE
  7082                                  	add word [code2_seg], si
  7083                                  	mov dx, word [code2_seg]
  7084                                  	push si
  7085                                   %if ! _PM
  7086                                  	mov si, relocate_from_code
  7087                                  	mov di, relocate_from_code.end
  7088                                  	call .relocate_code_patch
  7089                                  	mov si, relocate_from_code2
  7090                                  	mov di, relocate_from_code2.end
  7091                                   %endif
  7092                                  	push es
  7093                                  	mov es, dx
  7094                                  	pop dx
  7095                                   %if ! _PM
  7096                                  	call .relocate_code_patch
  7097                                  	jmp .relocate_code_done
  7098                                  
  7099                                  .relocate_code_loop:
  7100                                  	cs lodsw
  7101                                  	xchg bx, ax
  7102                                  	mov word [es:bx], dx
  7103                                  .relocate_code_patch:
  7104                                  	cmp si, di
  7105                                  	jb .relocate_code_loop
  7106                                  	retn
  7107                                  
  7108                                  .relocate_code_done:
  7109                                   %endif
  7110                                  	pop si
  7111                                  %endif
  7112                                  
  7113                                  %if _AREAS && _AREAS_HOOK_CLIENT
  7114                                  	mov ax, si
  7115                                  	mov dx, word [cs:relocate_down]
  7116                                  	call add_to_areas_linear_code1.dxax
  7117                                   %if _DUALCODE && _EXPRDUALCODE
  7118                                  	mov ax, si
  7119                                  	mov dx, word [cs:relocate_down]
  7120                                  	call add_to_areas_linear_code2.dxax
  7121                                   %endif
  7122                                  %endif
  7123                                  
  7124                                  
  7125                                  .relocate_auxbuff:
  7126 00002C0D 0136[0000]              	add word [auxbuff_segorsel + soaSegSel], si
  7127                                  %if _PM
  7128                                  	add word [auxbuff_segorsel + soaSegment], si
  7129                                  					; initialise auxbuff references
  7130                                  %endif
  7131                                  %if _IMMASM  && _IMMASM_AUXBUFF
  7132                                  	add word [immseg], si
  7133                                  %endif
  7134                                  
  7135                                  
  7136                                  %if _MESSAGESEGMENT
  7137                                  .relocate_messagesegment:
  7138 00002C11 0136[0000]              	add word [messageseg], si
  7139                                   %if _HELP_COMPRESSED && ! _PM
  7140 00002C15 0136[0000]              	add word [hshrink_memory_source.segment], si
  7141                                   %endif
  7142                                  %endif
  7143                                  
  7144                                  .keep:
  7145 00002C19 8B0E[0000]              	mov cx, word [extdata_size]
  7146 00002C1D 16                      	push ss
  7147 00002C1E 07                      	pop es
  7148 00002C1F BF[0000]                	mov di, ext_data_area
  7149 00002C22 B000                    	mov al, 0
  7150 00002C24 F3AA                    	rep stosb			; init ext data area
  7151                                  %endif
  7152                                  
  7153                                  
  7154                                  %if _EXTENSIONS
  7155                                  init_change_ext_size:
  7156 00002C26 2EA1[120E]              	mov ax, word [cs:init_ext_want]
  7157 00002C2A 83C00F                  	add ax, 15
  7158 00002C2D 24F0                    	and al, 0F0h
  7159 00002C2F A3[0000]                	mov word [extseg_size], ax
  7160                                  
  7161 00002C32 B104                    	mov cl, 4
  7162 00002C34 89C3                    	mov bx, ax
  7163 00002C36 D3EB                    	shr bx, cl
  7164 00002C38 BE0002                  	mov si, paras(_EXT_CODE_INIT_SIZE)
  7165 00002C3B 29DE                    	sub si, bx			; init size - want
  7166                                  		; negative if larger want than init
  7167 00002C3D 7441                    	jz @F				; if to keep init size
  7168                                  
  7169 00002C3F 2E2936[060E]            	sub word [cs:memsize], si
  7170                                  
  7171 00002C44 85F6                    	test si, si
  7172 00002C46 7911                    	jns .smaller
  7173 00002C48 BF0020                  	mov di, _EXT_CODE_INIT_SIZE
  7174 00002C4B 8E06[0000]              	mov es, word [extseg]
  7175 00002C4F 8B0E[0000]              	mov cx, word [extseg_size]
  7176 00002C53 29F9                    	sub cx, di
  7177 00002C55 B000                    	mov al, 0
  7178 00002C57 F3AA                    	rep stosb			; init trailer
  7179                                  .smaller:
  7180                                  
  7181                                   %if _DEVICE
  7182 00002C59 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  7183 00002C5E 7420                    	jz @F
  7184                                  
  7185 00002C60 2936[0000]              	sub word [device_mcb_paragraphs], si
  7186                                  					; fix our variable
  7187 00002C64 2936[0000]              	sub word [alloc_size], si	; this one too
  7188 00002C68 8CD8                    	mov ax, ds			; => PSP
  7189 00002C6A 2E0306[060E]            	add ax, word [cs:memsize]	; => where to place container sig
  7190 00002C6F E8D2DE                  	call init_dev_place_container_signature
  7191                                  					; CHG: es, di, cx, si
  7192                                  					; ax => behind memory used for device
  7193 00002C72 8E06[0000]              	mov es, word [reg_es]
  7194 00002C76 8B1E[0000]              	mov bx, word [reg_ebx]		; -> device request header
  7195 00002C7A 26894710                	mov word [es:bx + 0Eh + 2], ax	; -> behind memory in use
  7196 00002C7E 16                      	push ss
  7197 00002C7F 07                      	pop es
  7198                                   %endif
  7199                                  @@:
  7200                                  %endif
  7201                                  
  7202                                  
  7203                                  %if _HISTORY_SEPARATE_FIXED && _HISTORY
  7204                                  init_change_history_size:
  7205 00002C80 2EA1[160E]              	mov ax, word [cs:init_history_want]
  7206 00002C84 83C00F                  	add ax, 15
  7207 00002C87 24F0                    	and al, 0F0h
  7208 00002C89 A3[0000]                	mov word [historyseg_size], ax
  7209 00002C8C 89C3                    	mov bx, ax
  7210                                  
  7211 00002C8E 48                      	dec ax
  7212 00002C8F 48                      	dec ax
  7213 00002C90 A3[0000]                	mov word [history.first], ax
  7214 00002C93 A3[0000]                	mov word [history.last], ax
  7215                                  
  7216 00002C96 B104                    	mov cl, 4
  7217 00002C98 D3EB                    	shr bx, cl
  7218 00002C9A BE0002                  	mov si, paras(historysegment_size)
  7219 00002C9D 29DE                    	sub si, bx			; init size - want
  7220                                  		; negative if larger want than init
  7221 00002C9F 7467                    	jz .keep			; if to keep init size
  7222 00002CA1 19FF                    	sbb di, di			; -1 if negative
  7223 00002CA3 F7D7                    	not di				; -1 if positive (smaller want than init)
  7224 00002CA5 2E893E[1C0E]            	mov word [cs:relocate_down], di	; relocating down if smaller want
  7225                                  
  7226 00002CAA 2E8B0E[060E]            	mov cx, word [cs:memsize]	; how many paragraphs do we have
  7227                                   %if _DEVICE
  7228 00002CAF F606[0200]40            	testopt [internalflags6], dif6_device_mode
  7229 00002CB4 7401                    	jz @F
  7230 00002CB6 41                      	inc cx				; account for container paragraph
  7231                                  @@:
  7232                                   %endif
  7233 00002CB7 2E2936[060E]            	sub word [cs:memsize], si
  7234                                  
  7235 00002CBC 8CD8                    	mov ax, ds
  7236 00002CBE 01C1                    	add cx, ax
  7237 00002CC0 A1[0000]                	mov ax, word [history.segorsel + soaSegSel]
  7238 00002CC3 89C2                    	mov dx, ax
  7239 00002CC5 050002                  	add ax, paras(historysegment_size)
  7240                                  					; => source
  7241 00002CC8 01DA                    	add dx, bx			; => destination
  7242 00002CCA 29C1                    	sub cx, ax
  7243 00002CCC E8D5ED                  	call init_movp
  7244                                  
  7245                                   %if _DEVICE
  7246 00002CCF F606[0200]40            	testopt [internalflags6], dif6_device_mode
  7247 00002CD4 7416                    	jz @F
  7248                                  
  7249 00002CD6 2936[0000]              	sub word [device_mcb_paragraphs], si
  7250                                  					; fix our variable
  7251 00002CDA 2936[0000]              	sub word [alloc_size], si	; this one too
  7252 00002CDE 8E06[0000]              	mov es, word [reg_es]
  7253 00002CE2 8B1E[0000]              	mov bx, word [reg_ebx]		; -> device request header
  7254 00002CE6 26297710                	sub word [es:bx + 0Eh + 2], si	; -> behind memory in use
  7255 00002CEA 16                      	push ss
  7256 00002CEB 07                      	pop es
  7257                                   %endif
  7258                                  @@:
  7259                                  
  7260 00002CEC F7DE                    	neg si
  7261                                  
  7262                                  %if _APP_ENV_SIZE || _DEV_ENV_SIZE
  7263                                  .relocate_env:
  7264 00002CEE 2ED006[410E]            	rol byte [cs:app_env_allocation], 1
  7265 00002CF3 7204                    	jc @F
  7266 00002CF5 01362C00                	add word [2Ch], si
  7267                                  @@:
  7268 00002CF9 833E[0000]00            	cmp word [envseg], 0
  7269 00002CFE 7404                    	je @F
  7270 00002D00 0136[0000]              	add word [envseg], si
  7271                                  @@:
  7272                                  %endif
  7273                                  
  7274                                  %if _EXTENSIONS
  7275                                  .relocate_ext:
  7276 00002D04 0136[0000]              	add word [extseg], si
  7277                                  %endif
  7278                                  
  7279                                  .keep:
  7280 00002D08 8B0E[0000]              	mov cx, word [historyseg_size]
  7281 00002D0C 8E06[0000]              	mov es, word [history.segorsel + soaSegSel]
  7282 00002D10 31FF                    	xor di, di
  7283 00002D12 B000                    	mov al, 0
  7284 00002D14 F3AA                    	rep stosb			; init history buffer
  7285                                  %endif
  7286                                  
  7287                                  
  7288                                  init_relocate:
  7289 00002D16 2ED006[3D0E]            	rol byte [cs:init_switch_t], 1
  7290 00002D1B 7203E9C901              	jnc .done_outer
  7291                                  %if _DEVICE
  7292 00002D20 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  7293 00002D25 7403E9B901              	jnz .error_outer
  7294                                  %endif
  7295                                  
  7296 00002D2A 2ED006[3F0E]            	rol byte [cs:init_switch_t_break], 1
  7297 00002D2F 7301                    	jnc @F
  7298 00002D31 CC                      	int3
  7299                                  @@:
  7300                                  
  7301 00002D32 B80258                  		mov ax, 5802h			; Get UMB link state
  7302 00002D35 CD21                    		int 21h
  7303 00002D37 30E4                    		xor ah, ah
  7304 00002D39 50                      		push ax				; Save UMB link state
  7305 00002D3A B80058                  		mov ax, 5800h			; Get allocation strategy
  7306 00002D3D CD21                    		int 21h
  7307 00002D3F 50                      		push ax				; Save allocation strategy
  7308                                  
  7309 00002D40 31FF                    	xor di, di				; first set
  7310                                  .retry_alloc:
  7311 00002D42 B80358                  		mov ax, 5803h			; Set UMB link state:
  7312 00002D45 2E8B9D[240E]            		mov bx, [cs:init_switch_t_umblink + di]
  7313 00002D4A 83FBFF                  		cmp bx, -1			; not set ?
  7314 00002D4D 7503E96D01              		je .error_no_alloc_retry	; then error out -->
  7315 00002D52 CD21                    		int 21h
  7316 00002D54 B80158                  		mov ax, 5801h			; Set allocation strategy:
  7317 00002D57 2E8B9D[2A0E]            		mov bx, [cs:init_switch_t_strategy + di]
  7318 00002D5C CD21                    		int 21h
  7319                                  
  7320                                  		; allocate new memory block for process
  7321 00002D5E 2E8B1E[060E]            	mov bx, word [cs:memsize]
  7322 00002D63 B448                    	mov ah, 48h
  7323 00002D65 CD21                    	int 21h
  7324 00002D67 7303E95301              	jc .error_no_alloc_retry
  7325                                  
  7326 00002D6C 92                      	xchg dx, ax			; dx => new process block
  7327                                  
  7328                                  		; allocate new memory block for environment
  7329                                  %if _APP_ENV_SIZE
  7330 00002D6D 2ED006[410E]            	rol byte [cs:app_env_allocation], 1
  7331 00002D72 732D                    	jnc @F
  7332                                  %endif
  7333 00002D74 A12C00                  	mov ax, word [2Ch]
  7334 00002D77 85C0                    	test ax, ax			; zero ?
  7335 00002D79 7426                    	jz .allocated			; yes, nothing to relocate -->
  7336 00002D7B 48                      	dec ax
  7337 00002D7C 8EC0                    	mov es, ax			; es => MCB
  7338 00002D7E 268B1E0300              	mov bx, word [es:3]		; = MCB size
  7339 00002D83 B448                    	mov ah, 48h
  7340 00002D85 CD21                    	int 21h				; allocate
  7341 00002D87 7303E92D01              	jc .error_no_alloc_retry_free_dx
  7342                                  
  7343                                  		; relocate environment
  7344 00002D8C 52                      	push dx
  7345 00002D8D 92                      	xchg dx, ax			; dx => target
  7346 00002D8E A12C00                  	mov ax, word [2Ch]		; ax => source
  7347 00002D91 89D9                    	mov cx, bx			; cx = amount paragraphs
  7348 00002D93 E80EED                  	call init_movp
  7349 00002D96 89162C00                	mov word [2Ch], dx		; relocate environment
  7350 00002D9A 5A                      	pop dx				; => process memory block target
  7351 00002D9B 8EC0                    	mov es, ax
  7352 00002D9D B449                    	mov ah, 49h
  7353 00002D9F CD21                    	int 21h				; explicitly free old environment
  7354                                  					;  (not needed depending on method)
  7355                                  @@:
  7356                                  
  7357                                  .allocated:	; dx => new process block
  7358 00002DA1 8CD0                    	mov ax, ss			; => source process block
  7359 00002DA3 2E8B0E[060E]            	mov cx, word [cs:memsize]	; cx = amount paragraphs
  7360 00002DA8 2E890E[220E]            	mov word [cs:init_target_size], cx
  7361 00002DAD E8F4EC                  	call init_movp
  7362                                  
  7363 00002DB0 2EA3[1A0E]              	mov word [cs:relocate_source], ax
  7364 00002DB4 48                      	dec ax
  7365 00002DB5 1E                      	push ds
  7366 00002DB6 8ED8                    	mov ds, ax			; ds => original block MCB
  7367 00002DB8 89160100                	mov word [1], dx		; set original block owner to new
  7368                                  
  7369 00002DBC 89D0                    	mov ax, dx
  7370 00002DBE 48                      	dec ax
  7371 00002DBF 8EC0                    	mov es, ax			; es => new block MCB
  7372 00002DC1 2689160100              	mov word [es:1], dx		; set new block owner to new
  7373                                  
  7374 00002DC6 BF0800                  	mov di, 8		; es:di-> MCB name field
  7375 00002DC9 89FE                    	mov si, di
  7376 00002DCB A5                      	movsw
  7377 00002DCC A5                      	movsw
  7378 00002DCD A5                      	movsw
  7379 00002DCE A5                      	movsw			; Force MCB string
  7380 00002DCF 1F                      	pop ds			; restore => old block
  7381                                  
  7382 00002DD0 A12C00                  	mov ax, word [2Ch]		; => environment, or zero
  7383 00002DD3 85C0                    	test ax, ax
  7384 00002DD5 7408                    	jz @F
  7385 00002DD7 48                      	dec ax
  7386 00002DD8 8EC0                    	mov es, ax			; => environment MCB
  7387 00002DDA 2689160100              	mov word [es:1], dx		; set environment block owner to new
  7388                                  @@:
  7389                                  
  7390 00002DDF 8CD0                    	mov ax, ss			; ax => old PSP
  7391 00002DE1 8ED2                    	mov ss, dx			; relocate stack
  7392 00002DE3 90                      	nop
  7393                                  					; ds still => old PSP
  7394 00002DE4 92                      	xchg ax, dx			; ax => new PSP, dx => old PSP
  7395                                  
  7396                                  		; code from ecm TSR
  7397 00002DE5 8EC0                    	mov es, ax		; es = new PSP
  7398 00002DE7 BF1800                  	mov di, 18h
  7399 00002DEA B91400                  	mov cx, 20
  7400 00002DED 26A33600                	mov word [ es:34h+2 ], ax
  7401 00002DF1 26893E3400              	mov word [ es:34h ], di	; fix the new PSP's PHT pointer
  7402 00002DF6 26890E3200              	mov word [ es:32h ], cx	;  and the count of PHT entries field
  7403 00002DFB 50                      	 push ax
  7404 00002DFC B0FF                    	mov al, -1
  7405 00002DFE 57                      	 push di
  7406 00002DFF 89CB                    	mov bx, cx		; = 20
  7407 00002E01 F3AA                    	rep stosb		; initialise new PHT with empty entries
  7408 00002E03 5F                      	 pop di
  7409 00002E04 8B0E3200                	mov cx, word [ 32h ]	; cx = count of PHT entries
  7410 00002E08 39D9                    	cmp cx, bx		; >= 20 ?
  7411 00002E0A 7202                    	jb .shortertable	; no -->
  7412 00002E0C 89D9                    	mov cx, bx		; limit to 20
  7413                                  .shortertable:
  7414 00002E0E C5363400                	lds si, [ 34h ]		; ds:si-> old PHT
  7415 00002E12 56                      	push si
  7416 00002E13 51                      	push cx
  7417 00002E14 F3A4                    	rep movsb		; get all entries
  7418 00002E16 59                      	pop cx
  7419 00002E17 5F                      	pop di
  7420 00002E18 1E                      	 push ds
  7421 00002E19 07                      	 pop es			; es:di-> old PHT
  7422 00002E1A F3AA                    	rep stosb		; fill moved entries with -1 (closed)
  7423 00002E1C 58                      	 pop ax
  7424 00002E1D 8EDA                    	mov ds, dx		; ds = old PSP
  7425 00002E1F C7060A00[542E]          	mov word [ 0Ah ], .terminated
  7426 00002E25 8C0E0C00                	mov word [ 0Ah+2 ], cs	; Parent Return Address -> us
  7427                                  %if 0		; (not used)
  7428                                  	mov word [ 0Eh ], i23
  7429                                  	mov word [ 0Eh+2 ], ax
  7430                                  	mov word [ 12h ], i24
  7431                                  	mov word [ 12h+2 ], ax	; set interrupt vectors to ours
  7432                                  %endif
  7433 00002E29 A31600                  	mov word [ 16h ], ax	; set parent PSP to the relocated one
  7434 00002E2C 36A33000                	mov word [ ss:2Eh+2 ], ax
  7435                                  				; set SS used by process termination
  7436                                  
  7437 00002E30 93                      	xchg ax, bx		; bx = new location, dx = old location
  7438 00002E31 B85D33                  	mov ax, 335Dh
  7439 00002E34 CD21                    	int 21h			; PSP relocated call-out
  7440                                  
  7441                                  		; In order to set the correct stack address here,
  7442                                  		; the last Int21 call to a usual function (such as
  7443                                  		; Int21.48, .49) must've been made with the same stack
  7444                                  		; pointer as the Int21.4C call below gets.
  7445                                  		;
  7446                                  		; Update: dosemu2 does weird things to the stack.
  7447                                  		;  In particular, it inserts an additional iret
  7448                                  		;  frame depending on some conditions.
  7449                                  		; Only the interrupt 21h subfunctions 00h, 26h,
  7450                                  		;  31h, 4Bh, and 4Ch are handled differently.
  7451                                  		;  As a workaround we can call service 4Bh as the
  7452                                  		;  last interrupt 21h function before terminating.
  7453                                  		; Refer to https://github.com/dosemu2/dosemu2/blob/d7402eec84478c051d25e7b26dd8515514c186e2/src/base/core/int.c#L1633-L1639
  7454                                  
  7455                                  	; rol byte [j_flags.invalidexec], 1
  7456                                  	; jnc @F
  7457                                  
  7458 00002E36 0E                      	push cs
  7459 00002E37 1F                      	pop ds
  7460 00002E38 BA[4E2E]                	mov dx, .nullbyte	; just in case, ds:dx -> zero value byte
  7461 00002E3B B87F4B                  	mov ax, 4B7Fh		; 21.4B with invalid subfunction in al
  7462                                  				;  (note that FreeDOS masks off 80h)
  7463 00002E3E CD21                    	int 21h
  7464                                  @@:
  7465                                  
  7466 00002E40 2E8E06[1A0E]            	mov es, word [cs:relocate_source]
  7467 00002E45 26FF362E00              	push word [ es:2Eh ]
  7468 00002E4A 368F062E00              	pop word [ ss:2Eh ]	; set SP used by process termination
  7469                                  .nullbyte: equ $ - 1
  7470                                  
  7471 00002E4F B8004C                  	mov ax, 4C00h
  7472 00002E52 CD21                    	int 21h			; terminate, and make the new PSP active
  7473                                  				; also handles freeing all memory allocated to the old PSP
  7474                                  				; also closes any handles >20 if PHT larger
  7475                                  			; (not used) also relocates Int23, Int24
  7476                                  				; also notifies resident software old PSP is no longer valid
  7477                                  .terminated:			; (ax, bx, es might be changed)
  7478 00002E54 16                      	push ss
  7479 00002E55 1F                      	pop ds
  7480 00002E56 16                      	push ss
  7481 00002E57 07                      	pop es
  7482                                  		; end code from ecm TSR
  7483                                  
  7484                                  
  7485                                  .relocate:
  7486 00002E58 2E8326[1C0E]00          	and word [cs:relocate_down], 0	; = 0
  7487 00002E5E 8CD6                    	mov si, ss
  7488 00002E60 2E2B36[1A0E]            	sub si, word [cs:relocate_source]
  7489 00002E65 7305                    	jnc @F
  7490 00002E67 2EF716[1C0E]            	not word [cs:relocate_down]	; = 0FFFFh
  7491                                  @@:
  7492                                  		; target - source = delta
  7493                                  		; delta + source = target
  7494                                  		;  because target - source + source = target
  7495                                  
  7496                                  %if _HISTORY_SEPARATE_FIXED && _HISTORY
  7497                                  .relocate_history:
  7498 00002E6C 0136[0000]              	add word [history.segorsel + soaSegSel], si
  7499                                  %if _PM
  7500                                  	add word [history.segorsel + soaSegment], si
  7501                                  %endif
  7502                                  %endif
  7503                                  
  7504                                  %if _APP_ENV_SIZE
  7505                                  .relocate_env:
  7506 00002E70 2ED006[410E]            	rol byte [cs:app_env_allocation], 1
  7507 00002E75 7204                    	jc @F
  7508 00002E77 01362C00                	add word [2Ch], si
  7509                                  @@:
  7510 00002E7B 833E[0000]00            	cmp word [envseg], 0
  7511 00002E80 7404                    	je @F
  7512 00002E82 0136[0000]              	add word [envseg], si
  7513                                  @@:
  7514                                  %endif
  7515                                  
  7516                                  %if _EXTENSIONS
  7517                                  .relocate_ext:
  7518 00002E86 0136[0000]              	add word [extseg], si
  7519                                  %endif
  7520                                  
  7521                                  .relocate_code:
  7522 00002E8A A1[0000]                	mov ax, word [code_seg]
  7523 00002E8D 89C2                    	mov dx, ax
  7524 00002E8F 01F2                    	add dx, si
  7525                                  
  7526 00002E91 8EC2                    	mov es, dx
  7527 00002E93 0136[0000]              	add word [code_seg], si
  7528                                  %if _DUALCODE
  7529                                  	add word [code2_seg], si
  7530                                  	mov dx, word [code2_seg]
  7531                                  	push si
  7532                                   %if ! _PM
  7533                                  	mov si, relocate_from_code
  7534                                  	mov di, relocate_from_code.end
  7535                                  	call .relocate_code_patch
  7536                                  	mov si, relocate_from_code2
  7537                                  	mov di, relocate_from_code2.end
  7538                                   %endif
  7539                                  	push es
  7540                                  	mov es, dx
  7541                                  	pop dx
  7542                                   %if ! _PM
  7543                                  	call .relocate_code_patch
  7544                                  	jmp .relocate_code_done
  7545                                  
  7546                                  .relocate_code_loop:
  7547                                  	cs lodsw
  7548                                  	xchg bx, ax
  7549                                  	mov word [es:bx], dx
  7550                                  .relocate_code_patch:
  7551                                  	cmp si, di
  7552                                  	jb .relocate_code_loop
  7553                                  	retn
  7554                                  
  7555                                  .relocate_code_done:
  7556                                   %endif
  7557                                  	pop si
  7558                                  %endif
  7559                                  
  7560                                  %if _AREAS && _AREAS_HOOK_CLIENT
  7561                                  	mov ax, si
  7562                                  	mov dx, word [cs:relocate_down]
  7563                                  	call add_to_areas_linear_code1.dxax
  7564                                   %if _DUALCODE && _EXPRDUALCODE
  7565                                  	mov ax, si
  7566                                  	mov dx, word [cs:relocate_down]
  7567                                  	call add_to_areas_linear_code2.dxax
  7568                                   %endif
  7569                                  %endif
  7570                                  
  7571                                  
  7572                                  .relocate_auxbuff:
  7573 00002E97 0136[0000]              	add word [auxbuff_segorsel + soaSegSel], si
  7574                                  %if _PM
  7575                                  	add word [auxbuff_segorsel + soaSegment], si
  7576                                  					; initialise auxbuff references
  7577                                  %endif
  7578                                  %if _IMMASM  && _IMMASM_AUXBUFF
  7579                                  	add word [immseg], si
  7580                                  %endif
  7581                                  
  7582                                  
  7583                                  %if _MESSAGESEGMENT
  7584                                  .relocate_messagesegment:
  7585 00002E9B 0136[0000]              	add word [messageseg], si
  7586                                   %if _HELP_COMPRESSED && ! _PM
  7587 00002E9F 0136[0000]              	add word [hshrink_memory_source.segment], si
  7588                                   %endif
  7589                                  %endif
  7590                                  
  7591                                  
  7592                                  .relocate_old_initcode_variables:
  7593 00002EA3 8CD8                    	mov ax, ds
  7594 00002EA5 A3[0200]                	mov word [execblk.cmdline + 2], ax
  7595 00002EA8 A3[0200]                	mov word [execblk.fcb1 + 2], ax
  7596 00002EAB A3[0200]                	mov word [execblk.fcb2 + 2], ax	; set up parameter block for exec command
  7597 00002EAE A3[0000]                	mov word [pspdbg], ax
  7598                                  
  7599                                  %if _IMMASM  && !_IMMASM_AUXBUFF
  7600                                   %ifn _LINK
  7601                                  	add ax, (immasm_buffer + DATASECTIONFIXUP) >> 4
  7602                                   %else
  7603 00002EB1 05[0000]                	add ax, strict word immasm_buffer
  7604                                   wlcalc word_shr_4, equ $ - 2
  7605                                   %endif
  7606 00002EB4 A3[0000]                	mov word [immseg], ax
  7607                                  %endif
  7608                                  
  7609                                  
  7610                                  %if _AREAS_HOOK_SERVER
  7611                                  .relocate_areas:
  7612                                  	mov ax, ds
  7613                                  	mov word [ddebugareas.next + 2], ax
  7614                                  	mov word [ddebugareas.prev + 2], ax
  7615                                  	mov word [..@patch_entry_seg], ax
  7616                                  %endif
  7617                                  
  7618                                  
  7619                                  .relocate_done:
  7620 00002EB7 EB16                    	jmp .done
  7621                                  
  7622                                  
  7623                                  		; environment could not be allocated
  7624                                  .error_no_alloc_retry_free_dx:
  7625 00002EB9 8EC2                    	mov es, dx
  7626 00002EBB B449                    	mov ah, 49h
  7627 00002EBD CD21                    	int 21h				; free allocated block
  7628                                  
  7629                                  		; some memory could not be allocated
  7630                                  .error_no_alloc_retry:
  7631 00002EBF AF                      	scasw				; di += 2
  7632 00002EC0 83FF06                  	cmp di, 6
  7633 00002EC3 7303E97AFE              	jb .retry_alloc
  7634                                  
  7635                                  .error_no_retry:
  7636 00002EC8 2ED006[3E0E]            	rol byte [cs:init_switch_t_ignore], 1
  7637 00002ECD 7301                    	jnc .error
  7638                                  
  7639                                  .done:
  7640 00002ECF A8                      	db __TEST_IMM8			; (skip stc, NC)
  7641                                  .error:
  7642 00002ED0 F9                      	stc				; CY
  7643                                  .status:
  7644 00002ED1 19D2                    	sbb dx, dx				; 0 = NC, -1 = CY
  7645 00002ED3 5B                      		pop bx				; saved allocation strategy
  7646 00002ED4 B80158                  		mov ax, 5801h
  7647 00002ED7 CD21                    		int 21h				; Set allocation strategy
  7648 00002ED9 5B                      		pop bx				; saved UMB link state
  7649 00002EDA B80358                  		mov ax, 5803h
  7650 00002EDD CD21                    		int 21h				; Set UMB link state
  7651 00002EDF 85D2                    	test dx, dx
  7652 00002EE1 7406                    	jz .done_outer
  7653                                  .error_outer:
  7654 00002EE3 BA[B20F]                	mov dx, imsg.relocate_failure
  7655 00002EE6 E916F3                  	jmp ..@init_cmdline_error
  7656                                  
  7657                                  .done_outer:
  7658                                  
  7659                                  
  7660                                  %if _EXECUTABLE
  7661                                  init_executable:
  7662 00002EE9 16                      	push ss
  7663 00002EEA 1F                      	pop ds
  7664 00002EEB 16                      	push ss
  7665 00002EEC 07                      	pop es
  7666 00002EED F606[0200]40            	testopt [internalflags6], dif6_device_mode
  7667 00002EF2 7539                    	jnz .device
  7668                                  
  7669                                  .application:
  7670 00002EF4 8B162C00                	mov dx, word [2Ch]
  7671 00002EF8 85D2                    	test dx, dx
  7672 00002EFA 746B                    	jz .unable
  7673 00002EFC 8EC2                    	mov es, dx
  7674 00002EFE B90080                  	mov cx, 8000h
  7675 00002F01 31F6                    	xor si, si
  7676                                  @@:
  7677 00002F03 E81900                  	call .nextvar
  7678 00002F06 725F                    	jc .unable
  7679 00002F08 75F9                    	jne @B
  7680 00002F0A 46                      	inc si
  7681 00002F0B 26AD                    	es lodsw
  7682 00002F0D 83F801                  	cmp ax, 1
  7683 00002F10 7555                    	jne .unable
  7684                                  
  7685 00002F12 06                      	push es
  7686 00002F13 1F                      	pop ds				; => env
  7687 00002F14 16                      	push ss
  7688 00002F15 07                      	pop es				; => data entry
  7689 00002F16 BF[0000]                	mov di, init_executable_pathname
  7690 00002F19 B460                    	mov ah, 60h
  7691 00002F1B CD21                    	int 21h
  7692 00002F1D EB48                    	jmp .done
  7693                                  
  7694                                  .nextvar:
  7695                                  @@:
  7696 00002F1F 26AC                    	es lodsb
  7697 00002F21 84C0                    	test al, al
  7698 00002F23 E0FA                    	loopnz @B
  7699 00002F25 F9                      	stc
  7700 00002F26 7504                    	jnz @F
  7701 00002F28 26803C00                	cmp byte [es:si], 0
  7702                                  @@:
  7703 00002F2C C3                      	retn
  7704                                  
  7705                                  
  7706                                  .device:
  7707 00002F2D 8B36[0000]              	mov si, word [reg_ebx]
  7708 00002F31 8E1E[0000]              	mov ds, word [reg_es]
  7709 00002F35 C57412                  	lds si, [si + 12h]
  7710                                  
  7711 00002F38 89F7                    	mov di, si
  7712                                  @@:
  7713 00002F3A AC                      	lodsb
  7714 00002F3B 3C20                    	cmp al, 32
  7715 00002F3D 7412                    	je @F
  7716 00002F3F 3C09                    	cmp al, 9
  7717 00002F41 740E                    	je @F
  7718 00002F43 3C00                    	cmp al, 0
  7719 00002F45 740A                    	je @F
  7720 00002F47 3C0D                    	cmp al, 13
  7721 00002F49 7406                    	je @F
  7722 00002F4B 3C0A                    	cmp al, 10
  7723 00002F4D 7402                    	je @F
  7724 00002F4F EBE9                    	jmp @B
  7725                                  
  7726                                  @@:
  7727 00002F51 FF74FF                  	push word [si - 1]
  7728 00002F54 56                      	push si
  7729 00002F55 C644FF00                	mov byte [si - 1], 0
  7730 00002F59 89FE                    	mov si, di
  7731 00002F5B BF[0000]                	mov di, init_executable_pathname
  7732 00002F5E B460                    	mov ah, 60h
  7733 00002F60 CD21                    	int 21h
  7734 00002F62 5E                      	pop si
  7735 00002F63 58                      	pop ax
  7736 00002F64 8844FF                  	mov byte [si - 1], al
  7737                                  
  7738                                  .done:
  7739                                  .unable:
  7740 00002F67 16                      	push ss
  7741 00002F68 1F                      	pop ds
  7742 00002F69 16                      	push ss
  7743 00002F6A 07                      	pop es
  7744                                  
  7745 00002F6B BF[0000]                	mov di, init_executable_pathname
  7746 00002F6E 31C0                    	xor ax, ax
  7747 00002F70 B98000                  	mov cx, 128
  7748 00002F73 F2AE                    	repne scasb
  7749 00002F75 4F                      	dec di
  7750 00002F76 893E[0000]              	mov word [init_executable_pathname.end], di
  7751                                  %endif
  7752                                  
  7753                                  
  7754                                  init_hook_interrupts:
  7755                                  %if CATCHINTAMOUNT
  7756                                  		; Set up interrupt vectors.
  7757                                  %if _CATCHINT06 && _DETECT95LX
  7758 00002F7A 8B0E[0000]              	mov cx, word [inttab_number_variable]
  7759                                  %else
  7760                                  	mov cx, inttab_number
  7761                                  %endif
  7762 00002F7E E30D                    	jcxz .intend
  7763 00002F80 BE[0000]                	mov si, inttab
  7764                                  .intloop:
  7765 00002F83 AC                      	lodsb
  7766 00002F84 B435                    	mov ah, 35h
  7767 00002F86 CD21                    	int 21h			; get vector
  7768 00002F88 97                      	xchg ax, di
  7769 00002F89 AD                      	lodsw
  7770 00002F8A 97                      	xchg ax, di
  7771                                  %if _DEBUG && !_DEBUG_COND
  7772                                  				; vectors are set only when debuggee runs
  7773                                  %else
  7774                                   %if _DEBUG
  7775                                  	testopt [internalflags6], dif6_debug_mode
  7776                                  	jnz @F
  7777                                   %endif
  7778                                  	mov word [ di + ieNext ], bx
  7779                                  	mov word [ di + ieNext + 2 ], es
  7780                                  				; store it
  7781                                  	mov dx, di
  7782                                  	mov ah, 25h		; set interrupt vector
  7783                                  	int 21h			; ds => lDEBUG_DATA_ENTRY
  7784                                  @@:
  7785                                  %endif
  7786 00002F8B E2F6                    	loop .intloop
  7787                                  
  7788                                  .intend:
  7789                                  %endif
  7790                                  
  7791                                  
  7792                                  		; Disabled this. hook2F (debug.asm) now detects this condition.
  7793                                  %if _PM && 0
  7794                                  		; Windows 9x and DosEmu are among those hosts which handle some
  7795                                  		; V86 Ints internally without first calling the interrupt chain.
  7796                                  		; This causes various sorts of troubles and incompatibilities;
  7797                                  		; in our case, hooking interrupt 2Fh would not intercept calls
  7798                                  		; made to the DPMI interface because the host sees them first.
  7799                                   %if _WIN9XSUPP
  7800                                    %if _GUARD_86M_INT2F
  7801                                  	push es
  7802                                  	xor ax, ax
  7803                                  	mov es, ax		; (only used in 86 Mode)
  7804                                  	mov ax, [es:2Fh * 4]
  7805                                  	cmp ax, -1
  7806                                  	je @F			; --> (ZR)
  7807                                  	or ax, [es:2Fh * 4 + 2]
  7808                                  @@:
  7809                                  	pop es
  7810                                  	jz @F
  7811                                    %endif
  7812                                  	mov ax, 1600h		; running in a Win9x DOS box?
  7813                                  	int 2Fh
  7814                                  	cmp al, 4
  7815                                  	jge .no2Fhook		; this is intentionally a signed comparison!
  7816                                  @@:
  7817                                   %endif
  7818                                   %if _DOSEMU
  7819                                  	testopt [internalflags], runningdosemu
  7820                                  	jnz .no2Fhook
  7821                                   %endif
  7822                                   %if _WIN9XSUPP || _DOSEMU
  7823                                  	jmp short .dpmihostchecked
  7824                                  .no2Fhook:
  7825                                  	clropt [options4], opt4_int_2F_hook
  7826                                  .dpmihostchecked:
  7827                                   %endif
  7828                                  %endif
  7829                                  
  7830                                  %if _EXTENSIONS
  7831                                  init_eld_app_dev:
  7832 00002F8D E82B04                  	call init_eld
  7833                                  %else
  7834                                  	push ds
  7835                                  	pop es
  7836                                  %endif
  7837                                  
  7838                                  set_parent_pra:
  7839                                  		; Save, then modify termination address and parent PSP.
  7840                                  %if _DEVICE && _APPLICATION
  7841 00002F90 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  7842 00002F95 7403E94201              	jnz final_device
  7843                                  %elif _DEVICE
  7844                                  	jmp final_device
  7845                                  %endif
  7846                                  %if _APPLICATION
  7847 00002F9A BE0A00                  	mov si, TPIV
  7848 00002F9D BF[0000]                	mov di, psp22
  7849 00002FA0 A5                      	movsw
  7850 00002FA1 A5                      	movsw				; save Int22
  7851 00002FA2 BA[0000]                	mov dx, debug22
  7852 00002FA5 8954FC                  	mov word [ si-4 ], dx
  7853 00002FA8 8C5CFE                  	mov word [ si-2 ], ds		; set pspInt22 (required)
  7854 00002FAB BE1600                  	mov si, 16h
  7855 00002FAE A5                      	movsw				; save parent
  7856 00002FAF 8C5CFE                  	mov word [ si-2 ], ds		; set pspParent
  7857 00002FB2 B82225                  	mov ax, 2522h			; set Int22
  7858 00002FB5 CD21                    	int 21h				; (not really required)
  7859                                  
  7860                                  init_app_allocate_reserved:
  7861 00002FB7 B80258                  		mov ax, 5802h			; Get UMB link state
  7862 00002FBA CD21                    		int 21h
  7863 00002FBC 30E4                    		xor ah, ah
  7864 00002FBE 50                      		push ax				; Save UMB link state
  7865 00002FBF B80058                  		mov ax, 5800h			; Get allocation strategy
  7866 00002FC2 CD21                    		int 21h
  7867 00002FC4 50                      		push ax				; Save allocation strategy
  7868                                  
  7869 00002FC5 B80358                  		mov ax, 5803h			; Set UMB link state:
  7870 00002FC8 BB0100                  		mov bx, 1			; enabled
  7871 00002FCB CD21                    		int 21h
  7872 00002FCD B80158                  		mov ax, 5801h			; Set allocation strategy:
  7873 00002FD0 31DB                    		xor bx, bx			; first fit, LMA then UMA
  7874 00002FD2 CD21                    		int 21h
  7875                                  
  7876 00002FD4 2E8B16[1E0E]            	mov dx, word [cs:init_switch_r]
  7877                                  .loop:
  7878 00002FD9 31DB                    	xor bx, bx
  7879 00002FDB B448                    	mov ah, 48h
  7880 00002FDD CD21                    	int 21h
  7881 00002FDF 722D                    	jc .done
  7882 00002FE1 8EC0                    	mov es, ax
  7883 00002FE3 39D0                    	cmp ax, dx
  7884 00002FE5 7606                    	jbe .grow
  7885                                  .free:
  7886 00002FE7 B449                    	mov ah, 49h
  7887 00002FE9 CD21                    	int 21h
  7888 00002FEB EB21                    	jmp .done
  7889                                  
  7890                                  .grow:
  7891 00002FED 50                      	push ax
  7892 00002FEE 93                      	xchg bx, ax
  7893 00002FEF F7DB                    	neg bx
  7894 00002FF1 01D3                    	add bx, dx				; = dx - bx
  7895 00002FF3 B44A                    	mov ah, 4Ah
  7896 00002FF5 CD21                    	int 21h					; grow up to desired segment
  7897 00002FF7 58                      	pop ax					;  (if not free grow less)
  7898                                  
  7899 00002FF8 85DB                    	test bx, bx
  7900 00002FFA 7501                    	jnz .nonempty
  7901 00002FFC 48                      	dec ax					; => MCB (hack into the name field)
  7902                                  .nonempty:
  7903 00002FFD 8EC0                    	mov es, ax
  7904 00002FFF 26891E0C00              	mov word [es:12], bx			; size (0 if in MCB)
  7905 00003004 8706[0000]              	xchg ax, word [next_reserved_segment]	; :12 -> chain
  7906 00003008 26A30E00                	mov word [es:14], ax			; => next in chain
  7907 0000300C EBCB                    	jmp .loop
  7908                                  
  7909                                  .done:
  7910 0000300E 5B                      		pop bx				; saved allocation strategy
  7911 0000300F B80158                  		mov ax, 5801h
  7912 00003012 CD21                    		int 21h				; Set allocation strategy
  7913 00003014 5B                      		pop bx				; saved UMB link state
  7914 00003015 B80358                  		mov ax, 5803h
  7915 00003018 CD21                    		int 21h				; Set UMB link state
  7916                                  
  7917                                  init_app_resize:
  7918                                  		; shrink to required resident size
  7919 0000301A 1E                      	push ds
  7920 0000301B 07                      	pop es
  7921 0000301C 2EA1[060E]              	mov ax, word [cs:memsize]
  7922 00003020 A3[0000]                	mov word [alloc_size_not_reserved], ax
  7923 00003023 8CD8                    	mov ax, ds
  7924 00003025 2E8B16[1E0E]            	mov dx, word [cs:init_switch_r]
  7925 0000302A 8916[0000]              	mov word [reserved_address], dx
  7926 0000302E 39D0                    	cmp ax, dx
  7927 00003030 7325                    	jae @F
  7928 00003032 2E8B1E[220E]            	mov bx, word [cs:init_target_size]
  7929 00003037 01D8                    	add ax, bx
  7930 00003039 39D0                    	cmp ax, dx
  7931 0000303B 7215                    	jb .fulltargetsize
  7932 0000303D 8CD8                    	mov ax, ds
  7933 0000303F 2E0306[060E]            	add ax, word [cs:memsize]
  7934 00003044 39D0                    	cmp ax, dx
  7935 00003046 730F                    	jae @F					; no action needed
  7936 00003048 89D3                    	mov bx, dx
  7937 0000304A 8CD8                    	mov ax, ds
  7938 0000304C 29C3                    	sub bx, ax				; grow it up to /R (or less)
  7939 0000304E B44A                    	mov ah, 4Ah
  7940 00003050 CD21                    	int 21h					; get bx = actual size
  7941                                  .fulltargetsize:
  7942 00003052 2E891E[060E]            	mov word [cs:memsize], bx
  7943                                  @@:
  7944 00003057 B44A                    	mov ah, 4Ah
  7945 00003059 2E8B1E[060E]            	mov bx, word [cs:memsize]
  7946 0000305E 891E[0000]              	mov word [alloc_size], bx
  7947 00003062 8C1E[0000]              	mov word [alloc_seg], ds
  7948                                  
  7949                                  
  7950 00003066 2ED006[3D0E]            	rol byte [cs:init_switch_t], 1
  7951 0000306B 7209                    	jc .application_relocate
  7952                                  
  7953                                  .application_no_relocate:
  7954 0000306D BE[0000]                	mov si, initcont
  7955 00003070 FF36[0000]              	push word [code_seg]
  7956 00003074 56                      	push si
  7957 00003075 CB                      	retf
  7958                                  
  7959                                  .application_relocate:
  7960 00003076 83EC08                  	sub sp, .relocate_trampoline_size_w * 2
  7961 00003079 89E7                    	mov di, sp			; es:di -> stack space
  7962 0000307B 0E                      	push cs
  7963 0000307C 1F                      	pop ds
  7964 0000307D BE[D430]                	mov si, .relocate_trampoline	; ds:si -> trampoline code
  7965 00003080 B90400                  	mov cx, .relocate_trampoline_size_w
  7966 00003083 57                      	 push di
  7967 00003084 F3A5                    	rep movsw			; place trampoline
  7968 00003086 5F                      	 pop di
  7969                                  
  7970 00003087 BE[0000]                	mov si, initcont
  7971 0000308A 36FF36[0000]            	push word [ss:code_seg]
  7972 0000308F 56                      	push si				; place our return address
  7973                                  
  7974 00003090 06                      	push es
  7975 00003091 53                      	push bx
  7976 00003092 50                      	push ax				; stack for trampoline
  7977                                  
  7978 00003093 B549                    	mov ch, 49h			; set up to free original block
  7979 00003095 A1[1A0E]                	mov ax, word [relocate_source]
  7980 00003098 50                      	 push ax			; => source block
  7981 00003099 8B16[1E0E]              	mov dx, word [init_switch_r]
  7982 0000309D 39D0                    	cmp ax, dx
  7983 0000309F 732A                    	jae @F
  7984 000030A1 2E8B1E[200E]            	mov bx, word [cs:init_base_size]
  7985 000030A6 01D8                    	add ax, bx
  7986 000030A8 39D0                    	cmp ax, dx
  7987 000030AA 7206                    	jb .fullbasesize
  7988 000030AC 89D3                    	mov bx, dx
  7989 000030AE 58                      	 pop ax
  7990 000030AF 50                      	 push ax
  7991 000030B0 29C3                    	sub bx, ax
  7992                                  .fullbasesize:
  7993 000030B2 B54A                    	mov ch, 4Ah			; resize instead
  7994                                  
  7995 000030B4 58                      	 pop ax
  7996 000030B5 50                      	 push ax
  7997 000030B6 85DB                    	test bx, bx
  7998 000030B8 7501                    	jnz .nonempty
  7999 000030BA 48                      	dec ax					; => MCB (hack into the name field)
  8000                                  .nonempty:
  8001 000030BB 8EC0                    	mov es, ax
  8002 000030BD 26891E0C00              	mov word [es:12], bx			; size (0 if in MCB)
  8003 000030C2 368706[0000]            	xchg ax, word [ss:next_reserved_segment]; :12 -> chain
  8004 000030C7 26A30E00                	mov word [es:14], ax			; => next in chain
  8005                                  @@:
  8006 000030CB 58                      	 pop ax
  8007 000030CC 8EC0                    	mov es, ax			; => relocate source
  8008 000030CE 91                      	xchg ax, cx			; ah = 49h or 4Ah
  8009                                  
  8010 000030CF 16                      	 push ss
  8011 000030D0 1F                      	 pop ds				; reset ds
  8012 000030D1 16                      	push ss
  8013 000030D2 57                      	push di				; -> placed trampoline
  8014 000030D3 CB                      	retf				; jump to trampoline
  8015                                  
  8016                                  
  8017                                  	align 2, nop
  8018                                  .relocate_trampoline:
  8019 000030D4 CD21                    	int 21h				; free original process block
  8020 000030D6 58                      	pop ax				; ah = 4Ah
  8021 000030D7 5B                      	pop bx				; bx = memory size
  8022 000030D8 07                      	pop es				; es => new block
  8023                                  		; (we do not really need to resize the block here
  8024                                  		;  as it was already allocated the wanted size.)
  8025 000030D9 CA0800                  	retf .relocate_trampoline_size_w * 2
  8026                                  	align 2, nop
  8027                                   endarea .relocate_trampoline
  8028                                  
  8029                                  %endif
  8030                                  
  8031                                  
  8032                                  %if _DEVICE
  8033                                  final_device:
  8034 000030DC BE8000                  	mov si, 80h			; -> command line tail
  8035 000030DF 89F1                    	mov cx, si			; = 128
  8036 000030E1 29CC                    	sub sp, cx			; -> buffer on stack
  8037 000030E3 89E7                    	mov di, sp
  8038 000030E5 F3A4                    	rep movsb			; preserve it
  8039                                  
  8040                                   %if _DEV_ENV_SIZE
  8041 000030E7 FF362C00                	push word [2Ch]
  8042                                   %endif
  8043                                  
  8044 000030EB 8CDA                    	mov dx, ds
  8045 000030ED B455                    	mov ah, 55h
  8046 000030EF F8                      	clc
  8047 000030F0 CD21                    	int 21h				; create child PSP
  8048                                  
  8049 000030F2 BE0E00                  	mov si, TPIV + 4
  8050 000030F5 BA[0000]                	mov dx, debug22
  8051 000030F8 8954FC                  	mov word [ si-4 ], dx
  8052 000030FB 8C5CFE                  	mov word [ si-2 ], ds		; set pspInt22 (required)
  8053                                   %if _DEVICE_SET_2324
  8054 000030FE C704[0000]              	mov word [ si ], devint23
  8055 00003102 8C5C02                  	mov word [ si + 2 ], ds		; set pspInt23
  8056 00003105 C74404[0000]            	mov word [ si + 4 ], devint24
  8057 0000310A 8C5C06                  	mov word [ si + 6 ], ds		; set pspInt24
  8058                                   %endif
  8059 0000310D BE1800                  	mov si, 16h + 2
  8060 00003110 8C5CFE                  	mov word [ si-2 ], ds		; set pspParent
  8061                                  	; mov ax, 2522h			; set Int22
  8062                                  	; int 21h			; (not really required)
  8063                                  
  8064                                   %if _DEV_ENV_SIZE
  8065 00003113 8F062C00                	pop word [2Ch]
  8066                                   %else
  8067                                  	xor ax, ax
  8068                                  	mov word [2Ch], ax		; set environment to none
  8069                                   %endif
  8070                                  
  8071 00003117 BB0500                  	mov bx, 5			; close file handles past std (5)
  8072 0000311A 8B0E3200                	mov cx, word [32h]		; = number of file handles
  8073 0000311E 29D9                    	sub cx, bx			; = number past std handles
  8074 00003120 7607                    	jbe @FF				; if <= 0 handles to close -->
  8075                                  @@:
  8076 00003122 B43E                    	mov ah, 3Eh
  8077 00003124 CD21                    	int 21h				; close file handle
  8078 00003126 43                      	inc bx				; next handle
  8079 00003127 E2F9                    	loop @B				; loop -->
  8080                                  @@:
  8081                                  
  8082 00003129 89E6                    	mov si, sp			; -> buffer on stack
  8083 0000312B BF8000                  	mov di, 80h			; -> command line tail buffer in PSP
  8084 0000312E 89F8                    	mov ax, di			; = 128
  8085 00003130 89F9                    	mov cx, di			; = 128
  8086 00003132 F3A4                    	rep movsb			;
  8087 00003134 01C4                    	add sp, ax			; discard buffer
  8088                                  
  8089 00003136 BE[0000]                	mov si, initcont.device
  8090 00003139 FF36[0000]              	push word [code_seg]
  8091 0000313D 56                      	push si
  8092 0000313E CB                      	retf
  8093                                  %endif
  8094                                  %endif
  8095                                  
  8096                                  
  8097                                  %assign ELD 0
  8098                                  %assign INTERC3 0
  8099                                  %assign PART1 0
  8100                                  %assign PART2 1
  8101                                  %assign PART3 0
  8102                                  %define init_data_segment cs
  8103                                  
  8104                                   %imacro internalcoderelocation 0-*.nolist
  8105                                   %endmacro
  8106                                   %imacro internaldatarelocation 0-*.nolist
  8107                                   %endmacro
  8108                                   %imacro linkdatarelocation 0-*.nolist
  8109                                   %endmacro
  8110                                   %define relocated(address) address
  8111                                  
  8112                                  %include "pathshar.asm"
     1                              <1> 
     2                              <1> %if 0
     3                              <1> 
     4                              <1> lDebug initialisation - Path analyse and search
     5                              <1> 
     6                              <1> Copyright (C) 2008-2025 E. C. Masloch
     7                              <1> 
     8                              <1> Usage of the works is permitted provided that this
     9                              <1> instrument is retained with the works, so that any entity
    10                              <1> that uses the works is notified of this instrument.
    11                              <1> 
    12                              <1> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <1> 
    14                              <1> %endif
    15                              <1> 
    16                              <1> 
    17                              <1> ; defines used:
    18                              <1> ; ELD = nonzero iff included by Extension for lDebug path.asm (for path.eld)
    19                              <1> ; INTERC3 = nonzero iff included by INTERC3 intercep.asm
    20                              <1> ; else included by lDebug init.asm
    21                              <1> ; PART1 = nonzero if to embed main code
    22                              <1> ; PART2 = nonzero if to embed subfunctions
    23                              <1> ; PART3 = nonzero if to embed imsg messages
    24                              <1> 
    25                              <1> %if PART1
    26                              <1> 		; INP:	si -> pathname followed by command line
    27                              <1> 		;	word [ss:sp] = si
    28                              <1> 		; OUT:	word [ss:sp] -> final buffer
    29                              <1> init_analyse_pathname:
    30                              <1> 	mov bx, si
    31                              <1> 	xor dx, dx
    32                              <1> 	mov al, 0
    33                              <1> @@:
    34                              <1> 	cmp al, '/'
    35                              <1> 	je .slash
    36                              <1> 	cmp al, '\'
    37                              <1> 	je .slash
    38                              <1> 	cmp al, ':'
    39                              <1> 	je .colon
    40                              <1> 	cmp al, '.'
    41                              <1> 	jne .next
    42                              <1> .dot:
    43                              <1> 	mov dl, 1		; set dl (fn with dot)
    44                              <1> 	jmp .next
    45                              <1> 
    46                              <1> .slash:
    47                              <1> .colon:
    48                              <1> 	mov dx, 100h		; set dh (is a pathname), reset dl (fn with dot)
    49                              <1> .next:
    50                              <1> 	lodsb
    51                              <1> 	call init_ifsep
    52                              <1> 	jne @B
    53                              <1> 	dec si			; bx -> name, si -> terminator
    54                              <1> 				; dh = nonzero if a pathname not just filename
    55                              <1> 				; dl = nonzero if filename contains a dot
    56                              <1> 	push ss
    57                              <1> 	pop es
    58                              <1> 	mov cx, si
    59                              <1> 	sub cx, bx		; es:bx -> name, cx = length
    60                              <1> 
    61                              <1> 
    62                              <1> init_check_warn_extension:
    63                              <1> 	push dx
    64                              <1> 	push es
    65                              <1> 
    66                              <1> 	test dl, dl		; last component has a dot ?
    67                              <1> 	jz .done		; no, do not warn -->
    68                              <1> 
    69                              <1> 	rol byte [init_data_segment:init_switch_pw], 1
    70                              <1> internaldatarelocation
    71                              <1> 	jnc .done		; warning disabled -->
    72                              <1> 
    73                              <1> 	cmp cx, 4		; can fit an expected extension ?
    74                              <1> 	jb .warn		; no, warn -->
    75                              <1> 
    76                              <1> 	sub si, 4		; -> possible extension
    77                              <1> 	push init_data_segment
    78                              <1> 	pop es
    79                              <1> 	mov di, imsg.no_warn_extensions
    80                              <1> internaldatarelocation		; es:di -> allowed extensions
    81                              <1> .loop:
    82                              <1> 	mov al, 0
    83                              <1> 	xchg byte [init_data_segment:di+4], al
    84                              <1> 				; NUL-terminate the candidate extension
    85                              <1> 	push ax
    86                              <1> 	mov dx, di
    87                              <1> 	call init_isstring?	; is it this one ?
    88                              <1> 	pop ax
    89                              <1> 	mov byte [init_data_segment:di+4], al
    90                              <1> 				; restore next extension text
    91                              <1> 	je .done		; yes, do not warn -->
    92                              <1> 	scasw
    93                              <1> 	scasw			; di += 4
    94                              <1> 	test al, al		; was last ?
    95                              <1> 	jnz .loop
    96                              <1> .warn:
    97                              <1> 	mov dx, imsg.extension_warning
    98                              <1> internaldatarelocation
    99                              <1> 	call init_putsz_cs
   100                              <1> 
   101                              <1> .done:
   102                              <1> 	pop es
   103                              <1> 	pop dx
   104                              <1> 
   105                              <1> 
   106                              <1> init_find_path:
   107                              <1> %if ELD
   108                              <1> 	extcallcall InDOS
   109                              <1> 	jnz .done_j
   110                              <1> 	testopt [relocateddata], tt_while
   111                              <1> linkdatarelocation internalflags_with_tt_while, -3
   112                              <1> 	jnz .done_j
   113                              <1> %endif
   114                              <1> 	cmp word [init_data_segment:		init_switch_p_low_pathsearch_high_guessextension], strict byte 0
   116                              <1> internaldatarelocation -3
   117                              <1> 	je .done_j
   118                              <1> 
   119                              <1> 	jcxz .done_j		; if no filename given -->
   120                              <1> 
   121                              <1> 				; es:bx -> name, cx = length
   122                              <1> 	mov di, relocated(while_buffer)
   123                              <1> linkdatarelocation while_buffer	; ss:while_buffer -> prefix, ss:di -> after end
   124                              <1> 
   125                              <1> 	call init_check_filename
   126                              <1> 	jnc .found
   127                              <1> 
   128                              <1> 	test dh, dh
   129                              <1> 	jz @F
   130                              <1> .done_j:
   131                              <1> 	jmp .done
   132                              <1> @@:
   133                              <1> 	rol byte [init_data_segment:init_switch_p_pathsearch], 1
   134                              <1> internaldatarelocation
   135                              <1> 	jnc .done_j
   136                              <1> 
   137                              <1> %if _DEVICE && _APPLICATION && ! ELD && ! INTERC3
   138                              <1> 	testopt [internalflags6], dif6_device_mode
   139                              <1> 	jnz .device
   140                              <1> %endif
   141                              <1> %if _APPLICATION || ELD || INTERC3
   142                              <1> 	mov ax, [2Ch]
   143                              <1>  %if _DEVICE && ! ELD && ! INTERC3
   144                              <1> 	jmp @F
   145                              <1>  %endif
   146                              <1> %endif
   147                              <1> 
   148                              <1> %if _DEVICE && ! ELD && ! INTERC3
   149                              <1> .device:
   150                              <1> 	call init_device_get_environment
   151                              <1> @@:
   152                              <1> %endif
   153                              <1> 
   154                              <1> 	push cx
   155                              <1> 	mov di, imsg.varpath
   156                              <1> internaldatarelocation
   157                              <1> 	mov cx, imsg.varpath.length
   158                              <1> 	call init_findvar
   159                              <1> 	jc .done_pop
   160                              <1> 
   161                              <1> .pathloop:
   162                              <1> 	push si
   163                              <1> 	mov cx, 128		; put a limit
   164                              <1> @@:
   165                              <1> 	lodsb			; get next text
   166                              <1> 	cmp al, ';'		; separator ?
   167                              <1> 	je @F			; yes -->
   168                              <1> 	cmp al, 0		; separator ?
   169                              <1> 	je @F			; yes -->
   170                              <1> 	loop @B			; loop up to limit
   171                              <1> 	jmp .pathtoolong	; error -->
   172                              <1> @@:
   173                              <1> 	mov cx, si
   174                              <1> 	dec cx			; -> terminator
   175                              <1> 	pop si			; -> content text
   176                              <1> 	sub cx, si		; = length excluding terminator
   177                              <1> 	 push ss
   178                              <1> 	 pop es
   179                              <1> 	mov di, relocated(while_buffer)
   180                              <1> linkdatarelocation while_buffer	; es:di -> buffer
   181                              <1> 
   182                              <1> 	mov al, 0		; no backslash if empty
   183                              <1> 	jcxz @FFF		; skip loop if empty -->
   184                              <1> @@:
   185                              <1> 	lodsb			; load from variable
   186                              <1> 	cmp al, '/'		; forward slash ?
   187                              <1> 	jne @F			; no -->
   188                              <1> 	mov al, '\'		; replace by backslash
   189                              <1> @@:
   190                              <1> 	stosb			; store
   191                              <1> 	loop @BB		; loop for cx = count
   192                              <1> @@:
   193                              <1> 	cmp al, '\'		; trailing backslash ?
   194                              <1> 	je @F			; yes -->
   195                              <1> 	mov al, '\'
   196                              <1> 	stosb			; append it
   197                              <1> @@:
   198                              <1> 	pop cx
   199                              <1> 
   200                              <1> 	push ds
   201                              <1> 	push si
   202                              <1> 				; ss = es, es:bx -> name, cx = length
   203                              <1> 				; ss:while_buffer -> prefix, ss:di -> after end
   204                              <1> 	call init_check_filename
   205                              <1> 	pop si
   206                              <1> 	pop ds			; ds:si -> terminator of path element
   207                              <1> 	jnc .found
   208                              <1> 
   209                              <1> 	lodsb			; get terminator
   210                              <1> 	cmp al, ';'		; semicolon ?
   211                              <1> 	jne .done		; no -->
   212                              <1> 	push cx
   213                              <1> 	jmp .pathloop		; try next -->
   214                              <1> 
   215                              <1> 
   216                              <1> .found:
   217                              <1> 	push ss
   218                              <1> 	pop ds			; ds => PSP
   219                              <1> 	 pop si
   220                              <1> 	add si, cx		; ds:si -> behind original name
   221                              <1> 	push ss
   222                              <1> 	pop es
   223                              <1> 	dec di			; es:di -> NUL
   224                              <1> %if INTERC3
   225                              <1> 	mov al, 32		; blank codepoint
   226                              <1> 	cmp byte [si], al	; <= 32 ?
   227                              <1> 	ja @F			; no, store a blank first -->
   228                              <1> %endif
   229                              <1> 	jmp @FF			; skip store on first iteration
   230                              <1> 
   231                              <1> @@:
   232                              <1> 	cmp di, relocated(while_buffer.end) - 2
   233                              <1> linkdatarelocation while_buffer.end
   234                              <1> 	ja .toolong
   235                              <1> 	stosb
   236                              <1> @@:
   237                              <1> 	lodsb
   238                              <1> 	cmp al, 0
   239                              <1> 	je @F
   240                              <1> 	cmp al, 13
   241                              <1> 	jne @BB
   242                              <1> @@:			; (targeted from both directions)
   243                              <1> 	mov al, 13
   244                              <1> 	stosb
   245                              <1> 	mov si, relocated(while_buffer)
   246                              <1> linkdatarelocation while_buffer
   247                              <1> 	 push si		; offset for N/K command (kk)
   248                              <1> 	jmp .done
   249                              <1> 
   250                              <1> .toolong:
   251                              <1> 	mov dx, imsg.kktoolong
   252                              <1> internaldatarelocation
   253                              <1> 	call init_putsz_cs
   254                              <1> 	jmp @B
   255                              <1> 
   256                              <1> .pathtoolong:
   257                              <1>  %if ELD
   258                              <1> 	push ss
   259                              <1> 	pop ds
   260                              <1>  %endif
   261                              <1> 	mov dx, imsg.pathtoolong
   262                              <1> internaldatarelocation
   263                              <1> 	call init_putsz_cs
   264                              <1> 
   265                              <1> 	pop ax			; (discard si)
   266                              <1> .done_pop:
   267                              <1> 	pop ax			; (discard cx)
   268                              <1> .done:
   269                              <1> %endif
   270                              <1> 
   271                              <1> 
   272                              <1> %if PART2
   273                              <1> 		; Compare character with separators
   274                              <1> 		;
   275                              <1> 		; INP:	al = character
   276                              <1> 		; OUT:	ZR if al is CR, NUL, blank, tab, comma, semicolon, or equal sign
   277                              <1> 		;	ZR if switch character is a slash and al is a slash
   278                              <1> 		;	NZ else
   279                              <1> 		; REM:	This is only used for parsing FCBs.
   280                              <1> init_ifsep:
   281 0000313F 3C00                <1> 	cmp al, 0
   282 00003141 741D                <1> 	je .return
   283 00003143 3C0D                <1> 	cmp al, 13
   284 00003145 7419                <1> 	je .return
   285 00003147 3C3B                <1> 	cmp al, ';'
   286 00003149 7415                <1> 	je .return
   287 0000314B 3C20                <1> 	cmp al, 32
   288 0000314D 7411                <1> 	je .return
   289 0000314F 3C09                <1> 	cmp al, 9
   290 00003151 740D                <1> 	je .return
   291 00003153 3C2C                <1> 	cmp al, ','
   292 00003155 7409                <1> 	je .return
   293 00003157 3C3D                <1> 	cmp al, '='
   294 00003159 7405                <1> 	je .return
   295 0000315B 363A06[0000]        <1> 	cmp al, byte [ss:relocated(swch1)]
   296                              <1> linkdatarelocation swch1
   297                              <1> .return:
   298 00003160 C3                  <1> 	retn
   299                              <1> 
   300                              <1> 
   301                              <1> %if _APPLICATION || _DEVICE
   302                              <1> 		; INP:	es:bx -> name to try, cx = length
   303                              <1> 		;	dl = zero if to attempt filename extensions
   304                              <1> 		;	ss:while_buffer -> prefix, ss:di -> after
   305                              <1> 		; OUT:	NC if file found,
   306                              <1> 		;	 ss:while_buffer = name, ss:di -> after NUL
   307                              <1> 		;	CY if file not found
   308                              <1> 		;	ds = ss
   309                              <1> 		; CHG:	si, ax
   310                              <1> init_check_filename:
   311 00003161 06                  <1> 	push es
   312 00003162 51                  <1> 	push cx
   313                              <1> 
   314 00003163 06                  <1> 	push es
   315 00003164 1F                  <1> 	pop ds
   316 00003165 89DE                <1> 	mov si, bx		; ds:si -> name
   317 00003167 16                  <1> 	 push ss
   318 00003168 07                  <1> 	 pop es			; es:di -> where to append name
   319 00003169 F3A4                <1> 	rep movsb		; append the name
   320 0000316B 57                  <1> 	push di			; on stack: at initial terminator
   321 0000316C BE[4A0E]            <1> 	mov si, imsg.p_extensions
   322                              <1> internaldatarelocation
   323                              <1> 				; cs:si -> extensions to try
   324                              <1> .loop:
   325 0000316F B000                <1> 	mov al, 0
   326 00003171 AA                  <1> 	stosb			; zero-terminate name
   327 00003172 B80043              <1> 	mov ax, 4300h		; get attributes
   328 00003175 52                  <1> 	push dx
   329 00003176 16                  <1> 	 push ss
   330 00003177 1F                  <1> 	 pop ds
   331 00003178 BA[0000]            <1> 	mov dx, relocated(while_buffer)	; ds:dx -> pathname to try
   332                              <1> linkdatarelocation while_buffer
   333 0000317B F9                  <1> 	stc
   334                              <1> %if ELD
   335                              <1> 	extcallcall _doscall
   336                              <1> %else
   337 0000317C CD21                <1> 	int 21h			; try to get attributes
   338                              <1> %endif
   339 0000317E 7206                <1> 	jc @F			; not found --> CY
   340 00003180 F6C110              <1> 	test cl, 10h		; directory ?
   341 00003183 7401                <1> 	jz @F			; no --> NC
   342 00003185 F9                  <1> 	stc			; yes, handle as not found: CY
   343                              <1> @@:
   344 00003186 5A                  <1> 	pop dx
   345 00003187 731A                <1> 	jnc .ret		; --> (NC)
   346 00003189 84D2                <1> 	test dl, dl		; had an extension originally ?
   347 0000318B 7515                <1> 	jnz .ret_CY		; yes, do not try to append one -->
   348 0000318D 2ED006[190E]        <1> 	rol byte [init_data_segment:init_switch_p_guessextension], 1
   349                              <1> internaldatarelocation
   350 00003192 730E                <1> 	jnc .ret_CY		; if no guessing extension -->
   351 00003194 5F                  <1> 	pop di
   352 00003195 57                  <1> 	push di
   353 00003196 2E803C00            <1> 	cmp byte [init_data_segment:si], 0
   354                              <1> 				; last attempt done ?
   355 0000319A 7406                <1> 	je .ret_CY		; yes -->
   356 0000319C 2EA5                <1> 	init_data_segment movsw	; ".C"
   357 0000319E 2EA5                <1> 	init_data_segment movsw	; "OM"
   358 000031A0 EBCD                <1> 	jmp .loop
   359                              <1> 
   360                              <1> .ret_CY:
   361 000031A2 F9                  <1> 	stc			; CY
   362                              <1> .ret:
   363 000031A3 58                  <1> 	pop ax			; (discard)
   364 000031A4 59                  <1> 	pop cx
   365 000031A5 07                  <1> 	pop es
   366 000031A6 C3                  <1> 	retn
   367                              <1> %endif
   368                              <1> 
   369                              <1> 
   370                              <1> 		; INP:	ax => environment, zero if none
   371                              <1> 		;	cs:di -> variable name, including '=' terminator
   372                              <1> 		;	cx = variable name length, including '=' terminator
   373                              <1> 		; OUT:	CY if not found
   374                              <1> 		;	NC if found,
   375                              <1> 		;	 ds:si -> behind '=' of found variable
   376                              <1> 		; CHG:	ax, es, di, ds, si, cx
   377                              <1> init_findvar:
   378 000031A7 85C0                <1> 	test ax, ax
   379 000031A9 7415                <1> 	jz .notvar
   380 000031AB 8ED8                <1> 	mov ds, ax
   381 000031AD 31F6                <1> 	xor si, si
   382                              <1> 
   383                              <1> @@:
   384 000031AF 0E                  <1> 	push init_data_segment
   385 000031B0 07                  <1> 	pop es
   386 000031B1 51                  <1> 	push cx
   387 000031B2 57                  <1> 	push di
   388 000031B3 56                  <1> 	push si
   389 000031B4 F3A6                <1> 	repe cmpsb
   390 000031B6 740A                <1> 	je .foundvar		; --> (NC)
   391 000031B8 5E                  <1> 	pop si
   392 000031B9 5F                  <1> 	pop di
   393 000031BA 59                  <1> 	pop cx
   394 000031BB E80800              <1> 	call init_nextvar
   395 000031BE 75EF                <1> 	jnz @B
   396                              <1> .notvar:
   397 000031C0 F9                  <1> 	stc
   398 000031C1 C3                  <1> 	retn
   399                              <1> 
   400                              <1> .foundvar:
   401 000031C2 58                  <1> 	pop ax
   402 000031C3 58                  <1> 	pop ax
   403 000031C4 58                  <1> 	pop ax
   404 000031C5 C3                  <1> 	retn
   405                              <1> 
   406                              <1> 
   407                              <1> init_nextvar:
   408                              <1> @@:
   409 000031C6 AC                  <1> 	lodsb
   410 000031C7 84C0                <1> 	test al, al
   411 000031C9 75FB                <1> 	jnz @B
   412 000031CB 803C00              <1> 	cmp byte [si], 0
   413 000031CE C3                  <1> 	retn
   414                              <1> %endif
   415                              <1> 
   416                              <1> 
   417                              <1> %if PART3
   418                              <1>  %if INTERC3
   419                              <1>   %define _PROGNAME ""
   420                              <1>  %endif
   421                              <1> 	align 2, db 0
   422                              <1> .no_warn_extensions:
   423                              <1>  %ifn INTERC3
   424                              <1> 		db ".HEX",".ROM"
   425                              <1>  %endif
   426                              <1> %if (($ - .no_warn_extensions) % 4) != 0
   427                              <1>  %error Wrong extensions length
   428                              <1> %endif
   429                              <1> .p_extensions:	db ".COM"
   430                              <1> 		db ".EXE"
   431                              <1>  %ifn INTERC3
   432                              <1> 		db ".BIN"
   433                              <1>  %endif
   434                              <1> 		asciz
   435                              <1> %if (($ - 1 - .p_extensions) % 4) != 0
   436                              <1>  %error Wrong extensions length
   437                              <1> %endif
   438                              <1> .varpath:	db "PATH="
   439                              <1> .varpath.length equ $ - .varpath
   440                              <1> .extension_warning:
   441                              <1> %ifn ELD
   442                              <1> 	db _PROGNAME,": "
   443                              <1> %endif
   444                              <1> 	asciz "Warning, unknown filename extension specified!",13,10
   445                              <1> .kktoolong:
   446                              <1> %ifn ELD
   447                              <1> 	db _PROGNAME,": "
   448                              <1> %endif
   449                              <1> 	asciz "Error, too long command line tail!",13,10
   450                              <1> .pathtoolong:
   451                              <1> %ifn ELD
   452                              <1> 	db _PROGNAME,": "
   453                              <1> %endif
   454                              <1> 	asciz "Error, too long %PATH% variable element!",13,10
   455                              <1> %endif
  8113                                  
  8114                                   %undef extcall
  8115                                   %undef extcallcall
  8116                                   %unimacro internalcoderelocation 0-*.nolist
  8117                                   %unimacro internaldatarelocation 0-*.nolist
  8118                                   %unimacro linkdatarelocation 0-*.nolist
  8119                                   %undef relocated
  8120                                  
  8121                                  
  8122                                  %if _EXTHELP
  8123                                  switch_u:
  8124 000031CF 800E[0000]10            	setopt [options], nonpagingdevice
  8125                                  
  8126 000031D4 AC                      	lodsb
  8127 000031D5 E8CC00                  	call init_capitalise
  8128 000031D8 3C4C                    	cmp al, 'L'
  8129 000031DA 741B                    	je .license
  8130 000031DC 3C52                    	cmp al, 'R'
  8131 000031DE 7514                    	jne .both
  8132                                  .revision:
  8133 000031E0 E80200                  	call .do_revision
  8134 000031E3 EB1E                    	jmp .done
  8135                                  
  8136                                  .do_revision:
  8137 000031E5 BB[0000]                	mov bx, msg.build_array
  8138 000031E8 B9[0000]                	mov cx, msg.build_short_amount
  8139 000031EB E81800                  	call .putsz_spec_multi
  8140 000031EE BA[AF0F]                	mov dx, imsg.crlf
  8141 000031F1 E941E9                  	jmp init_putsz_cs
  8142                                  
  8143                                  .both:
  8144 000031F4 E8EEFF                  	call .do_revision
  8145                                  .license:
  8146 000031F7 BA[0000]                	mov dx, msg.license
  8147 000031FA E81300                  	call init_transfer_to_putsz_exthelp
  8148 000031FD BA[AF0F]                	mov dx, imsg.crlf
  8149 00003200 E832E9                  	call init_putsz_cs
  8150                                  .done:
  8151 00003203 E95EEF                  	jmp commandline.helpterminate
  8152                                  
  8153                                  .putsz_spec_multi:
  8154                                  @@:
  8155 00003206 8B17                    	mov dx, word [bx]
  8156 00003208 E80500                  	call init_transfer_to_putsz_exthelp
  8157 0000320B 43                      	inc bx
  8158 0000320C 43                      	inc bx
  8159 0000320D E2F7                    	loop @B
  8160 0000320F C3                      	retn
  8161                                  
  8162                                  
  8163                                  init_transfer_to_putsz_exthelp:
  8164                                  	lframe 0
  8165                                  	lpar word, in_ip_out_far_cs
  8166                                  	 ; near call ip
  8167                                  	lpar word, in_ax_out_far_ip
  8168 00003210 50                      	 push ax			; push into ?in_ax_out_far_ip
  8169                                  	lpar word, out_near_ip
  8170 00003211 B8[0000]                	mov ax, code_retf
  8171 00003214 50                      	 push ax			; push into ?out_near_ip
  8172                                  	lpar dword, destination
  8173 00003215 FF36[0000]              	 push word [code_seg]		; push into ?destination + 2
  8174 00003219 B8[0000]                	mov ax, putsz_exthelp
  8175 0000321C 50                      	 push ax			; push into ?destination + 0
  8176 0000321D 5589E5                  	lenter
  8177 00003220 8CC8                    	mov ax, cs			; = cs
  8178 00003222 87460A                  	xchg ax, word [bp + ?in_ip_out_far_cs]
  8179                                  					; ax = ip, var = cs
  8180 00003225 874608                  	xchg ax, word [bp + ?in_ax_out_far_ip]
  8181                                  					; ax = ax, var = ip
  8182 00003228 5D                      	lleave
  8183 00003229 CB                      	retf
  8184                                  %endif
  8185                                  
  8186                                  
  8187                                  %if _CONFIG
  8188                                  		; INP:	ax => environment, zero if none
  8189                                  		;	cs:di -> variable name, including '=' terminator
  8190                                  		;	cx = variable name length, including '=' terminator
  8191                                  		;	ss:dx -> buffer to write to, 256 bytes
  8192                                  		; OUT:	es = ds = ss
  8193                                  		;	CY if not found
  8194                                  		;	NC if found,
  8195                                  		;	 buffer filled
  8196                                  init_copyvar:
  8197 0000322A E87AFF                  	call init_findvar
  8198 0000322D 721A                    	jc .endvar
  8199                                  
  8200                                  .foundvar:
  8201 0000322F 1E                      	push ds
  8202 00003230 07                      	pop es
  8203 00003231 89F7                    	mov di, si
  8204 00003233 B000                    	mov al, 0
  8205 00003235 B9FF00                  	mov cx, 255
  8206 00003238 F2AE                    	repne scasb
  8207                                  
  8208 0000323A 29F7                    	sub di, si
  8209 0000323C 4F                      	dec di
  8210 0000323D 89F9                    	mov cx, di
  8211                                  
  8212 0000323F 16                      	push ss
  8213 00003240 07                      	pop es
  8214 00003241 89D7                    	mov di, dx
  8215 00003243 F3A4                    	rep movsb
  8216 00003245 B000                    	mov al, 0
  8217 00003247 AA                      	stosb
  8218 00003248 F8                      	clc
  8219                                  
  8220                                  .endvar:
  8221 00003249 16                      	push ss
  8222 0000324A 1F                      	pop ds
  8223 0000324B 16                      	push ss
  8224 0000324C 07                      	pop es
  8225 0000324D C3                      	retn
  8226                                  %endif
  8227                                  
  8228                                  
  8229                                  %assign ELD 0
  8230                                  %define PREFIX init_
  8231                                  %include "isstring.asm"
     1                              <1> 
     2                              <1> %if 0
     3                              <1> 
     4                              <1> lDebug string keyword comparison
     5                              <1> 
     6                              <1> Copyright (C) 1995-2003 Paul Vojta
     7                              <1> Copyright (C) 2008-2023 E. C. Masloch
     8                              <1> 
     9                              <1> Usage of the works is permitted provided that this
    10                              <1> instrument is retained with the works, so that any entity
    11                              <1> that uses the works is notified of this instrument.
    12                              <1> 
    13                              <1> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    14                              <1> 
    15                              <1> %endif
    16                              <1> 
    17                              <1> 
    18                              <1> 		; Check for given string (cap-insensitive)
    19                              <1> 		;
    20                              <1> 		; INP:	ds:si -> input string to check (either cap),
    21                              <1> 		;	 terminated by CR (13), NUL, semicolon, space,
    22                              <1> 		;	 tab, dot, comma, equals, colon, [, ], (, or )
    23                              <1> 		;	es:dx -> ASCIZ string to check (all-caps)
    24                              <1> 		; OUT:	Iff string matches,
    25                              <1> 		;	 ZR, NC
    26                              <1> 		;	 si -> at separator that terminates the keyword
    27                              <1> 		;	else,
    28                              <1> 		;	 NZ, CY
    29                              <1> 		;	 si = input si
    30                              <1> 		; STT:	ds = es = ss
    31                              <1> 		; CHG:	dx, al
    32                              <1> %[PREFIX]isstring?:
    33 0000324E 56                  <1> 	push si
    34 0000324F 87D7                <1> 	xchg dx, di
    35                              <1> .loop:
    36 00003251 AC                  <1> 	lodsb
    37 00003252 E84F00              <1> 	call %[PREFIX]capitalise
    38 00003255 AE                  <1> 	scasb
    39 00003256 7506                <1> 	jne .mismatch
    40 00003258 84C0                <1> 	test al, al		; NC
    41 0000325A 75F5                <1> 	jne .loop
    42                              <1> 				; ZR
    43 0000325C EB40                <1> 	jmp .matched_zr_nc
    44                              <1> 
    45                              <1> .mismatch:
    46 0000325E E84E00              <1> 	call %[PREFIX]iseol?
    47 00003261 7434                <1> 	je .checkend
    48 00003263 3C20                <1> 	cmp al, 32
    49 00003265 7430                <1> 	je .checkend
    50 00003267 3C09                <1> 	cmp al, 9
    51 00003269 742C                <1> 	je .checkend
    52 0000326B 3C2E                <1> 	cmp al, '.'
    53 0000326D 7428                <1> 	je .checkend
    54 0000326F 3C2C                <1> 	cmp al, ','
    55 00003271 7424                <1> 	je .checkend
    56 00003273 3C3D                <1> 	cmp al, '='
    57 00003275 7420                <1> 	je .checkend
    58 00003277 3C3A                <1> 	cmp al, ':'
    59 00003279 741C                <1> 	je .checkend
    60 0000327B 3C5B                <1> 	cmp al, '['
    61 0000327D 7418                <1> 	je .checkend
    62 0000327F 3C5D                <1> 	cmp al, ']'
    63 00003281 7414                <1> 	je .checkend
    64 00003283 3C28                <1> 	cmp al, '('
    65 00003285 7410                <1> 	je .checkend
    66 00003287 3C29                <1> 	cmp al, ')'
    67 00003289 740C                <1> 	je .checkend
    68                              <1> %ifidni PREFIX, init_
    69                              <1>  %if ELD
    70                              <1> 	cmp al, byte [ss:relocateddata]
    71                              <1> linkdatarelocation swch1
    72                              <1>  %else
    73 0000328B 363A06[0000]        <1> 	cmp al, byte [ss:swch1]
    74                              <1>  %endif
    75 00003290 7405                <1> 	je .checkend
    76                              <1> %endif
    77                              <1> .ret_nz:	; NZ
    78 00003292 5E                  <1> 	pop si
    79 00003293 F9                  <1> 	stc			; CY
    80                              <1> .ret:
    81 00003294 87D7                <1> 	xchg dx, di
    82 00003296 C3                  <1> 	retn
    83                              <1> 
    84                              <1> .checkend:
    85 00003297 26807DFF00          <1> 	cmp byte [es:di - 1], 0
    86 0000329C 75F4                <1> 	jne .ret_nz
    87                              <1> 				; ZR, NC
    88                              <1> .matched_zr_nc:	; ZR, NC
    89 0000329E 5F                  <1> 	pop di			; (discard)
    90 0000329F 8D74FF              <1> 	lea si, [si - 1]	; -> separator (preserve ZR)
    91 000032A2 EBF0                <1> 	jmp .ret
    92                              <1> 
    93                              <1> 
    94                              <1> %[PREFIX]capitalise: section_of_function
    95 000032A4 3C61                <1> 	cmp al, 'a'
    96 000032A6 7206                <1> 	jb .ret
    97 000032A8 3C7A                <1> 	cmp al, 'z'
    98 000032AA 7702                <1> 	ja .ret
    99 000032AC 24DF                <1> 	and al, TOUPPER
   100                              <1> .ret:
   101 000032AE C3                  <1> 	retn
   102                              <1> 
   103                              <1> %ifempty PREFIX
   104                              <1> iseol?_or_then:
   105                              <1>  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
   106                              <1> 	testopt [internalflags3], dif3_in_if
   107                              <1> 	jz iseol?
   108                              <1> 	mov dx, msg.then
   109                              <1> 	dec si
   110                              <1> 	call isstring?
   111                              <1> 	je iseol?.ret
   112                              <1> 	lodsb
   113                              <1>  %endif
   114                              <1> %endif
   115                              <1> 
   116                              <1> %[PREFIX]iseol?:
   117 000032AF 3C3B                <1> 	cmp al, ';'
   118 000032B1 7406                <1> 	je .ret
   119                              <1> .notsemicolon:
   120 000032B3 3C0D                <1> 	cmp al, 13		; this *IS* iseol?
   121 000032B5 7402                <1> 	je .ret
   122 000032B7 3C00                <1> 	cmp al, 0
   123                              <1> .ret:
   124 000032B9 C3                  <1> 	retn
   125                              <1> 
   126                              <1> 
   127                              <1> 		; Skip blanks, then an optional comma, and then more blanks
   128                              <1> 		;
   129                              <1> 		; INP:	ds:si -> first character
   130                              <1> 		; OUT:	al = first non-blank character behind
   131                              <1> 		;	ds:si -> character behind the first non-blank behind
   132                              <1> 		;	NC
   133                              <1> 		; STK:	3 word
   134                              <1> %[PREFIX]skipcomma: section_of_function
   135 000032BA AC                  <1> 	lodsb
   136                              <1> 
   137                              <1> 		; Same as above but we already have the first character in al
   138                              <1> %[PREFIX]skipcomm0: section_of_function
   139 000032BB E82C00              <1> 	call %[PREFIX]skipwh0
   140 000032BE 3C2C                <1> 	cmp al, ','
   141 000032C0 7510                <1> 	jne .return		; if no comma
   142 000032C2 56                  <1> 	push si
   143 000032C3 E82300              <1> 	call %[PREFIX]skipwhite
   144 000032C6 E8E6FF              <1> 	call %[PREFIX]iseol?
   145 000032C9 7504                <1> 	jne .noteol		; if not end of line
   146 000032CB 5E                  <1> 	pop si
   147 000032CC B02C                <1> 	mov al, ','
   148 000032CE C3                  <1> 	retn
   149                              <1> .noteol:
   150 000032CF 83C402              <1> 	add sp, byte 2		; pop si into nowhere
   151                              <1> .return:
   152 000032D2 C3                  <1> 	retn
   153                              <1> 
   154                              <1> 
   155                              <1> 		; Skip blanks, then an optional equals sign, then more blanks
   156                              <1> %[PREFIX]skipequals: section_of_function
   157 000032D3 AC                  <1> 	lodsb
   158                              <1> %[PREFIX]skipequ0:
   159 000032D4 E81300              <1> 	call %[PREFIX]skipwh0
   160 000032D7 3C3D                <1> 	cmp al, '='
   161 000032D9 7503                <1> 	jne .return
   162 000032DB E80B00              <1> 	call %[PREFIX]skipwhite
   163                              <1> .return:
   164 000032DE C3                  <1> 	retn
   165                              <1> 
   166                              <1> 
   167                              <1> 		; Skip alphabetic characters, and then white space
   168                              <1> 		;
   169                              <1> 		; INP:	ds:si-> first character
   170                              <1> 		; OUT:	al = first non-blank character behind alphabetic characters
   171                              <1> 		;	ds:si-> character behind the first non-blank behind alpha.
   172                              <1> 		;	NC
   173                              <1> %[PREFIX]skipalpha:
   174                              <1> .:
   175 000032DF AC                  <1> 	lodsb
   176 000032E0 24DF                <1> 	and al, TOUPPER
   177 000032E2 2C41                <1> 	sub al, 'A'
   178 000032E4 3C19                <1> 	cmp al, 'Z'-'A'
   179 000032E6 76F7                <1> 	jbe .
   180 000032E8 4E                  <1> 	dec si
   181                              <1> 
   182                              <1> 		; Skip blanks and tabs
   183                              <1> 		;
   184                              <1> 		; INP:	ds:si-> first character
   185                              <1> 		; OUT:	al = first non-blank character
   186                              <1> 		;	ds:si-> character behind the first non-blank
   187                              <1> 		;	NC
   188                              <1> 		; CHG:	-
   189                              <1> 		; STK:	1 word
   190                              <1> %[PREFIX]skipwhite: section_of_function
   191 000032E9 AC                  <1> 	lodsb
   192                              <1> 
   193                              <1> 		; Same as above, but first character in al
   194                              <1> 		;
   195                              <1> 		; INP:	al = first character
   196                              <1> 		;	ds:si-> next character
   197                              <1> 		; OUT:	al = first non-blank character
   198                              <1> 		;	ds:si-> character behind the first non-blank
   199                              <1> 		;	NC
   200                              <1> 		; CHG:	-
   201                              <1> 		; STK:	1 word
   202                              <1> %[PREFIX]skipwh0: section_of_function
   203 000032EA 3C20                <1> 	cmp al, 32
   204 000032EC 74FB                <1> 	je %[PREFIX]skipwhite
   205 000032EE 3C09                <1> 	cmp al, 9
   206 000032F0 74F7                <1> 	je %[PREFIX]skipwhite
   207 000032F2 F8                  <1> 	clc
   208 000032F3 C3                  <1> 	retn
  8232                                  
  8233                                  
  8234                                  		; INP:	bx => destination for auxbuff
  8235                                  		;	(The following are not actually used by this function,
  8236                                  		;	 they're just what is passed in and preserved to
  8237                                  		;	 be used by the caller after returning.)
  8238                                  		;	dx => destination for code image
  8239                                  		;	(if boot-loaded:) cx => destination for pseudo-PSP
  8240                                  		;		(implies cx+10h => destination for data_entry)
  8241                                  		;	ax => segment for history buffer
  8242                                  
  8243                                  init_app_layout_1:
  8244                                  %if 0
  8245                                  	mov bx, ds
  8246                                  	mov dx, bx
  8247                                  	add bx, paras(AUXTARGET1)
  8248                                  	add dx, paras(CODETARGET1)
  8249                                   %if _HISTORY_SEPARATE_FIXED && _HISTORY
  8250                                  	mov ax, bx
  8251                                  	add ax, paras(auxbuff_size)
  8252                                    %if AUXTARGET1_equate <= CODETARGET1_equate
  8253                                  	...
  8254                                    %endif
  8255                                   %endif
  8256                                  	mov cx, dx
  8257                                  %endif
  8258                                  
  8259                                  		; REM:	Only history segment and extsegment are behind auxbuff.
  8260                                   %if _EXTENSIONS || _HISTORY_SEPARATE_FIXED && _HISTORY || 	_DEV_ENV_SIZE || _APP_ENV_SIZE
  8262                                    %if _HISTORY_SEPARATE_FIXED && _HISTORY
  8263 000032F4 A1[0000]                	mov ax, word [history.segorsel + soaSegSel]
  8264                                  					; => history segment
  8265                                    %elif (_DEV_ENV_SIZE || _APP_ENV_SIZE) && _EXTENSIONS
  8266                                  	mov ax, word [envseg]
  8267                                  	test ax, ax
  8268                                  	jnz @F
  8269                                  	mov ax, word [extseg]
  8270                                  @@:
  8271                                    %elif (_DEV_ENV_SIZE || _APP_ENV_SIZE)
  8272                                  	mov ax, word [envseg]
  8273                                  		; if here then no history segment and no ext segment,
  8274                                  		;  so we do not want to copy anything if envseg unused.
  8275                                  		;  in this case hope that mem_envsize is 0 so the movp
  8276                                  		;  call below is a no-op.
  8277                                  		; better fix: just include a check for zero here.
  8278                                  	test ax, ax
  8279                                  	jz .skip_env_reloc
  8280                                    %elif _EXTENSIONS
  8281                                  	mov ax, word [extseg]
  8282                                    %else
  8283                                     %error Unexpected condition
  8284                                    %endif
  8285 000032F7 89C2                    	mov dx, ax
  8286 000032F9 01F2                    	add dx, si
  8287 000032FB B90004                  	mov cx, paras(historysegment_size + extsegment_size)
  8288                                  		; This runs before init_change_history_size
  8289                                  		;  and init_change_ext_size.
  8290                                  %if (_DEV_ENV_SIZE || _APP_ENV_SIZE)
  8291 000032FE 2E030E[080E]            	add cx, word [cs:mem_envsize]
  8292                                  %endif
  8293 00003303 E89EE7                  	call init_movp
  8294                                  .skip_env_reloc:
  8295                                  init_app_layout_common:
  8296                                    %if _HISTORY_SEPARATE_FIXED && _HISTORY
  8297 00003306 0136[0000]              	add word [history.segorsel + soaSegSel], si
  8298                                  %if _PM
  8299                                  	add word [history.segorsel + soaSegment], si
  8300                                  %endif
  8301                                    %endif
  8302                                    %if _EXTENSIONS
  8303 0000330A 0136[0000]              	add word [extseg], si
  8304                                    %endif
  8305                                    %if (_DEV_ENV_SIZE || _APP_ENV_SIZE)
  8306 0000330E 2ED006[410E]            	rol byte [cs:app_env_allocation], 1
  8307 00003313 7204                    	jc @F
  8308 00003315 01362C00                	add word [2Ch], si
  8309                                  @@:
  8310 00003319 833E[0000]00            	cmp word [envseg], 0
  8311 0000331E 7404                    	je @F
  8312 00003320 0136[0000]              	add word [envseg], si
  8313                                  @@:
  8314                                    %endif
  8315                                   %else
  8316                                  init_app_layout_common:
  8317                                   %endif
  8318 00003324 2E0136[060E]            	add word [cs:memsize], si
  8319 00003329 8E06[0000]              	mov es, word [auxbuff_segorsel + soaSegSel]
  8320 0000332D BF1020                  	mov di, fromwords(words(_AUXBUFFSIZE))
  8321 00003330 89F1                    	mov cx, si			; = amount paragraphs added
  8322 00003332 D1E1                    	shl cx, 1			; = amount qwords
  8323 00003334 D1E1                    	shl cx, 1			; = amount dwords
  8324 00003336 D1E1                    	shl cx, 1			; = amount words
  8325 00003338 31C0                    	xor ax, ax
  8326 0000333A F3AB                    	rep stosw			; initialise auxbuff trail
  8327 0000333C F8                      	clc
  8328 0000333D C3                      	retn
  8329                                  
  8330                                  
  8331                                  init_app_layout_2:
  8332                                  %if 0
  8333                                  	mov bx, ds
  8334                                  	mov dx, bx
  8335                                  	add bx, paras(AUXTARGET2)
  8336                                  	add dx, paras(CODETARGET2)
  8337                                   %if _HISTORY_SEPARATE_FIXED && _HISTORY
  8338                                    %if (paras(AUXTARGET1_equate) + paras(auxbuff_size_equate)) 	!= (paras(CODETARGET2_equate) + paras(ldebug_codes_truncated_size_equate))
  8340                                  	...
  8341                                    %endif
  8342                                   %endif
  8343                                  %endif
  8344                                  
  8345                                  		; REM:	Code1/code2 and history segment are behind auxbuff.
  8346 0000333E A1[0000]                	mov ax, word [code_seg]
  8347 00003341 89C2                    	mov dx, ax
  8348 00003343 01F2                    	add dx, si
  8349                                  %ifn _LINK
  8350                                  	mov cx, ldebug_code_bootldr_truncated_size_p 		+ ldebug_code2_size_p 		+ paras(historysegment_size) 		+ paras(extsegment_size)
  8354                                  %else
  8355 00003345 B9[0004]                	mov cx, relocatedzero + 0 		+ paras(historysegment_size) 		+ paras(extsegment_size)
  8358                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code_truncated, equ $ - 2
  8359                                   wlcalc word_wrt_@@lDEBUG_CODE2@_extpara_behind_code2, equ $ - 2
  8360                                  %endif
  8361                                  
  8362                                  		; This runs before init_change_history_size
  8363                                  		;  and init_change_ext_size.
  8364                                  %if (_DEV_ENV_SIZE || _APP_ENV_SIZE)
  8365 00003348 2E030E[080E]            	add cx, word [cs:mem_envsize]
  8366                                  %endif
  8367 0000334D E854E7                  	call init_movp
  8368                                  
  8369 00003350 8EC2                    	mov es, dx
  8370 00003352 0136[0000]              	add word [code_seg], si
  8371                                  %if _DUALCODE
  8372                                  	add word [code2_seg], si
  8373                                  	mov dx, word [code2_seg]
  8374                                  repatch_relocate:
  8375                                  	push si
  8376                                   %if ! _PM
  8377                                  	mov si, relocate_from_code
  8378                                  	mov di, relocate_from_code.end
  8379                                  	call .patch
  8380                                  	mov si, relocate_from_code2
  8381                                  	mov di, relocate_from_code2.end
  8382                                   %endif
  8383                                  	push es
  8384                                  	mov es, dx
  8385                                  	pop dx
  8386                                   %if ! _PM
  8387                                  	call .patch
  8388                                  	jmp .done
  8389                                  
  8390                                  .loop:
  8391                                  	cs lodsw
  8392                                  	xchg bx, ax
  8393                                  	mov word [es:bx], dx
  8394                                  .patch:
  8395                                  	cmp si, di
  8396                                  	jb .loop
  8397                                  	retn
  8398                                  
  8399                                  .done:
  8400                                   %endif
  8401                                  	pop si
  8402                                  %endif
  8403                                  
  8404                                  %if _AREAS && _AREAS_HOOK_CLIENT
  8405                                  	mov ax, si
  8406                                  	call add_to_areas_linear_code1
  8407                                   %if _DUALCODE && _EXPRDUALCODE
  8408                                  	mov ax, si
  8409                                  	call add_to_areas_linear_code2
  8410                                   %endif
  8411                                  %endif
  8412                                  
  8413 00003356 EBAE                    	jmp init_app_layout_common
  8414                                  
  8415                                  
  8416                                  		; REM:	Only history segment is behind auxbuff.
  8417                                  init_app_layout_3: equ init_app_layout_1
  8418                                  %if 0
  8419                                  		; If both prior attempts failed, we allocate
  8420                                  		;  an additional 8 KiB and move the buffer to
  8421                                  		;  that. This should always succeed.
  8422                                  	mov word [cs:memsize], paras(AUXTARGET3 			+ auxbuff_size 			+ historysegment_size)
  8425                                  				; enlarge the final memory block size
  8426                                  
  8427                                  	mov bx, ds
  8428                                  	add bx, paras(AUXTARGET3)
  8429                                  	mov dx, cx
  8430                                   %if _HISTORY_SEPARATE_FIXED && _HISTORY
  8431                                  	mov ax, bx
  8432                                  	add ax, paras(auxbuff_size)
  8433                                   %endif
  8434                                  %endif
  8435                                  
  8436                                  
  8437                                  %if _DEVICE
  8438                                  init_dev_layout_1:
  8439                                  %if 0
  8440                                  	mov bx, ds
  8441                                  	add bx, paras(DEVICEADJUST)
  8442                                  	mov dx, bx
  8443                                  	add bx, paras(AUXTARGET1)
  8444                                  	add dx, paras(CODETARGET1)
  8445                                   %if _HISTORY_SEPARATE_FIXED && _HISTORY
  8446                                  	mov ax, bx
  8447                                  	add ax, paras(auxbuff_size)
  8448                                   %endif
  8449                                  	mov cx, dx
  8450                                  %endif
  8451 00003358 E899FF                  	call init_app_layout_1
  8452 0000335B EB08                    	jmp init_dev_layout_common
  8453                                  
  8454                                  
  8455                                  init_dev_layout_2:
  8456                                  %if 0
  8457                                  	mov bx, ds
  8458                                  	add bx, paras(DEVICEADJUST)
  8459                                  	mov dx, bx
  8460                                  	add bx, paras(AUXTARGET2)
  8461                                  	add dx, paras(CODETARGET2)
  8462                                  %endif
  8463 0000335D E8DEFF                  	call init_app_layout_2
  8464 00003360 EB03                    	jmp init_dev_layout_common
  8465                                  
  8466                                  
  8467                                  init_dev_layout_3:
  8468                                  %if 0
  8469                                  	mov word [cs:memsize], paras(AUXTARGET3 			+ auxbuff_size 			+ historysegment_size)
  8472                                  				; enlarge the final memory block size
  8473                                  
  8474                                  	mov bx, ds
  8475                                  	add bx, paras(DEVICEADJUST)
  8476                                  	add bx, paras(AUXTARGET3)
  8477                                  	mov dx, cx
  8478                                   %if _HISTORY_SEPARATE_FIXED && _HISTORY
  8479                                  	mov ax, bx
  8480                                  	add ax, paras(auxbuff_size)
  8481                                   %endif
  8482                                  %endif
  8483                                  
  8484 00003362 E88FFF                  	call init_app_layout_3
  8485                                  init_dev_layout_common:
  8486 00003365 0136[0000]              	add word [device_mcb_paragraphs], si
  8487                                  					; fix our variable
  8488 00003369 0136[0000]              	add word [alloc_size], si	; this one too
  8489 0000336D 8CD8                    	mov ax, ds			; => PSP
  8490 0000336F 2E0306[060E]            	add ax, word [cs:memsize]	; => where to place container sig
  8491 00003374 E8CDD7                  	call init_dev_place_container_signature
  8492                                  					; CHG: es, di, cx, si
  8493                                  					; ax => behind memory used for device
  8494 00003377 8E06[0000]              	mov es, word [reg_es]
  8495 0000337B 8B1E[0000]              	mov bx, word [reg_ebx]		; -> device request header
  8496 0000337F 26894710                	mov word [es:bx + 0Eh + 2], ax	; -> behind memory in use
  8497 00003383 F8                      	clc
  8498 00003384 C3                      	retn
  8499                                  %endif
  8500                                  
  8501                                  
  8502                                  init_layout_none:
  8503 00003385 F9                      	stc
  8504 00003386 C3                      	retn
  8505                                  
  8506                                  
  8507                                  %if _AREAS && _AREAS_HOOK_CLIENT
  8508                                  add_to_areas_linear_code1:
  8509                                  	xor dx, dx
  8510                                  .dxax:
  8511                                  	mov cx, 4
  8512                                  @@:
  8513                                  	shl ax, 1
  8514                                  	rcl dx, 1
  8515                                  	loop @B
  8516                                  
  8517                                  	add word [areas_sub + areastrucsubLinear], ax
  8518                                  	adc word [areas_sub + areastrucsubLinear + 2], dx
  8519                                  	add word [areas_sub + areastrucsubLinearEnd], ax
  8520                                  	adc word [areas_sub + areastrucsubLinearEnd + 2], dx
  8521                                  
  8522                                  	add word [areas_fun + areastrucfunLinear], ax
  8523                                  	adc word [areas_fun + areastrucfunLinear + 2], dx
  8524                                  	add word [areas_fun + areastrucfunLinearEnd], ax
  8525                                  	adc word [areas_fun + areastrucfunLinearEnd + 2], dx
  8526                                  	retn
  8527                                  
  8528                                   %if _DUALCODE && _EXPRDUALCODE
  8529                                  add_to_areas_linear_code2:
  8530                                  	xor dx, dx
  8531                                  .dxax:
  8532                                  	mov cx, 4
  8533                                  @@:
  8534                                  	shl ax, 1
  8535                                  	rcl dx, 1
  8536                                  	loop @B
  8537                                  
  8538                                  	add word [areas_sub + AREASTRUCSUB_size + areastrucsubLinear], ax
  8539                                  	adc word [areas_sub + AREASTRUCSUB_size + areastrucsubLinear + 2], dx
  8540                                  	add word [areas_sub + AREASTRUCSUB_size + areastrucsubLinearEnd], ax
  8541                                  	adc word [areas_sub + AREASTRUCSUB_size + areastrucsubLinearEnd + 2], dx
  8542                                  	retn
  8543                                   %endif
  8544                                  %endif
  8545                                  
  8546                                  
  8547                                  %if _CONFIG
  8548                                  do_truename:
  8549                                  .:
  8550 00003387 16                      	push ss
  8551 00003388 1F                      	pop ds
  8552 00003389 89D6                    	mov si, dx		; ds:si -> source
  8553 0000338B 16                      	push ss
  8554 0000338C 07                      	pop es
  8555 0000338D 89D7                    	mov di, dx		; es:di -> destination (same)
  8556 0000338F B460                    	mov ah, 60h
  8557 00003391 CD21                    	int 21h
  8558 00003393 7309                    	jnc .done
  8559 00003395 803C00                  	cmp byte [si], 0	; empty ? (kernel rejects this)
  8560 00003398 C7042E00                	mov word [si], "."	; make a dot + NUL (current directory)
  8561 0000339C 74E9                    	je .			; if expected failure then repeat -->
  8562                                  
  8563                                  .done:
  8564 0000339E B000                    	mov al, 0
  8565 000033A0 B98000                  	mov cx, 128
  8566 000033A3 F2AE                    	repne scasb		; scan for NUL
  8567 000033A5 4F                      	dec di			; -> at the NUL
  8568                                  
  8569                                  @@:
  8570 000033A6 39F7                    	cmp di, si
  8571 000033A8 760C                    	jbe @F
  8572 000033AA 807DFF2F                	cmp byte [di - 1], '/'
  8573 000033AE 740A                    	je @FF
  8574 000033B0 807DFF5C                	cmp byte [di - 1], '\'
  8575 000033B4 7404                    	je @FF
  8576                                  @@:
  8577 000033B6 C6055C                  	mov byte [di], '\'
  8578 000033B9 47                      	inc di
  8579                                  @@:
  8580 000033BA C3                      	retn
  8581                                  %endif
  8582                                  
  8583                                  
  8584                                  %if _EXTENSIONS
  8585                                  init_eld:
  8586 000033BB 16                      	push ss
  8587 000033BC 1F                      	pop ds
  8588                                  
  8589                                  	numdef ELD_DEBUG_LINKCALL_NONZERO, 0, 32
  8590                                  %if _ELD_DEBUG_LINKCALL_NONZERO
  8591                                   %if _ELD_DEBUG_LINKCALL_NONZERO & 15
  8592                                    %error Invalid size
  8593                                   %endif
  8594                                   %if _ELD_DEBUG_LINKCALL_NONZERO < 32
  8595                                    %error Invalid size
  8596                                   %endif
  8597                                   %if _ELD_DEBUG_LINKCALL_NONZERO > 65520
  8598                                    %error Invalid size
  8599                                   %endif
  8600                                  	mov ax, word [extseg_size]
  8601                                  	mov di, word [extseg_used]
  8602                                  	sub ax, di			; = amount free space
  8603                                  	jc @F
  8604                                  	mov cx, _ELD_DEBUG_LINKCALL_NONZERO
  8605                                  	cmp ax, cx
  8606                                  	jb @F
  8607                                  	mov es, word [extseg]		; es:di -> where to place ELD instance
  8608                                  	xor ax, ax
  8609                                  	push di
  8610                                  	shr cx, 1			; = amount words
  8611                                  	rep stosw			; zero
  8612                                  	mov word [extseg_used], di	; -> behind ELD
  8613                                  	xchg ax, di			; ax -> behind ELD
  8614                                  	pop di
  8615                                  	mov word [es:di + eldiStartCode], di
  8616                                  	mov word [es:di + eldiEndCode], ax
  8617                                  	mov ax, "--"
  8618                                  	mov cl, 4
  8619                                  	add di, eldiIdentifier
  8620                                  	rep stosw
  8621                                  
  8622                                  @@:
  8623                                  %endif
  8624                                  
  8625 000033BD A1[0000]                	mov ax, word [extseg_size]
  8626 000033C0 8B3E[0000]              	mov di, word [extseg_used]
  8627 000033C4 29F8                    	sub ax, di			; = amount free space
  8628 000033C6 7233                    	jc .ret
  8629 000033C8 3D8000                  	cmp ax, eld_linkcall_size	; enough ?
  8630 000033CB 722E                    	jb .ret
  8631 000033CD 89F8                    	mov ax, di			; -> where to install this ELD
  8632 000033CF 8E06[0000]              	mov es, word [extseg]		; es:di -> where to place ELD instance
  8633 000033D3 0E                      	push cs
  8634 000033D4 1F                      	pop ds				; ! ds no longer equals ss
  8635 000033D5 BE[820D]                	mov si, eld_linkcall + 2	; ds:si -> ELD source plus one word
  8636 000033D8 B93E00                  	mov cx, eld_linkcall_size_w - 2	; cx = length less two words
  8637 000033DB AB                      	stosw				; init eldiStartCode
  8638 000033DC A5                      	movsw
  8639 000033DD 260145FE                	add word [es:di - 2], ax	; init eldiEndCode
  8640 000033E1 F3A5                    	rep movsw			; write our ELD
  8641 000033E3 16                      	push ss
  8642 000033E4 1F                      	pop ds
  8643 000033E5 893E[0000]              	mov word [extseg_used], di	; -> behind ELD
  8644 000033E9 83C028                  	add ax, eld_linkcall.to_code1 - eld_linkcall
  8645 000033EC A3[0000]                	mov word [linkcall_table.code1], ax
  8646                                   %if _DUALCODE
  8647                                  	add ax, eld_linkcall.to_code2 - eld_linkcall.to_code1
  8648                                  	mov word [linkcall_table.code2], ax
  8649                                  	add ax, eld_linkcall.to_entry - eld_linkcall.to_code2
  8650                                   %else
  8651 000033EF 83C0F8                  	add ax, eld_linkcall.to_entry - eld_linkcall.to_code1
  8652                                   %endif
  8653 000033F2 A3[0000]                	mov word [linkcall_table.entry], ax
  8654 000033F5 C706[0000]0100          	mov word [linkcall_table.init], 1
  8655                                  .ret:
  8656 000033FB 16                      	push ss
  8657 000033FC 1F                      	pop ds
  8658 000033FD 16                      	push ss
  8659 000033FE 07                      	pop es
  8660 000033FF C3                      	retn
  8661                                  %endif
  8662                                  
  8663                                  %if !_LINK && _LINK_COMPAT
  8664                                  %ifn _ONLY386 || _ONLYNON386
  8665                                  	align 2, db 0
  8666                                  		; Table of patches that are to be set NOP if running on a 386.
  8667                                  writepatchtable patch_386_table, PATCH_386_TABLE
  8668                                  %undef PATCH_386_TABLE
  8669                                  
  8670                                  	align 2, db 0				; align on word boundary
  8671                                  		; Table of patches that are to be set NOP if not running on a 386.
  8672                                  writepatchtable patch_no386_table, PATCH_NO386_TABLE
  8673                                  %undef PATCH_NO386_TABLE
  8674                                  
  8675                                  %if _DUALCODE
  8676                                  	align 2, db 0
  8677                                  		; Table of patches that are to be set NOP if running on a 386.
  8678                                  writepatchtable patch_386_table2, PATCH_386_TABLE2
  8679                                  %undef PATCH_386_TABLE2
  8680                                  
  8681                                  	align 2, db 0				; align on word boundary
  8682                                  		; Table of patches that are to be set NOP if not running on a 386.
  8683                                  writepatchtable patch_no386_table2, PATCH_NO386_TABLE2
  8684                                  %undef PATCH_NO386_TABLE2
  8685                                  %else
  8686                                   %assign __patch_no386_table2_method 0
  8687                                   %assign __patch_386_table2_method 0
  8688                                  %endif
  8689                                  
  8690                                  	align 2, db 0
  8691                                  		; Table of patches that are to be set NOP if running on a 386.
  8692                                  writepatchtable patch_386_tableentry, PATCH_386_TABLEENTRY
  8693                                  %undef PATCH_386_TABLEENTRY
  8694                                  
  8695                                  	align 2, db 0				; align on word boundary
  8696                                  		; Table of patches that are to be set NOP if not running on a 386.
  8697                                  writepatchtable patch_no386_tableentry, PATCH_NO386_TABLEENTRY
  8698                                  %undef PATCH_NO386_TABLEENTRY
  8699                                  %endif
  8700                                  
  8701                                  %if _DUALCODE && ! _PM
  8702                                  	align 2, db 0
  8703                                  relocate_from_code:
  8704                                  	dw  PATCH_RELOCATE_FROM_lDEBUG_CODE
  8705                                  .end:
  8706                                  	align 2, db 0
  8707                                  relocate_from_code2:
  8708                                  	dw  PATCH_RELOCATE_FROM_lDEBUG_CODE2
  8709                                  .end:
  8710                                  
  8711                                  %unimacro dualcall 1.nolist
  8712                                  	; make sure we do not allow later uses
  8713                                  %endif
  8714                                  %endif
