     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-05-27)"
    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
   208          ------------------  <2>  note: usesection lDEBUG_CODE2
   209                              <2> %else
   210                              <2> 	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
   216          ------------------  <2>  note: usesection lDEBUG_CODE2
   217                              <2>  %else
   218                              <2> 	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
   573                              <3> 
   574                              <3>  extern msg.copybpb
   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 00000006 ????                <1> saSegment:	resw 1
   740 00000008 ????                <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 00000004 ????                <1> so16aSegment:	resw 1
   754 00000006 ????                <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 00000002 ????                <1> soaSegment:	resw 1
   778 00000004 ????                <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> lsCopyBPB:	resd 1	; if not all-zeroes, copy BPB to far pointer
   815 00000018 ????                <1> lsCheckOffset:	resw 1	; offset in file segment of word to check
   816 0000001A ????                <1> lsCheckValue:	resw 1	; value to check for word, 0 if unused
   817 0000001C ????????????????    <1> lsName:		resq 1	; ASCIZ load protocol name
   818                              <1> 	endstruc
   819                              <1> 
   820                              <1> 		numdef LUF_DEFAULT_DISKETTE, 0
   821                              <1> 		numdef LUF_DEFAULT_HARDDISK, 0
   822                              <1> %endif
   823                              <1> 
   824                              <1> 
   825                              <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
   826                              <1> 
   827                              <1> 
   828                              <1> 	struc INPUTFILEHANDLE
   829 00000000 ????                <1> ifhHandle:	resw 1
   830 00000002 ????                <1> ifhFlags:	resw 1
   831 00000004 ????????            <1> ifhParentSeek:	resd 1
   832                              <1> 	endstruc
   833                              <1> 
   834                              <1> ifhfIsDup:		equ  100h	; before closing, seek it back
   835                              <1> 	; same value as LBA flag for boot load input files
   836                              <1> ifhfTestReserved1:	equ 1000h
   837                              <1> ifhfTestReserved2:	equ 2000h
   838                              <1> ifhfQuietInput:		equ 4000h	; do not display prompt and input
   839                              <1> ifhfQuietOutput:	equ 8000h	; do not display normal output
   840                              <1> 	; these four are valid for both input file handles and
   841                              <1> 	;  boot load input files.
   842                              <1> 
   843                              <1> 
   844                              <1> 	struc AREASTRUC
   845 00000000 <res 18h>           <1> areastrucEntry:		resb 24
   846 00000018 ????????            <1> areastrucNext:		resd 1
   847 0000001C ????????            <1> areastrucPrev:		resd 1
   848 00000020 ????                <1> areastrucSubAmount:	resw 1
   849 00000022 ????                <1> areastrucSubOffset:	resw 1
   850 00000024 ????                <1> areastrucFunAmount:	resw 1
   851 00000026 ????                <1> areastrucFunOffset:	resw 1
   852                              <1> 	endstruc
   853                              <1> 
   854                              <1> 	struc AREASTRUCSUB
   855 00000000 ????????            <1> areastrucsubLinear:	resd 1
   856 00000004 ????????            <1> areastrucsubLinearEnd:	resd 1
   857 00000008 ????                <1> areastrucsubListOffset:	resw 1
   858 0000000A ????                <1> areastrucsubListAmount:	resw 1
   859                              <1> 	endstruc
   860                              <1> 
   861                              <1> 	struc AREASTRUCFUN
   862 00000000 ????????            <1> areastrucfunLinear:	resd 1
   863 00000004 ????????            <1> areastrucfunLinearEnd:	resd 1
   864 00000008 ????                <1> areastrucfunListOffset:	resw 1
   865 0000000A ????                <1> areastrucfunListAmount:	resw 1
   866                              <1> 	endstruc
   867                              <1> 
   868                              <1> 	struc AREA
   869 00000000 ????                <1> areastart:		resw 1
   870 00000002 ????                <1> areaend:		resw 1
   871 00000004 ????                <1> areamessage:		resw 1
   872 00000006 ????                <1> 			resw 1
   873                              <1> 	endstruc
   874                              <1> 
   875                              <1> 
   876                              <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
   877                              <1> 
   878                              <1> 
   879                              <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
   880                              <1> 
   881                              <1> 
   882                              <1> %if _VDD
   883                              <1> ; standard BOPs for communication with DEBXXVDD on NT platforms
   884                              <1> %macro RegisterModule 0.nolist
   885                              <1> 	db 0C4h, 0C4h, 58h, 0
   886                              <1> 	nop
   887                              <1> %endmacro
   888                              <1> %macro UnRegisterModule 0.nolist
   889                              <1> 	db 0C4h, 0C4h, 58h, 1
   890                              <1> 	nop
   891                              <1> %endmacro
   892                              <1> %macro DispatchCall 0.nolist
   893                              <1> 	db 0C4h, 0C4h, 58h, 2
   894                              <1> 	nop
   895                              <1> %endmacro
   896                              <1> %endif
   897                              <1> 
   898                              <1> %assign CODE_INSURE_COUNT 0
   899                              <1> 
   900                              <1> 		; The entry_to_code_seg/_sel dispatcher in lDEBUG_DATA_ENTRY
   901                              <1> 		;  detects mistaken debugger breakpoints in its
   902                              <1> 		;  in-code-parameter by checking for a low-byte
   903                              <1> 		;  value equal to 0CCh (one-byte int3 opcode).
   904                              <1> 		; Therefore, we insure that all destinations jumped to
   905                              <1> 		;  via that dispatcher do not happen to be located
   906                              <1> 		;  on an offset that gives 0CCh in the low byte.
   907                              <1> 	%imacro code_insure_low_byte_not_0CCh 0.nolist
   908                              <1> %ifn _LINK
   909                              <1>  %if (($ - _CURRENT_SECTION %+ _start) & 0FFh) == 0CCh
   910                              <1> 	nop
   911                              <1>   %assign CODE_INSURE_COUNT 1 + CODE_INSURE_COUNT
   912                              <1>  %endif
   913                              <1> %endif
   914                              <1> 	%endmacro
   915                              <1> 
   916                              <1> 
   917                              <1> 		; dual code segments
   918                              <1> %if _DUALCODE && _PM
   919                              <1> 
   920                              <1> %if _DEBUG
   921                              <1> %idefine dualfunction comment
   922                              <1> %else
   923                              <1> %idefine dualfunction code_insure_low_byte_not_0CCh
   924                              <1> %endif
   925                              <1> 
   926                              <1> %idefine dualreturn call _CURRENT_SECTION %+ _dualret_helper
   927                              <1> %idefine dualdistance far
   928                              <1> 	%imacro dualcall 1.nolist
   929                              <1> %ifndef SECTION_OF_%1
   930                              <1>  %error Unknown target section for symbol %1
   931                              <1> %endif
   932                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _dualcall_helper
   933                              <1>  %if _DEBUG
   934                              <1> 	jmp strict short %%skipdata
   935                              <1>  %endif
   936                              <1> 	dw %1
   937                              <1> %%skipdata:
   938                              <1> 	%endmacro
   939                              <1> 	%imacro nearcall 1.nolist
   940                              <1> %ifndef SECTION_OF_%1
   941                              <1>  %error Unknown target section for symbol %1
   942                              <1> %endif
   943                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
   944                              <1> 	call %1
   945                              <1> %else
   946                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _nearcall_helper
   947                              <1>  %if _DEBUG
   948                              <1> 	jmp strict short %%skipdata
   949                              <1>  %endif
   950                              <1> 	dw %1
   951                              <1> %%skipdata:
   952                              <1> %endif
   953                              <1> 	%endmacro
   954                              <1> 
   955                              <1> %elif _DUALCODE && ! _PM
   956                              <1> 
   957                              <1> %idefine dualfunction comment
   958                              <1> %idefine dualreturn
   959                              <1> %idefine dualdistance far
   960                              <1> 
   961                              <1> %ifn _LINK
   962                              <1> %define PATCH_RELOCATE_FROM_lDEBUG_CODE ""
   963                              <1> %define PATCH_RELOCATE_FROM_lDEBUG_CODE2 ""
   964                              <1> 	%imacro dualcall 1.nolist
   965                              <1> %ifndef SECTION_OF_%1
   966                              <1>  %error Unknown target section for symbol %1
   967                              <1> %endif
   968                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
   969                              <1> 	push cs
   970                              <1> 	call %1
   971                              <1> %else
   972                              <1> 	call relocatedzero:%1
   973                              <1> %push
   974                              <1> %assign %$entry ($ + _CURRENT_SECTION %+ FIXUP) - 2
   975                              <1> 	relocatelist _CURRENT_SECTION, %$entry
   976                              <1> %pop
   977                              <1> %endif
   978                              <1> 	%endmacro
   979                              <1> 	%imacro relocatelist 2.nolist
   980                              <1>  %define PATCH_RELOCATE_FROM_%1 %[PATCH_RELOCATE_FROM_%1],%2
   981                              <1> 	%endmacro
   982                              <1> %else		; _LINK
   983                              <1> 	%idefine dualcall dualcall_with_filename __FILE__,
   984                              <1> 	%imacro dualcall_with_filename 2.nolist
   985                              <1> %ifndef SECTION_OF_%2
   986                              <1>  %error Unknown target section for symbol %2
   987                              <1> %endif
   988                              <1> %ifidni %[SECTION_OF_%2], _CURRENT_SECTION
   989                              <1> 	push cs
   990                              <1> 	call %2
   991                              <1> %else
   992                              <1> 	call relocatedzero:%2
   993                              <1> %ifidn _CURRENT_SECTION, lDEBUG_CODE
   994                              <1>  wllist Lrelocate_from_code, equ $ - 2, %1
   995                              <1> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
   996                              <1>  wllist Lrelocate_from_code2, equ $ - 2, %1
   997                              <1> %else
   998                              <1>  %error Wrong section
   999                              <1> %endif
  1000                              <1> %endif
  1001                              <1> 	%endmacro
  1002                              <1> %endif		; _LINK
  1003                              <1>  %if _DUALCODENEARDUAL
  1004                              <1> 
  1005                              <1> %if _LINK
  1006                              <1> 	%idefine nearcall nearcall_with_filename __FILE__,
  1007                              <1> 	%imacro nearcall_with_filename 2
  1008                              <1> %ifndef SECTION_OF_%2
  1009                              <1>  %error Unknown target section for symbol %2
  1010                              <1> %endif
  1011                              <1> %ifidni %[SECTION_OF_%2], _CURRENT_SECTION
  1012                              <1> 	call %2
  1013                              <1> %else
  1014                              <1>  %push
  1015                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1016                              <1>  %xdefine %$targetsection SECTION_OF_%2
  1017                              <1>  %deftok %%filenametoken SOURCEFILENAME
  1018                              <1>   %ifndef NEARCALL_THUNK_TO_%2%[%%filenametoken]
  1019                              <1> 	hiddenusesection %$targetsection
  1020                              <1> %define NEARCALL_THUNK_TO_%2%[%%filenametoken] %%nearcall_thunk_to_%2%[%%filenametoken]
  1021                              <1> section_of %%nearcall_thunk_to_%2%[%%filenametoken]
  1022                              <1> dualfunction
  1023                              <1> %%nearcall_thunk_to_%2%[%%filenametoken]:
  1024                              <1> 	call %2
  1025                              <1> 	dualreturn
  1026                              <1> 	retf
  1027                              <1> 
  1028                              <1> 	hiddenusesection %$originalsection
  1029                              <1>   %endif
  1030                              <1>  %pop
  1031                              <1> 	dualcall_with_filename %1, NEARCALL_THUNK_TO_%2%[%%filenametoken]
  1032                              <1> %endif
  1033                              <1> 	%endmacro
  1034                              <1> %elif _LINK_COMPAT	; _LINK
  1035                              <1> 	%imacro nearcall 1
  1036                              <1> %ifndef SECTION_OF_%1
  1037                              <1>  %error Unknown target section for symbol %1
  1038                              <1> %endif
  1039                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1040                              <1> 	call %1
  1041                              <1> %else
  1042                              <1>  %push
  1043                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1044                              <1>  %xdefine %$targetsection SECTION_OF_%1
  1045                              <1>  %deftok %%filenametoken SOURCEFILENAME
  1046                              <1>   %ifndef NEARCALL_THUNK_TO_%1%[%%filenametoken]
  1047                              <1> 	hiddenusesection %$targetsection
  1048                              <1> %define NEARCALL_THUNK_TO_%1%[%%filenametoken] %%nearcall_thunk_to_%1%[%%filenametoken]
  1049                              <1> section_of %%nearcall_thunk_to_%1%[%%filenametoken]
  1050                              <1> dualfunction
  1051                              <1> %%nearcall_thunk_to_%1%[%%filenametoken]:
  1052                              <1> 	call %1
  1053                              <1> 	dualreturn
  1054                              <1> 	retf
  1055                              <1> 
  1056                              <1> 	hiddenusesection %$originalsection
  1057                              <1>   %endif
  1058                              <1>  %pop
  1059                              <1> 	dualcall NEARCALL_THUNK_TO_%1%[%%filenametoken]
  1060                              <1> %endif
  1061                              <1> 	%endmacro
  1062                              <1> %else		; _LINK, _LINK_COMPAT
  1063                              <1> 	%imacro nearcall 1
  1064                              <1> %ifndef SECTION_OF_%1
  1065                              <1>  %error Unknown target section for symbol %1
  1066                              <1> %endif
  1067                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1068                              <1> 	call %1
  1069                              <1> %else
  1070                              <1>  %push
  1071                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1072                              <1>  %xdefine %$targetsection SECTION_OF_%1
  1073                              <1>   %ifndef NEARCALL_THUNK_TO_%1
  1074                              <1> 	hiddenusesection %$targetsection
  1075                              <1> %define NEARCALL_THUNK_TO_%1 %%nearcall_thunk_to_%1
  1076                              <1> section_of %%nearcall_thunk_to_%1
  1077                              <1> dualfunction
  1078                              <1> %%nearcall_thunk_to_%1:
  1079                              <1> 	call %1
  1080                              <1> 	dualreturn
  1081                              <1> 	retf
  1082                              <1> 
  1083                              <1> 	hiddenusesection %$originalsection
  1084                              <1>   %endif
  1085                              <1>  %pop
  1086                              <1> 	dualcall NEARCALL_THUNK_TO_%1
  1087                              <1> %endif
  1088                              <1> 	%endmacro
  1089                              <1> %endif		; _LINK, _LINK_COMPAT
  1090                              <1>  %else
  1091                              <1> 	%imacro nearcall 1.nolist
  1092                              <1> %ifndef SECTION_OF_%1
  1093                              <1>  %error Unknown target section for symbol %1
  1094                              <1> %endif
  1095                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1096                              <1> 	call %1
  1097                              <1> %else
  1098                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _nearcall_helper
  1099                              <1>  %if _DEBUG
  1100                              <1> 	jmp strict short %%skipdata
  1101                              <1>  %endif
  1102                              <1> 	dw %1
  1103                              <1> %%skipdata:
  1104                              <1> %endif
  1105                              <1> 	%endmacro
  1106                              <1>  %endif
  1107                              <1> %elif ! _DUALCODE
  1108                              <1> 
  1109                              <1> %idefine dualfunction comment
  1110                              <1> %idefine dualreturn
  1111                              <1> %idefine dualdistance near
  1112                              <1> 	%imacro dualcall 1.nolist
  1113                              <1> 	call %1
  1114                              <1> 	%endmacro
  1115                              <1> 	%imacro nearcall 1.nolist
  1116                              <1> 	call %1
  1117                              <1> 	%endmacro
  1118                              <1> %assign _SYMBOLICDUALCODE 0
  1119                              <1> %assign _SYMBOLASMDUALCODE 0
  1120                              <1> 
  1121                              <1> %else
  1122                              <1>  %error Unexpected defines
  1123                              <1> %endif
  1124                              <1> 
  1125                              <1> %ifn _SYMBOLICDUALCODE
  1126                              <1>  %assign _SYMBOLASMDUALCODE 0
  1127                              <1> %endif
  1128                              <1> 
  1129                              <1>  %if _SYMBOLIC && _DUALCODE && _SYMBOLASMDUALCODE
  1130                              <1> %idefine dual2function	dualfunction
  1131                              <1> %idefine dual2return	dualreturn
  1132                              <1> %idefine dual2distance	dualdistance
  1133                              <1> %idefine dual2call	dualcall
  1134                              <1>  %else
  1135                              <1> %idefine dual2function comment
  1136                              <1> %idefine dual2return
  1137                              <1> %idefine dual2distance near
  1138                              <1> 	%imacro dual2call 1.nolist
  1139                              <1> 	call %1
  1140                              <1> 	%endmacro
  1141                              <1>  %endif
  1142                              <1> 
  1143                              <1> 
  1144                              <1> 	numdef CHECKSECTION, 0
  1145                              <1> 	numdef CHECKCALLSECTION, _CHECKSECTION
  1146                              <1> 	numdef CHECKJMPSECTION, _CHECKSECTION
  1147                              <1> 	numdef CHECKJCCSECTION, _CHECKSECTION
  1148                              <1> 
  1149                              <1> %if _CHECKCALLSECTION
  1150                              <1> 	%imacro call 1.nolist
  1151                              <1> 	%? %1
  1152                              <1> checksection %1, %?, call
  1153                              <1> 	%endmacro
  1154                              <1> %endif
  1155                              <1> %if _CHECKJMPSECTION
  1156                              <1> 	%imacro jmp 1.nolist
  1157                              <1> 	%? %1
  1158                              <1> checksection %1, %?, jmp
  1159                              <1> 	%endmacro
  1160                              <1> %endif
  1161                              <1> %if _CHECKJCCSECTION
  1162                              <1> 	%imacro je 1.nolist
  1163                              <1> 	%? %1
  1164                              <1> checksection %1, %?, jcc
  1165                              <1> 	%endmacro
  1166                              <1> 	%imacro jne 1.nolist
  1167                              <1> 	%? %1
  1168                              <1> checksection %1, %?, jcc
  1169                              <1> 	%endmacro
  1170                              <1> 	%imacro jz 1.nolist
  1171                              <1> 	%? %1
  1172                              <1> checksection %1, %?, jcc
  1173                              <1> 	%endmacro
  1174                              <1> 	%imacro jnz 1.nolist
  1175                              <1> 	%? %1
  1176                              <1> checksection %1, %?, jcc
  1177                              <1> 	%endmacro
  1178                              <1> 
  1179                              <1> 	%imacro jb 1.nolist
  1180                              <1> 	%? %1
  1181                              <1> checksection %1, %?, jcc
  1182                              <1> 	%endmacro
  1183                              <1> 	%imacro jnb 1.nolist
  1184                              <1> 	%? %1
  1185                              <1> checksection %1, %?, jcc
  1186                              <1> 	%endmacro
  1187                              <1> 	%imacro jbe 1.nolist
  1188                              <1> 	%? %1
  1189                              <1> checksection %1, %?, jcc
  1190                              <1> 	%endmacro
  1191                              <1> 	%imacro jnbe 1.nolist
  1192                              <1> 	%? %1
  1193                              <1> checksection %1, %?, jcc
  1194                              <1> 	%endmacro
  1195                              <1> 	%imacro jc 1.nolist
  1196                              <1> 	%? %1
  1197                              <1> checksection %1, %?, jcc
  1198                              <1> 	%endmacro
  1199                              <1> 	%imacro jnc 1.nolist
  1200                              <1> 	%? %1
  1201                              <1> checksection %1, %?, jcc
  1202                              <1> 	%endmacro
  1203                              <1> 	%imacro ja 1.nolist
  1204                              <1> 	%? %1
  1205                              <1> checksection %1, %?, jcc
  1206                              <1> 	%endmacro
  1207                              <1> 	%imacro jna 1.nolist
  1208                              <1> 	%? %1
  1209                              <1> checksection %1, %?, jcc
  1210                              <1> 	%endmacro
  1211                              <1> 	%imacro jae 1.nolist
  1212                              <1> 	%? %1
  1213                              <1> checksection %1, %?, jcc
  1214                              <1> 	%endmacro
  1215                              <1> 	%imacro jnae 1.nolist
  1216                              <1> 	%? %1
  1217                              <1> checksection %1, %?, jcc
  1218                              <1> 	%endmacro
  1219                              <1> 
  1220                              <1> 	%imacro jl 1.nolist
  1221                              <1> 	%? %1
  1222                              <1> checksection %1, %?, jcc
  1223                              <1> 	%endmacro
  1224                              <1> 	%imacro jnl 1.nolist
  1225                              <1> 	%? %1
  1226                              <1> checksection %1, %?, jcc
  1227                              <1> 	%endmacro
  1228                              <1> 	%imacro jle 1.nolist
  1229                              <1> 	%? %1
  1230                              <1> checksection %1, %?, jcc
  1231                              <1> 	%endmacro
  1232                              <1> 	%imacro jnle 1.nolist
  1233                              <1> 	%? %1
  1234                              <1> checksection %1, %?, jcc
  1235                              <1> 	%endmacro
  1236                              <1> 	%imacro jg 1.nolist
  1237                              <1> 	%? %1
  1238                              <1> checksection %1, %?, jcc
  1239                              <1> 	%endmacro
  1240                              <1> 	%imacro jng 1.nolist
  1241                              <1> 	%? %1
  1242                              <1> checksection %1, %?, jcc
  1243                              <1> 	%endmacro
  1244                              <1> 	%imacro jge 1.nolist
  1245                              <1> 	%? %1
  1246                              <1> checksection %1, %?, jcc
  1247                              <1> 	%endmacro
  1248                              <1> 	%imacro jnge 1.nolist
  1249                              <1> 	%? %1
  1250                              <1> checksection %1, %?, jcc
  1251                              <1> 	%endmacro
  1252                              <1> 
  1253                              <1> 	%imacro jo 1.nolist
  1254                              <1> 	%? %1
  1255                              <1> checksection %1, %?, jcc
  1256                              <1> 	%endmacro
  1257                              <1> 	%imacro jno 1.nolist
  1258                              <1> 	%? %1
  1259                              <1> checksection %1, %?, jcc
  1260                              <1> 	%endmacro
  1261                              <1> 	%imacro jp 1.nolist
  1262                              <1> 	%? %1
  1263                              <1> checksection %1, %?, jcc
  1264                              <1> 	%endmacro
  1265                              <1> 	%imacro jnp 1.nolist
  1266                              <1> 	%? %1
  1267                              <1> checksection %1, %?, jcc
  1268                              <1> 	%endmacro
  1269                              <1> 	%imacro jpe 1.nolist
  1270                              <1> 	%? %1
  1271                              <1> checksection %1, %?, jcc
  1272                              <1> 	%endmacro
  1273                              <1> 	%imacro jnpe 1.nolist
  1274                              <1> 	%? %1
  1275                              <1> checksection %1, %?, jcc
  1276                              <1> 	%endmacro
  1277                              <1> 	%imacro jpo 1.nolist
  1278                              <1> 	%? %1
  1279                              <1> checksection %1, %?, jcc
  1280                              <1> 	%endmacro
  1281                              <1> 	%imacro jnpo 1.nolist
  1282                              <1> 	%? %1
  1283                              <1> checksection %1, %?, jcc
  1284                              <1> 	%endmacro
  1285                              <1> 	%imacro js 1.nolist
  1286                              <1> 	%? %1
  1287                              <1> checksection %1, %?, jcc
  1288                              <1> 	%endmacro
  1289                              <1> 	%imacro jns 1.nolist
  1290                              <1> 	%? %1
  1291                              <1> checksection %1, %?, jcc
  1292                              <1> 	%endmacro
  1293                              <1> 
  1294                              <1> 	%imacro jcxz 1.nolist
  1295                              <1> 	%? %1
  1296                              <1> checksection %1, %?, jcc
  1297                              <1> 	%endmacro
  1298                              <1> 	%imacro jecxz 1.nolist
  1299                              <1> 	%? %1
  1300                              <1> checksection %1, %?, jcc
  1301                              <1> 	%endmacro
  1302                              <1> 	%imacro loop 1.nolist
  1303                              <1> 	%? %1
  1304                              <1> checksection %1, %?, jcc
  1305                              <1> 	%endmacro
  1306                              <1> 	%imacro loopz 1.nolist
  1307                              <1> 	%? %1
  1308                              <1> checksection %1, %?, jcc
  1309                              <1> 	%endmacro
  1310                              <1> 	%imacro loopnz 1.nolist
  1311                              <1> 	%? %1
  1312                              <1> checksection %1, %?, jcc
  1313                              <1> 	%endmacro
  1314                              <1> 	%imacro loope 1.nolist
  1315                              <1> 	%? %1
  1316                              <1> checksection %1, %?, jcc
  1317                              <1> 	%endmacro
  1318                              <1> 	%imacro loopne 1.nolist
  1319                              <1> 	%? %1
  1320                              <1> checksection %1, %?, jcc
  1321                              <1> 	%endmacro
  1322                              <1> %endif
  1323                              <1> 
  1324                              <1> 	%imacro checksection 3.nolist
  1325                              <1> %push
  1326                              <1>  %defstr %$string %1
  1327                              <1>  %substr %$shortword %$string 1, 5
  1328                              <1>  %substr %$shortsep %$string 6, 1
  1329                              <1>  %substr %$nearword %$string 1, 4
  1330                              <1>  %substr %$nearsep %$string 5, 1
  1331                              <1>  %substr %$farword %$string 1, 3
  1332                              <1>  %substr %$farsep %$string 4, 1
  1333                              <1>  %assign %$isshort 0
  1334                              <1>  %ifidni %$shortword, "short"
  1335                              <1>   %if %$shortsep == 32 || %$shortsep == 9
  1336                              <1>    %assign %$isshort 1
  1337                              <1>    %substr %$string %$string 7, -1
  1338                              <1>   %elif %$shortsep == '['
  1339                              <1>    %assign %$isshort 1
  1340                              <1>    %substr %$string %$string 6, -1
  1341                              <1>   %endif
  1342                              <1>  %endif
  1343                              <1>  %assign %$isnear 0
  1344                              <1>  %ifidni %$nearword, "near"
  1345                              <1>   %if %$nearsep == 32 || %$nearsep == 9
  1346                              <1>    %assign %$isnear 1
  1347                              <1>    %substr %$string %$string 6, -1
  1348                              <1>   %elif %$nearsep == '['
  1349                              <1>    %assign %$isnear 1
  1350                              <1>    %substr %$string %$string 5, -1
  1351                              <1>   %endif
  1352                              <1>  %endif
  1353                              <1>  %assign %$isfar 0
  1354                              <1>  %ifidni %$farword, "far"
  1355                              <1>   %if %$farsep == 32 || %$farsep == 9
  1356                              <1>    %assign %$isfar 1
  1357                              <1>    %substr %$string %$string 5, -1
  1358                              <1>   %elif %$farsep == '['
  1359                              <1>    %assign %$isfar 1
  1360                              <1>    %substr %$string %$string 4, -1
  1361                              <1>   %endif
  1362                              <1>  %endif
  1363                              <1> 
  1364                              <1>  %deftok %$token %$string
  1365                              <1> 
  1366                              <1>  %assign %$size 2
  1367                              <1>  %assign %$isreg 0
  1368                              <1>  %assign %$exit 0
  1369                              <1>  %rep 2
  1370                              <1>   %ifn %$exit
  1371                              <1>    %if %$size == 2
  1372                              <1>     %define %$regnames "ax  cx  dx  bx  sp  bp  si  di  "
  1373                              <1>    %elif %$size == 4
  1374                              <1>     %define %$regnames "eax ecx edx ebx esp ebp esi edi "
  1375                              <1>    %endif
  1376                              <1>    %assign %$index 0
  1377                              <1>    %rep 8
  1378                              <1>     %ifn %$exit
  1379                              <1>      %substr %$reg %$regnames %$index * 4 + 1, 4
  1380                              <1>      %deftok %$reg %$reg
  1381                              <1>      %ifnempty %$reg
  1382                              <1>       %ifidni %$reg, %$token
  1383                              <1>        %assign %$isreg %$size
  1384                              <1>        %assign %$exit 1
  1385                              <1>        %exitrep
  1386                              <1>       %endif
  1387                              <1>      %endif
  1388                              <1>     %endif
  1389                              <1>     %assign %$index %$index + 1
  1390                              <1>    %endrep
  1391                              <1>    %if %$exit
  1392                              <1>     %exitrep
  1393                              <1>    %endif
  1394                              <1>    %assign %$size %$size * 2
  1395                              <1>   %endif
  1396                              <1>  %endrep
  1397                              <1> 
  1398                              <1>  %assign %$ismulti 0
  1399                              <1>  %assign %$ismem 0
  1400                              <1>  %strlen %$length %$string
  1401                              <1>  %assign %$ii 0
  1402                              <1>  %rep %$length
  1403                              <1>   %substr %$point %$string %$ii + 1, 1
  1404                              <1>   %if %$point == 32 || %$point == 9
  1405                              <1>    %assign %$ismulti 1
  1406                              <1>   %endif
  1407                              <1>   %ifidn %$point, '['
  1408                              <1>    %assign %$ismem 1
  1409                              <1>   %endif
  1410                              <1>   %assign %$ii %$ii + 1
  1411                              <1>  %endrep
  1412                              <1> 
  1413                              <1>  %assign %$islocal 0
  1414                              <1>  %substr %$point %$string 1, 1
  1415                              <1>  %substr %$prefix %$string 1, 3
  1416                              <1>  %ifidn %$point, '.'
  1417                              <1>   %ifnidn %$prefix, '..@'
  1418                              <1>    %assign %$islocal 1
  1419                              <1>   %endif
  1420                              <1>  %endif
  1421                              <1> 
  1422                              <1>  %if %$isreg
  1423                              <1>   %if %$isreg == 4
  1424                              <1>    %warning 32-bit reg %3: %2 %1
  1425                              <1>   %else
  1426                              <1>    %warning 16-bit reg %3: %2 %1
  1427                              <1>   %endif
  1428                              <1>  %elif %$ismulti || %$ismem
  1429                              <1>   %warning not single %3: %2 %1
  1430                              <1>  %elif %$islocal
  1431                              <1>   %ifidni %3, call
  1432                              <1>    %warning local %3: %2 %1
  1433                              <1>   %endif
  1434                              <1>  %elifdef SECTION_OF_%[%$token]
  1435                              <1>   %ifnidni SECTION_OF_%[%$token], _CURRENT_SECTION
  1436                              <1>    %error Symbol %$token called wrongly: section_of=SECTION_OF_%[%$token], current=_CURRENT_SECTION
  1437                              <1>   %endif
  1438                              <1>  %endif
  1439                              <1> %pop
  1440                              <1> 	%endmacro
  1441                              <1> 
  1442                              <1> 
  1443                              <1> 	struc MEMREF
  1444 00000000 ????????            <1> mrLinear:		resd 1
  1445 00000004 ????????            <1> mrOffset:		resd 1
  1446 00000008 ????                <1> mrSegmentSelector:	resw 1
  1447 0000000A ????                <1> mrFlags:		resw 1
  1448 0000000C ????????            <1> mrLength:		resd 1
  1449                              <1> 	endstruc
  1450                              <1> 
  1451                              <1> 		; Currently only direct branches are allowed when
  1452                              <1> 		;  disassembling from the U command. (That is,
  1453                              <1> 		;  [disflags] & DIS_F_SHOW is clear.) All other
  1454                              <1> 		;  types of references depend on segment registers
  1455                              <1> 		;  and sometimes base and index registers, which are
  1456                              <1> 		;  not known ahead of time. They are only known for
  1457                              <1> 		;  the R command's disassembly. (DIS_F_SHOW set.)
  1458                              <1> 		; (When a mov ss or pop to ss will change ss, a
  1459                              <1> 		;  subsequent instruction using ss will not be
  1460                              <1> 		;  disassembled with the correct ss value.
  1461                              <1> 		;  This should be rare though. We may at a later
  1462                              <1> 		;  point detect this condition and not display
  1463                              <1> 		;  references with ss then.)
  1464                              <1> mrfBranchDirect:	equ    1
  1465                              <1> mrfMem:			equ    2
  1466                              <1> mrfMemSource:		equ    4
  1467                              <1> mrfMemDest:		equ    8
  1468                              <1> mrfA32:			equ   10h
  1469                              <1> mrfString:		equ   20h
  1470                              <1> mrfStringSource:	equ   40h
  1471                              <1> mrfStringDest:		equ   80h
  1472                              <1> mrfUsesSS:		equ  100h
  1473                              <1> mrfBranchIndirect:	equ  200h
  1474                              <1> 
  1475                              <1> 
  1476                              <1> %if _VXCHG && ! _VXCHGBIOS
  1477                              <1> 	struc XMSM
  1478 00000000 ????????            <1> .size_:		resd 1
  1479 00000004 ????                <1> .srchdl:	resw 1
  1480 00000006 ????????            <1> .srcadr:	resd 1
  1481 0000000A ????                <1> .dsthdl:	resw 1
  1482 0000000C ????????            <1> .dstadr:	resd 1
  1483                              <1> 	endstruc
  1484                              <1> %endif
  1485                              <1> 
  1486                              <1> 
  1487                              <1> 	; doscall is used by symbols.asm and run.asm and in
  1488                              <1> 	;  cmd3_close_handle, so define it prior
  1489                              <1> %if _PM && _NOEXTENDER
  1490                              <1> %macro doscall 0
  1491                              <1> 	nearcall _doscall
  1492                              <1> %endmacro
  1493                              <1> %else
  1494                              <1> 		; When we don't support non-extended DPMI all Int21 calls
  1495                              <1> 		; are either in Real Mode or extended (all are real Int21
  1496                              <1> 		; instructions).
  1497                              <1> %macro doscall 0
  1498                              <1> 	int 21h
  1499                              <1> %endmacro
  1500                              <1> %endif
  1501                              <1> 
  1502                              <1> 
  1503                              <1> %if _LINK
  1504                              <1> %imacro wlcalc 1-2.nolist
  1505                              <1> %deftok %%filenametoken __FILE__
  1506                              <1>  global wlcalc_%1?%[%%l]%[%%filenametoken]
  1507                              <1> wlcalc_%1?%[%%l]%[%%filenametoken]: %2
  1508                              <1> %endmacro
  1509                              <1> %endif
  1510                              <1> 
  1511                              <1> %if _BOOTLDR && _LINK
  1512                              <1> %macro lot_equate 2.nolist
  1513                              <1> LOAD_%2 equ %1
  1514                              <1> %endmacro
  1515                              <1> 
  1516                              <1> 	lot_equate    1, SET_DL_UNIT
  1517                              <1> 	lot_equate    2, SET_BL_UNIT
  1518                              <1> 	lot_equate    4, SET_SIDI_CLUSTER
  1519                              <1> 	lot_equate  10h, SET_DSSI_DPT
  1520                              <1> 	lot_equate  20h, PUSH_DPT
  1521                              <1> 	lot_equate  40h, DATASTART_HIDDEN
  1522                              <1> 	lot_equate  80h, SET_AXBX_DATASTART
  1523                              <1> 	lot_equate 100h, SET_DSBP_BPB
  1524                              <1> 	lot_equate 200h, LBA_SET_TYPE
  1525                              <1> 	lot_equate 400h, MESSAGE_TABLE
  1526                              <1> 	lot_equate 800h, SET_AXBX_ROOT_HIDDEN
  1527                              <1> 	lot_equate 1000h, CMDLINE
  1528                              <1> 	lot_equate 2000h, NO_BPB
  1529                              <1> 	lot_equate 4000h, SET_DSSI_PARTINFO
  1530                              <1> %endif
  1531                              <1> 
  1532                              <1> %if _HELP_COMPRESSED
  1533                              <1>  %assign NONCOMPRESSEDFLAG 1
  1534                              <1> %else
  1535                              <1>  %assign NONCOMPRESSEDFLAG 0
  1536                              <1> %endif
  1537                              <1> 
  1538                              <1> [list +]
  1539                              <1> 
  1540                              <1> %if _LINK
  1541                              <1>  %if _ONLY386
  1542                              <1> 	cpu 386
  1543                              <1>  %else
  1544                              <1> 	cpu 8086
  1545                              <1>  %endif
  1546                              <1> 
  1547                              <1> auxbuff_size: equ (_AUXBUFFSIZE+15) & ~15
  1548                              <1> 	endarea auxbuff, 1
  1549                              <1> 
  1550                              <1> auxbuff_max_size: equ (_AUXBUFFMAXSIZE+15) & ~15
  1551                              <1> 	endarea auxbuff_max, 1
  1552                              <1> 
  1553                              <1> %if _INIT_MAX
  1554                              <1>  auxbuff_init_size: equ (_AUXBUFFMAXSIZE+15) & ~15
  1555                              <1> %else
  1556                              <1>  auxbuff_init_size: equ (_AUXBUFFSIZE+15) & ~15
  1557                              <1> %endif
  1558                              <1> 	endarea auxbuff_init, 1
  1559                              <1> 
  1560                              <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
  1561                              <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[DA0F]                	mov dx, imsg.early_mem_fail
   179                                  .earlyfail:
   180 00000025 E8EB1B                  	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 E82F1B                  	call init_movp
   252                                  %endif
   253                                  
   254 00000053 52                      	push dx
   255 00000054 E8D701                  	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[360E][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[3C0E][EC34]      	mov word [cs:init_layout], init_app_layout_1
   351 00000078 E8B401                  	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[3C0E][3A35]      	mov word [cs:init_layout], init_app_layout_2
   368 00000090 E89C01                  	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[360E][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[3C0E][EC34]      	mov word [cs:init_layout], init_app_layout_3
   418 000000B0 E87C01                  	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[9310]                	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 E83801                  	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 E8B21A                  	call init_movp
   449 000000D0 8916[0000]              	mov word [messageseg], dx
   450                                   %if _HELP_COMPRESSED && ! _PM
   451                                  	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 000000D4 C706[0000][0000]        	mov word [messageseg_size], behind_messagesegment_nobits_truncated wrt MESSAGESEGMENT
   458                                     %endif
   459                                    %if _HELP_COMPRESSED
   460 000000DA C706[0000][0000]        	mov word [indirect_hshrink_message_buffer], truncated_hshrink_message_buffer
   461                                     %if _LINK || _LINK_COMPAT
   462 000000E0 8E06[0000]              	mov es, [code_seg]
   463 000000E4 26800E[0000]01          	setopt [es:patch_boothelp_uncompressed], NONCOMPRESSEDFLAG
   464                                     %endif
   465                                    %endif
   466 000000EA 1E                      	push ds
   467 000000EB 0E                      	 push cs
   468 000000EC 1F                      	 pop ds
   469 000000ED BE[0A17]                	mov si, imsg.boothelp_replacement
   470 000000F0 8EC2                    	mov es, dx
   471 000000F2 BF[0000]                	mov di, msg.boothelp
   472 000000F5 B91C00                  	mov cx, imsg.boothelp_replacement_size_w
   473 000000F8 F3A5                    	rep movsw
   474 000000FA 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 000000FC 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 000000FF F3AB                    	rep stosw
   488 00000101 1F                      	pop ds
   489                                   %endif
   490                                  %endif
   491                                  
   492                                   %if _EXTENSIONS || _HISTORY_SEPARATE_FIXED && _HISTORY || _APP_ENV_SIZE
   493 00000102 58                      	pop ax
   494                                    %if _HISTORY_SEPARATE_FIXED && _HISTORY
   495 00000103 A3[0000]                	mov word [history.segorsel + soaSegSel], ax
   496                                  %if _PM
   497 00000106 A3[0200]                	mov word [history.segorsel + soaSegment], ax
   498                                  %endif
   499 00000109 8EC0                    	mov es, ax
   500 0000010B 31FF                    	xor di, di
   501 0000010D B90010                  	mov cx, historysegment_size >> 1
   502 00000110 31C0                    	xor ax, ax
   503 00000112 F3AB                    	rep stosw
   504                                    %endif
   505                                  
   506                                    %if _APP_ENV_SIZE
   507                                     %if _HISTORY_SEPARATE_FIXED && _HISTORY
   508 00000114 8CC0                    	mov ax, es
   509 00000116 050002                  	add ax, paras(historysegment_size)
   510                                     %endif
   511 00000119 A3[0000]                	mov word [envseg], ax
   512 0000011C 8EC0                    	mov es, ax
   513 0000011E 31FF                    	xor di, di
   514 00000120 B90004                  	mov cx, app_env_size >> 1
   515 00000123 C706[0000]0008          	mov word [env_size], app_env_size
   516 00000129 31C0                    	xor ax, ax
   517 0000012B F3AB                    	rep stosw
   518 0000012D 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 00000134 8CC0                    	mov ax, es
   524                                      %if _APP_ENV_SIZE
   525 00000136 058000                  	add ax, paras(app_env_size)
   526                                      %else
   527                                  	add ax, paras(historysegment_size)
   528                                      %endif
   529                                     %endif
   530 00000139 A3[0000]                	mov word [extseg], ax
   531 0000013C 8EC0                    	mov es, ax
   532 0000013E 31FF                    	xor di, di
   533 00000140 B90010                  	mov cx, extsegment_size >> 1
   534 00000143 31C0                    	xor ax, ax
   535 00000145 F3AB                    	rep stosw
   536                                    %endif
   537                                   %endif
   538                                  
   539 00000147 89D8                    	mov ax, bx
   540                                  
   541 00000149 A3[0000]                	mov word [auxbuff_segorsel + soaSegSel], ax
   542                                  %if _PM
   543 0000014C A3[0200]                	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 0000014F 8EC0                    	mov es, ax
   551 00000151 31FF                    	xor di, di
   552 00000153 B90810                  	mov cx, _AUXBUFFSIZE >> 1
   553 00000156 31C0                    	xor ax, ax
   554 00000158 F3AB                    	rep stosw			; initialise auxbuff
   555                                  
   556 0000015A FA                      	cli
   557 0000015B 8CD8                    	mov ax, ds
   558 0000015D 8EC0                    	mov es, ax
   559 0000015F 8ED0                    	mov ss, ax
   560 00000161 BC[0000]                	mov sp, stack_end		; application mode stack switch
   561 00000164 FB                      	sti
   562                                  
   563 00000165 B44A                    	mov ah, 4Ah
   564                                  %ifn _LINK
   565                                  	mov bx, paras(APPINITSTACK_START)
   566                                  %else
   567 00000167 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 0000016A 2E891E[520E]            	mov word [cs:init_target_size], bx
   577 0000016F 2E891E[500E]            	mov word [cs:init_base_size], bx
   578 00000174 CD21                    	int 21h				; shrink to drop init stack
   579                                  
   580                                  %if _CONFIG
   581                                  find_config_application:
   582 00000176 C606[0000]00            	mov byte [configpath], 0
   583 0000017B A12C00                  	mov ax, [2Ch]
   584 0000017E BF[740F]                	mov di, imsg.varconfig
   585 00000181 B90D00                  	mov cx, imsg.varconfig.length
   586 00000184 BA[0000]                	mov dx, configpath
   587 00000187 E89832                  	call init_copyvar
   588 0000018A 7303                    	jnc .done
   589 0000018C E82200                  	call find_executable_application
   590                                  .done:
   591                                  
   592                                  
   593                                  find_scripts_application:
   594 0000018F 36C606[0000]00          	mov byte [ss:scriptspath], 0
   595 00000195 36A12C00                	mov ax, [ss:2Ch]
   596 00000199 BF[810F]                	mov di, imsg.varscripts
   597 0000019C B90E00                  	mov cx, imsg.varscripts.length
   598 0000019F BA[0000]                	mov dx, scriptspath
   599 000001A2 E87D32                  	call init_copyvar
   600 000001A5 7303                    	jnc .done
   601 000001A7 E80700                  	call find_executable_application
   602                                  .done:
   603                                  
   604 000001AA 16                      	push ss
   605 000001AB 1F                      	pop ds
   606 000001AC 16                      	push ss
   607 000001AD 07                      	pop es
   608                                  %endif
   609                                  
   610 000001AE E9DC1A                  	jmp old_initcode
   611                                  
   612                                  
   613                                  %if _CONFIG
   614                                  		; INP:	dx -> buffer
   615                                  		;	ds => PSP
   616                                  find_executable_application:
   617 000001B1 A12C00                  	mov ax, [2Ch]
   618 000001B4 85C0                    	test ax, ax
   619 000001B6 743E                    	jz .noexec
   620 000001B8 8ED8                    	mov ds, ax
   621 000001BA 31F6                    	xor si, si
   622                                  @@:
   623 000001BC E8FF31                  	call init_nextvar
   624 000001BF 75FB                    	jne @B
   625 000001C1 46                      	inc si
   626 000001C2 AD                      	lodsw
   627 000001C3 83F801                  	cmp ax, 1
   628 000001C6 752E                    	jne .noexec
   629 000001C8 1E                      	push ds
   630 000001C9 07                      	pop es
   631 000001CA 89F7                    	mov di, si
   632 000001CC B97F00                  	mov cx, 127
   633 000001CF B000                    	mov al, 0
   634 000001D1 F2AE                    	repne scasb
   635 000001D3 7521                    	jne .noexec
   636 000001D5 4F                      	dec di
   637                                  
   638 000001D6 B90000                  	mov cx, 0
   639                                  @@:
   640 000001D9 39F7                    	cmp di, si
   641 000001DB 7610                    	jbe @F
   642 000001DD 4F                      	dec di
   643 000001DE 803D2F                  	cmp byte [di], '/'
   644 000001E1 7405                    	je .slash
   645 000001E3 803D5C                  	cmp byte [di], '\'
   646 000001E6 75F1                    	jne @B
   647                                  .slash:
   648 000001E8 89F9                    	mov cx, di
   649 000001EA 41                      	inc cx
   650 000001EB 29F1                    	sub cx, si
   651                                  @@:
   652                                  
   653 000001ED 16                      	push ss
   654 000001EE 07                      	pop es
   655 000001EF 89D7                    	mov di, dx
   656 000001F1 F3A4                    	rep movsb
   657 000001F3 B000                    	mov al, 0
   658 000001F5 AA                      	stosb
   659                                  
   660                                  .noexec:
   661                                  .done:
   662 000001F6 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 000001F7 8CD8                    	mov ax, ds
   676                                  %ifn _LINK
   677                                  	add ax, paras(CODESECTIONOFFSET)
   678                                  %else
   679 000001F9 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 000001FC C706[0000][0F00]        	mov word [code_size], behind_code_truncated + 15 wrt lDEBUG_CODE
   689                                   wlcalc word_clr_15, equ $ - 2
   690 00000202 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 00000205 39D0                    	cmp ax, dx		; source above destination ?
   696 00000207 7308                    	jae @F			; yes -->
   697 00000209 E81000                  	call .place_code2	; source is below, move "backward" (high first)
   698                                    %endif
   699 0000020C E87319                  	call init_movp		; low last
   700                                    %if _DUALCODE
   701 0000020F EB06                    	jmp @FF
   702                                  
   703                                  @@:
   704 00000211 E86E19                  	call init_movp		; source is above, move "forward" (low first)
   705 00000214 E80500                  	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 00000217 8916[0000]              	mov word [code_seg], dx	; initialise code segment reference
   718 0000021B C3                      	retn
   719                                  
   720                                   %if _BOOTLDR_DISCARD && _DUALCODE
   721                                  .place_code2:
   722 0000021C 50                      	push ax
   723 0000021D 51                      	push cx
   724 0000021E 52                      	push dx
   725 0000021F 01CA                    	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 00000221 05[0000]                	add ax, strict word relocatedzero + 0
   733                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code, equ $ - 2
   734 00000224 B9[0000]                	mov cx, relocatedzero + 0
   735                                   wlcalc word_wrt_@@lDEBUG_CODE2@_extpara_behind_code2, equ $ - 2
   736                                  %endif
   737 00000227 E85819                  	call init_movp
   738 0000022A 5A                      	pop dx
   739 0000022B 59                      	pop cx
   740 0000022C 58                      	pop ax
   741 0000022D C3                      	retn
   742                                   %endif
   743                                  %endif
   744                                  
   745                                  
   746                                  init_retf:
   747 0000022E 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 0000022F 89DE                    	mov si, bx		; => auxbuff
   764                                  %if _AUXBUFFSIZE < 8192
   765                                   %error Expected full sector length auxbuff
   766                                  %endif
   767 00000231 8DBC0002                	lea di, [si + (8192 >> 4)]; => behind auxbuff (at additional paragraph)
   768 00000235 81E600F0                	and si, 0F000h		; => 64 KiB chunk of first paragraph of auxbuff
   769 00000239 81E700F0                	and di, 0F000h		; => 64 KiB chunk of additional paragraph
   770 0000023D 39F7                    	cmp di, si		; same ?
   771                                  				; ZR if they are the same
   772 0000023F 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 00000240 FC                      	cld
   787                                  
   788                                  d4	call init_d4message
   789                                  d4	asciz "In boot_initcode",13,10
   790                                  
   791 00000241 8B56E0                  	mov dx, word [bp + ldMemoryTop]
   792                                  
   793                                  		; initialise sdp
   794 00000244 8B461E                  	mov ax, word [bp + bsBPB + bpbHiddenSectors + 2]
   795 00000247 A3[4E00]                	mov word [load_data - LOADDATA2 + bsBPB + bpbHiddenSectors + 2], ax
   796 0000024A 8B461C                  	mov ax, word [bp + bsBPB + bpbHiddenSectors]
   797 0000024D A3[4C00]                	mov word [load_data - LOADDATA2 + bsBPB + bpbHiddenSectors], ax
   798                                  
   799 00000250 31DB                    	xor bx, bx
   800 00000252 8A4640                  	mov al, byte [bp + bsBPB + ebpbNew + bpbnBootUnit]
   801 00000255 A2[7000]                	mov byte [load_data - LOADDATA2 + bsBPB + ebpbNew + bpbnBootUnit], al
   802 00000258 88C3                    	mov bl, al			; bx = LD unit
   803 0000025A 84C0                    	 test al, al			; hdd or diskette ?
   804 0000025C 8B46EC                  	mov ax, word [bp + ldQueryPatchValue]
   805 0000025F 7902                    	 jns @F				; diskette -->
   806 00000261 86C4                    	xchg al, ah			; get high word of query patch value
   807                                  @@:
   808 00000263 84C0                    	test al, al			; use for our access to this unit ?
   809 00000265 7906                    	jns @F				; no -->
   810 00000267 2407                    	and al, luf_mask_writable	; clear unused bits
   811 00000269 8887[0000]              	mov byte [load_unit_flags + bx], al
   812                                  					; save here
   813                                  @@:
   814                                  
   815                                  
   816 0000026D 8CDB                    	mov bx, ds
   817 0000026F 8EC3                    	mov es, bx			; => data entry image
   818 00000271 BF[0000]                	mov di, loaddata_loadedfrom	; -> loaded from data (ldp)
   819                                  
   820                                  		; initialise LOADDATA, LOADSTACKVARS, and BPB
   821 00000274 16                      	push ss
   822 00000275 1F                      	pop ds
   823 00000276 8D76E0                  	lea si, [bp + LOADDATA]		; -> LOADDATA on stack
   824 00000279 B97A00                  	mov cx, (-LOADDATA + bsBPB + ebpbNew + BPBN_size)
   825 0000027C F3A4                    	rep movsb
   826                                  
   827                                  		; initialise cmdline_buffer from below LOADDATA
   828 0000027E 8DB6E0FE                	lea si, [bp + ldCommandLine.start]
   829 00000282 BF[0000]                	mov di, cmdline_buffer		; -> our buffer in data entry
   830                                  
   831 00000285 813C00FF                	cmp word [si], 0FF00h
   832 00000289 7505                    	jne @F
   833                                  
   834 0000028B 0E                      	 push cs
   835 0000028C 1F                      	 pop ds
   836 0000028D BE[3E18]                	mov si, imsg.default_cmdline.boot
   837                                  
   838                                  @@:
   839 00000290 AC                      	lodsb
   840 00000291 84C0                    	test al, al
   841 00000293 7423                    	jz @FF
   842                                  
   843 00000295 26800E[0100]01          	setopt [es:internalflags3], dif3_input_cmdline
   844 0000029B A9                      	db __TEST_IMM16
   845                                  .switch_c_loop:
   846 0000029C AA                      	stosb
   847 0000029D AC                      	lodsb
   848                                  .switch_c_loop_after_semicolon:
   849 0000029E 3C00                    	cmp al, 0
   850 000002A0 7415                    	je @F
   851 000002A2 3C3B                    	cmp al, ';'
   852 000002A4 7508                    	jne .switch_c_not_semicolon
   853 000002A6 B00D                    	mov al, 13
   854 000002A8 AA                      	stosb
   855 000002A9 E83532                  	call init_skipwhite
   856 000002AC EBF0                    	jmp .switch_c_loop_after_semicolon
   857                                  
   858                                  .switch_c_not_semicolon:
   859 000002AE 3C5C                    	cmp al, '\'
   860 000002B0 75EA                    	jne .switch_c_loop
   861 000002B2 AC                      	lodsb
   862 000002B3 3C00                    	cmp al, 0
   863 000002B5 75E5                    	jne .switch_c_loop
   864                                  
   865                                  @@:
   866 000002B7 AA                      	stosb
   867                                  @@:
   868                                  
   869                                  		; es => data entry image
   870 000002B8 16                      	push ss
   871 000002B9 1F                      	pop ds
   872 000002BA 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 000002BD B9C201                  	mov cx, 512 - (bsBPB + bpbNew + BPBN_size)	; tail size FAT12/FAT16
   875 000002C0 837E1600                	cmp word [bp + bsBPB + bpbSectorsPerFAT], 0
   876 000002C4 7503                    	jne @F
   877 000002C6 B9A601                  	mov cx, 512 - (bsBPB + ebpbNew + BPBN_size)	; tail size FAT32
   878                                  @@:
   879 000002C9 E8CB04                  	call findname
   880                                  
   881                                  %if _EXECUTABLE
   882 000002CC 53                      	push bx
   883 000002CD 06                      	push es
   884 000002CE 1F                      	pop ds
   885 000002CF BE[0000]                	mov si, boot_init_foundname
   886 000002D2 BF[0000]                	mov di, init_executable_pathname
   887 000002D5 803C00                  	cmp byte [si], 0
   888 000002D8 7415                    	je .unable
   889                                  
   890 000002DA 31C9                    	xor cx, cx
   891 000002DC 89F3                    	mov bx, si
   892                                  @@:
   893 000002DE AC                      	lodsb
   894 000002DF 41                      	inc cx
   895 000002E0 84C0                    	test al, al
   896 000002E2 75FA                    	jnz @B
   897                                  
   898 000002E4 BE[8C18]                	mov si, imsg.ldpslash
   899                                  
   900 000002E7 2EA5                    	cs movsw
   901 000002E9 2EA5                    	cs movsw
   902                                  
   903 000002EB 89DE                    	mov si, bx
   904 000002ED F3A4                    	rep movsb
   905                                  
   906                                  .unable:
   907 000002EF BF[0000]                	mov di, init_executable_pathname
   908 000002F2 31C0                    	xor ax, ax
   909 000002F4 B98000                  	mov cx, 128
   910 000002F7 F2AE                    	repne scasb
   911 000002F9 4F                      	dec di
   912 000002FA 893E[0000]              	mov word [init_executable_pathname.end], di
   913 000002FE 5B                      	pop bx
   914                                  %endif
   915                                  
   916 000002FF 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 00000301 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 00000304 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 00000309 8CC9                    	mov cx, cs
   951                                  %ifn _LINK
   952                                  	add cx, paras(init_size + BOOTINITSTACK_SIZE)
   953                                  %else
   954 0000030B 81C1[2000]              	add cx, strict word relocatedzero + paras(BOOTINITSTACK_SIZE)
   955                                   wlcalc word_wrt_INIT_extpara_behind_init, equ $ - 2
   956                                  %endif
   957 0000030F 7303E95601              	jc .error_out_of_memory
   958 00000314 39D1                    	cmp cx, dx
   959 00000316 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 0000031B F646E704                	testopt [bp + ldHasLBA], ldhlfPreserveLoader
   971                                  		; set NZ if loader resident
   972                                  
   973 0000031F 8CCF                    	mov di, cs
   974 00000321 FA                      	cli
   975 00000322 8ED7                    	mov ss, di
   976                                  %ifn _LINK
   977                                  	mov sp, init_size + BOOTINITSTACK_SIZE
   978                                  %else
   979 00000324 BC[0002]                	mov sp, BOOTINITSTACK_SIZE + behind_init wrt INIT
   980                                  %endif
   981 00000327 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 00000328 5589E550                	lenter
   989                                  	lvar word,	targetstart
   990 0000032C 50                      	 push ax
   991                                  	lvar word,	memtop
   992 0000032D 52                      	 push dx
   993 0000032E 8D7F10                  	lea di, [bx + 10h]
   994                                  	lvar word,	data
   995 00000331 57                      	 push di
   996                                  	lvar word,	lowestused
   997 00000332 57                      	 push di
   998                                  %ifn _LINK
   999                                  	lea di, [bx + paras(CODESECTIONOFFSET)]
  1000                                  %else
  1001 00000333 8DBF[0000]              	lea di, [word relocatedzero + bx + 0]
  1002                                   wlcalc word_segrel_lDEBUG_CODE, equ $ - 2
  1003                                  %endif
  1004                                  	lvar word,	code
  1005 00000337 57                      	 push di
  1006                                  	lvar dword,	loaderentry
  1007 00000338 50                      	 push ax
  1008 00000339 50                      	 push ax
  1009 0000033A BF6000                  	mov di, 60h
  1010                                  	lvar word,	lowlimit
  1011 0000033D 57                      	 push di
  1012                                  
  1013                                  %if !_LOADER
  1014 0000033E 51                      	push cx
  1015 0000033F 50                      	push ax
  1016                                  
  1017                                  		; had set NZ if loader resident
  1018 00000340 745B                    	jz .no_loader
  1019 00000342 E80B05                  	call get_size_and_ebda
  1020 00000345 8B5EFA                  	mov bx, word [bp + ?memtop]
  1021 00000348 2E031E[640E]            	add bx, [cs:init_boot_ebdasize]
  1022 0000034D 8EC3                    	mov es, bx
  1023 0000034F 31FF                    	xor di, di
  1024 00000351 0E                      	 push cs
  1025 00000352 1F                      	 pop ds
  1026 00000353 BE[300E]                	mov si, loader_imageident
  1027 00000356 B90300                  	mov cx, words(loader_imageident.size)
  1028 00000359 BA[B619]                	mov dx, imsg.boot_warn_no_loader
  1029 0000035C F3A7                    	repe cmpsw
  1030 0000035E 7532                    	jne .loaderwarning
  1031 00000360 31F6                    	xor si, si
  1032 00000362 31D2                    	xor dx, dx
  1033 00000364 B90800                  	mov cx, 8
  1034                                  @@:
  1035 00000367 26AD                    	es lodsw
  1036 00000369 01C2                    	add dx, ax
  1037 0000036B E2FA                    	loop @B
  1038 0000036D BA[D319]                	mov dx, imsg.boot_warn_invalid_loader
  1039 00000370 7520                    	jnz .loaderwarning
  1040                                  
  1041 00000372 895EF2                  	mov word [bp + ?loaderentry + 2], bx
  1042 00000375 2EF616[6B0E]            	not byte [cs:init_preserveloader]
  1043 0000037A BA[F119]                	mov dx, imsg.boot_warn_lazy_loader
  1044 0000037D 268B0E1000              	mov cx, word [es:liiEntryQuerySize]
  1045 00000382 E30E                    	jcxz .loaderwarning
  1046 00000384 894EF0                  	mov word [bp + ?loaderentry], cx
  1047 00000387 B86000                  	mov ax, 60h
  1048 0000038A FF5EF0                  	call far [bp + ?loaderentry]
  1049 0000038D 8946EE                  	mov word [bp + ?lowlimit], ax
  1050 00000390 EB0B                    	jmp @F
  1051                                  
  1052                                  .loaderwarning:
  1053 00000392 52                      	push dx
  1054 00000393 BA[8E19]                	mov dx, imsg.bootwarn
  1055 00000396 E89C18                  	call init_putsz_cs_bootldr
  1056 00000399 5A                      	pop dx
  1057 0000039A E89818                  	call init_putsz_cs_bootldr
  1058                                  @@:
  1059                                  
  1060                                  .no_loader:
  1061 0000039D 58                      	pop ax
  1062 0000039E 59                      	pop cx
  1063                                  %endif
  1064                                  
  1065 0000039F 39C1                    	cmp cx, ax			; does init end below-or-equal target ?
  1066 000003A1 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 000003A6 8B46F8                  	mov ax, word [bp + ?data]
  1072                                  %ifn _LINK
  1073                                  	sub ax, strict word paras(init_size + BOOTINITSTACK_SIZE)
  1074                                  %else
  1075 000003A9 2D[2000]                	sub ax, strict word relocatedzero + paras(BOOTINITSTACK_SIZE)
  1076                                   wlcalc word_wrt_INIT_extpara_behind_init, equ $ - 2
  1077                                  %endif
  1078 000003AC 7303E9B900              	jc .error_out_of_memory		; already at start of memory -->
  1079 000003B1 3B46EE                  	cmp ax, [bp + ?lowlimit]
  1080 000003B4 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 000003B9 0E                      	push cs
  1088 000003BA 1F                      	pop ds
  1089 000003BB 31F6                    	xor si, si			; -> init source
  1090 000003BD 8EC0                    	mov es, ax
  1091 000003BF 8946F6                  	mov word [bp + ?lowestused], ax
  1092 000003C2 31FF                    	xor di, di			; -> init destination
  1093                                  %ifn _LINK
  1094                                  	mov cx, words(init_size + BOOTINITSTACK_SIZE)
  1095                                  %else
  1096 000003C4 B9[0102]                	mov cx, BOOTINITSTACK_SIZE + 1 + behind_init wrt INIT
  1097                                   wlcalc word_shr_1, equ $ - 2
  1098                                  %endif
  1099 000003C7 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 000003C9 50                      	push ax
  1105 000003CA 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 000003CD 8B4EF4                  	mov cx, word [bp + ?code]
  1120                                  %ifn _LINK
  1121                                  	add cx, paras(ldebug_code_size + ldebug_code2_size)	; untruncated
  1122                                  %else
  1123 000003D0 81C1[0000]              	add cx, strict word relocatedzero + 0
  1124                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code2, equ $ - 2
  1125                                  %endif
  1126 000003D4 3B4EFC                  	cmp cx, word [bp + ?targetstart]
  1127                                  					; does code end below-or-equal target ?
  1128 000003D7 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 000003DC 8B56EE                  	mov dx, [bp + ?lowlimit]
  1135 000003DF 8EC2                    	mov es, dx
  1136 000003E1 8CC8                    	mov ax, cs
  1137 000003E3 39C2                    	cmp dx, ax			; already at start of memory ?
  1138 000003E5 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 000003EA 42                      	inc dx
  1151                                  	; cmp dx, ax
  1152                                  	; ja .error_out_of_memory
  1153 000003EB B9[2404]                	mov cx, .relocated
  1154 000003EE 52                      	 push dx
  1155 000003EF 51                      	 push cx			; on stack: far address of .relocated
  1156                                  
  1157 000003F0 89C1                    	mov cx, ax			; source
  1158 000003F2 29D1                    	sub cx, dx			; source - target = how far to relocate
  1159                                  
  1160 000003F4 31FF                    	xor di, di			; es:di -> where to put relocator
  1161 000003F6 06                      	push es
  1162 000003F7 57                      	push di				; on stack: relocator destination
  1163 000003F8 51                      	push cx				; on stack: how far to relocate
  1164 000003F9 0E                      	 push cs
  1165 000003FA 1F                      	 pop ds
  1166 000003FB BE[2104]                	mov si, .relocator		; -> relocator source
  1167 000003FE B90800                  	mov cx, 8
  1168 00000401 F3A5                    	rep movsw			; put relocator stub
  1169                                  
  1170 00000403 8EC2                    	mov es, dx
  1171 00000405 5A                      	pop dx				; dx = how far to relocate
  1172                                  
  1173 00000406 31FF                    	xor di, di			; -> where to relocate to
  1174 00000408 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 0000040A 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 0000040D BB0010                  	mov bx, 1000h
  1194 00000410 89C8                    	mov ax, cx
  1195 00000412 39D8                    	cmp ax, bx			; > 64 KiB?
  1196 00000414 7602                    	jbe @F
  1197 00000416 89D9                    	mov cx, bx			; first relocate the first 64 KiB
  1198                                  @@:
  1199 00000418 29C8                    	sub ax, cx			; how much to relocate later
  1200 0000041A D1E1                    	shl cx, 1
  1201 0000041C D1E1                    	shl cx, 1
  1202 0000041E 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 00000420 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 00000421 F3A5                    	rep movsw
  1227 00000423 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 00000424 8CC1                    	mov cx, es
  1242 00000426 01D9                    	add cx, bx
  1243 00000428 8EC1                    	mov es, cx	; => next segment
  1244                                  
  1245 0000042A 8CD9                    	mov cx, ds
  1246 0000042C 01D9                    	add cx, bx
  1247 0000042E 8ED9                    	mov ds, cx	; => next segment
  1248                                  
  1249 00000430 29D8                    	sub ax, bx	; = how much to relocate after this round
  1250 00000432 B90080                  	mov cx, 1000h << 3	; in case another full 64 KiB to relocate
  1251 00000435 730B                    	jae @F		; another full 64 KiB to relocate this round -->
  1252 00000437 01D8                    	add ax, bx	; restore (possibly zero)
  1253 00000439 D1E0                    	shl ax, 1
  1254 0000043B D1E0                    	shl ax, 1
  1255 0000043D D1E0                    	shl ax, 1	; convert paragraphs to words
  1256 0000043F 91                      	xchg cx, ax	; cx = that many words (possibly zero)
  1257 00000440 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 00000442 31F6                    	xor si, si	; -> source
  1268 00000444 31FF                    	xor di, di	; -> destination
  1269 00000446 F3A5                    	rep movsw	; relocate next chunk
  1270 00000448 85C0                    	test ax, ax	; another round needed?
  1271 0000044A 75D8                    	jnz @BB		; yes -->
  1272                                  
  1273                                  .entire_relocation_done:
  1274 0000044C 8CC8                    	mov ax, cs
  1275 0000044E 8ED0                    	mov ss, ax			; relocate the stack
  1276 00000450 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 00000451 8946F6                  	mov word [bp + ?lowestused], ax
  1282 00000454 2956F8                  	sub word [bp + ?data], dx
  1283 00000457 721A                    	jc .error_internal
  1284 00000459 2956F4                  	sub word [bp + ?code], dx
  1285 0000045C 7215                    	jc .error_internal
  1286                                  
  1287 0000045E 8B4EF4                  	mov cx, word [bp + ?code]
  1288                                   %ifn _LINK
  1289                                  	add cx, paras(ldebug_code_size + ldebug_code2_size)	; untruncated
  1290                                   %else
  1291 00000461 81C1[0000]              	add cx, strict word relocatedzero + 0
  1292                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code2, equ $ - 2
  1293                                   %endif
  1294 00000465 3B4EFC                  	cmp cx, word [bp + ?targetstart]
  1295                                  					; does code end below-or-equal target ?
  1296 00000468 760E                    	jbe .done_relocation		; yes -->
  1297                                  
  1298                                  .error_out_of_memory:
  1299 0000046A BA[0A19]                	mov dx, imsg.boot_error_out_of_memory
  1300                                  .putsz_error:
  1301 0000046D E8C517                  	call init_putsz_cs_bootldr
  1302 00000470 E95E04                  	jmp init_booterror.soft
  1303                                  
  1304                                  .error_internal:
  1305 00000473 BA[1B19]                	mov dx, imsg.boot_error_internal
  1306 00000476 EBF5                    	jmp .putsz_error
  1307                                  
  1308                                  
  1309                                  .done_relocation:
  1310 00000478 8CC8                    	mov ax, cs
  1311 0000047A 8ED0                    	mov ss, ax			; relocate the stack
  1312 0000047C 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 0000047D 8B46F6                  	mov ax, word [bp + ?lowestused]
  1320 00000480 3B46EE                  	cmp ax, word [bp + ?lowlimit]
  1321 00000483 72E5                    	jb .error_out_of_memory
  1322                                  
  1323                                  .no_relocation:
  1324 00000485 2EC606[D608]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 0000048B 8B46F6                  	mov ax, word [bp + ?lowestused]
  1334 0000048E 2B46EE                  	sub ax, word [bp + ?lowlimit]
  1335 00000491 735E                    	jae .highenough
  1336                                  .relocatehigh:
  1337 00000493 F7D8                    	neg ax				; how much to relocate higher
  1338 00000495 8CC9                    	mov cx, cs
  1339                                  %ifn _LINK
  1340                                  	add cx, paras(init_size + BOOTINITSTACK_SIZE + 256)
  1341                                  %else
  1342 00000497 81C1[3000]              	add cx, strict word relocatedzero + paras(BOOTINITSTACK_SIZE + 256)
  1343                                   wlcalc word_wrt_INIT_extpara_behind_init, equ $ - 2
  1344                                  %endif
  1345 0000049B 72CD                    	jc .error_out_of_memory
  1346 0000049D 01C1                    	add cx, ax			; => past wanted init
  1347 0000049F 72C9                    	jc .error_out_of_memory
  1348 000004A1 3B4EFC                  	cmp cx, word [bp + ?targetstart]
  1349 000004A4 73C4                    	jae .error_out_of_memory	; if too little left -->
  1350                                  
  1351 000004A6 8CCA                    	mov dx, cs
  1352 000004A8 01C2                    	add dx, ax			; => destination init
  1353 000004AA 89E3                    	mov bx, sp			; preserve sp
  1354 000004AC FA                      	cli
  1355 000004AD 8ED2                    	mov ss, dx
  1356                                  %ifn _LINK
  1357                                  	mov sp, fromwords(words(init_size + BOOTINITSTACK_SIZE + 256 - 1))
  1358                                  %else
  1359 000004AF 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 000004B2 FB                      	sti
  1364 000004B3 BF[D504]                	mov di, .relocatedhigh
  1365 000004B6 52                      	  push dx
  1366 000004B7 57                      	  push di			; -> relocated .relocatedhigh (temp stack)
  1367 000004B8 41                      	inc cx
  1368 000004B9 8EC1                    	mov es, cx			; => relocator destination
  1369 000004BB 31FF                    	xor di, di
  1370 000004BD 06                      	  push es
  1371 000004BE 57                      	  push di			; -> relocator destination (temp stack)
  1372 000004BF 0E                      	 push cs
  1373 000004C0 1F                      	 pop ds
  1374 000004C1 BE[2104]                	mov si, .relocator		; -> relocator source
  1375 000004C4 B90800                  	mov cx, 8
  1376 000004C7 F3A5                    	rep movsw			; put relocator stub
  1377 000004C9 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 000004CB B9[0102]                	mov cx, behind_init + BOOTINITSTACK_SIZE + 1 wrt INIT
  1383                                   wlcalc word_shr_1, equ $ - 2
  1384 000004CE BE[FF01]                	mov si, behind_init + BOOTINITSTACK_SIZE + 1 - 2 wrt INIT
  1385                                   wlcalc word_clr_1, equ $ - 2
  1386                                  %endif
  1387 000004D1 89F7                    	mov di, si			; -> last word
  1388 000004D3 FD                      	std
  1389 000004D4 CB                      	retf				; (uses temp stack)
  1390                                  
  1391                                  .relocatedhigh:
  1392 000004D5 FC                      	cld
  1393                                  %if 0		; ss already == dx
  1394                                  	cli
  1395                                  	mov ss, dx
  1396                                  	mov sp, bx
  1397                                  	sti
  1398                                  %else
  1399 000004D6 89DC                    	mov sp, bx			; restore original stack
  1400                                  %endif
  1401 000004D8 8B56F8                  	mov dx, word [bp + ?data]	; => data source
  1402 000004DB 0146F8                  	add word [bp + ?data], ax
  1403 000004DE 7293                    	jc .error_internal
  1404 000004E0 0146F4                  	add word [bp + ?code], ax
  1405 000004E3 728E                    	jc .error_internal
  1406                                  
  1407 000004E5 52                      	push dx
  1408 000004E6 01C2                    	add dx, ax			; => data destination
  1409 000004E8 7289                    	jc .error_internal
  1410 000004EA 58                      	pop ax				; => data source
  1411                                  %ifn _LINK
  1412                                  	mov cx, paras(CODESECTIONOFFSET 		+ ldebug_code_size + ldebug_code2_size)	; untruncated
  1414                                  %else
  1415 000004EB 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 000004EE E89116                  	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 000004F1 2ED006[6B0E]            	rol byte [cs:init_preserveloader], 1
  1430 000004F6 7326                    	jnc @F
  1431                                  
  1432 000004F8 BA[221A]                	mov dx, imsg.boot_warn_loader_no_reloc
  1433 000004FB 8E46F2                  	mov es, word [bp + ?loaderentry + 2]
  1434 000004FE 268B0E1200              	mov cx, word [es:liiEntryRelocate]
  1435 00000503 E30E                    	jcxz .reloc_loaderwarning
  1436 00000505 894EF0                  	mov word [bp + ?loaderentry], cx
  1437 00000508 B86000                  	mov ax, 60h
  1438 0000050B FF5EF0                  	call far [bp + ?loaderentry]
  1439 0000050E 8946F2                  	mov word [bp + ?loaderentry + 2], ax
  1440                                  					; update our reference
  1441 00000511 EB0B                    	jmp @F
  1442                                  
  1443                                  .reloc_loaderwarning:
  1444 00000513 52                      	push dx
  1445 00000514 BA[8E19]                	mov dx, imsg.bootwarn
  1446 00000517 E81B17                  	call init_putsz_cs_bootldr
  1447 0000051A 5A                      	pop dx
  1448 0000051B E81717                  	call init_putsz_cs_bootldr
  1449                                  @@:
  1450                                  %endif
  1451                                  
  1452 0000051E E82F03                  	call get_size_and_ebda
  1453                                  
  1454 00000521 8B4EFA                  	mov cx, word [bp + ?memtop]
  1455 00000524 2E030E[640E]            	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 00000529 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 0000052D 49                      	dec cx				; => paragraph of image ident
  1473 0000052E 83E1C0                  	and cx, ~ (paras(1024) - 1)	; round down to kibibyte boundary
  1474 00000531 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 00000532 89CB                    	mov bx, cx
  1480 00000534 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 00000536 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 0000053A 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 0000053E 89D8                    	mov ax, bx
  1513 00000540 050102                  	add ax, paras(auxbuff_size)
  1514                                   %endif
  1515                                  %endif	; _LINK
  1516 00000543 E8E9FC                  	call init_check_auxbuff
  1517 00000546 743E                    	jz @F
  1518                                  
  1519                                  d4	call init_d4message
  1520                                  d4	asciz "First layout rejected",13,10
  1521                                  
  1522 00000548 89CB                    	mov bx, cx			; attempt same target again
  1523 0000054A 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 0000054C 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 00000550 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 00000554 E8D8FC                  	call init_check_auxbuff
  1553 00000557 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 00000559 8B4EFA                  	mov cx, word [bp + ?memtop]
  1562 0000055C 2E030E[640E]            	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 00000561 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 00000565 49                      	dec cx				; => paragraph of image ident
  1579 00000566 83E1C0                  	and cx, ~ (paras(1024) - 1)	; round down to kibibyte boundary
  1580 00000569 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 0000056A 89CB                    	mov bx, cx
  1585 0000056C 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 0000056E 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 00000572 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 00000576 89D8                    	mov ax, bx
  1616 00000578 050102                  	add ax, paras(auxbuff_size)
  1617                                   %endif
  1618 0000057B E8B1FC                  	call init_check_auxbuff
  1619 0000057E 7406                    	jz @F
  1620                                  
  1621                                  		; Because this shouldn't happen, this is
  1622                                  		;  considered an internal error.
  1623 00000580 BA[9310]                	mov dx, imsg.early_reloc_fail
  1624 00000583 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 00000586 50                      	push ax
  1640                                   %endif
  1641 00000587 894EFE                  	mov word [bp + ?target], cx
  1642 0000058A 52                      	push dx
  1643 0000058B 2E803E[6A0E]00          	cmp byte [cs:init_boot_ebdaflag], 0
  1644 00000591 742F                    	jz .reloc_memtop_no_ebda
  1645                                  %if !_LOADER
  1646 00000593 49                      	dec cx
  1647                                  %endif
  1648 00000594 2E2B0E[640E]            	sub cx, word [cs:init_boot_ebdasize]
  1649 00000599 2EA1[660E]              	mov ax, word [cs:init_boot_ebdasource]
  1650 0000059D 89CA                    	mov dx, cx
  1651 0000059F 2E890E[680E]            	mov word [cs:init_boot_ebdadest], cx
  1652 000005A4 2E8B0E[640E]            	mov cx, word [cs:init_boot_ebdasize]
  1653 000005A9 FA                      	cli
  1654 000005AA E8D515                  	call init_movp
  1655 000005AD 014EFA                  	add word [bp + ?memtop], cx
  1656 000005B0 2E800E[6A0E]02          	or byte [cs:init_boot_ebdaflag], 2
  1657 000005B6 B84000                  	mov ax, 40h
  1658 000005B9 8EC0                    	mov es, ax
  1659 000005BB 2689160E00              	mov word [es:0Eh], dx	; relocate EBDA
  1660                                  
  1661                                  d4	call init_d4message
  1662                                  d4	asciz "EBDA relocated",13,10
  1663                                  
  1664 000005C0 EB02                    	jmp @F
  1665                                  
  1666                                  .reloc_memtop_no_ebda:
  1667 000005C2 89CA                    	mov dx, cx
  1668                                  @@:
  1669 000005C4 B106                    	mov cl, 6
  1670 000005C6 D3EA                    	shr dx, cl
  1671 000005C8 B84000                  	mov ax, 40h
  1672 000005CB 8EC0                    	mov es, ax
  1673 000005CD 2E8916[600E]            	mov word [ cs:init_boot_new_memsizekib ], dx
  1674 000005D2 2687161300              	xchg word [es:13h], dx
  1675 000005D7 2E8916[620E]            	mov word [ cs:init_boot_old_memsizekib ], dx
  1676 000005DC 5A                      	pop dx
  1677 000005DD FB                      	sti
  1678                                  d4	call init_d4message
  1679                                  d4	asciz "Memory top relocated",13,10
  1680                                  
  1681 000005DE 8B4EFE                  	mov cx, word [bp + ?target]
  1682 000005E1 8ED9                    	mov ds, cx
  1683 000005E3 8B7EFA                  	mov di, word [bp + ?memtop]	; => memory top
  1684 000005E6 81EF4002                	sub di, paras(1024+8192)
  1685 000005EA 8EC7                    	mov es, di
  1686 000005EC 39CF                    	cmp di, cx			; max padding starts below target PSP ?
  1687 000005EE 7209                    	jb @F				; yes, do not initialise padding
  1688 000005F0 31FF                    	xor di, di			; -> padding
  1689 000005F2 B90012                  	mov cx, words(1024+8192)
  1690 000005F5 31C0                    	xor ax, ax
  1691 000005F7 F3AB                    	rep stosw			; initialise padding
  1692                                  @@:
  1693                                  
  1694 000005F9 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 000005FC B9[0000]                	mov cx, relocatedzero + 0
  1701                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code2, equ $ - 2
  1702                                  %endif
  1703 000005FF E88015                  	call init_movp			; relocate code to target
  1704                                  d4	call init_d4message
  1705                                  d4	asciz "Code segment relocated",13,10
  1706                                  
  1707 00000602 52                      		push dx			; (code segment)
  1708 00000603 8B46F8                  	mov ax, word [bp + ?data]	; => data_entry source
  1709 00000606 8CDA                    	mov dx, ds
  1710 00000608 83C210                  	add dx, paras(100h)		; => data_entry target
  1711                                  %ifn _LINK
  1712                                  	mov cx, paras(DATAENTRYTABLESIZE)
  1713                                  %else
  1714 0000060B B9[F0FF]                	mov cx, relocatedzero + - paras(256)
  1715                                   wlcalc word_wrt_@@lDEBUG_DATA_ENTRY@_extpara_behind_progbits_dataentry, equ $ - 2
  1716                                  %endif
  1717 0000060E E87115                  	call init_movp			; relocate data_entry to target
  1718 00000611 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 00000615 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 00000618 05[F0FF]                	add ax, strict word relocatedzero + - paras(100h)
  1731                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
  1732 0000061B 8CDA                    	mov dx, ds
  1733 0000061D 81C2[0000]              	add dx, strict word relocatedzero + 0
  1734                                   wlcalc word_wrt_@@lDEBUG_DATA_ENTRY@_extpara_end_of_datastack, equ $ - 2
  1735 00000621 B9[0000]                	mov cx, relocatedzero + 0
  1736                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment, equ $ - 2
  1737                                  %endif
  1738 00000624 E85B15                  	call init_movp
  1739 00000627 8916[0000]              	mov word [messageseg], dx
  1740                                   %if _HELP_COMPRESSED && ! _PM
  1741                                  	mov [hshrink_memory_source.segment], dx
  1742                                   %endif
  1743 0000062B 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 0000062D BF[0000]                	mov di, relocatedzero + 0
  1750                                   wlcalc word_wrt_MESSAGESEGMENT_ext_behind_messagesegment, equ $ - 2
  1751 00000630 31C0                    	xor ax, ax
  1752 00000632 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 00000635 F3AB                    	rep stosw
  1757                                  %endif
  1758                                  
  1759                                   %if _EXTENSIONS || _HISTORY_SEPARATE_FIXED && _HISTORY || _BOOT_ENV_SIZE
  1760 00000637 58                      	pop ax
  1761                                    %if _HISTORY_SEPARATE_FIXED && _HISTORY
  1762 00000638 A3[0000]                	mov word [history.segorsel + soaSegSel], ax
  1763                                  %if _PM
  1764 0000063B A3[0200]                	mov word [history.segorsel + soaSegment], ax
  1765                                  %endif
  1766 0000063E 8EC0                    	mov es, ax
  1767 00000640 31FF                    	xor di, di
  1768 00000642 B90010                  	mov cx, historysegment_boot_size >> 1
  1769 00000645 31C0                    	xor ax, ax
  1770 00000647 F3AB                    	rep stosw
  1771                                    %endif
  1772                                  
  1773                                    %if _BOOT_ENV_SIZE
  1774                                     %if _HISTORY_SEPARATE_FIXED && _HISTORY
  1775 00000649 8CC0                    	mov ax, es
  1776 0000064B 050002                  	add ax, paras(historysegment_boot_size)
  1777                                     %endif
  1778 0000064E A3[0000]                	mov word [envseg], ax
  1779 00000651 8EC0                    	mov es, ax
  1780 00000653 89C2                    	mov dx, ax
  1781 00000655 42                      	inc dx
  1782 00000656 31FF                    	xor di, di
  1783 00000658 B90004                  	mov cx, boot_env_size >> 1
  1784 0000065B C706[0000]0008          	mov word [env_size], boot_env_size
  1785 00000661 31C0                    	xor ax, ax
  1786 00000663 F3AB                    	rep stosw
  1787 00000665 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 0000066C 8CC0                    	mov ax, es
  1793                                      %if _BOOT_ENV_SIZE
  1794 0000066E 058000                  	add ax, paras(boot_env_size)
  1795                                      %else
  1796                                  	add ax, paras(historysegment_boot_size)
  1797                                      %endif
  1798                                     %endif
  1799 00000671 A3[0000]                	mov word [extseg], ax
  1800 00000674 8EC0                    	mov es, ax
  1801 00000676 31FF                    	xor di, di
  1802 00000678 B90020                  	mov cx, extsegment_boot_size >> 1
  1803 0000067B C706[0000]0040          	mov word [extseg_size], extsegment_boot_size
  1804 00000681 31C0                    	xor ax, ax
  1805 00000683 F3AB                    	rep stosw
  1806                                    %endif
  1807                                   %endif
  1808                                  
  1809 00000685 89D8                    	mov ax, bx
  1810 00000687 A3[0000]                	mov word [auxbuff_segorsel + soaSegSel], ax
  1811                                  %if _PM
  1812 0000068A A3[0200]                	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 0000068D 8EC0                    	mov es, ax
  1820 0000068F 31FF                    	xor di, di
  1821 00000691 B90810                  	mov cx, _AUXBUFFSIZE >> 1
  1822 00000694 31C0                    	xor ax, ax
  1823 00000696 F3AB                    	rep stosw			; initialise auxbuff
  1824                                  d4	call init_d4message
  1825                                  d4	asciz "auxbuff initialised",13,10
  1826                                  
  1827 00000698 1E                      	push ds
  1828 00000699 07                      	pop es
  1829 0000069A 31FF                    	xor di, di
  1830 0000069C B98000                  	mov cx, words(100h)
  1831 0000069F F3AB                    	rep stosw			; initialise pseudo-PSP
  1832                                  %if _BOOT_ENV_SIZE
  1833 000006A1 89162C00                	mov word [2Ch], dx
  1834                                  %endif
  1835                                  %if _EXTENSIONS
  1836 000006A5 8B0E[0000]              	mov cx, word [extdata_size]
  1837 000006A9 BF[0000]                	mov di, ext_data_area
  1838 000006AC B000                    	mov al, 0
  1839 000006AE F3AA                    	rep stosb			; init ext data area
  1840                                  %endif
  1841                                  
  1842                                  init_boot_imageident:
  1843 000006B0 8CD8                    	mov ax, ds
  1844                                  %if !_LOADER
  1845 000006B2 48                      	dec ax
  1846                                  %endif
  1847 000006B3 8EC0                    	mov es, ax			; => paragraph for imageident
  1848 000006B5 31FF                    	xor di, di			; -> imageident target
  1849 000006B7 8B5EFA                  	mov bx, word [bp + ?memtop]
  1850 000006BA 29C3                    	sub bx, ax			; = how many paragraphs do we use ?
  1851                                  
  1852 000006BC 891E[0000]              	mov word [alloc_size], bx
  1853 000006C0 A3[0000]                	mov word [alloc_seg], ax
  1854                                  
  1855 000006C3 0E                      	 push cs
  1856 000006C4 1F                      	 pop ds
  1857 000006C5 891E[980D]              	mov word [imageident.size], bx	; set image ident size
  1858                                  
  1859 000006C9 BE[900D]                	mov si, imageident
  1860 000006CC 56                      	push si
  1861 000006CD B90800                  	mov cx, 8
  1862 000006D0 31D2                    	xor dx, dx
  1863                                  .loop:
  1864 000006D2 AD                      	lodsw
  1865 000006D3 01C2                    	add dx, ax
  1866 000006D5 E2FB                    	loop .loop
  1867 000006D7 5E                      	pop si
  1868                                  
  1869 000006D8 F7DA                    	neg dx
  1870 000006DA 8916[960D]              	mov word [imageident.check], dx	; set image ident checksum
  1871                                  
  1872                                  %if !_LOADER
  1873 000006DE B108                    	mov cl, 8
  1874                                  %else
  1875                                  	mov cl, words(2Ch)
  1876                                  %endif
  1877 000006E0 F3A5                    	rep movsw			; write image ident paragraph
  1878                                  		; cx = 0
  1879                                  
  1880                                  %if !_LOADER
  1881 000006E2 2ED006[6B0E]            	rol byte [cs:init_preserveloader], 1
  1882 000006E7 730F                    	jnc @F
  1883 000006E9 8B56F2                  	mov dx, word [bp + ?loaderentry + 2]
  1884 000006EC 8EC2                    	mov es, dx
  1885 000006EE 268B0E1400              	mov cx, word [es:liiEntryDebug]	; cx nonzero if it has an entry
  1886 000006F3 268B1E1600              	mov bx, word [es:liiStackPointer]
  1887                                  					; fallback as zero if not supported
  1888                                  @@:
  1889                                  %endif
  1890                                  
  1891 000006F8 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 000006FB FA                      	cli
  1897 000006FC 8ED8                    	mov ds, ax
  1898 000006FE 8EC0                    	mov es, ax
  1899 00000700 8ED0                    	mov ss, ax
  1900 00000702 BC[0000]                	mov sp, stack_end		; boot mode stack switch
  1901 00000705 FB                      	sti
  1902                                  
  1903                                  %if !_LOADER
  1904 00000706 E339                    	jcxz init_boot_noloader
  1905 00000708 890E[0000]              	mov word [reg_eip], cx
  1906 0000070C 891E[0000]              	mov word [reg_esp], bx
  1907                                  
  1908 00000710 31C0                    	xor ax, ax		; initialise ax = 0 and FL = ZR NC etc
  1909 00000712 9C                      	pushf
  1910 00000713 8F06[0000]              	pop word [reg_efl]	; set to FL
  1911                                  
  1912 00000717 92                      	xchg ax, dx
  1913 00000718 BF[0000]                	mov di, reg_ds
  1914 0000071B AB                      	stosw
  1915 0000071C AF                      	scasw			; (skip dummy high word)
  1916 0000071D AB                      	stosw
  1917 0000071E AF                      	scasw
  1918 0000071F AB                      	stosw
  1919 00000720 AF                      	scasw
  1920 00000721 AB                      	stosw
  1921                                  
  1922                                  		; Set up initial addresses for 'a', 'd', and 'u' commands.
  1923                                  init_loader_adusetup:
  1924 00000722 A1[0000]                	mov ax, word [reg_eip]
  1925 00000725 8B0E[0200]              	mov cx, word [reg_eip+2]
  1926 00000729 8B1E[0000]              	mov bx, word [reg_cs]
  1927 0000072D BA[0000]                	mov dx, var_addr_entries.amount
  1928 00000730 BF[0000]                	mov di, var_addr_entries
  1929                                  
  1930                                  .loop:
  1931 00000733 AB                      	stosw			; IP
  1932                                  %if saSegSel == 4
  1933 00000734 890D                    	mov word [di], cx
  1934 00000736 AF                      	scasw			; skip this word
  1935                                  %endif
  1936 00000737 93                      	xchg ax, bx
  1937 00000738 AB                      	stosw			; CS
  1938                                  %if _PM
  1939                                   %if SEGADR_size != 10
  1940                                    %error Unexpected SEGADR size
  1941                                   %endif
  1942                                  .86m:
  1943 00000739 AB                      	stosw			; store saSegment
  1944 0000073A AF                      	scasw			; skip saSelector
  1945                                  %else
  1946                                   %if SEGADR_size == 10
  1947                                    %error Unexpected SEGADR size
  1948                                   %endif
  1949                                  %endif
  1950 0000073B 93                      	xchg ax, bx		; d_addr
  1951                                  
  1952 0000073C 4A                      	dec dx
  1953 0000073D 75F4                    	jnz .loop
  1954 0000073F EB05                    	jmp @F
  1955                                  %endif
  1956                                  
  1957                                  init_boot_noloader:
  1958 00000741 800E[0200]20            	setopt [internalflags3], dif3_gotint19
  1959                                  @@:
  1960                                  
  1961 00000746 2EFF36[620E]            	push word [cs:init_boot_old_memsizekib]
  1962 0000074B 8F06[0000]              	pop word [boot_old_memsizekib]
  1963 0000074F 2EFF36[600E]            	push word [cs:init_boot_new_memsizekib]
  1964 00000754 8F06[0000]              	pop word [boot_new_memsizekib]
  1965 00000758 2EA0[6A0E]              	mov al, byte [cs:init_boot_ebdaflag]
  1966 0000075C 2401                    	and al, 1
  1967 0000075E A2[0000]                	mov byte [boot_ebdaflag], al
  1968                                  
  1969 00000761 800E[0100]40            	setopt [internalflags], nodosloaded
  1970 00000766 8026[0000]0F            	clropt [internalflags], notstdinput|inputfile|notstdoutput|outputfile
  1971 0000076B C606[0000]00            	mov byte [notatty], 0	; it _is_ a tty
  1972                                  
  1973 00000770 BA[1110]                	mov dx, imsg.crlf
  1974 00000773 E89D14                  	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 00000776 BF[0000]                	mov di, configpath
  1982 00000779 B86C64                  	mov ax, "ld"
  1983 0000077C AB                      	stosw
  1984 0000077D B8702F                  	mov ax, "p/"
  1985 00000780 AB                      	stosw
  1986 00000781 893E[0000]              	mov word [configpath.dir_end], di
  1987 00000785 BF[0000]                	mov di, scriptspath
  1988 00000788 B86C64                  	mov ax, "ld"
  1989 0000078B AB                      	stosw
  1990 0000078C B8702F                  	mov ax, "p/"
  1991 0000078F AB                      	stosw
  1992 00000790 893E[0000]              	mov word [scriptspath.dir_end], di
  1993                                  %endif
  1994                                  
  1995 00000794 E9E514                  	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 00000797 83F90B                  	cmp cx, 11		; enough for another name ?
  2013 0000079A 7275                    	jb .none		; no -->
  2014                                  				; (cx == 0 jumps here too)
  2015                                  .check:
  2016 0000079C 51                      	push cx
  2017 0000079D 56                      	push si
  2018 0000079E B90B00                  	mov cx, 11
  2019 000007A1 AC                      	lodsb
  2020 000007A2 88C4                    	mov ah, al		; check for same char in all 11 places
  2021 000007A4 3C20                    	cmp al, 32		; first character must not be blank
  2022 000007A6 740D                    	je .check_fail		; if it is -->
  2023                                  ;	cmp al, 5		; first character may be 05h to indicate 0E5h
  2024                                  ;	je .check_pass
  2025 000007A8 A8                      	db __TEST_IMM8		; (skip lodsb)
  2026                                  .check_loop_same:
  2027 000007A9 AC                      	lodsb
  2028 000007AA 38C4                    	cmp ah, al
  2029 000007AC 752E                    	jne .check_loop_differs
  2030 000007AE E80A00                  	call .check_character
  2031 000007B1 7202                    	jc .check_fail
  2032 000007B3 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 000007B5 5E                      	pop si
  2038 000007B6 59                      	pop cx
  2039 000007B7 49                      	dec cx			; lessen the counter
  2040 000007B8 46                      	inc si			; -> next position to check
  2041 000007B9 EBDC                    	jmp .
  2042                                  
  2043                                  .check_character:
  2044 000007BB 3C20                    	cmp al, 32
  2045 000007BD 7218                    	jb .check_character_fail
  2046 000007BF 3C7F                    	cmp al, 127
  2047                                  ;	je .check_character_fail
  2048 000007C1 7314                    	jae .check_character_fail
  2049                                  		; note: with all characters >= 128 allowed,
  2050                                  		;  we get false positives in our sectors.
  2051 000007C3 3C2E                    	cmp al, '.'
  2052 000007C5 7410                    	je .check_character_fail
  2053 000007C7 3C2F                    	cmp al, '/'
  2054 000007C9 740C                    	je .check_character_fail
  2055 000007CB 3C5C                    	cmp al, '\'
  2056 000007CD 7408                    	je .check_character_fail
  2057 000007CF 3C61                    	cmp al, 'a'
  2058 000007D1 7206                    	jb .check_character_pass
  2059 000007D3 3C7A                    	cmp al, 'z'
  2060 000007D5 7702                    	ja .check_character_pass
  2061                                  .check_character_fail:
  2062 000007D7 F9                      	stc
  2063 000007D8 C3                      	retn
  2064                                  
  2065                                  .check_character_pass:
  2066 000007D9 F8                      	clc
  2067 000007DA C3                      	retn
  2068                                  
  2069                                  .check_loop:
  2070 000007DB AC                      	lodsb
  2071                                  .check_loop_differs:
  2072 000007DC E8DCFF                  	call .check_character
  2073 000007DF 72D4                    	jc .check_fail
  2074 000007E1 3C20                    	cmp al, 32
  2075 000007E3 740F                    	je .check_loop_is_blank
  2076                                  .check_pass:
  2077 000007E5 E2F4                    	loop .check_loop
  2078                                  
  2079 000007E7 58                      	pop ax			; (discard si)
  2080 000007E8 83EE0B                  	sub si, 11		; -> at name
  2081                                  
  2082 000007EB E82900                  	call convert_name_to_asciz
  2083                                  				; si -> behind name
  2084 000007EE 59                      	pop cx
  2085 000007EF 83E90B                  	sub cx, 11		; lessen the counter
  2086 000007F2 F8                      	clc
  2087 000007F3 C3                      	retn
  2088                                  
  2089                                  .check_loop_is_blank:
  2090 000007F4 88CC                    	mov ah, cl		; = how many remaining in ext (1 to 3)
  2091                                  				;  or name+ext (1 to 10, cannot be 11)
  2092 000007F6 80FC03                  	cmp ah, 3		; in ext ?
  2093 000007F9 7605                    	jbe @F			; yes -->
  2094 000007FB 80EC03                  	sub ah, 3		; 1 to 7 name field remaining
  2095 000007FE A8                      	db __TEST_IMM8		; (skip lodsb)
  2096                                  .check_loop_blank:
  2097 000007FF AC                      	lodsb
  2098                                  @@:
  2099 00000800 E8B8FF                  	call .check_character	; general check
  2100 00000803 72B0                    	jc .check_fail
  2101 00000805 3C20                    	cmp al, 32		; non-blank ?
  2102 00000807 75AC                    	jne .check_fail		; yes, fails -->
  2103 00000809 FECC                    	dec ah			; at end of field ?
  2104 0000080B 74D8                    	jz .check_pass		; yes -->
  2105                                  				; no, still in field after blank.
  2106                                  				;  check that next trail is all blanks too.
  2107 0000080D E2F0                    	loop .check_loop_blank
  2108 0000080F EBA4                    	jmp .check_fail		; (never reached)
  2109                                  
  2110                                  .none:
  2111 00000811 01CE                    	 add si, cx
  2112 00000813 31C9                    	 xor cx, cx
  2113 00000815 F9                      	stc
  2114 00000816 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 00000817 BF[0000]                	mov di, boot_init_foundname
  2124 0000081A B90800                  	mov cx, 8
  2125 0000081D F3A4                    	rep movsb		; copy over base name, si -> extension
  2126 0000081F 26807DF805              	cmp byte [es:di - 8], 05h	; is it 05h ?
  2127 00000824 7505                    	jne @F			; no -->
  2128 00000826 26C645F8E5              	mov byte [es:di - 8], 0E5h	; yes, convert to 0E5h
  2129                                  @@:
  2130                                  
  2131 0000082B A8                      	db __TEST_IMM8		; (skip dec)
  2132                                  @@:
  2133 0000082C 4F                      	dec di			; decrement -> at previous trailing blank
  2134 0000082D 26807DFF20              	cmp byte [es:di - 1], 32	; trailing blank ?
  2135 00000832 74F8                    	je @B			; yes -->
  2136                                  
  2137 00000834 B02E                    	mov al, '.'
  2138 00000836 AA                      	stosb			; store dot (if needed)
  2139 00000837 B103                    	mov cl, 3
  2140 00000839 F3A4                    	rep movsb		; copy over extension, si -> behind name
  2141                                  
  2142 0000083B A8                      	db __TEST_IMM8		; (skip dec)
  2143                                  @@:
  2144 0000083C 4F                      	dec di			; decrement -> at previous trailing blank
  2145 0000083D 26807DFF20              	cmp byte [es:di - 1], 32	; trailing blank ?
  2146 00000842 74F8                    	je @B			; yes -->
  2147                                  
  2148 00000844 26807DFF2E              	cmp byte [es:di - 1], '.'	; trailing dot ? (only occurs if all-blank ext)
  2149 00000849 7501                    	jne @F			; no -->
  2150 0000084B 4F                      	dec di			; -> at the dot
  2151                                  @@:
  2152 0000084C B000                    	mov al, 0
  2153 0000084E AA                      	stosb			; store filename terminator
  2154 0000084F C3                      	retn
  2155                                  
  2156                                  
  2157                                  get_size_and_ebda:
  2158 00000850 CD12                    	int 12h
  2159 00000852 B106                    	mov cl, 6
  2160 00000854 D3E0                    	shl ax, cl
  2161                                  
  2162 00000856 50                      	push ax
  2163 00000857 1E                      	push ds
  2164 00000858 31F6                    	xor si, si
  2165 0000085A 92                      	xchg dx, ax
  2166 0000085B 8EDE                    	mov ds, si
  2167 0000085D C536BC00                	lds si, [4 * 2Fh]
  2168 00000861 83C603                  	add si, 3
  2169 00000864 AC                      	lodsb
  2170 00000865 3C52                    	cmp al, 'R'
  2171 00000867 750F                    	jne .no_rpl
  2172 00000869 AC                      	lodsb
  2173 0000086A 3C50                    	cmp al, 'P'
  2174 0000086C 750A                    	jne .no_rpl
  2175 0000086E AC                      	lodsb
  2176 0000086F 3C4C                    	cmp al, 'L'
  2177 00000871 7505                    	jne .no_rpl
  2178 00000873 B8064A                  	mov ax, 4A06h
  2179 00000876 CD2F                    	int 2Fh
  2180                                  .no_rpl:
  2181 00000878 92                      	xchg ax, dx
  2182 00000879 1F                      	pop ds
  2183 0000087A 5A                      	pop dx
  2184                                  
  2185 0000087B 39D0                    	cmp ax, dx
  2186 0000087D 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 0000087F BA[9018]                	mov dx, imsg.rpl_detected
  2196 00000882 E9E8FB                  	jmp .putsz_error
  2197                                  
  2198                                  .no_error_rpl:
  2199                                  d4	call init_d4message
  2200                                  d4	asciz "Loader past RPL detection",13,10
  2201                                  
  2202 00000885 8B5EFA                  	mov bx, word [bp + ?memtop]
  2203 00000888 39C3                    	cmp bx, ax
  2204 0000088A 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 0000088C 8946FA                  	mov word [bp + ?memtop], ax
  2211 0000088F 89C3                    	mov bx, ax
  2212 00000891 7206                    	jb @F
  2213                                  
  2214 00000893 BA[B718]                	mov dx, imsg.mismatch_detected
  2215 00000896 E9D4FB                  	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 00000899 31D2                    	xor dx, dx			; initialise dx to zero if no EBDA
  2229 0000089B B84000                  	mov ax, 40h
  2230 0000089E 8EC0                    	mov es, ax
  2231 000008A0 26A10E00                	mov ax, word [ es:0Eh ]		; EBDA segment (unless zero) or LPT4 base I/O address (200h..3FCh)
  2232 000008A4 3D0004                  	cmp ax, 400h
  2233 000008A7 7227                    	jb .noebda			; -->
  2234                                  .ebda:
  2235                                  d4	call init_d4message
  2236                                  d4	asciz "EBDA detected",13,10
  2237                                  
  2238 000008A9 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 000008AB 7723                    	ja .noebda
  2242                                  		; MEMDISK can allocate memory *below* the EBDA.
  2243                                  		;  just pretend we don't see any EBDA.
  2244 000008AD 7406                    	je @F
  2245 000008AF BA[EB18]                	mov dx, imsg.boot_ebda_unexpected
  2246 000008B2 E9B8FB                  	jmp .putsz_error
  2247                                  
  2248                                  @@:
  2249 000008B5 2E800E[6A0E]01          	or byte [cs:init_boot_ebdaflag], 1
  2250                                  
  2251 000008BB 8ED8                    	mov ds, ax
  2252 000008BD 31D2                    	xor dx, dx
  2253 000008BF 8A160000                	mov dl, byte [ 0 ]		; EBDA size in KiB
  2254 000008C3 B106                    	mov cl, 6
  2255 000008C5 D3E2                    	shl dx, cl			; *64, to paragraphs
  2256 000008C7 2E8916[640E]            	mov word [cs:init_boot_ebdasize], dx
  2257 000008CC 2EA3[660E]              	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 000008D0 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 000008D1 31C0                    	xor ax, ax
  2273 000008D3 A9                      	db __TEST_IMM16			; (skip mov)
  2274                                  .hard:
  2275 000008D4 B001                    	mov al, 1
  2276                                  
  2277                                  ;d4	call init_d4pocketdosmemdump
  2278                                  d4	call init_d4dumpregs
  2279                                  
  2280                                  .patch_switch_stack:
  2281 000008D6 EB09                    	jmp strict short .no_switch_stack
  2282                                  
  2283 000008D8 8CCB                    	mov bx, cs
  2284 000008DA FA                      	cli
  2285 000008DB 8ED3                    	mov ss, bx
  2286                                  %ifn _LINK
  2287                                  	mov sp, init_size + BOOTINITSTACK_SIZE
  2288                                  %else
  2289 000008DD BC[0002]                	mov sp, BOOTINITSTACK_SIZE + behind_init wrt INIT
  2290                                  %endif
  2291 000008E0 FB                      	sti
  2292                                  
  2293                                  .no_switch_stack:
  2294 000008E1 50                      	push ax
  2295                                  
  2296 000008E2 B84000                  	mov ax, 40h
  2297 000008E5 8EC0                    	mov es, ax
  2298                                  
  2299 000008E7 2EF606[6A0E]02          	test byte [cs:init_boot_ebdaflag], 2
  2300 000008ED 7417                    	jz @F
  2301                                  
  2302 000008EF FA                      	cli
  2303 000008F0 2E8B16[660E]            	mov dx, [cs:init_boot_ebdasource]
  2304 000008F5 2EA1[680E]              	mov ax, [cs:init_boot_ebdadest]
  2305 000008F9 2E8B0E[640E]            	mov cx, [cs:init_boot_ebdasize]
  2306 000008FE E88112                  	call init_movp
  2307                                  
  2308 00000901 2689160E00              	mov word [es:0Eh], dx
  2309                                  @@:
  2310                                  
  2311 00000906 2E8B16[620E]            	mov dx, [cs:init_boot_old_memsizekib]
  2312 0000090B 85D2                    	test dx, dx
  2313 0000090D 7405                    	jz @F
  2314 0000090F 2689161300              	mov word [es:13h], dx
  2315                                  @@:
  2316 00000914 FB                      	sti
  2317                                  
  2318 00000915 BA[4919]                	mov dx, imsg.booterror
  2319 00000918 E81A13                  	call init_putsz_cs_bootldr
  2320 0000091B E8F012                  	call init_getc_bootldr
  2321 0000091E 58                      	pop ax
  2322 0000091F 85C0                    	test ax, ax
  2323 00000921 7502                    	jnz @F
  2324 00000923 CD19                    	int 19h
  2325                                  @@:
  2326 00000925 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 0000092A FC                      	cld
  2335                                  
  2336 0000092B 830E[0000]FF            	or word [device_header.next], -1
  2337                                  		; ! this uses offset 100h in the adjusted ds
  2338                                  
  2339 00000930 5B                      	pop bx
  2340 00000931 06                      	push es
  2341 00000932 53                      	push bx
  2342 00000933 51                      	push cx
  2343 00000934 52                      	push dx
  2344 00000935 56                      	push si
  2345 00000936 57                      	push di
  2346                                  
  2347 00000937 268B470E                	mov ax, word [es:bx + 0Eh]	; ax = amount bytes in last segment
  2348 0000093B B104                    	mov cl, 4
  2349 0000093D D3E8                    	shr ax, cl			; = paragraphs, rounding down
  2350 0000093F 26034710                	add ax, word [es:bx + 0Eh + 2]	; => behind available memory
  2351 00000943 7212                    	jc .memorybad
  2352 00000945 2EA3[3E0E]              	mov word [cs:dev_memory_end], ax
  2353 00000949 8CDA                    	mov dx, ds
  2354 0000094B 83C210                  	add dx, 10h			; => our memory
  2355 0000094E 29D0                    	sub ax, dx			; ax = amount available paragraphs
  2356 00000950 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 00000952 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 00000955 7333                    	jae .memorygood
  2391                                  
  2392                                  .memorybad:
  2393 00000957 BA[DA0F]                	mov dx, imsg.early_mem_fail
  2394 0000095A E8B612                  	call init_putsz_cs
  2395                                  
  2396 0000095D B80030                  	mov ax, 3000h
  2397 00000960 CD21                    	int 21h
  2398 00000962 3C05                    	cmp al, 5
  2399 00000964 7306                    	jae @F
  2400 00000966 BA[D610]                	mov dx, imsg.dos_below_5
  2401                                  .earlyfail:
  2402 00000969 E8A712                  	call init_putsz_cs
  2403                                  @@:
  2404                                  
  2405 0000096C 5F                      	pop di
  2406 0000096D 5E                      	pop si
  2407 0000096E 5A                      	pop dx
  2408 0000096F 59                      	pop cx
  2409 00000970 5B                      	pop bx
  2410 00000971 07                      	pop es
  2411                                  
  2412 00000972 8CD8                    	mov ax, ds
  2413 00000974 83C010                  	add ax, paras(100h)
  2414 00000977 26C747030581            	mov word [es:bx + 3], 8105h	; error, done, code: bad structure length
  2415 0000097D 2683670E00              	and word [es:bx + 0Eh], 0
  2416 00000982 26894710                	mov word [es:bx + 0Eh + 2], ax	; -> behind memory in use
  2417                                  
  2418 00000986 9D                      	popf
  2419 00000987 1F                      	pop ds
  2420 00000988 58                      	pop ax
  2421 00000989 CB                      	retf
  2422                                  
  2423                                  .memorygood:
  2424 0000098A 8CD8                    	mov ax, ds
  2425                                  %ifn _LINK
  2426                                  	add ax, paras(INITSECTIONOFFSET)
  2427                                  %else
  2428 0000098C 05[0000]                	add ax, strict word relocatedzero + 0
  2429                                   wlcalc word_segrel_INIT, equ $ - 2
  2430                                  %endif
  2431 0000098F 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 00000991 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 00000995 B9[0000]                	mov cx, relocatedzero + 0
  2463                                   wlcalc word_wrt_INIT_extpara_behind_deviceshim, equ $ - 2
  2464                                  %endif
  2465 00000998 E8E711                  	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 0000099B 52                      	push dx
  2476 0000099C E88FF8                  	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 0000099F 2EC706[360E][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 000009A6 2EC706[380E]8000        	mov word [cs:mem_envsize], paras(dev_env_size)
  2505                                  %endif
  2506                                  
  2507 000009AD 8CDB                    	mov bx, ds
  2508                                   %ifn _LINK
  2509                                  	add bx, FORCESTRICTWORD paras(DEVICEADJUST)
  2510                                   %else
  2511                                  ;%define DEVICEADJUST	(deviceshim_size + 110h)
  2512 000009AF 81C3[1100]              	add bx, strict word relocatedzero + paras(110h)
  2513                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2514                                   %endif
  2515 000009B3 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 000009B5 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 000009B9 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 000009BD 89D8                    	mov ax, bx
  2535 000009BF 050102                  	add ax, paras(auxbuff_size)
  2536                                   %endif
  2537 000009C2 89D1                    	mov cx, dx
  2538 000009C4 2EC706[3C0E][6C35]      	mov word [cs:init_layout], init_dev_layout_1
  2539 000009CB E861F8                  	call init_check_auxbuff
  2540 000009CE 7446                    	jz @F
  2541                                  
  2542 000009D0 8CDB                    	mov bx, ds
  2543                                   %ifn _LINK
  2544                                  	add bx, FORCESTRICTWORD paras(DEVICEADJUST)
  2545                                   %else
  2546                                  ;%define DEVICEADJUST	(deviceshim_size + 110h)
  2547 000009D2 81C3[1100]              	add bx, strict word relocatedzero + paras(110h)
  2548                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2549                                   %endif
  2550 000009D6 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 000009D8 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 000009DC 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 000009E0 2EC706[3C0E][7135]      	mov word [cs:init_layout], init_dev_layout_2
  2567 000009E7 E845F8                  	call init_check_auxbuff
  2568 000009EA 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 000009EC 2EC706[360E][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 000009F3 8CDB                    	mov bx, ds
  2594                                   %ifn _LINK
  2595                                  	add bx, FORCESTRICTWORD paras(DEVICEADJUST)
  2596                                   %else
  2597                                  ;%define DEVICEADJUST	(deviceshim_size + 110h)
  2598 000009F5 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 000009F9 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 000009FD 89CA                    	mov dx, cx
  2612                                   %if _EXTENSIONS || _HISTORY_SEPARATE_FIXED && _HISTORY || _DEV_ENV_SIZE
  2613 000009FF 89D8                    	mov ax, bx
  2614 00000A01 050102                  	add ax, paras(auxbuff_size)
  2615                                   %endif
  2616 00000A04 2EC706[3C0E][7635]      	mov word [cs:init_layout], init_dev_layout_3
  2617 00000A0B E821F8                  	call init_check_auxbuff
  2618 00000A0E 7406                    	jz @F
  2619                                  
  2620                                  		; Because this shouldn't happen, this is
  2621                                  		;  considered an internal error.
  2622 00000A10 BA[9310]                	mov dx, imsg.early_reloc_fail
  2623 00000A13 E953FF                  	jmp .earlyfail
  2624                                  
  2625                                  @@:
  2626                                   %if _EXTENSIONS || _HISTORY_SEPARATE_FIXED && _HISTORY || _DEV_ENV_SIZE
  2627 00000A16 50                      	push ax
  2628                                   %endif
  2629 00000A17 E8DDF7                  	call place_code_segments
  2630                                  
  2631                                  %if _MESSAGESEGMENT
  2632 00000A1A 8CD8                    	mov ax, ds
  2633                                  %ifn _LINK
  2634                                  	add ax, paras(MESSAGESECTIONOFFSET)
  2635                                  %else
  2636 00000A1C 05[0000]                	add ax, strict word relocatedzero + 0
  2637                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
  2638                                  %endif
  2639 00000A1F 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 00000A21 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 00000A25 B9[0000]                	mov cx, relocatedzero + 0
  2650                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_truncated, equ $ - 2
  2651                                  %endif
  2652 00000A28 E85711                  	call init_movp
  2653                                   %if _BOOTLDR_DISCARD_HELP
  2654                                  %ifn _LINK
  2655                                  	mov word [messageseg_size], messagesegment_nobits_truncated_size
  2656                                  %else
  2657 00000A2B C706[0000][0000]        	mov word [messageseg_size], behind_messagesegment_nobits_truncated wrt MESSAGESEGMENT
  2658                                  %endif
  2659                                    %if _HELP_COMPRESSED
  2660 00000A31 C706[0000][0000]        	mov word [indirect_hshrink_message_buffer], truncated_hshrink_message_buffer
  2661                                     %if _LINK || _LINK_COMPAT
  2662 00000A37 8E06[0000]              	mov es, [code_seg]
  2663 00000A3B 26800E[0000]01          	setopt [es:patch_boothelp_uncompressed], NONCOMPRESSEDFLAG
  2664                                     %endif
  2665                                    %endif
  2666 00000A41 1E                      	push ds
  2667 00000A42 0E                      	 push cs
  2668 00000A43 1F                      	 pop ds
  2669 00000A44 BE[0A17]                	mov si, imsg.boothelp_replacement
  2670 00000A47 8EC2                    	mov es, dx
  2671 00000A49 BF[0000]                	mov di, msg.boothelp
  2672 00000A4C B91C00                  	mov cx, imsg.boothelp_replacement_size_w
  2673 00000A4F F3A5                    	rep movsw
  2674 00000A51 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 00000A53 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 00000A56 F3AB                    	rep stosw
  2688 00000A58 1F                      	pop ds
  2689                                   %endif
  2690 00000A59 52                      	push dx
  2691                                  %endif
  2692                                  
  2693 00000A5A 8CD8                    	mov ax, ds
  2694 00000A5C 83C010                  	add ax, 10h
  2695 00000A5F 89C2                    	mov dx, ax
  2696                                  %ifn _LINK
  2697                                  	add dx, FORCESTRICTWORD paras(deviceshim_size + 110h)
  2698                                  %else
  2699 00000A61 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 00000A65 B9[F0FF]                	mov cx, relocatedzero + - paras(256)
  2706                                   wlcalc word_wrt_@@lDEBUG_DATA_ENTRY@_extpara_behind_progbits_dataentry, equ $ - 2
  2707                                  %endif
  2708 00000A68 E81711                  	call init_movp
  2709                                  
  2710 00000A6B 8CC8                    	mov ax, cs
  2711                                  %ifn _LINK
  2712                                  	add ax, init_size_p
  2713                                  %else
  2714 00000A6D 05[0000]                	add ax, strict word relocatedzero + 0
  2715                                   wlcalc word_wrt_INIT_extpara_behind_init, equ $ - 2
  2716                                  %endif
  2717 00000A70 8CDA                    	mov dx, ds
  2718 00000A72 83C210                  	add dx, paras(100h)
  2719                                  %ifn _LINK
  2720                                  	mov cx, deviceshim_size_p
  2721                                  %else
  2722 00000A75 B9[0000]                	mov cx, relocatedzero + 0
  2723                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2724                                  %endif
  2725 00000A78 E80711                  	call init_movp
  2726                                  
  2727 00000A7B 8CDA                    	mov dx, ds
  2728                                  %ifn _LINK
  2729                                  	add dx, FORCESTRICTWORD paras(100h) + deviceshim_size_p
  2730                                  %else
  2731 00000A7D 81C2[1000]              	add dx, strict word relocatedzero + paras(100h)
  2732                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2733                                  %endif
  2734 00000A81 8EC2                    	mov es, dx
  2735 00000A83 1E                      	push ds
  2736                                  %ifn _LINK
  2737                                  	sub dx, FORCESTRICTWORD deviceshim_size_p + 1
  2738                                  %else
  2739 00000A84 81EA[0100]              	sub dx, strict word relocatedzero + 1
  2740                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2741                                  %endif
  2742 00000A88 8EDA                    	mov ds, dx
  2743 00000A8A 31C0                    	xor ax, ax
  2744 00000A8C 31FF                    	xor di, di
  2745 00000A8E B90400                  	mov cx, 4
  2746 00000A91 F3AB                    	rep stosw
  2747 00000A93 BE0800                  	mov si, 8
  2748 00000A96 B104                    	mov cl, 4
  2749 00000A98 F3A5                    	rep movsw
  2750 00000A9A 1F                      	pop ds
  2751                                  
  2752 00000A9B 8CDA                    	mov dx, ds
  2753                                   %ifn _LINK
  2754                                  	add dx, FORCESTRICTWORD paras(DEVICEADJUST)
  2755                                   %else
  2756                                  ;%define DEVICEADJUST	(deviceshim_size + 110h)
  2757 00000A9D 81C2[1100]              	add dx, strict word relocatedzero + paras(110h)
  2758                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2759                                   %endif
  2760 00000AA1 8EDA                    	mov ds, dx
  2761                                  
  2762                                  %if _MESSAGESEGMENT
  2763                                   %if _HELP_COMPRESSED && ! _PM
  2764                                  	pop ax
  2765                                  	mov [hshrink_memory_source.segment], ax
  2766                                  	mov [messageseg], ax
  2767                                   %else
  2768 00000AA3 8F06[0000]              	pop word [messageseg]
  2769                                   %endif
  2770                                  %endif
  2771                                  
  2772 00000AA7 53                      	push bx
  2773 00000AA8 B451                    	mov ah, 51h
  2774 00000AAA CD21                    	int 21h
  2775 00000AAC 891E[0000]              	mov word [pspdbe], bx
  2776 00000AB0 5B                      	pop bx
  2777                                  
  2778 00000AB1 8EC2                    	mov es, dx
  2779 00000AB3 B98000                  	mov cx, words(256)
  2780 00000AB6 31FF                    	xor di, di
  2781 00000AB8 31C0                    	xor ax, ax
  2782 00000ABA 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 00000ABC 58                      	pop ax
  2788                                    %if _HISTORY_SEPARATE_FIXED && _HISTORY
  2789 00000ABD A3[0000]                	mov word [history.segorsel + soaSegSel], ax
  2790                                  %if _PM
  2791 00000AC0 A3[0200]                	mov word [history.segorsel + soaSegment], ax
  2792                                  %endif
  2793 00000AC3 8EC0                    	mov es, ax
  2794 00000AC5 31FF                    	xor di, di
  2795 00000AC7 B90010                  	mov cx, historysegment_size >> 1
  2796 00000ACA 31C0                    	xor ax, ax
  2797 00000ACC F3AB                    	rep stosw
  2798                                    %endif
  2799                                  
  2800                                    %if _DEV_ENV_SIZE
  2801                                     %if _HISTORY_SEPARATE_FIXED && _HISTORY
  2802 00000ACE 8CC0                    	mov ax, es
  2803 00000AD0 050002                  	add ax, paras(historysegment_size)
  2804                                     %endif
  2805 00000AD3 A3[0000]                	mov word [envseg], ax
  2806 00000AD6 8EC0                    	mov es, ax
  2807 00000AD8 89C2                    	mov dx, ax
  2808 00000ADA 42                      	inc dx
  2809 00000ADB 31FF                    	xor di, di
  2810 00000ADD B90004                  	mov cx, dev_env_size >> 1
  2811 00000AE0 C706[0000]0008          	mov word [env_size], dev_env_size
  2812 00000AE6 31C0                    	xor ax, ax
  2813 00000AE8 F3AB                    	rep stosw
  2814 00000AEA 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 00000AF1 8CC0                    	mov ax, es
  2820                                      %if _DEV_ENV_SIZE
  2821 00000AF3 058000                  	add ax, paras(dev_env_size)
  2822                                      %else
  2823                                  	add ax, paras(historysegment_size)
  2824                                      %endif
  2825                                     %endif
  2826 00000AF6 A3[0000]                	mov word [extseg], ax
  2827 00000AF9 8EC0                    	mov es, ax
  2828 00000AFB 31FF                    	xor di, di
  2829 00000AFD B90010                  	mov cx, extsegment_size >> 1
  2830 00000B00 31C0                    	xor ax, ax
  2831 00000B02 F3AB                    	rep stosw
  2832                                    %endif
  2833                                   %endif
  2834                                  
  2835 00000B04 89D8                    	mov ax, bx
  2836                                  
  2837 00000B06 A3[0000]                	mov word [auxbuff_segorsel + soaSegSel], ax
  2838                                  %if _PM
  2839 00000B09 A3[0200]                	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 00000B0C 8EC0                    	mov es, ax
  2847 00000B0E 31FF                    	xor di, di
  2848 00000B10 B90810                  	mov cx, _AUXBUFFSIZE >> 1
  2849 00000B13 31C0                    	xor ax, ax
  2850 00000B15 F3AB                    	rep stosw			; initialise auxbuff
  2851                                  
  2852                                  %if _DEV_ENV_SIZE
  2853 00000B17 89162C00                	mov word [2Ch], dx
  2854 00000B1B 1E                      	push ds
  2855 00000B1C E87701                  	call init_device_get_environment
  2856 00000B1F 85C0                    	test ax, ax
  2857 00000B21 7425                    	jz @F
  2858 00000B23 8ED8                    	mov ds, ax
  2859 00000B25 8EC2                    	mov es, dx
  2860 00000B27 31FF                    	xor di, di
  2861 00000B29 31F6                    	xor si, si
  2862                                  .loop_env:
  2863 00000B2B E89028                  	call init_nextvar
  2864 00000B2E 75FB                    	jne .loop_env
  2865 00000B30 46                      	inc si
  2866 00000B31 81FEEE07                	cmp si, dev_env_size - 16 - 2
  2867 00000B35 7608                    	jbe .copy_env
  2868 00000B37 BA[8F0F]                	mov dx, imsg.dev_env_too_large
  2869 00000B3A E8D610                  	call init_putsz_cs
  2870 00000B3D EB09                    	jmp @F
  2871                                  
  2872                                  .copy_env:
  2873 00000B3F 89F1                    	mov cx, si
  2874 00000B41 31F6                    	xor si, si
  2875 00000B43 F3A4                    	rep movsb
  2876 00000B45 31C0                    	xor ax, ax
  2877 00000B47 AB                      	stosw
  2878                                  @@:
  2879 00000B48 1F                      	pop ds
  2880                                  %endif
  2881                                  
  2882 00000B49 8CD8                    	mov ax, ds			; => PSP
  2883                                  %ifn _LINK
  2884                                  	sub ax, strict word deviceshim_size_p + paras(10h)
  2885                                  %else
  2886 00000B4B 2D[0100]                	sub ax, strict word relocatedzero + paras(10h)
  2887                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2888                                  %endif
  2889 00000B4E A3[0200]                	mov word [device_header_address + 2], ax
  2890 00000B51 A3[0000]                	mov word [alloc_seg], ax
  2891                                  
  2892 00000B54 8CD8                    	mov ax, ds			; => PSP
  2893 00000B56 2E8B1E[360E]            	mov bx, word [cs:memsize]
  2894                                  		; = amount paragraphs for PSP + DATA ENTRY + TABLE
  2895                                  		;  + DATA STACK + CODE + AUXBUFF + HISTORY + dev ENV + EXT
  2896 00000B5B 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 00000B5D 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 00000B61 891E[0000]              	mov word [device_mcb_paragraphs], bx
  2907 00000B65 891E[0000]              	mov word [alloc_size], bx
  2908                                  
  2909                                  					; ax => where to place container sig
  2910 00000B69 E80200                  	call init_dev_place_container_signature
  2911                                  					; ax => behind memory used for device
  2912 00000B6C 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 00000B6E 8EC0                    	mov es, ax
  2920 00000B70 31FF                    	xor di, di			; -> buffer for trailing container MCB
  2921 00000B72 B90800                  	mov cx, words(10h)		; = amount words
  2922 00000B75 1E                      	push ds
  2923 00000B76 0E                      	 push cs
  2924 00000B77 1F                      	 pop ds
  2925 00000B78 BE[A00D]                	 mov si, init_container_signature	; -> init string
  2926 00000B7B F3A5                    	rep movsw
  2927 00000B7D 1F                      	pop ds
  2928 00000B7E 40                      	inc ax				; => behind memory used for device
  2929 00000B7F C3                      	retn
  2930                                  
  2931                                  
  2932                                  @@:
  2933 00000B80 8F06[0000]              	pop word [reg_edi]
  2934 00000B84 8F06[0000]              	pop word [reg_esi]
  2935 00000B88 8F06[0000]              	pop word [reg_edx]
  2936 00000B8C 8F06[0000]              	pop word [reg_ecx]
  2937 00000B90 892E[0000]              	mov word [reg_ebp], bp
  2938 00000B94 5B                      	pop bx
  2939 00000B95 07                      	pop es
  2940 00000B96 891E[0000]              	mov word [reg_ebx], bx
  2941 00000B9A 8C06[0000]              	mov word [reg_es], es
  2942                                  
  2943 00000B9E 26C747030001            	mov word [es:bx + 3], 100h	; no error, done
  2944 00000BA4 2683670E00              	and word [es:bx + 0Eh], 0
  2945 00000BA9 26894710                	mov word [es:bx + 0Eh + 2], ax	; -> behind memory in use
  2946                                  
  2947 00000BAD 8F06[0000]              	pop word [reg_efl]
  2948 00000BB1 8F06[0000]              	pop word [reg_ds]
  2949 00000BB5 8F06[0000]              	pop word [reg_eax]
  2950 00000BB9 8C16[0000]              	mov word [reg_ss], ss
  2951 00000BBD 8926[0000]              	mov word [reg_esp], sp
  2952                                  
  2953 00000BC1 8C1E[0000]              	mov word [reg_cs], ds
  2954 00000BC5 C706[0000][0000]        	mov word [reg_eip], entry_retf
  2955                                  
  2956                                  .cmdline:
  2957 00000BCB 1E                      	push ds
  2958 00000BCC 26C57712                	lds si, [es:bx + 12h]		; ds:si -> device command line
  2959 00000BD0 07                      	pop es
  2960                                  %if _CONFIG
  2961 00000BD1 1E                      	push ds
  2962 00000BD2 56                      	push si
  2963                                  %endif
  2964 00000BD3 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 00000BD6 AC                      	lodsb
  2976 00000BD7 3C20                    	cmp al, 32			; blank ?
  2977 00000BD9 7412                    	je @F
  2978 00000BDB 3C09                    	cmp al, 9
  2979 00000BDD 740E                    	je @F				; yes, got past executable filename -->
  2980 00000BDF 3C00                    	cmp al, 0
  2981 00000BE1 7448                    	je .cmdline_end
  2982 00000BE3 3C0D                    	cmp al, 13
  2983 00000BE5 7444                    	je .cmdline_end
  2984 00000BE7 3C0A                    	cmp al, 10
  2985 00000BE9 7440                    	je .cmdline_end			; if empty tail -->
  2986 00000BEB EBE9                    	jmp @B
  2987                                  @@:
  2988 00000BED 81FFFF00                	cmp di, 0FFh			; can store and still have space for CR ?
  2989 00000BF1 7430                    	je .cmdline_end_truncate	; no -->
  2990 00000BF3 AA                      	stosb				; store it
  2991 00000BF4 3C00                    	cmp al, 0			; EOL ?
  2992 00000BF6 7432                    	je .cmdline_end_dec
  2993 00000BF8 3C0D                    	cmp al, 13
  2994 00000BFA 742E                    	je .cmdline_end_dec
  2995 00000BFC 3C0A                    	cmp al, 10
  2996 00000BFE 742A                    	je .cmdline_end_dec		; yes -->
  2997 00000C00 AC                      	lodsb
  2998 00000C01 3C21                    	cmp al, '!'			; escape for small letters ?
  2999 00000C03 75E8                    	jne @B				; no -->
  3000 00000C05 AC                      	lodsb
  3001 00000C06 3C00                    	cmp al, 0
  3002 00000C08 7414                    	je .cmdline_end_escaped
  3003 00000C0A 3C0D                    	cmp al, 13
  3004 00000C0C 7410                    	je .cmdline_end_escaped
  3005 00000C0E 3C0A                    	cmp al, 10
  3006 00000C10 740C                    	je .cmdline_end_escaped
  3007                                  	; cmp al, '!'			; (automatically supported)
  3008 00000C12 3C41                    	cmp al, 'A'			; is it a capital letter ?
  3009 00000C14 72D7                    	jb @B
  3010 00000C16 3C5A                    	cmp al, 'Z'
  3011 00000C18 77D3                    	ja @B
  3012 00000C1A 3420                    	xor al, 'a' ^ 'A'		; get the small letter
  3013 00000C1C EBCF                    	jmp @B
  3014                                  
  3015                                  .cmdline_end_escaped:
  3016 00000C1E BA[FF10]                	mov dx, imsg.device_end_escaped
  3017 00000C21 EB03                    	jmp @F
  3018                                  
  3019                                  .cmdline_end_truncate:
  3020 00000C23 BA[4311]                	mov dx, imsg.device_end_truncate
  3021                                   @@:
  3022 00000C26 E8EA0F                  	call init_putsz_cs
  3023 00000C29 A8                      	db __TEST_IMM8			; skip dec
  3024                                  .cmdline_end_dec:
  3025 00000C2A 4F                      	dec di
  3026                                  .cmdline_end:
  3027 00000C2B B00D                    	mov al, 13
  3028 00000C2D AA                      	stosb				; store CR
  3029 00000C2E 97                      	xchg ax, di
  3030 00000C2F 8CC3                    	 mov bx, es
  3031 00000C31 8EDB                    	 mov ds, bx
  3032 00000C33 2C82                    	sub al, 82h			; if -> 82h (CR at 81h). get 0
  3033 00000C35 A28000                  	mov byte [80h], al		; store length
  3034                                  
  3035                                  %if _CONFIG
  3036 00000C38 5E                      	pop si
  3037 00000C39 5A                      	pop dx
  3038                                  %endif
  3039                                  
  3040 00000C3A FA                      	cli
  3041 00000C3B 8ED3                    	 mov ss, bx
  3042 00000C3D BC[0000]                	 mov sp, stack_end		; device mode stack switch
  3043 00000C40 FB                      	sti
  3044                                  
  3045 00000C41 800E[0200]40            	setopt [internalflags], tsrmode
  3046 00000C46 8026[0200]7F            	clropt [internalflags], attachedterm
  3047 00000C4B 800E[0200]40            	setopt [internalflags6], dif6_device_mode
  3048                                  
  3049                                  %if _CONFIG
  3050                                  find_config_device:
  3051 00000C50 E84300                  	call init_device_get_environment
  3052                                  
  3053 00000C53 36C606[0000]00          	mov byte [ss:configpath], 0
  3054 00000C59 50                      	push ax
  3055 00000C5A 52                      	push dx
  3056 00000C5B 56                      	push si
  3057 00000C5C BF[740F]                	mov di, imsg.varconfig
  3058 00000C5F B90D00                  	mov cx, imsg.varconfig.length
  3059 00000C62 BA[0000]                	mov dx, configpath
  3060 00000C65 E8BA27                  	call init_copyvar
  3061 00000C68 5E                      	pop si
  3062 00000C69 1F                      	pop ds			; -> command line
  3063 00000C6A 1E                      	push ds
  3064 00000C6B 56                      	push si
  3065 00000C6C 7303                    	jnc .done
  3066 00000C6E E84A00                  	call find_executable_device
  3067                                  .done:
  3068 00000C71 5E                      	pop si
  3069 00000C72 1F                      	pop ds			; -> command line
  3070 00000C73 58                      	pop ax
  3071                                  
  3072                                  find_scripts_device:
  3073 00000C74 36C606[0000]00          	mov byte [ss:scriptspath], 0
  3074 00000C7A 1E                      	push ds
  3075 00000C7B 56                      	push si
  3076 00000C7C BF[810F]                	mov di, imsg.varscripts
  3077 00000C7F B90E00                  	mov cx, imsg.varscripts.length
  3078 00000C82 BA[0000]                	mov dx, scriptspath
  3079 00000C85 E89A27                  	call init_copyvar
  3080 00000C88 5E                      	pop si
  3081 00000C89 1F                      	pop ds			; -> command line
  3082 00000C8A 7303                    	jnc .done
  3083 00000C8C E82C00                  	call find_executable_device
  3084                                  .done:
  3085                                  
  3086 00000C8F 16                      	push ss
  3087 00000C90 1F                      	pop ds
  3088 00000C91 16                      	push ss
  3089 00000C92 07                      	pop es
  3090                                  %endif
  3091                                  
  3092 00000C93 E9F70F                  	jmp old_initcode
  3093                                  
  3094                                  
  3095                                  init_device_get_environment:
  3096 00000C96 B451                    	mov ah, 51h
  3097 00000C98 CD21                    	int 21h
  3098 00000C9A 8EDB                    	mov ds, bx
  3099 00000C9C A12C00                  	mov ax, [2Ch]
  3100 00000C9F 85C0                    	test ax, ax
  3101 00000CA1 7517                    	jnz @F
  3102 00000CA3 A11600                  	mov ax, [16h]
  3103 00000CA6 85C0                    	test ax, ax
  3104 00000CA8 740E                    	jz .zero
  3105 00000CAA 83F8FF                  	cmp ax, -1
  3106 00000CAD 7409                    	je .zero
  3107 00000CAF 39D8                    	cmp ax, bx
  3108 00000CB1 8ED8                    	mov ds, ax
  3109 00000CB3 A12C00                  	mov ax, [2Ch]
  3110 00000CB6 7502                    	jne @F
  3111                                  .zero:
  3112 00000CB8 31C0                    	xor ax, ax
  3113                                  @@:
  3114 00000CBA 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 00000CBB AC                      	lodsb
  3123 00000CBC 3C20                    	cmp al, 32
  3124 00000CBE 74FB                    	je @B
  3125 00000CC0 3C09                    	cmp al, 9
  3126 00000CC2 74F7                    	je @B
  3127 00000CC4 4E                      	dec si
  3128 00000CC5 89F7                    	mov di, si
  3129                                  @@:
  3130 00000CC7 AC                      	lodsb
  3131 00000CC8 3C09                    	cmp al, 9
  3132 00000CCA 7410                    	je @F
  3133 00000CCC 3C20                    	cmp al, 32
  3134 00000CCE 740C                    	je @F
  3135 00000CD0 3C0D                    	cmp al, 13
  3136 00000CD2 7408                    	je @F
  3137 00000CD4 3C0A                    	cmp al, 10
  3138 00000CD6 7404                    	je @F
  3139 00000CD8 84C0                    	test al, al
  3140 00000CDA 75EB                    	jnz @B
  3141                                  @@:
  3142 00000CDC 4E                      	dec si
  3143 00000CDD 1E                      	push ds
  3144 00000CDE 07                      	pop es
  3145 00000CDF 89F1                    	mov cx, si
  3146 00000CE1 29F9                    	sub cx, di
  3147 00000CE3 83F97F                  	cmp cx, 127
  3148 00000CE6 7722                    	ja .nodevice
  3149 00000CE8 87FE                    	xchg di, si
  3150                                  
  3151 00000CEA B90000                  	mov cx, 0
  3152                                  @@:
  3153 00000CED 39F7                    	cmp di, si
  3154 00000CEF 7610                    	jbe @F
  3155 00000CF1 4F                      	dec di
  3156 00000CF2 803D2F                  	cmp byte [di], '/'
  3157 00000CF5 7405                    	je .slash
  3158 00000CF7 803D5C                  	cmp byte [di], '\'
  3159 00000CFA 75F1                    	jne @B
  3160                                  .slash:
  3161 00000CFC 89F9                    	mov cx, di
  3162 00000CFE 41                      	inc cx
  3163 00000CFF 29F1                    	sub cx, si
  3164                                  @@:
  3165                                  
  3166 00000D01 16                      	push ss
  3167 00000D02 07                      	pop es
  3168 00000D03 89D7                    	mov di, dx
  3169 00000D05 F3A4                    	rep movsb
  3170 00000D07 B000                    	mov al, 0
  3171 00000D09 AA                      	stosb
  3172                                  
  3173                                  .nodevice:
  3174                                  .done:
  3175 00000D0A C3                      	retn
  3176                                  %endif
  3177                                  
  3178                                  
  3179                                  init_device_error_late:
  3180 00000D0B F606[0100]80            	testopt [internalflags], has386
  3181 00000D10 7431                    	jz .16
  3182                                  
  3183                                  subcpu 386
  3184 00000D12 66A1[0000]              	mov eax, [reg_eax]
  3185 00000D16 668B1E[0000]            	mov ebx, [reg_ebx]
  3186 00000D1B 668B0E[0000]            	mov ecx, [reg_ecx]
  3187 00000D20 668B16[0000]            	mov edx, [reg_edx]
  3188 00000D25 668B36[0000]            	mov esi, [reg_esi]
  3189 00000D2A 668B3E[0000]            	mov edi, [reg_edi]
  3190 00000D2F 668B2E[0000]            	mov ebp, [reg_ebp]
  3191 00000D34 66FF36[0000]            	push dword [reg_efl]
  3192 00000D39 669D                    	popfd
  3193 00000D3B 8E26[0000]              	mov fs, [reg_fs]
  3194 00000D3F 8E2E[0000]              	mov gs, [reg_gs]
  3195                                  subcpureset
  3196                                  
  3197                                  .16:
  3198                                  		; ax done last
  3199 00000D43 8B1E[0000]              	mov bx, [reg_ebx]
  3200 00000D47 8B0E[0000]              	mov cx, [reg_ecx]
  3201 00000D4B 8B16[0000]              	mov dx, [reg_edx]
  3202 00000D4F 8B36[0000]              	mov si, [reg_esi]
  3203 00000D53 8B3E[0000]              	mov di, [reg_edi]
  3204 00000D57 8B2E[0000]              	mov bp, [reg_ebp]
  3205 00000D5B FF36[0000]              	push word [reg_efl]
  3206 00000D5F 9D                      	popf
  3207 00000D60 8E06[0000]              	mov es, [reg_es]
  3208 00000D64 8E16[0000]              	mov ss, [reg_ss]
  3209 00000D68 8B26[0000]              	mov sp, [reg_esp]
  3210 00000D6C FF36[0000]              	push word [reg_eax]
  3211 00000D70 8CD8                    	mov ax, ds
  3212 00000D72 8E1E[0000]              	mov ds, [reg_ds]
  3213                                  
  3214                                  %ifn _LINK
  3215                                  	sub ax, strict word paras(deviceshim_size + 10h)
  3216                                  %else
  3217 00000D76 2D[0100]                	sub ax, strict word relocatedzero + paras(10h)
  3218                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  3219                                  %endif
  3220 00000D79 26C747030381            	mov word [es:bx + 3], 8103h	; error, done, code: unknown command
  3221 00000D7F 2683670E00              	and word [es:bx + 0Eh], 0
  3222 00000D84 26894710                	mov word [es:bx + 0Eh + 2], ax	; -> behind memory in use
  3223 00000D88 58                      	pop ax
  3224 00000D89 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 00000D8A 00<rep 6h>              	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 00000D90 4E4445423030            	db "NDEB00"
  3351 00000D96 0000                    .check:	dw 0
  3352 00000D98 0000                    .size:	dw 0
  3353 00000D9A 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 00000DA0 464F525F53445F434F-     	fill 16, 0, db "FOR_SD_CONTAINER"
  3379 00000DA9 4E5441494E4552     
  3380                                  %endif
  3381                                  %if _EXTENSIONS
  3382                                  	align 16, db 0
  3383                                  eld_linkcall:
  3384                                  .:
  3385                                  	istruc ELD_INSTANCE
  3386 00000DB0 0000                    at eldiStartCode,	dw 0
  3387 00000DB2 8000                    at eldiEndCode,		dw .end - .
  3388 00000DB4 0000                    at eldiStartData,	dw 0
  3389 00000DB6 0000                    at eldiEndData,		dw 0
  3390 00000DB8 4C494E4B43414C4C        at eldiIdentifier,	fill 8, 32, db "LINKCALL"
  3391 00000DC0 0100                    at eldiFlags,		dw eldifResident
  3392 00000DC2 00<rep Eh>              	iend
  3393                                  .to_entry:
  3394 00000DD0 53                      	push bx
  3395 00000DD1 B300                    	mov bl, 0 * (1 + !!_PM)
  3396 00000DD3 EB0E                    	jmp @F
  3397 00000DD5 90<rep 3h>              	align 8
  3398                                  .to_code1:
  3399 00000DD8 53                      	push bx
  3400 00000DD9 B304                    	mov bl, 2 * (1 + !!_PM)
  3401                                  %if _DUALCODE
  3402 00000DDB EB06                    	jmp @F
  3403 00000DDD 90<rep 3h>              	align 8
  3404                                  .to_code2:
  3405 00000DE0 53                      	push bx
  3406 00000DE1 B308                    	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 00000DE3 50                      	 push ax
  3414                                  	lpar dword, transfer
  3415 00000DE4 50                      	 push ax
  3416 00000DE5 50                      	 push ax
  3417 00000DE6 5589E5                  	lenter
  3418                                  	lvar word, restorebx
  3419 00000DE9 FF7608                  	 push word [bp + ?origbx_farret_ofs]
  3420                                   %if _PM
  3421                                  	lvar word, restoredi
  3422 00000DEC 57                      	 push di
  3423                                   %endif
  3424 00000DED B700                    	mov bh, 0
  3425 00000DEF 36FFB7[0000]            	push word [ss:extcall_table.ret + bx]
  3426 00000DF4 8F4606                  	pop word [bp + ?restore_back_nearret]
  3427                                   %if _PM
  3428 00000DF7 368B3E[0000]            	mov di, [ss:pm_2_86m_0]
  3429 00000DFC 368B99[0000]            	mov bx, word [ss:extcall_table.segsel + bx + di]
  3430                                   %else
  3431                                  	mov bx, word [ss:extcall_table.segsel + bx]
  3432                                   %endif
  3433 00000E01 368B1F                  	mov bx, word [ss:bx]
  3434 00000E04 895E04                  	mov word [bp + ?transfer + 2], bx
  3435                                  
  3436 00000E07 8B5E0A                  	mov bx, word [bp + ?origret_farret_seg]
  3437 00000E0A 2EFF7702                	push word [cs:bx + 2]
  3438 00000E0E 8F4602                  	pop word [bp + ?transfer]
  3439 00000E11 895E08                  	mov word [bp + ?origbx_farret_ofs], bx
  3440                                   %ifn _PM
  3441                                  	mov word [bp + ?origret_farret_seg], cs
  3442                                   %endif
  3443                                   %if _PM
  3444 00000E14 5F                      	pop di		; ?restoredi
  3445                                   %endif
  3446 00000E15 5B                      	pop bx		; ?restorebx
  3447                                  	lleave ctx
  3448 00000E16 5D                      	pop bp		; ?frame_bp
  3449 00000E17 CB                      	retf		; ?transfer
  3450                                  			; still on stack: near return address, far return address
  3451                                  
  3452 00000E18 90<rep 11h>             	times 79h - ($ - .) nop
  3453                                  .call_cmd3:
  3454 00000E29 E8ACFF                  	call .to_code1
  3455 00000E2C EBFE                    	jmp strict short $
  3456 00000E2E [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 00000E30 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 00000E36 [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 00000E38 0000                    mem_envsize:	dw 0
  3504                                  %endif
  3505                                  cmdline_buffer_start:
  3506 00000E3A [0000]                  		dw cmdline_buffer
  3507                                  init_layout:
  3508 00000E3C [9935]                  		dw init_layout_none
  3509                                  %if _DEVICE
  3510 00000E3E 0000                    dev_memory_end:	dw 0
  3511                                  %endif
  3512                                  init_auxbuff_want:
  3513 00000E40 1020                    		dw _AUXBUFFSIZE
  3514                                  %if _EXTENSIONS
  3515 00000E42 0040                    init_ext_want:	dw _EXT_CODE_DEFAULT_SIZE
  3516 00000E44 0040                    init_extdata_want:	dw _EXT_DATA_DEFAULT_SIZE
  3517                                  %endif
  3518                                  %if _HISTORY_SEPARATE_FIXED && _HISTORY
  3519 00000E46 0020                    init_history_want:	dw _HISTORY_WANT_SIZE
  3520                                  %endif
  3521                                  
  3522                                  init_switch_p_low_pathsearch_high_guessextension:
  3523 00000E48 00                      init_switch_p_pathsearch:	db 0
  3524 00000E49 00                      init_switch_p_guessextension:	db 0
  3525 00000E4A 0000                    relocate_source:	dw 0
  3526 00000E4C 0000                    relocate_down:		dw 0
  3527 00000E4E 0000                    init_switch_r:		dw 0
  3528 00000E50 0000                    init_base_size:		dw 0
  3529 00000E52 0000                    init_target_size:	dw 0
  3530 00000E54 0100                    init_switch_t_umblink:	dw 1		; Add UMBs to memory chain
  3531 00000E56 FFFF                    			dw -1
  3532 00000E58 FFFF                    			dw -1
  3533 00000E5A 8200                    init_switch_t_strategy:	dw 82h		; Last fit, high then low
  3534 00000E5C 8200                    			dw 82h
  3535 00000E5E 8200                    			dw 82h
  3536                                  %if _BOOTLDR
  3537 00000E60 0000                    init_boot_new_memsizekib:	dw 0
  3538 00000E62 0000                    init_boot_old_memsizekib:	dw 0
  3539                                  
  3540 00000E64 0000                    init_boot_ebdasize:	dw 0
  3541 00000E66 0000                    init_boot_ebdasource:	dw 0
  3542 00000E68 0000                    init_boot_ebdadest:	dw 0
  3543 00000E6A 00                      init_boot_ebdaflag:	db 0
  3544 00000E6B 00                      init_preserveloader:	db 0
  3545                                  %endif
  3546 00000E6C FF                      init_switch_pw:		db 0FFh
  3547 00000E6D 00                      init_switch_t:		db 0
  3548 00000E6E 00                      init_switch_t_ignore:	db 0
  3549 00000E6F 00                      init_switch_t_break:	db 0
  3550 00000E70 00                      init_switch_t_variable:	db 0		; /TV: do not relocate environment
  3551                                  %if _APP_ENV_SIZE || _DEV_ENV_SIZE
  3552 00000E71 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 00000E72 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 00000E7A 2E434F4D            <1> .p_extensions:	db ".COM"
   430 00000E7E 2E455845            <1> 		db ".EXE"
   431                              <1>  %ifn INTERC3
   432 00000E82 2E42494E            <1> 		db ".BIN"
   433                              <1>  %endif
   434 00000E86 00                  <1> 		asciz
   435                              <1> %if (($ - 1 - .p_extensions) % 4) != 0
   436                              <1>  %error Wrong extensions length
   437                              <1> %endif
   438 00000E87 504154483D          <1> .varpath:	db "PATH="
   439                              <1> .varpath.length equ $ - .varpath
   440                              <1> .extension_warning:
   441                              <1> %ifn ELD
   442 00000E8C 436F6E64746E6C2E20- <1> 	db _PROGNAME,": "
   442 00000E95 44656275676761626C- <1>
   442 00000E9E 65206C446562756758- <1>
   442 00000EA7 3A20                <1>
   443                              <1> %endif
   444 00000EA9 5761726E696E672C20- <1> 	asciz "Warning, unknown filename extension specified!",13,10
   444 00000EB2 756E6B6E6F776E2066- <1>
   444 00000EBB 696C656E616D652065- <1>
   444 00000EC4 7874656E73696F6E20- <1>
   444 00000ECD 737065636966696564- <1>
   444 00000ED6 210D0A00            <1>
   445                              <1> .kktoolong:
   446                              <1> %ifn ELD
   447 00000EDA 436F6E64746E6C2E20- <1> 	db _PROGNAME,": "
   447 00000EE3 44656275676761626C- <1>
   447 00000EEC 65206C446562756758- <1>
   447 00000EF5 3A20                <1>
   448                              <1> %endif
   449 00000EF7 4572726F722C20746F- <1> 	asciz "Error, too long command line tail!",13,10
   449 00000F00 6F206C6F6E6720636F- <1>
   449 00000F09 6D6D616E64206C696E- <1>
   449 00000F12 65207461696C210D0A- <1>
   449 00000F1B 00                  <1>
   450                              <1> .pathtoolong:
   451                              <1> %ifn ELD
   452 00000F1C 436F6E64746E6C2E20- <1> 	db _PROGNAME,": "
   452 00000F25 44656275676761626C- <1>
   452 00000F2E 65206C446562756758- <1>
   452 00000F37 3A20                <1>
   453                              <1> %endif
   454 00000F39 4572726F722C20746F- <1> 	asciz "Error, too long %PATH% variable element!",13,10
   454 00000F42 6F206C6F6E67202550- <1>
   454 00000F4B 415448252076617269- <1>
   454 00000F54 61626C6520656C656D- <1>
   454 00000F5D 656E74210D0A00      <1>
   455                              <1> %endif
  3568                                  %endif
  3569                                  
  3570 00000F64 4D415800                .max:	asciz "MAX"
  3571 00000F68 4D494E00                .min:	asciz "MIN"
  3572                                  .default:
  3573 00000F6C 44454641554C5400        	asciz "DEFAULT"
  3574                                  %if _CONFIG
  3575 00000F74 4C4445425547434F4E-     .varconfig:	db "LDEBUGCONFIG="
  3575 00000F7D 4649473D           
  3576                                  .varconfig.length equ $ - .varconfig
  3577 00000F81 4C4445425547534352-     .varscripts:	db "LDEBUGSCRIPTS="
  3577 00000F8A 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 00000F8F 436F6E64746E6C2E20-     	asciz _PROGNAME,": Warning, too long environment! Not copying.",13,10
  3583 00000F98 44656275676761626C-
  3583 00000FA1 65206C446562756758-
  3583 00000FAA 3A205761726E696E67-
  3583 00000FB3 2C20746F6F206C6F6E-
  3583 00000FBC 6720656E7669726F6E-
  3583 00000FC5 6D656E7421204E6F74-
  3583 00000FCE 20636F7079696E672E-
  3583 00000FD7 0D0A00             
  3584                                  %endif
  3585                                  %if _APPLICATION || _DEVICE
  3586                                  .early_mem_fail:
  3587 00000FDA 436F6E64746E6C2E20-     	db _PROGNAME,": Failed to allocate memory!"
  3587 00000FE3 44656275676761626C-
  3587 00000FEC 65206C446562756758-
  3587 00000FF5 3A204661696C656420-
  3587 00000FFE 746F20616C6C6F6361-
  3587 00001007 7465206D656D6F7279-
  3587 00001010 21                 
  3588                                  %endif
  3589                                  .crlf:
  3590 00001011 0D0A00                  	asciz 13,10
  3591                                  .relocate_failure:
  3592 00001014 436F6E64746E6C2E20-     	asciz _PROGNAME,": Relocation failed.",13,10
  3592 0000101D 44656275676761626C-
  3592 00001026 65206C446562756758-
  3592 0000102F 3A2052656C6F636174-
  3592 00001038 696F6E206661696C65-
  3592 00001041 642E0D0A00         
  3593                                  .init_relocate_failure:
  3594 00001046 436F6E64746E6C2E20-     	asciz _PROGNAME,": Second init relocation failed, out of memory.",13,10
  3594 0000104F 44656275676761626C-
  3594 00001058 65206C446562756758-
  3594 00001061 3A205365636F6E6420-
  3594 0000106A 696E69742072656C6F-
  3594 00001073 636174696F6E206661-
  3594 0000107C 696C65642C206F7574-
  3594 00001085 206F66206D656D6F72-
  3594 0000108E 792E0D0A00         
  3595                                  .early_reloc_fail:
  3596 00001093 436F6E64746E6C2E20-     	asciz _PROGNAME,": Failed to relocate, internal error!",13,10
  3596 0000109C 44656275676761626C-
  3596 000010A5 65206C446562756758-
  3596 000010AE 3A204661696C656420-
  3596 000010B7 746F2072656C6F6361-
  3596 000010C0 74652C20696E746572-
  3596 000010C9 6E616C206572726F72-
  3596 000010D2 210D0A00           
  3597                                  %if _DEVICE
  3598                                  .dos_below_5:
  3599 000010D6 204E6F74653A20444F-     	asciz " Note: DOS must be at least version 5.",13,10
  3599 000010DF 53206D757374206265-
  3599 000010E8 206174206C65617374-
  3599 000010F1 2076657273696F6E20-
  3599 000010FA 352E0D0A00         
  3600                                  .device_end_escaped:
  3601 000010FF 436F6E64746E6C2E20-     	asciz _PROGNAME,": Error, got escaped command line end!",13,10
  3601 00001108 44656275676761626C-
  3601 00001111 65206C446562756758-
  3601 0000111A 3A204572726F722C20-
  3601 00001123 676F74206573636170-
  3601 0000112C 656420636F6D6D616E-
  3601 00001135 64206C696E6520656E-
  3601 0000113E 64210D0A00         
  3602                                  .device_end_truncate:
  3603 00001143 436F6E64746E6C2E20-     	asciz _PROGNAME,": Error, truncating too long command line!",13,10
  3603 0000114C 44656275676761626C-
  3603 00001155 65206C446562756758-
  3603 0000115E 3A204572726F722C20-
  3603 00001167 7472756E636174696E-
  3603 00001170 6720746F6F206C6F6E-
  3603 00001179 6720636F6D6D616E64-
  3603 00001182 206C696E65210D0A00 
  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 0000118B 436F6E64746E6C2E20-     	asciz _PROGNAME,": Error, no alternative video adapter detected!",13,10
  3612 00001194 44656275676761626C-
  3612 0000119D 65206C446562756758-
  3612 000011A6 3A204572726F722C20-
  3612 000011AF 6E6F20616C7465726E-
  3612 000011B8 617469766520766964-
  3612 000011C1 656F20616461707465-
  3612 000011CA 722064657465637465-
  3612 000011D3 64210D0A00         
  3613                                  %endif
  3614                                  	align 2, db 0
  3615                                  .help.defaultfilename:
  3616 000011D8 43444542554758          	db _FILENAME
  3617                                  .help.defaultfilename.length equ $ - .help.defaultfilename
  3618                                  
  3619 000011DF 00                      	align 2, db 0
  3620                                  .help.1:
  3621 000011E0 436F6E64746E6C2E20-     	fill_at_least 80, 0, asciz _PROGNAME,_VERSION,", debugger.",13,10
  3621 000011E9 44656275676761626C-
  3621 000011F2 65206C446562756758-
  3621 000011FB 2028323032362D3035-
  3621 00001204 2D3237292C20646562-
  3621 0000120D 75676765722E0D0A00-
  3621 00001216 00<rep 1Ah>        
  3622                                  
  3623                                  .help.1a:
  3624 00001230 0D0A                    	db 13,10
  3625 00001232 55736167653A20          	db "Usage: "
  3626 00001239 00                      	asciz
  3627                                  .help.2:
  3628 0000123A 5B2E434F4D5D205B2F-     	db "[.COM] [/C=commands] [[drive:][path]progname.ext [parameters]]",13,10
  3628 00001243 433D636F6D6D616E64-
  3628 0000124C 735D205B5B64726976-
  3628 00001255 653A5D5B706174685D-
  3628 0000125E 70726F676E616D652E-
  3628 00001267 657874205B70617261-
  3628 00001270 6D65746572735D5D0D-
  3628 00001279 0A                 
  3629 0000127A 0D0A                    	db 13,10
  3630 0000127C 20202F433D636F6D6D-     	db "  /C=commands",9,9,	"semicolon-separated list of commands (quote spaces)",13,10
  3630 00001285 616E6473090973656D-
  3630 0000128E 69636F6C6F6E2D7365-
  3630 00001297 70617261746564206C-
  3630 000012A0 697374206F6620636F-
  3630 000012A9 6D6D616E6473202871-
  3630 000012B2 756F74652073706163-
  3630 000012BB 6573290D0A         
  3631                                  %if _CONFIG
  3632 000012C0 20202F494E09090964-     	db "  /IN",9,9,9,	"discard command line buffer, do not run config",13,10
  3632 000012C9 69736361726420636F-
  3632 000012D2 6D6D616E64206C696E-
  3632 000012DB 65206275666665722C-
  3632 000012E4 20646F206E6F742072-
  3632 000012ED 756E20636F6E666967-
  3632 000012F6 0D0A               
  3633                                  %endif
  3634                                  %if _AUXBUFFSIZE != _AUXBUFFMAXSIZE
  3635 000012F8 20202F413D4D415809-     	db "  /A=MAX",9,9,	"expand auxiliary buffer to maximum, #"
  3635 00001301 09657870616E642061-
  3635 0000130A 7578696C6961727920-
  3635 00001313 62756666657220746F-
  3635 0000131C 206D6178696D756D2C-
  3635 00001325 2023               
  3636 00001327 32345F353736            		_autodigits _AUXBUFFMAXSIZE, 1, 1
  3637 0000132D 2042797465730D0A        		db " Bytes",13,10
  3638 00001335 20202F413D4D494E09-     	db "  /A=MIN",9,9,	"restrict auxiliary buffer to minimum, #"
  3638 0000133E 097265737472696374-
  3638 00001347 20617578696C696172-
  3638 00001350 792062756666657220-
  3638 00001359 746F206D696E696D75-
  3638 00001362 6D2C2023           
  3639 00001366 385F323038              		_autodigits _AUXBUFFSIZE, 1, 1
  3640 0000136B 2042797465730D0A        		db " Bytes",13,10
  3641 00001373 20202F413D6E756D62-     	db "  /A=number",9,9,	"set auxiliary buffer size to hex number of bytes",13,10
  3641 0000137C 657209097365742061-
  3641 00001385 7578696C6961727920-
  3641 0000138E 627566666572207369-
  3641 00001397 7A6520746F20686578-
  3641 000013A0 206E756D626572206F-
  3641 000013A9 662062797465730D0A 
  3642 000013B2 20202F413D236E756D-     	db "  /A=#number",9,9,	"set auxiliary buffer size to decimal number of bytes",13,10
  3642 000013BB 626572090973657420-
  3642 000013C4 617578696C69617279-
  3642 000013CD 206275666665722073-
  3642 000013D6 697A6520746F206465-
  3642 000013DF 63696D616C206E756D-
  3642 000013E8 626572206F66206279-
  3642 000013F1 7465730D0A         
  3643 000013F6 20202F41090909616C-     	db "  /A",9,9,9,	"alias for /A=MAX",13,10
  3643 000013FF 69617320666F72202F-
  3643 00001408 413D4D41580D0A     
  3644                                  %endif
  3645                                  %if _EXTENSIONS
  3646 0000140F 20202F583D5B4D4158-     	db "  /X=[MAX|MIN|number]",9,	"change ELD code buffer size, 0 to #65_520 Bytes",13,10
  3646 00001418 7C4D494E7C6E756D62-
  3646 00001421 65725D096368616E67-
  3646 0000142A 6520454C4420636F64-
  3646 00001433 652062756666657220-
  3646 0000143C 73697A652C20302074-
  3646 00001445 6F202336355F353230-
  3646 0000144E 2042797465730D0A   
  3647 00001456 20202F593D5B4D4158-     	db "  /Y=[MAX|MIN|number]",9,	"change ELD data buffer size, 0 to #"
  3647 0000145F 7C4D494E7C6E756D62-
  3647 00001468 65725D096368616E67-
  3647 00001471 6520454C4420646174-
  3647 0000147A 612062756666657220-
  3647 00001483 73697A652C20302074-
  3647 0000148C 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 0000148F [F0FF]                  	dw  relocatedzero + 0FFF0h
  3656 00001491 00<rep 4h>              	times 4 db 0
  3657 00001495 2042797465730D0A        	db " Bytes",13,10
  3658                                   %endif
  3659                                  %endif
  3660                                  %if _HISTORY_SEPARATE_FIXED && _HISTORY
  3661 0000149D 20202F483D5B4D4158-     	db "  /H=[MAX|MIN|number]",9,	"change history buffer size, #260 to #65_520 Bytes",13,10
  3661 000014A6 7C4D494E7C6E756D62-
  3661 000014AF 65725D096368616E67-
  3661 000014B8 6520686973746F7279-
  3661 000014C1 206275666665722073-
  3661 000014CA 697A652C2023323630-
  3661 000014D3 20746F202336355F35-
  3661 000014DC 32302042797465730D-
  3661 000014E5 0A                 
  3662                                  %endif
  3663 000014E6 20202F420909097275-     	db "  /B",9,9,9,	"run a breakpoint within initialisation",13,10
  3663 000014EF 6E206120627265616B-
  3663 000014F8 706F696E7420776974-
  3663 00001501 68696E20696E697469-
  3663 0000150A 616C69736174696F6E-
  3663 00001513 0D0A               
  3664 00001515 20202F505B2B7C2D5D-     	db "  /P[+|-]",9,9,	"append ext to initial filename and search path",13,10
  3664 0000151E 0909617070656E6420-
  3664 00001527 65787420746F20696E-
  3664 00001530 697469616C2066696C-
  3664 00001539 656E616D6520616E64-
  3664 00001542 207365617263682070-
  3664 0000154B 6174680D0A         
  3665 00001550 20202F465B2B7C2D5D-     	db "  /F[+|-]",9,9,	"always treat executable file as a flat binary",13,10
  3665 00001559 0909616C7761797320-
  3665 00001562 747265617420657865-
  3665 0000156B 63757461626C652066-
  3665 00001574 696C65206173206120-
  3665 0000157D 666C61742062696E61-
  3665 00001586 72790D0A           
  3666 0000158A 20202F455B2B7C2D5D-     	db "  /E[+|-]",9,9,	"for flat binaries set up Stack Segment != PSP",13,10
  3666 00001593 0909666F7220666C61-
  3666 0000159C 742062696E61726965-
  3666 000015A5 732073657420757020-
  3666 000015AE 537461636B20536567-
  3666 000015B7 6D656E7420213D2050-
  3666 000015C0 53500D0A           
  3667                                  %if _VXCHG
  3668 000015C4 20202F565B2B7C2D5D-     	db "  /V[+|-]",9,9,	"enable/disable video screen swapping",13,10
  3668 000015CD 0909656E61626C652F-
  3668 000015D6 64697361626C652076-
  3668 000015DF 6964656F2073637265-
  3668 000015E8 656E20737761707069-
  3668 000015F1 6E670D0A           
  3669                                  %endif
  3670                                  %if _DEBUG && _DEBUG_COND
  3671 000015F5 20202F445B2B7C2D5D-     	db "  /D[+|-]",9,9,	"enable/disable debuggable mode",13,10
  3671 000015FE 0909656E61626C652F-
  3671 00001607 64697361626C652064-
  3671 00001610 656275676761626C65-
  3671 00001619 206D6F64650D0A     
  3672                                  %endif
  3673                                  %if _ALTVID
  3674 00001620 20202F325B2B7C2D5D-     	db "  /2[+|-]",9,9,	"enable/disable use alternate video adapter for output",13,10
  3674 00001629 0909656E61626C652F-
  3674 00001632 64697361626C652075-
  3674 0000163B 736520616C7465726E-
  3674 00001644 61746520766964656F-
  3674 0000164D 206164617074657220-
  3674 00001656 666F72206F75747075-
  3674 0000165F 740D0A             
  3675                                  %endif
  3676 00001662 202070726F676E616D-     	db "  progname.ext",9,9,"(executable) file to debug or examine",13,10
  3676 0000166B 652E65787409092865-
  3676 00001674 786563757461626C65-
  3676 0000167D 292066696C6520746F-
  3676 00001686 206465627567206F72-
  3676 0000168F 206578616D696E650D-
  3676 00001698 0A                 
  3677 00001699 2020706172616D6574-     	db "  parameters",9,9,	"parameters given to program",13,10
  3677 000016A2 657273090970617261-
  3677 000016AB 6D6574657273206769-
  3677 000016B4 76656E20746F207072-
  3677 000016BD 6F6772616D0D0A     
  3678 000016C4 0D0A                    	db 13,10
  3679 000016C6 466F722061206C6973-     	db "For a list of debugging commands, run "
  3679 000016CF 74206F662064656275-
  3679 000016D8 6767696E6720636F6D-
  3679 000016E1 6D616E64732C207275-
  3679 000016EA 6E20               
  3680 000016EC 00                      	asciz
  3681                                  .help.3:
  3682 000016ED 20616E642074797065-     	db " and type ? at the prompt.",13,10
  3682 000016F6 203F20617420746865-
  3682 000016FF 2070726F6D70742E0D-
  3682 00001708 0A                 
  3683 00001709 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                                  	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 0000170A 546869732068656C70- <1> 	db MESSAGE
    23 00001713 207061676520697320- <1>
    23 0000171C 6F6E6C792061766169- <1>
    23 00001725 6C61626C6520696E20- <1>
    23 0000172E 626F6F74206C6F6164- <1>
    23 00001737 6564206D6F64652E0D- <1>
    23 00001740 0A                  <1>
    24                              <1> %else
    25                              <1> 	_strlen MESSAGE,0
    26                              <1> %endif
  3700                                  %undef MESSAGE_INLINE
  3701 00001741 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 00001742 496E76616C69642073-     	db "Invalid switch - "
  3714 0000174B 7769746368202D20   
  3715                                  .invalidswitch_a:
  3716 00001753 780D0A00                	asciz "x",13,10
  3717                                  .switch_x_error:
  3718 00001757 537769746368202F        	db "Switch /"
  3719                                  .switch_x_error_a:
  3720 0000175F 7820696E76616C6964-     	asciz "x invalid content",13,10
  3720 00001768 20636F6E74656E740D-
  3720 00001771 0A00               
  3721                                  %endif
  3722                                  %if _CONFIG
  3723                                   %if _APPLICATION
  3724 00001773 00                      	align 2, db 0
  3725                                  .default_cmdline.app:
  3726                                  	db _APPSCRIPTPREFIX
  3727 00001774 406966206578697374-     	db "@if exists y ::CONFIG::",_APPSCRIPTNAME," :",_APPSCRIPTLABEL
  3727 0000177D 732079203A3A434F4E-
  3727 00001786 4649473A3A4C434445-
  3727 0000178F 4255472E534C44203A-
  3727 00001798 6170706C6963617469-
  3727 000017A1 6F6E73746172747570 
  3728 000017AA 207468656E2079203A-     	db " then y ::CONFIG::",_APPSCRIPTNAME," :",_APPSCRIPTLABEL
  3728 000017B3 3A434F4E4649473A3A-
  3728 000017BC 4C4344454255472E53-
  3728 000017C5 4C44203A6170706C69-
  3728 000017CE 636174696F6E737461-
  3728 000017D7 72747570           
  3729 000017DB 0D                      	db 13
  3730                                  .default_cmdline.app.length equ $ - .default_cmdline.app
  3731 000017DC 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 000017DD 00                      	align 2, db 0
  3738                                  .default_cmdline.dev:
  3739                                  	db _DEVSCRIPTPREFIX
  3740 000017DE 406966206578697374-     	db "@if exists y ::CONFIG::",_DEVSCRIPTNAME," :",_DEVSCRIPTLABEL
  3740 000017E7 732079203A3A434F4E-
  3740 000017F0 4649473A3A4C434445-
  3740 000017F9 4255472E534C44203A-
  3740 00001802 646576696365737461-
  3740 0000180B 72747570           
  3741 0000180F 207468656E2079203A-     	db " then y ::CONFIG::",_DEVSCRIPTNAME," :",_DEVSCRIPTLABEL
  3741 00001818 3A434F4E4649473A3A-
  3741 00001821 4C4344454255472E53-
  3741 0000182A 4C44203A6465766963-
  3741 00001833 6573746172747570   
  3742 0000183B 0D                      	db 13
  3743                                  .default_cmdline.dev.length equ $ - .default_cmdline.dev
  3744 0000183C 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 0000183D 00                      	align 2, db 0
  3752                                  .default_cmdline.boot:
  3753                                  	db _BOOTSCRIPTPREFIX
  3754 0000183E 406966206578697374-     	db "@if exists y ldp/",_BOOTSCRIPTNAME," :",_BOOTSCRIPTLABEL
  3754 00001847 732079206C64702F4C-
  3754 00001850 4344454255472E534C-
  3754 00001859 44203A626F6F747374-
  3754 00001862 6172747570         
  3755 00001867 207468656E2079206C-     	db " then y ldp/",_BOOTSCRIPTNAME," :",_BOOTSCRIPTLABEL
  3755 00001870 64702F4C4344454255-
  3755 00001879 472E534C44203A626F-
  3755 00001882 6F7473746172747570 
  3756 0000188B 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 0000188C 6C64702F                	db "ldp/"
  3765                                  %endif
  3766                                  .rpl_detected:
  3767 00001890 52504C206465746563-     	asciz "RPL detected! Currently unsupported.",13,10
  3767 00001899 746564212043757272-
  3767 000018A2 656E746C7920756E73-
  3767 000018AB 7570706F727465642E-
  3767 000018B4 0D0A00             
  3768                                  .mismatch_detected:
  3769 000018B7 4D69736D6174636820-     	asciz "Mismatch in memory size detected! Internal error!",13,10
  3769 000018C0 696E206D656D6F7279-
  3769 000018C9 2073697A6520646574-
  3769 000018D2 65637465642120496E-
  3769 000018DB 7465726E616C206572-
  3769 000018E4 726F72210D0A00     
  3770                                  .boot_ebda_unexpected:
  3771 000018EB 454244412061742075-     	asciz "EBDA at unexpected position.",13,10
  3771 000018F4 6E6578706563746564-
  3771 000018FD 20706F736974696F6E-
  3771 00001906 2E0D0A00           
  3772                                  .boot_error_out_of_memory:
  3773 0000190A 4F7574206F66206D65-     	asciz "Out of memory!",13,10
  3773 00001913 6D6F7279210D0A00   
  3774                                  .boot_error_internal:
  3775 0000191B 496E7465726E616C20-     	asciz "Internal error while relocating load image!",13,10
  3775 00001924 6572726F7220776869-
  3775 0000192D 6C652072656C6F6361-
  3775 00001936 74696E67206C6F6164-
  3775 0000193F 20696D616765210D0A-
  3775 00001948 00                 
  3776                                  .booterror:
  3777 00001949 0D0A436F6E64746E6C-     	asciz 13,10,_PROGNAME," boot error. Press any key to reboot.",13,10
  3777 00001952 2E2044656275676761-
  3777 0000195B 626C65206C44656275-
  3777 00001964 675820626F6F742065-
  3777 0000196D 72726F722E20507265-
  3777 00001976 737320616E79206B65-
  3777 0000197F 7920746F207265626F-
  3777 00001988 6F742E0D0A00       
  3778                                  .bootwarn:
  3779 0000198E 0D0A436F6E64746E6C-     	asciz 13,10,_PROGNAME," warning: "
  3779 00001997 2E2044656275676761-
  3779 000019A0 626C65206C44656275-
  3779 000019A9 6758207761726E696E-
  3779 000019B2 673A2000           
  3780                                  .boot_warn_no_loader:
  3781 000019B6 457870656374656420-     	asciz "Expected loader not found!",13,10
  3781 000019BF 6C6F61646572206E6F-
  3781 000019C8 7420666F756E64210D-
  3781 000019D1 0A00               
  3782                                  .boot_warn_invalid_loader:
  3783 000019D3 457870656374656420-     	asciz "Expected loader is invalid!",13,10
  3783 000019DC 6C6F61646572206973-
  3783 000019E5 20696E76616C696421-
  3783 000019EE 0D0A00             
  3784                                  .boot_warn_lazy_loader:
  3785 000019F1 457870656374656420-     	asciz "Expected loader doesn't have a query function!",13,10
  3785 000019FA 6C6F6164657220646F-
  3785 00001A03 65736E277420686176-
  3785 00001A0C 652061207175657279-
  3785 00001A15 2066756E6374696F6E-
  3785 00001A1E 210D0A00           
  3786                                  .boot_warn_loader_no_reloc:
  3787 00001A22 4C6F6164657220646F-     	asciz "Loader doesn't provide a relocation function!",13,10
  3787 00001A2B 65736E27742070726F-
  3787 00001A34 766964652061207265-
  3787 00001A3D 6C6F636174696F6E20-
  3787 00001A46 66756E6374696F6E21-
  3787 00001A4F 0D0A00             
  3788                                  %endif
  3789                                  %if _DOSEMU
  3790 00001A52 30322F32352F3933        .dosemudate:	db "02/25/93"
  3791                                  %endif
  3792                                  %if _VDD && (_APPLICATION || _DEVICE)
  3793 00001A5A 44454258585644442E-     .vdd:		asciz "DEBXXVDD.DLL"
  3793 00001A63 444C4C00           
  3794 00001A67 446973706174636800      .dispatch:	asciz "Dispatch"
  3795 00001A70 496E697400              .init:		asciz "Init"
  3796 00001A75 4D4F555345202020        .mouse:		db "MOUSE",32,32,32		; Looks like a device name
  3797 00001A7D 416E64792057617473-     .andy:		db "Andy Watson"		; I don't know him and why he's inside the NTVDM mouse driver
  3797 00001A86 6F6E               
  3798                                  	endarea .andy
  3799 00001A88 57696E646F7773204E-     .ntdos:		db "Windows NT MS-DOS subsystem Mouse Driver"	; Int33.004D mouse driver copyright string (not ASCIZ)
  3799 00001A91 54204D532D444F5320-
  3799 00001A9A 73756273797374656D-
  3799 00001AA3 204D6F757365204472-
  3799 00001AAC 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 00001AB0 B80258                  		mov ax, 5802h			; Get UMB link state
  3809 00001AB3 CD21                    		int 21h
  3810 00001AB5 30E4                    		xor ah, ah
  3811 00001AB7 50                      		push ax				; Save UMB link state
  3812 00001AB8 B80358                  		mov ax, 5803h			; Set UMB link state:
  3813 00001ABB BB0100                  		mov bx, 1			;  Add UMBs to memory chain
  3814 00001ABE CD21                    		int 21h
  3815 00001AC0 B452                    		mov ah, 52h
  3816 00001AC2 BBFFFF                  		mov bx, -1
  3817 00001AC5 CD21                    		int 21h				; Get list of lists
  3818 00001AC7 43                      		inc bx				; 0FFFFh ?
  3819 00001AC8 7503E98E00              		jz .notnt			; invalid -->
  3820 00001ACD 83FB02                  		cmp bx, 2			; would access word at 0FFFFh ?
  3821 00001AD0 7503E98600              		je .notnt			; yes, invalid -->
  3822 00001AD5 268B47FD                		mov ax, word [es:bx-3]		; First MCB
  3823 00001AD9 0E                      		push cs
  3824 00001ADA 07                      		pop es				; reset es
  3825                                  .loop:
  3826 00001ADB 8ED8                    		mov ds, ax			; ds = MCB
  3827 00001ADD 40                      		inc ax				; Now segment of memory block itself
  3828 00001ADE 31D2                    		xor dx, dx
  3829 00001AE0 31DB                    		xor bx, bx
  3830 00001AE2 803F5A                  		cmp byte [bx], 'Z'		; End of MCB chain?
  3831 00001AE5 7503                    		jne .notlast
  3832 00001AE7 42                      		inc dx
  3833 00001AE8 EB05                    		jmp short .notchain
  3834                                   .notlast:
  3835 00001AEA 803F4D                  		cmp byte [bx], 'M'		; Valid MCB chain?
  3836 00001AED 756C                    		jne .error
  3837                                   .notchain:
  3838 00001AEF 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 00001AF2 837F0108                		cmp word [bx+1], 8		; MCB owner DOS?
  3844 00001AF6 755D                    		jne .notfound_1
  3845 00001AF8 817F085344              		cmp word [bx+8], "SD"		; MCB name "SD"?
  3846 00001AFD 7556                    		jne .notfound_1
  3847                                  .loopsub:
  3848 00001AFF 8ED8                    		mov ds, ax			; SD sub-segment inside memory block
  3849 00001B01 40                      		inc ax
  3850 00001B02 49                      		dec cx
  3851 00001B03 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 00001B06 39E9                    		cmp cx, bp
  3857 00001B08 724B                    		jb .notfound_1			; Goes beyond memory block, invalid -->
  3858 00001B0A 803F51                  		cmp byte [bx], 'Q'		; NTVDM type 51h sub-segment ?
  3859 00001B0D 753C                    		jne .notfound_2			; no -->
  3860 00001B0F BE0800                  		mov si, 8			; Offset of device name (if SD device driver sub-segment)
  3861 00001B12 BF[751A]                		mov di, imsg.mouse
  3862 00001B15 51                      		push cx
  3863 00001B16 89F1                    		mov cx, si			; length of name
  3864 00001B18 F3A6                    		repe cmpsb			; blank-padded device name "MOUSE" ?
  3865 00001B1A 59                      		pop cx
  3866 00001B1B 752E                    		jne .notfound_2			;  Device name doesn't match, try next SD sub-segment
  3867 00001B1D 8CD8                    		mov ax, ds
  3868 00001B1F 40                      		inc ax
  3869 00001B20 8ED8                    		mov ds, ax			; Segment of SD sub-segment
  3870                                  				; ds = current SD sub-segment
  3871 00001B22 89E8                    		mov ax, bp			; Leave paragraph value in bp
  3872 00001B24 A900F0                  		test ax, 0F000h			; Would *16 cause an overflow?
  3873 00001B27 7520                    		jnz .notfound_3			;  Then too large -->
  3874 00001B29 51                      		push cx
  3875 00001B2A B104                    		mov cl, 4
  3876 00001B2C D3E0                    		shl ax, cl			; *16
  3877 00001B2E 59                      		pop cx
  3878                                  				; ax = current SD sub-segment size in byte
  3879                                  .andy:
  3880 00001B2F BF[7D1A]                		mov di, imsg.andy
  3881 00001B32 51                      		push cx
  3882 00001B33 B90B00                  		mov cx, imsg.andy_size
  3883 00001B36 E82E00                  		call findstring			; String "Andy Watson"?
  3884 00001B39 59                      		pop cx
  3885 00001B3A 720D                    		jc .notfound_3
  3886                                  .ntdos:
  3887 00001B3C BF[881A]                		mov di, imsg.ntdos
  3888 00001B3F 51                      		push cx
  3889 00001B40 B92800                  		mov cx, imsg.ntdos_size
  3890 00001B43 E82100                  		call findstring			; String "Windows NT MS-DOS subsystem Mouse Driver"?
  3891 00001B46 59                      		pop cx
  3892 00001B47 7313                    		jnc .found			; (NC)
  3893                                  .notfound_3:
  3894 00001B49 8CD8                    		mov ax, ds
  3895                                  .notfound_2:
  3896 00001B4B 39E9                    		cmp cx, bp
  3897 00001B4D 7406                    		je .notfound_1			; End of SD memory block, get next MCB
  3898 00001B4F 01E8                    		add ax, bp			; Address next SD sub-MCB
  3899 00001B51 29E9                    		sub cx, bp
  3900 00001B53 EBAA                    		jmp short .loopsub		; Try next SD sub-segment
  3901                                  .notfound_1:
  3902 00001B55 01C8                    		add ax, cx			; Address next MCB
  3903 00001B57 85D2                    		test dx, dx			; Non-zero if 'Z' MCB
  3904 00001B59 7480                    		jz .loop			; If not at end of MCB chain, try next
  3905                                  		; jmp short .notnt		;  Otherwise, not found
  3906                                   .error:
  3907                                   .notnt:
  3908 00001B5B F9                      		stc
  3909                                  .found:
  3910 00001B5C 0E                      		push cs
  3911 00001B5D 1F                      		pop ds				; restore ds
  3912                                  
  3913 00001B5E 5B                      		pop bx				; saved UMB link state
  3914 00001B5F B80358                  		mov ax, 5803h
  3915 00001B62 9C                      		pushf
  3916 00001B63 CD21                    		int 21h				; Set UMB link state
  3917 00001B65 9D                      		popf
  3918 00001B66 C3                      		retn
  3919                                  
  3920                                  findstring:
  3921 00001B67 31F6                    		xor si, si
  3922                                  .loop:
  3923 00001B69 56                      		push si
  3924 00001B6A 01CE                    		add si, cx
  3925 00001B6C 7203                    		jc .notfound_c
  3926 00001B6E 4E                      		dec si				; The largest offset we need for this compare
  3927 00001B6F 39F0                    		cmp ax, si
  3928                                   .notfound_c:
  3929 00001B71 5E                      		pop si
  3930 00001B72 720D                    		jb .return			; Not found if at top of memory block -->
  3931 00001B74 57                      		push di
  3932 00001B75 56                      		push si
  3933 00001B76 51                      		push cx
  3934 00001B77 F3A6                    		repe cmpsb			; String somewhere inside program?
  3935 00001B79 59                      		pop cx
  3936 00001B7A 5E                      		pop si
  3937 00001B7B 5F                      		pop di
  3938 00001B7C 7403                    		je .return			;  Yes, proceed --> (if ZR, NC)
  3939 00001B7E 46                      		inc si				; Increase pointer by one
  3940 00001B7F EBE8                    		jmp short .loop			;  Try next address
  3941                                  .return:
  3942 00001B81 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 00001B82 51                      	push cx
  3956 00001B83 1E                      	push ds
  3957 00001B84 56                      	push si
  3958 00001B85 06                      	push es
  3959 00001B86 57                      	push di
  3960                                  
  3961 00001B87 39D0                    	cmp ax, dx		; source above destination ?
  3962 00001B89 770A                    	ja .up			; yes, move up (forwards) -->
  3963 00001B8B 747B                    	je .return		; same, no need to move -->
  3964 00001B8D 50                      	push ax
  3965 00001B8E 01C8                    	add ax, cx		; (expected not to carry)
  3966 00001B90 39D0                    	cmp ax, dx		; end of source is above destination ?
  3967 00001B92 58                      	pop ax
  3968 00001B93 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 00001B95 50                      	push ax
  3974 00001B96 52                      	push dx
  3975                                  .uploop:
  3976 00001B97 8ED8                    	mov ds, ax
  3977 00001B99 8EC2                    	mov es, dx
  3978 00001B9B 31FF                    	xor di, di
  3979 00001B9D 31F6                    	xor si, si		; -> start of segment
  3980 00001B9F 81E90010                	sub cx, 1000h		; 64 KiB left ?
  3981 00001BA3 7610                    	jbe .uplast		; no -->
  3982 00001BA5 51                      	push cx
  3983 00001BA6 B90080                  	mov cx, 10000h /2
  3984 00001BA9 F3A5                    	rep movsw		; move 64 KiB
  3985 00001BAB 59                      	pop cx
  3986 00001BAC 050010                  	add ax, 1000h
  3987 00001BAF 81C20010                	add dx, 1000h		; -> next segment
  3988 00001BB3 EBE2                    	jmp short .uploop	; proceed for more -->
  3989                                  .uplast:
  3990 00001BB5 81C10010                	add cx, 1000h		; restore counter
  3991 00001BB9 D1E1                    	shl cx, 1
  3992 00001BBB D1E1                    	shl cx, 1
  3993 00001BBD D1E1                    	shl cx, 1		; *8, paragraphs to words
  3994 00001BBF F3A5                    	rep movsw		; move last part
  3995 00001BC1 5A                      	pop dx
  3996 00001BC2 58                      	pop ax
  3997 00001BC3 EB43                    	jmp short .return
  3998                                  
  3999                                  .down:
  4000 00001BC5 FD                      	std			; _AMD_ERRATUM_109_WORKAROUND as below
  4001                                  .dnloop:
  4002 00001BC6 81E90010                	sub cx, 1000h		; 64 KiB left ?
  4003 00001BCA 761A                    	jbe .dnlast		; no -->
  4004 00001BCC 50                      	push ax
  4005 00001BCD 52                      	push dx
  4006 00001BCE 01C8                    	add ax, cx
  4007 00001BD0 01CA                    	add dx, cx
  4008 00001BD2 8ED8                    	mov ds, ax		; -> 64 KiB not yet moved
  4009 00001BD4 8EC2                    	mov es, dx
  4010 00001BD6 5A                      	pop dx
  4011 00001BD7 58                      	pop ax
  4012 00001BD8 BFFEFF                  	mov di, -2
  4013 00001BDB 89FE                    	mov si, di		; moved from last word down
  4014 00001BDD 51                      	push cx
  4015 00001BDE B90080                  	mov cx, 10000h /2
  4016 00001BE1 F3A5                    	rep movsw		; move 64 KiB
  4017 00001BE3 59                      	pop cx
  4018 00001BE4 EBE0                    	jmp short .dnloop	; proceed for more -->
  4019                                  .dnlast:
  4020 00001BE6 81C10010                	add cx, 1000h		; restore counter
  4021 00001BEA D1E1                    	shl cx, 1
  4022 00001BEC D1E1                    	shl cx, 1
  4023 00001BEE D1E1                    	shl cx, 1		; *8, paragraphs to words
  4024 00001BF0 89CF                    	mov di, cx
  4025 00001BF2 4F                      	dec di
  4026 00001BF3 D1E7                    	shl di, 1		; words to offset, -> last word
  4027 00001BF5 89FE                    	mov si, di
  4028 00001BF7 8ED8                    	mov ds, ax
  4029 00001BF9 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 00001BFB E308                    	jcxz @FF
  4070 00001BFD 83F914                  	cmp cx, 20
  4071 00001C00 7703                    	ja @FF
  4072                                  @@:
  4073 00001C02 A5                      	movsw
  4074 00001C03 E2FD                    	loop @B
  4075                                  @@:
  4076                                  %endif
  4077 00001C05 F3A5                    	rep movsw		; move first part
  4078 00001C07 FC                      	cld
  4079                                  .return:
  4080 00001C08 5F                      	pop di
  4081 00001C09 07                      	pop es
  4082 00001C0A 5E                      	pop si
  4083 00001C0B 1F                      	pop ds
  4084 00001C0C 59                      	pop cx
  4085 00001C0D C3                      	retn
  4086                                  
  4087                                  
  4088                                  %if _BOOTLDR
  4089                                  		; only called for boot-loaded mode
  4090                                  init_getc_bootldr:
  4091 00001C0E 31C0                    	xor ax, ax
  4092 00001C10 CD16                    	int 16h
  4093 00001C12 C3                      	retn
  4094                                  %endif
  4095                                  
  4096                                  init_putsz_cs:
  4097 00001C13 50                      	push ax
  4098 00001C14 53                      	push bx
  4099 00001C15 51                      	push cx
  4100 00001C16 52                      	push dx
  4101 00001C17 1E                      	push ds
  4102 00001C18 06                      	push es
  4103 00001C19 57                      	push di
  4104 00001C1A 0E                      	 push cs
  4105 00001C1B 07                      	 pop es
  4106 00001C1C 0E                      	 push cs
  4107 00001C1D 1F                      	 pop ds
  4108 00001C1E 89D7                    	mov di, dx			; es:di-> string
  4109 00001C20 30C0                    	xor al, al
  4110 00001C22 B9FFFF                  	mov cx, -1
  4111 00001C25 F2AE                    	repne scasb			; search zero
  4112 00001C27 F7D1                    	not cx
  4113 00001C29 49                      	dec cx				; cx = length of message
  4114 00001C2A 5F                      	pop di
  4115 00001C2B E82900                  	call init_puts_ds
  4116 00001C2E 07                      	pop es
  4117 00001C2F 1F                      	pop ds
  4118 00001C30 5A                      	pop dx
  4119 00001C31 59                      	pop cx
  4120 00001C32 5B                      	pop bx
  4121 00001C33 58                      	pop ax
  4122 00001C34 C3                      	retn
  4123                                  
  4124                                  %if _BOOTLDR
  4125                                  init_putsz_cs_bootldr:
  4126 00001C35 50                      	push ax
  4127 00001C36 53                      	push bx
  4128 00001C37 51                      	push cx
  4129 00001C38 52                      	push dx
  4130 00001C39 1E                      	push ds
  4131 00001C3A 06                      	push es
  4132 00001C3B 57                      	push di
  4133 00001C3C 0E                      	 push cs
  4134 00001C3D 07                      	 pop es
  4135 00001C3E 0E                      	 push cs
  4136 00001C3F 1F                      	 pop ds
  4137 00001C40 89D7                    	mov di, dx			; es:di-> string
  4138 00001C42 30C0                    	xor al, al
  4139 00001C44 B9FFFF                  	mov cx, -1
  4140 00001C47 F2AE                    	repne scasb			; search zero
  4141 00001C49 F7D1                    	not cx
  4142 00001C4B 49                      	dec cx				; cx = length of message
  4143 00001C4C 5F                      	pop di
  4144 00001C4D E80F00                  	call init_puts_ds_bootldr
  4145 00001C50 07                      	pop es
  4146 00001C51 1F                      	pop ds
  4147 00001C52 5A                      	pop dx
  4148 00001C53 59                      	pop cx
  4149 00001C54 5B                      	pop bx
  4150 00001C55 58                      	pop ax
  4151 00001C56 C3                      	retn
  4152                                  %endif
  4153                                  
  4154                                  init_puts_ds:
  4155                                  %if _BOOTLDR
  4156                                   %if _APPLICATION || _DEVICE
  4157 00001C57 36F606[0100]40          	testopt [ss:internalflags], nodosloaded
  4158 00001C5D 7413                    	jz @F
  4159                                   %endif
  4160                                  
  4161                                  init_puts_ds_bootldr:
  4162 00001C5F 56                      	push si
  4163 00001C60 55                      	push bp
  4164 00001C61 89D6                    	mov si, dx
  4165 00001C63 E30A                    	jcxz .return
  4166                                  .loop:
  4167 00001C65 AC                      	lodsb
  4168 00001C66 BB0700                  	mov bx, 0007
  4169 00001C69 B40E                    	mov ah, 0Eh
  4170 00001C6B CD10                    	int 10h
  4171 00001C6D E2F6                    	loop .loop
  4172                                  .return:
  4173 00001C6F 5D                      	pop bp
  4174 00001C70 5E                      	pop si
  4175 00001C71 C3                      	retn
  4176                                  
  4177                                  @@:
  4178                                  %endif
  4179                                  %if _APPLICATION || _DEVICE
  4180 00001C72 BB0100                  	mov bx, 1			; standard output
  4181 00001C75 B440                    	mov ah, 40h			; write to file
  4182 00001C77 E302                    	jcxz @F
  4183 00001C79 CD21                    	int 21h
  4184                                  @@:
  4185 00001C7B 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 00001C7C 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 00001C7D C706[0000]8000          	mov word [execblk.cmdline], 80h
  4201 00001C83 C60681000D              	mov byte [81h], 0Dh
  4202 00001C88 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 00001C8D FC                      	cld
  4208                                  	d0bp
  4209 00001C8E 8CD8                    	mov ax, ds
  4210                                  %if !_LOADER
  4211 00001C90 A3[0200]                	mov word [execblk.cmdline + 2], ax
  4212 00001C93 A3[0200]                	mov word [execblk.fcb1 + 2], ax
  4213 00001C96 A3[0200]                	mov word [execblk.fcb2 + 2], ax	; set up parameter block for exec command
  4214                                  %endif
  4215 00001C99 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 00001C9C 05[0000]                	add ax, strict word immasm_buffer
  4222                                   wlcalc word_shr_4, equ $ - 2
  4223                                   %endif
  4224 00001C9F A3[0000]                	mov word [immseg], ax
  4225                                  %endif
  4226                                  
  4227 00001CA2 1E                      	push ds
  4228 00001CA3 B84000                  	mov ax, 40h
  4229 00001CA6 8ED8                    	mov ds, ax
  4230 00001CA8 A18200                  	mov ax, word [82h]	; end of circular keypress buffer
  4231 00001CAB 8B168000                	mov dx, word [80h]	; start of circular buffer
  4232 00001CAF 85C0                    	test ax, ax
  4233 00001CB1 7431                    	jz .forcekeybuffer
  4234 00001CB3 85D2                    	test dx, dx
  4235 00001CB5 742D                    	jz .forcekeybuffer
  4236 00001CB7 89C3                    	mov bx, ax
  4237 00001CB9 29D3                    	sub bx, dx		; cmp end, start
  4238 00001CBB 7627                    	jbe .forcekeybuffer	; below or equal is invalid -->
  4239 00001CBD F6C301                  	test bl, 1		; even amount of bytes ?
  4240 00001CC0 7522                    	jnz .forcekeybuffer	; no, invalid -->
  4241 00001CC2 8B1E1A00                	mov bx, word [1Ah]	; current head of circular buffer
  4242 00001CC6 39C3                    	cmp bx, ax
  4243 00001CC8 731A                    	jae .forcekeybuffer
  4244 00001CCA 29D3                    	sub bx, dx
  4245 00001CCC 7216                    	jb .forcekeybuffer
  4246 00001CCE F6C301                  	test bl, 1
  4247 00001CD1 7511                    	jnz .forcekeybuffer	; invalid -->
  4248 00001CD3 8B1E1C00                	mov bx, word [1Ch]	; current tail of circular buffer
  4249 00001CD7 39C3                    	cmp bx, ax
  4250 00001CD9 7309                    	jae .forcekeybuffer
  4251 00001CDB 29D3                    	sub bx, dx
  4252 00001CDD 7205                    	jb .forcekeybuffer
  4253 00001CDF F6C301                  	test bl, 1
  4254 00001CE2 740E                    	jz @F			; valid -->
  4255                                  .forcekeybuffer:
  4256 00001CE4 1F                      	pop ds
  4257 00001CE5 C706[0000]3E00          	mov word [io_end_buffer], 3Eh
  4258 00001CEB C706[0000]1E00          	mov word [io_start_buffer], 1Eh
  4259 00001CF1 A8                      	db __TEST_IMM8		; (skip pop)
  4260                                  @@:
  4261 00001CF2 1F                      	pop ds
  4262                                  
  4263                                  %if _BOOTLDR
  4264                                   %if _APPLICATION || _DEVICE
  4265 00001CF3 F606[0100]40            	testopt [internalflags], nodosloaded
  4266 00001CF8 7403                    	jz .checkio
  4267                                   %endif
  4268                                  d4	call init_d4message
  4269                                  d4	asciz "Common initialisation, determining processor type now",13,10
  4270 00001CFA 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 00001CFD B80044                  	mov ax, 4400h		; IOCTL get device information
  4279 00001D00 31DB                    	xor bx, bx		; StdIn
  4280 00001D02 B283                    	mov dl, 83h		; default if 21.4400 fails
  4281 00001D04 CD21                    	int 21h
  4282 00001D06 F6C280                  	test dl, 80h
  4283 00001D09 7414                    	jz .inputfile
  4284 00001D0B 8026[0000]DF            	clropt [internalflags], inputfile
  4285 00001D10 F6C203                  	test dl, 3
  4286 00001D13 740A                    	jz .inputdevice		; if not the console input
  4287 00001D15 8026[0000]EF            	clropt [internalflags], notstdinput
  4288 00001D1A C606[0000]00            	mov byte [notatty], 0	; it _is_ a tty
  4289                                  .inputdevice:
  4290                                  .inputfile:
  4291 00001D1F B80044                  	mov ax, 4400h		; IOCTL get device information
  4292 00001D22 43                      	inc bx			; StdOut
  4293 00001D23 B283                    	mov dl, 83h		; default if 21.4400 fails
  4294 00001D25 CD21                    	int 21h
  4295 00001D27 F6C280                  	test dl, 80h
  4296 00001D2A 740F                    	jz .outputfile
  4297 00001D2C 8026[0000]7F            	clropt [internalflags], outputfile
  4298 00001D31 F6C203                  	test dl, 3
  4299 00001D34 7405                    	jz .outputdevice	; if not the console output
  4300 00001D36 8026[0000]BF            	clropt [internalflags], notstdoutput
  4301                                  .outputdevice:
  4302                                  .outputfile:
  4303                                  
  4304                                  		; Check DOS version
  4305                                  %if _VDD
  4306 00001D3B 1E                      	push ds
  4307 00001D3C 0E                      	 push cs
  4308 00001D3D 1F                      	 pop ds
  4309 00001D3E 0E                      	 push cs
  4310 00001D3F 07                      	 pop es
  4311 00001D40 E86DFD                  	call isnt		; NTVDM ?
  4312 00001D43 1F                      	pop ds
  4313 00001D44 7205                    	jc .isnotnt		; no -->
  4314 00001D46 800E[0200]02            	setopt [internalflags], runningnt
  4315                                  .isnotnt:
  4316                                  %endif
  4317                                  
  4318 00001D4B B80030                  	mov ax, 3000h		; check DOS version
  4319 00001D4E CD21                    	int 21h
  4320 00001D50 86C4                    	xchg al, ah
  4321 00001D52 3D1F03                  	cmp ax, ver(3,31)	; MS-DOS version > 3.30 ?
  4322 00001D55 7205                    	jb .notoldpacket	; no -->
  4323 00001D57 800E[0000]01            	setopt [internalflags], oldpacket	; assume Int25/Int26 packet method available
  4324                                  .notoldpacket:
  4325 00001D5C 50                      	push ax
  4326 00001D5D 31DB                    	xor bx, bx		; preset to invalid value
  4327 00001D5F B80633                  	mov ax, 3306h
  4328 00001D62 CD21                    	int 21h
  4329 00001D64 84C0                    	test al, al		; invalid, DOS 1.x error -->
  4330 00001D66 7402                    	jz .213306invalid
  4331 00001D68 3CFF                    	cmp al, -1		; invalid
  4332                                  .213306invalid:
  4333 00001D6A 58                      	pop ax
  4334 00001D6B 7407                    	je .useoldver
  4335 00001D6D 85DB                    	test bx, bx		; 0.0 ?
  4336 00001D6F 7403                    	jz .useoldver		; assume invalid -->
  4337 00001D71 93                      	xchg ax, bx		; get version to ax
  4338 00001D72 86C4                    	xchg al, ah		; strange Microsoft version format
  4339                                  .useoldver:
  4340 00001D74 3D0107                  	cmp ax, ver(7,01)	; MS-DOS version > 7.00 ?
  4341 00001D77 7205                    	jb .notnewpacket	; no -->
  4342 00001D79 800E[0000]03            	setopt [internalflags], newpacket| oldpacket	; assume both packet methods available
  4343                                  .notnewpacket:
  4344                                  %if _VDD
  4345 00001D7E F606[0200]02            	testopt [internalflags], runningnt
  4346 00001D83 741F                    	jz .novdd
  4347 00001D85 1E                      	push ds
  4348 00001D86 0E                      	 push cs
  4349 00001D87 1F                      	 pop ds
  4350 00001D88 0E                      	 push cs
  4351 00001D89 07                      	 pop es
  4352 00001D8A BE[5A1A]                	mov si, imsg.vdd	; ds:si-> ASCIZ VDD filename
  4353 00001D8D BB[671A]                	mov bx, imsg.dispatch	; ds:bx-> ASCIZ dispatching entry
  4354 00001D90 BF[701A]                	mov di, imsg.init	; es:di-> ASCIZ init entry
  4355 00001D93 F8                      	clc			; !
  4356 00001D94 C4C4580090              	RegisterModule		; register VDD
  4357 00001D99 1F                      	pop ds
  4358 00001D9A 7208                    	jc .novdd		; error ? -->
  4359 00001D9C A3[0000]                	mov word [hVdd], ax
  4360 00001D9F 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 00001DA4 BA[0000]                	mov dx, configpath
  4369 00001DA7 E83918                  	call do_truename
  4370 00001DAA 893E[0000]              	mov word [configpath.dir_end], di
  4371                                  do_truename_scripts:
  4372 00001DAE BA[0000]                	mov dx, scriptspath
  4373 00001DB1 E82F18                  	call do_truename
  4374 00001DB4 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 00001DB8 B92101                  	mov cx, 0121h
  4383 00001DBB D2E5                    	shl ch, cl
  4384 00001DBD 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 00001DBF E80500                  	call .detect_nec
  4389 00001DC2 E30F                    	jcxz .found_186_plus	; if it was a nop -->
  4390 00001DC4 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 00001DC7 89E0                    	mov ax, sp
  4403 00001DC9 B90100                  	mov cx, 1		; = 1 if on actual 8088/8086
  4404 00001DCC 51                      	push cx
  4405 00001DCD 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 00001DCE 8FC1                    	db 8Fh, 0C1h		; pop r/m16 with cx as operand
  4414                                  				;  (reportedly a nop on the NECs)
  4415 00001DD0 89C4                    	mov sp, ax		; reset stack to known state
  4416 00001DD2 C3                      	retn
  4417                                  
  4418                                  .found_186_plus:
  4419                                  d4	call init_d4message
  4420                                  d4	asciz "Found 186+ processor",13,10
  4421 00001DD3 FE06[0000]              	inc byte [ machine ]	; 1
  4422 00001DD7 54                      	push sp
  4423 00001DD8 58                      	pop ax
  4424 00001DD9 39E0                    	cmp ax, sp
  4425 00001DDB 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 00001DE0 FE06[0000]              	inc byte [ machine ]	; 2
  4444 00001DE4 9C                      	 pushf			; save IF
  4445 00001DE5 9C                      	pushf			; get original flags into ax
  4446 00001DE6 58                      	pop ax
  4447 00001DE7 0D00F0                  	or ax, 0F000h		; try to set bits 12-15
  4448 00001DEA 25FFFD                  	and ax, ~0200h		; clear IF
  4449 00001DED 50                      	push ax			; save new flags value on stack
  4450 00001DEE 9D                      	popf			; replace current flags value; DI
  4451 00001DEF 9C                      	pushf			; get new flags
  4452 00001DF0 58                      	pop ax			; store new flags in ax
  4453 00001DF1 9D                      	 popf			; restore IF (in 86 Mode)
  4454 00001DF2 A900F0                  	test ax, 0F000h		; if bits 12-15 clear, CPU = 80286
  4455 00001DF5 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 00001DFA 800E[0100]80            	setopt [internalflags], has386
  4467 00001DFF FE06[0000]              	inc byte [ machine ]	; 3
  4468                                  
  4469                                  %if _DEVICE
  4470                                   %if _APPLICATION || _BOOTLDR
  4471 00001E03 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  4472 00001E08 7440                    	jz @F
  4473                                   %endif
  4474                                  
  4475 00001E0A 8C26[0000]              	mov word [reg_fs], fs
  4476 00001E0E 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 00001E12 6650                <1>  push e %+ %1
  4479 00001E14 58                  <1>  pop %1
  4480 00001E15 8F06[0200]          <1>  pop word [reg_e %+ %1 + 2]
  4483                                  	set_gpr_h bx
  4478 00001E19 6653                <1>  push e %+ %1
  4479 00001E1B 5B                  <1>  pop %1
  4480 00001E1C 8F06[0200]          <1>  pop word [reg_e %+ %1 + 2]
  4484                                  	set_gpr_h cx
  4478 00001E20 6651                <1>  push e %+ %1
  4479 00001E22 59                  <1>  pop %1
  4480 00001E23 8F06[0200]          <1>  pop word [reg_e %+ %1 + 2]
  4485                                  	set_gpr_h dx
  4478 00001E27 6652                <1>  push e %+ %1
  4479 00001E29 5A                  <1>  pop %1
  4480 00001E2A 8F06[0200]          <1>  pop word [reg_e %+ %1 + 2]
  4486                                  	set_gpr_h bp
  4478 00001E2E 6655                <1>  push e %+ %1
  4479 00001E30 5D                  <1>  pop %1
  4480 00001E31 8F06[0200]          <1>  pop word [reg_e %+ %1 + 2]
  4487                                  	set_gpr_h si
  4478 00001E35 6656                <1>  push e %+ %1
  4479 00001E37 5E                  <1>  pop %1
  4480 00001E38 8F06[0200]          <1>  pop word [reg_e %+ %1 + 2]
  4488                                  	set_gpr_h di
  4478 00001E3C 6657                <1>  push e %+ %1
  4479 00001E3E 5F                  <1>  pop %1
  4480 00001E3F 8F06[0200]          <1>  pop word [reg_e %+ %1 + 2]
  4489                                  		; esph and eiph remain zero
  4490 00001E43 669C                    	pushfd
  4491 00001E45 9D                      	popfw
  4492 00001E46 8F06[0200]              	pop word [reg_efl + 2]
  4493                                  %endif
  4494                                  @@:
  4495                                  
  4496 00001E4A 89E3                    	mov bx, sp		; save current stack pointer to align
  4497 00001E4C 83E4FC                  	and sp, ~3		; align stack to avoid AC fault
  4498 00001E4F 669C                    	pushfd			; push original EFLAGS
  4499 00001E51 6658                    	pop eax			; get original EFLAGS
  4500 00001E53 6689C1                  	mov ecx, eax		; save original EFLAGS in ECX (including IF)
  4501                                  
  4502 00001E56 663500000400            	xor eax, 40000h		; flip AC bit in EFLAGS
  4503 00001E5C 25FFFD                  	and ax, ~0200h		; clear IF
  4504 00001E5F 6650                    	push eax		; put new EFLAGS value on stack
  4505 00001E61 669D                    	popfd			; replace EFLAGS value; DI
  4506 00001E63 669C                    	pushfd			; get new EFLAGS
  4507 00001E65 6658                    	pop eax			; store new EFLAGS value in EAX
  4508 00001E67 89C8                    	mov ax, cx		; ignore low bits (including IF)
  4509 00001E69 6639C8                  	cmp eax, ecx
  4510 00001E6C 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 00001E6E FE06[0000]              	inc byte [ machine ]	; 4
  4519 00001E72 6689C8                  	mov eax, ecx		; get original EFLAGS
  4520 00001E75 663500002000            	xor eax, 200000h	; flip ID bit in EFLAGS
  4521 00001E7B 25FFFD                  	and ax, ~0200h		; clear IF
  4522 00001E7E 6650                    	push eax		; save new EFLAGS value on stack
  4523 00001E80 669D                    	popfd			; replace current EFLAGS value; DI
  4524 00001E82 669C                    	pushfd			; get new EFLAGS
  4525 00001E84 6658                    	pop eax			; store new EFLAGS in EAX
  4526 00001E86 89C8                    	mov ax, cx		; ignore low bits (including IF)
  4527                                  
  4528                                  .cpudone_stack_eax_equals_ecx:
  4529 00001E88 6651                    	push ecx
  4530 00001E8A 669D                    	popfd			; restore AC,ID bits and IF in EFLAGS (86 Mode)
  4531 00001E8C 89DC                    	mov sp, bx		; restore sp
  4532                                  
  4533 00001E8E 6639C8                  	cmp eax, ecx		; check if it's changed
  4534 00001E91 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 00001E93 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 00001E96 0FA2                    	 cpuid
  4554                                  	  __CPU__
  4555                                  d4	call init_d4message
  4556                                  d4	asciz "CPUID 0 executed",13,10
  4557 00001E98 6683F801                	cmp eax, byte 1
  4558 00001E9C 7220                    	jb .cpudone		; if 1 is not a valid input value for CPUID
  4559 00001E9E 6631C0                  	xor eax, eax		; otherwise, run CPUID with eax = 1
  4560 00001EA1 6640                    	inc eax
  4561                                  d4	call init_d4message
  4562                                  d4	asciz "Executing CPUID 1",13,10
  4563                                  	  [cpu 586]
  4564 00001EA3 0FA2                    	 cpuid
  4565                                  	  __CPU__
  4566                                  d4	call init_d4message
  4567                                  d4	asciz "CPUID 1 executed",13,10
  4568                                  %if _MMXSUPP
  4569 00001EA5 66F7C200008000          	test edx, 80_0000h
  4570 00001EAC 0F9506[0000]            	setnz byte [has_mmx]
  4571                                  %endif
  4572                                  
  4573 00001EB1 88E0                    	mov al, ah
  4574 00001EB3 240F                    	and al, 0Fh		; bits 8..11 are the model number
  4575 00001EB5 3C06                    	cmp al, 6
  4576 00001EB7 7202                    	jb .below686		; if < 6
  4577 00001EB9 B006                    	mov al, 6		; if >= 6, set it to 6
  4578                                  .below686:
  4579 00001EBB 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 00001EBE A0[0000]                	mov al, byte [ machine ]
  4601 00001EC1 A2[0000]                	mov byte [ mach_87 ], al	; by default, set mach_87 to machine
  4602 00001EC4 FE06[0000]              	inc byte [ has_87 ]
  4603 00001EC8 C606[0000]0C            	mov byte [encodedmach87], 0Ch
  4604 00001ECD 3C05                    	cmp al, 5			; a Pentium or above always will have a FPU
  4605 00001ECF 7350                    	jae .fpudone
  4606 00001ED1 FE0E[0000]              	dec byte [ has_87 ]		; assume no FPU
  4607 00001ED5 C606[0000]C0            	mov byte [encodedmach87], 0C0h
  4608                                  
  4609 00001EDA DBE3                    	fninit				; reset FPU
  4610 00001EDC B0FF                    	mov al, -1			; initialise with a non-zero value
  4611 00001EDE 50                      	push ax
  4612 00001EDF 89E3                    	mov bx, sp
  4613 00001EE1 36DD3F                  	fnstsw word [ss:bx]		; save FP status word
  4614 00001EE4 58                      	pop ax				; retrieve it
  4615 00001EE5 84C0                    	test al, al
  4616 00001EE7 7538                    	jnz .fpudone			; if no FPU present
  4617                                  
  4618                                  		; al = 0 here
  4619 00001EE9 50                      	push ax
  4620 00001EEA 36D93F                  	fnstcw word [ss:bx]		; save FP control word
  4621 00001EED 58                      	pop ax				; retrieve it
  4622 00001EEE 253F10                  	and ax, 103Fh			; see if selected parts look OK
  4623 00001EF1 83F83F                  	cmp ax, byte 3Fh
  4624 00001EF4 752B                    	jne .fpudone			; if no FPU present
  4625 00001EF6 FE06[0000]              	inc byte [ has_87 ]		; there's an FPU
  4626 00001EFA 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 00001EFF 803E[0000]03            	cmp byte [ machine ], 3
  4631 00001F04 751B                    	jne .fpudone			; if not a 386
  4632                                  [cpu 386]
  4633 00001F06 D9E8                    	fld1				; must use default control from FNINIT
  4634 00001F08 D9EE                    	fldz				; form infinity
  4635 00001F0A DEF9                    	fdivp ST1			; 1 / 0 = infinity
  4636 00001F0C D9C0                    	fld ST0
  4637 00001F0E D9E0                    	fchs				; form negative infinity
  4638 00001F10 DED9                    	fcompp				; see if they are the same and remove them
  4639 00001F12 9BDFE0                  	fstsw ax
  4640 00001F15 9E                      	sahf				; look at status from FCOMPP
  4641 00001F16 7509                    	jne .fpudone			; if they are different, then it's a 387
  4642 00001F18 FE0E[0000]              	dec byte [ mach_87 ]		; otherwise, it's a 287
  4643 00001F1C 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 00001F21 8E06[0000]              	mov es, [code_seg]
  4687 00001F25 F606[0100]80            	testopt [internalflags], has386
  4688 00001F2A 740B                    	jz @F
  4689 00001F2C BE[0000]                	mov si, patch_386_table		; table of patches to set for 386+
  4690                                  %if __patch_386_table_method == 1
  4691 00001F2F B9[0000]                	mov cx, patch_386_table.amount
  4692 00001F32 E83200                  	call .patch1
  4693                                  %else
  4694                                  	call .patch2
  4695                                  %endif
  4696 00001F35 EB3C                    	jmp .patch_code1_end
  4697                                  
  4698                                  @@:
  4699                                  %ifn _ONLYNON386
  4700                                  
  4701                                  %if _RUN2_ENTRY_SECTION
  4702 00001F37 C606[0000]3E            	mov byte [..@patch_no386_ds_code_or_entry], 3Eh
  4703                                  					; write a ds prefix
  4704 00001F3C 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 00001F41 C606[0000]3E            	mov byte [..@patch_no386_ds_entry_pmint21_1], 3Eh
  4714 00001F46 C606[0000]3E            	mov byte [..@patch_no386_ds_entry_pmint21_2], 3Eh
  4715                                  					; write ds prefixes (note the segment!)
  4716                                   %endif
  4717                                   %if _PM
  4718 00001F4B 26C606[0000]3E          	mov byte [es:..@patch_no386_ds_4], 3Eh
  4719 00001F51 26C606[0000]3E          	mov byte [es:..@patch_no386_ds_5], 3Eh	; write some more ds prefixes
  4720                                   %endif
  4721                                   %if _CATCHINT07 || _CATCHINT0C || _CATCHINT0D
  4722 00001F57 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 00001F5C BE[0000]                	mov si, patch_no386_table	; table of patches to set for 16-bit CPU
  4727                                  %if __patch_no386_table_method == 1
  4728 00001F5F B9[0000]                	mov cx, patch_no386_table.amount
  4729 00001F62 E80200                  	call .patch1
  4730                                  %else
  4731                                  	call .patch2
  4732                                  %endif
  4733 00001F65 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 00001F67 E309                    	jcxz .patchesdone
  4765                                  .looppatch1:
  4766 00001F69 2EAD                    	cs lodsw			; load address of patch
  4767 00001F6B 93                      	xchg bx, ax			; (set bx = ax, CHG ax)
  4768 00001F6C 26C60790                	mov byte [es:bx], 90h		; patch
  4769 00001F70 E2F7                    	loop .looppatch1
  4770                                  %endif
  4771                                  .patchesdone:
  4772 00001F72 C3                      	retn
  4773                                  
  4774                                  .patch_code1_end:
  4775                                  
  4776                                  %if _DUALCODE
  4777 00001F73 8CC2                    	mov dx, es			; dx => code1 seg
  4778                                  %endif
  4779                                   %if _BOOTLDR_DISCARD
  4780 00001F75 F606[0100]40            	testopt [internalflags], nodosloaded
  4781 00001F7A 750F                    	jnz @F
  4782                                  
  4783                                    %if _AREAS && _AREAS_HOOK_CLIENT
  4784                                     %ifn _LINK
  4785                                  	mov ax, ldebug_code_bootldr_truncated_size
  4786                                     %else
  4787 00001F7C B8[0000]                	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 00001F7F A3[0400]                	mov word [areas_sub + areastrucfunLinearEnd], ax
  4792 00001F82 A3[0400]                	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 00001F85 81C2[0000]              	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 00001F89 EB04                    	jmp @FF
  4807                                  @@:					; if bootloaded
  4808                                   %endif
  4809                                    %ifn _LINK
  4810                                  	add dx, ldebug_code_size_p	; use untruncated
  4811                                    %else
  4812 00001F8B 81C2[0000]              	add dx, strict word relocatedzero + 0
  4813                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code, equ $ - 2
  4814                                    %endif
  4815                                  @@:
  4816 00001F8F 8916[0000]              	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 00001F93 06                      	push es
  4827 00001F94 8EC2                    	mov es, dx
  4828 00001F96 5A                      	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 00001F97 F606[0100]80            	testopt [internalflags], has386
  4846 00001F9C 740B                    	jz @F
  4847 00001F9E BE[0000]                	mov si, patch_386_table2	; table of patches to set for 386+
  4848                                  %if __patch_386_table2_method == 1
  4849 00001FA1 B9[0000]                	mov cx, patch_386_table2.amount
  4850 00001FA4 E8C0FF                  	call apply_patches.patch1
  4851                                  %else
  4852                                  	call apply_patches.patch2
  4853                                  %endif
  4854 00001FA7 EB09                    	jmp .patch_code2_end
  4855                                  
  4856                                  @@:
  4857 00001FA9 BE[0000]                	mov si, patch_no386_table2	; table of patches to set for 16-bit CPU
  4858                                  %if __patch_no386_table2_method == 1
  4859 00001FAC B9[0000]                	mov cx, patch_no386_table2.amount
  4860 00001FAF E8B5FF                  	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 00001FB2 1E                      	push ds
  4877 00001FB3 07                      	pop es
  4878 00001FB4 F606[0100]80            	testopt [internalflags], has386
  4879 00001FB9 740B                    	jz @F
  4880 00001FBB BE[0000]                	mov si, patch_386_tableentry	; table of patches to set for 386+
  4881                                  %if __patch_386_tableentry_method == 1
  4882 00001FBE B9[0000]                	mov cx, patch_386_tableentry.amount
  4883 00001FC1 E8A3FF                  	call apply_patches.patch1
  4884                                  %else
  4885                                  	call apply_patches.patch2
  4886                                  %endif
  4887 00001FC4 EB09                    	jmp .patch_entry_end
  4888                                  
  4889                                  @@:
  4890 00001FC6 BE[0000]                	mov si, patch_no386_tableentry	; table of patches to set for 16-bit CPU
  4891                                  %if __patch_no386_tableentry_method == 1
  4892 00001FC9 B9[0000]                	mov cx, patch_no386_tableentry.amount
  4893 00001FCC E898FF                  	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 00001FCF 1E                      	push ds
  4906 00001FD0 07                      	pop es
  4907 00001FD1 BE[0000]                	mov si, regs
  4908 00001FD4 BF[0000]                	mov di, device_quittable_regs
  4909                                   %ifn _LINK
  4910                                  	mov cx, words(regs.size)
  4911                                   %else
  4912 00001FD7 B9[0100]                	mov cx, regs.size + 1
  4913                                   wlcalc word_shr_1, equ $ - 2
  4914                                   %endif
  4915 00001FDA 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 00001FDC B800F0                  	mov ax, 0F000h
  4923 00001FDF 8EC0                    	mov es, ax
  4924 00001FE1 1E                      	push ds
  4925 00001FE2 0E                      	 push cs
  4926 00001FE3 1F                      	 pop ds			; avoid "repe cs cmpsw" (8086 bug)
  4927 00001FE4 BFF5FF                  	mov di, 0FFF5h
  4928 00001FE7 BE[521A]                	mov si, imsg.dosemudate
  4929 00001FEA B90400                  	mov cx, 4
  4930 00001FED F3A7                    	repe cmpsw		; running in DosEmu?
  4931 00001FEF 1F                      	pop ds
  4932 00001FF0 750A                    	jne .dosemuchecked
  4933 00001FF2 800E[0300]01            	setopt [internalflags], runningdosemu
  4934                                   %if _DOSEMU_PRESTROKES_HELP
  4935 00001FF7 B80900                  	mov ax, 0009h
  4936 00001FFA 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 00001FFC 1E                      	push ds
  4951 00001FFD 07                      	pop es			; => lDEBUG_DATA_ENTRY
  4952                                  
  4953 00001FFE BF[0000]                	mov di, line_in
  4954 00002001 B0FF                    	mov al, 255
  4955 00002003 AA                      	stosb
  4956 00002004 B000                    	mov al, 0
  4957 00002006 AA                      	stosb
  4958 00002007 B00D                    	mov al, 13
  4959 00002009 AA                      	stosb				; overwrite line_in beginning
  4960                                  
  4961 0000200A BC[0000]                	mov sp, stack_end		; stack pointer (paragraph aligned)
  4962 0000200D BF[0000]                	mov di, ..@init_first
  4963                                  %ifn _LINK
  4964                                  	mov cx, ..@init_behind - ..@init_first
  4965                                  %else
  4966 00002010 B9[0000]                	mov cx, ..@init_behind
  4967                                   wlcalc word_minusext_..@init_first, equ $ - 2
  4968                                  %endif
  4969 00002013 31C0                    	xor ax, ax
  4970 00002015 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 00002017 BF[0000]                	mov di, stack
  4976                                  %endif
  4977                                  %ifn _LINK
  4978                                  	mov cx, stack_end - stack
  4979                                  %else
  4980 0000201A B9[0000]                	mov cx, stack_end
  4981                                   wlcalc word_minusext_stack, equ $ - 2
  4982                                  %endif
  4983 0000201D B05E                    	mov al, 5Eh
  4984 0000201F F3AA                    	rep stosb			; initialise the stack
  4985                                  %endif
  4986                                  
  4987 00002021 C606[0000]30            	mov byte [ trim_overflow ], '0'	; initialise line_out so the trimputs loop doesn't overflow
  4988 00002026 C706[0000]4226          	mov word [line_out_overflow], 2642h
  4989                                  
  4990                                  
  4991                                  %if _AREAS_HOOK_SERVER
  4992 0000202C 8CD8                    	mov ax, ds
  4993 0000202E A3[0200]                	mov word [ddebugareas.next + 2], ax
  4994 00002031 A3[0200]                	mov word [ddebugareas.prev + 2], ax
  4995 00002034 A3[0000]                	mov word [..@patch_entry_seg], ax
  4996                                  %endif
  4997                                  
  4998                                  %if _AREAS && _AREAS_HOOK_CLIENT
  4999 00002037 A1[0000]                	mov ax, word [code_seg]
  5000 0000203A E85E15                  	call add_to_areas_linear_code1
  5001                                  
  5002                                   %if _DUALCODE && _EXPRDUALCODE
  5003 0000203D A1[0000]                	mov ax, word [code2_seg]
  5004 00002040 E88415                  	call add_to_areas_linear_code2
  5005                                   %endif
  5006                                  %endif
  5007                                  
  5008                                  
  5009                                  %if _DEBUG && _DEBUG_COND && _DEBUG_COND_DEFAULT_ON
  5010 00002043 800E[0100]01            	setopt [internalflags6], dif6_debug_mode
  5011 00002048 800E[0100]01            	setopt [options6], opt6_debug_mode
  5012 0000204D 800E[0100]01            	setopt [startoptions6], opt6_debug_mode
  5013                                  %endif
  5014                                  
  5015                                  %if _CATCHINT06 && _DETECT95LX
  5016 00002052 B8D44D                  	mov ax, 4DD4h
  5017 00002055 31DB                    	xor bx, bx
  5018 00002057 CD15                    	int 15h				; HP 95LX/100LX/200LX detect
  5019 00002059 81FB5048                	cmp bx, 4850h			; "HP" reversed
  5020 0000205D 7516                    	jne @F
  5021 0000205F 81F90101                	cmp cx, 0101h			; 95LX ?
  5022 00002063 7510                    	jne @F				; no -->
  5023                                  
  5024                                   %if _CATCHINT2D
  5025 00002065 A1[0100]                	mov ax, word [inttab.i2D + 1]
  5026 00002068 A3[0100]                	mov word [inttab.i06 + 1], ax	; overwrite i06 entry with i2D
  5027 0000206B A0[0000]                	mov al, byte [inttab.i2D]
  5028 0000206E A2[0000]                	mov byte [inttab.i06], al	; interrupt number too
  5029                                   %endif
  5030 00002071 FF0E[0000]              	dec word [inttab_number_variable]	; remember one less in use
  5031                                  @@:
  5032                                  %endif
  5033                                  
  5034 00002075 B40F                    	mov ah, 0Fh
  5035 00002077 CD10                    	int 10h
  5036 00002079 883E[0000]              	mov byte [vpage], bh
  5037                                  
  5038                                  
  5039                                  %if _BOOTLDR
  5040                                   %if _APPLICATION || _DEVICE
  5041 0000207D F606[0100]40            	testopt [internalflags], nodosloaded
  5042 00002082 7441                    	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 00002084 8B0E[0000]              	mov cx, word [inttab_number_variable]
  5054                                  %else
  5055                                  	mov cx, inttab_number
  5056                                  %endif
  5057 00002088 E32F                    	jcxz .bootintend
  5058 0000208A BE[0000]                	mov si, inttab
  5059                                  .bootintloop:
  5060                                  
  5061                                  		; assumes ss = lDEBUG_DATA_ENTRY
  5062 0000208D 36AC                    	ss lodsb
  5063 0000208F 31DB                    	xor bx, bx
  5064 00002091 8EDB                    	mov ds, bx
  5065 00002093 88C3                    	mov bl, al
  5066 00002095 01DB                    	add bx, bx
  5067 00002097 01DB                    	add bx, bx
  5068 00002099 97                      	xchg ax, di
  5069 0000209A 36AD                    	ss lodsw		; get address of IISP header
  5070 0000209C 97                      	xchg ax, di
  5071                                  %if _DEBUG && !_DEBUG_COND
  5072                                  				; vectors are set only when debuggee runs
  5073                                  %else
  5074                                   %if _DEBUG
  5075 0000209D 36F606[0100]01          	testopt [ss:internalflags6], dif6_debug_mode
  5076 000020A3 7512                    	jnz @F
  5077                                   %endif
  5078 000020A5 FF7702                  	push word [ bx+2 ]
  5079 000020A8 FF37                    	push word [ bx ]	; get vector
  5080 000020AA 368F4502                	pop word [ ss:di + ieNext ]
  5081 000020AE 368F4504                	pop word [ ss:di + ieNext + 2 ]
  5082                                  				; store it
  5083 000020B2 8C5702                  	mov word [ bx+2 ], ss
  5084 000020B5 893F                    	mov word [ bx ], di	; set interrupt vector
  5085                                  @@:
  5086                                  %endif
  5087 000020B7 E2D4                    	loop .bootintloop
  5088                                  
  5089                                  .bootintend:
  5090                                  %endif
  5091                                  
  5092                                  %if _EXTENSIONS
  5093                                  init_eld_boot:
  5094 000020B9 E85B15                  	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 000020BC BE[0000]                	mov si, initcont.boot_entry
  5105 000020BF FF36[0000]              	push word [code_seg]
  5106 000020C3 56                      	push si
  5107 000020C4 CB                      	retf
  5108                                  %endif
  5109                                  
  5110                                  %if _APPLICATION || _DEVICE
  5111                                  initdos:
  5112                                  %if _MCB || _INT || _EXTENSIONS
  5113 000020C5 B80258                  	mov ax, 5802h
  5114 000020C8 CD21                    	int 21h
  5115 000020CA 30E4                    	xor ah, ah		; some "DOS" only return al
  5116 000020CC 50                      	push ax			; save UMB link
  5117                                  
  5118                                  getfirstmcb:
  5119 000020CD B452                    	mov ah, 52h		; get list of lists
  5120 000020CF BBFFFF                  	mov bx, -1
  5121 000020D2 CD21                    	int 21h
  5122 000020D4 83FBFF                  	cmp bx, -1
  5123 000020D7 7503E98800              	je mcb_not_found
  5124 000020DC 83FB01                  	cmp bx, 1
  5125 000020DF 7503E98000              	je mcb_not_found
  5126 000020E4 268B47FE                	mov ax, word [ es:bx-2 ]; start of MCBs
  5127 000020E8 A3[0000]                	mov word [firstmcb], ax
  5128                                  
  5129                                  getfirstumcb:
  5130 000020EB 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 000020EC 06                      	push es
  5138 000020ED 31C0                    	xor ax, ax
  5139 000020EF 8EC0                    	mov es, ax		; (only used in 86 Mode)
  5140 000020F1 26A1BC00                	mov ax, [es:2Fh * 4]
  5141 000020F5 83F8FF                  	cmp ax, -1
  5142 000020F8 7405                    	je @F			; --> (ZR)
  5143 000020FA 260B06BE00              	or ax, [es:2Fh * 4 + 2]
  5144                                  @@:
  5145 000020FF 07                      	pop es
  5146 00002100 7414                    	jz .determine
  5147                                    %endif
  5148 00002102 B86112                  	mov ax, 1261h		; PTS-DOS: Get first UMCB
  5149 00002105 F9                      	stc
  5150 00002106 CD2F                    	int 2Fh
  5151 00002108 720C                    	jc .determine		; not supported -->
  5152 0000210A 40                      	inc ax
  5153 0000210B 83F802                  	cmp ax, byte 2		; -1, 0, 1 ?
  5154 0000210E 7606                    	jbe .determine		; not supported (or none) -->
  5155 00002110 48                      	dec ax
  5156 00002111 A3[0000]                	mov word [ firstumcb ], ax	; set UMB
  5157 00002114 EB4D                    	jmp short .got		; got it -->
  5158                                  
  5159                                  .determine:
  5160 00002116 B80358                  	mov ax, 5803h
  5161 00002119 31DB                    	xor bx, bx
  5162 0000211B CD21                    	int 21h			; disable UMB link, leave only LMA chain
  5163 0000211D 7244                    	jc .none		; that isn't supported either -->
  5164                                  
  5165 0000211F A1[0000]                	mov ax, word [firstmcb]
  5166 00002122 89C2                    	mov dx, ax		; first MCB
  5167 00002124 31DB                    	xor bx, bx		; use offsets from bx, not addresses
  5168                                  .looplmb:
  5169 00002126 8ED8                    	mov ds, ax
  5170 00002128 40                      	inc ax
  5171 00002129 034703                  	add ax, word [ bx + 3 ]	; next MCB's address
  5172 0000212C 803F4D                  	cmp byte [ bx ], 'M'
  5173 0000212F 74F5                    	je .looplmb		; not last -->
  5174 00002131 803F5A                  	cmp byte [ bx ], 'Z'
  5175 00002134 752D                    	jne .none		; corrupted -->
  5176 00002136 92                      	xchg ax, dx		; dx = what we assume to be the first UMA chain MCB
  5177                                  				; ax = first MCB
  5178                                  
  5179 00002137 50                      	push ax
  5180 00002138 43                      	inc bx			; = 1
  5181 00002139 B80358                  	mov ax, 5803h
  5182 0000213C CD21                    	int 21h			; enable UMB link, include UMA chain
  5183 0000213E 58                      	pop ax
  5184 0000213F 7222                    	jc .none		; so we can disable it but not enable? -->
  5185                                  
  5186 00002141 4B                      	dec bx			; = 0
  5187 00002142 31C9                    	xor cx, cx		; flag if assumed first UMCB found
  5188                                  .loopumb:
  5189 00002144 39D0                    	cmp ax, dx
  5190 00002146 7501                    	jne .notlastlmb
  5191 00002148 41                      	inc cx			; there it is
  5192                                  .notlastlmb:
  5193 00002149 8ED8                    	mov ds, ax
  5194 0000214B 803F4D                  	cmp byte [ bx ], 'M'
  5195 0000214E 7506                    	jne .islastumb?		; last or corrupted -->
  5196 00002150 40                      	inc ax
  5197 00002151 034703                  	add ax, word [ bx + 3 ]
  5198 00002154 EBEE                    	jmp short .loopumb	; process next -->
  5199                                  .islastumb?:
  5200 00002156 803F5A                  	cmp byte [ bx ], 'Z'
  5201 00002159 7508                    	jne .none		; corrupted -->
  5202 0000215B 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 0000215D 1F                      	pop ds
  5208 0000215E 8916[0000]              	mov word [ firstumcb ], dx
  5209 00002162 A8                      	db __TEST_IMM8		; (skip pop)
  5210                                  .none:
  5211                                  .got:
  5212 00002163 1F                      	pop ds
  5213                                  mcb_not_found:
  5214 00002164 5B                      	pop bx
  5215 00002165 B80358                  	mov ax, 5803h
  5216 00002168 CD21                    	int 21h			; restore UMB link
  5217                                  %endif
  5218                                  
  5219                                  getindosflag:
  5220 0000216A B434                    	mov ah, 34h
  5221 0000216C CD21                    	int 21h
  5222 0000216E 891E[0000]              	mov word [pInDOS + so16aOffset], bx
  5223 00002172 8C06[0200]              	mov word [pInDOS + so16aSegSel], es
  5224                                  %if _PM
  5225 00002176 8C06[0400]              	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 0000217A 1E                      	push ds
  5234 0000217B B8065D                  	mov ax, 5D06h
  5235 0000217E F9                      	stc				; initialise to CY
  5236 0000217F CD21                    	int 21h
  5237 00002181 8CD8                    	mov ax, ds
  5238 00002183 1F                      	pop ds
  5239 00002184 7218                    	jc .noSDA			; if CY returned, not supported -->
  5240 00002186 8EC0                    	mov es, ax			; es:si -> SDA
  5241                                   %if _DEVICE
  5242 00002188 50                      	push ax
  5243 00002189 B451                    	mov ah, 51h
  5244 0000218B CD21                    	int 21h				; bx = current PSP
  5245 0000218D 58                      	pop ax
  5246                                   %else
  5247                                  	mov bx, ds			; bx = our PSP (= current PSP in app mode)
  5248                                   %endif
  5249 0000218E 26395C10                	cmp word [es:si + 10h], bx	; does this seem like the current PSP field ?
  5250 00002192 750A                    	jne .noSDA			; no -->
  5251 00002194 8936[0000]              	mov word [pSDA + so16aOffset], si
  5252 00002198 A3[0200]                	mov word [pSDA + so16aSegSel], ax
  5253                                  %if _PM
  5254 0000219B A3[0400]                	mov word [pSDA + so16aSegment], ax
  5255                                  %endif
  5256                                  .noSDA:
  5257                                  %endif
  5258                                  
  5259 0000219E B83135                  	mov ax, 3531h
  5260 000021A1 CD21                    	int 21h
  5261 000021A3 8CC3                    	mov bx, es
  5262                                  %if _USESDA
  5263 000021A5 3B1E[0200]              	cmp bx, word [pSDA + so16aSegSel]
  5264 000021A9 750B                    	jne @F
  5265                                  %endif
  5266 000021AB 3B1E[0200]              	cmp bx, word [pInDOS + so16aSegSel]
  5267 000021AF 7505                    	jne @F
  5268                                  
  5269 000021B1 800E[0300]20            	setopt [internalflags2], dif2_int31_segment
  5270                                  @@:
  5271                                  
  5272                                  
  5273                                  commandline:
  5274 000021B6 16                      	push ss
  5275 000021B7 07                      	pop es
  5276                                  
  5277                                  %if _CONFIG
  5278                                  %if _APPLICATION
  5279 000021B8 BE[7417]                	mov si, imsg.default_cmdline.app
  5280 000021BB B93400                  	mov cx, words(imsg.default_cmdline.app.length)
  5281                                  %endif
  5282                                  %if _DEVICE
  5283                                   %if _APPLICATION
  5284 000021BE F606[0200]40            	testopt [internalflags6], dif6_device_mode
  5285 000021C3 7406                    	jz @F
  5286                                   %endif
  5287 000021C5 BE[DE17]                	mov si, imsg.default_cmdline.dev
  5288 000021C8 B92F00                  	mov cx, words(imsg.default_cmdline.dev.length)
  5289                                  %endif
  5290                                  @@:
  5291                                  
  5292 000021CB 0E                      	push cs
  5293 000021CC 1F                      	pop ds
  5294 000021CD BF[0000]                	mov di, cmdline_buffer
  5295 000021D0 F3A5                    	rep movsw
  5296 000021D2 26807DFF00              	cmp byte [es:di - 1], 0
  5297 000021D7 7501                    	jne @F
  5298 000021D9 4F                      	dec di
  5299                                  @@:
  5300 000021DA 893E[3A0E]              	mov [cmdline_buffer_start], di
  5301 000021DE B000                    	mov al, 0
  5302 000021E0 AA                      	stosb
  5303 000021E1 16                      	push ss
  5304 000021E2 1F                      	pop ds
  5305 000021E3 800E[0100]01            	setopt [internalflags3], dif3_input_cmdline
  5306                                  %endif
  5307                                  
  5308                                  		; Interpret switches and erase them from the command line.
  5309 000021E8 B80037                  	mov ax, 3700h			; get switch character
  5310 000021EB B22F                    	mov dl, '/'			; preset with default value
  5311 000021ED CD21                    	int 21h
  5312 000021EF 8816[0000]              	mov byte [ switchar ], dl
  5313 000021F3 80FA2F                  	cmp dl, '/'
  5314 000021F6 7504                    	jne .notslash
  5315 000021F8 8816[0000]              	mov byte [ swch1 ], dl
  5316                                  .notslash:
  5317 000021FC BE8100                  	mov si, DTA+1
  5318                                  %if _MS_N_COMPAT
  5319 000021FF C644FF30                	mov byte [si - 1], '0'	; avoid kk underflow before start of tail
  5320                                  %endif
  5321                                  .blankloop:
  5322 00002203 AC                      	lodsb
  5323 00002204 3C20                    	cmp al, 32
  5324 00002206 74FB                    	je .blankloop
  5325 00002208 3C09                    	cmp al, 9
  5326 0000220A 74F7                    	je .blankloop
  5327                                  
  5328                                  		; Process the /? switch (or the [switchar]? switch).
  5329                                  		; If switchar != / and /? occurs, make sure nothing follows.
  5330 0000220C 3A06[0000]              	cmp al, byte [switchar]
  5331 00002210 7503E9DB00              	je .switch		; if switch character -->
  5332 00002215 3C2F                    	cmp al, '/'
  5333 00002217 7403E95208              	jne .noswitches		; if not the help switch -->
  5334 0000221C 8A04                    	mov al, byte [ si ]
  5335 0000221E 3C3F                    	cmp al, '?'
  5336 00002220 7403E94908              	jne .noswitches		; if not /?
  5337 00002225 8A4401                  	mov al, byte [ si+1 ]
  5338 00002228 3C20                    	cmp al, 32
  5339 0000222A 740B                    	je .help		; if nothing after /?
  5340 0000222C 3C09                    	cmp al, 9
  5341 0000222E 7407                    	je .help		; ditto
  5342 00002230 3C0D                    	cmp al, 13
  5343 00002232 7403E93708              	jne .noswitches		; if something after /? -->
  5344                                  
  5345                                  		; Print a help message
  5346                                  .help:
  5347 00002237 1E                      	push ds
  5348                                  %if _DEVICE
  5349                                   %if _APPLICATION
  5350 00002238 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  5351 0000223D 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 0000223F 8B36[0000]              	mov si, word [reg_ebx]
  5357 00002243 8E1E[0000]              	mov ds, word [reg_es]
  5358 00002247 C57412                  	lds si, [si + 12h]
  5359 0000224A 56                      	push si
  5360                                  @@:
  5361 0000224B AC                      	lodsb
  5362 0000224C 3C20                    	cmp al, 32
  5363 0000224E 7412                    	je @F
  5364 00002250 3C09                    	cmp al, 9
  5365 00002252 740E                    	je @F
  5366 00002254 3C00                    	cmp al, 0
  5367 00002256 740A                    	je @F
  5368 00002258 3C0D                    	cmp al, 13
  5369 0000225A 7406                    	je @F
  5370 0000225C 3C0A                    	cmp al, 10
  5371 0000225E 7402                    	je @F
  5372 00002260 EBE9                    	jmp @B
  5373                                  
  5374                                  @@:
  5375 00002262 C644FF00                	mov byte [si - 1], 0
  5376 00002266 5E                      	pop si
  5377 00002267 EB1B                    	jmp .help_common
  5378                                  
  5379                                  .help_not_device:
  5380                                  %endif
  5381                                  %if _APPLICATION
  5382 00002269 A12C00                  	mov ax, word [2Ch]	; => environment
  5383 0000226C 85C0                    	test ax, ax
  5384 0000226E 7476                    	jz .help.no_name
  5385 00002270 8ED8                    	mov ds, ax
  5386 00002272 31F6                    	xor si, si
  5387                                  @@:
  5388 00002274 AC                      	lodsb
  5389 00002275 84C0                    	test al, al
  5390 00002277 75FB                    	jnz @B
  5391 00002279 AC                      	lodsb
  5392 0000227A 84C0                    	test al, al
  5393 0000227C 75F6                    	jnz @B
  5394 0000227E AD                      	lodsw
  5395 0000227F 83F801                  	cmp ax, 1
  5396 00002282 7562                    	jne .help.no_name
  5397                                  %endif
  5398                                  .help_common:
  5399                                  @@:
  5400 00002284 89F3                    	mov bx, si
  5401                                  @@:
  5402 00002286 AC                      	lodsb
  5403 00002287 3C61                    	cmp al, 'a'
  5404 00002289 7208                    	jb @F
  5405 0000228B 3C7A                    	cmp al, 'z'
  5406 0000228D 7704                    	ja @F
  5407 0000228F 806CFF20                	sub byte [si - 1], 'a' - 'A'
  5408                                  @@:
  5409 00002293 3C5C                    	cmp al, '\'
  5410 00002295 74ED                    	je @BBB
  5411 00002297 3C2F                    	cmp al, '/'
  5412 00002299 74E9                    	je @BBB
  5413 0000229B 84C0                    	test al, al
  5414 0000229D 75E7                    	jnz @BB
  5415                                  
  5416 0000229F 89F1                    	mov cx, si
  5417 000022A1 49                      	dec cx
  5418 000022A2 29D9                    	sub cx, bx
  5419                                  
  5420                                  @@:
  5421 000022A4 4E                      	dec si
  5422 000022A5 39DE                    	cmp si, bx
  5423 000022A7 7209                    	jb @F
  5424 000022A9 803C2E                  	cmp byte [si], '.'
  5425 000022AC 75F6                    	jne @B
  5426                                  
  5427 000022AE 89F1                    	mov cx, si
  5428 000022B0 29D9                    	sub cx, bx
  5429                                  @@:
  5430 000022B2 E332                    	jcxz .help.no_name
  5431                                  @@:
  5432 000022B4 BA[E011]                	mov dx, imsg.help.1	; command-line help message
  5433 000022B7 E859F9                  	call init_putsz_cs
  5434 000022BA BA[3012]                	mov dx, imsg.help.1a
  5435 000022BD E853F9                  	call init_putsz_cs
  5436 000022C0 53                      	push bx
  5437 000022C1 89DA                    	mov dx, bx
  5438 000022C3 E891F9                  	call init_puts_ds
  5439 000022C6 BA[3A12]                	mov dx, imsg.help.2
  5440 000022C9 E847F9                  	call init_putsz_cs
  5441 000022CC 5A                      	pop dx
  5442 000022CD E887F9                  	call init_puts_ds
  5443 000022D0 BA[ED16]                	mov dx, imsg.help.3
  5444 000022D3 E83DF9                  	call init_putsz_cs
  5445 000022D6 1F                      	pop ds
  5446                                  .helpterminate:
  5447                                  %if _DEVICE && _APPLICATION
  5448 000022D7 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  5449 000022DC 7403E92AEA              	jnz init_device_error_late
  5450                                  %elif _DEVICE
  5451                                  	jmp init_device_error_late
  5452                                  %endif
  5453                                  %if _APPLICATION
  5454 000022E1 B8004C                  	mov ax, 4C00h
  5455 000022E4 CD21                    	int 21h			; done
  5456                                  %endif
  5457                                  
  5458                                  .help.no_name:
  5459 000022E6 0E                      	push cs
  5460 000022E7 1F                      	pop ds
  5461 000022E8 BB[D811]                	mov bx, imsg.help.defaultfilename
  5462 000022EB B90700                  	mov cx, imsg.help.defaultfilename.length
  5463 000022EE EBC4                    	jmp @B
  5464                                  
  5465                                  
  5466                                  		; Do the (proper) switches.
  5467 000022F0 AC                      .switch:lodsb
  5468 000022F1 3C3F                    	cmp al,'?'
  5469 000022F3 7503E93FFF              	je .help		; if -?
  5470 000022F8 E8A111                  	call init_capitalise
  5471                                  %if _EXTHELP
  5472 000022FB 3C55                    	cmp al, 'U'
  5473 000022FD 7503E9C510              	je switch_u
  5474                                  %endif
  5475                                  %if _CONFIG
  5476 00002302 3C49                    	cmp al, 'I'
  5477 00002304 7503E98400              	je .switch_i
  5478                                  %endif
  5479 00002309 3C43                    	cmp al, 'C'
  5480 0000230B 7503E99E00              	je .switch_c
  5481 00002310 3C50                    	cmp al, 'P'
  5482 00002312 7503E90901              	je .switch_p
  5483 00002317 3C46                    	cmp al, 'F'
  5484 00002319 7503E99D01              	je .switch_f
  5485 0000231E 3C45                    	cmp al, 'E'
  5486 00002320 7503E9C601              	je .switch_e
  5487 00002325 3C42                    	cmp al, 'B'
  5488 00002327 7503E9EB00              	je .switch_b
  5489 0000232C 3C41                    	cmp al, 'A'
  5490 0000232E 7503E91F06              	je .switch_a
  5491 00002333 3C54                    	cmp al, 'T'
  5492 00002335 7503E9CB02              	je .switch_t
  5493 0000233A 3C52                    	cmp al, 'R'
  5494 0000233C 7503E9CF06              	je .switch_r
  5495                                  %if _VXCHG
  5496 00002341 3C56                    	cmp al, 'V'
  5497 00002343 7503E9D001              	je .switch_v
  5498                                  %endif
  5499                                  %if _ALTVID
  5500 00002348 3C32                    	cmp al, '2'
  5501 0000234A 7503E92C02              	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 0000234F 3C44                    	cmp al, 'D'
  5515 00002351 7503E9EF01              	je .switch_d
  5516                                  %endif
  5517                                  
  5518                                  %if _EXTENSIONS
  5519 00002356 3C58                    	cmp al, 'X'
  5520 00002358 7503E9C603              	je .switch_x
  5521 0000235D 3C59                    	cmp al, 'Y'
  5522 0000235F 7503E97604              	je .switch_y
  5523                                  %endif
  5524                                  %if _HISTORY_SEPARATE_FIXED && _HISTORY
  5525 00002364 3C48                    	cmp al, 'H'
  5526 00002366 7503E92705              	je .switch_h
  5527                                  %endif
  5528                                  
  5529                                  		; Other switches may go here.
  5530 0000236B 2EA2[5317]              	mov [ cs:imsg.invalidswitch_a ], al
  5531 0000236F BA[4217]                	mov dx, imsg.invalidswitch	; Invalid switch
  5532                                  ..@init_cmdline_error:
  5533 00002372 E89EF8                  	call init_putsz_cs	; print string
  5534                                  %if _DEVICE && _APPLICATION
  5535 00002375 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  5536 0000237A 7403E98CE9              	jnz init_device_error_late
  5537                                  %elif _DEVICE
  5538                                  	jmp init_device_error_late
  5539                                  %endif
  5540                                  %if _APPLICATION
  5541 0000237F B8014C                  	mov ax, 4C01h		; Quit and return error status
  5542 00002382 CD21                    	int 21h
  5543                                  %endif
  5544                                  
  5545                                  ..@init_cmdline_switch_error:
  5546 00002384 2EA2[5F17]              	mov byte [cs:imsg.switch_x_error_a], al
  5547 00002388 BA[5717]                	mov dx, imsg.switch_x_error
  5548 0000238B EBE5                    	jmp ..@init_cmdline_error
  5549                                  
  5550                                  
  5551                                  %if _CONFIG
  5552                                  .switch_i:
  5553 0000238D AC                      	lodsb
  5554 0000238E 3C4E                    	cmp al, 'N'
  5555 00002390 7408                    	je @F
  5556 00002392 3C6E                    	cmp al, 'n'
  5557 00002394 7404                    	je @F
  5558 00002396 B049                    	mov al, 'I'
  5559 00002398 EBEA                    	jmp ..@init_cmdline_switch_error
  5560                                  
  5561                                  @@:
  5562 0000239A 8026[0100]FE            	clropt [internalflags3], dif3_input_cmdline
  5563 0000239F C606[0000]00            	mov byte [cmdline_buffer], 0
  5564 000023A4 2EC706[3A0E][0000]      	mov word [cs:cmdline_buffer_start], cmdline_buffer
  5565 000023AB E955FE                  	jmp .blankloop
  5566                                  %endif
  5567                                  
  5568                                  .switch_c:
  5569                                  @@:
  5570 000023AE AC                      	lodsb
  5571 000023AF 3C3D                    	cmp al, '='
  5572 000023B1 74FB                    	je @B
  5573 000023B3 3C3A                    	cmp al, ':'
  5574 000023B5 74F7                    	je @B
  5575                                  
  5576 000023B7 2E8B3E[3A0E]            	mov di, [cs:cmdline_buffer_start]
  5577 000023BC B400                    	mov ah, 0		; initialise to 0 = unquoted
  5578 000023BE A9                      	db __TEST_IMM16
  5579                                  .switch_c_loop:
  5580 000023BF AA                      	stosb
  5581                                  .switch_c_quoted:
  5582 000023C0 AC                      	lodsb
  5583                                  .switch_c_loop_after_semicolon:
  5584                                  
  5585 000023C1 3C0D                    	cmp al, 13
  5586 000023C3 7442                    	je .switch_c_eol
  5587 000023C5 38E0                    	cmp al, ah		; close quote mark ?
  5588 000023C7 7508                    	jne @F			; no -->
  5589 000023C9 3C00                    	cmp al, 0
  5590 000023CB 743A                    	je .switch_c_eol
  5591 000023CD B400                    	mov ah, 0		; continue unquoted
  5592 000023CF EBEF                    	jmp .switch_c_quoted	; and load next character -->
  5593                                  
  5594                                  @@:
  5595 000023D1 84E4                    	test ah, ah		; currently quoted ?
  5596 000023D3 7514                    	jnz .switch_c_not_blank	; yes -->
  5597                                  
  5598 000023D5 3C22                    	cmp al, '"'		; open quote mark ?
  5599 000023D7 7404                    	je @F
  5600 000023D9 3C27                    	cmp al, "'"
  5601 000023DB 7504                    	jne @FF			; no -->
  5602                                  @@:
  5603 000023DD 88C4                    	mov ah, al		; remember quoted state
  5604 000023DF EBDF                    	jmp .switch_c_quoted	; and load next character -->
  5605                                  
  5606                                  @@:
  5607 000023E1 3C20                    	cmp al, 32		; blank while unquoted ?
  5608 000023E3 7426                    	je .unquoted_blank
  5609 000023E5 3C09                    	cmp al, 9
  5610 000023E7 7422                    	je .unquoted_blank	; yes -->
  5611                                  .switch_c_not_blank:
  5612 000023E9 3C3B                    	cmp al, ';'		; unescaped semicolon ?
  5613 000023EB 750C                    	jne .switch_c_not_semicolon
  5614 000023ED B00D                    	mov al, 13		; yes, replace by CR
  5615 000023EF AA                      	stosb
  5616 000023F0 84E4                    	test ah, ah
  5617 000023F2 74CC                    	jz .switch_c_quoted
  5618 000023F4 E8EA10                  	call init_skipwhite
  5619 000023F7 EBC8                    	jmp .switch_c_loop_after_semicolon
  5620                                  
  5621                                  .switch_c_not_semicolon:
  5622 000023F9 3C5C                    	cmp al, '\'		; escape ?
  5623 000023FB 75C2                    	jne .switch_c_loop	; no, store literal -->
  5624 000023FD AC                      	lodsb			; load escaped character
  5625                                  				;  (may be backslash, semicolon, quote)
  5626 000023FE 3C0D                    	cmp al, 13		; guard against EOL
  5627 00002400 75BD                    	jne .switch_c_loop
  5628                                  .switch_c_error:
  5629 00002402 B043                    	mov al, 'C'
  5630 00002404 E97DFF                  	jmp ..@init_cmdline_switch_error
  5631                                  
  5632                                  .switch_c_eol:
  5633 00002407 84E4                    	test ah, ah		; in quoted state ?
  5634 00002409 75F7                    	jnz .switch_c_error	; yes, error -->
  5635                                  .unquoted_blank:
  5636 0000240B B000                    	mov al, 0
  5637 0000240D AA                      	stosb			; terminate command line buffer
  5638 0000240E 800E[0100]01            	setopt [internalflags3], dif3_input_cmdline
  5639 00002413 4E                      	dec si
  5640 00002414 E9ECFD                  	jmp .blankloop
  5641                                  
  5642                                  
  5643                                  .switch_b:
  5644 00002417 2EC606[6E2A]CC          	mov byte [cs:.breakpoint], 0CCh	; SMC in section init, set point
  5645 0000241D E9E3FD                  	jmp .blankloop
  5646                                  
  5647                                  
  5648                                  .switch_p:
  5649 00002420 AC                      	lodsb
  5650 00002421 E87810                  	call init_capitalise
  5651 00002424 BBFFFF                  	mov bx, 0FFFFh		; or 0FFFFh
  5652 00002427 89DA                    	mov dx, bx		; and 0FFFFh
  5653 00002429 4E                      	dec si
  5654 0000242A 3C20                    	cmp al, 32
  5655 0000242C 7478                    	je @F
  5656 0000242E 3C09                    	cmp al, 9
  5657 00002430 7474                    	je @F
  5658 00002432 3C0D                    	cmp al, 13
  5659 00002434 7470                    	je @F
  5660 00002436 46                      	inc si
  5661 00002437 3C2B                    	cmp al, '+'
  5662 00002439 746B                    	je @F
  5663 0000243B 42                      	inc dx			; and 0000h
  5664 0000243C 3C2D                    	cmp al, '-'
  5665 0000243E 7466                    	je @F
  5666                                  
  5667                                  .switch_p_not_plusminus:
  5668 00002440 3C53                    	cmp al, 'S'
  5669 00002442 751E                    	jne .switch_p_not_s
  5670 00002444 B700                    	mov bh, 00h		; or 0FFh
  5671 00002446 4A                      	dec dx			; and 0FFFFh
  5672 00002447 AC                      	lodsb
  5673 00002448 4E                      	dec si
  5674 00002449 3C20                    	cmp al, 32
  5675 0000244B 7459                    	je @F
  5676 0000244D 3C09                    	cmp al, 9
  5677 0000244F 7455                    	je @F
  5678 00002451 3C0D                    	cmp al, 13
  5679 00002453 7451                    	je @F
  5680 00002455 46                      	inc si
  5681 00002456 3C2B                    	cmp al, '+'
  5682 00002458 744C                    	je @F
  5683 0000245A B200                    	mov dl, 00h		; and 0FF00h
  5684 0000245C 3C2D                    	cmp al, '-'
  5685 0000245E 7446                    	je @F
  5686 00002460 EB3F                    	jmp .switch_p_error
  5687                                  
  5688                                  .switch_p_not_s:
  5689 00002462 3C45                    	cmp al, 'E'
  5690 00002464 751E                    	jne .switch_p_not_e
  5691 00002466 B300                    	mov bl, 00h		; or 0FF00h
  5692 00002468 4A                      	dec dx			; and 0FFFFh
  5693 00002469 AC                      	lodsb
  5694 0000246A 4E                      	dec si
  5695 0000246B 3C20                    	cmp al, 32
  5696 0000246D 7437                    	je @F
  5697 0000246F 3C09                    	cmp al, 9
  5698 00002471 7433                    	je @F
  5699 00002473 3C0D                    	cmp al, 13
  5700 00002475 742F                    	je @F
  5701 00002477 46                      	inc si
  5702 00002478 3C2B                    	cmp al, '+'
  5703 0000247A 742A                    	je @F
  5704 0000247C B600                    	mov dh, 00h		; and 00FFh
  5705 0000247E 3C2D                    	cmp al, '-'
  5706 00002480 7424                    	je @F
  5707 00002482 EB1D                    	jmp .switch_p_error
  5708                                  
  5709                                  .switch_p_not_e:
  5710 00002484 3C57                    	cmp al, 'W'
  5711 00002486 7519                    	jne .switch_p_not_w
  5712                                  		; bl = 0FFh
  5713 00002488 AC                      	lodsb
  5714 00002489 4E                      	dec si
  5715 0000248A 3C20                    	cmp al, 32
  5716 0000248C 7425                    	je @FF
  5717 0000248E 3C09                    	cmp al, 9
  5718 00002490 7421                    	je @FF
  5719 00002492 3C0D                    	cmp al, 13
  5720 00002494 741D                    	je @FF
  5721 00002496 46                      	inc si
  5722 00002497 3C2B                    	cmp al, '+'
  5723 00002499 7418                    	je @FF
  5724 0000249B B300                    	mov bl, 00h
  5725 0000249D 3C2D                    	cmp al, '-'
  5726 0000249F 7412                    	je @FF
  5727                                  	; jmp .switch_p_error
  5728                                  
  5729                                  .switch_p_not_w:
  5730                                  .switch_p_error:
  5731 000024A1 B050                    	mov al, 'P'
  5732 000024A3 E9DEFE                  	jmp ..@init_cmdline_switch_error
  5733                                  @@:
  5734 000024A6 2E091E[480E]            	or [cs:init_switch_p_low_pathsearch_high_guessextension], bx
  5735 000024AB 2E2116[480E]            	and [cs:init_switch_p_low_pathsearch_high_guessextension], dx
  5736 000024B0 E950FD                  	jmp .blankloop
  5737                                  
  5738                                  @@:
  5739 000024B3 2E881E[6C0E]            	mov [cs:init_switch_pw], bl
  5740 000024B8 E948FD                  	jmp .blankloop
  5741                                  
  5742                                  
  5743                                  .switch_f:
  5744 000024BB AC                      	lodsb
  5745 000024BC BB000C                  	mov bx, opt6_flat_binary + opt6_big_stack
  5746 000024BF 4E                      	dec si
  5747 000024C0 3C20                    	cmp al, 32
  5748 000024C2 741B                    	je @F
  5749 000024C4 3C09                    	cmp al, 9
  5750 000024C6 7417                    	je @F
  5751 000024C8 3C0D                    	cmp al, 13
  5752 000024CA 7413                    	je @F
  5753 000024CC BB0004                  	mov bx, opt6_flat_binary
  5754 000024CF 46                      	inc si
  5755 000024D0 3C2B                    	cmp al, '+'
  5756 000024D2 740B                    	je @F
  5757 000024D4 31DB                    	xor bx, bx
  5758 000024D6 3C2D                    	cmp al, '-'
  5759 000024D8 7405                    	je @F
  5760                                  .switch_f_error:
  5761 000024DA B046                    	mov al, 'F'
  5762 000024DC E9A5FE                  	jmp ..@init_cmdline_switch_error
  5763                                  @@:
  5764 000024DF 8026[0100]FB            	clropt [options6], opt6_flat_binary
  5765 000024E4 091E[0000]              	or word [options6], bx
  5766 000024E8 E918FD                  	jmp .blankloop
  5767                                  
  5768                                  .switch_e:
  5769 000024EB AC                      	lodsb
  5770 000024EC BB0008                  	mov bx, opt6_big_stack
  5771 000024EF 4E                      	dec si
  5772 000024F0 3C20                    	cmp al, 32
  5773 000024F2 7418                    	je @F
  5774 000024F4 3C09                    	cmp al, 9
  5775 000024F6 7414                    	je @F
  5776 000024F8 3C0D                    	cmp al, 13
  5777 000024FA 7410                    	je @F
  5778 000024FC 46                      	inc si
  5779 000024FD 3C2B                    	cmp al, '+'
  5780 000024FF 740B                    	je @F
  5781 00002501 31DB                    	xor bx, bx
  5782 00002503 3C2D                    	cmp al, '-'
  5783 00002505 7405                    	je @F
  5784                                  .switch_e_error:
  5785 00002507 B045                    	mov al, 'E'
  5786 00002509 E978FE                  	jmp ..@init_cmdline_switch_error
  5787                                  @@:
  5788 0000250C 8026[0100]F7            	clropt [options6], opt6_big_stack
  5789 00002511 091E[0000]              	or word [options6], bx
  5790 00002515 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 00002518 AC                      	lodsb
  5820 00002519 BB0100                  	mov bx, opt6_vv_mode
  5821 0000251C 4E                      	dec si
  5822 0000251D 3C20                    	cmp al, 32
  5823 0000251F 7418                    	je @F
  5824 00002521 3C09                    	cmp al, 9
  5825 00002523 7414                    	je @F
  5826 00002525 3C0D                    	cmp al, 13
  5827 00002527 7410                    	je @F
  5828 00002529 46                      	inc si
  5829 0000252A 3C2B                    	cmp al, '+'
  5830 0000252C 740B                    	je @F
  5831 0000252E 31DB                    	xor bx, bx
  5832 00002530 3C2D                    	cmp al, '-'
  5833 00002532 7405                    	je @F
  5834                                  .switch_v_error:
  5835 00002534 B056                    	mov al, 'V'
  5836 00002536 E94BFE                  	jmp ..@init_cmdline_switch_error
  5837                                  @@:
  5838 00002539 8026[0000]FE            	clropt [options6], opt6_vv_mode
  5839 0000253E 091E[0000]              	or word [options6], bx
  5840 00002542 E9BEFC                  	jmp .blankloop
  5841                                  %endif
  5842                                  
  5843                                  %if _DEBUG && _DEBUG_COND
  5844                                  .switch_d:
  5845 00002545 AC                      	lodsb
  5846 00002546 BB0001                  	mov bx, dif6_debug_mode
  5847 00002549 4E                      	dec si
  5848 0000254A 3C20                    	cmp al, 32
  5849 0000254C 7418                    	je @F
  5850 0000254E 3C09                    	cmp al, 9
  5851 00002550 7414                    	je @F
  5852 00002552 3C0D                    	cmp al, 13
  5853 00002554 7410                    	je @F
  5854 00002556 46                      	inc si
  5855 00002557 3C2B                    	cmp al, '+'
  5856 00002559 740B                    	je @F
  5857 0000255B 31DB                    	xor bx, bx
  5858 0000255D 3C2D                    	cmp al, '-'
  5859 0000255F 7405                    	je @F
  5860                                  .switch_d_error:
  5861 00002561 B044                    	mov al, 'D'
  5862 00002563 E91EFE                  	jmp ..@init_cmdline_switch_error
  5863                                  @@:
  5864 00002566 8026[0100]FE            	clropt [internalflags6], dif6_debug_mode
  5865 0000256B 8026[0100]FE            	clropt [options6], opt6_debug_mode
  5866 00002570 091E[0000]              	or word [internalflags6], bx
  5867 00002574 091E[0000]              	or word [options6], bx
  5868                                   %if dif6_debug_mode != opt6_debug_mode
  5869                                    %error Mismatch of flag and option
  5870                                   %endif
  5871 00002578 E988FC                  	jmp .blankloop
  5872                                  %else
  5873                                  .switch_d:
  5874                                  	lodsb
  5875                                   %if _DEBUG
  5876                                  	dec si
  5877                                  	cmp al, 32
  5878                                  	je @F
  5879                                  	cmp al, 9
  5880                                  	je @F
  5881                                  	cmp al, 13
  5882                                  	je @F
  5883                                  	inc si
  5884                                  	cmp al, '+'
  5885                                  @@:
  5886                                   %else
  5887                                  	cmp al, '-'
  5888                                   %endif
  5889                                  	je .blankloop
  5890                                  	mov al, 'D'
  5891                                  	jmp ..@init_cmdline_switch_error
  5892                                  %endif
  5893                                  
  5894                                  
  5895                                  %if _ALTVID
  5896                                  .switch_2:
  5897 0000257B AC                      	lodsb
  5898 0000257C B31E                    	mov bl, 1Eh			; "push ds"
  5899 0000257E 4E                      	dec si
  5900 0000257F 3C20                    	cmp al, 32
  5901 00002581 7418                    	je @F
  5902 00002583 3C09                    	cmp al, 9
  5903 00002585 7414                    	je @F
  5904 00002587 3C0D                    	cmp al, 13
  5905 00002589 7410                    	je @F
  5906 0000258B 46                      	inc si
  5907 0000258C 3C2B                    	cmp al, '+'
  5908 0000258E 740B                    	je @F
  5909 00002590 B3C3                    	mov bl, 0C3h			; "retn"
  5910 00002592 3C2D                    	cmp al, '-'
  5911 00002594 7405                    	je @F
  5912                                  .switch_2_error:
  5913 00002596 B032                    	mov al, '2'
  5914 00002598 E9E9FD                  	jmp ..@init_cmdline_switch_error
  5915                                  @@:
  5916 0000259B 8E06[0000]              	mov es, [code_seg]
  5917 0000259F 26881E[0000]            	mov byte [es:setscreen], bl
  5918 000025A4 16                      	push ss
  5919 000025A5 07                      	pop es
  5920 000025A6 80FBC3                  	cmp bl, 0C3h
  5921 000025A9 7445                    	je .noaltvid
  5922 000025AB B8001A                  	mov ax, 1A00h
  5923 000025AE CD10                    	int 10h
  5924 000025B0 3C1A                    	cmp al, 1Ah
  5925 000025B2 753C                    	jnz .noaltvid
  5926 000025B4 80FF00                  	cmp bh, 0
  5927 000025B7 7437                    	jz .noaltvid
  5928                                  
  5929 000025B9 1E                      	push ds
  5930 000025BA B84000                  	mov ax, 40h
  5931 000025BD 8ED8                    	mov ds, ax
  5932 000025BF 8B166300                	mov dx, [63h]
  5933 000025C3 1F                      	pop ds
  5934 000025C4 80F260                  	xor dl, 60h
  5935 000025C7 8916[0000]              	mov [oldcrtp], dx
  5936 000025CB B007                    	mov al, 7
  5937 000025CD 80FAB4                  	cmp dl, 0B4h
  5938 000025D0 7402                    	jz @F
  5939 000025D2 B003                    	mov al, 3
  5940                                  @@:
  5941 000025D4 A2[0000]                	mov [oldmode], al
  5942 000025D7 B00E                    	mov al, 0Eh
  5943 000025D9 EE                      	out dx, al
  5944 000025DA 42                      	inc dx
  5945 000025DB EC                      	in al, dx
  5946 000025DC 88C4                    	mov ah, al
  5947 000025DE 4A                      	dec dx
  5948 000025DF B00F                    	mov al, 0Fh
  5949 000025E1 EE                      	out dx, al
  5950 000025E2 42                      	inc dx
  5951 000025E3 EC                      	in al, dx
  5952 000025E4 B350                    	mov bl, 80
  5953 000025E6 F6F3                    	div bl
  5954 000025E8 86C4                    	xchg al, ah
  5955 000025EA A3[0000]                	mov [oldcsrpos], ax
  5956 000025ED E913FC                  	jmp .blankloop
  5957                                  
  5958                                  .noaltvid:
  5959 000025F0 BA[8B11]                	mov dx, imsg.noaltvid
  5960 000025F3 E81DF6                  	call init_putsz_cs
  5961 000025F6 8E06[0000]              	mov es, [code_seg]
  5962 000025FA 26C606[0000]C3          	mov byte [es:setscreen], 0C3h
  5963 00002600 16                      	push ss
  5964 00002601 07                      	pop es
  5965 00002602 E9FEFB                  	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 00002605 B3FF                    	mov bl, 0FFh
  6055 00002607 31FF                    	xor di, di
  6056                                  .switch_t_loop:
  6057                                  @@:
  6058 00002609 AC                      	lodsb
  6059 0000260A 3C3D                    	cmp al, '='
  6060 0000260C 74FB                    	je @B
  6061 0000260E 3C3A                    	cmp al, ':'
  6062 00002610 74F7                    	je @B
  6063 00002612 3C2C                    	cmp al, ','
  6064 00002614 74F3                    	je @B
  6065 00002616 4E                      	dec si
  6066 00002617 3C20                    	cmp al, 32
  6067 00002619 7503E9A800              	je @F
  6068 0000261E 3C09                    	cmp al, 9
  6069 00002620 7503E9A100              	je @F
  6070 00002625 3C0D                    	cmp al, 13
  6071 00002627 7503E99A00              	je @F
  6072 0000262C 46                      	inc si
  6073 0000262D 3C2B                    	cmp al, '+'
  6074 0000262F 7503E98C00              	je .switch_t_set
  6075 00002634 3C2D                    	cmp al, '-'
  6076 00002636 7503E98900              	je .switch_t_clear
  6077                                  
  6078 0000263B 2E8A1E[6D0E]            	mov bl, byte [cs:init_switch_t]
  6079 00002640 E8590E                  	call init_capitalise
  6080 00002643 3C49                    	cmp al, 'I'		; ignore ?
  6081 00002645 7508                    	jne .t_notignore
  6082 00002647 2EC606[6E0E]FF          	mov byte [cs:init_switch_t_ignore], 0FFh
  6083 0000264D EBBA                    	jmp @B
  6084                                  
  6085                                  .t_notignore:
  6086 0000264F 3C4F                    	cmp al, 'O'		; only ?
  6087 00002651 7508                    	jne .t_notonly
  6088 00002653 2EC606[6E0E]00          	mov byte [cs:init_switch_t_ignore], 0
  6089 00002659 EBAE                    	jmp @B
  6090                                  
  6091                                  .t_notonly:
  6092 0000265B 3C50                    	cmp al, 'P'		; point ?
  6093 0000265D 7508                    	jne .t_notpoint
  6094 0000265F 2EC606[6F0E]FF          	mov byte [cs:init_switch_t_break], 0FFh
  6095 00002665 EBA2                    	jmp @B
  6096                                  
  6097                                  .t_notpoint:
  6098 00002667 3C56                    	cmp al, 'V'		; variable ?
  6099 00002669 7508                    	jne .t_notvar
  6100 0000266B 2EC606[700E]FF          	mov byte [cs:init_switch_t_variable], 0FFh
  6101 00002671 EB96                    	jmp @B
  6102                                  
  6103                                  .t_notvar:
  6104 00002673 3C55                    	cmp al, 'U'		; enable UMA ?
  6105 00002675 7509                    	jne .t_notupper
  6106 00002677 2EC785[540E]0100        	mov word [cs:init_switch_t_umblink + di], 1
  6107 0000267E EB89                    	jmp @B
  6108                                  
  6109                                  .t_notupper:
  6110 00002680 3C4C                    	cmp al, 'L'		; restrict to LMA ?
  6111 00002682 750A                    	jne .t_notlower
  6112 00002684 2EC785[540E]0000        	mov word [cs:init_switch_t_umblink + di], 0
  6113 0000268B E97BFF                  	jmp @B
  6114                                  
  6115                                  .t_notlower:
  6116 0000268E 3C58                    	cmp al, 'X'
  6117 00002690 7505                    	jne .t_not_x
  6118 00002692 31FF                    	xor di, di
  6119 00002694 E972FF                  	jmp @B
  6120                                  
  6121                                  .t_not_x:
  6122 00002697 3C59                    	cmp al, 'Y'
  6123 00002699 7506                    	jne .t_not_y
  6124 0000269B BF0200                  	mov di, 2
  6125 0000269E E968FF                  	jmp @B
  6126                                  
  6127                                  .t_not_y:
  6128 000026A1 3C5A                    	cmp al, 'Z'
  6129 000026A3 7506                    	jne .t_not_z
  6130 000026A5 BF0400                  	mov di, 4
  6131 000026A8 E95EFF                  	jmp @B
  6132                                  
  6133                                  .t_not_z:
  6134 000026AB 3C30                    	cmp al, '0'
  6135 000026AD 720C                    	jb .switch_t_error
  6136 000026AF 3C39                    	cmp al, '9'
  6137 000026B1 7626                    	jbe .switch_t_numeric
  6138 000026B3 3C41                    	cmp al, 'A'
  6139 000026B5 7204                    	jb .switch_t_error
  6140 000026B7 3C46                    	cmp al, 'F'
  6141 000026B9 761E                    	jbe .switch_t_numeric
  6142                                  .switch_t_error:
  6143 000026BB B054                    	mov al, 'T'
  6144 000026BD E9C4FC                  	jmp ..@init_cmdline_switch_error
  6145                                  
  6146                                  .switch_t_set:
  6147 000026C0 B3FF                    	mov bl, 0FFh
  6148 000026C2 EB02                    	jmp @F
  6149                                  
  6150                                  .switch_t_clear:
  6151 000026C4 31DB                    	xor bx, bx
  6152                                  
  6153                                  @@:
  6154                                  %if _DEVICE
  6155 000026C6 84DB                    	test bl, bl
  6156 000026C8 7407                    	jz @F
  6157 000026CA F606[0200]40            	testopt [internalflags6], dif6_device_mode
  6158 000026CF 75EA                    	jnz .switch_t_error
  6159                                  @@:
  6160                                  %endif
  6161 000026D1 2E881E[6D0E]            	mov byte [cs:init_switch_t], bl
  6162 000026D6 E92AFB                  	jmp .blankloop
  6163                                  
  6164                                  .switch_t_numeric:
  6165 000026D9 31D2                    	xor dx, dx
  6166 000026DB A8                      	db __TEST_IMM8		; (skip lodsb)
  6167                                  @@:
  6168 000026DC AC                      	lodsb
  6169 000026DD 3C2C                    	cmp al, ','
  6170 000026DF 7439                    	je @F
  6171 000026E1 3C20                    	cmp al, 32
  6172 000026E3 7435                    	je @F
  6173 000026E5 3C09                    	cmp al, 9
  6174 000026E7 7431                    	je @F
  6175 000026E9 3C0D                    	cmp al, 13
  6176 000026EB 742D                    	je @F
  6177 000026ED E8AC0D                  	call init_capitalise
  6178 000026F0 B400                    	mov ah, 0
  6179 000026F2 3C30                    	cmp al, '0'			; decimal digit ?
  6180 000026F4 72C5                    	jb .switch_t_error
  6181 000026F6 3C39                    	cmp al, '9'
  6182 000026F8 7714                    	ja .switch_t_notdec
  6183 000026FA 2C30                    	sub al, '0'			; ax = digit
  6184                                  .switch_t_gotdigit:
  6185 000026FC 81FA0010                	cmp dx, 1000h
  6186 00002700 73B9                    	jae .switch_t_error
  6187 00002702 01D2                    	add dx, dx
  6188 00002704 01D2                    	add dx, dx
  6189 00002706 01D2                    	add dx, dx
  6190 00002708 01D2                    	add dx, dx			; * 16
  6191 0000270A 01C2                    	add dx, ax
  6192 0000270C EBCE                    	jmp @B
  6193                                  
  6194                                  .switch_t_notdec:
  6195 0000270E 3C41                    	cmp al, 'A'			; alphabetic ?
  6196 00002710 72A9                    	jb .switch_t_error
  6197 00002712 3C46                    	cmp al, 'F'
  6198 00002714 77A5                    	ja .switch_t_error
  6199 00002716 04C9                    	add al, 10 - 'A'		; ax = digit
  6200 00002718 EBE2                    	jmp .switch_t_gotdigit
  6201                                  
  6202                                  @@:
  6203 0000271A 2E8995[5A0E]            	mov word [cs:init_switch_t_strategy + di], dx
  6204 0000271F 4E                      	dec si
  6205 00002720 E9E6FE                  	jmp .switch_t_loop
  6206                                  
  6207                                  %if _EXTENSIONS
  6208                                  .switch_x:
  6209 00002723 BBF0FF                  	mov bx, _EXT_CODE_SIZE
  6210 00002726 AC                      	lodsb
  6211 00002727 3C09                    	cmp al, 9
  6212 00002729 7503E9A100              	je .switch_x_got
  6213 0000272E 3C20                    	cmp al, 32
  6214 00002730 7503E99A00              	je .switch_x_got
  6215 00002735 3C0D                    	cmp al, 13
  6216 00002737 7503E99300              	je .switch_x_got
  6217 0000273C 3C3A                    	cmp al, ':'
  6218 0000273E 7404                    	je @F
  6219 00002740 3C3D                    	cmp al, '='
  6220 00002742 7501                    	jne @FF
  6221                                  @@:
  6222 00002744 AC                      	lodsb
  6223                                  @@:
  6224 00002745 4E                      	dec si
  6225 00002746 0E                      	push cs
  6226 00002747 07                      	pop es
  6227 00002748 BA[640F]                	mov dx, imsg.max
  6228 0000274B E8F80C                  	call init_isstring?
  6229 0000274E 747E                    	je .switch_x_got.lodsb
  6230 00002750 BB0000                  	mov bx, 0
  6231 00002753 BA[680F]                	mov dx, imsg.min
  6232 00002756 E8ED0C                  	call init_isstring?
  6233 00002759 7473                    	je .switch_x_got.lodsb
  6234 0000275B BB0040                  	mov bx, _EXT_CODE_DEFAULT_SIZE
  6235 0000275E BA[6C0F]                	mov dx, imsg.default
  6236 00002761 E8E20C                  	call init_isstring?
  6237 00002764 7468                    	je .switch_x_got.lodsb
  6238                                  
  6239 00002766 BA1000                  	mov dx, 16
  6240 00002769 803C23                  	cmp byte [si], '#'
  6241 0000276C 7503                    	jne .switch_x_zero
  6242 0000276E 46                      	inc si
  6243 0000276F B20A                    	mov dl, 10
  6244                                  .switch_x_zero:
  6245 00002771 31DB                    	xor bx, bx
  6246                                  .switch_x_num:
  6247 00002773 AC                      	lodsb
  6248 00002774 3C20                    	cmp al, 32			; end of number ?
  6249 00002776 7450                    	je .switch_x_check
  6250 00002778 3C09                    	cmp al, 9
  6251 0000277A 744C                    	je .switch_x_check
  6252 0000277C 3C0D                    	cmp al, 13
  6253 0000277E 7448                    	je .switch_x_check		; yes -->
  6254 00002780 3C5F                    	cmp al, '_'			; separator ?
  6255 00002782 74EF                    	je .switch_x_num
  6256 00002784 3C23                    	cmp al, '#'			; base change ?
  6257 00002786 7432                    	je .switch_x_base
  6258 00002788 E8110D                  	call init_capitalise
  6259 0000278B B400                    	mov ah, 0
  6260 0000278D 3C30                    	cmp al, '0'			; decimal digit ?
  6261 0000278F 7224                    	jb .switch_x_error
  6262 00002791 3C39                    	cmp al, '9'
  6263 00002793 7712                    	ja .switch_x_notdec
  6264 00002795 2C30                    	sub al, '0'			; ax = digit
  6265                                  .switch_x_gotdigit:
  6266 00002797 93                      	xchg ax, bx			; ax = prior
  6267 00002798 52                      	push dx
  6268 00002799 F7E2                    	mul dx				; dx:ax = prior * base
  6269 0000279B 85D2                    	test dx, dx			; >= 64 KiB ?
  6270 0000279D 7516                    	jnz .switch_x_error		; error -->
  6271 0000279F 5A                      	pop dx
  6272 000027A0 93                      	xchg bx, ax			; return bx = prior
  6273 000027A1 01C3                    	add bx, ax			; prior += next
  6274 000027A3 7210                    	jc .switch_x_error
  6275 000027A5 EBCC                    	jmp .switch_x_num
  6276                                  
  6277                                  .switch_x_notdec:
  6278 000027A7 3C41                    	cmp al, 'A'			; alphabetic ?
  6279 000027A9 720A                    	jb .switch_x_error
  6280 000027AB 3C5A                    	cmp al, 'Z'
  6281 000027AD 7706                    	ja .switch_x_error
  6282 000027AF 04C9                    	add al, 10 - 'A'		; ax = digit
  6283 000027B1 39D0                    	cmp ax, dx
  6284 000027B3 72E2                    	jb .switch_x_gotdigit
  6285                                  	; jae .switch_x_error
  6286                                  .switch_x_error:
  6287                                  ..@init_cmdline_switch_x_error:
  6288 000027B5 B058                    	mov al, 'X'
  6289 000027B7 E9CAFB                  	jmp ..@init_cmdline_switch_error
  6290                                  
  6291                                  .switch_x_base:
  6292 000027BA 83FB02                  	cmp bx, 2
  6293 000027BD 72F6                    	jb .switch_x_error
  6294 000027BF 83FB24                  	cmp bx, 36
  6295 000027C2 77F1                    	ja .switch_x_error
  6296 000027C4 89DA                    	mov dx, bx
  6297 000027C6 EBA9                    	jmp .switch_x_zero
  6298                                  
  6299                                  .switch_x_check:
  6300 000027C8 83FBF0                  	cmp bx, _EXT_CODE_SIZE
  6301 000027CB 77E8                    	ja .switch_x_error
  6302                                  
  6303 000027CD A8                      	db __TEST_IMM8			; (skip lodsb)
  6304                                  .switch_x_got.lodsb:
  6305 000027CE AC                      	lodsb
  6306                                  .switch_x_got:
  6307 000027CF 1E                      	push ds
  6308 000027D0 07                      	pop es
  6309 000027D1 2E891E[420E]            	mov word [cs:init_ext_want], bx
  6310 000027D6 4E                      	dec si
  6311 000027D7 E929FA                  	jmp .blankloop
  6312                                  
  6313                                  
  6314                                  .switch_y:
  6315                                  %ifn _LINK
  6316                                  	mov bx, ext_data_max_size_equate
  6317                                  %else
  6318 000027DA BB[F0FF]                	mov bx, relocatedzero + 0FFF0h
  6319                                   wlcalc word_minusext_ext_data_area, equ $ - 2
  6320                                  %endif
  6321 000027DD AC                      	lodsb
  6322 000027DE 3C09                    	cmp al, 9
  6323 000027E0 7503E9A200              	je .switch_y_got
  6324 000027E5 3C20                    	cmp al, 32
  6325 000027E7 7503E99B00              	je .switch_y_got
  6326 000027EC 3C0D                    	cmp al, 13
  6327 000027EE 7503E99400              	je .switch_y_got
  6328 000027F3 3C3A                    	cmp al, ':'
  6329 000027F5 7404                    	je @F
  6330 000027F7 3C3D                    	cmp al, '='
  6331 000027F9 7501                    	jne @FF
  6332                                  @@:
  6333 000027FB AC                      	lodsb
  6334                                  @@:
  6335 000027FC 4E                      	dec si
  6336 000027FD 0E                      	push cs
  6337 000027FE 07                      	pop es
  6338 000027FF BA[640F]                	mov dx, imsg.max
  6339 00002802 E8410C                  	call init_isstring?
  6340 00002805 747F                    	je .switch_y_got.lodsb
  6341 00002807 BB0000                  	mov bx, 0
  6342 0000280A BA[680F]                	mov dx, imsg.min
  6343 0000280D E8360C                  	call init_isstring?
  6344 00002810 7474                    	je .switch_y_got.lodsb
  6345 00002812 BB0040                  	mov bx, _EXT_DATA_DEFAULT_SIZE
  6346 00002815 BA[6C0F]                	mov dx, imsg.default
  6347 00002818 E82B0C                  	call init_isstring?
  6348 0000281B 7469                    	je .switch_y_got.lodsb
  6349                                  
  6350 0000281D BA1000                  	mov dx, 16
  6351 00002820 803C23                  	cmp byte [si], '#'
  6352 00002823 7503                    	jne .switch_y_zero
  6353 00002825 46                      	inc si
  6354 00002826 B20A                    	mov dl, 10
  6355                                  .switch_y_zero:
  6356 00002828 31DB                    	xor bx, bx
  6357                                  .switch_y_num:
  6358 0000282A AC                      	lodsb
  6359 0000282B 3C20                    	cmp al, 32			; end of number ?
  6360 0000282D 7450                    	je .switch_y_check
  6361 0000282F 3C09                    	cmp al, 9
  6362 00002831 744C                    	je .switch_y_check
  6363 00002833 3C0D                    	cmp al, 13
  6364 00002835 7448                    	je .switch_y_check		; yes -->
  6365 00002837 3C5F                    	cmp al, '_'			; separator ?
  6366 00002839 74EF                    	je .switch_y_num
  6367 0000283B 3C23                    	cmp al, '#'			; base change ?
  6368 0000283D 7432                    	je .switch_y_base
  6369 0000283F E85A0C                  	call init_capitalise
  6370 00002842 B400                    	mov ah, 0
  6371 00002844 3C30                    	cmp al, '0'			; decimal digit ?
  6372 00002846 7224                    	jb .switch_y_error
  6373 00002848 3C39                    	cmp al, '9'
  6374 0000284A 7712                    	ja .switch_y_notdec
  6375 0000284C 2C30                    	sub al, '0'			; ax = digit
  6376                                  .switch_y_gotdigit:
  6377 0000284E 93                      	xchg ax, bx			; ax = prior
  6378 0000284F 52                      	push dx
  6379 00002850 F7E2                    	mul dx				; dx:ax = prior * base
  6380 00002852 85D2                    	test dx, dx			; >= 64 KiB ?
  6381 00002854 7516                    	jnz .switch_y_error		; error -->
  6382 00002856 5A                      	pop dx
  6383 00002857 93                      	xchg bx, ax			; return bx = prior
  6384 00002858 01C3                    	add bx, ax			; prior += next
  6385 0000285A 7210                    	jc .switch_y_error
  6386 0000285C EBCC                    	jmp .switch_y_num
  6387                                  
  6388                                  .switch_y_notdec:
  6389 0000285E 3C41                    	cmp al, 'A'			; alphabetic ?
  6390 00002860 720A                    	jb .switch_y_error
  6391 00002862 3C5A                    	cmp al, 'Z'
  6392 00002864 7706                    	ja .switch_y_error
  6393 00002866 04C9                    	add al, 10 - 'A'		; ax = digit
  6394 00002868 39D0                    	cmp ax, dx
  6395 0000286A 72E2                    	jb .switch_y_gotdigit
  6396                                  	; jae .switch_y_error
  6397                                  .switch_y_error:
  6398                                  ..@init_cmdline_switch_y_error:
  6399 0000286C B059                    	mov al, 'Y'
  6400 0000286E E913FB                  	jmp ..@init_cmdline_switch_error
  6401                                  
  6402                                  .switch_y_base:
  6403 00002871 83FB02                  	cmp bx, 2
  6404 00002874 72F6                    	jb .switch_y_error
  6405 00002876 83FB24                  	cmp bx, 36
  6406 00002879 77F1                    	ja .switch_y_error
  6407 0000287B 89DA                    	mov dx, bx
  6408 0000287D EBA9                    	jmp .switch_y_zero
  6409                                  
  6410                                  .switch_y_check:
  6411                                  %ifn _LINK
  6412                                  	cmp bx, ext_data_max_size_equate
  6413                                  %else
  6414 0000287F 81FB[F0FF]              	cmp bx, strict word relocatedzero + 0FFF0h
  6415                                   wlcalc word_minusext_ext_data_area, equ $ - 2
  6416                                  %endif
  6417 00002883 77E7                    	ja .switch_y_error
  6418                                  
  6419 00002885 A8                      	db __TEST_IMM8			; (skip lodsb)
  6420                                  .switch_y_got.lodsb:
  6421 00002886 AC                      	lodsb
  6422                                  .switch_y_got:
  6423 00002887 1E                      	push ds
  6424 00002888 07                      	pop es
  6425 00002889 2E891E[440E]            	mov word [cs:init_extdata_want], bx
  6426 0000288E 4E                      	dec si
  6427 0000288F E971F9                  	jmp .blankloop
  6428                                  %endif
  6429                                  
  6430                                  
  6431                                  %if _HISTORY_SEPARATE_FIXED && _HISTORY
  6432                                  .switch_h:
  6433 00002892 BBF0FF                  	mov bx, 0FFF0h
  6434 00002895 AC                      	lodsb
  6435 00002896 3C09                    	cmp al, 9
  6436 00002898 7503E9AA00              	je .switch_h_got
  6437 0000289D 3C20                    	cmp al, 32
  6438 0000289F 7503E9A300              	je .switch_h_got
  6439 000028A4 3C0D                    	cmp al, 13
  6440 000028A6 7503E99C00              	je .switch_h_got
  6441 000028AB 3C3A                    	cmp al, ':'
  6442 000028AD 7404                    	je @F
  6443 000028AF 3C3D                    	cmp al, '='
  6444 000028B1 7501                    	jne @FF
  6445                                  @@:
  6446 000028B3 AC                      	lodsb
  6447                                  @@:
  6448 000028B4 4E                      	dec si
  6449 000028B5 0E                      	push cs
  6450 000028B6 07                      	pop es
  6451 000028B7 BA[640F]                	mov dx, imsg.max
  6452 000028BA E8890B                  	call init_isstring?
  6453 000028BD 7503E98400              	je .switch_h_got.lodsb
  6454 000028C2 BB0401                  	mov bx, 260
  6455 000028C5 BA[680F]                	mov dx, imsg.min
  6456 000028C8 E87B0B                  	call init_isstring?
  6457 000028CB 7479                    	je .switch_h_got.lodsb
  6458 000028CD BB0020                  	mov bx, _HISTORY_WANT_SIZE
  6459 000028D0 BA[6C0F]                	mov dx, imsg.default
  6460 000028D3 E8700B                  	call init_isstring?
  6461 000028D6 746E                    	je .switch_h_got.lodsb
  6462                                  
  6463 000028D8 BA1000                  	mov dx, 16
  6464 000028DB 803C23                  	cmp byte [si], '#'
  6465 000028DE 7503                    	jne .switch_h_zero
  6466 000028E0 46                      	inc si
  6467 000028E1 B20A                    	mov dl, 10
  6468                                  .switch_h_zero:
  6469 000028E3 31DB                    	xor bx, bx
  6470                                  .switch_h_num:
  6471 000028E5 AC                      	lodsb
  6472 000028E6 3C20                    	cmp al, 32			; end of number ?
  6473 000028E8 7450                    	je .switch_h_check
  6474 000028EA 3C09                    	cmp al, 9
  6475 000028EC 744C                    	je .switch_h_check
  6476 000028EE 3C0D                    	cmp al, 13
  6477 000028F0 7448                    	je .switch_h_check		; yes -->
  6478 000028F2 3C5F                    	cmp al, '_'			; separator ?
  6479 000028F4 74EF                    	je .switch_h_num
  6480 000028F6 3C23                    	cmp al, '#'			; base change ?
  6481 000028F8 7432                    	je .switch_h_base
  6482 000028FA E89F0B                  	call init_capitalise
  6483 000028FD B400                    	mov ah, 0
  6484 000028FF 3C30                    	cmp al, '0'			; decimal digit ?
  6485 00002901 7224                    	jb .switch_h_error
  6486 00002903 3C39                    	cmp al, '9'
  6487 00002905 7712                    	ja .switch_h_notdec
  6488 00002907 2C30                    	sub al, '0'			; ax = digit
  6489                                  .switch_h_gotdigit:
  6490 00002909 93                      	xchg ax, bx			; ax = prior
  6491 0000290A 52                      	push dx
  6492 0000290B F7E2                    	mul dx				; dx:ax = prior * base
  6493 0000290D 85D2                    	test dx, dx			; >= 64 KiB ?
  6494 0000290F 7516                    	jnz .switch_h_error		; error -->
  6495 00002911 5A                      	pop dx
  6496 00002912 93                      	xchg bx, ax			; return bx = prior
  6497 00002913 01C3                    	add bx, ax			; prior += next
  6498 00002915 7210                    	jc .switch_h_error
  6499 00002917 EBCC                    	jmp .switch_h_num
  6500                                  
  6501                                  .switch_h_notdec:
  6502 00002919 3C41                    	cmp al, 'A'			; alphabetic ?
  6503 0000291B 720A                    	jb .switch_h_error
  6504 0000291D 3C5A                    	cmp al, 'Z'
  6505 0000291F 7706                    	ja .switch_h_error
  6506 00002921 04C9                    	add al, 10 - 'A'		; ax = digit
  6507 00002923 39D0                    	cmp ax, dx
  6508 00002925 72E2                    	jb .switch_h_gotdigit
  6509                                  	; jae .switch_h_error
  6510                                  .switch_h_error:
  6511                                  ..@init_cmdline_switch_h_error:
  6512 00002927 B048                    	mov al, 'H'
  6513 00002929 E958FA                  	jmp ..@init_cmdline_switch_error
  6514                                  
  6515                                  .switch_h_base:
  6516 0000292C 83FB02                  	cmp bx, 2
  6517 0000292F 72F6                    	jb .switch_h_error
  6518 00002931 83FB24                  	cmp bx, 36
  6519 00002934 77F1                    	ja .switch_h_error
  6520 00002936 89DA                    	mov dx, bx
  6521 00002938 EBA9                    	jmp .switch_h_zero
  6522                                  
  6523                                  .switch_h_check:
  6524 0000293A 83FBF0                  	cmp bx, 0FFF0h
  6525 0000293D 77E8                    	ja .switch_h_error
  6526 0000293F 81FB0401                	cmp bx, 260
  6527 00002943 72E2                    	jb .switch_h_error
  6528                                  
  6529 00002945 A8                      	db __TEST_IMM8			; (skip lodsb)
  6530                                  .switch_h_got.lodsb:
  6531 00002946 AC                      	lodsb
  6532                                  .switch_h_got:
  6533 00002947 1E                      	push ds
  6534 00002948 07                      	pop es
  6535 00002949 2E891E[460E]            	mov word [cs:init_history_want], bx
  6536 0000294E 4E                      	dec si
  6537 0000294F E9B1F8                  	jmp .blankloop
  6538                                  %endif
  6539                                  
  6540                                  
  6541                                  .switch_a:
  6542 00002952 BB0060                  	mov bx, _AUXBUFFMAXSIZE
  6543 00002955 AC                      	lodsb
  6544 00002956 3C09                    	cmp al, 9
  6545 00002958 7503E9A800              	je .switch_a_got
  6546 0000295D 3C20                    	cmp al, 32
  6547 0000295F 7503E9A100              	je .switch_a_got
  6548 00002964 3C0D                    	cmp al, 13
  6549 00002966 7503E99A00              	je .switch_a_got
  6550 0000296B 3C3A                    	cmp al, ':'
  6551 0000296D 7404                    	je @F
  6552 0000296F 3C3D                    	cmp al, '='
  6553 00002971 7501                    	jne @FF
  6554                                  @@:
  6555 00002973 AC                      	lodsb
  6556                                  @@:
  6557 00002974 4E                      	dec si
  6558 00002975 0E                      	push cs
  6559 00002976 07                      	pop es
  6560 00002977 BA[640F]                	mov dx, imsg.max
  6561 0000297A E8C90A                  	call init_isstring?
  6562 0000297D 7503E98200              	je .switch_a_got.lodsb
  6563 00002982 BB1020                  	mov bx, _AUXBUFFSIZE
  6564 00002985 BA[680F]                	mov dx, imsg.min
  6565 00002988 E8BB0A                  	call init_isstring?
  6566 0000298B 7477                    	je .switch_a_got.lodsb
  6567                                  	; default == minimum
  6568 0000298D BA[6C0F]                	mov dx, imsg.default
  6569 00002990 E8B30A                  	call init_isstring?
  6570 00002993 746F                    	je .switch_a_got.lodsb
  6571                                  
  6572 00002995 BA1000                  	mov dx, 16
  6573 00002998 803C23                  	cmp byte [si], '#'
  6574 0000299B 7503                    	jne .switch_a_zero
  6575 0000299D 46                      	inc si
  6576 0000299E B20A                    	mov dl, 10
  6577                                  .switch_a_zero:
  6578 000029A0 31DB                    	xor bx, bx
  6579                                  .switch_a_num:
  6580 000029A2 AC                      	lodsb
  6581 000029A3 3C20                    	cmp al, 32			; end of number ?
  6582 000029A5 7450                    	je .switch_a_check
  6583 000029A7 3C09                    	cmp al, 9
  6584 000029A9 744C                    	je .switch_a_check
  6585 000029AB 3C0D                    	cmp al, 13
  6586 000029AD 7448                    	je .switch_a_check		; yes -->
  6587 000029AF 3C5F                    	cmp al, '_'			; separator ?
  6588 000029B1 74EF                    	je .switch_a_num
  6589 000029B3 3C23                    	cmp al, '#'			; base change ?
  6590 000029B5 7432                    	je .switch_a_base
  6591 000029B7 E8E20A                  	call init_capitalise
  6592 000029BA B400                    	mov ah, 0
  6593 000029BC 3C30                    	cmp al, '0'			; decimal digit ?
  6594 000029BE 7224                    	jb .switch_a_error
  6595 000029C0 3C39                    	cmp al, '9'
  6596 000029C2 7712                    	ja .switch_a_notdec
  6597 000029C4 2C30                    	sub al, '0'			; ax = digit
  6598                                  .switch_a_gotdigit:
  6599 000029C6 93                      	xchg ax, bx			; ax = prior
  6600 000029C7 52                      	push dx
  6601 000029C8 F7E2                    	mul dx				; dx:ax = prior * base
  6602 000029CA 85D2                    	test dx, dx			; >= 64 KiB ?
  6603 000029CC 7516                    	jnz .switch_a_error		; error -->
  6604 000029CE 5A                      	pop dx
  6605 000029CF 93                      	xchg bx, ax			; return bx = prior
  6606 000029D0 01C3                    	add bx, ax			; prior += next
  6607 000029D2 7210                    	jc .switch_a_error
  6608 000029D4 EBCC                    	jmp .switch_a_num
  6609                                  
  6610                                  .switch_a_notdec:
  6611 000029D6 3C41                    	cmp al, 'A'			; alphabetic ?
  6612 000029D8 720A                    	jb .switch_a_error
  6613 000029DA 3C5A                    	cmp al, 'Z'
  6614 000029DC 7706                    	ja .switch_a_error
  6615 000029DE 04C9                    	add al, 10 - 'A'		; ax = digit
  6616 000029E0 39D0                    	cmp ax, dx
  6617 000029E2 72E2                    	jb .switch_a_gotdigit
  6618                                  	; jae .switch_a_error
  6619                                  .switch_a_error:
  6620                                  ..@init_cmdline_switch_a_error:
  6621 000029E4 B041                    	mov al, 'A'
  6622 000029E6 E99BF9                  	jmp ..@init_cmdline_switch_error
  6623                                  
  6624                                  .switch_a_base:
  6625 000029E9 83FB02                  	cmp bx, 2
  6626 000029EC 72F6                    	jb .switch_a_error
  6627 000029EE 83FB24                  	cmp bx, 36
  6628 000029F1 77F1                    	ja .switch_a_error
  6629 000029F3 89DA                    	mov dx, bx
  6630 000029F5 EBA9                    	jmp .switch_a_zero
  6631                                  
  6632                                  .switch_a_check:
  6633 000029F7 81FB1020                	cmp bx, _AUXBUFFSIZE
  6634 000029FB 72E7                    	jb .switch_a_error
  6635 000029FD 81FB0060                	cmp bx, _AUXBUFFMAXSIZE
  6636 00002A01 77E1                    	ja .switch_a_error
  6637                                  
  6638 00002A03 A8                      	db __TEST_IMM8			; (skip lodsb)
  6639                                  .switch_a_got.lodsb:
  6640 00002A04 AC                      	lodsb
  6641                                  .switch_a_got:
  6642 00002A05 1E                      	push ds
  6643 00002A06 07                      	pop es
  6644 00002A07 2E891E[400E]            	mov word [cs:init_auxbuff_want], bx
  6645 00002A0C 4E                      	dec si
  6646 00002A0D E9F3F7                  	jmp .blankloop
  6647                                  
  6648                                  
  6649                                  .switch_r:
  6650 00002A10 AC                      	lodsb
  6651 00002A11 3C3A                    	cmp al, ':'
  6652 00002A13 7404                    	je @F
  6653 00002A15 3C3D                    	cmp al, '='
  6654 00002A17 7501                    	jne @FF
  6655                                  @@:
  6656 00002A19 A8                      	db __TEST_IMM8			; skip dec
  6657                                  @@:
  6658 00002A1A 4E                      	dec si
  6659 00002A1B BA1000                  	mov dx, 16
  6660 00002A1E 31DB                    	xor bx, bx
  6661                                  .switch_r_num:
  6662 00002A20 AC                      	lodsb
  6663 00002A21 3C20                    	cmp al, 32			; end of number ?
  6664 00002A23 743E                    	je .switch_r_check
  6665 00002A25 3C09                    	cmp al, 9
  6666 00002A27 743A                    	je .switch_r_check
  6667 00002A29 3C0D                    	cmp al, 13
  6668 00002A2B 7436                    	je .switch_r_check		; yes -->
  6669 00002A2D 3C5F                    	cmp al, '_'			; separator ?
  6670 00002A2F 74EF                    	je .switch_r_num
  6671 00002A31 E8680A                  	call init_capitalise
  6672 00002A34 B400                    	mov ah, 0
  6673 00002A36 3C30                    	cmp al, '0'			; decimal digit ?
  6674 00002A38 7224                    	jb .switch_r_error
  6675 00002A3A 3C39                    	cmp al, '9'
  6676 00002A3C 7712                    	ja .switch_r_notdec
  6677 00002A3E 2C30                    	sub al, '0'			; ax = digit
  6678                                  .switch_r_gotdigit:
  6679 00002A40 93                      	xchg ax, bx			; ax = prior
  6680 00002A41 52                      	push dx
  6681 00002A42 F7E2                    	mul dx				; dx:ax = prior * base
  6682 00002A44 85D2                    	test dx, dx			; >= 64 KiB ?
  6683 00002A46 7516                    	jnz .switch_r_error		; error -->
  6684 00002A48 5A                      	pop dx
  6685 00002A49 93                      	xchg bx, ax			; return bx = prior
  6686 00002A4A 01C3                    	add bx, ax			; prior += next
  6687 00002A4C 7210                    	jc .switch_r_error
  6688 00002A4E EBD0                    	jmp .switch_r_num
  6689                                  
  6690                                  .switch_r_notdec:
  6691 00002A50 3C41                    	cmp al, 'A'			; alphabetic ?
  6692 00002A52 720A                    	jb .switch_r_error
  6693 00002A54 3C5A                    	cmp al, 'Z'
  6694 00002A56 7706                    	ja .switch_r_error
  6695 00002A58 04C9                    	add al, 10 - 'A'		; ax = digit
  6696 00002A5A 39D0                    	cmp ax, dx
  6697 00002A5C 72E2                    	jb .switch_r_gotdigit
  6698                                  	; jae .switch_r_error
  6699                                  .switch_r_error:
  6700                                  ..@init_cmdline_switch_r_error:
  6701 00002A5E B052                    	mov al, 'R'
  6702 00002A60 E921F9                  	jmp ..@init_cmdline_switch_error
  6703                                  
  6704                                  .switch_r_check:
  6705                                  .switch_r_got:
  6706 00002A63 1E                      	push ds
  6707 00002A64 07                      	pop es
  6708 00002A65 2E891E[4E0E]            	mov word [cs:init_switch_r], bx
  6709 00002A6A 4E                      	dec si
  6710 00002A6B E995F7                  	jmp .blankloop
  6711                                  
  6712                                  
  6713                                  .noswitches:
  6714                                  .breakpoint:
  6715 00002A6E 90                      	nop			; SMC in section init
  6716                                  		; Feed the remaining command line to the 'n' command.
  6717 00002A6F 4E                      	dec si
  6718 00002A70 E83F0A                  	call init_skipcomma
  6719 00002A73 4E                      	dec si
  6720 00002A74 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 00002A75 89F3                <1> 	mov bx, si
    31 00002A77 31D2                <1> 	xor dx, dx
    32 00002A79 B000                <1> 	mov al, 0
    33                              <1> @@:
    34 00002A7B 3C2F                <1> 	cmp al, '/'
    35 00002A7D 7410                <1> 	je .slash
    36 00002A7F 3C5C                <1> 	cmp al, '\'
    37 00002A81 740C                <1> 	je .slash
    38 00002A83 3C3A                <1> 	cmp al, ':'
    39 00002A85 7408                <1> 	je .colon
    40 00002A87 3C2E                <1> 	cmp al, '.'
    41 00002A89 7507                <1> 	jne .next
    42                              <1> .dot:
    43 00002A8B B201                <1> 	mov dl, 1		; set dl (fn with dot)
    44 00002A8D EB03                <1> 	jmp .next
    45                              <1> 
    46                              <1> .slash:
    47                              <1> .colon:
    48 00002A8F BA0001              <1> 	mov dx, 100h		; set dh (is a pathname), reset dl (fn with dot)
    49                              <1> .next:
    50 00002A92 AC                  <1> 	lodsb
    51 00002A93 E8A108              <1> 	call init_ifsep
    52 00002A96 75E3                <1> 	jne @B
    53 00002A98 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 00002A99 16                  <1> 	push ss
    57 00002A9A 07                  <1> 	pop es
    58 00002A9B 89F1                <1> 	mov cx, si
    59 00002A9D 29D9                <1> 	sub cx, bx		; es:bx -> name, cx = length
    60                              <1> 
    61                              <1> 
    62                              <1> init_check_warn_extension:
    63 00002A9F 52                  <1> 	push dx
    64 00002AA0 06                  <1> 	push es
    65                              <1> 
    66 00002AA1 84D2                <1> 	test dl, dl		; last component has a dot ?
    67 00002AA3 7433                <1> 	jz .done		; no, do not warn -->
    68                              <1> 
    69 00002AA5 2ED006[6C0E]        <1> 	rol byte [init_data_segment:init_switch_pw], 1
    70                              <1> internaldatarelocation
    71 00002AAA 732C                <1> 	jnc .done		; warning disabled -->
    72                              <1> 
    73 00002AAC 83F904              <1> 	cmp cx, 4		; can fit an expected extension ?
    74 00002AAF 7221                <1> 	jb .warn		; no, warn -->
    75                              <1> 
    76 00002AB1 83EE04              <1> 	sub si, 4		; -> possible extension
    77 00002AB4 0E                  <1> 	push init_data_segment
    78 00002AB5 07                  <1> 	pop es
    79 00002AB6 BF[720E]            <1> 	mov di, imsg.no_warn_extensions
    80                              <1> internaldatarelocation		; es:di -> allowed extensions
    81                              <1> .loop:
    82 00002AB9 B000                <1> 	mov al, 0
    83 00002ABB 2E864504            <1> 	xchg byte [init_data_segment:di+4], al
    84                              <1> 				; NUL-terminate the candidate extension
    85 00002ABF 50                  <1> 	push ax
    86 00002AC0 89FA                <1> 	mov dx, di
    87 00002AC2 E88109              <1> 	call init_isstring?	; is it this one ?
    88 00002AC5 58                  <1> 	pop ax
    89 00002AC6 2E884504            <1> 	mov byte [init_data_segment:di+4], al
    90                              <1> 				; restore next extension text
    91 00002ACA 740C                <1> 	je .done		; yes, do not warn -->
    92 00002ACC AF                  <1> 	scasw
    93 00002ACD AF                  <1> 	scasw			; di += 4
    94 00002ACE 84C0                <1> 	test al, al		; was last ?
    95 00002AD0 75E7                <1> 	jnz .loop
    96                              <1> .warn:
    97 00002AD2 BA[8C0E]            <1> 	mov dx, imsg.extension_warning
    98                              <1> internaldatarelocation
    99 00002AD5 E83BF1              <1> 	call init_putsz_cs
   100                              <1> 
   101                              <1> .done:
   102 00002AD8 07                  <1> 	pop es
   103 00002AD9 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 00002ADA 2E833E[480E]00      <1> 	cmp word [init_data_segment:		init_switch_p_low_pathsearch_high_guessextension], strict byte 0
   116                              <1> internaldatarelocation -3
   117 00002AE0 740E                <1> 	je .done_j
   118                              <1> 
   119 00002AE2 E30C                <1> 	jcxz .done_j		; if no filename given -->
   120                              <1> 
   121                              <1> 				; es:bx -> name, cx = length
   122 00002AE4 BF[0000]            <1> 	mov di, relocated(while_buffer)
   123                              <1> linkdatarelocation while_buffer	; ss:while_buffer -> prefix, ss:di -> after end
   124                              <1> 
   125 00002AE7 E86F08              <1> 	call init_check_filename
   126 00002AEA 736C                <1> 	jnc .found
   127                              <1> 
   128 00002AEC 84F6                <1> 	test dh, dh
   129 00002AEE 7403                <1> 	jz @F
   130                              <1> .done_j:
   131 00002AF0 E99800              <1> 	jmp .done
   132                              <1> @@:
   133 00002AF3 2ED006[480E]        <1> 	rol byte [init_data_segment:init_switch_p_pathsearch], 1
   134                              <1> internaldatarelocation
   135 00002AF8 73F6                <1> 	jnc .done_j
   136                              <1> 
   137                              <1> %if _DEVICE && _APPLICATION && ! ELD && ! INTERC3
   138 00002AFA F606[0200]40        <1> 	testopt [internalflags6], dif6_device_mode
   139 00002AFF 7505                <1> 	jnz .device
   140                              <1> %endif
   141                              <1> %if _APPLICATION || ELD || INTERC3
   142 00002B01 A12C00              <1> 	mov ax, [2Ch]
   143                              <1>  %if _DEVICE && ! ELD && ! INTERC3
   144 00002B04 EB03                <1> 	jmp @F
   145                              <1>  %endif
   146                              <1> %endif
   147                              <1> 
   148                              <1> %if _DEVICE && ! ELD && ! INTERC3
   149                              <1> .device:
   150 00002B06 E88DE1              <1> 	call init_device_get_environment
   151                              <1> @@:
   152                              <1> %endif
   153                              <1> 
   154 00002B09 51                  <1> 	push cx
   155 00002B0A BF[870E]            <1> 	mov di, imsg.varpath
   156                              <1> internaldatarelocation
   157 00002B0D B90500              <1> 	mov cx, imsg.varpath.length
   158 00002B10 E88C08              <1> 	call init_findvar
   159 00002B13 7275                <1> 	jc .done_pop
   160                              <1> 
   161                              <1> .pathloop:
   162 00002B15 56                  <1> 	push si
   163 00002B16 B98000              <1> 	mov cx, 128		; put a limit
   164                              <1> @@:
   165 00002B19 AC                  <1> 	lodsb			; get next text
   166 00002B1A 3C3B                <1> 	cmp al, ';'		; separator ?
   167 00002B1C 7408                <1> 	je @F			; yes -->
   168 00002B1E 3C00                <1> 	cmp al, 0		; separator ?
   169 00002B20 7404                <1> 	je @F			; yes -->
   170 00002B22 E2F5                <1> 	loop @B			; loop up to limit
   171 00002B24 EB5D                <1> 	jmp .pathtoolong	; error -->
   172                              <1> @@:
   173 00002B26 89F1                <1> 	mov cx, si
   174 00002B28 49                  <1> 	dec cx			; -> terminator
   175 00002B29 5E                  <1> 	pop si			; -> content text
   176 00002B2A 29F1                <1> 	sub cx, si		; = length excluding terminator
   177 00002B2C 16                  <1> 	 push ss
   178 00002B2D 07                  <1> 	 pop es
   179 00002B2E BF[0000]            <1> 	mov di, relocated(while_buffer)
   180                              <1> linkdatarelocation while_buffer	; es:di -> buffer
   181                              <1> 
   182 00002B31 B000                <1> 	mov al, 0		; no backslash if empty
   183 00002B33 E30A                <1> 	jcxz @FFF		; skip loop if empty -->
   184                              <1> @@:
   185 00002B35 AC                  <1> 	lodsb			; load from variable
   186 00002B36 3C2F                <1> 	cmp al, '/'		; forward slash ?
   187 00002B38 7502                <1> 	jne @F			; no -->
   188 00002B3A B05C                <1> 	mov al, '\'		; replace by backslash
   189                              <1> @@:
   190 00002B3C AA                  <1> 	stosb			; store
   191 00002B3D E2F6                <1> 	loop @BB		; loop for cx = count
   192                              <1> @@:
   193 00002B3F 3C5C                <1> 	cmp al, '\'		; trailing backslash ?
   194 00002B41 7403                <1> 	je @F			; yes -->
   195 00002B43 B05C                <1> 	mov al, '\'
   196 00002B45 AA                  <1> 	stosb			; append it
   197                              <1> @@:
   198 00002B46 59                  <1> 	pop cx
   199                              <1> 
   200 00002B47 1E                  <1> 	push ds
   201 00002B48 56                  <1> 	push si
   202                              <1> 				; ss = es, es:bx -> name, cx = length
   203                              <1> 				; ss:while_buffer -> prefix, ss:di -> after end
   204 00002B49 E80D08              <1> 	call init_check_filename
   205 00002B4C 5E                  <1> 	pop si
   206 00002B4D 1F                  <1> 	pop ds			; ds:si -> terminator of path element
   207 00002B4E 7308                <1> 	jnc .found
   208                              <1> 
   209 00002B50 AC                  <1> 	lodsb			; get terminator
   210 00002B51 3C3B                <1> 	cmp al, ';'		; semicolon ?
   211 00002B53 7536                <1> 	jne .done		; no -->
   212 00002B55 51                  <1> 	push cx
   213 00002B56 EBBD                <1> 	jmp .pathloop		; try next -->
   214                              <1> 
   215                              <1> 
   216                              <1> .found:
   217 00002B58 16                  <1> 	push ss
   218 00002B59 1F                  <1> 	pop ds			; ds => PSP
   219 00002B5A 5E                  <1> 	 pop si
   220 00002B5B 01CE                <1> 	add si, cx		; ds:si -> behind original name
   221 00002B5D 16                  <1> 	push ss
   222 00002B5E 07                  <1> 	pop es
   223 00002B5F 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 00002B60 EB07                <1> 	jmp @FF			; skip store on first iteration
   230                              <1> 
   231                              <1> @@:
   232 00002B62 81FF[FEFF]          <1> 	cmp di, relocated(while_buffer.end) - 2
   233                              <1> linkdatarelocation while_buffer.end
   234 00002B66 7713                <1> 	ja .toolong
   235 00002B68 AA                  <1> 	stosb
   236                              <1> @@:
   237 00002B69 AC                  <1> 	lodsb
   238 00002B6A 3C00                <1> 	cmp al, 0
   239 00002B6C 7404                <1> 	je @F
   240 00002B6E 3C0D                <1> 	cmp al, 13
   241 00002B70 75F0                <1> 	jne @BB
   242                              <1> @@:			; (targeted from both directions)
   243 00002B72 B00D                <1> 	mov al, 13
   244 00002B74 AA                  <1> 	stosb
   245 00002B75 BE[0000]            <1> 	mov si, relocated(while_buffer)
   246                              <1> linkdatarelocation while_buffer
   247 00002B78 56                  <1> 	 push si		; offset for N/K command (kk)
   248 00002B79 EB10                <1> 	jmp .done
   249                              <1> 
   250                              <1> .toolong:
   251 00002B7B BA[DA0E]            <1> 	mov dx, imsg.kktoolong
   252                              <1> internaldatarelocation
   253 00002B7E E892F0              <1> 	call init_putsz_cs
   254 00002B81 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 00002B83 BA[1C0F]            <1> 	mov dx, imsg.pathtoolong
   262                              <1> internaldatarelocation
   263 00002B86 E88AF0              <1> 	call init_putsz_cs
   264                              <1> 
   265 00002B89 58                  <1> 	pop ax			; (discard si)
   266                              <1> .done_pop:
   267 00002B8A 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 00002B8B 16                      	push ss
  6751 00002B8C 1F                      	pop ds
  6752                                   %if _DEVICE
  6753 00002B8D F606[0200]40            	testopt [internalflags6], dif6_device_mode
  6754 00002B92 755F                    	jnz .skip
  6755                                   %endif
  6756 00002B94 2EC706[380E]8000        	mov word [cs:mem_envsize], paras(app_env_size)
  6757 00002B9B 8B16[0000]              	mov dx, word [envseg]		; => pseudo MCB
  6758 00002B9F 42                      	inc dx				; => space for environment
  6759 00002BA0 A12C00                  	mov ax, word [2Ch]
  6760 00002BA3 1E                      	push ds
  6761 00002BA4 85C0                    	test ax, ax
  6762 00002BA6 7446                    	jz @F
  6763 00002BA8 8ED8                    	mov ds, ax
  6764 00002BAA 8EC2                    	mov es, dx
  6765 00002BAC 31FF                    	xor di, di
  6766 00002BAE 31F6                    	xor si, si
  6767                                  .loop_env:
  6768 00002BB0 E80B08                  	call init_nextvar
  6769 00002BB3 75FB                    	jne .loop_env
  6770 00002BB5 46                      	inc si
  6771 00002BB6 AD                      	lodsw
  6772 00002BB7 83F801                  	cmp ax, 1
  6773 00002BBA 7504                    	jne .notrail
  6774 00002BBC E8FF07                  	call init_nextvar
  6775 00002BBF A9                      	db __TEST_IMM16
  6776                                  .notrail:
  6777 00002BC0 4E                      	dec si
  6778 00002BC1 4E                      	dec si
  6779 00002BC2 81FEEE07                	cmp si, app_env_size - 16 - 2
  6780 00002BC6 7610                    	jbe .copy_env
  6781 00002BC8 BA[8F0F]                	mov dx, imsg.app_env_too_large
  6782 00002BCB E845F0                  	call init_putsz_cs
  6783                                  .no_reloc:
  6784 00002BCE 2EC606[710E]FF          	mov byte [cs:app_env_allocation], 0FFh
  6785 00002BD4 8CDA                    	mov dx, ds
  6786 00002BD6 EB16                    	jmp @F
  6787                                  
  6788                                  .copy_env:
  6789 00002BD8 2ED006[700E]            	rol byte [cs:init_switch_t_variable], 1
  6790 00002BDD 72EF                    	jc .no_reloc
  6791 00002BDF 89F1                    	mov cx, si
  6792 00002BE1 31F6                    	xor si, si
  6793 00002BE3 F3A4                    	rep movsb
  6794 00002BE5 31C0                    	xor ax, ax
  6795 00002BE7 AB                      	stosw
  6796 00002BE8 1E                      	push ds
  6797 00002BE9 07                      	pop es
  6798 00002BEA B449                    	mov ah, 49h
  6799 00002BEC CD21                    	int 21h
  6800                                  @@:
  6801 00002BEE 1F                      	pop ds
  6802 00002BEF 89162C00                	mov word [2Ch], dx
  6803                                  
  6804                                  .skip:
  6805                                  %endif
  6806                                  
  6807                                  
  6808                                  init_relocate_init:
  6809 00002BF3 16                      	push ss
  6810 00002BF4 1F                      	pop ds
  6811 00002BF5 16                      	push ss
  6812 00002BF6 07                      	pop es
  6813                                  %if _AUXBUFFSIZE != _AUXBUFFMAXSIZE
  6814 00002BF7 2EA1[400E]              	mov ax, word [cs:init_auxbuff_want]
  6815 00002BFB 83C00F                  	add ax, 15			; cannot carry, ax <= _AUXBUFFMAXSIZE
  6816 00002BFE 24F0                    	and al, 0F0h
  6817 00002C00 B104                    	mov cl, 4
  6818 00002C02 89C3                    	mov bx, ax
  6819 00002C04 D3EB                    	shr bx, cl
  6820 00002C06 BEFFFD                  	mov si, - paras(_AUXBUFFSIZE)
  6821 00002C09 01DE                    	add si, bx			; want size - init size = how much to add
  6822 00002C0B 31D2                    	xor dx, dx			; always positive
  6823                                  %else
  6824                                  	xor si, si			; = 0
  6825                                  	xor dx, dx
  6826                                  %endif
  6827                                  
  6828                                  %if _EXTENSIONS
  6829 00002C0D 2EA1[440E]              	mov ax, word [cs:init_extdata_want]
  6830 00002C11 83C00F                  	add ax, 15
  6831 00002C14 24F0                    	and al, 0F0h
  6832                                  
  6833 00002C16 B104                    	mov cl, 4
  6834 00002C18 89C3                    	mov bx, ax
  6835 00002C1A D3EB                    	shr bx, cl
  6836 00002C1C BF00FC                  	mov di, - paras(_EXT_DATA_BOOT_SIZE)
  6837 00002C1F 01DF                    	add di, bx			; want size - init size = how much to add
  6838                                  					;  negative if to subtract
  6839 00002C21 19DB                    	sbb bx, bx			; -1 if >= 0 to add
  6840 00002C23 F7D3                    	not bx				; -1 if negative
  6841 00002C25 01FE                    	add si, di
  6842 00002C27 11DA                    	adc dx, bx			; add positive or negative dword
  6843                                  
  6844                                  
  6845 00002C29 2EA1[420E]              	mov ax, word [cs:init_ext_want]
  6846 00002C2D 83C00F                  	add ax, 15
  6847 00002C30 24F0                    	and al, 0F0h
  6848                                  
  6849 00002C32 B104                    	mov cl, 4
  6850 00002C34 89C3                    	mov bx, ax
  6851 00002C36 D3EB                    	shr bx, cl
  6852 00002C38 BF00FE                  	mov di, - paras(_EXT_CODE_INIT_SIZE)
  6853 00002C3B 01DF                    	add di, bx			; want size - init size = how much to add
  6854                                  					;  negative if to subtract
  6855 00002C3D 19DB                    	sbb bx, bx			; -1 if >= 0 to add
  6856 00002C3F F7D3                    	not bx
  6857 00002C41 01FE                    	add si, di
  6858 00002C43 11DA                    	adc dx, bx			; add positive or negative dword
  6859                                  %endif
  6860                                  
  6861                                  %if _HISTORY_SEPARATE_FIXED && _HISTORY
  6862 00002C45 2EA1[460E]              	mov ax, word [cs:init_history_want]
  6863 00002C49 83C00F                  	add ax, 15
  6864 00002C4C 24F0                    	and al, 0F0h
  6865                                  
  6866 00002C4E B104                    	mov cl, 4
  6867 00002C50 89C3                    	mov bx, ax
  6868 00002C52 D3EB                    	shr bx, cl
  6869 00002C54 BF00FE                  	mov di, - paras(historysegment_size)
  6870 00002C57 01DF                    	add di, bx			; want size - init size = how much to add
  6871                                  					;  negative if to subtract
  6872 00002C59 19DB                    	sbb bx, bx			; -1 if >= 0 to add
  6873 00002C5B F7D3                    	not bx				; -1 if negative
  6874 00002C5D 01FE                    	add si, di
  6875 00002C5F 11DA                    	adc dx, bx			; add positive or negative dword
  6876                                  %endif
  6877                                  
  6878 00002C61 85D2                    	test dx, dx			; add paras is negative ?
  6879 00002C63 7567                    	jnz .done			; yes -->
  6880 00002C65 85F6                    	test si, si
  6881 00002C67 7463                    	jz .done			; if to add == 0 -->
  6882                                  
  6883                                  .reloc:
  6884 00002C69 2E0336[360E]            	add si, word [cs:memsize]	; = new memsize
  6885 00002C6E 7256                    	jc .error
  6886 00002C70 8CD8                    	mov ax, ds
  6887 00002C72 01C6                    	add si, ax			; => past want alloc
  6888 00002C74 7250                    	jc .error
  6889                                  %if _DEVICE
  6890 00002C76 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  6891 00002C7B 7403                    	jz @F
  6892 00002C7D 46                      	inc si				; account for container paragraph
  6893 00002C7E 7446                    	jz .error
  6894                                  @@:
  6895                                  %endif
  6896 00002C80 8CCB                    	mov bx, cs
  6897 00002C82 39DE                    	cmp si, bx			; below-or-equal cs ?
  6898 00002C84 7646                    	jbe .done			; yes, no need to relocate -->
  6899                                  
  6900                                  %ifn _LINK
  6901                                  	mov cx, init_size_p		; size of init
  6902                                  %else
  6903 00002C86 B9[0000]                	mov cx, relocatedzero + 0
  6904                                   wlcalc word_wrt_INIT_extpara_behind_init, equ $ - 2
  6905                                  %endif
  6906 00002C89 01CB                    	add bx, cx			; => minimum init reloc target
  6907 00002C8B 39DE                    	cmp si, bx
  6908 00002C8D 7602                    	jbe .havetarget
  6909 00002C8F 89F3                    	mov bx, si			; => needed init reloc target
  6910                                  
  6911                                  .havetarget:
  6912 00002C91 89DA                    	mov dx, bx			; dx => target
  6913 00002C93 01CB                    	add bx, cx			; bx => behind target
  6914 00002C95 722F                    	jc .error
  6915                                  %if _DEVICE
  6916 00002C97 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  6917 00002C9C 7409                    	jz @F
  6918 00002C9E 2E3B1E[3E0E]            	cmp bx, word [cs:dev_memory_end]; enough space ?
  6919 00002CA3 7721                    	ja .error			; no -->
  6920 00002CA5 EB14                    	jmp .movp
  6921                                  
  6922                                  @@:
  6923                                  %endif
  6924 00002CA7 8CD8                    	mov ax, ds
  6925 00002CA9 29C3                    	sub bx, ax			; = amount paragraphs needed
  6926 00002CAB 2E891E[520E]            	mov word [cs:init_target_size], bx
  6927 00002CB0 2E891E[500E]            	mov word [cs:init_base_size], bx
  6928 00002CB5 B44A                    	mov ah, 4Ah
  6929 00002CB7 CD21                    	int 21h				; resize memory block = es
  6930 00002CB9 720B                    	jc .error			; if error -->
  6931                                  
  6932                                  .movp:
  6933 00002CBB 8CC8                    	mov ax, cs
  6934 00002CBD E8C2EE                  	call init_movp			; move init
  6935 00002CC0 52                      	push dx				; => relocated init
  6936 00002CC1 E86AD5                  	call init_retf			; ttansfer control
  6937 00002CC4 EB06                    	jmp .done			; done
  6938                                  
  6939                                  .error:
  6940 00002CC6 BA[4610]                	mov dx, imsg.init_relocate_failure
  6941 00002CC9 E9A6F6                  	jmp ..@init_cmdline_error
  6942                                  
  6943                                  .done:
  6944                                  
  6945                                  
  6946                                  init_change_auxbuff_size:
  6947 00002CCC 16                      	push ss
  6948 00002CCD 1F                      	pop ds
  6949 00002CCE 16                      	push ss
  6950 00002CCF 07                      	pop es
  6951                                  %if _AUXBUFFSIZE != _AUXBUFFMAXSIZE
  6952 00002CD0 2EA1[400E]              	mov ax, word [cs:init_auxbuff_want]
  6953 00002CD4 83C00F                  	add ax, 15			; cannot carry, ax <= _AUXBUFFMAXSIZE
  6954 00002CD7 24F0                    	and al, 0F0h
  6955                                  
  6956 00002CD9 89C7                    	mov di, ax
  6957 00002CDB 83EF18                  	sub di, 8 * 3
  6958 00002CDE A3[0000]                	mov word [auxbuff_current_size], ax
  6959 00002CE1 893E[0000]              	mov word [auxbuff_current_size_minus_24], di
  6960                                  
  6961 00002CE5 B104                    	mov cl, 4
  6962 00002CE7 89C3                    	mov bx, ax
  6963 00002CE9 D3EB                    	shr bx, cl
  6964 00002CEB BEFFFD                  	mov si, - paras(_AUXBUFFSIZE)
  6965 00002CEE 01DE                    	add si, bx
  6966 00002CF0 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 00002CF2 2EFF16[3C0E]            	call near [cs:init_layout]
  6976 00002CF7 16                      	push ss
  6977 00002CF8 1F                      	pop ds
  6978 00002CF9 16                      	push ss
  6979 00002CFA 07                      	pop es
  6980 00002CFB 7303E9E4FC              	jc ..@init_cmdline_switch_a_error
  6981                                  @@:
  6982                                  %endif
  6983                                  
  6984                                  
  6985                                  %if _EXTENSIONS
  6986                                  init_change_extdata_size_and_init:
  6987 00002D00 2EA1[440E]              	mov ax, word [cs:init_extdata_want]
  6988 00002D04 83C00F                  	add ax, 15
  6989 00002D07 24F0                    	and al, 0F0h
  6990 00002D09 A3[0000]                	mov word [extdata_size], ax
  6991                                  
  6992 00002D0C 89C1                    	mov cx, ax
  6993 00002D0E 81E90040                	sub cx, fromparas(paras(_EXT_DATA_BOOT_SIZE))
  6994 00002D12 010E[0000]              	add word [entryseg_size], cx
  6995                                  
  6996 00002D16 B104                    	mov cl, 4
  6997 00002D18 89C3                    	mov bx, ax
  6998 00002D1A D3EB                    	shr bx, cl
  6999 00002D1C BE0004                  	mov si, paras(_EXT_DATA_BOOT_SIZE)
  7000 00002D1F 29DE                    	sub si, bx			; init size - want
  7001                                  		; negative if larger want than init
  7002 00002D21 7503E9A700              	jz .keep			; if to keep init size
  7003 00002D26 19FF                    	sbb di, di			; -1 if negative
  7004 00002D28 F7D7                    	not di				; -1 if positive (smaller want than init)
  7005 00002D2A 2E893E[4C0E]            	mov word [cs:relocate_down], di	; relocating down if smaller want
  7006                                  
  7007 00002D2F 2E8B0E[360E]            	mov cx, word [cs:memsize]	; how many paragraphs do we have
  7008                                   %if _DEVICE
  7009 00002D34 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  7010 00002D39 7401                    	jz @F
  7011 00002D3B 41                      	inc cx				; account for container paragraph
  7012                                  @@:
  7013                                   %endif
  7014 00002D3C 2E2936[360E]            	sub word [cs:memsize], si
  7015                                  
  7016 00002D41 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 00002D43 05[0000]                	add ax, strict word relocatedzero + 0
  7024                                   wlcalc word_wrt_@@lDEBUG_DATA_ENTRY@_extpara_end_of_datastack, equ $ - 2
  7025 00002D46 89C2                    	mov dx, ax
  7026 00002D48 29F2                    	sub dx, si
  7027 00002D4A 81E9[0000]              	sub cx, strict word relocatedzero + 0
  7028                                   wlcalc word_wrt_@@lDEBUG_DATA_ENTRY@_extpara_end_of_datastack, equ $ - 2
  7029                                  %endif
  7030 00002D4E E831EE                  	call init_movp
  7031                                  
  7032                                   %if _DEVICE
  7033 00002D51 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  7034 00002D56 7416                    	jz @F
  7035                                  
  7036 00002D58 2936[0000]              	sub word [device_mcb_paragraphs], si
  7037                                  					; fix our variable
  7038 00002D5C 2936[0000]              	sub word [alloc_size], si	; this one too
  7039 00002D60 8E06[0000]              	mov es, word [reg_es]
  7040 00002D64 8B1E[0000]              	mov bx, word [reg_ebx]		; -> device request header
  7041 00002D68 26297710                	sub word [es:bx + 0Eh + 2], si	; -> behind memory in use
  7042 00002D6C 16                      	push ss
  7043 00002D6D 07                      	pop es
  7044                                   %endif
  7045                                  @@:
  7046                                  
  7047 00002D6E F7DE                    	neg si
  7048                                  
  7049                                  %if _HISTORY_SEPARATE_FIXED && _HISTORY
  7050                                  .relocate_history:
  7051 00002D70 0136[0000]              	add word [history.segorsel + soaSegSel], si
  7052                                  %if _PM
  7053 00002D74 0136[0200]              	add word [history.segorsel + soaSegment], si
  7054                                  %endif
  7055                                  %endif
  7056                                  
  7057                                  %if _APP_ENV_SIZE || _DEV_ENV_SIZE
  7058                                  .relocate_env:
  7059 00002D78 2ED006[710E]            	rol byte [cs:app_env_allocation], 1
  7060 00002D7D 7204                    	jc @F
  7061 00002D7F 01362C00                	add word [2Ch], si
  7062                                  @@:
  7063 00002D83 833E[0000]00            	cmp word [envseg], 0
  7064 00002D88 7404                    	je @F
  7065 00002D8A 0136[0000]              	add word [envseg], si
  7066                                  @@:
  7067                                  %endif
  7068                                  
  7069                                  %if _EXTENSIONS
  7070                                  .relocate_ext:
  7071 00002D8E 0136[0000]              	add word [extseg], si
  7072                                  %endif
  7073                                  
  7074                                  .relocate_code:
  7075 00002D92 A1[0000]                	mov ax, word [code_seg]
  7076 00002D95 89C2                    	mov dx, ax
  7077 00002D97 01F2                    	add dx, si
  7078                                  
  7079 00002D99 8EC2                    	mov es, dx
  7080 00002D9B 0136[0000]              	add word [code_seg], si
  7081                                  %if _DUALCODE
  7082 00002D9F 0136[0000]              	add word [code2_seg], si
  7083 00002DA3 8B16[0000]              	mov dx, word [code2_seg]
  7084 00002DA7 56                      	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 00002DA8 06                      	push es
  7093 00002DA9 8EC2                    	mov es, dx
  7094 00002DAB 5A                      	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 00002DAC 5E                      	pop si
  7111                                  %endif
  7112                                  
  7113                                  %if _AREAS && _AREAS_HOOK_CLIENT
  7114 00002DAD 89F0                    	mov ax, si
  7115 00002DAF 2E8B16[4C0E]            	mov dx, word [cs:relocate_down]
  7116 00002DB4 E8E607                  	call add_to_areas_linear_code1.dxax
  7117                                   %if _DUALCODE && _EXPRDUALCODE
  7118 00002DB7 89F0                    	mov ax, si
  7119 00002DB9 2E8B16[4C0E]            	mov dx, word [cs:relocate_down]
  7120 00002DBE E80808                  	call add_to_areas_linear_code2.dxax
  7121                                   %endif
  7122                                  %endif
  7123                                  
  7124                                  
  7125                                  .relocate_auxbuff:
  7126 00002DC1 0136[0000]              	add word [auxbuff_segorsel + soaSegSel], si
  7127                                  %if _PM
  7128 00002DC5 0136[0200]              	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 00002DC9 0136[0000]              	add word [messageseg], si
  7139                                   %if _HELP_COMPRESSED && ! _PM
  7140                                  	add word [hshrink_memory_source.segment], si
  7141                                   %endif
  7142                                  %endif
  7143                                  
  7144                                  .keep:
  7145 00002DCD 8B0E[0000]              	mov cx, word [extdata_size]
  7146 00002DD1 16                      	push ss
  7147 00002DD2 07                      	pop es
  7148 00002DD3 BF[0000]                	mov di, ext_data_area
  7149 00002DD6 B000                    	mov al, 0
  7150 00002DD8 F3AA                    	rep stosb			; init ext data area
  7151                                  %endif
  7152                                  
  7153                                  
  7154                                  %if _EXTENSIONS
  7155                                  init_change_ext_size:
  7156 00002DDA 2EA1[420E]              	mov ax, word [cs:init_ext_want]
  7157 00002DDE 83C00F                  	add ax, 15
  7158 00002DE1 24F0                    	and al, 0F0h
  7159 00002DE3 A3[0000]                	mov word [extseg_size], ax
  7160                                  
  7161 00002DE6 B104                    	mov cl, 4
  7162 00002DE8 89C3                    	mov bx, ax
  7163 00002DEA D3EB                    	shr bx, cl
  7164 00002DEC BE0002                  	mov si, paras(_EXT_CODE_INIT_SIZE)
  7165 00002DEF 29DE                    	sub si, bx			; init size - want
  7166                                  		; negative if larger want than init
  7167 00002DF1 7441                    	jz @F				; if to keep init size
  7168                                  
  7169 00002DF3 2E2936[360E]            	sub word [cs:memsize], si
  7170                                  
  7171 00002DF8 85F6                    	test si, si
  7172 00002DFA 7911                    	jns .smaller
  7173 00002DFC BF0020                  	mov di, _EXT_CODE_INIT_SIZE
  7174 00002DFF 8E06[0000]              	mov es, word [extseg]
  7175 00002E03 8B0E[0000]              	mov cx, word [extseg_size]
  7176 00002E07 29F9                    	sub cx, di
  7177 00002E09 B000                    	mov al, 0
  7178 00002E0B F3AA                    	rep stosb			; init trailer
  7179                                  .smaller:
  7180                                  
  7181                                   %if _DEVICE
  7182 00002E0D F606[0200]40            	testopt [internalflags6], dif6_device_mode
  7183 00002E12 7420                    	jz @F
  7184                                  
  7185 00002E14 2936[0000]              	sub word [device_mcb_paragraphs], si
  7186                                  					; fix our variable
  7187 00002E18 2936[0000]              	sub word [alloc_size], si	; this one too
  7188 00002E1C 8CD8                    	mov ax, ds			; => PSP
  7189 00002E1E 2E0306[360E]            	add ax, word [cs:memsize]	; => where to place container sig
  7190 00002E23 E848DD                  	call init_dev_place_container_signature
  7191                                  					; CHG: es, di, cx, si
  7192                                  					; ax => behind memory used for device
  7193 00002E26 8E06[0000]              	mov es, word [reg_es]
  7194 00002E2A 8B1E[0000]              	mov bx, word [reg_ebx]		; -> device request header
  7195 00002E2E 26894710                	mov word [es:bx + 0Eh + 2], ax	; -> behind memory in use
  7196 00002E32 16                      	push ss
  7197 00002E33 07                      	pop es
  7198                                   %endif
  7199                                  @@:
  7200                                  %endif
  7201                                  
  7202                                  
  7203                                  %if _HISTORY_SEPARATE_FIXED && _HISTORY
  7204                                  init_change_history_size:
  7205 00002E34 2EA1[460E]              	mov ax, word [cs:init_history_want]
  7206 00002E38 83C00F                  	add ax, 15
  7207 00002E3B 24F0                    	and al, 0F0h
  7208 00002E3D A3[0000]                	mov word [historyseg_size], ax
  7209 00002E40 89C3                    	mov bx, ax
  7210                                  
  7211 00002E42 48                      	dec ax
  7212 00002E43 48                      	dec ax
  7213 00002E44 A3[0000]                	mov word [history.first], ax
  7214 00002E47 A3[0000]                	mov word [history.last], ax
  7215                                  
  7216 00002E4A B104                    	mov cl, 4
  7217 00002E4C D3EB                    	shr bx, cl
  7218 00002E4E BE0002                  	mov si, paras(historysegment_size)
  7219 00002E51 29DE                    	sub si, bx			; init size - want
  7220                                  		; negative if larger want than init
  7221 00002E53 7467                    	jz .keep			; if to keep init size
  7222 00002E55 19FF                    	sbb di, di			; -1 if negative
  7223 00002E57 F7D7                    	not di				; -1 if positive (smaller want than init)
  7224 00002E59 2E893E[4C0E]            	mov word [cs:relocate_down], di	; relocating down if smaller want
  7225                                  
  7226 00002E5E 2E8B0E[360E]            	mov cx, word [cs:memsize]	; how many paragraphs do we have
  7227                                   %if _DEVICE
  7228 00002E63 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  7229 00002E68 7401                    	jz @F
  7230 00002E6A 41                      	inc cx				; account for container paragraph
  7231                                  @@:
  7232                                   %endif
  7233 00002E6B 2E2936[360E]            	sub word [cs:memsize], si
  7234                                  
  7235 00002E70 8CD8                    	mov ax, ds
  7236 00002E72 01C1                    	add cx, ax
  7237 00002E74 A1[0000]                	mov ax, word [history.segorsel + soaSegSel]
  7238 00002E77 89C2                    	mov dx, ax
  7239 00002E79 050002                  	add ax, paras(historysegment_size)
  7240                                  					; => source
  7241 00002E7C 01DA                    	add dx, bx			; => destination
  7242 00002E7E 29C1                    	sub cx, ax
  7243 00002E80 E8FFEC                  	call init_movp
  7244                                  
  7245                                   %if _DEVICE
  7246 00002E83 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  7247 00002E88 7416                    	jz @F
  7248                                  
  7249 00002E8A 2936[0000]              	sub word [device_mcb_paragraphs], si
  7250                                  					; fix our variable
  7251 00002E8E 2936[0000]              	sub word [alloc_size], si	; this one too
  7252 00002E92 8E06[0000]              	mov es, word [reg_es]
  7253 00002E96 8B1E[0000]              	mov bx, word [reg_ebx]		; -> device request header
  7254 00002E9A 26297710                	sub word [es:bx + 0Eh + 2], si	; -> behind memory in use
  7255 00002E9E 16                      	push ss
  7256 00002E9F 07                      	pop es
  7257                                   %endif
  7258                                  @@:
  7259                                  
  7260 00002EA0 F7DE                    	neg si
  7261                                  
  7262                                  %if _APP_ENV_SIZE || _DEV_ENV_SIZE
  7263                                  .relocate_env:
  7264 00002EA2 2ED006[710E]            	rol byte [cs:app_env_allocation], 1
  7265 00002EA7 7204                    	jc @F
  7266 00002EA9 01362C00                	add word [2Ch], si
  7267                                  @@:
  7268 00002EAD 833E[0000]00            	cmp word [envseg], 0
  7269 00002EB2 7404                    	je @F
  7270 00002EB4 0136[0000]              	add word [envseg], si
  7271                                  @@:
  7272                                  %endif
  7273                                  
  7274                                  %if _EXTENSIONS
  7275                                  .relocate_ext:
  7276 00002EB8 0136[0000]              	add word [extseg], si
  7277                                  %endif
  7278                                  
  7279                                  .keep:
  7280 00002EBC 8B0E[0000]              	mov cx, word [historyseg_size]
  7281 00002EC0 8E06[0000]              	mov es, word [history.segorsel + soaSegSel]
  7282 00002EC4 31FF                    	xor di, di
  7283 00002EC6 B000                    	mov al, 0
  7284 00002EC8 F3AA                    	rep stosb			; init history buffer
  7285                                  %endif
  7286                                  
  7287                                  
  7288                                  init_relocate:
  7289 00002ECA 2ED006[6D0E]            	rol byte [cs:init_switch_t], 1
  7290 00002ECF 7203E9FA01              	jnc .done_outer
  7291                                  %if _DEVICE
  7292 00002ED4 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  7293 00002ED9 7403E9EA01              	jnz .error_outer
  7294                                  %endif
  7295                                  
  7296 00002EDE 2ED006[6F0E]            	rol byte [cs:init_switch_t_break], 1
  7297 00002EE3 7301                    	jnc @F
  7298 00002EE5 CC                      	int3
  7299                                  @@:
  7300                                  
  7301 00002EE6 B80258                  		mov ax, 5802h			; Get UMB link state
  7302 00002EE9 CD21                    		int 21h
  7303 00002EEB 30E4                    		xor ah, ah
  7304 00002EED 50                      		push ax				; Save UMB link state
  7305 00002EEE B80058                  		mov ax, 5800h			; Get allocation strategy
  7306 00002EF1 CD21                    		int 21h
  7307 00002EF3 50                      		push ax				; Save allocation strategy
  7308                                  
  7309 00002EF4 31FF                    	xor di, di				; first set
  7310                                  .retry_alloc:
  7311 00002EF6 B80358                  		mov ax, 5803h			; Set UMB link state:
  7312 00002EF9 2E8B9D[540E]            		mov bx, [cs:init_switch_t_umblink + di]
  7313 00002EFE 83FBFF                  		cmp bx, -1			; not set ?
  7314 00002F01 7503E99E01              		je .error_no_alloc_retry	; then error out -->
  7315 00002F06 CD21                    		int 21h
  7316 00002F08 B80158                  		mov ax, 5801h			; Set allocation strategy:
  7317 00002F0B 2E8B9D[5A0E]            		mov bx, [cs:init_switch_t_strategy + di]
  7318 00002F10 CD21                    		int 21h
  7319                                  
  7320                                  		; allocate new memory block for process
  7321 00002F12 2E8B1E[360E]            	mov bx, word [cs:memsize]
  7322 00002F17 B448                    	mov ah, 48h
  7323 00002F19 CD21                    	int 21h
  7324 00002F1B 7303E98401              	jc .error_no_alloc_retry
  7325                                  
  7326 00002F20 92                      	xchg dx, ax			; dx => new process block
  7327                                  
  7328                                  		; allocate new memory block for environment
  7329                                  %if _APP_ENV_SIZE
  7330 00002F21 2ED006[710E]            	rol byte [cs:app_env_allocation], 1
  7331 00002F26 732D                    	jnc @F
  7332                                  %endif
  7333 00002F28 A12C00                  	mov ax, word [2Ch]
  7334 00002F2B 85C0                    	test ax, ax			; zero ?
  7335 00002F2D 7426                    	jz .allocated			; yes, nothing to relocate -->
  7336 00002F2F 48                      	dec ax
  7337 00002F30 8EC0                    	mov es, ax			; es => MCB
  7338 00002F32 268B1E0300              	mov bx, word [es:3]		; = MCB size
  7339 00002F37 B448                    	mov ah, 48h
  7340 00002F39 CD21                    	int 21h				; allocate
  7341 00002F3B 7303E95E01              	jc .error_no_alloc_retry_free_dx
  7342                                  
  7343                                  		; relocate environment
  7344 00002F40 52                      	push dx
  7345 00002F41 92                      	xchg dx, ax			; dx => target
  7346 00002F42 A12C00                  	mov ax, word [2Ch]		; ax => source
  7347 00002F45 89D9                    	mov cx, bx			; cx = amount paragraphs
  7348 00002F47 E838EC                  	call init_movp
  7349 00002F4A 89162C00                	mov word [2Ch], dx		; relocate environment
  7350 00002F4E 5A                      	pop dx				; => process memory block target
  7351 00002F4F 8EC0                    	mov es, ax
  7352 00002F51 B449                    	mov ah, 49h
  7353 00002F53 CD21                    	int 21h				; explicitly free old environment
  7354                                  					;  (not needed depending on method)
  7355                                  @@:
  7356                                  
  7357                                  .allocated:	; dx => new process block
  7358 00002F55 8CD0                    	mov ax, ss			; => source process block
  7359 00002F57 2E8B0E[360E]            	mov cx, word [cs:memsize]	; cx = amount paragraphs
  7360 00002F5C 2E890E[520E]            	mov word [cs:init_target_size], cx
  7361 00002F61 E81EEC                  	call init_movp
  7362                                  
  7363 00002F64 2EA3[4A0E]              	mov word [cs:relocate_source], ax
  7364 00002F68 48                      	dec ax
  7365 00002F69 1E                      	push ds
  7366 00002F6A 8ED8                    	mov ds, ax			; ds => original block MCB
  7367 00002F6C 89160100                	mov word [1], dx		; set original block owner to new
  7368                                  
  7369 00002F70 89D0                    	mov ax, dx
  7370 00002F72 48                      	dec ax
  7371 00002F73 8EC0                    	mov es, ax			; es => new block MCB
  7372 00002F75 2689160100              	mov word [es:1], dx		; set new block owner to new
  7373                                  
  7374 00002F7A BF0800                  	mov di, 8		; es:di-> MCB name field
  7375 00002F7D 89FE                    	mov si, di
  7376 00002F7F A5                      	movsw
  7377 00002F80 A5                      	movsw
  7378 00002F81 A5                      	movsw
  7379 00002F82 A5                      	movsw			; Force MCB string
  7380 00002F83 1F                      	pop ds			; restore => old block
  7381                                  
  7382 00002F84 A12C00                  	mov ax, word [2Ch]		; => environment, or zero
  7383 00002F87 85C0                    	test ax, ax
  7384 00002F89 7408                    	jz @F
  7385 00002F8B 48                      	dec ax
  7386 00002F8C 8EC0                    	mov es, ax			; => environment MCB
  7387 00002F8E 2689160100              	mov word [es:1], dx		; set environment block owner to new
  7388                                  @@:
  7389                                  
  7390 00002F93 8CD0                    	mov ax, ss			; ax => old PSP
  7391 00002F95 8ED2                    	mov ss, dx			; relocate stack
  7392 00002F97 90                      	nop
  7393                                  					; ds still => old PSP
  7394 00002F98 92                      	xchg ax, dx			; ax => new PSP, dx => old PSP
  7395                                  
  7396                                  		; code from ecm TSR
  7397 00002F99 8EC0                    	mov es, ax		; es = new PSP
  7398 00002F9B BF1800                  	mov di, 18h
  7399 00002F9E B91400                  	mov cx, 20
  7400 00002FA1 26A33600                	mov word [ es:34h+2 ], ax
  7401 00002FA5 26893E3400              	mov word [ es:34h ], di	; fix the new PSP's PHT pointer
  7402 00002FAA 26890E3200              	mov word [ es:32h ], cx	;  and the count of PHT entries field
  7403 00002FAF 50                      	 push ax
  7404 00002FB0 B0FF                    	mov al, -1
  7405 00002FB2 57                      	 push di
  7406 00002FB3 89CB                    	mov bx, cx		; = 20
  7407 00002FB5 F3AA                    	rep stosb		; initialise new PHT with empty entries
  7408 00002FB7 5F                      	 pop di
  7409 00002FB8 8B0E3200                	mov cx, word [ 32h ]	; cx = count of PHT entries
  7410 00002FBC 39D9                    	cmp cx, bx		; >= 20 ?
  7411 00002FBE 7202                    	jb .shortertable	; no -->
  7412 00002FC0 89D9                    	mov cx, bx		; limit to 20
  7413                                  .shortertable:
  7414 00002FC2 C5363400                	lds si, [ 34h ]		; ds:si-> old PHT
  7415 00002FC6 56                      	push si
  7416 00002FC7 51                      	push cx
  7417 00002FC8 F3A4                    	rep movsb		; get all entries
  7418 00002FCA 59                      	pop cx
  7419 00002FCB 5F                      	pop di
  7420 00002FCC 1E                      	 push ds
  7421 00002FCD 07                      	 pop es			; es:di-> old PHT
  7422 00002FCE F3AA                    	rep stosb		; fill moved entries with -1 (closed)
  7423 00002FD0 58                      	 pop ax
  7424 00002FD1 8EDA                    	mov ds, dx		; ds = old PSP
  7425 00002FD3 C7060A00[0830]          	mov word [ 0Ah ], .terminated
  7426 00002FD9 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 00002FDD A31600                  	mov word [ 16h ], ax	; set parent PSP to the relocated one
  7434 00002FE0 36A33000                	mov word [ ss:2Eh+2 ], ax
  7435                                  				; set SS used by process termination
  7436                                  
  7437 00002FE4 93                      	xchg ax, bx		; bx = new location, dx = old location
  7438 00002FE5 B85D33                  	mov ax, 335Dh
  7439 00002FE8 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 00002FEA 0E                      	push cs
  7459 00002FEB 1F                      	pop ds
  7460 00002FEC BA[0230]                	mov dx, .nullbyte	; just in case, ds:dx -> zero value byte
  7461 00002FEF B87F4B                  	mov ax, 4B7Fh		; 21.4B with invalid subfunction in al
  7462                                  				;  (note that FreeDOS masks off 80h)
  7463 00002FF2 CD21                    	int 21h
  7464                                  @@:
  7465                                  
  7466 00002FF4 2E8E06[4A0E]            	mov es, word [cs:relocate_source]
  7467 00002FF9 26FF362E00              	push word [ es:2Eh ]
  7468 00002FFE 368F062E00              	pop word [ ss:2Eh ]	; set SP used by process termination
  7469                                  .nullbyte: equ $ - 1
  7470                                  
  7471 00003003 B8004C                  	mov ax, 4C00h
  7472 00003006 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 00003008 16                      	push ss
  7479 00003009 1F                      	pop ds
  7480 0000300A 16                      	push ss
  7481 0000300B 07                      	pop es
  7482                                  		; end code from ecm TSR
  7483                                  
  7484                                  
  7485                                  .relocate:
  7486 0000300C 2E8326[4C0E]00          	and word [cs:relocate_down], 0	; = 0
  7487 00003012 8CD6                    	mov si, ss
  7488 00003014 2E2B36[4A0E]            	sub si, word [cs:relocate_source]
  7489 00003019 7305                    	jnc @F
  7490 0000301B 2EF716[4C0E]            	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 00003020 0136[0000]              	add word [history.segorsel + soaSegSel], si
  7499                                  %if _PM
  7500 00003024 0136[0200]              	add word [history.segorsel + soaSegment], si
  7501                                  %endif
  7502                                  %endif
  7503                                  
  7504                                  %if _APP_ENV_SIZE
  7505                                  .relocate_env:
  7506 00003028 2ED006[710E]            	rol byte [cs:app_env_allocation], 1
  7507 0000302D 7204                    	jc @F
  7508 0000302F 01362C00                	add word [2Ch], si
  7509                                  @@:
  7510 00003033 833E[0000]00            	cmp word [envseg], 0
  7511 00003038 7404                    	je @F
  7512 0000303A 0136[0000]              	add word [envseg], si
  7513                                  @@:
  7514                                  %endif
  7515                                  
  7516                                  %if _EXTENSIONS
  7517                                  .relocate_ext:
  7518 0000303E 0136[0000]              	add word [extseg], si
  7519                                  %endif
  7520                                  
  7521                                  .relocate_code:
  7522 00003042 A1[0000]                	mov ax, word [code_seg]
  7523 00003045 89C2                    	mov dx, ax
  7524 00003047 01F2                    	add dx, si
  7525                                  
  7526 00003049 8EC2                    	mov es, dx
  7527 0000304B 0136[0000]              	add word [code_seg], si
  7528                                  %if _DUALCODE
  7529 0000304F 0136[0000]              	add word [code2_seg], si
  7530 00003053 8B16[0000]              	mov dx, word [code2_seg]
  7531 00003057 56                      	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 00003058 06                      	push es
  7540 00003059 8EC2                    	mov es, dx
  7541 0000305B 5A                      	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 0000305C 5E                      	pop si
  7558                                  %endif
  7559                                  
  7560                                  %if _AREAS && _AREAS_HOOK_CLIENT
  7561 0000305D 89F0                    	mov ax, si
  7562 0000305F 2E8B16[4C0E]            	mov dx, word [cs:relocate_down]
  7563 00003064 E83605                  	call add_to_areas_linear_code1.dxax
  7564                                   %if _DUALCODE && _EXPRDUALCODE
  7565 00003067 89F0                    	mov ax, si
  7566 00003069 2E8B16[4C0E]            	mov dx, word [cs:relocate_down]
  7567 0000306E E85805                  	call add_to_areas_linear_code2.dxax
  7568                                   %endif
  7569                                  %endif
  7570                                  
  7571                                  
  7572                                  .relocate_auxbuff:
  7573 00003071 0136[0000]              	add word [auxbuff_segorsel + soaSegSel], si
  7574                                  %if _PM
  7575 00003075 0136[0200]              	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 00003079 0136[0000]              	add word [messageseg], si
  7586                                   %if _HELP_COMPRESSED && ! _PM
  7587                                  	add word [hshrink_memory_source.segment], si
  7588                                   %endif
  7589                                  %endif
  7590                                  
  7591                                  
  7592                                  .relocate_old_initcode_variables:
  7593 0000307D 8CD8                    	mov ax, ds
  7594 0000307F A3[0200]                	mov word [execblk.cmdline + 2], ax
  7595 00003082 A3[0200]                	mov word [execblk.fcb1 + 2], ax
  7596 00003085 A3[0200]                	mov word [execblk.fcb2 + 2], ax	; set up parameter block for exec command
  7597 00003088 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 0000308B 05[0000]                	add ax, strict word immasm_buffer
  7604                                   wlcalc word_shr_4, equ $ - 2
  7605                                   %endif
  7606 0000308E A3[0000]                	mov word [immseg], ax
  7607                                  %endif
  7608                                  
  7609                                  
  7610                                  %if _AREAS_HOOK_SERVER
  7611                                  .relocate_areas:
  7612 00003091 8CD8                    	mov ax, ds
  7613 00003093 A3[0200]                	mov word [ddebugareas.next + 2], ax
  7614 00003096 A3[0200]                	mov word [ddebugareas.prev + 2], ax
  7615 00003099 A3[0000]                	mov word [..@patch_entry_seg], ax
  7616                                  %endif
  7617                                  
  7618                                  
  7619                                  .relocate_done:
  7620 0000309C EB16                    	jmp .done
  7621                                  
  7622                                  
  7623                                  		; environment could not be allocated
  7624                                  .error_no_alloc_retry_free_dx:
  7625 0000309E 8EC2                    	mov es, dx
  7626 000030A0 B449                    	mov ah, 49h
  7627 000030A2 CD21                    	int 21h				; free allocated block
  7628                                  
  7629                                  		; some memory could not be allocated
  7630                                  .error_no_alloc_retry:
  7631 000030A4 AF                      	scasw				; di += 2
  7632 000030A5 83FF06                  	cmp di, 6
  7633 000030A8 7303E949FE              	jb .retry_alloc
  7634                                  
  7635                                  .error_no_retry:
  7636 000030AD 2ED006[6E0E]            	rol byte [cs:init_switch_t_ignore], 1
  7637 000030B2 7301                    	jnc .error
  7638                                  
  7639                                  .done:
  7640 000030B4 A8                      	db __TEST_IMM8			; (skip stc, NC)
  7641                                  .error:
  7642 000030B5 F9                      	stc				; CY
  7643                                  .status:
  7644 000030B6 19D2                    	sbb dx, dx				; 0 = NC, -1 = CY
  7645 000030B8 5B                      		pop bx				; saved allocation strategy
  7646 000030B9 B80158                  		mov ax, 5801h
  7647 000030BC CD21                    		int 21h				; Set allocation strategy
  7648 000030BE 5B                      		pop bx				; saved UMB link state
  7649 000030BF B80358                  		mov ax, 5803h
  7650 000030C2 CD21                    		int 21h				; Set UMB link state
  7651 000030C4 85D2                    	test dx, dx
  7652 000030C6 7406                    	jz .done_outer
  7653                                  .error_outer:
  7654 000030C8 BA[1410]                	mov dx, imsg.relocate_failure
  7655 000030CB E9A4F2                  	jmp ..@init_cmdline_error
  7656                                  
  7657                                  .done_outer:
  7658                                  
  7659                                  
  7660                                  %if _EXECUTABLE
  7661                                  init_executable:
  7662 000030CE 16                      	push ss
  7663 000030CF 1F                      	pop ds
  7664 000030D0 16                      	push ss
  7665 000030D1 07                      	pop es
  7666 000030D2 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  7667 000030D7 7539                    	jnz .device
  7668                                  
  7669                                  .application:
  7670 000030D9 8B162C00                	mov dx, word [2Ch]
  7671 000030DD 85D2                    	test dx, dx
  7672 000030DF 746B                    	jz .unable
  7673 000030E1 8EC2                    	mov es, dx
  7674 000030E3 B90080                  	mov cx, 8000h
  7675 000030E6 31F6                    	xor si, si
  7676                                  @@:
  7677 000030E8 E81900                  	call .nextvar
  7678 000030EB 725F                    	jc .unable
  7679 000030ED 75F9                    	jne @B
  7680 000030EF 46                      	inc si
  7681 000030F0 26AD                    	es lodsw
  7682 000030F2 83F801                  	cmp ax, 1
  7683 000030F5 7555                    	jne .unable
  7684                                  
  7685 000030F7 06                      	push es
  7686 000030F8 1F                      	pop ds				; => env
  7687 000030F9 16                      	push ss
  7688 000030FA 07                      	pop es				; => data entry
  7689 000030FB BF[0000]                	mov di, init_executable_pathname
  7690 000030FE B460                    	mov ah, 60h
  7691 00003100 CD21                    	int 21h
  7692 00003102 EB48                    	jmp .done
  7693                                  
  7694                                  .nextvar:
  7695                                  @@:
  7696 00003104 26AC                    	es lodsb
  7697 00003106 84C0                    	test al, al
  7698 00003108 E0FA                    	loopnz @B
  7699 0000310A F9                      	stc
  7700 0000310B 7504                    	jnz @F
  7701 0000310D 26803C00                	cmp byte [es:si], 0
  7702                                  @@:
  7703 00003111 C3                      	retn
  7704                                  
  7705                                  
  7706                                  .device:
  7707 00003112 8B36[0000]              	mov si, word [reg_ebx]
  7708 00003116 8E1E[0000]              	mov ds, word [reg_es]
  7709 0000311A C57412                  	lds si, [si + 12h]
  7710                                  
  7711 0000311D 89F7                    	mov di, si
  7712                                  @@:
  7713 0000311F AC                      	lodsb
  7714 00003120 3C20                    	cmp al, 32
  7715 00003122 7412                    	je @F
  7716 00003124 3C09                    	cmp al, 9
  7717 00003126 740E                    	je @F
  7718 00003128 3C00                    	cmp al, 0
  7719 0000312A 740A                    	je @F
  7720 0000312C 3C0D                    	cmp al, 13
  7721 0000312E 7406                    	je @F
  7722 00003130 3C0A                    	cmp al, 10
  7723 00003132 7402                    	je @F
  7724 00003134 EBE9                    	jmp @B
  7725                                  
  7726                                  @@:
  7727 00003136 FF74FF                  	push word [si - 1]
  7728 00003139 56                      	push si
  7729 0000313A C644FF00                	mov byte [si - 1], 0
  7730 0000313E 89FE                    	mov si, di
  7731 00003140 BF[0000]                	mov di, init_executable_pathname
  7732 00003143 B460                    	mov ah, 60h
  7733 00003145 CD21                    	int 21h
  7734 00003147 5E                      	pop si
  7735 00003148 58                      	pop ax
  7736 00003149 8844FF                  	mov byte [si - 1], al
  7737                                  
  7738                                  .done:
  7739                                  .unable:
  7740 0000314C 16                      	push ss
  7741 0000314D 1F                      	pop ds
  7742 0000314E 16                      	push ss
  7743 0000314F 07                      	pop es
  7744                                  
  7745 00003150 BF[0000]                	mov di, init_executable_pathname
  7746 00003153 31C0                    	xor ax, ax
  7747 00003155 B98000                  	mov cx, 128
  7748 00003158 F2AE                    	repne scasb
  7749 0000315A 4F                      	dec di
  7750 0000315B 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 0000315F 8B0E[0000]              	mov cx, word [inttab_number_variable]
  7759                                  %else
  7760                                  	mov cx, inttab_number
  7761                                  %endif
  7762 00003163 E320                    	jcxz .intend
  7763 00003165 BE[0000]                	mov si, inttab
  7764                                  .intloop:
  7765 00003168 AC                      	lodsb
  7766 00003169 B435                    	mov ah, 35h
  7767 0000316B CD21                    	int 21h			; get vector
  7768 0000316D 97                      	xchg ax, di
  7769 0000316E AD                      	lodsw
  7770 0000316F 97                      	xchg ax, di
  7771                                  %if _DEBUG && !_DEBUG_COND
  7772                                  				; vectors are set only when debuggee runs
  7773                                  %else
  7774                                   %if _DEBUG
  7775 00003170 F606[0100]01            	testopt [internalflags6], dif6_debug_mode
  7776 00003175 750C                    	jnz @F
  7777                                   %endif
  7778 00003177 895D02                  	mov word [ di + ieNext ], bx
  7779 0000317A 8C4504                  	mov word [ di + ieNext + 2 ], es
  7780                                  				; store it
  7781 0000317D 89FA                    	mov dx, di
  7782 0000317F B425                    	mov ah, 25h		; set interrupt vector
  7783 00003181 CD21                    	int 21h			; ds => lDEBUG_DATA_ENTRY
  7784                                  @@:
  7785                                  %endif
  7786 00003183 E2E3                    	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 00003185 E88F04                  	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 00003188 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  7842 0000318D 7403E94201              	jnz final_device
  7843                                  %elif _DEVICE
  7844                                  	jmp final_device
  7845                                  %endif
  7846                                  %if _APPLICATION
  7847 00003192 BE0A00                  	mov si, TPIV
  7848 00003195 BF[0000]                	mov di, psp22
  7849 00003198 A5                      	movsw
  7850 00003199 A5                      	movsw				; save Int22
  7851 0000319A BA[0000]                	mov dx, debug22
  7852 0000319D 8954FC                  	mov word [ si-4 ], dx
  7853 000031A0 8C5CFE                  	mov word [ si-2 ], ds		; set pspInt22 (required)
  7854 000031A3 BE1600                  	mov si, 16h
  7855 000031A6 A5                      	movsw				; save parent
  7856 000031A7 8C5CFE                  	mov word [ si-2 ], ds		; set pspParent
  7857 000031AA B82225                  	mov ax, 2522h			; set Int22
  7858 000031AD CD21                    	int 21h				; (not really required)
  7859                                  
  7860                                  init_app_allocate_reserved:
  7861 000031AF B80258                  		mov ax, 5802h			; Get UMB link state
  7862 000031B2 CD21                    		int 21h
  7863 000031B4 30E4                    		xor ah, ah
  7864 000031B6 50                      		push ax				; Save UMB link state
  7865 000031B7 B80058                  		mov ax, 5800h			; Get allocation strategy
  7866 000031BA CD21                    		int 21h
  7867 000031BC 50                      		push ax				; Save allocation strategy
  7868                                  
  7869 000031BD B80358                  		mov ax, 5803h			; Set UMB link state:
  7870 000031C0 BB0100                  		mov bx, 1			; enabled
  7871 000031C3 CD21                    		int 21h
  7872 000031C5 B80158                  		mov ax, 5801h			; Set allocation strategy:
  7873 000031C8 31DB                    		xor bx, bx			; first fit, LMA then UMA
  7874 000031CA CD21                    		int 21h
  7875                                  
  7876 000031CC 2E8B16[4E0E]            	mov dx, word [cs:init_switch_r]
  7877                                  .loop:
  7878 000031D1 31DB                    	xor bx, bx
  7879 000031D3 B448                    	mov ah, 48h
  7880 000031D5 CD21                    	int 21h
  7881 000031D7 722D                    	jc .done
  7882 000031D9 8EC0                    	mov es, ax
  7883 000031DB 39D0                    	cmp ax, dx
  7884 000031DD 7606                    	jbe .grow
  7885                                  .free:
  7886 000031DF B449                    	mov ah, 49h
  7887 000031E1 CD21                    	int 21h
  7888 000031E3 EB21                    	jmp .done
  7889                                  
  7890                                  .grow:
  7891 000031E5 50                      	push ax
  7892 000031E6 93                      	xchg bx, ax
  7893 000031E7 F7DB                    	neg bx
  7894 000031E9 01D3                    	add bx, dx				; = dx - bx
  7895 000031EB B44A                    	mov ah, 4Ah
  7896 000031ED CD21                    	int 21h					; grow up to desired segment
  7897 000031EF 58                      	pop ax					;  (if not free grow less)
  7898                                  
  7899 000031F0 85DB                    	test bx, bx
  7900 000031F2 7501                    	jnz .nonempty
  7901 000031F4 48                      	dec ax					; => MCB (hack into the name field)
  7902                                  .nonempty:
  7903 000031F5 8EC0                    	mov es, ax
  7904 000031F7 26891E0C00              	mov word [es:12], bx			; size (0 if in MCB)
  7905 000031FC 8706[0000]              	xchg ax, word [next_reserved_segment]	; :12 -> chain
  7906 00003200 26A30E00                	mov word [es:14], ax			; => next in chain
  7907 00003204 EBCB                    	jmp .loop
  7908                                  
  7909                                  .done:
  7910 00003206 5B                      		pop bx				; saved allocation strategy
  7911 00003207 B80158                  		mov ax, 5801h
  7912 0000320A CD21                    		int 21h				; Set allocation strategy
  7913 0000320C 5B                      		pop bx				; saved UMB link state
  7914 0000320D B80358                  		mov ax, 5803h
  7915 00003210 CD21                    		int 21h				; Set UMB link state
  7916                                  
  7917                                  init_app_resize:
  7918                                  		; shrink to required resident size
  7919 00003212 1E                      	push ds
  7920 00003213 07                      	pop es
  7921 00003214 2EA1[360E]              	mov ax, word [cs:memsize]
  7922 00003218 A3[0000]                	mov word [alloc_size_not_reserved], ax
  7923 0000321B 8CD8                    	mov ax, ds
  7924 0000321D 2E8B16[4E0E]            	mov dx, word [cs:init_switch_r]
  7925 00003222 8916[0000]              	mov word [reserved_address], dx
  7926 00003226 39D0                    	cmp ax, dx
  7927 00003228 7325                    	jae @F
  7928 0000322A 2E8B1E[520E]            	mov bx, word [cs:init_target_size]
  7929 0000322F 01D8                    	add ax, bx
  7930 00003231 39D0                    	cmp ax, dx
  7931 00003233 7215                    	jb .fulltargetsize
  7932 00003235 8CD8                    	mov ax, ds
  7933 00003237 2E0306[360E]            	add ax, word [cs:memsize]
  7934 0000323C 39D0                    	cmp ax, dx
  7935 0000323E 730F                    	jae @F					; no action needed
  7936 00003240 89D3                    	mov bx, dx
  7937 00003242 8CD8                    	mov ax, ds
  7938 00003244 29C3                    	sub bx, ax				; grow it up to /R (or less)
  7939 00003246 B44A                    	mov ah, 4Ah
  7940 00003248 CD21                    	int 21h					; get bx = actual size
  7941                                  .fulltargetsize:
  7942 0000324A 2E891E[360E]            	mov word [cs:memsize], bx
  7943                                  @@:
  7944 0000324F B44A                    	mov ah, 4Ah
  7945 00003251 2E8B1E[360E]            	mov bx, word [cs:memsize]
  7946 00003256 891E[0000]              	mov word [alloc_size], bx
  7947 0000325A 8C1E[0000]              	mov word [alloc_seg], ds
  7948                                  
  7949                                  
  7950 0000325E 2ED006[6D0E]            	rol byte [cs:init_switch_t], 1
  7951 00003263 7209                    	jc .application_relocate
  7952                                  
  7953                                  .application_no_relocate:
  7954 00003265 BE[0000]                	mov si, initcont
  7955 00003268 FF36[0000]              	push word [code_seg]
  7956 0000326C 56                      	push si
  7957 0000326D CB                      	retf
  7958                                  
  7959                                  .application_relocate:
  7960 0000326E 83EC08                  	sub sp, .relocate_trampoline_size_w * 2
  7961 00003271 89E7                    	mov di, sp			; es:di -> stack space
  7962 00003273 0E                      	push cs
  7963 00003274 1F                      	pop ds
  7964 00003275 BE[CC32]                	mov si, .relocate_trampoline	; ds:si -> trampoline code
  7965 00003278 B90400                  	mov cx, .relocate_trampoline_size_w
  7966 0000327B 57                      	 push di
  7967 0000327C F3A5                    	rep movsw			; place trampoline
  7968 0000327E 5F                      	 pop di
  7969                                  
  7970 0000327F BE[0000]                	mov si, initcont
  7971 00003282 36FF36[0000]            	push word [ss:code_seg]
  7972 00003287 56                      	push si				; place our return address
  7973                                  
  7974 00003288 06                      	push es
  7975 00003289 53                      	push bx
  7976 0000328A 50                      	push ax				; stack for trampoline
  7977                                  
  7978 0000328B B549                    	mov ch, 49h			; set up to free original block
  7979 0000328D A1[4A0E]                	mov ax, word [relocate_source]
  7980 00003290 50                      	 push ax			; => source block
  7981 00003291 8B16[4E0E]              	mov dx, word [init_switch_r]
  7982 00003295 39D0                    	cmp ax, dx
  7983 00003297 732A                    	jae @F
  7984 00003299 2E8B1E[500E]            	mov bx, word [cs:init_base_size]
  7985 0000329E 01D8                    	add ax, bx
  7986 000032A0 39D0                    	cmp ax, dx
  7987 000032A2 7206                    	jb .fullbasesize
  7988 000032A4 89D3                    	mov bx, dx
  7989 000032A6 58                      	 pop ax
  7990 000032A7 50                      	 push ax
  7991 000032A8 29C3                    	sub bx, ax
  7992                                  .fullbasesize:
  7993 000032AA B54A                    	mov ch, 4Ah			; resize instead
  7994                                  
  7995 000032AC 58                      	 pop ax
  7996 000032AD 50                      	 push ax
  7997 000032AE 85DB                    	test bx, bx
  7998 000032B0 7501                    	jnz .nonempty
  7999 000032B2 48                      	dec ax					; => MCB (hack into the name field)
  8000                                  .nonempty:
  8001 000032B3 8EC0                    	mov es, ax
  8002 000032B5 26891E0C00              	mov word [es:12], bx			; size (0 if in MCB)
  8003 000032BA 368706[0000]            	xchg ax, word [ss:next_reserved_segment]; :12 -> chain
  8004 000032BF 26A30E00                	mov word [es:14], ax			; => next in chain
  8005                                  @@:
  8006 000032C3 58                      	 pop ax
  8007 000032C4 8EC0                    	mov es, ax			; => relocate source
  8008 000032C6 91                      	xchg ax, cx			; ah = 49h or 4Ah
  8009                                  
  8010 000032C7 16                      	 push ss
  8011 000032C8 1F                      	 pop ds				; reset ds
  8012 000032C9 16                      	push ss
  8013 000032CA 57                      	push di				; -> placed trampoline
  8014 000032CB CB                      	retf				; jump to trampoline
  8015                                  
  8016                                  
  8017                                  	align 2, nop
  8018                                  .relocate_trampoline:
  8019 000032CC CD21                    	int 21h				; free original process block
  8020 000032CE 58                      	pop ax				; ah = 4Ah
  8021 000032CF 5B                      	pop bx				; bx = memory size
  8022 000032D0 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 000032D1 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 000032D4 BE8000                  	mov si, 80h			; -> command line tail
  8035 000032D7 89F1                    	mov cx, si			; = 128
  8036 000032D9 29CC                    	sub sp, cx			; -> buffer on stack
  8037 000032DB 89E7                    	mov di, sp
  8038 000032DD F3A4                    	rep movsb			; preserve it
  8039                                  
  8040                                   %if _DEV_ENV_SIZE
  8041 000032DF FF362C00                	push word [2Ch]
  8042                                   %endif
  8043                                  
  8044 000032E3 8CDA                    	mov dx, ds
  8045 000032E5 B455                    	mov ah, 55h
  8046 000032E7 F8                      	clc
  8047 000032E8 CD21                    	int 21h				; create child PSP
  8048                                  
  8049 000032EA BE0E00                  	mov si, TPIV + 4
  8050 000032ED BA[0000]                	mov dx, debug22
  8051 000032F0 8954FC                  	mov word [ si-4 ], dx
  8052 000032F3 8C5CFE                  	mov word [ si-2 ], ds		; set pspInt22 (required)
  8053                                   %if _DEVICE_SET_2324
  8054 000032F6 C704[0000]              	mov word [ si ], devint23
  8055 000032FA 8C5C02                  	mov word [ si + 2 ], ds		; set pspInt23
  8056 000032FD C74404[0000]            	mov word [ si + 4 ], devint24
  8057 00003302 8C5C06                  	mov word [ si + 6 ], ds		; set pspInt24
  8058                                   %endif
  8059 00003305 BE1800                  	mov si, 16h + 2
  8060 00003308 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 0000330B 8F062C00                	pop word [2Ch]
  8066                                   %else
  8067                                  	xor ax, ax
  8068                                  	mov word [2Ch], ax		; set environment to none
  8069                                   %endif
  8070                                  
  8071 0000330F BB0500                  	mov bx, 5			; close file handles past std (5)
  8072 00003312 8B0E3200                	mov cx, word [32h]		; = number of file handles
  8073 00003316 29D9                    	sub cx, bx			; = number past std handles
  8074 00003318 7607                    	jbe @FF				; if <= 0 handles to close -->
  8075                                  @@:
  8076 0000331A B43E                    	mov ah, 3Eh
  8077 0000331C CD21                    	int 21h				; close file handle
  8078 0000331E 43                      	inc bx				; next handle
  8079 0000331F E2F9                    	loop @B				; loop -->
  8080                                  @@:
  8081                                  
  8082 00003321 89E6                    	mov si, sp			; -> buffer on stack
  8083 00003323 BF8000                  	mov di, 80h			; -> command line tail buffer in PSP
  8084 00003326 89F8                    	mov ax, di			; = 128
  8085 00003328 89F9                    	mov cx, di			; = 128
  8086 0000332A F3A4                    	rep movsb			;
  8087 0000332C 01C4                    	add sp, ax			; discard buffer
  8088                                  
  8089 0000332E BE[0000]                	mov si, initcont.device
  8090 00003331 FF36[0000]              	push word [code_seg]
  8091 00003335 56                      	push si
  8092 00003336 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 00003337 3C00                <1> 	cmp al, 0
   282 00003339 741D                <1> 	je .return
   283 0000333B 3C0D                <1> 	cmp al, 13
   284 0000333D 7419                <1> 	je .return
   285 0000333F 3C3B                <1> 	cmp al, ';'
   286 00003341 7415                <1> 	je .return
   287 00003343 3C20                <1> 	cmp al, 32
   288 00003345 7411                <1> 	je .return
   289 00003347 3C09                <1> 	cmp al, 9
   290 00003349 740D                <1> 	je .return
   291 0000334B 3C2C                <1> 	cmp al, ','
   292 0000334D 7409                <1> 	je .return
   293 0000334F 3C3D                <1> 	cmp al, '='
   294 00003351 7405                <1> 	je .return
   295 00003353 363A06[0000]        <1> 	cmp al, byte [ss:relocated(swch1)]
   296                              <1> linkdatarelocation swch1
   297                              <1> .return:
   298 00003358 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 00003359 06                  <1> 	push es
   312 0000335A 51                  <1> 	push cx
   313                              <1> 
   314 0000335B 06                  <1> 	push es
   315 0000335C 1F                  <1> 	pop ds
   316 0000335D 89DE                <1> 	mov si, bx		; ds:si -> name
   317 0000335F 16                  <1> 	 push ss
   318 00003360 07                  <1> 	 pop es			; es:di -> where to append name
   319 00003361 F3A4                <1> 	rep movsb		; append the name
   320 00003363 57                  <1> 	push di			; on stack: at initial terminator
   321 00003364 BE[7A0E]            <1> 	mov si, imsg.p_extensions
   322                              <1> internaldatarelocation
   323                              <1> 				; cs:si -> extensions to try
   324                              <1> .loop:
   325 00003367 B000                <1> 	mov al, 0
   326 00003369 AA                  <1> 	stosb			; zero-terminate name
   327 0000336A B80043              <1> 	mov ax, 4300h		; get attributes
   328 0000336D 52                  <1> 	push dx
   329 0000336E 16                  <1> 	 push ss
   330 0000336F 1F                  <1> 	 pop ds
   331 00003370 BA[0000]            <1> 	mov dx, relocated(while_buffer)	; ds:dx -> pathname to try
   332                              <1> linkdatarelocation while_buffer
   333 00003373 F9                  <1> 	stc
   334                              <1> %if ELD
   335                              <1> 	extcallcall _doscall
   336                              <1> %else
   337 00003374 CD21                <1> 	int 21h			; try to get attributes
   338                              <1> %endif
   339 00003376 7206                <1> 	jc @F			; not found --> CY
   340 00003378 F6C110              <1> 	test cl, 10h		; directory ?
   341 0000337B 7401                <1> 	jz @F			; no --> NC
   342 0000337D F9                  <1> 	stc			; yes, handle as not found: CY
   343                              <1> @@:
   344 0000337E 5A                  <1> 	pop dx
   345 0000337F 731A                <1> 	jnc .ret		; --> (NC)
   346 00003381 84D2                <1> 	test dl, dl		; had an extension originally ?
   347 00003383 7515                <1> 	jnz .ret_CY		; yes, do not try to append one -->
   348 00003385 2ED006[490E]        <1> 	rol byte [init_data_segment:init_switch_p_guessextension], 1
   349                              <1> internaldatarelocation
   350 0000338A 730E                <1> 	jnc .ret_CY		; if no guessing extension -->
   351 0000338C 5F                  <1> 	pop di
   352 0000338D 57                  <1> 	push di
   353 0000338E 2E803C00            <1> 	cmp byte [init_data_segment:si], 0
   354                              <1> 				; last attempt done ?
   355 00003392 7406                <1> 	je .ret_CY		; yes -->
   356 00003394 2EA5                <1> 	init_data_segment movsw	; ".C"
   357 00003396 2EA5                <1> 	init_data_segment movsw	; "OM"
   358 00003398 EBCD                <1> 	jmp .loop
   359                              <1> 
   360                              <1> .ret_CY:
   361 0000339A F9                  <1> 	stc			; CY
   362                              <1> .ret:
   363 0000339B 58                  <1> 	pop ax			; (discard)
   364 0000339C 59                  <1> 	pop cx
   365 0000339D 07                  <1> 	pop es
   366 0000339E 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 0000339F 85C0                <1> 	test ax, ax
   379 000033A1 7415                <1> 	jz .notvar
   380 000033A3 8ED8                <1> 	mov ds, ax
   381 000033A5 31F6                <1> 	xor si, si
   382                              <1> 
   383                              <1> @@:
   384 000033A7 0E                  <1> 	push init_data_segment
   385 000033A8 07                  <1> 	pop es
   386 000033A9 51                  <1> 	push cx
   387 000033AA 57                  <1> 	push di
   388 000033AB 56                  <1> 	push si
   389 000033AC F3A6                <1> 	repe cmpsb
   390 000033AE 740A                <1> 	je .foundvar		; --> (NC)
   391 000033B0 5E                  <1> 	pop si
   392 000033B1 5F                  <1> 	pop di
   393 000033B2 59                  <1> 	pop cx
   394 000033B3 E80800              <1> 	call init_nextvar
   395 000033B6 75EF                <1> 	jnz @B
   396                              <1> .notvar:
   397 000033B8 F9                  <1> 	stc
   398 000033B9 C3                  <1> 	retn
   399                              <1> 
   400                              <1> .foundvar:
   401 000033BA 58                  <1> 	pop ax
   402 000033BB 58                  <1> 	pop ax
   403 000033BC 58                  <1> 	pop ax
   404 000033BD C3                  <1> 	retn
   405                              <1> 
   406                              <1> 
   407                              <1> init_nextvar:
   408                              <1> @@:
   409 000033BE AC                  <1> 	lodsb
   410 000033BF 84C0                <1> 	test al, al
   411 000033C1 75FB                <1> 	jnz @B
   412 000033C3 803C00              <1> 	cmp byte [si], 0
   413 000033C6 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 000033C7 800E[0000]10            	setopt [options], nonpagingdevice
  8125                                  
  8126 000033CC AC                      	lodsb
  8127 000033CD E8CC00                  	call init_capitalise
  8128 000033D0 3C4C                    	cmp al, 'L'
  8129 000033D2 741B                    	je .license
  8130 000033D4 3C52                    	cmp al, 'R'
  8131 000033D6 7514                    	jne .both
  8132                                  .revision:
  8133 000033D8 E80200                  	call .do_revision
  8134 000033DB EB1E                    	jmp .done
  8135                                  
  8136                                  .do_revision:
  8137 000033DD BB[0000]                	mov bx, msg.build_array
  8138 000033E0 B9[0000]                	mov cx, msg.build_short_amount
  8139 000033E3 E81800                  	call .putsz_spec_multi
  8140 000033E6 BA[1110]                	mov dx, imsg.crlf
  8141 000033E9 E927E8                  	jmp init_putsz_cs
  8142                                  
  8143                                  .both:
  8144 000033EC E8EEFF                  	call .do_revision
  8145                                  .license:
  8146 000033EF BA[0000]                	mov dx, msg.license
  8147 000033F2 E81300                  	call init_transfer_to_putsz_exthelp
  8148 000033F5 BA[1110]                	mov dx, imsg.crlf
  8149 000033F8 E818E8                  	call init_putsz_cs
  8150                                  .done:
  8151 000033FB E9D9EE                  	jmp commandline.helpterminate
  8152                                  
  8153                                  .putsz_spec_multi:
  8154                                  @@:
  8155 000033FE 8B17                    	mov dx, word [bx]
  8156 00003400 E80500                  	call init_transfer_to_putsz_exthelp
  8157 00003403 43                      	inc bx
  8158 00003404 43                      	inc bx
  8159 00003405 E2F7                    	loop @B
  8160 00003407 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 00003408 50                      	 push ax			; push into ?in_ax_out_far_ip
  8169                                  	lpar word, out_near_ip
  8170 00003409 B8[0000]                	mov ax, code_retf
  8171 0000340C 50                      	 push ax			; push into ?out_near_ip
  8172                                  	lpar dword, destination
  8173 0000340D FF36[0000]              	 push word [code_seg]		; push into ?destination + 2
  8174 00003411 B8[0000]                	mov ax, putsz_exthelp
  8175 00003414 50                      	 push ax			; push into ?destination + 0
  8176 00003415 5589E5                  	lenter
  8177 00003418 8CC8                    	mov ax, cs			; = cs
  8178 0000341A 87460A                  	xchg ax, word [bp + ?in_ip_out_far_cs]
  8179                                  					; ax = ip, var = cs
  8180 0000341D 874608                  	xchg ax, word [bp + ?in_ax_out_far_ip]
  8181                                  					; ax = ax, var = ip
  8182 00003420 5D                      	lleave
  8183 00003421 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 00003422 E87AFF                  	call init_findvar
  8198 00003425 721A                    	jc .endvar
  8199                                  
  8200                                  .foundvar:
  8201 00003427 1E                      	push ds
  8202 00003428 07                      	pop es
  8203 00003429 89F7                    	mov di, si
  8204 0000342B B000                    	mov al, 0
  8205 0000342D B9FF00                  	mov cx, 255
  8206 00003430 F2AE                    	repne scasb
  8207                                  
  8208 00003432 29F7                    	sub di, si
  8209 00003434 4F                      	dec di
  8210 00003435 89F9                    	mov cx, di
  8211                                  
  8212 00003437 16                      	push ss
  8213 00003438 07                      	pop es
  8214 00003439 89D7                    	mov di, dx
  8215 0000343B F3A4                    	rep movsb
  8216 0000343D B000                    	mov al, 0
  8217 0000343F AA                      	stosb
  8218 00003440 F8                      	clc
  8219                                  
  8220                                  .endvar:
  8221 00003441 16                      	push ss
  8222 00003442 1F                      	pop ds
  8223 00003443 16                      	push ss
  8224 00003444 07                      	pop es
  8225 00003445 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 00003446 56                  <1> 	push si
    34 00003447 87D7                <1> 	xchg dx, di
    35                              <1> .loop:
    36 00003449 AC                  <1> 	lodsb
    37 0000344A E84F00              <1> 	call %[PREFIX]capitalise
    38 0000344D AE                  <1> 	scasb
    39 0000344E 7506                <1> 	jne .mismatch
    40 00003450 84C0                <1> 	test al, al		; NC
    41 00003452 75F5                <1> 	jne .loop
    42                              <1> 				; ZR
    43 00003454 EB40                <1> 	jmp .matched_zr_nc
    44                              <1> 
    45                              <1> .mismatch:
    46 00003456 E84E00              <1> 	call %[PREFIX]iseol?
    47 00003459 7434                <1> 	je .checkend
    48 0000345B 3C20                <1> 	cmp al, 32
    49 0000345D 7430                <1> 	je .checkend
    50 0000345F 3C09                <1> 	cmp al, 9
    51 00003461 742C                <1> 	je .checkend
    52 00003463 3C2E                <1> 	cmp al, '.'
    53 00003465 7428                <1> 	je .checkend
    54 00003467 3C2C                <1> 	cmp al, ','
    55 00003469 7424                <1> 	je .checkend
    56 0000346B 3C3D                <1> 	cmp al, '='
    57 0000346D 7420                <1> 	je .checkend
    58 0000346F 3C3A                <1> 	cmp al, ':'
    59 00003471 741C                <1> 	je .checkend
    60 00003473 3C5B                <1> 	cmp al, '['
    61 00003475 7418                <1> 	je .checkend
    62 00003477 3C5D                <1> 	cmp al, ']'
    63 00003479 7414                <1> 	je .checkend
    64 0000347B 3C28                <1> 	cmp al, '('
    65 0000347D 7410                <1> 	je .checkend
    66 0000347F 3C29                <1> 	cmp al, ')'
    67 00003481 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 00003483 363A06[0000]        <1> 	cmp al, byte [ss:swch1]
    74                              <1>  %endif
    75 00003488 7405                <1> 	je .checkend
    76                              <1> %endif
    77                              <1> .ret_nz:	; NZ
    78 0000348A 5E                  <1> 	pop si
    79 0000348B F9                  <1> 	stc			; CY
    80                              <1> .ret:
    81 0000348C 87D7                <1> 	xchg dx, di
    82 0000348E C3                  <1> 	retn
    83                              <1> 
    84                              <1> .checkend:
    85 0000348F 26807DFF00          <1> 	cmp byte [es:di - 1], 0
    86 00003494 75F4                <1> 	jne .ret_nz
    87                              <1> 				; ZR, NC
    88                              <1> .matched_zr_nc:	; ZR, NC
    89 00003496 5F                  <1> 	pop di			; (discard)
    90 00003497 8D74FF              <1> 	lea si, [si - 1]	; -> separator (preserve ZR)
    91 0000349A EBF0                <1> 	jmp .ret
    92                              <1> 
    93                              <1> 
    94                              <1> %[PREFIX]capitalise: section_of_function
    95 0000349C 3C61                <1> 	cmp al, 'a'
    96 0000349E 7206                <1> 	jb .ret
    97 000034A0 3C7A                <1> 	cmp al, 'z'
    98 000034A2 7702                <1> 	ja .ret
    99 000034A4 24DF                <1> 	and al, TOUPPER
   100                              <1> .ret:
   101 000034A6 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 000034A7 3C3B                <1> 	cmp al, ';'
   118 000034A9 7406                <1> 	je .ret
   119                              <1> .notsemicolon:
   120 000034AB 3C0D                <1> 	cmp al, 13		; this *IS* iseol?
   121 000034AD 7402                <1> 	je .ret
   122 000034AF 3C00                <1> 	cmp al, 0
   123                              <1> .ret:
   124 000034B1 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 000034B2 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 000034B3 E82C00              <1> 	call %[PREFIX]skipwh0
   140 000034B6 3C2C                <1> 	cmp al, ','
   141 000034B8 7510                <1> 	jne .return		; if no comma
   142 000034BA 56                  <1> 	push si
   143 000034BB E82300              <1> 	call %[PREFIX]skipwhite
   144 000034BE E8E6FF              <1> 	call %[PREFIX]iseol?
   145 000034C1 7504                <1> 	jne .noteol		; if not end of line
   146 000034C3 5E                  <1> 	pop si
   147 000034C4 B02C                <1> 	mov al, ','
   148 000034C6 C3                  <1> 	retn
   149                              <1> .noteol:
   150 000034C7 83C402              <1> 	add sp, byte 2		; pop si into nowhere
   151                              <1> .return:
   152 000034CA 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 000034CB AC                  <1> 	lodsb
   158                              <1> %[PREFIX]skipequ0:
   159 000034CC E81300              <1> 	call %[PREFIX]skipwh0
   160 000034CF 3C3D                <1> 	cmp al, '='
   161 000034D1 7503                <1> 	jne .return
   162 000034D3 E80B00              <1> 	call %[PREFIX]skipwhite
   163                              <1> .return:
   164 000034D6 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 000034D7 AC                  <1> 	lodsb
   176 000034D8 24DF                <1> 	and al, TOUPPER
   177 000034DA 2C41                <1> 	sub al, 'A'
   178 000034DC 3C19                <1> 	cmp al, 'Z'-'A'
   179 000034DE 76F7                <1> 	jbe .
   180 000034E0 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 000034E1 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 000034E2 3C20                <1> 	cmp al, 32
   204 000034E4 74FB                <1> 	je %[PREFIX]skipwhite
   205 000034E6 3C09                <1> 	cmp al, 9
   206 000034E8 74F7                <1> 	je %[PREFIX]skipwhite
   207 000034EA F8                  <1> 	clc
   208 000034EB 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 000034EC 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 000034EF 89C2                    	mov dx, ax
  8286 000034F1 01F2                    	add dx, si
  8287 000034F3 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 000034F6 2E030E[380E]            	add cx, word [cs:mem_envsize]
  8292                                  %endif
  8293 000034FB E884E6                  	call init_movp
  8294                                  .skip_env_reloc:
  8295                                  init_app_layout_common:
  8296                                    %if _HISTORY_SEPARATE_FIXED && _HISTORY
  8297 000034FE 0136[0000]              	add word [history.segorsel + soaSegSel], si
  8298                                  %if _PM
  8299 00003502 0136[0200]              	add word [history.segorsel + soaSegment], si
  8300                                  %endif
  8301                                    %endif
  8302                                    %if _EXTENSIONS
  8303 00003506 0136[0000]              	add word [extseg], si
  8304                                    %endif
  8305                                    %if (_DEV_ENV_SIZE || _APP_ENV_SIZE)
  8306 0000350A 2ED006[710E]            	rol byte [cs:app_env_allocation], 1
  8307 0000350F 7204                    	jc @F
  8308 00003511 01362C00                	add word [2Ch], si
  8309                                  @@:
  8310 00003515 833E[0000]00            	cmp word [envseg], 0
  8311 0000351A 7404                    	je @F
  8312 0000351C 0136[0000]              	add word [envseg], si
  8313                                  @@:
  8314                                    %endif
  8315                                   %else
  8316                                  init_app_layout_common:
  8317                                   %endif
  8318 00003520 2E0136[360E]            	add word [cs:memsize], si
  8319 00003525 8E06[0000]              	mov es, word [auxbuff_segorsel + soaSegSel]
  8320 00003529 BF1020                  	mov di, fromwords(words(_AUXBUFFSIZE))
  8321 0000352C 89F1                    	mov cx, si			; = amount paragraphs added
  8322 0000352E D1E1                    	shl cx, 1			; = amount qwords
  8323 00003530 D1E1                    	shl cx, 1			; = amount dwords
  8324 00003532 D1E1                    	shl cx, 1			; = amount words
  8325 00003534 31C0                    	xor ax, ax
  8326 00003536 F3AB                    	rep stosw			; initialise auxbuff trail
  8327 00003538 F8                      	clc
  8328 00003539 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 0000353A A1[0000]                	mov ax, word [code_seg]
  8347 0000353D 89C2                    	mov dx, ax
  8348 0000353F 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 00003541 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 00003544 2E030E[380E]            	add cx, word [cs:mem_envsize]
  8366                                  %endif
  8367 00003549 E836E6                  	call init_movp
  8368                                  
  8369 0000354C 8EC2                    	mov es, dx
  8370 0000354E 0136[0000]              	add word [code_seg], si
  8371                                  %if _DUALCODE
  8372 00003552 0136[0000]              	add word [code2_seg], si
  8373 00003556 8B16[0000]              	mov dx, word [code2_seg]
  8374                                  repatch_relocate:
  8375 0000355A 56                      	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 0000355B 06                      	push es
  8384 0000355C 8EC2                    	mov es, dx
  8385 0000355E 5A                      	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 0000355F 5E                      	pop si
  8402                                  %endif
  8403                                  
  8404                                  %if _AREAS && _AREAS_HOOK_CLIENT
  8405 00003560 89F0                    	mov ax, si
  8406 00003562 E83600                  	call add_to_areas_linear_code1
  8407                                   %if _DUALCODE && _EXPRDUALCODE
  8408 00003565 89F0                    	mov ax, si
  8409 00003567 E85D00                  	call add_to_areas_linear_code2
  8410                                   %endif
  8411                                  %endif
  8412                                  
  8413 0000356A EB92                    	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 0000356C E87DFF                  	call init_app_layout_1
  8452 0000356F 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 00003571 E8C6FF                  	call init_app_layout_2
  8464 00003574 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 00003576 E873FF                  	call init_app_layout_3
  8485                                  init_dev_layout_common:
  8486 00003579 0136[0000]              	add word [device_mcb_paragraphs], si
  8487                                  					; fix our variable
  8488 0000357D 0136[0000]              	add word [alloc_size], si	; this one too
  8489 00003581 8CD8                    	mov ax, ds			; => PSP
  8490 00003583 2E0306[360E]            	add ax, word [cs:memsize]	; => where to place container sig
  8491 00003588 E8E3D5                  	call init_dev_place_container_signature
  8492                                  					; CHG: es, di, cx, si
  8493                                  					; ax => behind memory used for device
  8494 0000358B 8E06[0000]              	mov es, word [reg_es]
  8495 0000358F 8B1E[0000]              	mov bx, word [reg_ebx]		; -> device request header
  8496 00003593 26894710                	mov word [es:bx + 0Eh + 2], ax	; -> behind memory in use
  8497 00003597 F8                      	clc
  8498 00003598 C3                      	retn
  8499                                  %endif
  8500                                  
  8501                                  
  8502                                  init_layout_none:
  8503 00003599 F9                      	stc
  8504 0000359A C3                      	retn
  8505                                  
  8506                                  
  8507                                  %if _AREAS && _AREAS_HOOK_CLIENT
  8508                                  add_to_areas_linear_code1:
  8509 0000359B 31D2                    	xor dx, dx
  8510                                  .dxax:
  8511 0000359D B90400                  	mov cx, 4
  8512                                  @@:
  8513 000035A0 D1E0                    	shl ax, 1
  8514 000035A2 D1D2                    	rcl dx, 1
  8515 000035A4 E2FA                    	loop @B
  8516                                  
  8517 000035A6 0106[0000]              	add word [areas_sub + areastrucsubLinear], ax
  8518 000035AA 1116[0200]              	adc word [areas_sub + areastrucsubLinear + 2], dx
  8519 000035AE 0106[0400]              	add word [areas_sub + areastrucsubLinearEnd], ax
  8520 000035B2 1116[0600]              	adc word [areas_sub + areastrucsubLinearEnd + 2], dx
  8521                                  
  8522 000035B6 0106[0000]              	add word [areas_fun + areastrucfunLinear], ax
  8523 000035BA 1116[0200]              	adc word [areas_fun + areastrucfunLinear + 2], dx
  8524 000035BE 0106[0400]              	add word [areas_fun + areastrucfunLinearEnd], ax
  8525 000035C2 1116[0600]              	adc word [areas_fun + areastrucfunLinearEnd + 2], dx
  8526 000035C6 C3                      	retn
  8527                                  
  8528                                   %if _DUALCODE && _EXPRDUALCODE
  8529                                  add_to_areas_linear_code2:
  8530 000035C7 31D2                    	xor dx, dx
  8531                                  .dxax:
  8532 000035C9 B90400                  	mov cx, 4
  8533                                  @@:
  8534 000035CC D1E0                    	shl ax, 1
  8535 000035CE D1D2                    	rcl dx, 1
  8536 000035D0 E2FA                    	loop @B
  8537                                  
  8538 000035D2 0106[0C00]              	add word [areas_sub + AREASTRUCSUB_size + areastrucsubLinear], ax
  8539 000035D6 1116[0E00]              	adc word [areas_sub + AREASTRUCSUB_size + areastrucsubLinear + 2], dx
  8540 000035DA 0106[1000]              	add word [areas_sub + AREASTRUCSUB_size + areastrucsubLinearEnd], ax
  8541 000035DE 1116[1200]              	adc word [areas_sub + AREASTRUCSUB_size + areastrucsubLinearEnd + 2], dx
  8542 000035E2 C3                      	retn
  8543                                   %endif
  8544                                  %endif
  8545                                  
  8546                                  
  8547                                  %if _CONFIG
  8548                                  do_truename:
  8549                                  .:
  8550 000035E3 16                      	push ss
  8551 000035E4 1F                      	pop ds
  8552 000035E5 89D6                    	mov si, dx		; ds:si -> source
  8553 000035E7 16                      	push ss
  8554 000035E8 07                      	pop es
  8555 000035E9 89D7                    	mov di, dx		; es:di -> destination (same)
  8556 000035EB B460                    	mov ah, 60h
  8557 000035ED CD21                    	int 21h
  8558 000035EF 7309                    	jnc .done
  8559 000035F1 803C00                  	cmp byte [si], 0	; empty ? (kernel rejects this)
  8560 000035F4 C7042E00                	mov word [si], "."	; make a dot + NUL (current directory)
  8561 000035F8 74E9                    	je .			; if expected failure then repeat -->
  8562                                  
  8563                                  .done:
  8564 000035FA B000                    	mov al, 0
  8565 000035FC B98000                  	mov cx, 128
  8566 000035FF F2AE                    	repne scasb		; scan for NUL
  8567 00003601 4F                      	dec di			; -> at the NUL
  8568                                  
  8569                                  @@:
  8570 00003602 39F7                    	cmp di, si
  8571 00003604 760C                    	jbe @F
  8572 00003606 807DFF2F                	cmp byte [di - 1], '/'
  8573 0000360A 740A                    	je @FF
  8574 0000360C 807DFF5C                	cmp byte [di - 1], '\'
  8575 00003610 7404                    	je @FF
  8576                                  @@:
  8577 00003612 C6055C                  	mov byte [di], '\'
  8578 00003615 47                      	inc di
  8579                                  @@:
  8580 00003616 C3                      	retn
  8581                                  %endif
  8582                                  
  8583                                  
  8584                                  %if _EXTENSIONS
  8585                                  init_eld:
  8586 00003617 16                      	push ss
  8587 00003618 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 00003619 A1[0000]                	mov ax, word [extseg_size]
  8626 0000361C 8B3E[0000]              	mov di, word [extseg_used]
  8627 00003620 29F8                    	sub ax, di			; = amount free space
  8628 00003622 7239                    	jc .ret
  8629 00003624 3D8000                  	cmp ax, eld_linkcall_size	; enough ?
  8630 00003627 7234                    	jb .ret
  8631 00003629 89F8                    	mov ax, di			; -> where to install this ELD
  8632 0000362B 8E06[0000]              	mov es, word [extseg]		; es:di -> where to place ELD instance
  8633 0000362F 0E                      	push cs
  8634 00003630 1F                      	pop ds				; ! ds no longer equals ss
  8635 00003631 BE[B20D]                	mov si, eld_linkcall + 2	; ds:si -> ELD source plus one word
  8636 00003634 B93E00                  	mov cx, eld_linkcall_size_w - 2	; cx = length less two words
  8637 00003637 AB                      	stosw				; init eldiStartCode
  8638 00003638 A5                      	movsw
  8639 00003639 260145FE                	add word [es:di - 2], ax	; init eldiEndCode
  8640 0000363D F3A5                    	rep movsw			; write our ELD
  8641 0000363F 16                      	push ss
  8642 00003640 1F                      	pop ds
  8643 00003641 893E[0000]              	mov word [extseg_used], di	; -> behind ELD
  8644 00003645 83C028                  	add ax, eld_linkcall.to_code1 - eld_linkcall
  8645 00003648 A3[0000]                	mov word [linkcall_table.code1], ax
  8646                                   %if _DUALCODE
  8647 0000364B 83C008                  	add ax, eld_linkcall.to_code2 - eld_linkcall.to_code1
  8648 0000364E A3[0000]                	mov word [linkcall_table.code2], ax
  8649 00003651 83C0F0                  	add ax, eld_linkcall.to_entry - eld_linkcall.to_code2
  8650                                   %else
  8651                                  	add ax, eld_linkcall.to_entry - eld_linkcall.to_code1
  8652                                   %endif
  8653 00003654 A3[0000]                	mov word [linkcall_table.entry], ax
  8654 00003657 C706[0000]0100          	mov word [linkcall_table.init], 1
  8655                                  .ret:
  8656 0000365D 16                      	push ss
  8657 0000365E 1F                      	pop ds
  8658 0000365F 16                      	push ss
  8659 00003660 07                      	pop es
  8660 00003661 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
