     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-03-28)"
    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
   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> lsCheckOffset:	resw 1	; offset in file segment of word to check
   815 00000016 ????                <1> lsCheckValue:	resw 1	; value to check for word, 0 if unused
   816 00000018 ????????????????    <1> lsName:		resq 1	; ASCIZ load protocol name
   817                              <1> 	endstruc
   818                              <1> 
   819                              <1> 		numdef LUF_DEFAULT_DISKETTE, 0
   820                              <1> 		numdef LUF_DEFAULT_HARDDISK, 0
   821                              <1> %endif
   822                              <1> 
   823                              <1> 
   824                              <1> %include "mzheader.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug MZ .EXE header macros
     5                              <2> 
     6                              <2> Copyright (C) 1995-2003 Paul Vojta
     7                              <2> Copyright (C) 2008-2023 E. C. Masloch
     8                              <2> 
     9                              <2> Usage of the works is permitted provided that this
    10                              <2> instrument is retained with the works, so that any entity
    11                              <2> that uses the works is notified of this instrument.
    12                              <2> 
    13                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    14                              <2> 
    15                              <2> %endif
    16                              <2> 
    17                              <2> 
    18                              <2> 	struc EXEHEADER
    19 00000000 ????                <2> exact_struc_at 00h, exeSignature:	resw 1
    20 00000002 ????                <2> exact_struc_at 02h, exeExtraBytes:	resw 1	; bytes in last page
    21 00000004 ????                <2> exact_struc_at 04h, exePages:		resw 1	; number of 512-byte pages. includes the header!
    22 00000006 ????                <2> exact_struc_at 06h, exeRelocItems:	resw 1	; number of relocation items
    23 00000008 ????                <2> exact_struc_at 08h, exeHeaderSize:	resw 1	; header size in 16-byte paragraphs
    24 0000000A ????                <2> exact_struc_at 0Ah, exeMinAlloc:	resw 1	; minimum (bss) allocation in paragraphs
    25 0000000C ????                <2> exact_struc_at 0Ch, exeMaxAlloc:	resw 1	; maximum (bss) allocation in paragraphs
    26 0000000E ????                <2> exact_struc_at 0Eh, exeInitSS:		resw 1	; init ss (is relocated)
    27 00000010 ????                <2> exact_struc_at 10h, exeInitSP:		resw 1	; init sp
    28 00000012 ????                <2> exact_struc_at 12h, exeChecksum:	resw 1
    29                              <2> exact_struc_at 14h, exeInitCSIP:
    30 00000014 ????                <2> exact_struc_at 14h, exeInitIP:		resw 1	; init ip
    31 00000016 ????                <2> exact_struc_at 16h, exeInitCS:		resw 1	; init cs (is relocated)
    32 00000018 ????                <2> exact_struc_at 18h, exeRelocTable:	resw 1	; byte offset of relocation table
    33                              <2> 		; Each relocation item is a word offset and a word segment.
    34                              <2> 		;  The segment of the item itself is relocated as well.
    35 0000001A ????                <2> exact_struc_at 1Ah, exeOverlayNum:	resw 1
    36                              <2> exact_struc_at 1Ch
    37                              <2> 	endstruc
   825                              <1> 
   826                              <1> 
   827                              <1> 	struc INPUTFILEHANDLE
   828 00000000 ????                <1> ifhHandle:	resw 1
   829 00000002 ????                <1> ifhFlags:	resw 1
   830 00000004 ????????            <1> ifhParentSeek:	resd 1
   831                              <1> 	endstruc
   832                              <1> 
   833                              <1> ifhfIsDup:		equ  100h	; before closing, seek it back
   834                              <1> 	; same value as LBA flag for boot load input files
   835                              <1> ifhfTestReserved1:	equ 1000h
   836                              <1> ifhfTestReserved2:	equ 2000h
   837                              <1> ifhfQuietInput:		equ 4000h	; do not display prompt and input
   838                              <1> ifhfQuietOutput:	equ 8000h	; do not display normal output
   839                              <1> 	; these four are valid for both input file handles and
   840                              <1> 	;  boot load input files.
   841                              <1> 
   842                              <1> 
   843                              <1> 	struc AREASTRUC
   844 00000000 <res 18h>           <1> areastrucEntry:		resb 24
   845 00000018 ????????            <1> areastrucNext:		resd 1
   846 0000001C ????????            <1> areastrucPrev:		resd 1
   847 00000020 ????                <1> areastrucSubAmount:	resw 1
   848 00000022 ????                <1> areastrucSubOffset:	resw 1
   849 00000024 ????                <1> areastrucFunAmount:	resw 1
   850 00000026 ????                <1> areastrucFunOffset:	resw 1
   851                              <1> 	endstruc
   852                              <1> 
   853                              <1> 	struc AREASTRUCSUB
   854 00000000 ????????            <1> areastrucsubLinear:	resd 1
   855 00000004 ????????            <1> areastrucsubLinearEnd:	resd 1
   856 00000008 ????                <1> areastrucsubListOffset:	resw 1
   857 0000000A ????                <1> areastrucsubListAmount:	resw 1
   858                              <1> 	endstruc
   859                              <1> 
   860                              <1> 	struc AREASTRUCFUN
   861 00000000 ????????            <1> areastrucfunLinear:	resd 1
   862 00000004 ????????            <1> areastrucfunLinearEnd:	resd 1
   863 00000008 ????                <1> areastrucfunListOffset:	resw 1
   864 0000000A ????                <1> areastrucfunListAmount:	resw 1
   865                              <1> 	endstruc
   866                              <1> 
   867                              <1> 	struc AREA
   868 00000000 ????                <1> areastart:		resw 1
   869 00000002 ????                <1> areaend:		resw 1
   870 00000004 ????                <1> areamessage:		resw 1
   871 00000006 ????                <1> 			resw 1
   872                              <1> 	endstruc
   873                              <1> 
   874                              <1> 
   875                              <1> %include "isvariab.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug isvariable? function strutures and macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2025 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 
    17                              <2> 	struc ISVARIABLESTRUC
    18 00000000 ????                <2> ivName:		resw 1		; -> name (up to 13 bytes, but actually only 11)
    19                              <2> 				;  (search for ivfNameLengthLimit for limit)
    20                              <2> 				;  (length given by ivFlags & ivfNameLengthMask)
    21                              <2> 	; The ivName pointer is only used for more-byte names. It actually
    22                              <2> 	;  contains the trailer of the name, excluding the prefix formed by
    23                              <2> 	;  the first two bytes. This suffix can be the empty string if the
    24                              <2> 	;  variable in question has a two-byte name.
    25                              <2> 	; (For one-byte names this field is unused and contains zero.)
    26 00000002 ????                <2> ivFlags:	resw 1
    27 00000004 ????                <2> ivAddress:	resw 1		; default -> variable
    28                              <2> 	; The ivAddress field is used by default_variable_setup as the base
    29                              <2> 	;  address for the variable(s). It is also used by var_ext_setup as
    30                              <2> 	;  the ELD code section offset to transfer control to. Otherwise, it
    31                              <2> 	;  is usually set to zero and unused.
    32 00000006 ????                <2> ivSetup:	resw 1		; -> set up code (in expr code section)
    33                              <2> 	; INP:	ax = array index (0-based)
    34                              <2> 	;	di = 0
    35                              <2> 	;	cl = default size of variable (1..4)
    36                              <2> 	;	ch = length of variable name
    37                              <2> 	;	bx -> ISVARIABLESTRUC structure
    38                              <2> 	; CHG:	ax, bx, cx, dx, si, di
    39                              <2> 	; OUT:	NC if valid,
    40                              <2> 	;	 bx -> var, di = 0 or di -> mask
    41                              <2> 	;	 cl = size of variable (1..4)
    42                              <2> 	;	 ch = length of variable name
    43 00000008 ??                  <2> ivArrayLast:	resb 1		; 0 if no array, FFh = 256 entries
    44                              <2> 	; The ivArrayLast field is used by the dispatcher to determine
    45                              <2> 	;  whether to support array index expressions. It is checked
    46                              <2> 	;  before decrementing the index if ivfArrayOneBased is set.
    47 00000009 ??                  <2> ivArrayBetween: resb 1		; how many bytes to skip for each index
    48                              <2> 	; The ivArrayBetween field is only used by default_variable_setup.
    49                              <2> 	endstruc
    50                              <2> 
    51                              <2> ivfNameLengthMask:	equ 15	; gives name trailer length, 0 to 11
    52                              <2> ivfNameLengthLimit:	equ 13
    53                              <2> ivfVarLengthShift:	equ 4
    54                              <2> ivfVarLengthMask:	equ 3 << ivfVarLengthShift
    55                              <2> 				; gives default variable size minus 1
    56                              <2> ivfReadOnly:		equ 80h	; variable cannot be written at all
    57                              <2> ivfArrayOneBased:	equ 100h; first array entry is 1 not 0 (ivArrayLast > 0)
    58                              <2> ivfArrayOptional:	equ 200h; array index expression is optional
    59                              <2> ivfSeparatorSpecial:	equ 400h; used for RIxxP/L/S/O
    60                              <2> 
    61                              <2> %define ISVARIABLESTRINGS db "",db ""
    62                              <2> %define IVS_ONEBYTE_NAMES ""
    63                              <2> %define IVS_MOREBYTE_NAMEHEADERS ""
    64                              <2> %assign IVS_HAVE_ONEBYTE 0
    65                              <2> %assign IVS_SINGLE_ONEBYTE 1
    66                              <2> 
    67                              <2> 		; %1 = name string
    68                              <2> 		; %2 = default variable length, 1 to 4
    69                              <2> 		; %3 = flags to set (except name length and var length)
    70                              <2> 		; %4 = ivAddress value
    71                              <2> 		; %5 = ivArrayLast, defaults to 0 (no array)
    72                              <2> 		; %6 = ivArrayBetween, defaults to 0 (immediately consecutive)
    73                              <2> 		; %7 = ivSetup, defaults to default_variable_setup
    74                              <2> 	%macro isvariablestruc 4-7.nolist 0, 0, default_variable_setup
    75                              <2> %push
    76                              <2> %strlen %$namelength %1
    77                              <2> %if %$namelength > ivfNameLengthLimit
    78                              <2>  %error Expected at most 13-byte name (or adjust isvariable? code)
    79                              <2> %endif
    80                              <2> %if IVS_ONEBYTE && %$namelength != 1
    81                              <2>  %error Expected a one-byte name
    82                              <2> %elif ! IVS_ONEBYTE && %$namelength < 2
    83                              <2>  %error Expected at least a two-byte name
    84                              <2> %endif
    85                              <2> %if IVS_ONEBYTE
    86                              <2>  %define IVS_SINGLE_ONEBYTE_NAME %1
    87                              <2>  %if IVS_HAVE_ONEBYTE
    88                              <2>   %assign IVS_SINGLE_ONEBYTE 0
    89                              <2>  %endif
    90                              <2>  %assign IVS_HAVE_ONEBYTE 1
    91                              <2>  %assign %$namelength 0
    92                              <2>  %xdefine IVS_ONEBYTE_NAMES IVS_ONEBYTE_NAMES, %1
    93                              <2>  %%name equ 0
    94                              <2> %else
    95                              <2>  %assign %$namelength %$namelength - 2
    96                              <2>  %substr %$nametrailer %1 3,-1
    97                              <2>  %substr %$nameheader %1 1,2
    98                              <2>  %xdefine IVS_MOREBYTE_NAMEHEADERS IVS_MOREBYTE_NAMEHEADERS, %$nameheader
    99                              <2>  %xdefine ISVARIABLESTRINGS ISVARIABLESTRINGS, %%name:, {db %$nametrailer}
   100                              <2> %endif
   101                              <2> 
   102                              <2> %assign %$varlength %2 - 1	; 0 means one byte, 1 means two bytes,
   103                              <2> 				;  2 means three bytes, 3 means four bytes
   104                              <2> 	istruc ISVARIABLESTRUC
   105                              <2> at ivName,		dw %%name
   106                              <2>  IV_NAME_RELOCATION
   107                              <2> at ivFlags,		dw %$$namelength | (%$$varlength << ivfVarLengthShift) | %3
   108                              <2> at ivAddress,		dw %4
   109                              <2>  IV_ADDRESS_RELOCATION
   110                              <2> at ivSetup,		dw %7
   111                              <2>  IV_SETUP_RELOCATION
   112                              <2> at ivArrayLast,		db %5
   113                              <2> at ivArrayBetween,	db %6
   114                              <2> 	iend
   115                              <2> %pop
   116                              <2> %ifndef SECTION_OF_%7
   117                              <2>  %error Unknown target section for symbol %7
   118                              <2> %elifnidni %[SECTION_OF_%7], _EXPR_SECTION
   119                              <2>  %error Wrong section for symbol %7: section_of=SECTION_OF_%7, expr=_EXPR_SECTION
   120                              <2> %endif
   121                              <2> 	%endmacro
   122                              <2> 
   123                              <2> %define IV_NAME_RELOCATION
   124                              <2> %define IV_ADDRESS_RELOCATION
   125                              <2> %define IV_SETUP_RELOCATION
   126                              <2> 
   127                              <2> 	%macro isvariablestrings 2-*.nolist
   128                              <2> %rep %0
   129                              <2>  %1
   130                              <2>  %rotate 1
   131                              <2> %endrep
   132                              <2> 	%endmacro
   876                              <1> 
   877                              <1> 
   878                              <1> %include "386.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug 386 patch macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2026 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 	numdef LINK, 0
    17                              <2> 
    18                              <2> 	numdef WPT_LABELS, 0
    19                              <2> 		; This used to be required, because CODESECTIONFIXUP used
    20                              <2> 		;  ldebug_data_entry_size, which is not yet defined during
    21                              <2> 		;  assembling of (most) lDEBUG_CODE fragments.
    22                              <2> 		; However, assembling DebugX with this option selected
    23                              <2> 		;  took more than 2 minutes, so the non-label variant
    24                              <2> 		;  is clearly to be preferred when available.
    25                              <2> 		; Now that lDEBUG_CODE has vstart=0 we can use the
    26                              <2> 		;  CODESECTIONFIXUP again and thus disable this option.
    27                              <2> 
    28                              <2> %ifn _LINK
    29                              <2> %define PATCH_NO386_TABLE ""
    30                              <2> %define PATCH_386_TABLE ""
    31                              <2> %define PATCH_NO386_TABLE2 ""
    32                              <2> %define PATCH_386_TABLE2 ""
    33                              <2> %define PATCH_NO386_TABLEENTRY ""
    34                              <2> %define PATCH_386_TABLEENTRY ""
    35                              <2> %endif
    36                              <2> 
    37                              <2> %if _ONLY386
    38                              <2> 		; Default patch macros if only running on 386+.
    39                              <2> %define _386_o32 o32
    40                              <2> %define _386_a32 a32
    41                              <2> %define _386_jmps jmp short
    42                              <2> %define _386_jmpn jmp near
    43                              <2> %define _no386_jmps comment
    44                              <2> %define _no386_jmpn comment
    45                              <2> 	%macro _386 0-1+.nolist
    46                              <2> [cpu 386]			; change CPU type
    47                              <2> 		%1		; write instruction
    48                              <2> __CPU__				; reset CPU type
    49                              <2> 	%endmacro
    50                              <2> %define _no386 comment
    51                              <2> %elif _ONLYNON386
    52                              <2> 		; Default patch macros if only running on non-386.
    53                              <2> %define _386_o32
    54                              <2> %define _386_a32
    55                              <2> %define _386_jmps comment
    56                              <2> %define _386_jmpn comment
    57                              <2> %define _no386_jmps jmp short
    58                              <2> %define _no386_jmpn jmp near
    59                              <2> %define _386 comment
    60                              <2> %define _no386
    61                              <2> %else
    62                              <2> 
    63                              <2> ; These macros are to make DEBUG's 386 support as small as
    64                              <2> ; possible. To achieve this, two patch tables are created
    65                              <2> ; in the initialisation code. One of the tables is used if
    66                              <2> ; the CPU is a 386+, the other one if it isn't. The bytes
    67                              <2> ; pointed to in the used table are over-written with NOP
    68                              <2> ; instructions. (The patched bytes are usually address or
    69                              <2> ; operand size prefixes or jumps that branch to 386/non-386
    70                              <2> ; code.)
    71                              <2> 
    72                              <2> ; There are a few special patches that require the
    73                              <2> ; initialisation code to write specific bytes other than
    74                              <2> ; NOP instructions for lower resident memory usage.
    75                              <2> ; Two are in the run: code, three in pmentry.asm.
    76                              <2> 
    77                              <2> %if _LINK
    78                              <2> 
    79                              <2> %imacro wllist 1-3.nolist
    80                              <2> %ifnempty %3
    81                              <2>  %deftok %%filenametoken %3
    82                              <2> %else
    83                              <2>  %deftok %%filenametoken __FILE__
    84                              <2> %endif
    85                              <2>  global ..@wllist_%1?%[%%l]%[%%filenametoken]
    86                              <2> ..@wllist_%1?%[%%l]%[%%filenametoken]: %2
    87                              <2> %endmacro
    88                              <2> 
    89                              <2> 	%macro patch386 2-3.nolist 1
    90                              <2> %define %%repeat
    91                              <2> %if %3 != 1
    92                              <2>  %define %%repeat r%3_
    93                              <2> %endif
    94                              <2> %ifidn _CURRENT_SECTION, lDEBUG_CODE
    95                              <2>  wllist %[%%repeat]Lpatch_%{1}386_table, %2
    96                              <2> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
    97                              <2>  wllist %[%%repeat]Lpatch_%{1}386_table2, %2
    98                              <2> %elifidn _CURRENT_SECTION, lDEBUG_DATA_ENTRY
    99                              <2>  wllist %[%%repeat]Lpatch_%{1}386_tableentry, %2
   100                              <2> %else
   101                              <2>  %error Wrong section
   102                              <2> %endif
   103                              <2> 	%endmacro
   104                              <2> 
   105                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   106                              <2> 	%macro _386_o32 0-1+.nolist
   107                              <2> _386		o32
   108                              <2> 		%1
   109                              <2> 	%endmacro
   110                              <2> 
   111                              <2> 		; Address size 32-bit prefix if 386+ CPU
   112                              <2> 	%macro _386_a32 0-1+.nolist
   113                              <2> _386		a32
   114                              <2> 		%1
   115                              <2> 	%endmacro
   116                              <2> 
   117                              <2> 		; Short jump if 386+ CPU
   118                              <2> 	%macro _386_jmps 1.nolist
   119                              <2> _386		jmp short %1
   120                              <2> 	%endmacro
   121                              <2> 
   122                              <2> 		; Near jump if 386+ CPU
   123                              <2> 	%macro _386_jmpn 1.nolist
   124                              <2> _386		jmp near %1
   125                              <2> 	%endmacro
   126                              <2> 
   127                              <2> 		; Short jump if no 386+ CPU
   128                              <2> 	%macro _no386_jmps 1.nolist
   129                              <2> _no386		jmp short %1
   130                              <2> 	%endmacro
   131                              <2> 
   132                              <2> 		; Near jump if no 386+ CPU
   133                              <2> 	%macro _no386_jmpn 1.nolist
   134                              <2> _no386		jmp near %1
   135                              <2> 	%endmacro
   136                              <2> 
   137                              <2> 		; Instruction if 386+ CPU
   138                              <2> 	%macro _386 0-1+.nolist
   139                              <2> [cpu 386]			; change CPU type
   140                              <2> %%entry:
   141                              <2> 		%1		; write instruction
   142                              <2> __CPU__				; reset CPU type
   143                              <2> %assign %%length ($ - %%entry)
   144                              <2>  patch386 no, equ %%entry, %%length
   145                              <2> 	%endmacro
   146                              <2> 
   147                              <2> 		; Instruction if no 386+ CPU
   148                              <2> 	%macro _no386 0-1+.nolist
   149                              <2> %%entry:
   150                              <2> 		%1		; write instruction
   151                              <2> %assign %%length ($ - %%entry)
   152                              <2>  patch386 , equ %%entry, %%length
   153                              <2> 	%endmacro
   154                              <2> 
   155                              <2> %else
   156                              <2> 	%macro patch386 2+.nolist
   157                              <2> %ifidn _CURRENT_SECTION, lDEBUG_CODE
   158                              <2>  %define PATCH_%{1}386_TABLE %[PATCH_%{1}386_TABLE], %2
   159                              <2> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
   160                              <2>  %define PATCH_%{1}386_TABLE2 %[PATCH_%{1}386_TABLE2], %2
   161                              <2> %elifidn _CURRENT_SECTION, lDEBUG_DATA_ENTRY
   162                              <2>  %define PATCH_%{1}386_TABLEENTRY %[PATCH_%{1}386_TABLEENTRY], %2
   163                              <2> %else
   164                              <2>  %error Wrong section
   165                              <2> %endif
   166                              <2> 	%endmacro
   167                              <2> 
   168                              <2> %if _WPT_LABELS
   169                              <2> 	; These forms provide verbose info by defining a
   170                              <2> 	; meaningful label for each patch. That fills up
   171                              <2> 	; the map file and might take longer though.
   172                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   173                              <2> 	%macro _386_o32 0-1+.nolist
   174                              <2> %%386_o32:	o32
   175                              <2> patch386 NO, %%386_o32
   176                              <2> 		%1
   177                              <2> 	%endmacro
   178                              <2> 
   179                              <2> 		; Address size 32-bit prefix if 386+ CPU
   180                              <2> 	%macro _386_a32 0-1+.nolist
   181                              <2> %%386_a32:	a32
   182                              <2> patch386 NO, %%386_a32
   183                              <2> 		%1
   184                              <2> 	%endmacro
   185                              <2> 
   186                              <2> 		; Short jump if 386+ CPU
   187                              <2> 	%macro _386_jmps 1.nolist
   188                              <2> %%386_jmps:	jmp short %1
   189                              <2> patch386 NO, %%386_jmps,%%386_jmps+1
   190                              <2> 	%endmacro
   191                              <2> 
   192                              <2> 		; Near jump if 386+ CPU
   193                              <2> 	%macro _386_jmpn 1.nolist
   194                              <2> %%386_jmpn:	jmp near %1
   195                              <2> patch386 NO, %%386_jmpn,%%386_jmpn+1,%%386_jmpn+2
   196                              <2> 	%endmacro
   197                              <2> 
   198                              <2> 		; Short jump if no 386+ CPU
   199                              <2> 	%macro _no386_jmps 1.nolist
   200                              <2> %%no386_jmps:	jmp short %1
   201                              <2> patch386 , %%no386_jmps,%%no386_jmps+1
   202                              <2> 	%endmacro
   203                              <2> 
   204                              <2> 		; Near jump if no 386+ CPU
   205                              <2> 	%macro _no386_jmpn 1.nolist
   206                              <2> %%no386_jmpn:	jmp near %1
   207                              <2> patch386 , %%no386_jmpn,%%no386_jmpn+1,%%no386_jmpn+2
   208                              <2> 	%endmacro
   209                              <2> 
   210                              <2> 		; Instruction if 386+ CPU
   211                              <2> 	%macro _386 0-1+.nolist
   212                              <2> [cpu 386]			; change CPU type
   213                              <2> %%386_instr:	%1		; write instruction
   214                              <2> __CPU__				; reset CPU type
   215                              <2> 
   216                              <2> %assign %%INSTRCOUNT 0
   217                              <2> %rep $-%%386_instr		; count size of instruction
   218                              <2>  patch386 NO, %%386_instr+%[%%INSTRCOUNT]
   219                              <2> 				; write a patch for each byte
   220                              <2>  %assign %%INSTRCOUNT %%INSTRCOUNT+1
   221                              <2> %endrep
   222                              <2> %undef %%INSTRCOUNT
   223                              <2> 	%endmacro
   224                              <2> 
   225                              <2> 		; Instruction if no 386+ CPU
   226                              <2> 	%macro _no386 0-1+.nolist
   227                              <2> %%no386_instr:	%1		; write instruction
   228                              <2> 
   229                              <2> %assign %%INSTRCOUNT 0
   230                              <2> %rep $-%%no386_instr		; count size of instruction
   231                              <2>  patch386 , %%no386_instr+%[%%INSTRCOUNT]
   232                              <2> 				; write a patch for each byte
   233                              <2>  %assign %%INSTRCOUNT %%INSTRCOUNT+1
   234                              <2> %endrep
   235                              <2> %undef %%INSTRCOUNT
   236                              <2> 	%endmacro
   237                              <2> %else	; _WPT_LABELS
   238                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   239                              <2> 	%macro _386_o32 0-1+.nolist
   240                              <2> _386		o32
   241                              <2> 		%1
   242                              <2> 	%endmacro
   243                              <2> 
   244                              <2> 		; Address size 32-bit prefix if 386+ CPU
   245                              <2> 	%macro _386_a32 0-1+.nolist
   246                              <2> _386		a32
   247                              <2> 		%1
   248                              <2> 	%endmacro
   249                              <2> 
   250                              <2> 		; Short jump if 386+ CPU
   251                              <2> 	%macro _386_jmps 1.nolist
   252                              <2> _386		jmp short %1
   253                              <2> 	%endmacro
   254                              <2> 
   255                              <2> 		; Near jump if 386+ CPU
   256                              <2> 	%macro _386_jmpn 1.nolist
   257                              <2> _386		jmp near %1
   258                              <2> 	%endmacro
   259                              <2> 
   260                              <2> 		; Short jump if no 386+ CPU
   261                              <2> 	%macro _no386_jmps 1.nolist
   262                              <2> _no386		jmp short %1
   263                              <2> 	%endmacro
   264                              <2> 
   265                              <2> 		; Near jump if no 386+ CPU
   266                              <2> 	%macro _no386_jmpn 1.nolist
   267                              <2> _no386		jmp near %1
   268                              <2> 	%endmacro
   269                              <2> 
   270                              <2> 		; Instruction if 386+ CPU
   271                              <2> 	%macro _386 0-1+.nolist
   272                              <2> %push
   273                              <2> [cpu 386]			; change CPU type
   274                              <2> %assign %$entry $ + _CURRENT_SECTION %+ FIXUP
   275                              <2> 		%1		; write instruction
   276                              <2> __CPU__				; reset CPU type
   277                              <2> 
   278                              <2> %rep ($ + _CURRENT_SECTION %+ FIXUP) - %$entry
   279                              <2> 				; count size of instruction
   280                              <2>  patch386 NO, %[%$entry]	; write a patch for each byte
   281                              <2>  %assign %$entry %$entry+1
   282                              <2> %endrep
   283                              <2> %pop
   284                              <2> 	%endmacro
   285                              <2> 
   286                              <2> 		; Instruction if no 386+ CPU
   287                              <2> 	%macro _no386 0-1+.nolist
   288                              <2> %push
   289                              <2> %assign %$entry $ + _CURRENT_SECTION %+ FIXUP
   290                              <2> 		%1		; write instruction
   291                              <2> 
   292                              <2> %rep ($ + _CURRENT_SECTION %+ FIXUP) - %$entry
   293                              <2> 				; count size of instruction
   294                              <2>  patch386 , %[%$entry]		; write a patch for each byte
   295                              <2>  %assign %$entry %$entry+1
   296                              <2> %endrep
   297                              <2> %pop
   298                              <2> 	%endmacro
   299                              <2> %endif	; _WPT_LABELS
   300                              <2> %endif	; _LINK
   301                              <2> 
   302                              <2> %endif
   303                              <2> 
   304                              <2> 		; Patch macros but for cases where the 386+
   305                              <2> 		; instructions should only be generated for
   306                              <2> 		; DEBUGX (i.e. for 32-bit DPMI addressing code).
   307                              <2> %if _PM
   308                              <2> %define _386_PM_o32	_386_o32
   309                              <2> %define _386_PM_a32	_386_a32
   310                              <2> %define _386_PM_jmps	_386_jmps
   311                              <2> %define _386_PM_jmpn	_386_jmpn
   312                              <2> %define _386_PM		_386
   313                              <2> %else
   314                              <2> %define _386_PM_o32
   315                              <2> %define _386_PM_a32
   316                              <2> %define _386_PM_jmps	comment
   317                              <2> %define _386_PM_jmpn	comment
   318                              <2> %define _386_PM		comment
   319                              <2> %endif
   320                              <2> 
   321                              <2> 
   322                              <2> %ifn _LINK
   323                              <2> %macro __writepatchtable2 0-*.nolist
   324                              <2> %if %0 & 1
   325                              <2>  %fatal Expected even number of arguments
   326                              <2> %endif
   327                              <2> %rep %0 >> 1
   328                              <2> 	%1 %2
   329                              <2> %rotate 2
   330                              <2> %endrep
   331                              <2> %endmacro
   332                              <2> 
   333                              <2> %macro __patchtable2_entry 0.nolist
   334                              <2>   ; only if this isn't the first (pseudo-)entry
   335                              <2>   %if %$lastcount != 0
   336                              <2>     %assign %$runscount %[%$runscount]+1
   337                              <2>    ; if the offset from %$previous is less than 255
   338                              <2>    %if (%$last-%$previous) < 255
   339                              <2>     %assign %$$method2tablesize %$$method2tablesize+1
   340                              <2>     ; then write a single byte (number of bytes not to patch between)
   341                              <2>     %xdefine %$$method2list %$$method2list,db,%$last-%$previous
   342                              <2>    %else
   343                              <2>     ; otherwise write a 255 ("reposition") and write the 16-bit address afterwards
   344                              <2>     %assign %$$method2tablesize %$$method2tablesize+3
   345                              <2>     %xdefine %$$method2list %$$method2list,db,255,dw,%$last
   346                              <2>     %assign %$reposcount %[%$reposcount]+1
   347                              <2>    %endif
   348                              <2>    %if %$lastcount == 1
   349                              <2>     %assign %$onecount %[%$onecount]+1
   350                              <2>    %endif
   351                              <2>    %assign %$$method2tablesize %$$method2tablesize+1
   352                              <2>    ; and write the number of bytes to be patched
   353                              <2>    %xdefine %$$method2list %$$method2list,db,%$lastcount
   354                              <2>    ; define %$previous for the next entry: it points to the next non-patched byte
   355                              <2>    %define %$previous (%[%$last]+%[%$lastcount])
   356                              <2>   %endif
   357                              <2> %endmacro
   358                              <2> 
   359                              <2> %macro writepatchtable 2-*.nolist
   360                              <2> 
   361                              <2> 	numdef %{1}_FORCE_METHOD, 0
   362                              <2> %push
   363                              <2> 		; Determine length of simple table:
   364                              <2> %assign %$method1tablesize (%0 - 2)*2
   365                              <2> 
   366                              <2> %if !_%{1}_FORCE_METHOD || _%{1}_FORCE_METHOD == 2
   367                              <2> 		; Determine length of complicated table:
   368                              <2> %assign %$method2tablesize 0
   369                              <2> %define %$method2list db,""
   370                              <2> %push
   371                              <2> %if _WPT_LABELS
   372                              <2>  %define %$previous code_start	; if list contains labels
   373                              <2> %else
   374                              <2>  %define %$previous 0
   375                              <2> %endif
   376                              <2> %define %$last %[%$previous]
   377                              <2> %assign %$lastcount 0
   378                              <2> %assign %$onecount 0
   379                              <2> %assign %$reposcount 0
   380                              <2> %assign %$bytescount %0 - 2
   381                              <2> %assign %$runscount 0
   382                              <2> %rotate 1
   383                              <2> %rep %0 - 2
   384                              <2>  %rotate 1
   385                              <2>  ;if  it continues the previous patch   and not too long   and this isn't the first
   386                              <2>  %if ((%$last+%$lastcount) == %1) && (%$lastcount < 255) && (%$lastcount != 0)
   387                              <2>   ; then do not write an entry, just increase the patch's size
   388                              <2>   %assign %$lastcount %[%$lastcount]+1
   389                              <2>  %else
   390                              <2>   ; otherwise write the last entry
   391                              <2>   __patchtable2_entry
   392                              <2>   ; define new %$last to this parameter, %$lastcount to one
   393                              <2>   %define %$last %1
   394                              <2>   %assign %$lastcount 1
   395                              <2>  %endif
   396                              <2> %endrep
   397                              <2> __patchtable2_entry
   398                              <2> 
   399                              <2> ; at the end, there's a patch with offset 0, size 0
   400                              <2> %assign %$$method2tablesize %$$method2tablesize+2
   401                              <2> %xdefine %$$method2list %$$method2list,db,0,db,0
   402                              <2> 
   403                              <2> %assign %$$onecount %$onecount
   404                              <2> %assign %$$reposcount %$reposcount
   405                              <2> %assign %$$bytescount %$bytescount
   406                              <2> %assign %$$runscount %$runscount
   407                              <2> %pop
   408                              <2> %rotate 1
   409                              <2> %endif
   410                              <2> 
   411                              <2> %if _%{1}_FORCE_METHOD == 2
   412                              <2>  %define __%{1}_method 2
   413                              <2> %elif _%{1}_FORCE_METHOD == 1
   414                              <2>  %define __%{1}_method 1
   415                              <2> %else
   416                              <2>  %if _%{1}_FORCE_METHOD
   417                              <2>   %fatal Invalid forced method selected: _%{1}_FORCE_METHOD
   418                              <2>  %endif
   419                              <2>  %if %$method1tablesize > (%$method2tablesize+20)
   420                              <2>   %define __%{1}_method 2
   421                              <2>  %else
   422                              <2>   %define __%{1}_method 1
   423                              <2>  %endif
   424                              <2> %endif
   425                              <2> 
   426                              <2> 
   427                              <2> %1:
   428                              <2> %if __%{1}_method == 2
   429                              <2> 	__writepatchtable2 %$method2list
   430                              <2> 	endarea %1
   431                              <2> %assign %$size %1_size
   432                              <2> %warning %1: %$size bytes (Method 2)
   433                              <2> %warning 1B=%$onecount repo=%$reposcount run=%$runscount byte=%$bytescount
   434                              <2> %else
   435                              <2> %rotate 1
   436                              <2> %rep %0 - 2
   437                              <2> %rotate 1
   438                              <2> 	dw %1
   439                              <2> %endrep
   440                              <2> %rotate 1
   441                              <2> 	endarea %1
   442                              <2> %assign %$size %1_size
   443                              <2> %warning %1: %$size bytes (Method 1)
   444                              <2> %1.amount equ %1_size_w
   445                              <2> %endif
   446                              <2> %pop
   447                              <2> %endmacro
   448                              <2> %endif
   879                              <1> 
   880                              <1> 
   881                              <1> %if _VDD
   882                              <1> ; standard BOPs for communication with DEBXXVDD on NT platforms
   883                              <1> %macro RegisterModule 0.nolist
   884                              <1> 	db 0C4h, 0C4h, 58h, 0
   885                              <1> 	nop
   886                              <1> %endmacro
   887                              <1> %macro UnRegisterModule 0.nolist
   888                              <1> 	db 0C4h, 0C4h, 58h, 1
   889                              <1> 	nop
   890                              <1> %endmacro
   891                              <1> %macro DispatchCall 0.nolist
   892                              <1> 	db 0C4h, 0C4h, 58h, 2
   893                              <1> 	nop
   894                              <1> %endmacro
   895                              <1> %endif
   896                              <1> 
   897                              <1> %assign CODE_INSURE_COUNT 0
   898                              <1> 
   899                              <1> 		; The entry_to_code_seg/_sel dispatcher in lDEBUG_DATA_ENTRY
   900                              <1> 		;  detects mistaken debugger breakpoints in its
   901                              <1> 		;  in-code-parameter by checking for a low-byte
   902                              <1> 		;  value equal to 0CCh (one-byte int3 opcode).
   903                              <1> 		; Therefore, we insure that all destinations jumped to
   904                              <1> 		;  via that dispatcher do not happen to be located
   905                              <1> 		;  on an offset that gives 0CCh in the low byte.
   906                              <1> 	%imacro code_insure_low_byte_not_0CCh 0.nolist
   907                              <1> %ifn _LINK
   908                              <1>  %if (($ - _CURRENT_SECTION %+ _start) & 0FFh) == 0CCh
   909                              <1> 	nop
   910                              <1>   %assign CODE_INSURE_COUNT 1 + CODE_INSURE_COUNT
   911                              <1>  %endif
   912                              <1> %endif
   913                              <1> 	%endmacro
   914                              <1> 
   915                              <1> 
   916                              <1> 		; dual code segments
   917                              <1> %if _DUALCODE && _PM
   918                              <1> 
   919                              <1> %if _DEBUG
   920                              <1> %idefine dualfunction comment
   921                              <1> %else
   922                              <1> %idefine dualfunction code_insure_low_byte_not_0CCh
   923                              <1> %endif
   924                              <1> 
   925                              <1> %idefine dualreturn call _CURRENT_SECTION %+ _dualret_helper
   926                              <1> %idefine dualdistance far
   927                              <1> 	%imacro dualcall 1.nolist
   928                              <1> %ifndef SECTION_OF_%1
   929                              <1>  %error Unknown target section for symbol %1
   930                              <1> %endif
   931                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _dualcall_helper
   932                              <1>  %if _DEBUG
   933                              <1> 	jmp strict short %%skipdata
   934                              <1>  %endif
   935                              <1> 	dw %1
   936                              <1> %%skipdata:
   937                              <1> 	%endmacro
   938                              <1> 	%imacro nearcall 1.nolist
   939                              <1> %ifndef SECTION_OF_%1
   940                              <1>  %error Unknown target section for symbol %1
   941                              <1> %endif
   942                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
   943                              <1> 	call %1
   944                              <1> %else
   945                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _nearcall_helper
   946                              <1>  %if _DEBUG
   947                              <1> 	jmp strict short %%skipdata
   948                              <1>  %endif
   949                              <1> 	dw %1
   950                              <1> %%skipdata:
   951                              <1> %endif
   952                              <1> 	%endmacro
   953                              <1> 
   954                              <1> %elif _DUALCODE && ! _PM
   955                              <1> 
   956                              <1> %idefine dualfunction comment
   957                              <1> %idefine dualreturn
   958                              <1> %idefine dualdistance far
   959                              <1> 
   960                              <1> %ifn _LINK
   961                              <1> %define PATCH_RELOCATE_FROM_lDEBUG_CODE ""
   962                              <1> %define PATCH_RELOCATE_FROM_lDEBUG_CODE2 ""
   963                              <1> 	%imacro dualcall 1.nolist
   964                              <1> %ifndef SECTION_OF_%1
   965                              <1>  %error Unknown target section for symbol %1
   966                              <1> %endif
   967                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
   968                              <1> 	push cs
   969                              <1> 	call %1
   970                              <1> %else
   971                              <1> 	call relocatedzero:%1
   972                              <1> %push
   973                              <1> %assign %$entry ($ + _CURRENT_SECTION %+ FIXUP) - 2
   974                              <1> 	relocatelist _CURRENT_SECTION, %$entry
   975                              <1> %pop
   976                              <1> %endif
   977                              <1> 	%endmacro
   978                              <1> 	%imacro relocatelist 2.nolist
   979                              <1>  %define PATCH_RELOCATE_FROM_%1 %[PATCH_RELOCATE_FROM_%1],%2
   980                              <1> 	%endmacro
   981                              <1> %else		; _LINK
   982                              <1> 	%idefine dualcall dualcall_with_filename __FILE__,
   983                              <1> 	%imacro dualcall_with_filename 2.nolist
   984                              <1> %ifndef SECTION_OF_%2
   985                              <1>  %error Unknown target section for symbol %2
   986                              <1> %endif
   987                              <1> %ifidni %[SECTION_OF_%2], _CURRENT_SECTION
   988                              <1> 	push cs
   989                              <1> 	call %2
   990                              <1> %else
   991                              <1> 	call relocatedzero:%2
   992                              <1> %ifidn _CURRENT_SECTION, lDEBUG_CODE
   993                              <1>  wllist Lrelocate_from_code, equ $ - 2, %1
   994                              <1> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
   995                              <1>  wllist Lrelocate_from_code2, equ $ - 2, %1
   996                              <1> %else
   997                              <1>  %error Wrong section
   998                              <1> %endif
   999                              <1> %endif
  1000                              <1> 	%endmacro
  1001                              <1> %endif		; _LINK
  1002                              <1>  %if _DUALCODENEARDUAL
  1003                              <1> 
  1004                              <1> %if _LINK
  1005                              <1> 	%idefine nearcall nearcall_with_filename __FILE__,
  1006                              <1> 	%imacro nearcall_with_filename 2
  1007                              <1> %ifndef SECTION_OF_%2
  1008                              <1>  %error Unknown target section for symbol %2
  1009                              <1> %endif
  1010                              <1> %ifidni %[SECTION_OF_%2], _CURRENT_SECTION
  1011                              <1> 	call %2
  1012                              <1> %else
  1013                              <1>  %push
  1014                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1015                              <1>  %xdefine %$targetsection SECTION_OF_%2
  1016                              <1>  %deftok %%filenametoken SOURCEFILENAME
  1017                              <1>   %ifndef NEARCALL_THUNK_TO_%2%[%%filenametoken]
  1018                              <1> 	hiddenusesection %$targetsection
  1019                              <1> %define NEARCALL_THUNK_TO_%2%[%%filenametoken] %%nearcall_thunk_to_%2%[%%filenametoken]
  1020                              <1> section_of %%nearcall_thunk_to_%2%[%%filenametoken]
  1021                              <1> dualfunction
  1022                              <1> %%nearcall_thunk_to_%2%[%%filenametoken]:
  1023                              <1> 	call %2
  1024                              <1> 	dualreturn
  1025                              <1> 	retf
  1026                              <1> 
  1027                              <1> 	hiddenusesection %$originalsection
  1028                              <1>   %endif
  1029                              <1>  %pop
  1030                              <1> 	dualcall_with_filename %1, NEARCALL_THUNK_TO_%2%[%%filenametoken]
  1031                              <1> %endif
  1032                              <1> 	%endmacro
  1033                              <1> %elif _LINK_COMPAT	; _LINK
  1034                              <1> 	%imacro nearcall 1
  1035                              <1> %ifndef SECTION_OF_%1
  1036                              <1>  %error Unknown target section for symbol %1
  1037                              <1> %endif
  1038                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1039                              <1> 	call %1
  1040                              <1> %else
  1041                              <1>  %push
  1042                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1043                              <1>  %xdefine %$targetsection SECTION_OF_%1
  1044                              <1>  %deftok %%filenametoken SOURCEFILENAME
  1045                              <1>   %ifndef NEARCALL_THUNK_TO_%1%[%%filenametoken]
  1046                              <1> 	hiddenusesection %$targetsection
  1047                              <1> %define NEARCALL_THUNK_TO_%1%[%%filenametoken] %%nearcall_thunk_to_%1%[%%filenametoken]
  1048                              <1> section_of %%nearcall_thunk_to_%1%[%%filenametoken]
  1049                              <1> dualfunction
  1050                              <1> %%nearcall_thunk_to_%1%[%%filenametoken]:
  1051                              <1> 	call %1
  1052                              <1> 	dualreturn
  1053                              <1> 	retf
  1054                              <1> 
  1055                              <1> 	hiddenusesection %$originalsection
  1056                              <1>   %endif
  1057                              <1>  %pop
  1058                              <1> 	dualcall NEARCALL_THUNK_TO_%1%[%%filenametoken]
  1059                              <1> %endif
  1060                              <1> 	%endmacro
  1061                              <1> %else		; _LINK, _LINK_COMPAT
  1062                              <1> 	%imacro nearcall 1
  1063                              <1> %ifndef SECTION_OF_%1
  1064                              <1>  %error Unknown target section for symbol %1
  1065                              <1> %endif
  1066                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1067                              <1> 	call %1
  1068                              <1> %else
  1069                              <1>  %push
  1070                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1071                              <1>  %xdefine %$targetsection SECTION_OF_%1
  1072                              <1>   %ifndef NEARCALL_THUNK_TO_%1
  1073                              <1> 	hiddenusesection %$targetsection
  1074                              <1> %define NEARCALL_THUNK_TO_%1 %%nearcall_thunk_to_%1
  1075                              <1> section_of %%nearcall_thunk_to_%1
  1076                              <1> dualfunction
  1077                              <1> %%nearcall_thunk_to_%1:
  1078                              <1> 	call %1
  1079                              <1> 	dualreturn
  1080                              <1> 	retf
  1081                              <1> 
  1082                              <1> 	hiddenusesection %$originalsection
  1083                              <1>   %endif
  1084                              <1>  %pop
  1085                              <1> 	dualcall NEARCALL_THUNK_TO_%1
  1086                              <1> %endif
  1087                              <1> 	%endmacro
  1088                              <1> %endif		; _LINK, _LINK_COMPAT
  1089                              <1>  %else
  1090                              <1> 	%imacro nearcall 1.nolist
  1091                              <1> %ifndef SECTION_OF_%1
  1092                              <1>  %error Unknown target section for symbol %1
  1093                              <1> %endif
  1094                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1095                              <1> 	call %1
  1096                              <1> %else
  1097                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _nearcall_helper
  1098                              <1>  %if _DEBUG
  1099                              <1> 	jmp strict short %%skipdata
  1100                              <1>  %endif
  1101                              <1> 	dw %1
  1102                              <1> %%skipdata:
  1103                              <1> %endif
  1104                              <1> 	%endmacro
  1105                              <1>  %endif
  1106                              <1> %elif ! _DUALCODE
  1107                              <1> 
  1108                              <1> %idefine dualfunction comment
  1109                              <1> %idefine dualreturn
  1110                              <1> %idefine dualdistance near
  1111                              <1> 	%imacro dualcall 1.nolist
  1112                              <1> 	call %1
  1113                              <1> 	%endmacro
  1114                              <1> 	%imacro nearcall 1.nolist
  1115                              <1> 	call %1
  1116                              <1> 	%endmacro
  1117                              <1> %assign _SYMBOLICDUALCODE 0
  1118                              <1> %assign _SYMBOLASMDUALCODE 0
  1119                              <1> 
  1120                              <1> %else
  1121                              <1>  %error Unexpected defines
  1122                              <1> %endif
  1123                              <1> 
  1124                              <1> %ifn _SYMBOLICDUALCODE
  1125                              <1>  %assign _SYMBOLASMDUALCODE 0
  1126                              <1> %endif
  1127                              <1> 
  1128                              <1>  %if _SYMBOLIC && _DUALCODE && _SYMBOLASMDUALCODE
  1129                              <1> %idefine dual2function	dualfunction
  1130                              <1> %idefine dual2return	dualreturn
  1131                              <1> %idefine dual2distance	dualdistance
  1132                              <1> %idefine dual2call	dualcall
  1133                              <1>  %else
  1134                              <1> %idefine dual2function comment
  1135                              <1> %idefine dual2return
  1136                              <1> %idefine dual2distance near
  1137                              <1> 	%imacro dual2call 1.nolist
  1138                              <1> 	call %1
  1139                              <1> 	%endmacro
  1140                              <1>  %endif
  1141                              <1> 
  1142                              <1> 
  1143                              <1> 	numdef CHECKSECTION, 0
  1144                              <1> 	numdef CHECKCALLSECTION, _CHECKSECTION
  1145                              <1> 	numdef CHECKJMPSECTION, _CHECKSECTION
  1146                              <1> 	numdef CHECKJCCSECTION, _CHECKSECTION
  1147                              <1> 
  1148                              <1> %if _CHECKCALLSECTION
  1149                              <1> 	%imacro call 1.nolist
  1150                              <1> 	%? %1
  1151                              <1> checksection %1, %?, call
  1152                              <1> 	%endmacro
  1153                              <1> %endif
  1154                              <1> %if _CHECKJMPSECTION
  1155                              <1> 	%imacro jmp 1.nolist
  1156                              <1> 	%? %1
  1157                              <1> checksection %1, %?, jmp
  1158                              <1> 	%endmacro
  1159                              <1> %endif
  1160                              <1> %if _CHECKJCCSECTION
  1161                              <1> 	%imacro je 1.nolist
  1162                              <1> 	%? %1
  1163                              <1> checksection %1, %?, jcc
  1164                              <1> 	%endmacro
  1165                              <1> 	%imacro jne 1.nolist
  1166                              <1> 	%? %1
  1167                              <1> checksection %1, %?, jcc
  1168                              <1> 	%endmacro
  1169                              <1> 	%imacro jz 1.nolist
  1170                              <1> 	%? %1
  1171                              <1> checksection %1, %?, jcc
  1172                              <1> 	%endmacro
  1173                              <1> 	%imacro jnz 1.nolist
  1174                              <1> 	%? %1
  1175                              <1> checksection %1, %?, jcc
  1176                              <1> 	%endmacro
  1177                              <1> 
  1178                              <1> 	%imacro jb 1.nolist
  1179                              <1> 	%? %1
  1180                              <1> checksection %1, %?, jcc
  1181                              <1> 	%endmacro
  1182                              <1> 	%imacro jnb 1.nolist
  1183                              <1> 	%? %1
  1184                              <1> checksection %1, %?, jcc
  1185                              <1> 	%endmacro
  1186                              <1> 	%imacro jbe 1.nolist
  1187                              <1> 	%? %1
  1188                              <1> checksection %1, %?, jcc
  1189                              <1> 	%endmacro
  1190                              <1> 	%imacro jnbe 1.nolist
  1191                              <1> 	%? %1
  1192                              <1> checksection %1, %?, jcc
  1193                              <1> 	%endmacro
  1194                              <1> 	%imacro jc 1.nolist
  1195                              <1> 	%? %1
  1196                              <1> checksection %1, %?, jcc
  1197                              <1> 	%endmacro
  1198                              <1> 	%imacro jnc 1.nolist
  1199                              <1> 	%? %1
  1200                              <1> checksection %1, %?, jcc
  1201                              <1> 	%endmacro
  1202                              <1> 	%imacro ja 1.nolist
  1203                              <1> 	%? %1
  1204                              <1> checksection %1, %?, jcc
  1205                              <1> 	%endmacro
  1206                              <1> 	%imacro jna 1.nolist
  1207                              <1> 	%? %1
  1208                              <1> checksection %1, %?, jcc
  1209                              <1> 	%endmacro
  1210                              <1> 	%imacro jae 1.nolist
  1211                              <1> 	%? %1
  1212                              <1> checksection %1, %?, jcc
  1213                              <1> 	%endmacro
  1214                              <1> 	%imacro jnae 1.nolist
  1215                              <1> 	%? %1
  1216                              <1> checksection %1, %?, jcc
  1217                              <1> 	%endmacro
  1218                              <1> 
  1219                              <1> 	%imacro jl 1.nolist
  1220                              <1> 	%? %1
  1221                              <1> checksection %1, %?, jcc
  1222                              <1> 	%endmacro
  1223                              <1> 	%imacro jnl 1.nolist
  1224                              <1> 	%? %1
  1225                              <1> checksection %1, %?, jcc
  1226                              <1> 	%endmacro
  1227                              <1> 	%imacro jle 1.nolist
  1228                              <1> 	%? %1
  1229                              <1> checksection %1, %?, jcc
  1230                              <1> 	%endmacro
  1231                              <1> 	%imacro jnle 1.nolist
  1232                              <1> 	%? %1
  1233                              <1> checksection %1, %?, jcc
  1234                              <1> 	%endmacro
  1235                              <1> 	%imacro jg 1.nolist
  1236                              <1> 	%? %1
  1237                              <1> checksection %1, %?, jcc
  1238                              <1> 	%endmacro
  1239                              <1> 	%imacro jng 1.nolist
  1240                              <1> 	%? %1
  1241                              <1> checksection %1, %?, jcc
  1242                              <1> 	%endmacro
  1243                              <1> 	%imacro jge 1.nolist
  1244                              <1> 	%? %1
  1245                              <1> checksection %1, %?, jcc
  1246                              <1> 	%endmacro
  1247                              <1> 	%imacro jnge 1.nolist
  1248                              <1> 	%? %1
  1249                              <1> checksection %1, %?, jcc
  1250                              <1> 	%endmacro
  1251                              <1> 
  1252                              <1> 	%imacro jo 1.nolist
  1253                              <1> 	%? %1
  1254                              <1> checksection %1, %?, jcc
  1255                              <1> 	%endmacro
  1256                              <1> 	%imacro jno 1.nolist
  1257                              <1> 	%? %1
  1258                              <1> checksection %1, %?, jcc
  1259                              <1> 	%endmacro
  1260                              <1> 	%imacro jp 1.nolist
  1261                              <1> 	%? %1
  1262                              <1> checksection %1, %?, jcc
  1263                              <1> 	%endmacro
  1264                              <1> 	%imacro jnp 1.nolist
  1265                              <1> 	%? %1
  1266                              <1> checksection %1, %?, jcc
  1267                              <1> 	%endmacro
  1268                              <1> 	%imacro jpe 1.nolist
  1269                              <1> 	%? %1
  1270                              <1> checksection %1, %?, jcc
  1271                              <1> 	%endmacro
  1272                              <1> 	%imacro jnpe 1.nolist
  1273                              <1> 	%? %1
  1274                              <1> checksection %1, %?, jcc
  1275                              <1> 	%endmacro
  1276                              <1> 	%imacro jpo 1.nolist
  1277                              <1> 	%? %1
  1278                              <1> checksection %1, %?, jcc
  1279                              <1> 	%endmacro
  1280                              <1> 	%imacro jnpo 1.nolist
  1281                              <1> 	%? %1
  1282                              <1> checksection %1, %?, jcc
  1283                              <1> 	%endmacro
  1284                              <1> 	%imacro js 1.nolist
  1285                              <1> 	%? %1
  1286                              <1> checksection %1, %?, jcc
  1287                              <1> 	%endmacro
  1288                              <1> 	%imacro jns 1.nolist
  1289                              <1> 	%? %1
  1290                              <1> checksection %1, %?, jcc
  1291                              <1> 	%endmacro
  1292                              <1> 
  1293                              <1> 	%imacro jcxz 1.nolist
  1294                              <1> 	%? %1
  1295                              <1> checksection %1, %?, jcc
  1296                              <1> 	%endmacro
  1297                              <1> 	%imacro jecxz 1.nolist
  1298                              <1> 	%? %1
  1299                              <1> checksection %1, %?, jcc
  1300                              <1> 	%endmacro
  1301                              <1> 	%imacro loop 1.nolist
  1302                              <1> 	%? %1
  1303                              <1> checksection %1, %?, jcc
  1304                              <1> 	%endmacro
  1305                              <1> 	%imacro loopz 1.nolist
  1306                              <1> 	%? %1
  1307                              <1> checksection %1, %?, jcc
  1308                              <1> 	%endmacro
  1309                              <1> 	%imacro loopnz 1.nolist
  1310                              <1> 	%? %1
  1311                              <1> checksection %1, %?, jcc
  1312                              <1> 	%endmacro
  1313                              <1> 	%imacro loope 1.nolist
  1314                              <1> 	%? %1
  1315                              <1> checksection %1, %?, jcc
  1316                              <1> 	%endmacro
  1317                              <1> 	%imacro loopne 1.nolist
  1318                              <1> 	%? %1
  1319                              <1> checksection %1, %?, jcc
  1320                              <1> 	%endmacro
  1321                              <1> %endif
  1322                              <1> 
  1323                              <1> 	%imacro checksection 3.nolist
  1324                              <1> %push
  1325                              <1>  %defstr %$string %1
  1326                              <1>  %substr %$shortword %$string 1, 5
  1327                              <1>  %substr %$shortsep %$string 6, 1
  1328                              <1>  %substr %$nearword %$string 1, 4
  1329                              <1>  %substr %$nearsep %$string 5, 1
  1330                              <1>  %substr %$farword %$string 1, 3
  1331                              <1>  %substr %$farsep %$string 4, 1
  1332                              <1>  %assign %$isshort 0
  1333                              <1>  %ifidni %$shortword, "short"
  1334                              <1>   %if %$shortsep == 32 || %$shortsep == 9
  1335                              <1>    %assign %$isshort 1
  1336                              <1>    %substr %$string %$string 7, -1
  1337                              <1>   %elif %$shortsep == '['
  1338                              <1>    %assign %$isshort 1
  1339                              <1>    %substr %$string %$string 6, -1
  1340                              <1>   %endif
  1341                              <1>  %endif
  1342                              <1>  %assign %$isnear 0
  1343                              <1>  %ifidni %$nearword, "near"
  1344                              <1>   %if %$nearsep == 32 || %$nearsep == 9
  1345                              <1>    %assign %$isnear 1
  1346                              <1>    %substr %$string %$string 6, -1
  1347                              <1>   %elif %$nearsep == '['
  1348                              <1>    %assign %$isnear 1
  1349                              <1>    %substr %$string %$string 5, -1
  1350                              <1>   %endif
  1351                              <1>  %endif
  1352                              <1>  %assign %$isfar 0
  1353                              <1>  %ifidni %$farword, "far"
  1354                              <1>   %if %$farsep == 32 || %$farsep == 9
  1355                              <1>    %assign %$isfar 1
  1356                              <1>    %substr %$string %$string 5, -1
  1357                              <1>   %elif %$farsep == '['
  1358                              <1>    %assign %$isfar 1
  1359                              <1>    %substr %$string %$string 4, -1
  1360                              <1>   %endif
  1361                              <1>  %endif
  1362                              <1> 
  1363                              <1>  %deftok %$token %$string
  1364                              <1> 
  1365                              <1>  %assign %$size 2
  1366                              <1>  %assign %$isreg 0
  1367                              <1>  %assign %$exit 0
  1368                              <1>  %rep 2
  1369                              <1>   %ifn %$exit
  1370                              <1>    %if %$size == 2
  1371                              <1>     %define %$regnames "ax  cx  dx  bx  sp  bp  si  di  "
  1372                              <1>    %elif %$size == 4
  1373                              <1>     %define %$regnames "eax ecx edx ebx esp ebp esi edi "
  1374                              <1>    %endif
  1375                              <1>    %assign %$index 0
  1376                              <1>    %rep 8
  1377                              <1>     %ifn %$exit
  1378                              <1>      %substr %$reg %$regnames %$index * 4 + 1, 4
  1379                              <1>      %deftok %$reg %$reg
  1380                              <1>      %ifnempty %$reg
  1381                              <1>       %ifidni %$reg, %$token
  1382                              <1>        %assign %$isreg %$size
  1383                              <1>        %assign %$exit 1
  1384                              <1>        %exitrep
  1385                              <1>       %endif
  1386                              <1>      %endif
  1387                              <1>     %endif
  1388                              <1>     %assign %$index %$index + 1
  1389                              <1>    %endrep
  1390                              <1>    %if %$exit
  1391                              <1>     %exitrep
  1392                              <1>    %endif
  1393                              <1>    %assign %$size %$size * 2
  1394                              <1>   %endif
  1395                              <1>  %endrep
  1396                              <1> 
  1397                              <1>  %assign %$ismulti 0
  1398                              <1>  %assign %$ismem 0
  1399                              <1>  %strlen %$length %$string
  1400                              <1>  %assign %$ii 0
  1401                              <1>  %rep %$length
  1402                              <1>   %substr %$point %$string %$ii + 1, 1
  1403                              <1>   %if %$point == 32 || %$point == 9
  1404                              <1>    %assign %$ismulti 1
  1405                              <1>   %endif
  1406                              <1>   %ifidn %$point, '['
  1407                              <1>    %assign %$ismem 1
  1408                              <1>   %endif
  1409                              <1>   %assign %$ii %$ii + 1
  1410                              <1>  %endrep
  1411                              <1> 
  1412                              <1>  %assign %$islocal 0
  1413                              <1>  %substr %$point %$string 1, 1
  1414                              <1>  %substr %$prefix %$string 1, 3
  1415                              <1>  %ifidn %$point, '.'
  1416                              <1>   %ifnidn %$prefix, '..@'
  1417                              <1>    %assign %$islocal 1
  1418                              <1>   %endif
  1419                              <1>  %endif
  1420                              <1> 
  1421                              <1>  %if %$isreg
  1422                              <1>   %if %$isreg == 4
  1423                              <1>    %warning 32-bit reg %3: %2 %1
  1424                              <1>   %else
  1425                              <1>    %warning 16-bit reg %3: %2 %1
  1426                              <1>   %endif
  1427                              <1>  %elif %$ismulti || %$ismem
  1428                              <1>   %warning not single %3: %2 %1
  1429                              <1>  %elif %$islocal
  1430                              <1>   %ifidni %3, call
  1431                              <1>    %warning local %3: %2 %1
  1432                              <1>   %endif
  1433                              <1>  %elifdef SECTION_OF_%[%$token]
  1434                              <1>   %ifnidni SECTION_OF_%[%$token], _CURRENT_SECTION
  1435                              <1>    %error Symbol %$token called wrongly: section_of=SECTION_OF_%[%$token], current=_CURRENT_SECTION
  1436                              <1>   %endif
  1437                              <1>  %endif
  1438                              <1> %pop
  1439                              <1> 	%endmacro
  1440                              <1> 
  1441                              <1> 
  1442                              <1> 	struc MEMREF
  1443 00000000 ????????            <1> mrLinear:		resd 1
  1444 00000004 ????????            <1> mrOffset:		resd 1
  1445 00000008 ????                <1> mrSegmentSelector:	resw 1
  1446 0000000A ????                <1> mrFlags:		resw 1
  1447 0000000C ????????            <1> mrLength:		resd 1
  1448                              <1> 	endstruc
  1449                              <1> 
  1450                              <1> 		; Currently only direct branches are allowed when
  1451                              <1> 		;  disassembling from the U command. (That is,
  1452                              <1> 		;  [disflags] & DIS_F_SHOW is clear.) All other
  1453                              <1> 		;  types of references depend on segment registers
  1454                              <1> 		;  and sometimes base and index registers, which are
  1455                              <1> 		;  not known ahead of time. They are only known for
  1456                              <1> 		;  the R command's disassembly. (DIS_F_SHOW set.)
  1457                              <1> 		; (When a mov ss or pop to ss will change ss, a
  1458                              <1> 		;  subsequent instruction using ss will not be
  1459                              <1> 		;  disassembled with the correct ss value.
  1460                              <1> 		;  This should be rare though. We may at a later
  1461                              <1> 		;  point detect this condition and not display
  1462                              <1> 		;  references with ss then.)
  1463                              <1> mrfBranchDirect:	equ    1
  1464                              <1> mrfMem:			equ    2
  1465                              <1> mrfMemSource:		equ    4
  1466                              <1> mrfMemDest:		equ    8
  1467                              <1> mrfA32:			equ   10h
  1468                              <1> mrfString:		equ   20h
  1469                              <1> mrfStringSource:	equ   40h
  1470                              <1> mrfStringDest:		equ   80h
  1471                              <1> mrfUsesSS:		equ  100h
  1472                              <1> mrfBranchIndirect:	equ  200h
  1473                              <1> 
  1474                              <1> 
  1475                              <1> %if _VXCHG && ! _VXCHGBIOS
  1476                              <1> 	struc XMSM
  1477 00000000 ????????            <1> .size_:		resd 1
  1478 00000004 ????                <1> .srchdl:	resw 1
  1479 00000006 ????????            <1> .srcadr:	resd 1
  1480 0000000A ????                <1> .dsthdl:	resw 1
  1481 0000000C ????????            <1> .dstadr:	resd 1
  1482                              <1> 	endstruc
  1483                              <1> %endif
  1484                              <1> 
  1485                              <1> 
  1486                              <1> 	; doscall is used by symbols.asm and run.asm and in
  1487                              <1> 	;  cmd3_close_handle, so define it prior
  1488                              <1> %if _PM && _NOEXTENDER
  1489                              <1> %macro doscall 0
  1490                              <1> 	nearcall _doscall
  1491                              <1> %endmacro
  1492                              <1> %else
  1493                              <1> 		; When we don't support non-extended DPMI all Int21 calls
  1494                              <1> 		; are either in Real Mode or extended (all are real Int21
  1495                              <1> 		; instructions).
  1496                              <1> %macro doscall 0
  1497                              <1> 	int 21h
  1498                              <1> %endmacro
  1499                              <1> %endif
  1500                              <1> 
  1501                              <1> 
  1502                              <1> %if _LINK
  1503                              <1> %imacro wlcalc 1-2.nolist
  1504                              <1> %deftok %%filenametoken __FILE__
  1505                              <1>  global wlcalc_%1?%[%%l]%[%%filenametoken]
  1506                              <1> wlcalc_%1?%[%%l]%[%%filenametoken]: %2
  1507                              <1> %endmacro
  1508                              <1> %endif
  1509                              <1> 
  1510                              <1> %if _BOOTLDR && _LINK
  1511                              <1> %macro lot_equate 2.nolist
  1512                              <1> LOAD_%2 equ %1
  1513                              <1> %endmacro
  1514                              <1> 
  1515                              <1> 	lot_equate    1, SET_DL_UNIT
  1516                              <1> 	lot_equate    2, SET_BL_UNIT
  1517                              <1> 	lot_equate    4, SET_SIDI_CLUSTER
  1518                              <1> 	lot_equate  10h, SET_DSSI_DPT
  1519                              <1> 	lot_equate  20h, PUSH_DPT
  1520                              <1> 	lot_equate  40h, DATASTART_HIDDEN
  1521                              <1> 	lot_equate  80h, SET_AXBX_DATASTART
  1522                              <1> 	lot_equate 100h, SET_DSBP_BPB
  1523                              <1> 	lot_equate 200h, LBA_SET_TYPE
  1524                              <1> 	lot_equate 400h, MESSAGE_TABLE
  1525                              <1> 	lot_equate 800h, SET_AXBX_ROOT_HIDDEN
  1526                              <1> 	lot_equate 1000h, CMDLINE
  1527                              <1> 	lot_equate 2000h, NO_BPB
  1528                              <1> 	lot_equate 4000h, SET_DSSI_PARTINFO
  1529                              <1> %endif
  1530                              <1> 
  1531                              <1> %if _HELP_COMPRESSED
  1532                              <1>  %assign NONCOMPRESSEDFLAG 1
  1533                              <1> %else
  1534                              <1>  %assign NONCOMPRESSEDFLAG 0
  1535                              <1> %endif
  1536                              <1> 
  1537                              <1> [list +]
  1538                              <1> 
  1539                              <1> %if _LINK
  1540                              <1>  %if _ONLY386
  1541                              <1> 	cpu 386
  1542                              <1>  %else
  1543                              <1> 	cpu 8086
  1544                              <1>  %endif
  1545                              <1> 
  1546                              <1> auxbuff_size: equ (_AUXBUFFSIZE+15) & ~15
  1547                              <1> 	endarea auxbuff, 1
  1548                              <1> 
  1549                              <1> auxbuff_max_size: equ (_AUXBUFFMAXSIZE+15) & ~15
  1550                              <1> 	endarea auxbuff_max, 1
  1551                              <1> 
  1552                              <1> %if _INIT_MAX
  1553                              <1>  auxbuff_init_size: equ (_AUXBUFFMAXSIZE+15) & ~15
  1554                              <1> %else
  1555                              <1>  auxbuff_init_size: equ (_AUXBUFFSIZE+15) & ~15
  1556                              <1> %endif
  1557                              <1> 	endarea auxbuff_init, 1
  1558                              <1> 
  1559                              <1>  %include "options.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug options and internal flags
     5                              <2> 
     6                              <2> Copyright (C) 2008-2025 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 
    17                              <2> dispregs32	equ	  1	; RX: 32-bit register display (R, T/P/G)
    18                              <2> traceints	equ	  2	; TM: trace into interrupts (T)
    19                              <2> cpdepchars	equ	  4	; allow dumping of CP-dependent characters (D, DX)
    20                              <2> fakeindos	equ	  8	; always assume InDOS flag non-zero (all)
    21                              <2> nonpagingdevice	equ	 10h	; disallow paged output with [more] prompt (all exc. P, T)
    22                              <2> 	; This option was never used anywhere:
    23                              <2> ; pagingdevice	equ	 20h	; allow paged output with [more] prompt (all exc. P, T)
    24                              <2> 				; paged output is by default on if the output device is StdOut, else off
    25                              <2> hexrn		equ	 40h	; display raw hexadecimal content of FPU registers (RN)
    26                              <2> ;novdd		equ	 80h	; don't use a registered NTVDM VDD (L, W)
    27                              <2> nondospaging	equ	100h	; paging: don't use DOS for input when waiting for a key
    28                              <2> opt1_86mnohlt	equ	200h	; (86 Mode:) HLT doesn't work, don't use it
    29                              <2> biosidles	equ	400h	; don't idle with HLT or Int2F.1680, only call BIOS Int16.00
    30                              <2> opt_usegetinput	equ	800h	; use getinput for int 21h interactive input
    31                              <2> use_si_units	equ    1000h	; in disp_*_size use SI units (kB = 1000, etc)
    32                              <2> use_jedec_units	equ    2000h	; in disp_*_size use JEDEC units (kB = 1024)
    33                              <2> enable_serial	equ    4000h	; enable serial I/O (preferred over DOS or BIOS terminal)
    34                              <2> int8_disable_serial equ	   8000h	; disable serial I/O when breaking due to intr8
    35                              <2> gg_do_not_skip_bp equ	 1_0000h	; gg: do not skip a breakpoint (bb or gg)
    36                              <2> gg_no_autorepeat equ	 2_0000h	; gg: do not auto-repeat
    37                              <2> tp_do_not_skip_bp equ	 4_0000h	; T/TP/P: do not skip a (bb) breakpoint
    38                              <2> gg_bb_hit_no_repeat equ	 8_0000h	; gg: do not auto-repeat after bb hit
    39                              <2> tp_bb_hit_no_repeat equ	10_0000h	; T/TP/P: do not auto-repeat after bb hit
    40                              <2> gg_unexpected_no_repeat equ 20_0000h	; gg: do not auto-repeat after unexpectedinterrupt
    41                              <2> tp_unexpected_no_repeat equ 40_0000h	; T/TP/P
    42                              <2> ss_no_dump:		equ 80_0000h
    43                              <2> %if _SYMBOLIC
    44                              <2> dd_no_blanks_sym:	equ 100_0000h
    45                              <2> zz_no_pm_xms:		equ 200_0000h
    46                              <2> %endif
    47                              <2> rr_disasm_no_rept:	equ 1000_0000h
    48                              <2> rr_disasm_no_show:	equ 2000_0000h
    49                              <2> opt_cmdline_quiet_input:equ 4000_0000h
    50                              <2> opt_cmdline_quiet_output:equ 8000_0000h
    51                              <2> %if _SYMBOLIC
    52                              <2> DEFAULTOPTIONS	equ zz_no_pm_xms
    53                              <2> %else
    54                              <2> DEFAULTOPTIONS	equ 0
    55                              <2> %endif
    56                              <2> 
    57                              <2> 
    58                              <2> opt2_db_header:		equ 1
    59                              <2> opt2_db_trailer:	equ 2
    60                              <2> opt2_dw_header:		equ 10h
    61                              <2> opt2_dw_trailer:	equ 20h
    62                              <2> opt2_dd_header:		equ 100h
    63                              <2> opt2_dd_trailer:	equ 200h
    64                              <2> opt2_getinput_dpmi:	equ 800h
    65                              <2> opt2_hh_compat:		equ 1000h
    66                              <2> opt2_getc_idle:		equ 2000h
    67                              <2> opt2_getc_idle_dpmi:	equ 4000h
    68                              <2> opt2_re_cancel_tpg:	equ 8000h
    69                              <2> opt2_nn_compat:		equ 1_0000h
    70                              <2> opt2_nn_capitalise:	equ 2_0000h
    71                              <2> %if _MS_0RANGE_COMPAT
    72                              <2> opt2_0range_compat:	equ 4_0000h
    73                              <2> %endif
    74                              <2> opt2_rr16_compat:	equ 8_0000h
    75                              <2> opt2_r_prompt_compat:	equ 10_0000h
    76                              <2> opt2_r_separate:	equ 20_0000h
    77                              <2> opt2_r_linebreak_always:equ 40_0000h
    78                              <2> opt2_dpminohlt:		equ 8000_0000h	; DPMI doesn't like hlt
    79                              <2> DEFAULTOPTIONS2	equ opt2_dw_header | opt2_dd_header | opt2_getc_idle_dpmi | opt2_dpminohlt
    80                              <2> 
    81                              <2> 
    82                              <2> opt3_tt_no_paging:	equ 1
    83                              <2> opt3_tp_no_paging:	equ 2
    84                              <2> opt3_pp_no_paging:	equ 4
    85                              <2> opt3_gg_no_paging:	equ 8
    86                              <2> opt3_silence_paging_set:equ 100h
    87                              <2> opt3_silence_paging_on:	equ 200h
    88                              <2> opt3_paging_rc:		equ 1000h
    89                              <2> opt3_paging_yy:		equ 2000h
    90                              <2> opt3_paging_re:		equ 4000h
    91                              <2> opt3_r_highlight_diff:	equ 10000h
    92                              <2> opt3_r_highlight_dumb:	equ 20000h
    93                              <2> opt3_r_highlight_full:	equ 40000h
    94                              <2> opt3_r_highlight_eip:	equ 80000h
    95                              <2> %if _PM
    96                              <2> opt3_ss_b_bit_set:	equ   10_0000h
    97                              <2>  %if _BREAK_INSTALLDPMI
    98                              <2> opt3_break_installdpmi:	equ   20_0000h
    99                              <2>  %endif
   100                              <2> %endif
   101                              <2> %if _DHIGHLIGHT
   102                              <2> opt3_d_highlight:	equ   80_0000h
   103                              <2> %endif
   104                              <2> %if _GETLINEHIGHLIGHT
   105                              <2> opt3_getline_highlight:	equ  100_0000h
   106                              <2> %endif
   107                              <2> opt3_no_idle_2F:	equ  200_0000h
   108                              <2> %if _DELAY_BEFORE_BP
   109                              <2> opt3_delay_before_bp:	equ  400_0000h
   110                              <2> %endif
   111                              <2> opt3_no_call_amis:	equ  800_0000h
   112                              <2> opt3_disable_autorepeat:equ 1000_0000h
   113                              <2> opt3_check_ctrlc_keyb:	equ 2000_0000h
   114                              <2> opt3_check_ctrlc_0bh:	equ 4000_0000h
   115                              <2> opt3_tsr_quit_leave_tf:	equ 8000_0000h
   116                              <2> DEFAULTOPTIONS3	equ opt3_tt_no_paging | opt3_tp_no_paging 		| opt3_pp_no_paging | opt3_gg_no_paging 		| opt3_check_ctrlc_keyb | opt3_check_ctrlc_0bh
   119                              <2> 
   120                              <2> 
   121                              <2> opt4_int_2F_hook:	equ 2
   122                              <2> opt4_int_08_hook:	equ 4
   123                              <2> opt4_int_2D_hook:	equ 8
   124                              <2> %if _CATCHINTFAULTCOND
   125                              <2> opt4_int_fault_hook:	equ 10h
   126                              <2> %endif
   127                              <2> opt4_int_serial_force:	equ 1_0000h
   128                              <2> opt4_int_2F_force:	equ 2_0000h
   129                              <2> opt4_int_08_force:	equ 4_0000h
   130                              <2> opt4_int_2D_force:	equ 8_0000h
   131                              <2> %if _CATCHINT0D
   132                              <2> opt4_int_0D_force:	equ   10_0000h
   133                              <2> %endif
   134                              <2> %if _CATCHINT0C
   135                              <2> opt4_int_0C_force:	equ   20_0000h
   136                              <2> %endif
   137                              <2> opt4_int_00_force:	equ  100_0000h
   138                              <2> opt4_int_01_force:	equ  200_0000h
   139                              <2> opt4_int_03_force:	equ  400_0000h
   140                              <2> opt4_int_06_force:	equ  800_0000h
   141                              <2> opt4_int_18_force:	equ 1000_0000h
   142                              <2> opt4_int_19_force:	equ 2000_0000h
   143                              <2> opt4_int_09_force:	equ 4000_0000h	; not used at the same time as 15h
   144                              <2> opt4_int_15_force:	equ 4000_0000h	; not used at the same time as 09h
   145                              <2> opt4_int_07_force:	equ 8000_0000h
   146                              <2> DEFAULTOPTIONS4 equ opt4_int_2F_hook
   147                              <2> 
   148                              <2> 
   149                              <2> %if _VXCHG
   150                              <2> opt6_vv_mode:		equ 1
   151                              <2> opt6_vv_keep:		equ 2
   152                              <2> opt6_vv_int16:		equ 10h
   153                              <2>  %if _VXCHG_DEFAULT_ON
   154                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq | opt6_vv_mode
   155                              <2>  %else
   156                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq
   157                              <2>  %endif
   158                              <2> %else
   159                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq
   160                              <2> %endif
   161                              <2> %if _DEBUG
   162                              <2> opt6_debug_exception_late:	equ  20h
   163                              <2> opt6_debug_exception_early:	equ  40h
   164                              <2>  %if _DEBUG_COND
   165                              <2> opt6_debug_exception:	equ  80h
   166                              <2> opt6_debug_mode:	equ 100h
   167                              <2>  %endif
   168                              <2> %endif
   169                              <2> opt6_bios_output:	equ 200h
   170                              <2> opt6_flat_binary:	equ 400h
   171                              <2> opt6_big_stack:		equ 800h
   172                              <2> opt6_40_columns:	equ 1000h
   173                              <2> opt6_40_indent_odd:	equ 2000h
   174                              <2> opt6_40_dash:		equ 4000h
   175                              <2> opt6_share_serial_irq:	equ 1_0000h
   176                              <2> opt6_serial_EOI_call:	equ 2_0000h
   177                              <2> %if _RH
   178                              <2> opt6_rh_mode:		equ 10_0000h
   179                              <2> %endif
   180                              <2> %if _DEBUG
   181                              <2> opt6_debug_putrunint_early:	equ  40_0000h
   182                              <2>  %if _DEBUG_COND
   183                              <2> opt6_debug_putrunint:		equ  80_0000h
   184                              <2>  %endif
   185                              <2> %endif
   186                              <2> opt6_bios_io:		equ 100_0000h
   187                              <2> opt6_immasm_display_uu:	equ 200_0000h
   188                              <2> opt6_immasm_debug:	equ 400_0000h
   189                              <2> opt6_immasm_flag:	equ 800_0000h
   190                              <2> opt6_immasm_nobranch:	equ 1000_0000h
   191                              <2> opt6_r_flags_style2:	equ 2000_0000h
   192                              <2> opt6_r_flags_style3:	equ 4000_0000h
   193                              <2> opt6_r_linebreak_conditional:	equ 8000_0000h
   194                              <2> 
   195                              <2> 
   196                              <2> DEFAULTOPTIONS7 equ opt7_no_tsr_ll
   197                              <2> opt7_no_free_oneshot_eld:	equ 1
   198                              <2> opt7_debug_optional_link:	equ 2
   199                              <2> opt7_quiet_install:		equ 4
   200                              <2> opt7_quick_run:			equ 8
   201                              <2> opt7_houdini:			equ 100h
   202                              <2> opt7_debug_run:			equ 200h
   203                              <2> opt7_no_ensure:			equ 1000h
   204                              <2> opt7_no_tsr_ll:			equ 2000h
   205                              <2> 
   206                              <2> 
   207                              <2> oldpacket	equ	  1	; Int25/Int26 packet method available (L, W)
   208                              <2> newpacket	equ	  2	; Int21.7305 packet method available (L, W)
   209                              <2> ntpacket	equ	  4	; VDD registered and usable (L, W)
   210                              <2> pagedcommand	equ	  8	; allows paging in puts
   211                              <2> notstdinput	equ	 10h	; DEBUG's StdIn isn't a device with StdIn bit (is file or other device)
   212                              <2> inputfile	equ	 20h	; DEBUG's StdIn is a file, notstdinput also set
   213                              <2> notstdoutput	equ	 40h	; DEBUG's StdOut isn't a device with StdOut bit (is file or other device)
   214                              <2> outputfile	equ	  80h	; DEBUG's StdOut is a file, notstdoutput also set
   215                              <2> hooked2F	equ	 100h	; Int2F hooked
   216                              <2> nohook2F	equ	 200h	; don't hook Int2F.1687 (required for Win9x, DosEmu?)
   217                              <2> unused_dif1_dpminohlt equ 400h	; DPMI doesn't like hlt
   218                              <2> protectedmode	equ	 800h	; in (DPMI) protected mode
   219                              <2> debuggeeA20	equ	1000h	; state of debuggee's A20
   220                              <2> debuggerA20	equ	2000h	; state of debugger's A20 (will be on if possible)
   221                              <2> nodosloaded	equ	4000h	; No DOS loaded currently (Boot loader mode)
   222                              <2> has386		equ	8000h	; CPU is a 386
   223                              <2> usecharcounter	equ    1_0000h	; don't reset charcounter between calls to puts
   224                              <2> runningnt	equ    2_0000h	; running in NTVDM
   225                              <2> canswitchmode	equ    4_0000h	; can switch modes (auxbuff large enough, DPMI mode switch set up)
   226                              <2> modeswitched	equ    8_0000h	; switched mode (now in the mode that we weren't entered in)
   227                              <2> promptwaiting	equ   10_0000h	; puts: any more output needs to display a prompt first
   228                              <2> switchbuffer	equ   20_0000h	; mode switch needs a buffer (auxbuff)
   229                              <2> tsrmode		equ   40_0000h	; in TSR mode; DPI and DPP not valid
   230                              <2> attachedterm	equ   80_0000h	; the attached process terminated
   231                              <2> runningdosemu	equ  100_0000h	; running in dosemu
   232                              <2> ; load_is_ldp	equ  200_0000h	; boot load: partition specified as "ldp"
   233                              <2> tt_while:	equ  400_0000h	; tt: while condition specified
   234                              <2> tt_p:		equ  800_0000h	; tt: proceed past repeated string instructions
   235                              <2> tt_silent_mode:	equ 1000_0000h	; tt: run should be silent (dump at end)
   236                              <2> tt_silence:	equ 2000_0000h	; tt: silent writing (write to auxbuff instead)
   237                              <2> tt_no_bb:	equ 4000_0000h	; tt: do not use bb breakpoints
   238                              <2> tt_no_bb_first:	equ 8000_0000h	; tt: do not use bb breakpoints at first
   239                              <2> 
   240                              <2> 
   241                              <2> dif2_gg_is_first:	equ   1
   242                              <2> dif2_gg_skip_non_cseip:	equ   2
   243                              <2> dif2_gg_skip_cseip:	equ   4
   244                              <2> dif2_gg_is_gg:		equ   8
   245                              <2> dif2_gg_first_detected:	equ  10h
   246                              <2> dif2_gg_again:		equ  20h
   247                              <2> dif2_tpg_proceed_bp_set:equ  40h
   248                              <2> dif2_tpg_keep_proceed_bp: equ 80h
   249                              <2> dif2_tpg_have_bp:	equ 100h
   250                              <2> dif2_tpg_adjusted_cseip:equ 200h
   251                              <2> dif2_tpg_do_not_adjust:	equ 400h
   252                              <2> dif2_bp_failure:	equ 800h
   253                              <2> dif2_is_pp:		equ 1000h
   254                              <2> %if _SYMBOLIC
   255                              <2> dif2_createdprocess:	equ 800_0000h	; created empty debuggee process
   256                              <2> dif2_sym_req_xms:	equ 2000h
   257                              <2> dif2_sym_req_86mm:	equ 4000h
   258                              <2> dif2_sym_req_mask equ dif2_sym_req_86mm | dif2_sym_req_xms
   259                              <2> dif2_no_pm_xms:		equ 1_0000h
   260                              <2> dif2_xms_detection_done:equ 2_0000h
   261                              <2> %endif
   262                              <2> %if _INPUT_FILE_HANDLES
   263                              <2> dif2_input_file:	equ 10_0000h
   264                              <2> dif2_closed_input_file:	equ 20_0000h
   265                              <2> %endif
   266                              <2> dif2_did_getline_file:	equ 40_0000h
   267                              <2> %if _SYMBOLIC
   268                              <2> dif2_poison:		equ 80_0000h
   269                              <2> %endif
   270                              <2> dif2_boot_loaded_kernel:equ 100_0000h
   271                              <2> %if _INPUT_FILE_BOOT
   272                              <2> dif2_input_file_boot:	equ 200_0000h
   273                              <2> dif2_closed_input_file_boot:	equ 400_0000h
   274                              <2> %endif
   275                              <2> dif2_in_silence_dump:	equ 1000_0000h
   276                              <2> dif2_int31_segment:	equ 2000_0000h
   277                              <2> dif2_nn_compat:		equ 4000_0000h
   278                              <2> dif2_nn_capitalise:	equ 8000_0000h
   279                              <2> 
   280                              <2> 
   281                              <2> dif3_load_is_ldp:	equ 1	; boot load: partition specified as "ldp"
   282                              <2> dif3_load_is_sdp:	equ 2	; boot load: partition specified as "sdp"
   283                              <2> dif3_load_is_ydp:	equ 4	; boot load: partition specified as "ydp"
   284                              <2> dif3_load_is_dp:	equ dif3_load_is_ldp 				| dif3_load_is_sdp 				| dif3_load_is_ydp
   287                              <2> dif3_load_dir_dir:	equ 8
   288                              <2> dif3_input_terminal_override:	equ 10h
   289                              <2> dif3_input_serial_override:	equ 20h
   290                              <2> dif3_if_not:		equ 40h
   291                              <2> dif3_partition_changed:	equ 80h
   292                              <2> ;
   293                              <2> dif3_input_cmdline:	equ 100h; input reading from cmdline_buffer
   294                              <2> dif3_input_cmdline_closed: equ 200h
   295                              <2> dif3_at_line_end:	equ 400h
   296                              <2> dif3_quiet_input_single:equ 800h
   297                              <2> dif3_quiet_output:	equ 1000h
   298                              <2> dif3_unquiet_error:	equ 2000h
   299                              <2> dif3_unquiet_prompt:	equ 4000h
   300                              <2> dif3_unquiet:		equ dif3_unquiet_error | dif3_unquiet_prompt
   301                              <2> dif3_return_eof:	equ 8000h
   302                              <2> dif3_highlighting:	equ 1_0000h
   303                              <2> dif3_do_not_highlight:	equ 2_0000h
   304                              <2> dif3_int10_highlight:	equ 2_0000h
   305                              <2> dif3_nosymbols_1:	equ 4_0000h
   306                              <2> dif3_nosymbols_2:	equ 8_0000h
   307                              <2> %if _PM
   308                              <2> dif3_ss_b_bit_set:	equ  10_0000h
   309                              <2> %endif
   310                              <2> dif3_gotint19:		equ  20_0000h
   311                              <2> dif3_prior_pm:		equ  40_0000h
   312                              <2> %if _DELAY_BEFORE_BP
   313                              <2> dif3_delayed		equ  80_0000h
   314                              <2> %endif
   315                              <2> dif3_input_re:		equ 100_0000h	; input reading from re_buffer
   316                              <2> dif3_input_re_closed:	equ 200_0000h
   317                              <2> dif3_accept_getrange_0:	equ 400_0000h
   318                              <2> %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
   319                              <2> dif3_in_if:		equ 800_0000h
   320                              <2> %endif
   321                              <2> dif3_auxbuff_guarded_1:	equ 1000_0000h
   322                              <2> dif3_auxbuff_guarded_2:	equ 2000_0000h
   323                              <2> dif3_auxbuff_guarded_3:	equ 4000_0000h
   324                              <2> dif3_sss_is_reverse:	equ 8000_0000h
   325                              <2> 
   326                              <2> 
   327                              <2> dif4_int_serial_hooked:	equ 1
   328                              <2> dif4_int_2F_hooked:	equ 2
   329                              <2> dif4_int_08_hooked:	equ 4
   330                              <2> dif4_int_2D_hooked:	equ 8
   331                              <2> %if _CATCHINTFAULTCOND && _CATCHINT0D
   332                              <2> dif4_int_0D_hooked:	equ 10h
   333                              <2> %endif
   334                              <2> %if _CATCHINTFAULTCOND && _CATCHINT0C
   335                              <2> dif4_int_0C_hooked:	equ 20h
   336                              <2> %endif
   337                              <2> %if _LOADER
   338                              <2> dif4_int_18_hooked:	equ 1000h
   339                              <2> dif4_int_19_hooked:	equ 2000h
   340                              <2> %endif
   341                              <2> 
   342                              <2> 
   343                              <2> %if _VXCHG
   344                              <2> dif6_vv_mode:		equ 1
   345                              <2> %endif
   346                              <2> dif6_in_hook2F:		equ 2
   347                              <2> dif6_in_amis_hook2F:	equ 4
   348                              <2> dif6_debug_mode:	equ 100h
   349                              <2> dif6_locked:		equ 200h
   350                              <2> dif6_mcp:		equ 400h
   351                              <2> %if _RH
   352                              <2> dif6_rh_mode_was:	equ  8_0000h
   353                              <2> dif6_rh_mode:		equ 10_0000h
   354                              <2> dif6_rh_mode_2:		equ 20_0000h
   355                              <2> %endif
   356                              <2> dif6_device_mode:	equ 40_0000h
   357                              <2> dif6_cpdepchars:	equ 80_0000h
   358                              <2> %if _IMMASM
   359                              <2> dif6_immasm_no_output:	equ 100_0000h
   360                              <2> dif6_immasm:		equ 200_0000h
   361                              <2> dif6_immasm_rel8:	equ 400_0000h
   362                              <2> %endif
   363                              <2> 
   364                              <2> 
   365                              <2> disasm_lowercase	equ 1
   366                              <2> disasm_commablank	equ 2
   367                              <2> disasm_nasm		equ 4
   368                              <2> disasm_lowercase_refmem:equ 8
   369                              <2> disasm_show_short:	equ 10h
   370                              <2> disasm_show_near:	equ 20h
   371                              <2> disasm_show_far:	equ 40h
   372                              <2> disasm_nec:		equ 80h
   373                              <2> disasm_40_columns:	equ 100h
   374                              <2> disasm_no_indent:	equ 200h
   375                              <2> disasm_msdebug_mnemonofs: equ 400h
   376                              <2> disasm_a16_memref:	equ 1000h
   377                              <2> disasm_a32_memref:	equ 2000h
   378                              <2> disasm_a16_string:	equ 4000h
   379                              <2> disasm_a32_string:	equ 8000h
   380                              <2> disasm_hide_modrm:	equ 10000h
   381                              <2> disasm_asize_loop_nasm:	equ 20000h
   382                              <2> disasm_modrm_always:	equ 40000h
   383                              <2> DEFAULTASMOPTIONS equ disasm_lowercase|disasm_commablank|disasm_nasm 	| disasm_a16_memref | disasm_a32_memref 	| disasm_a16_string | disasm_a32_string
   386                              <2> 
   387                              <2> 	; serial_flags values
   388                              <2> sf_init_done:	equ 1
   389                              <2> sf_ctrl_c:	equ 2
   390                              <2> sf_double_ctrl_c:	equ 4
   391                              <2> sf_built_in_fifo:	equ 8
   392                              <2> sf_use_serial:		equ 10h
  1560                              <1> %endif
    21                                  %endif
    22                                  
    23                                  %if _LINK_COMPAT
    24                                   %define FORCEWORD word
    25                                   %define FORCESTRICTWORD strict word
    26                                  %else
    27                                   %define FORCEWORD
    28                                   %define FORCESTRICTWORD
    29                                  %endif
    30                                  
    31                                  
    32                                  %if _LINK
    33                                  
    34                                  %if !(_ONLY386 || _ONLYNON386) || _DUALCODE && _PM
    35                                   wllist G_GINITGROUP_SINIT
    36                                  %endif
    37                                  
    38                                  %ifn _ONLY386 || _ONLYNON386
    39                                   wllist N_SINIT_Lpatch_386_table
    40                                   wllist N_SINIT_Lpatch_no386_table
    41                                  %if _DUALCODE
    42                                   wllist N_SINIT_Lpatch_386_table2
    43                                   wllist N_SINIT_Lpatch_no386_table2
    44                                  %endif
    45                                   wllist N_SINIT_Lpatch_386_tableentry
    46                                   wllist N_SINIT_Lpatch_no386_tableentry
    47                                  %endif
    48                                  
    49                                  %if _DUALCODE && ! _PM
    50                                   wllist N_SINIT_Lrelocate_from_code
    51                                   wllist N_SINIT_Lrelocate_from_code2
    52                                  
    53                                   extern relocate_from_code
    54                                   extern relocate_from_code.end
    55                                   extern relocate_from_code2
    56                                   extern relocate_from_code2.end
    57                                  %endif
    58                                  
    59                                  %endif
    60                                  	usesection INIT
    60          ------------------       note: usesection INIT
    61                                  
    62                                  %ifn _LINK
    63                                  CODETARGET1_equate equ CODETARGET1
    64                                  CODETARGET2_equate equ CODETARGET2
    65                                  AUXTARGET1_equate equ AUXTARGET1
    66                                  AUXTARGET2_equate equ AUXTARGET2
    67                                  BOOTCODETARGET1_equate equ BOOTCODETARGET1
    68                                  BOOTCODETARGET2_equate equ BOOTCODETARGET2
    69                                  BOOTAUXTARGET1_equate equ BOOTAUXTARGET1
    70                                  BOOTAUXTARGET2_equate equ BOOTAUXTARGET2
    71                                  ldebug_codes_size_equate equ ldebug_code_size + ldebug_code2_size
    72                                  ldebug_codes_truncated_size_equate equ ldebug_code_bootldr_truncated_size + ldebug_code2_size
    73                                  auxbuff_size_equate equ auxbuff_size
    74                                  initsectionoffset_p_equate equ paras(INITSECTIONOFFSET)
    75                                  %endif
    76                                  
    77                                  initcode:
    78                                  %if ($ - $$) != 0
    79                                   %fatal initcode expected at start of section
    80                                  %endif
    81                                  %ifn _APPLICATION
    82                                  	push cs
    83                                  	pop ds
    84                                  	mov dx, imsg.not_an_application
    85                                  	mov ah, 09h
    86                                  	int 21h
    87                                  	mov ax, 4CFFh
    88                                  	int 21h
    89                                  
    90                                  		; magic sequence for tellsize
    91                                  %if _LINK
    92                                  	mov bx, 1
    93                                   wlcalc word_wrt_INIT_extpara_behind_init, equ $ - 2
    94                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
    95                                   wlcalc word_segrel_INIT, equ $ - 2
    96                                  %else
    97                                  	mov bx, paras(INITSECTIONOFFSET + init_size + deviceshim_size + 16)
    98                                  %endif
    99                                  	mov ah, 4Ah
   100                                  	int 21h
   101                                  		; end of magic sequence for tellsize
   102                                  
   103                                  		; The +16 is to avoid entering a zero value
   104                                  		;  for exeMinAlloc and exeMaxAlloc, which
   105                                  		;  seems to be handled in a special way by
   106                                  		;  DOS. (This special handling occurs for
   107                                  		;  the uncompressed bootable build, eg
   108                                  		;  ldebugu.com, and the nonbootable MZ shim
   109                                  		;  build, eg debug.com.)
   110                                  %endif
   111                                  
   112                                  %if _APPLICATION
   113 00000000 8CD0                    	mov ax, ss
   114 00000002 8CDA                    	mov dx, ds
   115 00000004 29D0                    	sub ax, dx
   116                                  
   117 00000006 50                      	push ax			; (if sp was zero)
   118                                  
   119 00000007 89E2                    	mov dx, sp
   120 00000009 B103                    	mov cl, 3
   121 0000000B 83C20F                  	add dx, 15
   122 0000000E D1DA                    	rcr dx, 1
   123 00000010 D3EA                    	shr dx, cl
   124 00000012 01D0                    	add ax, dx
   125                                  
   126                                  %ifn _LINK
   127                                  	cmp ax, strict word paras(APPINITSTACK_END)
   128                                  %else
   129                                  
   130                                  %if 0
   131                                  %define APPINITTARGET (INITSECTIONOFFSET 			+ datastack_size 			+ ext_data_nonboot_add_size 			+ auxbuff_size + auxbuff_init_size 			+ historysegment_size 			+ app_env_size 			+ extsegment_size)
   138                                  		; The early stack goes behind the init target.
   139                                  %define APPINITSTACK_START (APPINITTARGET+init_size)
   140                                  APPINITSTACK_SIZE equ 512	; must be even
   141                                  		; This is the size of the application mode
   142                                  		;  process memory block required while still
   143                                  		;  using the init stack behind init target.
   144                                  %define APPINITSTACK_END (APPINITSTACK_START+APPINITSTACK_SIZE)
   145                                  %endif
   146                                  
   147 00000014 3D[A208]                	cmp ax, strict word relocatedzero + paras( 		+ auxbuff_size + auxbuff_init_size 		+ historysegment_size 		+ app_env_size 		+ extsegment_size 		+ APPINITSTACK_SIZE)
   153                                   wlcalc word_segrel_INIT, equ $ - 2
   154                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
   155                                   wlcalc word_wrt_INIT_extpara_behind_init, equ $ - 2
   156                                  %endif
   157 00000017 7314                    	jae .stackdownfirst
   158                                  .memupfirst:
   159                                  		; magic sequence for tellsize
   160                                  %ifn _LINK
   161                                  	mov bx, paras(APPINITSTACK_END)
   162                                  %else
   163 00000019 BB[A208]                	mov bx, relocatedzero + paras( 		+ auxbuff_size + auxbuff_init_size 		+ historysegment_size 		+ app_env_size 		+ extsegment_size 		+ APPINITSTACK_SIZE)
   169                                   wlcalc word_segrel_INIT, equ $ - 2
   170                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
   171                                   wlcalc word_wrt_INIT_extpara_behind_init, equ $ - 2
   172                                  %endif
   173 0000001C B44A                    	mov ah, 4Ah
   174 0000001E CD21                    	int 21h
   175                                  		; end of magic sequence for tellsize
   176 00000020 730B                    	jnc @F
   177                                  .memfail:
   178 00000022 BA[8A0F]                	mov dx, imsg.early_mem_fail
   179                                  .earlyfail:
   180 00000025 E8B51A                  	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 E8F919                  	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][3233]      	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][8033]      	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][3233]      	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[0710]                	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 E87C19                  	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[0216]                	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[380F]                	mov di, imsg.varconfig
   585 00000181 B90D00                  	mov cx, imsg.varconfig.length
   586 00000184 BA[0000]                	mov dx, configpath
   587 00000187 E8DE30                  	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[450F]                	mov di, imsg.varscripts
   597 0000019C B90E00                  	mov cx, imsg.varscripts.length
   598 0000019F BA[0000]                	mov dx, scriptspath
   599 000001A2 E8C330                  	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 E9A619                  	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 E84530                  	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 E83D18                  	call init_movp		; low last
   700                                    %if _DUALCODE
   701 0000020F EB06                    	jmp @FF
   702                                  
   703                                  @@:
   704 00000211 E83818                  	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 E82218                  	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[3217]                	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 E87B30                  	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[7E17]                	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[8018]                	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[9D18]                	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[BB18]                	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[6C18]                	mov dx, imsg.bootwarn
  1055 00000396 E86617                  	call init_putsz_cs_bootldr
  1056 00000399 5A                      	pop dx
  1057 0000039A E86217                  	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[FC17]                	mov dx, imsg.boot_error_out_of_memory
  1300                                  .putsz_error:
  1301 0000046D E88F16                  	call init_putsz_cs_bootldr
  1302 00000470 E95C04                  	jmp init_booterror.soft
  1303                                  
  1304                                  .error_internal:
  1305 00000473 BA[0D18]                	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[D408]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 E85B15                  	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[EC18]                	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[6C18]                	mov dx, imsg.bootwarn
  1446 00000517 E8E515                  	call init_putsz_cs_bootldr
  1447 0000051A 5A                      	pop dx
  1448 0000051B E8E115                  	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[0710]                	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 E89F14                  	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 E84A14                  	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 E83B14                  	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 E82514                  	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[AD0F]                	mov dx, imsg.crlf
  1974 00000773 E86713                  	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 E9AF13                  	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[8217]                	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[A917]                	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 7225                    	jb .noebda			; -->
  2234                                  .ebda:
  2235                                  d4	call init_d4message
  2236                                  d4	asciz "EBDA detected",13,10
  2237                                  
  2238 000008A9 2E800E[6A0E]01          	or byte [cs:init_boot_ebdaflag], 1
  2239 000008AF 39D8                    	cmp ax, bx
  2240                                  	;jb init_booterror.soft		; uhh, the EBDA is inside our memory?
  2241                                  	;ja init_booterror.soft		; EBDA higher than top of memory. This is just as unexpected.
  2242 000008B1 7406                    	je @F
  2243 000008B3 BA[DD17]                	mov dx, imsg.boot_ebda_unexpected
  2244 000008B6 E9B4FB                  	jmp .putsz_error
  2245                                  
  2246                                  @@:
  2247 000008B9 8ED8                    	mov ds, ax
  2248 000008BB 31D2                    	xor dx, dx
  2249 000008BD 8A160000                	mov dl, byte [ 0 ]		; EBDA size in KiB
  2250 000008C1 B106                    	mov cl, 6
  2251 000008C3 D3E2                    	shl dx, cl			; *64, to paragraphs
  2252 000008C5 2E8916[640E]            	mov word [cs:init_boot_ebdasize], dx
  2253 000008CA 2EA3[660E]              	mov word [cs:init_boot_ebdasource], ax
  2254                                  d4	jmp @F
  2255                                  .noebda:
  2256                                  d4	call init_d4message
  2257                                  d4	asciz "No EBDA detected",13,10
  2258                                  @@:
  2259 000008CE C3                      	retn
  2260                                  
  2261                                  .putsz_error: equ boot_initcode.putsz_error
  2262                                  
  2263                                  	lleave ctx			; dropping early boot_initcode frame
  2264                                  
  2265                                  
  2266                                  init_booterror:
  2267                                  .soft:
  2268 000008CF 31C0                    	xor ax, ax
  2269 000008D1 A9                      	db __TEST_IMM16			; (skip mov)
  2270                                  .hard:
  2271 000008D2 B001                    	mov al, 1
  2272                                  
  2273                                  ;d4	call init_d4pocketdosmemdump
  2274                                  d4	call init_d4dumpregs
  2275                                  
  2276                                  .patch_switch_stack:
  2277 000008D4 EB09                    	jmp strict short .no_switch_stack
  2278                                  
  2279 000008D6 8CCB                    	mov bx, cs
  2280 000008D8 FA                      	cli
  2281 000008D9 8ED3                    	mov ss, bx
  2282                                  %ifn _LINK
  2283                                  	mov sp, init_size + BOOTINITSTACK_SIZE
  2284                                  %else
  2285 000008DB BC[0002]                	mov sp, BOOTINITSTACK_SIZE + behind_init wrt INIT
  2286                                  %endif
  2287 000008DE FB                      	sti
  2288                                  
  2289                                  .no_switch_stack:
  2290 000008DF 50                      	push ax
  2291                                  
  2292 000008E0 B84000                  	mov ax, 40h
  2293 000008E3 8EC0                    	mov es, ax
  2294                                  
  2295 000008E5 2EF606[6A0E]02          	test byte [cs:init_boot_ebdaflag], 2
  2296 000008EB 7417                    	jz @F
  2297                                  
  2298 000008ED FA                      	cli
  2299 000008EE 2E8B16[660E]            	mov dx, [cs:init_boot_ebdasource]
  2300 000008F3 2EA1[680E]              	mov ax, [cs:init_boot_ebdadest]
  2301 000008F7 2E8B0E[640E]            	mov cx, [cs:init_boot_ebdasize]
  2302 000008FC E84D11                  	call init_movp
  2303                                  
  2304 000008FF 2689160E00              	mov word [es:0Eh], dx
  2305                                  @@:
  2306                                  
  2307 00000904 2E8B16[620E]            	mov dx, [cs:init_boot_old_memsizekib]
  2308 00000909 85D2                    	test dx, dx
  2309 0000090B 7405                    	jz @F
  2310 0000090D 2689161300              	mov word [es:13h], dx
  2311                                  @@:
  2312 00000912 FB                      	sti
  2313                                  
  2314 00000913 BA[3B18]                	mov dx, imsg.booterror
  2315 00000916 E8E611                  	call init_putsz_cs_bootldr
  2316 00000919 E8BC11                  	call init_getc_bootldr
  2317 0000091C 58                      	pop ax
  2318 0000091D 85C0                    	test ax, ax
  2319 0000091F 7502                    	jnz @F
  2320 00000921 CD19                    	int 19h
  2321                                  @@:
  2322 00000923 EA0000FFFF              	jmp 0FFFFh:0
  2323                                  %endif	; _BOOTLDR
  2324                                  
  2325                                  %if _DEVICE
  2326                                  		; Our entrypoint transfers control to us with these registers:
  2327                                  		; INP:	ss:sp -> bx, fl, ds, ax, far return address to DOS
  2328                                  		;	ds:100h -> loaded payload
  2329                                  device_initcode:
  2330 00000928 FC                      	cld
  2331                                  
  2332 00000929 830E[0000]FF            	or word [device_header.next], -1
  2333                                  		; ! this uses offset 100h in the adjusted ds
  2334                                  
  2335 0000092E 5B                      	pop bx
  2336 0000092F 06                      	push es
  2337 00000930 53                      	push bx
  2338 00000931 51                      	push cx
  2339 00000932 52                      	push dx
  2340 00000933 56                      	push si
  2341 00000934 57                      	push di
  2342                                  
  2343 00000935 268B470E                	mov ax, word [es:bx + 0Eh]	; ax = amount bytes in last segment
  2344 00000939 B104                    	mov cl, 4
  2345 0000093B D3E8                    	shr ax, cl			; = paragraphs, rounding down
  2346 0000093D 26034710                	add ax, word [es:bx + 0Eh + 2]	; => behind available memory
  2347 00000941 7212                    	jc .memorybad
  2348 00000943 2EA3[3E0E]              	mov word [cs:dev_memory_end], ax
  2349 00000947 8CDA                    	mov dx, ds
  2350 00000949 83C210                  	add dx, 10h			; => our memory
  2351 0000094C 29D0                    	sub ax, dx			; ax = amount available paragraphs
  2352 0000094E 7205                    	jc .memorybad
  2353                                  
  2354                                  %ifn _LINK
  2355                                  	cmp ax, (DEVICEINITSIZE + 15) >> 4
  2356                                  %else
  2357                                   %if 0
  2358                                  %define DEVICEADJUST	(deviceshim_size + 110h)
  2359                                  %define DEVICEINITTARGET (INITSECTIONOFFSET 			+ DEVICEADJUST 			+ datastack_size 			+ ext_data_nonboot_add_size 			+ auxbuff_size + auxbuff_init_size 			+ historysegment_size 			+ dev_env_size 			+ extsegment_size 			+ 10h)
  2368                                  %define DEVICEINITSIZE (DEVICEINITTARGET - 100h 			+ init_size 			+ deviceshim_size)
  2371                                   %endif
  2372 00000950 3D[8408]                	cmp ax, strict word relocatedzero + paras( 		+ auxbuff_size 		+ auxbuff_init_size 		+ historysegment_size 		+ dev_env_size 		+ extsegment_size 		+ 20h)
  2379                                   wlcalc word_segrel_INIT, equ $ - 2
  2380                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  2381                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2382                                  ; wlcalc word_wrt_@@lDEBUG_DATA_ENTRY@_minusextpara_end_of_datastack, equ $ - 2
  2383                                   wlcalc word_wrt_INIT_extpara_behind_init, equ $ - 2
  2384                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2385                                  %endif
  2386 00000953 7333                    	jae .memorygood
  2387                                  
  2388                                  .memorybad:
  2389 00000955 BA[8A0F]                	mov dx, imsg.early_mem_fail
  2390 00000958 E88211                  	call init_putsz_cs
  2391                                  
  2392 0000095B B80030                  	mov ax, 3000h
  2393 0000095E CD21                    	int 21h
  2394 00000960 3C05                    	cmp al, 5
  2395 00000962 7306                    	jae @F
  2396 00000964 BA[3610]                	mov dx, imsg.dos_below_5
  2397                                  .earlyfail:
  2398 00000967 E87311                  	call init_putsz_cs
  2399                                  @@:
  2400                                  
  2401 0000096A 5F                      	pop di
  2402 0000096B 5E                      	pop si
  2403 0000096C 5A                      	pop dx
  2404 0000096D 59                      	pop cx
  2405 0000096E 5B                      	pop bx
  2406 0000096F 07                      	pop es
  2407                                  
  2408 00000970 8CD8                    	mov ax, ds
  2409 00000972 83C010                  	add ax, paras(100h)
  2410 00000975 26C747030581            	mov word [es:bx + 3], 8105h	; error, done, code: bad structure length
  2411 0000097B 2683670E00              	and word [es:bx + 0Eh], 0
  2412 00000980 26894710                	mov word [es:bx + 0Eh + 2], ax	; -> behind memory in use
  2413                                  
  2414 00000984 9D                      	popf
  2415 00000985 1F                      	pop ds
  2416 00000986 58                      	pop ax
  2417 00000987 CB                      	retf
  2418                                  
  2419                                  .memorygood:
  2420 00000988 8CD8                    	mov ax, ds
  2421                                  %ifn _LINK
  2422                                  	add ax, paras(INITSECTIONOFFSET)
  2423                                  %else
  2424 0000098A 05[0000]                	add ax, strict word relocatedzero + 0
  2425                                   wlcalc word_segrel_INIT, equ $ - 2
  2426                                  %endif
  2427 0000098D 8CDA                    	mov dx, ds
  2428                                  %ifn _LINK
  2429                                  	add dx, paras(DEVICEINITTARGET)
  2430                                  	mov cx, init_size_p + deviceshim_size_p
  2431                                  %else
  2432                                   %if 0
  2433                                  %define DEVICEADJUST	(deviceshim_size + 110h)
  2434                                  %define DEVICEINITTARGET (INITSECTIONOFFSET 			+ DEVICEADJUST 			+ datastack_size 			+ ext_data_nonboot_add_size 			+ auxbuff_size + auxbuff_init_size 			+ historysegment_size 			+ dev_env_size 			+ extsegment_size 			+ 10h)
  2443                                  %define DEVICEINITSIZE (DEVICEINITTARGET - 100h 			+ init_size 			+ deviceshim_size)
  2446                                   %endif
  2447 0000098F 81C2[9408]              	add dx, strict word relocatedzero + paras( 		+ auxbuff_size 		+ auxbuff_init_size 		+ historysegment_size 		+ dev_env_size 		+ extsegment_size 		+ 120h)
  2454                                   wlcalc word_segrel_INIT, equ $ - 2
  2455                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  2456                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2457                                  ; wlcalc word_wrt_@@lDEBUG_DATA_ENTRY@_minusextpara_end_of_datastack, equ $ - 2
  2458 00000993 B9[0000]                	mov cx, relocatedzero + 0
  2459                                   wlcalc word_wrt_INIT_extpara_behind_deviceshim, equ $ - 2
  2460                                  %endif
  2461 00000996 E8B310                  	call init_movp
  2462                                  %ifn _LINK
  2463                                  init_plus_deviceshim_size_p_equate equ init_size_p + deviceshim_size_p
  2464                                  deviceinittarget_p_equate equ paras(DEVICEINITTARGET)
  2465                                  %if initsectionoffset_p_equate + init_plus_deviceshim_size_p_equate 	> deviceinittarget_p_equate
  2467                                   %error Overlap detected
  2468                                  %endif
  2469                                  %endif
  2470                                  
  2471 00000999 52                      	push dx
  2472 0000099A E891F8                  	call init_retf
  2473                                  
  2474                                  %if _DEV_ENV_SIZE
  2475                                   %ifn _LINK
  2476                                  	mov word [cs:memsize], paras(CODETARGET2 			+ ldebug_code_bootldr_truncated_size 			+ ldebug_code2_size 			+ historysegment_size 			+ dev_env_size 			+ extsegment_size)
  2482                                   %else
  2483                                   %if 0
  2484                                  %define CODETARGET1 (MESSAGESECTIONOFFSET + messagesegment_nobits_truncated_size + datastack_size)
  2485                                  %define CODETARGET2 (CODETARGET1+auxbuff_size)
  2486                                  %define AUXTARGET1 (CODETARGET1+ldebug_code_bootldr_truncated_size+ldebug_code2_size)
  2487                                  %define AUXTARGET2 CODETARGET1
  2488                                  %define AUXTARGET3 (AUXTARGET1+auxbuff_size)
  2489                                   %endif
  2490 0000099D 2EC706[360E][8106]      	mov word [cs:memsize], relocatedzero + paras(auxbuff_size 			+ historysegment_size 			+ dev_env_size 			+ extsegment_size)
  2494                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
  2495                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits_truncated, equ $ - 2
  2496                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  2497                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code_truncated, equ $ - 2
  2498                                   wlcalc word_wrt_@@lDEBUG_CODE2@_extpara_behind_code2, equ $ - 2
  2499                                   %endif
  2500 000009A4 2EC706[380E]8000        	mov word [cs:mem_envsize], paras(dev_env_size)
  2501                                  %endif
  2502                                  
  2503 000009AB 8CDB                    	mov bx, ds
  2504                                   %ifn _LINK
  2505                                  	add bx, FORCESTRICTWORD paras(DEVICEADJUST)
  2506                                   %else
  2507                                  ;%define DEVICEADJUST	(deviceshim_size + 110h)
  2508 000009AD 81C3[1100]              	add bx, strict word relocatedzero + paras(110h)
  2509                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2510                                   %endif
  2511 000009B1 89DA                    	mov dx, bx
  2512                                   %ifn _LINK
  2513                                  	add bx, paras(AUXTARGET1)
  2514                                  	add dx, paras(CODETARGET1)
  2515                                   %else
  2516                                  	; add bx, paras(AUXTARGET1)
  2517 000009B3 81C3[0000]              	add bx, strict word relocatedzero + 0
  2518                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
  2519                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits_truncated, equ $ - 2
  2520                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  2521                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code_truncated, equ $ - 2
  2522                                   wlcalc word_wrt_@@lDEBUG_CODE2@_extpara_behind_code2, equ $ - 2
  2523                                  	; add dx, paras(CODETARGET1)
  2524 000009B7 81C2[0000]              	add dx, strict word relocatedzero + 0
  2525                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
  2526                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits_truncated, equ $ - 2
  2527                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  2528                                   %endif
  2529                                   %if _EXTENSIONS || _HISTORY_SEPARATE_FIXED && _HISTORY || _DEV_ENV_SIZE
  2530 000009BB 89D8                    	mov ax, bx
  2531 000009BD 050102                  	add ax, paras(auxbuff_size)
  2532                                   %endif
  2533 000009C0 89D1                    	mov cx, dx
  2534 000009C2 2EC706[3C0E][A833]      	mov word [cs:init_layout], init_dev_layout_1
  2535 000009C9 E863F8                  	call init_check_auxbuff
  2536 000009CC 7446                    	jz @F
  2537                                  
  2538 000009CE 8CDB                    	mov bx, ds
  2539                                   %ifn _LINK
  2540                                  	add bx, FORCESTRICTWORD paras(DEVICEADJUST)
  2541                                   %else
  2542                                  ;%define DEVICEADJUST	(deviceshim_size + 110h)
  2543 000009D0 81C3[1100]              	add bx, strict word relocatedzero + paras(110h)
  2544                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2545                                   %endif
  2546 000009D4 89DA                    	mov dx, bx
  2547                                   %ifn _LINK
  2548                                  	add bx, paras(AUXTARGET2)
  2549                                  	add dx, paras(CODETARGET2)
  2550                                   %else
  2551                                  	; add bx, paras(AUXTARGET2)
  2552 000009D6 81C3[0000]              	add bx, strict word relocatedzero + 0
  2553                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
  2554                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits_truncated, equ $ - 2
  2555                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  2556                                  	; add dx, paras(CODETARGET2)
  2557 000009DA 81C2[0102]              	add dx, strict word relocatedzero + paras(auxbuff_size)
  2558                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
  2559                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits_truncated, equ $ - 2
  2560                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  2561                                   %endif
  2562 000009DE 2EC706[3C0E][AD33]      	mov word [cs:init_layout], init_dev_layout_2
  2563 000009E5 E847F8                  	call init_check_auxbuff
  2564 000009E8 742A                    	jz @F
  2565                                  
  2566                                  		; If both prior attempts failed, we allocate
  2567                                  		;  an additional 8 KiB and move the buffer to
  2568                                  		;  that. This should always succeed.
  2569                                  %ifn _LINK
  2570                                  	mov word [cs:memsize], paras(AUXTARGET3 			+ auxbuff_size 			+ historysegment_size 			+ dev_env_size 			+ extsegment_size)
  2575                                  				; enlarge the final memory block size
  2576                                  %else
  2577 000009EA 2EC706[360E][8208]      	mov word [cs:memsize], relocatedzero + paras(auxbuff_size 			+ auxbuff_size 			+ historysegment_size 			+ dev_env_size 			+ extsegment_size)
  2582                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
  2583                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits_truncated, equ $ - 2
  2584                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  2585                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code_truncated, equ $ - 2
  2586                                   wlcalc word_wrt_@@lDEBUG_CODE2@_extpara_behind_code2, equ $ - 2
  2587                                  %endif
  2588                                  
  2589 000009F1 8CDB                    	mov bx, ds
  2590                                   %ifn _LINK
  2591                                  	add bx, FORCESTRICTWORD paras(DEVICEADJUST)
  2592                                   %else
  2593                                  ;%define DEVICEADJUST	(deviceshim_size + 110h)
  2594 000009F3 81C3[1100]              	add bx, strict word relocatedzero + paras(110h)
  2595                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2596                                   %endif
  2597                                  %ifn _LINK
  2598                                  	add bx, paras(AUXTARGET3)
  2599                                  %else
  2600 000009F7 81C3[0102]              	add bx, strict word relocatedzero + paras(auxbuff_size)
  2601                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
  2602                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits_truncated, equ $ - 2
  2603                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  2604                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code_truncated, equ $ - 2
  2605                                   wlcalc word_wrt_@@lDEBUG_CODE2@_extpara_behind_code2, equ $ - 2
  2606                                  %endif	; _LINK
  2607 000009FB 89CA                    	mov dx, cx
  2608                                   %if _EXTENSIONS || _HISTORY_SEPARATE_FIXED && _HISTORY || _DEV_ENV_SIZE
  2609 000009FD 89D8                    	mov ax, bx
  2610 000009FF 050102                  	add ax, paras(auxbuff_size)
  2611                                   %endif
  2612 00000A02 2EC706[3C0E][B233]      	mov word [cs:init_layout], init_dev_layout_3
  2613 00000A09 E823F8                  	call init_check_auxbuff
  2614 00000A0C 7406                    	jz @F
  2615                                  
  2616                                  		; Because this shouldn't happen, this is
  2617                                  		;  considered an internal error.
  2618 00000A0E BA[0710]                	mov dx, imsg.early_reloc_fail
  2619 00000A11 E953FF                  	jmp .earlyfail
  2620                                  
  2621                                  @@:
  2622                                   %if _EXTENSIONS || _HISTORY_SEPARATE_FIXED && _HISTORY || _DEV_ENV_SIZE
  2623 00000A14 50                      	push ax
  2624                                   %endif
  2625 00000A15 E8DFF7                  	call place_code_segments
  2626                                  
  2627                                  %if _MESSAGESEGMENT
  2628 00000A18 8CD8                    	mov ax, ds
  2629                                  %ifn _LINK
  2630                                  	add ax, paras(MESSAGESECTIONOFFSET)
  2631                                  %else
  2632 00000A1A 05[0000]                	add ax, strict word relocatedzero + 0
  2633                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
  2634                                  %endif
  2635 00000A1D 8CDA                    	mov dx, ds
  2636                                  %ifn _LINK
  2637                                  	add dx, 10h 		+ paras(deviceshim_size + 110h 		+ DATAENTRYTABLESIZE + datastack_size)
  2640                                  	mov cx, paras(messagesegment_truncated_size)
  2641                                  %else
  2642 00000A1F 81C2[1100]              	add dx, strict word relocatedzero + 10h + paras(110h - 100h)
  2643                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2644                                   wlcalc word_wrt_@@lDEBUG_DATA_ENTRY@_extpara_end_of_datastack, equ $ - 2
  2645 00000A23 B9[0000]                	mov cx, relocatedzero + 0
  2646                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_truncated, equ $ - 2
  2647                                  %endif
  2648 00000A26 E82310                  	call init_movp
  2649                                   %if _BOOTLDR_DISCARD_HELP
  2650                                  %ifn _LINK
  2651                                  	mov word [messageseg_size], messagesegment_nobits_truncated_size
  2652                                  %else
  2653 00000A29 C706[0000][0000]        	mov word [messageseg_size], behind_messagesegment_nobits_truncated wrt MESSAGESEGMENT
  2654                                  %endif
  2655                                    %if _HELP_COMPRESSED
  2656 00000A2F C706[0000][0000]        	mov word [indirect_hshrink_message_buffer], truncated_hshrink_message_buffer
  2657                                     %if _LINK || _LINK_COMPAT
  2658 00000A35 8E06[0000]              	mov es, [code_seg]
  2659 00000A39 26800E[0000]01          	setopt [es:patch_boothelp_uncompressed], NONCOMPRESSEDFLAG
  2660                                     %endif
  2661                                    %endif
  2662 00000A3F 1E                      	push ds
  2663 00000A40 0E                      	 push cs
  2664 00000A41 1F                      	 pop ds
  2665 00000A42 BE[0216]                	mov si, imsg.boothelp_replacement
  2666 00000A45 8EC2                    	mov es, dx
  2667 00000A47 BF[0000]                	mov di, msg.boothelp
  2668 00000A4A B91C00                  	mov cx, imsg.boothelp_replacement_size_w
  2669 00000A4D F3A5                    	rep movsw
  2670 00000A4F 31C0                    	xor ax, ax
  2671                                     %ifn _LINK
  2672                                  	mov cx, words(messagesegment_nobits_truncated_size 		- (msg.boothelp - messagesegment_start 			+ fromwords(imsg.boothelp_replacement_size_w)))
  2675                                     %else
  2676 00000A51 B9[3800]                	mov cx, relocatedzero + fromwords(imsg.boothelp_replacement_size_w)
  2677                                   wlcalc word_ext_msg.boothelp, equ $ - 2	; length + start
  2678                                   wlcalc word_subr_0, equ $ - 2			; - (length + start)
  2679                                   wlcalc word_wrt_MESSAGESEGMENT_ext_behind_messagesegment_nobits_truncated, equ $ - 2
  2680                                   						; behind - (length + start)
  2681                                   wlcalc word_shr_1, equ $ - 2			; above >> 1
  2682                                     %endif
  2683 00000A54 F3AB                    	rep stosw
  2684 00000A56 1F                      	pop ds
  2685                                   %endif
  2686 00000A57 52                      	push dx
  2687                                  %endif
  2688                                  
  2689 00000A58 8CD8                    	mov ax, ds
  2690 00000A5A 83C010                  	add ax, 10h
  2691 00000A5D 89C2                    	mov dx, ax
  2692                                  %ifn _LINK
  2693                                  	add dx, FORCESTRICTWORD paras(deviceshim_size + 110h)
  2694                                  %else
  2695 00000A5F 81C2[1100]              	add dx, strict word relocatedzero + paras(110h)
  2696                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2697                                  %endif
  2698                                  %ifn _LINK
  2699                                  	mov cx, paras(DATAENTRYTABLESIZE)
  2700                                  %else
  2701 00000A63 B9[F0FF]                	mov cx, relocatedzero + - paras(256)
  2702                                   wlcalc word_wrt_@@lDEBUG_DATA_ENTRY@_extpara_behind_progbits_dataentry, equ $ - 2
  2703                                  %endif
  2704 00000A66 E8E30F                  	call init_movp
  2705                                  
  2706 00000A69 8CC8                    	mov ax, cs
  2707                                  %ifn _LINK
  2708                                  	add ax, init_size_p
  2709                                  %else
  2710 00000A6B 05[0000]                	add ax, strict word relocatedzero + 0
  2711                                   wlcalc word_wrt_INIT_extpara_behind_init, equ $ - 2
  2712                                  %endif
  2713 00000A6E 8CDA                    	mov dx, ds
  2714 00000A70 83C210                  	add dx, paras(100h)
  2715                                  %ifn _LINK
  2716                                  	mov cx, deviceshim_size_p
  2717                                  %else
  2718 00000A73 B9[0000]                	mov cx, relocatedzero + 0
  2719                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2720                                  %endif
  2721 00000A76 E8D30F                  	call init_movp
  2722                                  
  2723 00000A79 8CDA                    	mov dx, ds
  2724                                  %ifn _LINK
  2725                                  	add dx, FORCESTRICTWORD paras(100h) + deviceshim_size_p
  2726                                  %else
  2727 00000A7B 81C2[1000]              	add dx, strict word relocatedzero + paras(100h)
  2728                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2729                                  %endif
  2730 00000A7F 8EC2                    	mov es, dx
  2731 00000A81 1E                      	push ds
  2732                                  %ifn _LINK
  2733                                  	sub dx, FORCESTRICTWORD deviceshim_size_p + 1
  2734                                  %else
  2735 00000A82 81EA[0100]              	sub dx, strict word relocatedzero + 1
  2736                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2737                                  %endif
  2738 00000A86 8EDA                    	mov ds, dx
  2739 00000A88 31C0                    	xor ax, ax
  2740 00000A8A 31FF                    	xor di, di
  2741 00000A8C B90400                  	mov cx, 4
  2742 00000A8F F3AB                    	rep stosw
  2743 00000A91 BE0800                  	mov si, 8
  2744 00000A94 B104                    	mov cl, 4
  2745 00000A96 F3A5                    	rep movsw
  2746 00000A98 1F                      	pop ds
  2747                                  
  2748 00000A99 8CDA                    	mov dx, ds
  2749                                   %ifn _LINK
  2750                                  	add dx, FORCESTRICTWORD paras(DEVICEADJUST)
  2751                                   %else
  2752                                  ;%define DEVICEADJUST	(deviceshim_size + 110h)
  2753 00000A9B 81C2[1100]              	add dx, strict word relocatedzero + paras(110h)
  2754                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2755                                   %endif
  2756 00000A9F 8EDA                    	mov ds, dx
  2757                                  
  2758                                  %if _MESSAGESEGMENT
  2759                                   %if _HELP_COMPRESSED && ! _PM
  2760                                  	pop ax
  2761                                  	mov [hshrink_memory_source.segment], ax
  2762                                  	mov [messageseg], ax
  2763                                   %else
  2764 00000AA1 8F06[0000]              	pop word [messageseg]
  2765                                   %endif
  2766                                  %endif
  2767                                  
  2768 00000AA5 53                      	push bx
  2769 00000AA6 B451                    	mov ah, 51h
  2770 00000AA8 CD21                    	int 21h
  2771 00000AAA 891E[0000]              	mov word [pspdbe], bx
  2772 00000AAE 5B                      	pop bx
  2773                                  
  2774 00000AAF 8EC2                    	mov es, dx
  2775 00000AB1 B98000                  	mov cx, words(256)
  2776 00000AB4 31FF                    	xor di, di
  2777 00000AB6 31C0                    	xor ax, ax
  2778 00000AB8 F3AB                    	rep stosw		; clear buffer for PSP + command line tail
  2779                                  
  2780                                  		; PSP creation moved to later, after command line parsing
  2781                                  
  2782                                   %if _EXTENSIONS || _HISTORY_SEPARATE_FIXED && _HISTORY || _DEV_ENV_SIZE
  2783 00000ABA 58                      	pop ax
  2784                                    %if _HISTORY_SEPARATE_FIXED && _HISTORY
  2785 00000ABB A3[0000]                	mov word [history.segorsel + soaSegSel], ax
  2786                                  %if _PM
  2787 00000ABE A3[0200]                	mov word [history.segorsel + soaSegment], ax
  2788                                  %endif
  2789 00000AC1 8EC0                    	mov es, ax
  2790 00000AC3 31FF                    	xor di, di
  2791 00000AC5 B90010                  	mov cx, historysegment_size >> 1
  2792 00000AC8 31C0                    	xor ax, ax
  2793 00000ACA F3AB                    	rep stosw
  2794                                    %endif
  2795                                  
  2796                                    %if _DEV_ENV_SIZE
  2797                                     %if _HISTORY_SEPARATE_FIXED && _HISTORY
  2798 00000ACC 8CC0                    	mov ax, es
  2799 00000ACE 050002                  	add ax, paras(historysegment_size)
  2800                                     %endif
  2801 00000AD1 A3[0000]                	mov word [envseg], ax
  2802 00000AD4 8EC0                    	mov es, ax
  2803 00000AD6 89C2                    	mov dx, ax
  2804 00000AD8 42                      	inc dx
  2805 00000AD9 31FF                    	xor di, di
  2806 00000ADB B90004                  	mov cx, dev_env_size >> 1
  2807 00000ADE C706[0000]0008          	mov word [env_size], dev_env_size
  2808 00000AE4 31C0                    	xor ax, ax
  2809 00000AE6 F3AB                    	rep stosw
  2810 00000AE8 26C70603007F00          	mov word [es:3], paras(dev_env_size - 16)
  2811                                    %endif
  2812                                  
  2813                                    %if _EXTENSIONS
  2814                                     %if _HISTORY_SEPARATE_FIXED && _HISTORY || _DEV_ENV_SIZE
  2815 00000AEF 8CC0                    	mov ax, es
  2816                                      %if _DEV_ENV_SIZE
  2817 00000AF1 058000                  	add ax, paras(dev_env_size)
  2818                                      %else
  2819                                  	add ax, paras(historysegment_size)
  2820                                      %endif
  2821                                     %endif
  2822 00000AF4 A3[0000]                	mov word [extseg], ax
  2823 00000AF7 8EC0                    	mov es, ax
  2824 00000AF9 31FF                    	xor di, di
  2825 00000AFB B90010                  	mov cx, extsegment_size >> 1
  2826 00000AFE 31C0                    	xor ax, ax
  2827 00000B00 F3AB                    	rep stosw
  2828                                    %endif
  2829                                   %endif
  2830                                  
  2831 00000B02 89D8                    	mov ax, bx
  2832                                  
  2833 00000B04 A3[0000]                	mov word [auxbuff_segorsel + soaSegSel], ax
  2834                                  %if _PM
  2835 00000B07 A3[0200]                	mov word [auxbuff_segorsel + soaSegment], ax
  2836                                  					; initialise auxbuff references
  2837                                  %endif
  2838                                  %if _IMMASM  && _IMMASM_AUXBUFF
  2839                                  	mov word [immseg], ax
  2840                                  %endif
  2841                                  
  2842 00000B0A 8EC0                    	mov es, ax
  2843 00000B0C 31FF                    	xor di, di
  2844 00000B0E B90810                  	mov cx, _AUXBUFFSIZE >> 1
  2845 00000B11 31C0                    	xor ax, ax
  2846 00000B13 F3AB                    	rep stosw			; initialise auxbuff
  2847                                  
  2848                                  %if _DEV_ENV_SIZE
  2849 00000B15 89162C00                	mov word [2Ch], dx
  2850 00000B19 1E                      	push ds
  2851 00000B1A E87701                  	call init_device_get_environment
  2852 00000B1D 85C0                    	test ax, ax
  2853 00000B1F 7425                    	jz @F
  2854 00000B21 8ED8                    	mov ds, ax
  2855 00000B23 8EC2                    	mov es, dx
  2856 00000B25 31FF                    	xor di, di
  2857 00000B27 31F6                    	xor si, si
  2858                                  .loop_env:
  2859 00000B29 E8D826                  	call init_nextvar
  2860 00000B2C 75FB                    	jne .loop_env
  2861 00000B2E 46                      	inc si
  2862 00000B2F 81FEEE07                	cmp si, dev_env_size - 16 - 2
  2863 00000B33 7608                    	jbe .copy_env
  2864 00000B35 BA[530F]                	mov dx, imsg.dev_env_too_large
  2865 00000B38 E8A20F                  	call init_putsz_cs
  2866 00000B3B EB09                    	jmp @F
  2867                                  
  2868                                  .copy_env:
  2869 00000B3D 89F1                    	mov cx, si
  2870 00000B3F 31F6                    	xor si, si
  2871 00000B41 F3A4                    	rep movsb
  2872 00000B43 31C0                    	xor ax, ax
  2873 00000B45 AB                      	stosw
  2874                                  @@:
  2875 00000B46 1F                      	pop ds
  2876                                  %endif
  2877                                  
  2878 00000B47 8CD8                    	mov ax, ds			; => PSP
  2879                                  %ifn _LINK
  2880                                  	sub ax, strict word deviceshim_size_p + paras(10h)
  2881                                  %else
  2882 00000B49 2D[0100]                	sub ax, strict word relocatedzero + paras(10h)
  2883                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2884                                  %endif
  2885 00000B4C A3[0200]                	mov word [device_header_address + 2], ax
  2886 00000B4F A3[0000]                	mov word [alloc_seg], ax
  2887                                  
  2888 00000B52 8CD8                    	mov ax, ds			; => PSP
  2889 00000B54 2E8B1E[360E]            	mov bx, word [cs:memsize]
  2890                                  		; = amount paragraphs for PSP + DATA ENTRY + TABLE
  2891                                  		;  + DATA STACK + CODE + AUXBUFF + HISTORY + dev ENV + EXT
  2892 00000B59 01D8                    	add ax, bx			; => placeholder for trailing container
  2893                                  %ifn _LINK
  2894                                  	add bx, FORCESTRICTWORD deviceshim_size_p + paras(10h) + paras(10h)
  2895                                  %else
  2896 00000B5B 81C3[0200]              	add bx, strict word relocatedzero + paras(10h + 10h)
  2897                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  2898                                  %endif
  2899                                  		; (layout is deviceshim, MCB placeholder, debugger segments,
  2900                                  		;  placeholder for trailing container MCB)
  2901                                  					; = amount paragraphs expected in MCB
  2902 00000B5F 891E[0000]              	mov word [device_mcb_paragraphs], bx
  2903 00000B63 891E[0000]              	mov word [alloc_size], bx
  2904                                  
  2905                                  					; ax => where to place container sig
  2906 00000B67 E80200                  	call init_dev_place_container_signature
  2907                                  					; ax => behind memory used for device
  2908 00000B6A EB12                    	jmp @F
  2909                                  
  2910                                  		; INP:	ax => where to place container signature
  2911                                  		; OUT:	ax => behind memory used for device
  2912                                  		;	ax = INP:ax + 1
  2913                                  		; CHG:	es, di, cx, si
  2914                                  init_dev_place_container_signature:
  2915 00000B6C 8EC0                    	mov es, ax
  2916 00000B6E 31FF                    	xor di, di			; -> buffer for trailing container MCB
  2917 00000B70 B90800                  	mov cx, words(10h)		; = amount words
  2918 00000B73 1E                      	push ds
  2919 00000B74 0E                      	 push cs
  2920 00000B75 1F                      	 pop ds
  2921 00000B76 BE[A00D]                	 mov si, init_container_signature	; -> init string
  2922 00000B79 F3A5                    	rep movsw
  2923 00000B7B 1F                      	pop ds
  2924 00000B7C 40                      	inc ax				; => behind memory used for device
  2925 00000B7D C3                      	retn
  2926                                  
  2927                                  
  2928                                  @@:
  2929 00000B7E 8F06[0000]              	pop word [reg_edi]
  2930 00000B82 8F06[0000]              	pop word [reg_esi]
  2931 00000B86 8F06[0000]              	pop word [reg_edx]
  2932 00000B8A 8F06[0000]              	pop word [reg_ecx]
  2933 00000B8E 892E[0000]              	mov word [reg_ebp], bp
  2934 00000B92 5B                      	pop bx
  2935 00000B93 07                      	pop es
  2936 00000B94 891E[0000]              	mov word [reg_ebx], bx
  2937 00000B98 8C06[0000]              	mov word [reg_es], es
  2938                                  
  2939 00000B9C 26C747030001            	mov word [es:bx + 3], 100h	; no error, done
  2940 00000BA2 2683670E00              	and word [es:bx + 0Eh], 0
  2941 00000BA7 26894710                	mov word [es:bx + 0Eh + 2], ax	; -> behind memory in use
  2942                                  
  2943 00000BAB 8F06[0000]              	pop word [reg_efl]
  2944 00000BAF 8F06[0000]              	pop word [reg_ds]
  2945 00000BB3 8F06[0000]              	pop word [reg_eax]
  2946 00000BB7 8C16[0000]              	mov word [reg_ss], ss
  2947 00000BBB 8926[0000]              	mov word [reg_esp], sp
  2948                                  
  2949 00000BBF 8C1E[0000]              	mov word [reg_cs], ds
  2950 00000BC3 C706[0000][0000]        	mov word [reg_eip], entry_retf
  2951                                  
  2952                                  .cmdline:
  2953 00000BC9 1E                      	push ds
  2954 00000BCA 26C57712                	lds si, [es:bx + 12h]		; ds:si -> device command line
  2955 00000BCE 07                      	pop es
  2956                                  %if _CONFIG
  2957 00000BCF 1E                      	push ds
  2958 00000BD0 56                      	push si
  2959                                  %endif
  2960 00000BD1 BF8100                  	mov di, 81h			; es:di -> PSP command line tail
  2961                                  
  2962                                  		; Writing MS-DOS Device Drivers, second edition, page 349
  2963                                  		;  specifies the following as to the command line termination:
  2964                                  		; "Note that the DEVICE= command string is terminated by an
  2965                                  		;  Ah when there are no arguments. When there are arguments,
  2966                                  		;  the string is terminated with the following sequence:
  2967                                  		;  0h, Dh, Ah."
  2968                                  
  2969                                  		; First skip past name.
  2970                                  @@:
  2971 00000BD4 AC                      	lodsb
  2972 00000BD5 3C20                    	cmp al, 32			; blank ?
  2973 00000BD7 7412                    	je @F
  2974 00000BD9 3C09                    	cmp al, 9
  2975 00000BDB 740E                    	je @F				; yes, got past executable filename -->
  2976 00000BDD 3C00                    	cmp al, 0
  2977 00000BDF 7448                    	je .cmdline_end
  2978 00000BE1 3C0D                    	cmp al, 13
  2979 00000BE3 7444                    	je .cmdline_end
  2980 00000BE5 3C0A                    	cmp al, 10
  2981 00000BE7 7440                    	je .cmdline_end			; if empty tail -->
  2982 00000BE9 EBE9                    	jmp @B
  2983                                  @@:
  2984 00000BEB 81FFFF00                	cmp di, 0FFh			; can store and still have space for CR ?
  2985 00000BEF 7430                    	je .cmdline_end_truncate	; no -->
  2986 00000BF1 AA                      	stosb				; store it
  2987 00000BF2 3C00                    	cmp al, 0			; EOL ?
  2988 00000BF4 7432                    	je .cmdline_end_dec
  2989 00000BF6 3C0D                    	cmp al, 13
  2990 00000BF8 742E                    	je .cmdline_end_dec
  2991 00000BFA 3C0A                    	cmp al, 10
  2992 00000BFC 742A                    	je .cmdline_end_dec		; yes -->
  2993 00000BFE AC                      	lodsb
  2994 00000BFF 3C21                    	cmp al, '!'			; escape for small letters ?
  2995 00000C01 75E8                    	jne @B				; no -->
  2996 00000C03 AC                      	lodsb
  2997 00000C04 3C00                    	cmp al, 0
  2998 00000C06 7414                    	je .cmdline_end_escaped
  2999 00000C08 3C0D                    	cmp al, 13
  3000 00000C0A 7410                    	je .cmdline_end_escaped
  3001 00000C0C 3C0A                    	cmp al, 10
  3002 00000C0E 740C                    	je .cmdline_end_escaped
  3003                                  	; cmp al, '!'			; (automatically supported)
  3004 00000C10 3C41                    	cmp al, 'A'			; is it a capital letter ?
  3005 00000C12 72D7                    	jb @B
  3006 00000C14 3C5A                    	cmp al, 'Z'
  3007 00000C16 77D3                    	ja @B
  3008 00000C18 3420                    	xor al, 'a' ^ 'A'		; get the small letter
  3009 00000C1A EBCF                    	jmp @B
  3010                                  
  3011                                  .cmdline_end_escaped:
  3012 00000C1C BA[5F10]                	mov dx, imsg.device_end_escaped
  3013 00000C1F EB03                    	jmp @F
  3014                                  
  3015                                  .cmdline_end_truncate:
  3016 00000C21 BA[8F10]                	mov dx, imsg.device_end_truncate
  3017                                   @@:
  3018 00000C24 E8B60E                  	call init_putsz_cs
  3019 00000C27 A8                      	db __TEST_IMM8			; skip dec
  3020                                  .cmdline_end_dec:
  3021 00000C28 4F                      	dec di
  3022                                  .cmdline_end:
  3023 00000C29 B00D                    	mov al, 13
  3024 00000C2B AA                      	stosb				; store CR
  3025 00000C2C 97                      	xchg ax, di
  3026 00000C2D 8CC3                    	 mov bx, es
  3027 00000C2F 8EDB                    	 mov ds, bx
  3028 00000C31 2C82                    	sub al, 82h			; if -> 82h (CR at 81h). get 0
  3029 00000C33 A28000                  	mov byte [80h], al		; store length
  3030                                  
  3031                                  %if _CONFIG
  3032 00000C36 5E                      	pop si
  3033 00000C37 5A                      	pop dx
  3034                                  %endif
  3035                                  
  3036 00000C38 FA                      	cli
  3037 00000C39 8ED3                    	 mov ss, bx
  3038 00000C3B BC[0000]                	 mov sp, stack_end		; device mode stack switch
  3039 00000C3E FB                      	sti
  3040                                  
  3041 00000C3F 800E[0200]40            	setopt [internalflags], tsrmode
  3042 00000C44 8026[0200]7F            	clropt [internalflags], attachedterm
  3043 00000C49 800E[0200]40            	setopt [internalflags6], dif6_device_mode
  3044                                  
  3045                                  %if _CONFIG
  3046                                  find_config_device:
  3047 00000C4E E84300                  	call init_device_get_environment
  3048                                  
  3049 00000C51 36C606[0000]00          	mov byte [ss:configpath], 0
  3050 00000C57 50                      	push ax
  3051 00000C58 52                      	push dx
  3052 00000C59 56                      	push si
  3053 00000C5A BF[380F]                	mov di, imsg.varconfig
  3054 00000C5D B90D00                  	mov cx, imsg.varconfig.length
  3055 00000C60 BA[0000]                	mov dx, configpath
  3056 00000C63 E80226                  	call init_copyvar
  3057 00000C66 5E                      	pop si
  3058 00000C67 1F                      	pop ds			; -> command line
  3059 00000C68 1E                      	push ds
  3060 00000C69 56                      	push si
  3061 00000C6A 7303                    	jnc .done
  3062 00000C6C E84A00                  	call find_executable_device
  3063                                  .done:
  3064 00000C6F 5E                      	pop si
  3065 00000C70 1F                      	pop ds			; -> command line
  3066 00000C71 58                      	pop ax
  3067                                  
  3068                                  find_scripts_device:
  3069 00000C72 36C606[0000]00          	mov byte [ss:scriptspath], 0
  3070 00000C78 1E                      	push ds
  3071 00000C79 56                      	push si
  3072 00000C7A BF[450F]                	mov di, imsg.varscripts
  3073 00000C7D B90E00                  	mov cx, imsg.varscripts.length
  3074 00000C80 BA[0000]                	mov dx, scriptspath
  3075 00000C83 E8E225                  	call init_copyvar
  3076 00000C86 5E                      	pop si
  3077 00000C87 1F                      	pop ds			; -> command line
  3078 00000C88 7303                    	jnc .done
  3079 00000C8A E82C00                  	call find_executable_device
  3080                                  .done:
  3081                                  
  3082 00000C8D 16                      	push ss
  3083 00000C8E 1F                      	pop ds
  3084 00000C8F 16                      	push ss
  3085 00000C90 07                      	pop es
  3086                                  %endif
  3087                                  
  3088 00000C91 E9C30E                  	jmp old_initcode
  3089                                  
  3090                                  
  3091                                  init_device_get_environment:
  3092 00000C94 B451                    	mov ah, 51h
  3093 00000C96 CD21                    	int 21h
  3094 00000C98 8EDB                    	mov ds, bx
  3095 00000C9A A12C00                  	mov ax, [2Ch]
  3096 00000C9D 85C0                    	test ax, ax
  3097 00000C9F 7517                    	jnz @F
  3098 00000CA1 A11600                  	mov ax, [16h]
  3099 00000CA4 85C0                    	test ax, ax
  3100 00000CA6 740E                    	jz .zero
  3101 00000CA8 83F8FF                  	cmp ax, -1
  3102 00000CAB 7409                    	je .zero
  3103 00000CAD 39D8                    	cmp ax, bx
  3104 00000CAF 8ED8                    	mov ds, ax
  3105 00000CB1 A12C00                  	mov ax, [2Ch]
  3106 00000CB4 7502                    	jne @F
  3107                                  .zero:
  3108 00000CB6 31C0                    	xor ax, ax
  3109                                  @@:
  3110 00000CB8 C3                      	retn
  3111                                  
  3112                                  
  3113                                  %if _CONFIG
  3114                                  		; INP:	ss:dx -> buffer
  3115                                  		;	ds:si -> device driver command line
  3116                                  find_executable_device:
  3117                                  @@:
  3118 00000CB9 AC                      	lodsb
  3119 00000CBA 3C20                    	cmp al, 32
  3120 00000CBC 74FB                    	je @B
  3121 00000CBE 3C09                    	cmp al, 9
  3122 00000CC0 74F7                    	je @B
  3123 00000CC2 4E                      	dec si
  3124 00000CC3 89F7                    	mov di, si
  3125                                  @@:
  3126 00000CC5 AC                      	lodsb
  3127 00000CC6 3C09                    	cmp al, 9
  3128 00000CC8 7410                    	je @F
  3129 00000CCA 3C20                    	cmp al, 32
  3130 00000CCC 740C                    	je @F
  3131 00000CCE 3C0D                    	cmp al, 13
  3132 00000CD0 7408                    	je @F
  3133 00000CD2 3C0A                    	cmp al, 10
  3134 00000CD4 7404                    	je @F
  3135 00000CD6 84C0                    	test al, al
  3136 00000CD8 75EB                    	jnz @B
  3137                                  @@:
  3138 00000CDA 4E                      	dec si
  3139 00000CDB 1E                      	push ds
  3140 00000CDC 07                      	pop es
  3141 00000CDD 89F1                    	mov cx, si
  3142 00000CDF 29F9                    	sub cx, di
  3143 00000CE1 83F97F                  	cmp cx, 127
  3144 00000CE4 7722                    	ja .nodevice
  3145 00000CE6 87FE                    	xchg di, si
  3146                                  
  3147 00000CE8 B90000                  	mov cx, 0
  3148                                  @@:
  3149 00000CEB 39F7                    	cmp di, si
  3150 00000CED 7610                    	jbe @F
  3151 00000CEF 4F                      	dec di
  3152 00000CF0 803D2F                  	cmp byte [di], '/'
  3153 00000CF3 7405                    	je .slash
  3154 00000CF5 803D5C                  	cmp byte [di], '\'
  3155 00000CF8 75F1                    	jne @B
  3156                                  .slash:
  3157 00000CFA 89F9                    	mov cx, di
  3158 00000CFC 41                      	inc cx
  3159 00000CFD 29F1                    	sub cx, si
  3160                                  @@:
  3161                                  
  3162 00000CFF 16                      	push ss
  3163 00000D00 07                      	pop es
  3164 00000D01 89D7                    	mov di, dx
  3165 00000D03 F3A4                    	rep movsb
  3166 00000D05 B000                    	mov al, 0
  3167 00000D07 AA                      	stosb
  3168                                  
  3169                                  .nodevice:
  3170                                  .done:
  3171 00000D08 C3                      	retn
  3172                                  %endif
  3173                                  
  3174                                  
  3175                                  init_device_error_late:
  3176 00000D09 F606[0100]80            	testopt [internalflags], has386
  3177 00000D0E 7431                    	jz .16
  3178                                  
  3179                                  subcpu 386
  3180 00000D10 66A1[0000]              	mov eax, [reg_eax]
  3181 00000D14 668B1E[0000]            	mov ebx, [reg_ebx]
  3182 00000D19 668B0E[0000]            	mov ecx, [reg_ecx]
  3183 00000D1E 668B16[0000]            	mov edx, [reg_edx]
  3184 00000D23 668B36[0000]            	mov esi, [reg_esi]
  3185 00000D28 668B3E[0000]            	mov edi, [reg_edi]
  3186 00000D2D 668B2E[0000]            	mov ebp, [reg_ebp]
  3187 00000D32 66FF36[0000]            	push dword [reg_efl]
  3188 00000D37 669D                    	popfd
  3189 00000D39 8E26[0000]              	mov fs, [reg_fs]
  3190 00000D3D 8E2E[0000]              	mov gs, [reg_gs]
  3191                                  subcpureset
  3192                                  
  3193                                  .16:
  3194                                  		; ax done last
  3195 00000D41 8B1E[0000]              	mov bx, [reg_ebx]
  3196 00000D45 8B0E[0000]              	mov cx, [reg_ecx]
  3197 00000D49 8B16[0000]              	mov dx, [reg_edx]
  3198 00000D4D 8B36[0000]              	mov si, [reg_esi]
  3199 00000D51 8B3E[0000]              	mov di, [reg_edi]
  3200 00000D55 8B2E[0000]              	mov bp, [reg_ebp]
  3201 00000D59 FF36[0000]              	push word [reg_efl]
  3202 00000D5D 9D                      	popf
  3203 00000D5E 8E06[0000]              	mov es, [reg_es]
  3204 00000D62 8E16[0000]              	mov ss, [reg_ss]
  3205 00000D66 8B26[0000]              	mov sp, [reg_esp]
  3206 00000D6A FF36[0000]              	push word [reg_eax]
  3207 00000D6E 8CD8                    	mov ax, ds
  3208 00000D70 8E1E[0000]              	mov ds, [reg_ds]
  3209                                  
  3210                                  %ifn _LINK
  3211                                  	sub ax, strict word paras(deviceshim_size + 10h)
  3212                                  %else
  3213 00000D74 2D[0100]                	sub ax, strict word relocatedzero + paras(10h)
  3214                                   wlcalc word_wrt_DEVICESHIM_extpara_behind_deviceshim, equ $ - 2
  3215                                  %endif
  3216 00000D77 26C747030381            	mov word [es:bx + 3], 8103h	; error, done, code: unknown command
  3217 00000D7D 2683670E00              	and word [es:bx + 0Eh], 0
  3218 00000D82 26894710                	mov word [es:bx + 0Eh + 2], ax	; -> behind memory in use
  3219 00000D86 58                      	pop ax
  3220 00000D87 CB                      	retf
  3221                                  %endif
  3222                                  
  3223                                  
  3224                                  %if _DEBUG4 || _DEBUG5
  3225                                  %define _DEB_ASM_PREFIX init_
  3226                                  %include "deb.asm"
  3227                                  %endif
  3228                                  
  3229                                  
  3230                                  %if ! _LINK && ! _LINK_COMPAT
  3231                                  	align 2, db 0				; align on word boundary
  3232                                  		; Table of patches that are to be set NOP if not running on a 386.
  3233                                  writepatchtable patch_no386_table, PATCH_NO386_TABLE
  3234                                  %undef PATCH_NO386_TABLE
  3235                                  
  3236                                  	align 2, db 0
  3237                                  		; Table of patches that are to be set NOP if running on a 386.
  3238                                  writepatchtable patch_386_table, PATCH_386_TABLE
  3239                                  %undef PATCH_386_TABLE
  3240                                  
  3241                                  %if _DUALCODE
  3242                                  	align 2, db 0				; align on word boundary
  3243                                  		; Table of patches that are to be set NOP if not running on a 386.
  3244                                  writepatchtable patch_no386_table2, PATCH_NO386_TABLE2
  3245                                  %undef PATCH_NO386_TABLE2
  3246                                  
  3247                                  	align 2, db 0
  3248                                  		; Table of patches that are to be set NOP if running on a 386.
  3249                                  writepatchtable patch_386_table2, PATCH_386_TABLE2
  3250                                  %undef PATCH_386_TABLE2
  3251                                  %else
  3252                                   %assign __patch_no386_table2_method 0
  3253                                   %assign __patch_386_table2_method 0
  3254                                  %endif
  3255                                  
  3256                                  	align 2, db 0				; align on word boundary
  3257                                  		; Table of patches that are to be set NOP if not running on a 386.
  3258                                  writepatchtable patch_no386_tableentry, PATCH_NO386_TABLEENTRY
  3259                                  %undef PATCH_NO386_TABLEENTRY
  3260                                  
  3261                                  	align 2, db 0
  3262                                  		; Table of patches that are to be set NOP if running on a 386.
  3263                                  writepatchtable patch_386_tableentry, PATCH_386_TABLEENTRY
  3264                                  %undef PATCH_386_TABLEENTRY
  3265                                  %elif _LINK
  3266                                  %ifn _ONLY386 || _ONLYNON386
  3267                                   extern patch_no386_table
  3268                                   extern patch_no386_table.amount
  3269                                  %assign __patch_no386_table_method 1
  3270                                   extern patch_386_table
  3271                                   extern patch_386_table.amount
  3272                                  %assign __patch_386_table_method 1
  3273                                  %if _DUALCODE
  3274                                   extern patch_no386_table2
  3275                                   extern patch_no386_table2.amount
  3276                                  %assign __patch_no386_table2_method 1
  3277                                   extern patch_386_table2
  3278                                   extern patch_386_table2.amount
  3279                                  %assign __patch_386_table2_method 1
  3280                                  %else
  3281                                  %assign __patch_no386_table2_method 0
  3282                                  %assign __patch_386_table2_method 0
  3283                                  %endif
  3284                                   extern patch_no386_tableentry
  3285                                   extern patch_no386_tableentry.amount
  3286                                  %assign __patch_no386_tableentry_method 1
  3287                                   extern patch_386_tableentry
  3288                                   extern patch_386_tableentry.amount
  3289                                  %assign __patch_386_tableentry_method 1
  3290                                  %assign patch_386_tableentry_size 1	; placeholder
  3291                                  %assign patch_no386_tableentry_size 1	; placeholder
  3292                                  %endif
  3293                                  %endif
  3294                                  
  3295                                  %if !_LINK && _LINK_COMPAT
  3296                                  %assign _patch_no386_table_FORCE_METHOD 1
  3297                                  %assign _patch_386_table_FORCE_METHOD 1
  3298                                  %assign _patch_no386_table2_FORCE_METHOD 1
  3299                                  %assign _patch_386_table2_FORCE_METHOD 1
  3300                                  %assign _patch_no386_tableentry_FORCE_METHOD 1
  3301                                  %assign _patch_386_tableentry_FORCE_METHOD 1
  3302                                  
  3303                                   %ifn _ONLY386 || _ONLYNON386
  3304                                  %assign __patch_no386_table_method 1
  3305                                  %assign __patch_386_table_method 1
  3306                                    %if _DUALCODE
  3307                                  %assign __patch_no386_table2_method 1
  3308                                  %assign __patch_386_table2_method 1
  3309                                    %else
  3310                                  %assign __patch_no386_table2_method 0
  3311                                  %assign __patch_386_table2_method 0
  3312                                    %endif
  3313                                  %assign __patch_no386_tableentry_method 1
  3314                                  %assign __patch_386_tableentry_method 1
  3315                                   %endif
  3316                                  %endif
  3317                                  
  3318                                  
  3319                                  %ifn _LINK || _LINK_COMPAT
  3320                                  %if _DUALCODE && ! _PM
  3321                                  	align 2, db 0
  3322                                  relocate_from_code:
  3323                                  	dw  PATCH_RELOCATE_FROM_lDEBUG_CODE
  3324                                  .end:
  3325                                  	align 2, db 0
  3326                                  relocate_from_code2:
  3327                                  	dw  PATCH_RELOCATE_FROM_lDEBUG_CODE2
  3328                                  .end:
  3329                                  
  3330                                  %unimacro dualcall 1.nolist
  3331                                  	; make sure we do not allow later uses
  3332                                  %endif
  3333                                  %endif
  3334                                  
  3335                                  
  3336                                  %if _BOOTLDR
  3337 00000D88 00<rep 8h>              	align 16, db 0
  3338                                  	; Image identification
  3339                                  	; First dword: signature
  3340                                  	; Next word: version, two ASCII digits
  3341                                  	; Next word: checksum. adding up all words of the paragraph gives zero
  3342                                  	; Next word: size of image (including this paragraph)
  3343                                  	; Three words reserved, zero.
  3344                                  imageident:
  3345                                  %if !_LOADER
  3346 00000D90 4E4445423030            	db "NDEB00"
  3347 00000D96 0000                    .check:	dw 0
  3348 00000D98 0000                    .size:	dw 0
  3349 00000D9A 0000<rep 3h>            	times 3 dw 0
  3350                                  %else
  3351                                  	istruc LOADERIMAGEIDENT
  3352                                  at liiSignature
  3353                                  	db "NLDR00"
  3354                                  at liiChecksum
  3355                                  .check:	dw 0
  3356                                  at liiAmountParagraphs
  3357                                  .size:	dw 0
  3358                                  at liiReserved
  3359                                  	times 3 dw 0
  3360                                  at liiEntryQuerySize
  3361                                  	dw loader_query
  3362                                  at liiEntryRelocate
  3363                                  	dw loader_transfer_relocate
  3364                                  at liiEntryDebug
  3365                                  	dw loader_transfer_cmd3
  3366                                  at liiStackPointer
  3367                                  	dw stack_end
  3368                                  	iend
  3369                                  	times (2Ch - ($ - imageident)) / 2 dw 0
  3370                                  %endif
  3371                                  %endif
  3372                                  %if _DEVICE
  3373                                  	align 16, db 0
  3374                                  init_container_signature:
  3375 00000DA0 464F525F53445F434F-     	fill 16, 0, db "FOR_SD_CONTAINER"
  3375 00000DA9 4E5441494E4552     
  3376                                  %endif
  3377                                  %if _EXTENSIONS
  3378                                  	align 16, db 0
  3379                                  eld_linkcall:
  3380                                  .:
  3381                                  	istruc ELD_INSTANCE
  3382 00000DB0 0000                    at eldiStartCode,	dw 0
  3383 00000DB2 8000                    at eldiEndCode,		dw .end - .
  3384 00000DB4 0000                    at eldiStartData,	dw 0
  3385 00000DB6 0000                    at eldiEndData,		dw 0
  3386 00000DB8 4C494E4B43414C4C        at eldiIdentifier,	fill 8, 32, db "LINKCALL"
  3387 00000DC0 0100                    at eldiFlags,		dw eldifResident
  3388 00000DC2 00<rep Eh>              	iend
  3389                                  .to_entry:
  3390 00000DD0 53                      	push bx
  3391 00000DD1 B300                    	mov bl, 0 * (1 + !!_PM)
  3392 00000DD3 EB0E                    	jmp @F
  3393 00000DD5 90<rep 3h>              	align 8
  3394                                  .to_code1:
  3395 00000DD8 53                      	push bx
  3396 00000DD9 B304                    	mov bl, 2 * (1 + !!_PM)
  3397                                  %if _DUALCODE
  3398 00000DDB EB06                    	jmp @F
  3399 00000DDD 90<rep 3h>              	align 8
  3400                                  .to_code2:
  3401 00000DE0 53                      	push bx
  3402 00000DE1 B308                    	mov bl, 4 * (1 + !!_PM)
  3403                                  %endif
  3404                                  @@:
  3405                                  	lframe 0
  3406                                  	lpar word, origret_farret_seg
  3407                                  	lpar word, origbx_farret_ofs
  3408                                  	lpar word, restore_back_nearret
  3409 00000DE3 50                      	 push ax
  3410                                  	lpar dword, transfer
  3411 00000DE4 50                      	 push ax
  3412 00000DE5 50                      	 push ax
  3413 00000DE6 5589E5                  	lenter
  3414                                  	lvar word, restorebx
  3415 00000DE9 FF7608                  	 push word [bp + ?origbx_farret_ofs]
  3416                                   %if _PM
  3417                                  	lvar word, restoredi
  3418 00000DEC 57                      	 push di
  3419                                   %endif
  3420 00000DED B700                    	mov bh, 0
  3421 00000DEF 36FFB7[0000]            	push word [ss:extcall_table.ret + bx]
  3422 00000DF4 8F4606                  	pop word [bp + ?restore_back_nearret]
  3423                                   %if _PM
  3424 00000DF7 368B3E[0000]            	mov di, [ss:pm_2_86m_0]
  3425 00000DFC 368B99[0000]            	mov bx, word [ss:extcall_table.segsel + bx + di]
  3426                                   %else
  3427                                  	mov bx, word [ss:extcall_table.segsel + bx]
  3428                                   %endif
  3429 00000E01 368B1F                  	mov bx, word [ss:bx]
  3430 00000E04 895E04                  	mov word [bp + ?transfer + 2], bx
  3431                                  
  3432 00000E07 8B5E0A                  	mov bx, word [bp + ?origret_farret_seg]
  3433 00000E0A 2EFF7702                	push word [cs:bx + 2]
  3434 00000E0E 8F4602                  	pop word [bp + ?transfer]
  3435 00000E11 895E08                  	mov word [bp + ?origbx_farret_ofs], bx
  3436                                   %ifn _PM
  3437                                  	mov word [bp + ?origret_farret_seg], cs
  3438                                   %endif
  3439                                   %if _PM
  3440 00000E14 5F                      	pop di		; ?restoredi
  3441                                   %endif
  3442 00000E15 5B                      	pop bx		; ?restorebx
  3443                                  	lleave ctx
  3444 00000E16 5D                      	pop bp		; ?frame_bp
  3445 00000E17 CB                      	retf		; ?transfer
  3446                                  			; still on stack: near return address, far return address
  3447                                  
  3448 00000E18 90<rep 11h>             	times 79h - ($ - .) nop
  3449                                  .call_cmd3:
  3450 00000E29 E8ACFF                  	call .to_code1
  3451 00000E2C EBFE                    	jmp strict short $
  3452 00000E2E [0000]                  	dw cmd3
  3453                                  
  3454                                  	align 16
  3455                                  	times 128 - ($ - .) nop
  3456                                  .end:
  3457                                  	endarea eld_linkcall
  3458                                  %endif
  3459                                  
  3460                                  %if _BOOTLDR
  3461                                  	align 2, db 0
  3462                                  loader_imageident:
  3463                                  .:
  3464 00000E30 4E4C44523030            	db "NLDR00"
  3465                                  .size equ $ - .
  3466                                  %endif
  3467                                  
  3468                                  	align 2, db 0
  3469                                  memsize:
  3470                                  %ifn _LINK
  3471                                  		dw paras(CODETARGET2 			+ ldebug_code_bootldr_truncated_size 			+ ldebug_code2_size 			+ historysegment_size 			+ extsegment_size)
  3476                                  	; same as paras(AUXTARGET1
  3477                                  	;	+ auxbuff_size
  3478                                  	;	+ historysegment_size
  3479                                  	;	+ extsegment_size)
  3480                                  %else
  3481                                   %if 0
  3482                                  %define CODETARGET1 (MESSAGESECTIONOFFSET + messagesegment_nobits_truncated_size + datastack_size)
  3483                                  %define CODETARGET2 (CODETARGET1+auxbuff_size)
  3484                                  %define AUXTARGET1 (CODETARGET1+ldebug_code_bootldr_truncated_size+ldebug_code2_size)
  3485                                  %define AUXTARGET2 CODETARGET1
  3486                                  %define AUXTARGET3 (AUXTARGET1+auxbuff_size)
  3487                                   %endif
  3488 00000E36 [0106]                  		dw  relocatedzero + paras(auxbuff_size 			+ historysegment_size 			+ extsegment_size)
  3491                                   wlcalc word_segrel_MESSAGESEGMENT, equ $ - 2
  3492                                   wlcalc word_wrt_MESSAGESEGMENT_extpara_behind_messagesegment_nobits_truncated, equ $ - 2
  3493                                   wlcalc word_wrt_DATASTACKBASE_extpara_end_of_datastack, equ $ - 2
  3494                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code_truncated, equ $ - 2
  3495                                   wlcalc word_wrt_@@lDEBUG_CODE2@_extpara_behind_code2, equ $ - 2
  3496                                  %endif
  3497                                  
  3498                                  %if _DEV_ENV_SIZE || _APP_ENV_SIZE
  3499 00000E38 0000                    mem_envsize:	dw 0
  3500                                  %endif
  3501                                  cmdline_buffer_start:
  3502 00000E3A [0000]                  		dw cmdline_buffer
  3503                                  init_layout:
  3504 00000E3C [D533]                  		dw init_layout_none
  3505                                  %if _DEVICE
  3506 00000E3E 0000                    dev_memory_end:	dw 0
  3507                                  %endif
  3508                                  init_auxbuff_want:
  3509 00000E40 1020                    		dw _AUXBUFFSIZE
  3510                                  %if _EXTENSIONS
  3511 00000E42 0040                    init_ext_want:	dw _EXT_CODE_DEFAULT_SIZE
  3512 00000E44 0040                    init_extdata_want:	dw _EXT_DATA_DEFAULT_SIZE
  3513                                  %endif
  3514                                  %if _HISTORY_SEPARATE_FIXED && _HISTORY
  3515 00000E46 0020                    init_history_want:	dw _HISTORY_WANT_SIZE
  3516                                  %endif
  3517                                  
  3518                                  init_switch_p_low_pathsearch_high_guessextension:
  3519 00000E48 00                      init_switch_p_pathsearch:	db 0
  3520 00000E49 00                      init_switch_p_guessextension:	db 0
  3521 00000E4A 0000                    relocate_source:	dw 0
  3522 00000E4C 0000                    relocate_down:		dw 0
  3523 00000E4E 0000                    init_switch_r:		dw 0
  3524 00000E50 0000                    init_base_size:		dw 0
  3525 00000E52 0000                    init_target_size:	dw 0
  3526 00000E54 0100                    init_switch_t_umblink:	dw 1		; Add UMBs to memory chain
  3527 00000E56 FFFF                    			dw -1
  3528 00000E58 FFFF                    			dw -1
  3529 00000E5A 8200                    init_switch_t_strategy:	dw 82h		; Last fit, high then low
  3530 00000E5C 8200                    			dw 82h
  3531 00000E5E 8200                    			dw 82h
  3532                                  %if _BOOTLDR
  3533 00000E60 0000                    init_boot_new_memsizekib:	dw 0
  3534 00000E62 0000                    init_boot_old_memsizekib:	dw 0
  3535                                  
  3536 00000E64 0000                    init_boot_ebdasize:	dw 0
  3537 00000E66 0000                    init_boot_ebdasource:	dw 0
  3538 00000E68 0000                    init_boot_ebdadest:	dw 0
  3539 00000E6A 00                      init_boot_ebdaflag:	db 0
  3540 00000E6B 00                      init_preserveloader:	db 0
  3541                                  %endif
  3542 00000E6C FF                      init_switch_pw:		db 0FFh
  3543 00000E6D 00                      init_switch_t:		db 0
  3544 00000E6E 00                      init_switch_t_ignore:	db 0
  3545 00000E6F 00                      init_switch_t_break:	db 0
  3546 00000E70 00                      init_switch_t_variable:	db 0		; /TV: do not relocate environment
  3547                                  %if _APP_ENV_SIZE || _DEV_ENV_SIZE
  3548 00000E71 00                      app_env_allocation:	db 0		; set to 0FFh if app's environment
  3549                                  					;  *is* in its own separate memory block
  3550                                  					;  (like it used to be always)
  3551                                  %endif
  3552                                  
  3553                                  
  3554                                  imsg:
  3555                                  
  3556                                  %if _APPLICATION || _DEVICE
  3557                                  %assign ELD 0
  3558                                  %assign INTERC3 0
  3559                                  %assign PART1 0
  3560                                  %assign PART2 0
  3561                                  %assign PART3 1
  3562                                  
  3563                                  %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 6C4465627567583A20  <1> 	db _PROGNAME,": "
   443                              <1> %endif
   444 00000E95 5761726E696E672C20- <1> 	asciz "Warning, unknown filename extension specified!",13,10
   444 00000E9E 756E6B6E6F776E2066- <1>
   444 00000EA7 696C656E616D652065- <1>
   444 00000EB0 7874656E73696F6E20- <1>
   444 00000EB9 737065636966696564- <1>
   444 00000EC2 210D0A00            <1>
   445                              <1> .kktoolong:
   446                              <1> %ifn ELD
   447 00000EC6 6C4465627567583A20  <1> 	db _PROGNAME,": "
   448                              <1> %endif
   449 00000ECF 4572726F722C20746F- <1> 	asciz "Error, too long command line tail!",13,10
   449 00000ED8 6F206C6F6E6720636F- <1>
   449 00000EE1 6D6D616E64206C696E- <1>
   449 00000EEA 65207461696C210D0A- <1>
   449 00000EF3 00                  <1>
   450                              <1> .pathtoolong:
   451                              <1> %ifn ELD
   452 00000EF4 6C4465627567583A20  <1> 	db _PROGNAME,": "
   453                              <1> %endif
   454 00000EFD 4572726F722C20746F- <1> 	asciz "Error, too long %PATH% variable element!",13,10
   454 00000F06 6F206C6F6E67202550- <1>
   454 00000F0F 415448252076617269- <1>
   454 00000F18 61626C6520656C656D- <1>
   454 00000F21 656E74210D0A00      <1>
   455                              <1> %endif
  3564                                  %endif
  3565                                  
  3566 00000F28 4D415800                .max:	asciz "MAX"
  3567 00000F2C 4D494E00                .min:	asciz "MIN"
  3568                                  .default:
  3569 00000F30 44454641554C5400        	asciz "DEFAULT"
  3570                                  %if _CONFIG
  3571 00000F38 4C4445425547434F4E-     .varconfig:	db "LDEBUGCONFIG="
  3571 00000F41 4649473D           
  3572                                  .varconfig.length equ $ - .varconfig
  3573 00000F45 4C4445425547534352-     .varscripts:	db "LDEBUGSCRIPTS="
  3573 00000F4E 495054533D         
  3574                                  .varscripts.length equ $ - .varscripts
  3575                                  %endif
  3576                                  %if _DEVICE && _DEV_ENV_SIZE || _APPLICATION && _APP_ENV_SIZE
  3577                                  .app_env_too_large:
  3578                                  .dev_env_too_large:
  3579 00000F53 6C4465627567583A20-     	asciz _PROGNAME,": Warning, too long environment! Not copying.",13,10
  3579 00000F5C 5761726E696E672C20-
  3579 00000F65 746F6F206C6F6E6720-
  3579 00000F6E 656E7669726F6E6D65-
  3579 00000F77 6E7421204E6F742063-
  3579 00000F80 6F7079696E672E0D0A-
  3579 00000F89 00                 
  3580                                  %endif
  3581                                  %if _APPLICATION || _DEVICE
  3582                                  .early_mem_fail:
  3583 00000F8A 6C4465627567583A20-     	db _PROGNAME,": Failed to allocate memory!"
  3583 00000F93 4661696C656420746F-
  3583 00000F9C 20616C6C6F63617465-
  3583 00000FA5 206D656D6F727921   
  3584                                  %endif
  3585                                  .crlf:
  3586 00000FAD 0D0A00                  	asciz 13,10
  3587                                  .relocate_failure:
  3588 00000FB0 6C4465627567583A20-     	asciz _PROGNAME,": Relocation failed.",13,10
  3588 00000FB9 52656C6F636174696F-
  3588 00000FC2 6E206661696C65642E-
  3588 00000FCB 0D0A00             
  3589                                  .init_relocate_failure:
  3590 00000FCE 6C4465627567583A20-     	asciz _PROGNAME,": Second init relocation failed, out of memory.",13,10
  3590 00000FD7 5365636F6E6420696E-
  3590 00000FE0 69742072656C6F6361-
  3590 00000FE9 74696F6E206661696C-
  3590 00000FF2 65642C206F7574206F-
  3590 00000FFB 66206D656D6F72792E-
  3590 00001004 0D0A00             
  3591                                  .early_reloc_fail:
  3592 00001007 6C4465627567583A20-     	asciz _PROGNAME,": Failed to relocate, internal error!",13,10
  3592 00001010 4661696C656420746F-
  3592 00001019 2072656C6F63617465-
  3592 00001022 2C20696E7465726E61-
  3592 0000102B 6C206572726F72210D-
  3592 00001034 0A00               
  3593                                  %if _DEVICE
  3594                                  .dos_below_5:
  3595 00001036 204E6F74653A20444F-     	asciz " Note: DOS must be at least version 5.",13,10
  3595 0000103F 53206D757374206265-
  3595 00001048 206174206C65617374-
  3595 00001051 2076657273696F6E20-
  3595 0000105A 352E0D0A00         
  3596                                  .device_end_escaped:
  3597 0000105F 6C4465627567583A20-     	asciz _PROGNAME,": Error, got escaped command line end!",13,10
  3597 00001068 4572726F722C20676F-
  3597 00001071 742065736361706564-
  3597 0000107A 20636F6D6D616E6420-
  3597 00001083 6C696E6520656E6421-
  3597 0000108C 0D0A00             
  3598                                  .device_end_truncate:
  3599 0000108F 6C4465627567583A20-     	asciz _PROGNAME,": Error, truncating too long command line!",13,10
  3599 00001098 4572726F722C207472-
  3599 000010A1 756E636174696E6720-
  3599 000010AA 746F6F206C6F6E6720-
  3599 000010B3 636F6D6D616E64206C-
  3599 000010BC 696E65210D0A00     
  3600                                  %endif
  3601                                  %ifn _APPLICATION
  3602                                  .not_an_application:
  3603                                  	ascic _PROGNAME,": Error, no application mode included!",13,10
  3604                                  %endif
  3605                                  %if _APPLICATION || _DEVICE
  3606                                  %if _ALTVID
  3607                                  .noaltvid:
  3608 000010C3 6C4465627567583A20-     	asciz _PROGNAME,": Error, no alternative video adapter detected!",13,10
  3608 000010CC 4572726F722C206E6F-
  3608 000010D5 20616C7465726E6174-
  3608 000010DE 69766520766964656F-
  3608 000010E7 206164617074657220-
  3608 000010F0 646574656374656421-
  3608 000010F9 0D0A00             
  3609                                  %endif
  3610                                  	align 2, db 0
  3611                                  .help.defaultfilename:
  3612 000010FC 444542554758            	db _FILENAME
  3613                                  .help.defaultfilename.length equ $ - .help.defaultfilename
  3614                                  
  3615                                  	align 2, db 0
  3616                                  .help.1:
  3617 00001102 6C4465627567582028-     	fill_at_least 80, 0, asciz _PROGNAME,_VERSION,", debugger.",13,10
  3617 0000110B 323032362D30332D32-
  3617 00001114 38292C206465627567-
  3617 0000111D 6765722E0D0A0000-  
  3617 0000111D <rep 2Eh>          
  3618                                  
  3619                                  .help.1a:
  3620 00001152 0D0A                    	db 13,10
  3621 00001154 55736167653A20          	db "Usage: "
  3622 0000115B 00                      	asciz
  3623                                  .help.2:
  3624 0000115C 5B2E434F4D5D205B2F-     	db "[.COM] [/C=commands] [[drive:][path]progname.ext [parameters]]",13,10
  3624 00001165 433D636F6D6D616E64-
  3624 0000116E 735D205B5B64726976-
  3624 00001177 653A5D5B706174685D-
  3624 00001180 70726F676E616D652E-
  3624 00001189 657874205B70617261-
  3624 00001192 6D65746572735D5D0D-
  3624 0000119B 0A                 
  3625 0000119C 0D0A                    	db 13,10
  3626 0000119E 20202F433D636F6D6D-     	db "  /C=commands",9,9,	"semicolon-separated list of commands (quote spaces)",13,10
  3626 000011A7 616E6473090973656D-
  3626 000011B0 69636F6C6F6E2D7365-
  3626 000011B9 70617261746564206C-
  3626 000011C2 697374206F6620636F-
  3626 000011CB 6D6D616E6473202871-
  3626 000011D4 756F74652073706163-
  3626 000011DD 6573290D0A         
  3627                                  %if _CONFIG
  3628 000011E2 20202F494E09090964-     	db "  /IN",9,9,9,	"discard command line buffer, do not run config",13,10
  3628 000011EB 69736361726420636F-
  3628 000011F4 6D6D616E64206C696E-
  3628 000011FD 65206275666665722C-
  3628 00001206 20646F206E6F742072-
  3628 0000120F 756E20636F6E666967-
  3628 00001218 0D0A               
  3629                                  %endif
  3630                                  %if _AUXBUFFSIZE != _AUXBUFFMAXSIZE
  3631 0000121A 20202F413D4D415809-     	db "  /A=MAX",9,9,	"expand auxiliary buffer to maximum, #"
  3631 00001223 09657870616E642061-
  3631 0000122C 7578696C6961727920-
  3631 00001235 62756666657220746F-
  3631 0000123E 206D6178696D756D2C-
  3631 00001247 2023               
  3632 00001249 32345F353736            		_autodigits _AUXBUFFMAXSIZE, 1, 1
  3633 0000124F 2042797465730D0A        		db " Bytes",13,10
  3634 00001257 20202F413D4D494E09-     	db "  /A=MIN",9,9,	"restrict auxiliary buffer to minimum, #"
  3634 00001260 097265737472696374-
  3634 00001269 20617578696C696172-
  3634 00001272 792062756666657220-
  3634 0000127B 746F206D696E696D75-
  3634 00001284 6D2C2023           
  3635 00001288 385F323038              		_autodigits _AUXBUFFSIZE, 1, 1
  3636 0000128D 2042797465730D0A        		db " Bytes",13,10
  3637 00001295 20202F413D6E756D62-     	db "  /A=number",9,9,	"set auxiliary buffer size to hex number of bytes",13,10
  3637 0000129E 657209097365742061-
  3637 000012A7 7578696C6961727920-
  3637 000012B0 627566666572207369-
  3637 000012B9 7A6520746F20686578-
  3637 000012C2 206E756D626572206F-
  3637 000012CB 662062797465730D0A 
  3638 000012D4 20202F413D236E756D-     	db "  /A=#number",9,9,	"set auxiliary buffer size to decimal number of bytes",13,10
  3638 000012DD 626572090973657420-
  3638 000012E6 617578696C69617279-
  3638 000012EF 206275666665722073-
  3638 000012F8 697A6520746F206465-
  3638 00001301 63696D616C206E756D-
  3638 0000130A 626572206F66206279-
  3638 00001313 7465730D0A         
  3639 00001318 20202F41090909616C-     	db "  /A",9,9,9,	"alias for /A=MAX",13,10
  3639 00001321 69617320666F72202F-
  3639 0000132A 413D4D41580D0A     
  3640                                  %endif
  3641                                  %if _EXTENSIONS
  3642 00001331 20202F583D5B4D4158-     	db "  /X=[MAX|MIN|number]",9,	"change ELD code buffer size, 0 to #65_520 Bytes",13,10
  3642 0000133A 7C4D494E7C6E756D62-
  3642 00001343 65725D096368616E67-
  3642 0000134C 6520454C4420636F64-
  3642 00001355 652062756666657220-
  3642 0000135E 73697A652C20302074-
  3642 00001367 6F202336355F353230-
  3642 00001370 2042797465730D0A   
  3643 00001378 20202F593D5B4D4158-     	db "  /Y=[MAX|MIN|number]",9,	"change ELD data buffer size, 0 to #"
  3643 00001381 7C4D494E7C6E756D62-
  3643 0000138A 65725D096368616E67-
  3643 00001393 6520454C4420646174-
  3643 0000139C 612062756666657220-
  3643 000013A5 73697A652C20302074-
  3643 000013AE 6F2023             
  3644                                   %ifn _LINK
  3645                                  %assign NUMBER ext_data_max_size_equate_early
  3646                                  		_autodigits NUMBER, 5, 1
  3647                                  	db " Bytes",13,10
  3648                                   %else
  3649                                   wlcalc word_minusext_ext_data_area, equ $
  3650                                   wlcalc word_itoa_31_06_0Ah, equ $
  3651 000013B1 [F0FF]                  	dw  relocatedzero + 0FFF0h
  3652 000013B3 00<rep 4h>              	times 4 db 0
  3653 000013B7 2042797465730D0A        	db " Bytes",13,10
  3654                                   %endif
  3655                                  %endif
  3656                                  %if _HISTORY_SEPARATE_FIXED && _HISTORY
  3657 000013BF 20202F483D5B4D4158-     	db "  /H=[MAX|MIN|number]",9,	"change history buffer size, #260 to #65_520 Bytes",13,10
  3657 000013C8 7C4D494E7C6E756D62-
  3657 000013D1 65725D096368616E67-
  3657 000013DA 6520686973746F7279-
  3657 000013E3 206275666665722073-
  3657 000013EC 697A652C2023323630-
  3657 000013F5 20746F202336355F35-
  3657 000013FE 32302042797465730D-
  3657 00001407 0A                 
  3658                                  %endif
  3659 00001408 20202F420909097275-     	db "  /B",9,9,9,	"run a breakpoint within initialisation",13,10
  3659 00001411 6E206120627265616B-
  3659 0000141A 706F696E7420776974-
  3659 00001423 68696E20696E697469-
  3659 0000142C 616C69736174696F6E-
  3659 00001435 0D0A               
  3660 00001437 20202F505B2B7C2D5D-     	db "  /P[+|-]",9,9,	"append ext to initial filename and search path",13,10
  3660 00001440 0909617070656E6420-
  3660 00001449 65787420746F20696E-
  3660 00001452 697469616C2066696C-
  3660 0000145B 656E616D6520616E64-
  3660 00001464 207365617263682070-
  3660 0000146D 6174680D0A         
  3661 00001472 20202F465B2B7C2D5D-     	db "  /F[+|-]",9,9,	"always treat executable file as a flat binary",13,10
  3661 0000147B 0909616C7761797320-
  3661 00001484 747265617420657865-
  3661 0000148D 63757461626C652066-
  3661 00001496 696C65206173206120-
  3661 0000149F 666C61742062696E61-
  3661 000014A8 72790D0A           
  3662 000014AC 20202F455B2B7C2D5D-     	db "  /E[+|-]",9,9,	"for flat binaries set up Stack Segment != PSP",13,10
  3662 000014B5 0909666F7220666C61-
  3662 000014BE 742062696E61726965-
  3662 000014C7 732073657420757020-
  3662 000014D0 537461636B20536567-
  3662 000014D9 6D656E7420213D2050-
  3662 000014E2 53500D0A           
  3663                                  %if _VXCHG
  3664 000014E6 20202F565B2B7C2D5D-     	db "  /V[+|-]",9,9,	"enable/disable video screen swapping",13,10
  3664 000014EF 0909656E61626C652F-
  3664 000014F8 64697361626C652076-
  3664 00001501 6964656F2073637265-
  3664 0000150A 656E20737761707069-
  3664 00001513 6E670D0A           
  3665                                  %endif
  3666                                  %if _DEBUG && _DEBUG_COND
  3667                                  	db "  /D[+|-]",9,9,	"enable/disable debuggable mode",13,10
  3668                                  %endif
  3669                                  %if _ALTVID
  3670 00001517 20202F325B2B7C2D5D-     	db "  /2[+|-]",9,9,	"enable/disable use alternate video adapter for output",13,10
  3670 00001520 0909656E61626C652F-
  3670 00001529 64697361626C652075-
  3670 00001532 736520616C7465726E-
  3670 0000153B 61746520766964656F-
  3670 00001544 206164617074657220-
  3670 0000154D 666F72206F75747075-
  3670 00001556 740D0A             
  3671                                  %endif
  3672 00001559 202070726F676E616D-     	db "  progname.ext",9,9,"(executable) file to debug or examine",13,10
  3672 00001562 652E65787409092865-
  3672 0000156B 786563757461626C65-
  3672 00001574 292066696C6520746F-
  3672 0000157D 206465627567206F72-
  3672 00001586 206578616D696E650D-
  3672 0000158F 0A                 
  3673 00001590 2020706172616D6574-     	db "  parameters",9,9,	"parameters given to program",13,10
  3673 00001599 657273090970617261-
  3673 000015A2 6D6574657273206769-
  3673 000015AB 76656E20746F207072-
  3673 000015B4 6F6772616D0D0A     
  3674 000015BB 0D0A                    	db 13,10
  3675 000015BD 466F722061206C6973-     	db "For a list of debugging commands, run "
  3675 000015C6 74206F662064656275-
  3675 000015CF 6767696E6720636F6D-
  3675 000015D8 6D616E64732C207275-
  3675 000015E1 6E20               
  3676 000015E3 00                      	asciz
  3677                                  .help.3:
  3678 000015E4 20616E642074797065-     	db " and type ? at the prompt.",13,10
  3678 000015ED 203F20617420746865-
  3678 000015F6 2070726F6D70742E0D-
  3678 000015FF 0A                 
  3679 00001600 00                      	asciz
  3680                                  %endif
  3681                                  %if _ONLY386
  3682                                  .no386:	ascizline "Error: This ",_PROGNAME," build requires a 386 CPU or higher."
  3683                                  %elif _ONLYNON386
  3684                                  .386:	asciiline "Warning: This ",_PROGNAME," build is ignorant of 386 CPU specifics."
  3685                                  	ascizline 9," It does not allow access to the available 386-specific registers!"
  3686                                  %endif
  3687                                  
  3688                                  %if _BOOTLDR_DISCARD_HELP
  3689 00001601 00                      	align 2, db 0
  3690                                   %ifn _LINK || _LINK_COMPAT
  3691                                  .boothelp_replacement: helppage bootdisc
  3692                                   %else
  3693                                  .boothelp_replacement:
  3694                                  %define MESSAGE_INLINE
  3695                                  	%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 00001602 546869732068656C70- <1> 	db MESSAGE
    23 0000160B 207061676520697320- <1>
    23 00001614 6F6E6C792061766169- <1>
    23 0000161D 6C61626C6520696E20- <1>
    23 00001626 626F6F74206C6F6164- <1>
    23 0000162F 6564206D6F64652E0D- <1>
    23 00001638 0A                  <1>
    24                              <1> %else
    25                              <1> 	_strlen MESSAGE,0
    26                              <1> %endif
  3696                                  %undef MESSAGE_INLINE
  3697 00001639 00                      	asciz
  3698                                   %endif
  3699                                  	endarea .boothelp_replacement
  3700                                  %endif
  3701                                  
  3702                                  %if _APPLICATION || _DEVICE
  3703                                  %if _SYMBOLIC
  3704                                  .switch_s_garbage:
  3705                                  	asciz "Ignoring garbage at end of /S switch!",13,10
  3706                                  .switch_s_error:
  3707                                  	asciz "Switch /S invalid content",13,10
  3708                                  %endif
  3709                                  .invalidswitch:
  3710 0000163A 496E76616C69642073-     	db "Invalid switch - "
  3710 00001643 7769746368202D20   
  3711                                  .invalidswitch_a:
  3712 0000164B 780D0A00                	asciz "x",13,10
  3713                                  .switch_x_error:
  3714 0000164F 537769746368202F        	db "Switch /"
  3715                                  .switch_x_error_a:
  3716 00001657 7820696E76616C6964-     	asciz "x invalid content",13,10
  3716 00001660 20636F6E74656E740D-
  3716 00001669 0A00               
  3717                                  %endif
  3718                                  %if _CONFIG
  3719                                   %if _APPLICATION
  3720 0000166B 00                      	align 2, db 0
  3721                                  .default_cmdline.app:
  3722                                  	db _APPSCRIPTPREFIX
  3723 0000166C 406966206578697374-     	db "@if exists y ::CONFIG::",_APPSCRIPTNAME," :",_APPSCRIPTLABEL
  3723 00001675 732079203A3A434F4E-
  3723 0000167E 4649473A3A4C444542-
  3723 00001687 55472E534C44203A61-
  3723 00001690 70706C69636174696F-
  3723 00001699 6E73746172747570   
  3724 000016A1 207468656E2079203A-     	db " then y ::CONFIG::",_APPSCRIPTNAME," :",_APPSCRIPTLABEL
  3724 000016AA 3A434F4E4649473A3A-
  3724 000016B3 4C44454255472E534C-
  3724 000016BC 44203A6170706C6963-
  3724 000016C5 6174696F6E73746172-
  3724 000016CE 747570             
  3725 000016D1 0D                      	db 13
  3726                                  .default_cmdline.app.length equ $ - .default_cmdline.app
  3727 000016D2 00                      	db 0
  3728                                    %if .default_cmdline.app.length + 128 + 8 > _RC_BUFFER_SIZE
  3729                                     %error Too large default app cmdline
  3730                                    %endif
  3731                                   %endif
  3732                                   %if _DEVICE
  3733 000016D3 00                      	align 2, db 0
  3734                                  .default_cmdline.dev:
  3735                                  	db _DEVSCRIPTPREFIX
  3736 000016D4 406966206578697374-     	db "@if exists y ::CONFIG::",_DEVSCRIPTNAME," :",_DEVSCRIPTLABEL
  3736 000016DD 732079203A3A434F4E-
  3736 000016E6 4649473A3A4C444542-
  3736 000016EF 55472E534C44203A64-
  3736 000016F8 657669636573746172-
  3736 00001701 747570             
  3737 00001704 207468656E2079203A-     	db " then y ::CONFIG::",_DEVSCRIPTNAME," :",_DEVSCRIPTLABEL
  3737 0000170D 3A434F4E4649473A3A-
  3737 00001716 4C44454255472E534C-
  3737 0000171F 44203A646576696365-
  3737 00001728 73746172747570     
  3738 0000172F 0D                      	db 13
  3739                                  .default_cmdline.dev.length equ $ - .default_cmdline.dev
  3740 00001730 00                      	db 0
  3741                                    %if .default_cmdline.dev.length + 128 + 8 > _RC_BUFFER_SIZE
  3742                                     %error Too large default dev cmdline
  3743                                    %endif
  3744                                   %endif
  3745                                  %endif
  3746                                  %if _BOOTLDR
  3747 00001731 00                      	align 2, db 0
  3748                                  .default_cmdline.boot:
  3749                                  	db _BOOTSCRIPTPREFIX
  3750 00001732 406966206578697374-     	db "@if exists y ldp/",_BOOTSCRIPTNAME," :",_BOOTSCRIPTLABEL
  3750 0000173B 732079206C64702F4C-
  3750 00001744 44454255472E534C44-
  3750 0000174D 203A626F6F74737461-
  3750 00001756 72747570           
  3751 0000175A 207468656E2079206C-     	db " then y ldp/",_BOOTSCRIPTNAME," :",_BOOTSCRIPTLABEL
  3751 00001763 64702F4C4445425547-
  3751 0000176C 2E534C44203A626F6F-
  3751 00001775 7473746172747570   
  3752 0000177D 00                      	asciz
  3753                                  .default_cmdline.boot.length equ $ - .default_cmdline.boot
  3754                                    %if .default_cmdline.boot.length + 8 > _RC_BUFFER_SIZE
  3755                                     %error Too large default boot cmdline
  3756                                    %endif
  3757                                  
  3758                                  %if _EXECUTABLE
  3759                                  .ldpslash:
  3760 0000177E 6C64702F                	db "ldp/"
  3761                                  %endif
  3762                                  .rpl_detected:
  3763 00001782 52504C206465746563-     	asciz "RPL detected! Currently unsupported.",13,10
  3763 0000178B 746564212043757272-
  3763 00001794 656E746C7920756E73-
  3763 0000179D 7570706F727465642E-
  3763 000017A6 0D0A00             
  3764                                  .mismatch_detected:
  3765 000017A9 4D69736D6174636820-     	asciz "Mismatch in memory size detected! Internal error!",13,10
  3765 000017B2 696E206D656D6F7279-
  3765 000017BB 2073697A6520646574-
  3765 000017C4 65637465642120496E-
  3765 000017CD 7465726E616C206572-
  3765 000017D6 726F72210D0A00     
  3766                                  .boot_ebda_unexpected:
  3767 000017DD 454244412061742075-     	asciz "EBDA at unexpected position.",13,10
  3767 000017E6 6E6578706563746564-
  3767 000017EF 20706F736974696F6E-
  3767 000017F8 2E0D0A00           
  3768                                  .boot_error_out_of_memory:
  3769 000017FC 4F7574206F66206D65-     	asciz "Out of memory!",13,10
  3769 00001805 6D6F7279210D0A00   
  3770                                  .boot_error_internal:
  3771 0000180D 496E7465726E616C20-     	asciz "Internal error while relocating load image!",13,10
  3771 00001816 6572726F7220776869-
  3771 0000181F 6C652072656C6F6361-
  3771 00001828 74696E67206C6F6164-
  3771 00001831 20696D616765210D0A-
  3771 0000183A 00                 
  3772                                  .booterror:
  3773 0000183B 0D0A6C446562756758-     	asciz 13,10,_PROGNAME," boot error. Press any key to reboot.",13,10
  3773 00001844 20626F6F7420657272-
  3773 0000184D 6F722E205072657373-
  3773 00001856 20616E79206B657920-
  3773 0000185F 746F207265626F6F74-
  3773 00001868 2E0D0A00           
  3774                                  .bootwarn:
  3775 0000186C 0D0A6C446562756758-     	asciz 13,10,_PROGNAME," warning: "
  3775 00001875 207761726E696E673A-
  3775 0000187E 2000               
  3776                                  .boot_warn_no_loader:
  3777 00001880 457870656374656420-     	asciz "Expected loader not found!",13,10
  3777 00001889 6C6F61646572206E6F-
  3777 00001892 7420666F756E64210D-
  3777 0000189B 0A00               
  3778                                  .boot_warn_invalid_loader:
  3779 0000189D 457870656374656420-     	asciz "Expected loader is invalid!",13,10
  3779 000018A6 6C6F61646572206973-
  3779 000018AF 20696E76616C696421-
  3779 000018B8 0D0A00             
  3780                                  .boot_warn_lazy_loader:
  3781 000018BB 457870656374656420-     	asciz "Expected loader doesn't have a query function!",13,10
  3781 000018C4 6C6F6164657220646F-
  3781 000018CD 65736E277420686176-
  3781 000018D6 652061207175657279-
  3781 000018DF 2066756E6374696F6E-
  3781 000018E8 210D0A00           
  3782                                  .boot_warn_loader_no_reloc:
  3783 000018EC 4C6F6164657220646F-     	asciz "Loader doesn't provide a relocation function!",13,10
  3783 000018F5 65736E27742070726F-
  3783 000018FE 766964652061207265-
  3783 00001907 6C6F636174696F6E20-
  3783 00001910 66756E6374696F6E21-
  3783 00001919 0D0A00             
  3784                                  %endif
  3785                                  %if _DOSEMU
  3786 0000191C 30322F32352F3933        .dosemudate:	db "02/25/93"
  3787                                  %endif
  3788                                  %if _VDD && (_APPLICATION || _DEVICE)
  3789 00001924 44454258585644442E-     .vdd:		asciz "DEBXXVDD.DLL"
  3789 0000192D 444C4C00           
  3790 00001931 446973706174636800      .dispatch:	asciz "Dispatch"
  3791 0000193A 496E697400              .init:		asciz "Init"
  3792 0000193F 4D4F555345202020        .mouse:		db "MOUSE",32,32,32		; Looks like a device name
  3793 00001947 416E64792057617473-     .andy:		db "Andy Watson"		; I don't know him and why he's inside the NTVDM mouse driver
  3793 00001950 6F6E               
  3794                                  	endarea .andy
  3795 00001952 57696E646F7773204E-     .ntdos:		db "Windows NT MS-DOS subsystem Mouse Driver"	; Int33.004D mouse driver copyright string (not ASCIZ)
  3795 0000195B 54204D532D444F5320-
  3795 00001964 73756273797374656D-
  3795 0000196D 204D6F757365204472-
  3795 00001976 69766572           
  3796                                  	endarea .ntdos
  3797                                  
  3798                                  		; INP:	-
  3799                                  		; OUT:	CY if not NTVDM
  3800                                  		;	NC if NTVDM
  3801                                  		;	ds = es = cs
  3802                                  		; CHG:	ax, bx, cx, dx, di, si, bp, es, ds
  3803                                  isnt:
  3804 0000197A B80258                  		mov ax, 5802h			; Get UMB link state
  3805 0000197D CD21                    		int 21h
  3806 0000197F 30E4                    		xor ah, ah
  3807 00001981 50                      		push ax				; Save UMB link state
  3808 00001982 B80358                  		mov ax, 5803h			; Set UMB link state:
  3809 00001985 BB0100                  		mov bx, 1			;  Add UMBs to memory chain
  3810 00001988 CD21                    		int 21h
  3811 0000198A B452                    		mov ah, 52h
  3812 0000198C BBFFFF                  		mov bx, -1
  3813 0000198F CD21                    		int 21h				; Get list of lists
  3814 00001991 43                      		inc bx				; 0FFFFh ?
  3815 00001992 7503E98E00              		jz .notnt			; invalid -->
  3816 00001997 83FB02                  		cmp bx, 2			; would access word at 0FFFFh ?
  3817 0000199A 7503E98600              		je .notnt			; yes, invalid -->
  3818 0000199F 268B47FD                		mov ax, word [es:bx-3]		; First MCB
  3819 000019A3 0E                      		push cs
  3820 000019A4 07                      		pop es				; reset es
  3821                                  .loop:
  3822 000019A5 8ED8                    		mov ds, ax			; ds = MCB
  3823 000019A7 40                      		inc ax				; Now segment of memory block itself
  3824 000019A8 31D2                    		xor dx, dx
  3825 000019AA 31DB                    		xor bx, bx
  3826 000019AC 803F5A                  		cmp byte [bx], 'Z'		; End of MCB chain?
  3827 000019AF 7503                    		jne .notlast
  3828 000019B1 42                      		inc dx
  3829 000019B2 EB05                    		jmp short .notchain
  3830                                   .notlast:
  3831 000019B4 803F4D                  		cmp byte [bx], 'M'		; Valid MCB chain?
  3832 000019B7 756C                    		jne .error
  3833                                   .notchain:
  3834 000019B9 8B4F03                  		mov cx, [bx+3]			; MCB size in paragraphs
  3835                                  				; ax = current memory block
  3836                                  				; cx = size of current memory block in paragraphs
  3837                                  				; dx = flag whether this is the last MCB
  3838                                  				; ds = current MCB (before memory block)
  3839 000019BC 837F0108                		cmp word [bx+1], 8		; MCB owner DOS?
  3840 000019C0 755D                    		jne .notfound_1
  3841 000019C2 817F085344              		cmp word [bx+8], "SD"		; MCB name "SD"?
  3842 000019C7 7556                    		jne .notfound_1
  3843                                  .loopsub:
  3844 000019C9 8ED8                    		mov ds, ax			; SD sub-segment inside memory block
  3845 000019CB 40                      		inc ax
  3846 000019CC 49                      		dec cx
  3847 000019CD 8B6F03                  		mov bp, word [bx+3]		; Paragraphs 'til end of SD sub-segment
  3848                                  				; ax = current SD sub-segment
  3849                                  				; cx = paragraphs from SD sub-segment start (ax) to current memory block end
  3850                                  				; ds = current SD sub-MCB (like MCB, but for SD sub-segment)
  3851                                  				; bp = current SD sub-segment size in paragraphs
  3852 000019D0 39E9                    		cmp cx, bp
  3853 000019D2 724B                    		jb .notfound_1			; Goes beyond memory block, invalid -->
  3854 000019D4 803F51                  		cmp byte [bx], 'Q'		; NTVDM type 51h sub-segment ?
  3855 000019D7 753C                    		jne .notfound_2			; no -->
  3856 000019D9 BE0800                  		mov si, 8			; Offset of device name (if SD device driver sub-segment)
  3857 000019DC BF[3F19]                		mov di, imsg.mouse
  3858 000019DF 51                      		push cx
  3859 000019E0 89F1                    		mov cx, si			; length of name
  3860 000019E2 F3A6                    		repe cmpsb			; blank-padded device name "MOUSE" ?
  3861 000019E4 59                      		pop cx
  3862 000019E5 752E                    		jne .notfound_2			;  Device name doesn't match, try next SD sub-segment
  3863 000019E7 8CD8                    		mov ax, ds
  3864 000019E9 40                      		inc ax
  3865 000019EA 8ED8                    		mov ds, ax			; Segment of SD sub-segment
  3866                                  				; ds = current SD sub-segment
  3867 000019EC 89E8                    		mov ax, bp			; Leave paragraph value in bp
  3868 000019EE A900F0                  		test ax, 0F000h			; Would *16 cause an overflow?
  3869 000019F1 7520                    		jnz .notfound_3			;  Then too large -->
  3870 000019F3 51                      		push cx
  3871 000019F4 B104                    		mov cl, 4
  3872 000019F6 D3E0                    		shl ax, cl			; *16
  3873 000019F8 59                      		pop cx
  3874                                  				; ax = current SD sub-segment size in byte
  3875                                  .andy:
  3876 000019F9 BF[4719]                		mov di, imsg.andy
  3877 000019FC 51                      		push cx
  3878 000019FD B90B00                  		mov cx, imsg.andy_size
  3879 00001A00 E82E00                  		call findstring			; String "Andy Watson"?
  3880 00001A03 59                      		pop cx
  3881 00001A04 720D                    		jc .notfound_3
  3882                                  .ntdos:
  3883 00001A06 BF[5219]                		mov di, imsg.ntdos
  3884 00001A09 51                      		push cx
  3885 00001A0A B92800                  		mov cx, imsg.ntdos_size
  3886 00001A0D E82100                  		call findstring			; String "Windows NT MS-DOS subsystem Mouse Driver"?
  3887 00001A10 59                      		pop cx
  3888 00001A11 7313                    		jnc .found			; (NC)
  3889                                  .notfound_3:
  3890 00001A13 8CD8                    		mov ax, ds
  3891                                  .notfound_2:
  3892 00001A15 39E9                    		cmp cx, bp
  3893 00001A17 7406                    		je .notfound_1			; End of SD memory block, get next MCB
  3894 00001A19 01E8                    		add ax, bp			; Address next SD sub-MCB
  3895 00001A1B 29E9                    		sub cx, bp
  3896 00001A1D EBAA                    		jmp short .loopsub		; Try next SD sub-segment
  3897                                  .notfound_1:
  3898 00001A1F 01C8                    		add ax, cx			; Address next MCB
  3899 00001A21 85D2                    		test dx, dx			; Non-zero if 'Z' MCB
  3900 00001A23 7480                    		jz .loop			; If not at end of MCB chain, try next
  3901                                  		; jmp short .notnt		;  Otherwise, not found
  3902                                   .error:
  3903                                   .notnt:
  3904 00001A25 F9                      		stc
  3905                                  .found:
  3906 00001A26 0E                      		push cs
  3907 00001A27 1F                      		pop ds				; restore ds
  3908                                  
  3909 00001A28 5B                      		pop bx				; saved UMB link state
  3910 00001A29 B80358                  		mov ax, 5803h
  3911 00001A2C 9C                      		pushf
  3912 00001A2D CD21                    		int 21h				; Set UMB link state
  3913 00001A2F 9D                      		popf
  3914 00001A30 C3                      		retn
  3915                                  
  3916                                  findstring:
  3917 00001A31 31F6                    		xor si, si
  3918                                  .loop:
  3919 00001A33 56                      		push si
  3920 00001A34 01CE                    		add si, cx
  3921 00001A36 7203                    		jc .notfound_c
  3922 00001A38 4E                      		dec si				; The largest offset we need for this compare
  3923 00001A39 39F0                    		cmp ax, si
  3924                                   .notfound_c:
  3925 00001A3B 5E                      		pop si
  3926 00001A3C 720D                    		jb .return			; Not found if at top of memory block -->
  3927 00001A3E 57                      		push di
  3928 00001A3F 56                      		push si
  3929 00001A40 51                      		push cx
  3930 00001A41 F3A6                    		repe cmpsb			; String somewhere inside program?
  3931 00001A43 59                      		pop cx
  3932 00001A44 5E                      		pop si
  3933 00001A45 5F                      		pop di
  3934 00001A46 7403                    		je .return			;  Yes, proceed --> (if ZR, NC)
  3935 00001A48 46                      		inc si				; Increase pointer by one
  3936 00001A49 EBE8                    		jmp short .loop			;  Try next address
  3937                                  .return:
  3938 00001A4B C3                      		retn
  3939                                  %endif
  3940                                  
  3941                                  
  3942                                  		; Move paragraphs
  3943                                  		;
  3944                                  		; INP:	ax:0-> source
  3945                                  		;	dx:0-> destination
  3946                                  		;	cx = number of paragraphs
  3947                                  		; CHG:	-
  3948                                  		; Note:	Doesn't work correctly on HMA; doesn't always wrap to LMA either.
  3949                                  		;	Do not provide a wrapped/HMA source or destination!
  3950                                  init_movp:
  3951 00001A4C 51                      	push cx
  3952 00001A4D 1E                      	push ds
  3953 00001A4E 56                      	push si
  3954 00001A4F 06                      	push es
  3955 00001A50 57                      	push di
  3956                                  
  3957 00001A51 39D0                    	cmp ax, dx		; source above destination ?
  3958 00001A53 770A                    	ja .up			; yes, move up (forwards) -->
  3959 00001A55 747B                    	je .return		; same, no need to move -->
  3960 00001A57 50                      	push ax
  3961 00001A58 01C8                    	add ax, cx		; (expected not to carry)
  3962 00001A5A 39D0                    	cmp ax, dx		; end of source is above destination ?
  3963 00001A5C 58                      	pop ax
  3964 00001A5D 7730                    	ja .down		; yes, move from top down -->
  3965                                  	; Here, the end of source is below-or-equal the destination,
  3966                                  	;  so they do not overlap. In this case we prefer moving up.
  3967                                  
  3968                                  .up:
  3969 00001A5F 50                      	push ax
  3970 00001A60 52                      	push dx
  3971                                  .uploop:
  3972 00001A61 8ED8                    	mov ds, ax
  3973 00001A63 8EC2                    	mov es, dx
  3974 00001A65 31FF                    	xor di, di
  3975 00001A67 31F6                    	xor si, si		; -> start of segment
  3976 00001A69 81E90010                	sub cx, 1000h		; 64 KiB left ?
  3977 00001A6D 7610                    	jbe .uplast		; no -->
  3978 00001A6F 51                      	push cx
  3979 00001A70 B90080                  	mov cx, 10000h /2
  3980 00001A73 F3A5                    	rep movsw		; move 64 KiB
  3981 00001A75 59                      	pop cx
  3982 00001A76 050010                  	add ax, 1000h
  3983 00001A79 81C20010                	add dx, 1000h		; -> next segment
  3984 00001A7D EBE2                    	jmp short .uploop	; proceed for more -->
  3985                                  .uplast:
  3986 00001A7F 81C10010                	add cx, 1000h		; restore counter
  3987 00001A83 D1E1                    	shl cx, 1
  3988 00001A85 D1E1                    	shl cx, 1
  3989 00001A87 D1E1                    	shl cx, 1		; *8, paragraphs to words
  3990 00001A89 F3A5                    	rep movsw		; move last part
  3991 00001A8B 5A                      	pop dx
  3992 00001A8C 58                      	pop ax
  3993 00001A8D EB43                    	jmp short .return
  3994                                  
  3995                                  .down:
  3996 00001A8F FD                      	std			; _AMD_ERRATUM_109_WORKAROUND as below
  3997                                  .dnloop:
  3998 00001A90 81E90010                	sub cx, 1000h		; 64 KiB left ?
  3999 00001A94 761A                    	jbe .dnlast		; no -->
  4000 00001A96 50                      	push ax
  4001 00001A97 52                      	push dx
  4002 00001A98 01C8                    	add ax, cx
  4003 00001A9A 01CA                    	add dx, cx
  4004 00001A9C 8ED8                    	mov ds, ax		; -> 64 KiB not yet moved
  4005 00001A9E 8EC2                    	mov es, dx
  4006 00001AA0 5A                      	pop dx
  4007 00001AA1 58                      	pop ax
  4008 00001AA2 BFFEFF                  	mov di, -2
  4009 00001AA5 89FE                    	mov si, di		; moved from last word down
  4010 00001AA7 51                      	push cx
  4011 00001AA8 B90080                  	mov cx, 10000h /2
  4012 00001AAB F3A5                    	rep movsw		; move 64 KiB
  4013 00001AAD 59                      	pop cx
  4014 00001AAE EBE0                    	jmp short .dnloop	; proceed for more -->
  4015                                  .dnlast:
  4016 00001AB0 81C10010                	add cx, 1000h		; restore counter
  4017 00001AB4 D1E1                    	shl cx, 1
  4018 00001AB6 D1E1                    	shl cx, 1
  4019 00001AB8 D1E1                    	shl cx, 1		; *8, paragraphs to words
  4020 00001ABA 89CF                    	mov di, cx
  4021 00001ABC 4F                      	dec di
  4022 00001ABD D1E7                    	shl di, 1		; words to offset, -> last word
  4023 00001ABF 89FE                    	mov si, di
  4024 00001AC1 8ED8                    	mov ds, ax
  4025 00001AC3 8EC2                    	mov es, dx		; first segment correct
  4026                                  
  4027                                  
  4028                                  	numdef AMD_ERRATUM_109_WORKAROUND, 1
  4029                                  %if 0
  4030                                  
  4031                                  Jack R. Ellis pointed out this erratum:
  4032                                  
  4033                                  Quoting from https://www.amd.com/system/files/TechDocs/25759.pdf page 69:
  4034                                  
  4035                                  109   Certain Reverse REP MOVS May Produce Unpredictable Behavior
  4036                                  
  4037                                  Description
  4038                                  
  4039                                  In certain situations a REP MOVS instruction may lead to
  4040                                  incorrect results. An incorrect address size, data size
  4041                                  or source operand segment may be used or a succeeding
  4042                                  instruction may be skipped. This may occur under the
  4043                                  following conditions:
  4044                                  
  4045                                  * EFLAGS.DF=1 (the string is being moved in the reverse direction).
  4046                                  
  4047                                  * The number of items being moved (RCX) is between 1 and 20.
  4048                                  
  4049                                  * The REP MOVS instruction is preceded by some microcoded instruction
  4050                                    that has not completely retired by the time the REP MOVS begins
  4051                                    execution. The set of such instructions includes BOUND, CLI, LDS,
  4052                                    LES, LFS, LGS, LSS, IDIV, and most microcoded x87 instructions.
  4053                                  
  4054                                  Potential Effect on System
  4055                                  
  4056                                  Incorrect results may be produced or the system may hang.
  4057                                  
  4058                                  Suggested Workaround
  4059                                  
  4060                                  Contact your AMD representative for information on a BIOS update.
  4061                                  
  4062                                  %endif
  4063                                  
  4064                                  %if _AMD_ERRATUM_109_WORKAROUND
  4065 00001AC5 E308                    	jcxz @FF
  4066 00001AC7 83F914                  	cmp cx, 20
  4067 00001ACA 7703                    	ja @FF
  4068                                  @@:
  4069 00001ACC A5                      	movsw
  4070 00001ACD E2FD                    	loop @B
  4071                                  @@:
  4072                                  %endif
  4073 00001ACF F3A5                    	rep movsw		; move first part
  4074 00001AD1 FC                      	cld
  4075                                  .return:
  4076 00001AD2 5F                      	pop di
  4077 00001AD3 07                      	pop es
  4078 00001AD4 5E                      	pop si
  4079 00001AD5 1F                      	pop ds
  4080 00001AD6 59                      	pop cx
  4081 00001AD7 C3                      	retn
  4082                                  
  4083                                  
  4084                                  %if _BOOTLDR
  4085                                  		; only called for boot-loaded mode
  4086                                  init_getc_bootldr:
  4087 00001AD8 31C0                    	xor ax, ax
  4088 00001ADA CD16                    	int 16h
  4089 00001ADC C3                      	retn
  4090                                  %endif
  4091                                  
  4092                                  init_putsz_cs:
  4093 00001ADD 50                      	push ax
  4094 00001ADE 53                      	push bx
  4095 00001ADF 51                      	push cx
  4096 00001AE0 52                      	push dx
  4097 00001AE1 1E                      	push ds
  4098 00001AE2 06                      	push es
  4099 00001AE3 57                      	push di
  4100 00001AE4 0E                      	 push cs
  4101 00001AE5 07                      	 pop es
  4102 00001AE6 0E                      	 push cs
  4103 00001AE7 1F                      	 pop ds
  4104 00001AE8 89D7                    	mov di, dx			; es:di-> string
  4105 00001AEA 30C0                    	xor al, al
  4106 00001AEC B9FFFF                  	mov cx, -1
  4107 00001AEF F2AE                    	repne scasb			; search zero
  4108 00001AF1 F7D1                    	not cx
  4109 00001AF3 49                      	dec cx				; cx = length of message
  4110 00001AF4 5F                      	pop di
  4111 00001AF5 E82900                  	call init_puts_ds
  4112 00001AF8 07                      	pop es
  4113 00001AF9 1F                      	pop ds
  4114 00001AFA 5A                      	pop dx
  4115 00001AFB 59                      	pop cx
  4116 00001AFC 5B                      	pop bx
  4117 00001AFD 58                      	pop ax
  4118 00001AFE C3                      	retn
  4119                                  
  4120                                  %if _BOOTLDR
  4121                                  init_putsz_cs_bootldr:
  4122 00001AFF 50                      	push ax
  4123 00001B00 53                      	push bx
  4124 00001B01 51                      	push cx
  4125 00001B02 52                      	push dx
  4126 00001B03 1E                      	push ds
  4127 00001B04 06                      	push es
  4128 00001B05 57                      	push di
  4129 00001B06 0E                      	 push cs
  4130 00001B07 07                      	 pop es
  4131 00001B08 0E                      	 push cs
  4132 00001B09 1F                      	 pop ds
  4133 00001B0A 89D7                    	mov di, dx			; es:di-> string
  4134 00001B0C 30C0                    	xor al, al
  4135 00001B0E B9FFFF                  	mov cx, -1
  4136 00001B11 F2AE                    	repne scasb			; search zero
  4137 00001B13 F7D1                    	not cx
  4138 00001B15 49                      	dec cx				; cx = length of message
  4139 00001B16 5F                      	pop di
  4140 00001B17 E80F00                  	call init_puts_ds_bootldr
  4141 00001B1A 07                      	pop es
  4142 00001B1B 1F                      	pop ds
  4143 00001B1C 5A                      	pop dx
  4144 00001B1D 59                      	pop cx
  4145 00001B1E 5B                      	pop bx
  4146 00001B1F 58                      	pop ax
  4147 00001B20 C3                      	retn
  4148                                  %endif
  4149                                  
  4150                                  init_puts_ds:
  4151                                  %if _BOOTLDR
  4152                                   %if _APPLICATION || _DEVICE
  4153 00001B21 36F606[0100]40          	testopt [ss:internalflags], nodosloaded
  4154 00001B27 7413                    	jz @F
  4155                                   %endif
  4156                                  
  4157                                  init_puts_ds_bootldr:
  4158 00001B29 56                      	push si
  4159 00001B2A 55                      	push bp
  4160 00001B2B 89D6                    	mov si, dx
  4161 00001B2D E30A                    	jcxz .return
  4162                                  .loop:
  4163 00001B2F AC                      	lodsb
  4164 00001B30 BB0700                  	mov bx, 0007
  4165 00001B33 B40E                    	mov ah, 0Eh
  4166 00001B35 CD10                    	int 10h
  4167 00001B37 E2F6                    	loop .loop
  4168                                  .return:
  4169 00001B39 5D                      	pop bp
  4170 00001B3A 5E                      	pop si
  4171 00001B3B C3                      	retn
  4172                                  
  4173                                  @@:
  4174                                  %endif
  4175                                  %if _APPLICATION || _DEVICE
  4176 00001B3C BB0100                  	mov bx, 1			; standard output
  4177 00001B3F B440                    	mov ah, 40h			; write to file
  4178 00001B41 E302                    	jcxz @F
  4179 00001B43 CD21                    	int 21h
  4180                                  @@:
  4181 00001B45 C3                      	retn
  4182                                  %endif
  4183                                  
  4184                                  
  4185                                  %if _BOOTLDR
  4186                                  		; ds = ss = debugger data segment
  4187                                  		; (ds - 1) = image ident prefix paragraph
  4188                                  boot_old_initcode:
  4189 00001B46 FC                      	cld
  4190                                  
  4191                                  d4	call init_d4message
  4192                                  d4	asciz "In boot loader; press any key",13,10
  4193                                  d4	call init_d4pauseforkey
  4194                                  
  4195                                  %if !_LOADER
  4196 00001B47 C706[0000]8000          	mov word [execblk.cmdline], 80h
  4197 00001B4D C60681000D              	mov byte [81h], 0Dh
  4198 00001B52 C606[0000]01            	mov byte [fileext], EXT_OTHER	; empty file name and command line as per N
  4199                                  %endif
  4200                                  %endif	; _BOOTLDR
  4201                                  
  4202                                  old_initcode:
  4203 00001B57 FC                      	cld
  4204                                  	d0bp
  4205 00001B58 8CD8                    	mov ax, ds
  4206                                  %if !_LOADER
  4207 00001B5A A3[0200]                	mov word [execblk.cmdline + 2], ax
  4208 00001B5D A3[0200]                	mov word [execblk.fcb1 + 2], ax
  4209 00001B60 A3[0200]                	mov word [execblk.fcb2 + 2], ax	; set up parameter block for exec command
  4210                                  %endif
  4211 00001B63 A3[0000]                	mov word [pspdbg], ax
  4212                                  
  4213                                  %if _IMMASM  && !_IMMASM_AUXBUFF
  4214                                   %ifn _LINK
  4215                                  	add ax, (immasm_buffer + DATASECTIONFIXUP) >> 4
  4216                                   %else
  4217 00001B66 05[0000]                	add ax, strict word immasm_buffer
  4218                                   wlcalc word_shr_4, equ $ - 2
  4219                                   %endif
  4220 00001B69 A3[0000]                	mov word [immseg], ax
  4221                                  %endif
  4222                                  
  4223 00001B6C 1E                      	push ds
  4224 00001B6D B84000                  	mov ax, 40h
  4225 00001B70 8ED8                    	mov ds, ax
  4226 00001B72 A18200                  	mov ax, word [82h]	; end of circular keypress buffer
  4227 00001B75 8B168000                	mov dx, word [80h]	; start of circular buffer
  4228 00001B79 85C0                    	test ax, ax
  4229 00001B7B 7431                    	jz .forcekeybuffer
  4230 00001B7D 85D2                    	test dx, dx
  4231 00001B7F 742D                    	jz .forcekeybuffer
  4232 00001B81 89C3                    	mov bx, ax
  4233 00001B83 29D3                    	sub bx, dx		; cmp end, start
  4234 00001B85 7627                    	jbe .forcekeybuffer	; below or equal is invalid -->
  4235 00001B87 F6C301                  	test bl, 1		; even amount of bytes ?
  4236 00001B8A 7522                    	jnz .forcekeybuffer	; no, invalid -->
  4237 00001B8C 8B1E1A00                	mov bx, word [1Ah]	; current head of circular buffer
  4238 00001B90 39C3                    	cmp bx, ax
  4239 00001B92 731A                    	jae .forcekeybuffer
  4240 00001B94 29D3                    	sub bx, dx
  4241 00001B96 7216                    	jb .forcekeybuffer
  4242 00001B98 F6C301                  	test bl, 1
  4243 00001B9B 7511                    	jnz .forcekeybuffer	; invalid -->
  4244 00001B9D 8B1E1C00                	mov bx, word [1Ch]	; current tail of circular buffer
  4245 00001BA1 39C3                    	cmp bx, ax
  4246 00001BA3 7309                    	jae .forcekeybuffer
  4247 00001BA5 29D3                    	sub bx, dx
  4248 00001BA7 7205                    	jb .forcekeybuffer
  4249 00001BA9 F6C301                  	test bl, 1
  4250 00001BAC 740E                    	jz @F			; valid -->
  4251                                  .forcekeybuffer:
  4252 00001BAE 1F                      	pop ds
  4253 00001BAF C706[0000]3E00          	mov word [io_end_buffer], 3Eh
  4254 00001BB5 C706[0000]1E00          	mov word [io_start_buffer], 1Eh
  4255 00001BBB A8                      	db __TEST_IMM8		; (skip pop)
  4256                                  @@:
  4257 00001BBC 1F                      	pop ds
  4258                                  
  4259                                  %if _BOOTLDR
  4260                                   %if _APPLICATION || _DEVICE
  4261 00001BBD F606[0100]40            	testopt [internalflags], nodosloaded
  4262 00001BC2 7403                    	jz .checkio
  4263                                   %endif
  4264                                  d4	call init_d4message
  4265                                  d4	asciz "Common initialisation, determining processor type now",13,10
  4266 00001BC4 E9BB00                  	jmp init_determineprocessor
  4267                                  .checkio:
  4268                                  %endif
  4269                                  
  4270                                  %if _APPLICATION || _DEVICE
  4271                                  		; Check for console input vs. input from a file or other device.
  4272                                  		; This has to be done early because MS-DOS seems to switch CON
  4273                                  		; to cooked I/O mode only then.
  4274 00001BC7 B80044                  	mov ax, 4400h		; IOCTL get device information
  4275 00001BCA 31DB                    	xor bx, bx		; StdIn
  4276 00001BCC B283                    	mov dl, 83h		; default if 21.4400 fails
  4277 00001BCE CD21                    	int 21h
  4278 00001BD0 F6C280                  	test dl, 80h
  4279 00001BD3 7414                    	jz .inputfile
  4280 00001BD5 8026[0000]DF            	clropt [internalflags], inputfile
  4281 00001BDA F6C203                  	test dl, 3
  4282 00001BDD 740A                    	jz .inputdevice		; if not the console input
  4283 00001BDF 8026[0000]EF            	clropt [internalflags], notstdinput
  4284 00001BE4 C606[0000]00            	mov byte [notatty], 0	; it _is_ a tty
  4285                                  .inputdevice:
  4286                                  .inputfile:
  4287 00001BE9 B80044                  	mov ax, 4400h		; IOCTL get device information
  4288 00001BEC 43                      	inc bx			; StdOut
  4289 00001BED B283                    	mov dl, 83h		; default if 21.4400 fails
  4290 00001BEF CD21                    	int 21h
  4291 00001BF1 F6C280                  	test dl, 80h
  4292 00001BF4 740F                    	jz .outputfile
  4293 00001BF6 8026[0000]7F            	clropt [internalflags], outputfile
  4294 00001BFB F6C203                  	test dl, 3
  4295 00001BFE 7405                    	jz .outputdevice	; if not the console output
  4296 00001C00 8026[0000]BF            	clropt [internalflags], notstdoutput
  4297                                  .outputdevice:
  4298                                  .outputfile:
  4299                                  
  4300                                  		; Check DOS version
  4301                                  %if _VDD
  4302 00001C05 1E                      	push ds
  4303 00001C06 0E                      	 push cs
  4304 00001C07 1F                      	 pop ds
  4305 00001C08 0E                      	 push cs
  4306 00001C09 07                      	 pop es
  4307 00001C0A E86DFD                  	call isnt		; NTVDM ?
  4308 00001C0D 1F                      	pop ds
  4309 00001C0E 7205                    	jc .isnotnt		; no -->
  4310 00001C10 800E[0200]02            	setopt [internalflags], runningnt
  4311                                  .isnotnt:
  4312                                  %endif
  4313                                  
  4314 00001C15 B80030                  	mov ax, 3000h		; check DOS version
  4315 00001C18 CD21                    	int 21h
  4316 00001C1A 86C4                    	xchg al, ah
  4317 00001C1C 3D1F03                  	cmp ax, ver(3,31)	; MS-DOS version > 3.30 ?
  4318 00001C1F 7205                    	jb .notoldpacket	; no -->
  4319 00001C21 800E[0000]01            	setopt [internalflags], oldpacket	; assume Int25/Int26 packet method available
  4320                                  .notoldpacket:
  4321 00001C26 50                      	push ax
  4322 00001C27 31DB                    	xor bx, bx		; preset to invalid value
  4323 00001C29 B80633                  	mov ax, 3306h
  4324 00001C2C CD21                    	int 21h
  4325 00001C2E 84C0                    	test al, al		; invalid, DOS 1.x error -->
  4326 00001C30 7402                    	jz .213306invalid
  4327 00001C32 3CFF                    	cmp al, -1		; invalid
  4328                                  .213306invalid:
  4329 00001C34 58                      	pop ax
  4330 00001C35 7407                    	je .useoldver
  4331 00001C37 85DB                    	test bx, bx		; 0.0 ?
  4332 00001C39 7403                    	jz .useoldver		; assume invalid -->
  4333 00001C3B 93                      	xchg ax, bx		; get version to ax
  4334 00001C3C 86C4                    	xchg al, ah		; strange Microsoft version format
  4335                                  .useoldver:
  4336 00001C3E 3D0107                  	cmp ax, ver(7,01)	; MS-DOS version > 7.00 ?
  4337 00001C41 7205                    	jb .notnewpacket	; no -->
  4338 00001C43 800E[0000]03            	setopt [internalflags], newpacket| oldpacket	; assume both packet methods available
  4339                                  .notnewpacket:
  4340                                  %if _VDD
  4341 00001C48 F606[0200]02            	testopt [internalflags], runningnt
  4342 00001C4D 741F                    	jz .novdd
  4343 00001C4F 1E                      	push ds
  4344 00001C50 0E                      	 push cs
  4345 00001C51 1F                      	 pop ds
  4346 00001C52 0E                      	 push cs
  4347 00001C53 07                      	 pop es
  4348 00001C54 BE[2419]                	mov si, imsg.vdd	; ds:si-> ASCIZ VDD filename
  4349 00001C57 BB[3119]                	mov bx, imsg.dispatch	; ds:bx-> ASCIZ dispatching entry
  4350 00001C5A BF[3A19]                	mov di, imsg.init	; es:di-> ASCIZ init entry
  4351 00001C5D F8                      	clc			; !
  4352 00001C5E C4C4580090              	RegisterModule		; register VDD
  4353 00001C63 1F                      	pop ds
  4354 00001C64 7208                    	jc .novdd		; error ? -->
  4355 00001C66 A3[0000]                	mov word [hVdd], ax
  4356 00001C69 800E[0000]05            	setopt [internalflags], ntpacket| oldpacket	; assume old packet method also available
  4357                                  .novdd:
  4358                                  %endif
  4359                                  %endif
  4360                                  
  4361                                  
  4362                                  %if _CONFIG
  4363                                  do_truename_config:
  4364 00001C6E BA[0000]                	mov dx, configpath
  4365 00001C71 E86317                  	call do_truename
  4366 00001C74 893E[0000]              	mov word [configpath.dir_end], di
  4367                                  do_truename_scripts:
  4368 00001C78 BA[0000]                	mov dx, scriptspath
  4369 00001C7B E85917                  	call do_truename
  4370 00001C7E 893E[0000]              	mov word [scriptspath.dir_end], di
  4371                                  %endif
  4372                                  
  4373                                  
  4374                                  init_determineprocessor:
  4375                                  d4	call init_d4message
  4376                                  d4	asciz "Determining processor type",13,10
  4377                                  
  4378 00001C82 B92101                  	mov cx, 0121h
  4379 00001C85 D2E5                    	shl ch, cl
  4380 00001C87 7514                    	jnz .found_186_plus	; normal 186 masks shift count with 31 -->
  4381                                  
  4382                                  		; To make it easier to trace past the long-form pop cx
  4383                                  		;  instruction, we now run it in a subfunction.
  4384 00001C89 E80500                  	call .detect_nec
  4385 00001C8C E30F                    	jcxz .found_186_plus	; if it was a nop -->
  4386 00001C8E E9F700                  	jmp .cpudone		; is an actual 8088/8086 -->
  4387                                  
  4388                                  
  4389                                  		; INP:	-
  4390                                  		; OUR:	cx = 0 if NEC V20 or NEC V30
  4391                                  		;	cx = 1 else
  4392                                  		; CHG:	ax, cx
  4393                                  .detect_nec:
  4394                                  		; The NEC V20/V30 processors do support the 186 extensions
  4395                                  		;  to the instruction set but do not mask the shift count.
  4396                                  		;  Therefore, specifically detect them here. Based on the
  4397                                  		;  text in http://www.textfiles.com/hamradio/v20_bug.txt
  4398 00001C91 89E0                    	mov ax, sp
  4399 00001C93 B90100                  	mov cx, 1		; = 1 if on actual 8088/8086
  4400 00001C96 51                      	push cx
  4401 00001C97 49                      	dec cx			; = 0 if on NEC V20/V30
  4402                                  
  4403                                  		; NB: Do *NOT* trace this instruction with Trace Flag = 1 and
  4404                                  		;  do *NOT* write a breakpoint at the mov sp instruction,
  4405                                  		;  that is the very next instruction after the pop cx.
  4406                                  		; Doing either leads to locking up the HP 95LX, requiring to
  4407                                  		;  reset the system using Ctrl-Shift-On (which zeroes the
  4408                                  		;  system date and time).
  4409 00001C98 8FC1                    	db 8Fh, 0C1h		; pop r/m16 with cx as operand
  4410                                  				;  (reportedly a nop on the NECs)
  4411 00001C9A 89C4                    	mov sp, ax		; reset stack to known state
  4412 00001C9C C3                      	retn
  4413                                  
  4414                                  .found_186_plus:
  4415                                  d4	call init_d4message
  4416                                  d4	asciz "Found 186+ processor",13,10
  4417 00001C9D FE06[0000]              	inc byte [ machine ]	; 1
  4418 00001CA1 54                      	push sp
  4419 00001CA2 58                      	pop ax
  4420 00001CA3 39E0                    	cmp ax, sp
  4421 00001CA5 7403E9DE00              	jne .cpudone		; 80186 pushes the adjusted value of sp -->
  4422                                  
  4423                                  d4	call init_d4message
  4424                                  d4	asciz "Found 286+ processor",13,10
  4425                                  		; Determine the processor type.  This is adapted from code in the
  4426                                  		; Pentium<tm> Family User's Manual, Volume 3:  Architecture and
  4427                                  		; Programming Manual, Intel Corp., 1994, Chapter 5.  That code contains
  4428                                  		; the following comment:
  4429                                  		;
  4430                                  		; This program has been developed by Intel Corporation.
  4431                                  		; Software developers have Intel's permission to incorporate
  4432                                  		; this source code into your software royalty free.
  4433                                  		;
  4434                                  		; Intel 286 CPU check.
  4435                                  		; Bits 12-15 of the flags register are always clear on the
  4436                                  		; 286 processor in real-address mode.
  4437                                  		; Bits 12-15 of the FLAGS register are always set on the
  4438                                  		; 8086 and 186 processor.
  4439 00001CAA FE06[0000]              	inc byte [ machine ]	; 2
  4440 00001CAE 9C                      	 pushf			; save IF
  4441 00001CAF 9C                      	pushf			; get original flags into ax
  4442 00001CB0 58                      	pop ax
  4443 00001CB1 0D00F0                  	or ax, 0F000h		; try to set bits 12-15
  4444 00001CB4 25FFFD                  	and ax, ~0200h		; clear IF
  4445 00001CB7 50                      	push ax			; save new flags value on stack
  4446 00001CB8 9D                      	popf			; replace current flags value; DI
  4447 00001CB9 9C                      	pushf			; get new flags
  4448 00001CBA 58                      	pop ax			; store new flags in ax
  4449 00001CBB 9D                      	 popf			; restore IF (in 86 Mode)
  4450 00001CBC A900F0                  	test ax, 0F000h		; if bits 12-15 clear, CPU = 80286
  4451 00001CBF 7503E9C400              	jz .cpudone		; if 80286 -->
  4452                                  
  4453                                  d4	call init_d4message
  4454                                  d4	asciz "Found 386+ processor",13,10
  4455                                  		; Intel 386 CPU check.
  4456                                  		; The AC bit, bit #18, is a new bit introduced in the EFLAGS
  4457                                  		; register on the Intel486 DX cpu to generate alignment faults.
  4458                                  		; This bit cannot be set on the Intel386 CPU.
  4459                                  		;
  4460                                  		; It is now safe to use 32-bit opcode/operands.
  4461                                  subcpu 386
  4462 00001CC4 800E[0100]80            	setopt [internalflags], has386
  4463 00001CC9 FE06[0000]              	inc byte [ machine ]	; 3
  4464                                  
  4465                                  %if _DEVICE
  4466                                   %if _APPLICATION || _BOOTLDR
  4467 00001CCD F606[0200]40            	testopt [internalflags6], dif6_device_mode
  4468 00001CD2 7440                    	jz @F
  4469                                   %endif
  4470                                  
  4471 00001CD4 8C26[0000]              	mov word [reg_fs], fs
  4472 00001CD8 8C2E[0000]              	mov word [reg_gs], gs
  4473                                  %macro set_gpr_h 1
  4474                                  	push e %+ %1
  4475                                  	pop %1
  4476                                  	pop word [reg_e %+ %1 + 2]
  4477                                  %endmacro
  4478                                  	set_gpr_h ax
  4474 00001CDC 6650                <1>  push e %+ %1
  4475 00001CDE 58                  <1>  pop %1
  4476 00001CDF 8F06[0200]          <1>  pop word [reg_e %+ %1 + 2]
  4479                                  	set_gpr_h bx
  4474 00001CE3 6653                <1>  push e %+ %1
  4475 00001CE5 5B                  <1>  pop %1
  4476 00001CE6 8F06[0200]          <1>  pop word [reg_e %+ %1 + 2]
  4480                                  	set_gpr_h cx
  4474 00001CEA 6651                <1>  push e %+ %1
  4475 00001CEC 59                  <1>  pop %1
  4476 00001CED 8F06[0200]          <1>  pop word [reg_e %+ %1 + 2]
  4481                                  	set_gpr_h dx
  4474 00001CF1 6652                <1>  push e %+ %1
  4475 00001CF3 5A                  <1>  pop %1
  4476 00001CF4 8F06[0200]          <1>  pop word [reg_e %+ %1 + 2]
  4482                                  	set_gpr_h bp
  4474 00001CF8 6655                <1>  push e %+ %1
  4475 00001CFA 5D                  <1>  pop %1
  4476 00001CFB 8F06[0200]          <1>  pop word [reg_e %+ %1 + 2]
  4483                                  	set_gpr_h si
  4474 00001CFF 6656                <1>  push e %+ %1
  4475 00001D01 5E                  <1>  pop %1
  4476 00001D02 8F06[0200]          <1>  pop word [reg_e %+ %1 + 2]
  4484                                  	set_gpr_h di
  4474 00001D06 6657                <1>  push e %+ %1
  4475 00001D08 5F                  <1>  pop %1
  4476 00001D09 8F06[0200]          <1>  pop word [reg_e %+ %1 + 2]
  4485                                  		; esph and eiph remain zero
  4486 00001D0D 669C                    	pushfd
  4487 00001D0F 9D                      	popfw
  4488 00001D10 8F06[0200]              	pop word [reg_efl + 2]
  4489                                  %endif
  4490                                  @@:
  4491                                  
  4492 00001D14 89E3                    	mov bx, sp		; save current stack pointer to align
  4493 00001D16 83E4FC                  	and sp, ~3		; align stack to avoid AC fault
  4494 00001D19 669C                    	pushfd			; push original EFLAGS
  4495 00001D1B 6658                    	pop eax			; get original EFLAGS
  4496 00001D1D 6689C1                  	mov ecx, eax		; save original EFLAGS in ECX (including IF)
  4497                                  
  4498 00001D20 663500000400            	xor eax, 40000h		; flip AC bit in EFLAGS
  4499 00001D26 25FFFD                  	and ax, ~0200h		; clear IF
  4500 00001D29 6650                    	push eax		; put new EFLAGS value on stack
  4501 00001D2B 669D                    	popfd			; replace EFLAGS value; DI
  4502 00001D2D 669C                    	pushfd			; get new EFLAGS
  4503 00001D2F 6658                    	pop eax			; store new EFLAGS value in EAX
  4504 00001D31 89C8                    	mov ax, cx		; ignore low bits (including IF)
  4505 00001D33 6639C8                  	cmp eax, ecx
  4506 00001D36 741A                    	je .cpudone_stack_eax_equals_ecx	; if 80386 -->
  4507                                  
  4508                                  d4	call init_d4message
  4509                                  d4	asciz "Found 486+ processor",13,10
  4510                                  		; Intel486 DX CPU, Intel487 SX NDP, and Intel486 SX CPU check.
  4511                                  		; Checking for ability to set/clear ID flag (bit 21) in EFLAGS
  4512                                  		; which indicates the presence of a processor with the ability
  4513                                  		; to use the CPUID instruction.
  4514 00001D38 FE06[0000]              	inc byte [ machine ]	; 4
  4515 00001D3C 6689C8                  	mov eax, ecx		; get original EFLAGS
  4516 00001D3F 663500002000            	xor eax, 200000h	; flip ID bit in EFLAGS
  4517 00001D45 25FFFD                  	and ax, ~0200h		; clear IF
  4518 00001D48 6650                    	push eax		; save new EFLAGS value on stack
  4519 00001D4A 669D                    	popfd			; replace current EFLAGS value; DI
  4520 00001D4C 669C                    	pushfd			; get new EFLAGS
  4521 00001D4E 6658                    	pop eax			; store new EFLAGS in EAX
  4522 00001D50 89C8                    	mov ax, cx		; ignore low bits (including IF)
  4523                                  
  4524                                  .cpudone_stack_eax_equals_ecx:
  4525 00001D52 6651                    	push ecx
  4526 00001D54 669D                    	popfd			; restore AC,ID bits and IF in EFLAGS (86 Mode)
  4527 00001D56 89DC                    	mov sp, bx		; restore sp
  4528                                  
  4529 00001D58 6639C8                  	cmp eax, ecx		; check if it's changed
  4530 00001D5B 742B                    	je .cpudone		; if it's a 486 (can't toggle ID bit) -->
  4531                                  
  4532                                  d4	call init_d4message
  4533                                  d4	asciz "Found processor with CPUID support",13,10
  4534                                  		; Execute CPUID instruction.
  4535                                  subcpu 486		; NASM (at least 2.10rc1) handles cpuid itself as a
  4536                                  			;  586+ instruction, but we know better. So this
  4537                                  			;  part is declared for 486 compatibility, and only
  4538                                  			;  the cpuid instructions are emitted with 586
  4539                                  			;  compatibility to appease NASM.
  4540                                  %if 0
  4541                                  d4	call init_d4message
  4542                                  d4	asciz "CPUID will NOT be executed, to work around official DOSBox releases",13,10
  4543                                  d4	jmp .cpudone
  4544                                  %endif
  4545 00001D5D 6631C0                  	xor eax, eax		; set up input for CPUID instruction
  4546                                  d4	call init_d4message
  4547                                  d4	asciz "Executing CPUID 0",13,10
  4548                                  	  [cpu 586]
  4549 00001D60 0FA2                    	 cpuid
  4550                                  	  __CPU__
  4551                                  d4	call init_d4message
  4552                                  d4	asciz "CPUID 0 executed",13,10
  4553 00001D62 6683F801                	cmp eax, byte 1
  4554 00001D66 7220                    	jb .cpudone		; if 1 is not a valid input value for CPUID
  4555 00001D68 6631C0                  	xor eax, eax		; otherwise, run CPUID with eax = 1
  4556 00001D6B 6640                    	inc eax
  4557                                  d4	call init_d4message
  4558                                  d4	asciz "Executing CPUID 1",13,10
  4559                                  	  [cpu 586]
  4560 00001D6D 0FA2                    	 cpuid
  4561                                  	  __CPU__
  4562                                  d4	call init_d4message
  4563                                  d4	asciz "CPUID 1 executed",13,10
  4564                                  %if _MMXSUPP
  4565 00001D6F 66F7C200008000          	test edx, 80_0000h
  4566 00001D76 0F9506[0000]            	setnz byte [has_mmx]
  4567                                  %endif
  4568                                  
  4569 00001D7B 88E0                    	mov al, ah
  4570 00001D7D 240F                    	and al, 0Fh		; bits 8..11 are the model number
  4571 00001D7F 3C06                    	cmp al, 6
  4572 00001D81 7202                    	jb .below686		; if < 6
  4573 00001D83 B006                    	mov al, 6		; if >= 6, set it to 6
  4574                                  .below686:
  4575 00001D85 A2[0000]                	mov byte [ machine ], al; save machine type (486, 586, 686+)
  4576                                  
  4577                                  .cpudone:
  4578                                  subcpureset			; subcpu 486
  4579                                  subcpureset			; subcpu 386
  4580                                  d4	call init_d4message
  4581                                  d4	asciz "Determining floating-point unit",13,10
  4582                                  
  4583                                  		; Next determine the type of FPU in a system and set the mach_87
  4584                                  		; variable with the appropriate value.  All registers are used by
  4585                                  		; this code; none are preserved.
  4586                                  		;
  4587                                  		; Coprocessor check.
  4588                                  		; The algorithm is to determine whether the floating-point
  4589                                  		; status and control words can be written to.  If not, no
  4590                                  		; coprocessor exists.  If the status and control words can be
  4591                                  		; written to, the correct coprocessor is then determined
  4592                                  		; depending on the processor ID.  The Intel 386 CPU can
  4593                                  		; work with either an Intel 287 NDP or an Intel 387 NDP.
  4594                                  		; The infinity of the coprocessor must be checked
  4595                                  		; to determine the correct coprocessor ID.
  4596 00001D88 A0[0000]                	mov al, byte [ machine ]
  4597 00001D8B A2[0000]                	mov byte [ mach_87 ], al	; by default, set mach_87 to machine
  4598 00001D8E FE06[0000]              	inc byte [ has_87 ]
  4599 00001D92 C606[0000]0C            	mov byte [encodedmach87], 0Ch
  4600 00001D97 3C05                    	cmp al, 5			; a Pentium or above always will have a FPU
  4601 00001D99 7350                    	jae .fpudone
  4602 00001D9B FE0E[0000]              	dec byte [ has_87 ]		; assume no FPU
  4603 00001D9F C606[0000]C0            	mov byte [encodedmach87], 0C0h
  4604                                  
  4605 00001DA4 DBE3                    	fninit				; reset FPU
  4606 00001DA6 B0FF                    	mov al, -1			; initialise with a non-zero value
  4607 00001DA8 50                      	push ax
  4608 00001DA9 89E3                    	mov bx, sp
  4609 00001DAB 36DD3F                  	fnstsw word [ss:bx]		; save FP status word
  4610 00001DAE 58                      	pop ax				; retrieve it
  4611 00001DAF 84C0                    	test al, al
  4612 00001DB1 7538                    	jnz .fpudone			; if no FPU present
  4613                                  
  4614                                  		; al = 0 here
  4615 00001DB3 50                      	push ax
  4616 00001DB4 36D93F                  	fnstcw word [ss:bx]		; save FP control word
  4617 00001DB7 58                      	pop ax				; retrieve it
  4618 00001DB8 253F10                  	and ax, 103Fh			; see if selected parts look OK
  4619 00001DBB 83F83F                  	cmp ax, byte 3Fh
  4620 00001DBE 752B                    	jne .fpudone			; if no FPU present
  4621 00001DC0 FE06[0000]              	inc byte [ has_87 ]		; there's an FPU
  4622 00001DC4 C606[0000]0C            	mov byte [encodedmach87], 0Ch
  4623                                  
  4624                                  		; If we're using a 386, check for 287 vs. 387 by checking whether
  4625                                  		; +infinity = -infinity.
  4626 00001DC9 803E[0000]03            	cmp byte [ machine ], 3
  4627 00001DCE 751B                    	jne .fpudone			; if not a 386
  4628                                  [cpu 386]
  4629 00001DD0 D9E8                    	fld1				; must use default control from FNINIT
  4630 00001DD2 D9EE                    	fldz				; form infinity
  4631 00001DD4 DEF9                    	fdivp ST1			; 1 / 0 = infinity
  4632 00001DD6 D9C0                    	fld ST0
  4633 00001DD8 D9E0                    	fchs				; form negative infinity
  4634 00001DDA DED9                    	fcompp				; see if they are the same and remove them
  4635 00001DDC 9BDFE0                  	fstsw ax
  4636 00001DDF 9E                      	sahf				; look at status from FCOMPP
  4637 00001DE0 7509                    	jne .fpudone			; if they are different, then it's a 387
  4638 00001DE2 FE0E[0000]              	dec byte [ mach_87 ]		; otherwise, it's a 287
  4639 00001DE6 C606[0000]C2            	mov byte [encodedmach87], 0C2h
  4640                                  __CPU__
  4641                                  .fpudone:
  4642                                  
  4643                                  apply_patches:
  4644                                  %if _ONLY386
  4645                                  	testopt [internalflags], has386
  4646                                  	jnz @F				; okay -->
  4647                                  
  4648                                   %if _BOOTLDR && (_APPLICATION || _DEVICE)
  4649                                  	testopt [internalflags], nodosloaded
  4650                                  	lahf				; remember status
  4651                                   %endif
  4652                                  	mov dx, imsg.no386
  4653                                  	call init_putsz_cs		; display the error
  4654                                   %if _BOOTLDR && (_APPLICATION || _DEVICE)
  4655                                  	sahf
  4656                                  	jnz init_booterror.soft		; abort for loader -->
  4657                                   %elif _BOOTLDR
  4658                                  	jmp init_booterror.soft
  4659                                   %endif
  4660                                  %if _DEVICE && _APPLICATION
  4661                                  	testopt [internalflags6], dif6_device_mode
  4662                                  	jnz init_device_error_late
  4663                                  %elif _DEVICE
  4664                                  	jmp init_device_error_late
  4665                                  %endif
  4666                                  %if _APPLICATION
  4667                                  	mov ax, 4C01h
  4668                                  	int 21h				; abort our process
  4669                                  %endif
  4670                                  
  4671                                  @@:
  4672                                  %elif _ONLYNON386
  4673                                  	testopt [internalflags], has386
  4674                                  	jz @F				; okay -->
  4675                                  	mov dx, imsg.386
  4676                                  	call init_putsz_cs		; display the warning
  4677                                  @@:
  4678                                  %endif
  4679                                  
  4680                                  		; Determine which patch table to use, then patch
  4681                                  		; out either the 386+ or non-386 code as appropriate.
  4682 00001DEB 8E06[0000]              	mov es, [code_seg]
  4683 00001DEF F606[0100]80            	testopt [internalflags], has386
  4684 00001DF4 740B                    	jz @F
  4685 00001DF6 BE[0000]                	mov si, patch_386_table		; table of patches to set for 386+
  4686                                  %if __patch_386_table_method == 1
  4687 00001DF9 B9[0000]                	mov cx, patch_386_table.amount
  4688 00001DFC E83200                  	call .patch1
  4689                                  %else
  4690                                  	call .patch2
  4691                                  %endif
  4692 00001DFF EB3C                    	jmp .patch_code1_end
  4693                                  
  4694                                  @@:
  4695                                  %ifn _ONLYNON386
  4696                                  
  4697                                  %if _RUN2_ENTRY_SECTION
  4698 00001E01 C606[0000]3E            	mov byte [..@patch_no386_ds_code_or_entry], 3Eh
  4699                                  					; write a ds prefix
  4700 00001E06 C606[0000]CF            	mov byte [..@patch_no386_iret_code_or_entry], 0CFh
  4701                                  					; write an iret instruction
  4702                                  %else
  4703                                  	mov byte [es:..@patch_no386_ds_code_or_entry], 3Eh
  4704                                  					; write a ds prefix
  4705                                  	mov byte [es:..@patch_no386_iret_code_or_entry], 0CFh
  4706                                  					; write an iret instruction
  4707                                  %endif
  4708                                   %if _PM && _CATCHPMINT214C
  4709 00001E0B C606[0000]3E            	mov byte [..@patch_no386_ds_entry_pmint21_1], 3Eh
  4710 00001E10 C606[0000]3E            	mov byte [..@patch_no386_ds_entry_pmint21_2], 3Eh
  4711                                  					; write ds prefixes (note the segment!)
  4712                                   %endif
  4713                                   %if _PM
  4714 00001E15 26C606[0000]3E          	mov byte [es:..@patch_no386_ds_4], 3Eh
  4715 00001E1B 26C606[0000]3E          	mov byte [es:..@patch_no386_ds_5], 3Eh	; write some more ds prefixes
  4716                                   %endif
  4717                                   %if _CATCHINT07 || _CATCHINT0C || _CATCHINT0D
  4718 00001E21 C606[0000]3E            	mov byte [..@patch_no386_ds_6_DATA_ENTRY], 3Eh
  4719                                  					; write a ds prefix (note the segment!)
  4720                                   %endif
  4721                                  %endif
  4722 00001E26 BE[0000]                	mov si, patch_no386_table	; table of patches to set for 16-bit CPU
  4723                                  %if __patch_no386_table_method == 1
  4724 00001E29 B9[0000]                	mov cx, patch_no386_table.amount
  4725 00001E2C E80200                  	call .patch1
  4726                                  %else
  4727                                  	call .patch2
  4728                                  %endif
  4729 00001E2F EB0C                    	jmp .patch_code1_end
  4730                                  
  4731                                  		; Complicated table patch code.
  4732                                  %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
  4735                                  .patch2:
  4736                                  	mov di, code_start		; initialise offset
  4737                                  	xor ax, ax			; initialise ah
  4738                                  .looppatch2:
  4739                                  	cs lodsb
  4740                                  	add di, ax			; skip number of bytes to skip
  4741                                  	cmp al, 255			; really repositioning?
  4742                                  	jne .l2patch			; no -->
  4743                                  	xchg ax, di			; (to preserve ah)
  4744                                  	cs lodsw			; ax = new address
  4745                                  	xchg ax, di			; di = new address
  4746                                  .l2patch:
  4747                                  	cs lodsb
  4748                                  	mov cx, ax			; cx = number of bytes to patch
  4749                                  	jcxz .patchesdone		; end of table -->
  4750                                  	mov al, 90h			; patch to NOP
  4751                                  	rep stosb			; patch as many bytes as specified
  4752                                  	jmp short .looppatch2
  4753                                  %endif
  4754                                  
  4755                                  		; Simple table patch code.
  4756                                  %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
  4759                                  .patch1:
  4760 00001E31 E309                    	jcxz .patchesdone
  4761                                  .looppatch1:
  4762 00001E33 2EAD                    	cs lodsw			; load address of patch
  4763 00001E35 93                      	xchg bx, ax			; (set bx = ax, CHG ax)
  4764 00001E36 26C60790                	mov byte [es:bx], 90h		; patch
  4765 00001E3A E2F7                    	loop .looppatch1
  4766                                  %endif
  4767                                  .patchesdone:
  4768 00001E3C C3                      	retn
  4769                                  
  4770                                  .patch_code1_end:
  4771                                  
  4772                                  %if _DUALCODE
  4773 00001E3D 8CC2                    	mov dx, es			; dx => code1 seg
  4774                                  %endif
  4775                                   %if _BOOTLDR_DISCARD
  4776 00001E3F F606[0100]40            	testopt [internalflags], nodosloaded
  4777 00001E44 7506                    	jnz @F
  4778                                  
  4779                                    %if _AREAS && _AREAS_HOOK_CLIENT
  4780                                     %ifn _LINK
  4781                                  	mov ax, ldebug_code_bootldr_truncated_size
  4782                                     %else
  4783                                  	mov ax, behind_code_truncated wrt lDEBUG_CODE
  4784                                   wlcalc word_add_15, equ $ - 2
  4785                                   wlcalc word_clr_15, equ $ - 2
  4786                                     %endif
  4787                                  	mov word [areas_sub + areastrucfunLinearEnd], ax
  4788                                  	mov word [areas_fun + areastrucfunLinearEnd], ax
  4789                                    %endif
  4790                                   %endif
  4791                                  %ifn _DUALCODE
  4792                                  @@:					; if bootloaded
  4793                                  %else
  4794                                   %if _BOOTLDR_DISCARD
  4795                                    %ifn _LINK
  4796                                  	add dx, ldebug_code_bootldr_truncated_size_p
  4797                                    %else
  4798 00001E46 81C2[0000]              	add dx, strict word relocatedzero + 0
  4799                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code_truncated, equ $ - 2
  4800                                    %endif
  4801                                  					; if not bootloaded, use truncated
  4802 00001E4A EB04                    	jmp @FF
  4803                                  @@:					; if bootloaded
  4804                                   %endif
  4805                                    %ifn _LINK
  4806                                  	add dx, ldebug_code_size_p	; use untruncated
  4807                                    %else
  4808 00001E4C 81C2[0000]              	add dx, strict word relocatedzero + 0
  4809                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code, equ $ - 2
  4810                                    %endif
  4811                                  @@:
  4812 00001E50 8916[0000]              	mov word [code2_seg], dx
  4813                                  patch_relocate:
  4814                                  
  4815                                   %if ! _PM
  4816                                  	mov si, relocate_from_code
  4817                                  	mov di, relocate_from_code.end
  4818                                  	call .patch
  4819                                  	mov si, relocate_from_code2
  4820                                  	mov di, relocate_from_code2.end
  4821                                   %endif
  4822 00001E54 06                      	push es
  4823 00001E55 8EC2                    	mov es, dx
  4824 00001E57 5A                      	pop dx
  4825                                   %if ! _PM
  4826                                  	call .patch
  4827                                  	jmp .done
  4828                                  
  4829                                  .loop:
  4830                                  	cs lodsw
  4831                                  	xchg bx, ax
  4832                                  	mov word [es:bx], dx
  4833                                  .patch:
  4834                                  	cmp si, di
  4835                                  	jb .loop
  4836                                  	retn
  4837                                  
  4838                                  .done:
  4839                                   %endif
  4840                                  
  4841 00001E58 F606[0100]80            	testopt [internalflags], has386
  4842 00001E5D 740B                    	jz @F
  4843 00001E5F BE[0000]                	mov si, patch_386_table2	; table of patches to set for 386+
  4844                                  %if __patch_386_table2_method == 1
  4845 00001E62 B9[0000]                	mov cx, patch_386_table2.amount
  4846 00001E65 E8C9FF                  	call apply_patches.patch1
  4847                                  %else
  4848                                  	call apply_patches.patch2
  4849                                  %endif
  4850 00001E68 EB09                    	jmp .patch_code2_end
  4851                                  
  4852                                  @@:
  4853 00001E6A BE[0000]                	mov si, patch_no386_table2	; table of patches to set for 16-bit CPU
  4854                                  %if __patch_no386_table2_method == 1
  4855 00001E6D B9[0000]                	mov cx, patch_no386_table2.amount
  4856 00001E70 E8BEFF                  	call apply_patches.patch1
  4857                                  %else
  4858                                  	call apply_patches.patch2
  4859                                  %endif
  4860                                  .patch_code2_end:
  4861                                  %endif
  4862                                  
  4863                                  
  4864                                  patch_entry:
  4865                                  	numdef EMIT_ENTRY_PATCH, _LINK || _LINK_COMPAT
  4866                                  %ifn _EMIT_ENTRY_PATCH
  4867                                   %if patch_386_tableentry_size != 0 || patch_no386_tableentry_size != 0
  4868                                    %assign _EMIT_ENTRY_PATCH 1
  4869                                   %endif
  4870                                  %endif
  4871                                  %if _EMIT_ENTRY_PATCH
  4872 00001E73 1E                      	push ds
  4873 00001E74 07                      	pop es
  4874 00001E75 F606[0100]80            	testopt [internalflags], has386
  4875 00001E7A 740B                    	jz @F
  4876 00001E7C BE[0000]                	mov si, patch_386_tableentry	; table of patches to set for 386+
  4877                                  %if __patch_386_tableentry_method == 1
  4878 00001E7F B9[0000]                	mov cx, patch_386_tableentry.amount
  4879 00001E82 E8ACFF                  	call apply_patches.patch1
  4880                                  %else
  4881                                  	call apply_patches.patch2
  4882                                  %endif
  4883 00001E85 EB09                    	jmp .patch_entry_end
  4884                                  
  4885                                  @@:
  4886 00001E87 BE[0000]                	mov si, patch_no386_tableentry	; table of patches to set for 16-bit CPU
  4887                                  %if __patch_no386_tableentry_method == 1
  4888 00001E8A B9[0000]                	mov cx, patch_no386_tableentry.amount
  4889 00001E8D E8A1FF                  	call apply_patches.patch1
  4890                                  %else
  4891                                  	call apply_patches.patch2
  4892                                  %endif
  4893                                  .patch_entry_end:
  4894                                  %endif
  4895                                  
  4896                                  
  4897                                  %if _DEVICE
  4898                                  		; This must be done after CPU detection
  4899                                  		;  because we want to get the high parts
  4900                                  		;  of the registers only initialised here.
  4901 00001E90 1E                      	push ds
  4902 00001E91 07                      	pop es
  4903 00001E92 BE[0000]                	mov si, regs
  4904 00001E95 BF[0000]                	mov di, device_quittable_regs
  4905                                   %ifn _LINK
  4906                                  	mov cx, words(regs.size)
  4907                                   %else
  4908 00001E98 B9[0100]                	mov cx, regs.size + 1
  4909                                   wlcalc word_shr_1, equ $ - 2
  4910                                   %endif
  4911 00001E9B F3A5                    	rep movsw
  4912                                  %endif
  4913                                  
  4914                                  
  4915                                  		; Check for dosemu. This is done for the boot loaded instance
  4916                                  		; too, as we might be running as DOS inside dosemu.
  4917                                  %if _DOSEMU
  4918 00001E9D B800F0                  	mov ax, 0F000h
  4919 00001EA0 8EC0                    	mov es, ax
  4920 00001EA2 1E                      	push ds
  4921 00001EA3 0E                      	 push cs
  4922 00001EA4 1F                      	 pop ds			; avoid "repe cs cmpsw" (8086 bug)
  4923 00001EA5 BFF5FF                  	mov di, 0FFF5h
  4924 00001EA8 BE[1C19]                	mov si, imsg.dosemudate
  4925 00001EAB B90400                  	mov cx, 4
  4926 00001EAE F3A7                    	repe cmpsw		; running in DosEmu?
  4927 00001EB0 1F                      	pop ds
  4928 00001EB1 750A                    	jne .dosemuchecked
  4929 00001EB3 800E[0300]01            	setopt [internalflags], runningdosemu
  4930                                   %if _DOSEMU_PRESTROKES_HELP
  4931 00001EB8 B80900                  	mov ax, 0009h
  4932 00001EBB CDE6                    	int 0E6h		; run dosemu2 start_pre_strokes function
  4933                                  ; dosemu2 recently gained a feature that tries to avoid
  4934                                  ;  a kernel from eating the first text byte of an -input
  4935                                  ;  string. However, this interferes with our use because
  4936                                  ;  the strokes are only enabled in dos_post_boot (int.c).
  4937                                  ; There is a new int 0E6h helper function now to enable
  4938                                  ;  the strokes right away, which is made for lDebug to work
  4939                                  ;  when the debugger is booted and wants the input. This
  4940                                  ;  is called DOS_HELPER_PRESTROKES_START (also int.c).
  4941                                  ; Reference: https://github.com/dosemu2/dosemu2/issues/2071
  4942                                   %endif
  4943                                  .dosemuchecked:
  4944                                  %endif
  4945                                  
  4946 00001EBD 1E                      	push ds
  4947 00001EBE 07                      	pop es			; => lDEBUG_DATA_ENTRY
  4948                                  
  4949 00001EBF BF[0000]                	mov di, line_in
  4950 00001EC2 B0FF                    	mov al, 255
  4951 00001EC4 AA                      	stosb
  4952 00001EC5 B000                    	mov al, 0
  4953 00001EC7 AA                      	stosb
  4954 00001EC8 B00D                    	mov al, 13
  4955 00001ECA AA                      	stosb				; overwrite line_in beginning
  4956                                  
  4957 00001ECB BC[0000]                	mov sp, stack_end		; stack pointer (paragraph aligned)
  4958 00001ECE BF[0000]                	mov di, ..@init_first
  4959                                  %ifn _LINK
  4960                                  	mov cx, ..@init_behind - ..@init_first
  4961                                  %else
  4962 00001ED1 B9[0000]                	mov cx, ..@init_behind
  4963                                   wlcalc word_minusext_..@init_first, equ $ - 2
  4964                                  %endif
  4965 00001ED4 31C0                    	xor ax, ax
  4966 00001ED6 F3AA                    	rep stosb			; initialise breakpoint lists, line_out
  4967                                  %if 1
  4968                                  ..@init_behind_equate equ ..@init_behind
  4969                                  stack_equate equ stack
  4970                                  %if ..@init_behind_equate != stack_equate
  4971 00001ED8 BF[0000]                	mov di, stack
  4972                                  %endif
  4973                                  %ifn _LINK
  4974                                  	mov cx, stack_end - stack
  4975                                  %else
  4976 00001EDB B9[0000]                	mov cx, stack_end
  4977                                   wlcalc word_minusext_stack, equ $ - 2
  4978                                  %endif
  4979 00001EDE B05E                    	mov al, 5Eh
  4980 00001EE0 F3AA                    	rep stosb			; initialise the stack
  4981                                  %endif
  4982                                  
  4983 00001EE2 C606[0000]30            	mov byte [ trim_overflow ], '0'	; initialise line_out so the trimputs loop doesn't overflow
  4984 00001EE7 C706[0000]4226          	mov word [line_out_overflow], 2642h
  4985                                  
  4986                                  
  4987                                  %if _AREAS_HOOK_SERVER
  4988 00001EED 8CD8                    	mov ax, ds
  4989 00001EEF A3[0200]                	mov word [ddebugareas.next + 2], ax
  4990 00001EF2 A3[0200]                	mov word [ddebugareas.prev + 2], ax
  4991 00001EF5 A3[0000]                	mov word [..@patch_entry_seg], ax
  4992                                  %endif
  4993                                  
  4994                                  %if _AREAS && _AREAS_HOOK_CLIENT
  4995                                  	mov ax, word [code_seg]
  4996                                  	call add_to_areas_linear_code1
  4997                                  
  4998                                   %if _DUALCODE && _EXPRDUALCODE
  4999                                  	mov ax, word [code2_seg]
  5000                                  	call add_to_areas_linear_code2
  5001                                   %endif
  5002                                  %endif
  5003                                  
  5004                                  
  5005                                  %if _DEBUG && _DEBUG_COND && _DEBUG_COND_DEFAULT_ON
  5006                                  	setopt [internalflags6], dif6_debug_mode
  5007                                  	setopt [options6], opt6_debug_mode
  5008                                  	setopt [startoptions6], opt6_debug_mode
  5009                                  %endif
  5010                                  
  5011                                  %if _CATCHINT06 && _DETECT95LX
  5012 00001EF8 B8D44D                  	mov ax, 4DD4h
  5013 00001EFB 31DB                    	xor bx, bx
  5014 00001EFD CD15                    	int 15h				; HP 95LX/100LX/200LX detect
  5015 00001EFF 81FB5048                	cmp bx, 4850h			; "HP" reversed
  5016 00001F03 7516                    	jne @F
  5017 00001F05 81F90101                	cmp cx, 0101h			; 95LX ?
  5018 00001F09 7510                    	jne @F				; no -->
  5019                                  
  5020                                   %if _CATCHINT2D
  5021 00001F0B A1[0100]                	mov ax, word [inttab.i2D + 1]
  5022 00001F0E A3[0100]                	mov word [inttab.i06 + 1], ax	; overwrite i06 entry with i2D
  5023 00001F11 A0[0000]                	mov al, byte [inttab.i2D]
  5024 00001F14 A2[0000]                	mov byte [inttab.i06], al	; interrupt number too
  5025                                   %endif
  5026 00001F17 FF0E[0000]              	dec word [inttab_number_variable]	; remember one less in use
  5027                                  @@:
  5028                                  %endif
  5029                                  
  5030 00001F1B B40F                    	mov ah, 0Fh
  5031 00001F1D CD10                    	int 10h
  5032 00001F1F 883E[0000]              	mov byte [vpage], bh
  5033                                  
  5034                                  
  5035                                  %if _BOOTLDR
  5036                                   %if _APPLICATION || _DEVICE
  5037 00001F23 F606[0100]40            	testopt [internalflags], nodosloaded
  5038 00001F28 7439                    	jz initdos
  5039                                   %endif
  5040                                  d4	call init_d4message
  5041                                  d4	asciz "386-related patches applied, boot initialisation proceeding",13,10
  5042                                  
  5043                                  
  5044                                  %if CATCHINTAMOUNT
  5045                                  		; Set up interrupt vectors.
  5046                                  
  5047                                  		; ds still => lDEBUG_DATA_ENTRY
  5048                                  %if _CATCHINT06 && _DETECT95LX
  5049 00001F2A 8B0E[0000]              	mov cx, word [inttab_number_variable]
  5050                                  %else
  5051                                  	mov cx, inttab_number
  5052                                  %endif
  5053 00001F2E E327                    	jcxz .bootintend
  5054 00001F30 BE[0000]                	mov si, inttab
  5055                                  .bootintloop:
  5056                                  
  5057                                  		; assumes ss = lDEBUG_DATA_ENTRY
  5058 00001F33 36AC                    	ss lodsb
  5059 00001F35 31DB                    	xor bx, bx
  5060 00001F37 8EDB                    	mov ds, bx
  5061 00001F39 88C3                    	mov bl, al
  5062 00001F3B 01DB                    	add bx, bx
  5063 00001F3D 01DB                    	add bx, bx
  5064 00001F3F 97                      	xchg ax, di
  5065 00001F40 36AD                    	ss lodsw		; get address of IISP header
  5066 00001F42 97                      	xchg ax, di
  5067                                  %if _DEBUG && !_DEBUG_COND
  5068                                  				; vectors are set only when debuggee runs
  5069                                  %else
  5070                                   %if _DEBUG
  5071                                  	testopt [ss:internalflags6], dif6_debug_mode
  5072                                  	jnz @F
  5073                                   %endif
  5074 00001F43 FF7702                  	push word [ bx+2 ]
  5075 00001F46 FF37                    	push word [ bx ]	; get vector
  5076 00001F48 368F4502                	pop word [ ss:di + ieNext ]
  5077 00001F4C 368F4504                	pop word [ ss:di + ieNext + 2 ]
  5078                                  				; store it
  5079 00001F50 8C5702                  	mov word [ bx+2 ], ss
  5080 00001F53 893F                    	mov word [ bx ], di	; set interrupt vector
  5081                                  @@:
  5082                                  %endif
  5083 00001F55 E2DC                    	loop .bootintloop
  5084                                  
  5085                                  .bootintend:
  5086                                  %endif
  5087                                  
  5088                                  %if _EXTENSIONS
  5089                                  init_eld_boot:
  5090 00001F57 E8B114                  	call init_eld
  5091                                  %else
  5092                                  	push ss
  5093                                  	pop ds
  5094                                  	push ss
  5095                                  	pop es
  5096                                  %endif
  5097                                  
  5098                                  d4	call init_d4message
  5099                                  d4	asciz "Jumping to final boot initialisation code",13,10
  5100 00001F5A BE[0000]                	mov si, initcont.boot_entry
  5101 00001F5D FF36[0000]              	push word [code_seg]
  5102 00001F61 56                      	push si
  5103 00001F62 CB                      	retf
  5104                                  %endif
  5105                                  
  5106                                  %if _APPLICATION || _DEVICE
  5107                                  initdos:
  5108                                  %if _MCB || _INT || _EXTENSIONS
  5109 00001F63 B80258                  	mov ax, 5802h
  5110 00001F66 CD21                    	int 21h
  5111 00001F68 30E4                    	xor ah, ah		; some "DOS" only return al
  5112 00001F6A 50                      	push ax			; save UMB link
  5113                                  
  5114                                  getfirstmcb:
  5115 00001F6B B452                    	mov ah, 52h		; get list of lists
  5116 00001F6D BBFFFF                  	mov bx, -1
  5117 00001F70 CD21                    	int 21h
  5118 00001F72 83FBFF                  	cmp bx, -1
  5119 00001F75 7503E98800              	je mcb_not_found
  5120 00001F7A 83FB01                  	cmp bx, 1
  5121 00001F7D 7503E98000              	je mcb_not_found
  5122 00001F82 268B47FE                	mov ax, word [ es:bx-2 ]; start of MCBs
  5123 00001F86 A3[0000]                	mov word [firstmcb], ax
  5124                                  
  5125                                  getfirstumcb:
  5126 00001F89 1E                      	push ds
  5127                                  			; We try to get the first UMCB for gateout
  5128                                  			;  for now. To harden our code it should
  5129                                  			;  not be assumed that the address is of
  5130                                  			;  a valid MCB. However, it is fine to
  5131                                  			;  compare an actual MCB address with it.
  5132                                    %if _GUARD_86M_INT2F
  5133 00001F8A 06                      	push es
  5134 00001F8B 31C0                    	xor ax, ax
  5135 00001F8D 8EC0                    	mov es, ax		; (only used in 86 Mode)
  5136 00001F8F 26A1BC00                	mov ax, [es:2Fh * 4]
  5137 00001F93 83F8FF                  	cmp ax, -1
  5138 00001F96 7405                    	je @F			; --> (ZR)
  5139 00001F98 260B06BE00              	or ax, [es:2Fh * 4 + 2]
  5140                                  @@:
  5141 00001F9D 07                      	pop es
  5142 00001F9E 7414                    	jz .determine
  5143                                    %endif
  5144 00001FA0 B86112                  	mov ax, 1261h		; PTS-DOS: Get first UMCB
  5145 00001FA3 F9                      	stc
  5146 00001FA4 CD2F                    	int 2Fh
  5147 00001FA6 720C                    	jc .determine		; not supported -->
  5148 00001FA8 40                      	inc ax
  5149 00001FA9 83F802                  	cmp ax, byte 2		; -1, 0, 1 ?
  5150 00001FAC 7606                    	jbe .determine		; not supported (or none) -->
  5151 00001FAE 48                      	dec ax
  5152 00001FAF A3[0000]                	mov word [ firstumcb ], ax	; set UMB
  5153 00001FB2 EB4D                    	jmp short .got		; got it -->
  5154                                  
  5155                                  .determine:
  5156 00001FB4 B80358                  	mov ax, 5803h
  5157 00001FB7 31DB                    	xor bx, bx
  5158 00001FB9 CD21                    	int 21h			; disable UMB link, leave only LMA chain
  5159 00001FBB 7244                    	jc .none		; that isn't supported either -->
  5160                                  
  5161 00001FBD A1[0000]                	mov ax, word [firstmcb]
  5162 00001FC0 89C2                    	mov dx, ax		; first MCB
  5163 00001FC2 31DB                    	xor bx, bx		; use offsets from bx, not addresses
  5164                                  .looplmb:
  5165 00001FC4 8ED8                    	mov ds, ax
  5166 00001FC6 40                      	inc ax
  5167 00001FC7 034703                  	add ax, word [ bx + 3 ]	; next MCB's address
  5168 00001FCA 803F4D                  	cmp byte [ bx ], 'M'
  5169 00001FCD 74F5                    	je .looplmb		; not last -->
  5170 00001FCF 803F5A                  	cmp byte [ bx ], 'Z'
  5171 00001FD2 752D                    	jne .none		; corrupted -->
  5172 00001FD4 92                      	xchg ax, dx		; dx = what we assume to be the first UMA chain MCB
  5173                                  				; ax = first MCB
  5174                                  
  5175 00001FD5 50                      	push ax
  5176 00001FD6 43                      	inc bx			; = 1
  5177 00001FD7 B80358                  	mov ax, 5803h
  5178 00001FDA CD21                    	int 21h			; enable UMB link, include UMA chain
  5179 00001FDC 58                      	pop ax
  5180 00001FDD 7222                    	jc .none		; so we can disable it but not enable? -->
  5181                                  
  5182 00001FDF 4B                      	dec bx			; = 0
  5183 00001FE0 31C9                    	xor cx, cx		; flag if assumed first UMCB found
  5184                                  .loopumb:
  5185 00001FE2 39D0                    	cmp ax, dx
  5186 00001FE4 7501                    	jne .notlastlmb
  5187 00001FE6 41                      	inc cx			; there it is
  5188                                  .notlastlmb:
  5189 00001FE7 8ED8                    	mov ds, ax
  5190 00001FE9 803F4D                  	cmp byte [ bx ], 'M'
  5191 00001FEC 7506                    	jne .islastumb?		; last or corrupted -->
  5192 00001FEE 40                      	inc ax
  5193 00001FEF 034703                  	add ax, word [ bx + 3 ]
  5194 00001FF2 EBEE                    	jmp short .loopumb	; process next -->
  5195                                  .islastumb?:
  5196 00001FF4 803F5A                  	cmp byte [ bx ], 'Z'
  5197 00001FF7 7508                    	jne .none		; corrupted -->
  5198 00001FF9 E306                    	jcxz .none		; didn't find that UMCB -->
  5199                                  			; The MCB at dx which was behind the one that contained the 'Z'
  5200                                  			; signature when we disabled the UMB link is now a valid MCB in
  5201                                  			; the MCB chain after we enabled the UMB link. All previous MCBs
  5202                                  			; are now 'M'.
  5203 00001FFB 1F                      	pop ds
  5204 00001FFC 8916[0000]              	mov word [ firstumcb ], dx
  5205 00002000 A8                      	db __TEST_IMM8		; (skip pop)
  5206                                  .none:
  5207                                  .got:
  5208 00002001 1F                      	pop ds
  5209                                  mcb_not_found:
  5210 00002002 5B                      	pop bx
  5211 00002003 B80358                  	mov ax, 5803h
  5212 00002006 CD21                    	int 21h			; restore UMB link
  5213                                  %endif
  5214                                  
  5215                                  getindosflag:
  5216 00002008 B434                    	mov ah, 34h
  5217 0000200A CD21                    	int 21h
  5218 0000200C 891E[0000]              	mov word [pInDOS + so16aOffset], bx
  5219 00002010 8C06[0200]              	mov word [pInDOS + so16aSegSel], es
  5220                                  %if _PM
  5221 00002014 8C06[0400]              	mov word [pInDOS + so16aSegment], es
  5222                                  %endif
  5223                                  
  5224                                  		; get address of DOS swappable DATA area
  5225                                  		; to be used to get/set PSP and thus avoid DOS calls
  5226                                  		; will not work for DOS < 3
  5227                                  %if _USESDA
  5228                                  getsda:
  5229 00002018 1E                      	push ds
  5230 00002019 B8065D                  	mov ax, 5D06h
  5231 0000201C F9                      	stc				; initialise to CY
  5232 0000201D CD21                    	int 21h
  5233 0000201F 8CD8                    	mov ax, ds
  5234 00002021 1F                      	pop ds
  5235 00002022 7218                    	jc .noSDA			; if CY returned, not supported -->
  5236 00002024 8EC0                    	mov es, ax			; es:si -> SDA
  5237                                   %if _DEVICE
  5238 00002026 50                      	push ax
  5239 00002027 B451                    	mov ah, 51h
  5240 00002029 CD21                    	int 21h				; bx = current PSP
  5241 0000202B 58                      	pop ax
  5242                                   %else
  5243                                  	mov bx, ds			; bx = our PSP (= current PSP in app mode)
  5244                                   %endif
  5245 0000202C 26395C10                	cmp word [es:si + 10h], bx	; does this seem like the current PSP field ?
  5246 00002030 750A                    	jne .noSDA			; no -->
  5247 00002032 8936[0000]              	mov word [pSDA + so16aOffset], si
  5248 00002036 A3[0200]                	mov word [pSDA + so16aSegSel], ax
  5249                                  %if _PM
  5250 00002039 A3[0400]                	mov word [pSDA + so16aSegment], ax
  5251                                  %endif
  5252                                  .noSDA:
  5253                                  %endif
  5254                                  
  5255 0000203C B83135                  	mov ax, 3531h
  5256 0000203F CD21                    	int 21h
  5257 00002041 8CC3                    	mov bx, es
  5258                                  %if _USESDA
  5259 00002043 3B1E[0200]              	cmp bx, word [pSDA + so16aSegSel]
  5260 00002047 750B                    	jne @F
  5261                                  %endif
  5262 00002049 3B1E[0200]              	cmp bx, word [pInDOS + so16aSegSel]
  5263 0000204D 7505                    	jne @F
  5264                                  
  5265 0000204F 800E[0300]20            	setopt [internalflags2], dif2_int31_segment
  5266                                  @@:
  5267                                  
  5268                                  
  5269                                  commandline:
  5270 00002054 16                      	push ss
  5271 00002055 07                      	pop es
  5272                                  
  5273                                  %if _CONFIG
  5274                                  %if _APPLICATION
  5275 00002056 BE[6C16]                	mov si, imsg.default_cmdline.app
  5276 00002059 B93300                  	mov cx, words(imsg.default_cmdline.app.length)
  5277                                  %endif
  5278                                  %if _DEVICE
  5279                                   %if _APPLICATION
  5280 0000205C F606[0200]40            	testopt [internalflags6], dif6_device_mode
  5281 00002061 7406                    	jz @F
  5282                                   %endif
  5283 00002063 BE[D416]                	mov si, imsg.default_cmdline.dev
  5284 00002066 B92E00                  	mov cx, words(imsg.default_cmdline.dev.length)
  5285                                  %endif
  5286                                  @@:
  5287                                  
  5288 00002069 0E                      	push cs
  5289 0000206A 1F                      	pop ds
  5290 0000206B BF[0000]                	mov di, cmdline_buffer
  5291 0000206E F3A5                    	rep movsw
  5292 00002070 26807DFF00              	cmp byte [es:di - 1], 0
  5293 00002075 7501                    	jne @F
  5294 00002077 4F                      	dec di
  5295                                  @@:
  5296 00002078 893E[3A0E]              	mov [cmdline_buffer_start], di
  5297 0000207C B000                    	mov al, 0
  5298 0000207E AA                      	stosb
  5299 0000207F 16                      	push ss
  5300 00002080 1F                      	pop ds
  5301 00002081 800E[0100]01            	setopt [internalflags3], dif3_input_cmdline
  5302                                  %endif
  5303                                  
  5304                                  		; Interpret switches and erase them from the command line.
  5305 00002086 B80037                  	mov ax, 3700h			; get switch character
  5306 00002089 B22F                    	mov dl, '/'			; preset with default value
  5307 0000208B CD21                    	int 21h
  5308 0000208D 8816[0000]              	mov byte [ switchar ], dl
  5309 00002091 80FA2F                  	cmp dl, '/'
  5310 00002094 7504                    	jne .notslash
  5311 00002096 8816[0000]              	mov byte [ swch1 ], dl
  5312                                  .notslash:
  5313 0000209A BE8100                  	mov si, DTA+1
  5314                                  %if _MS_N_COMPAT
  5315 0000209D C644FF30                	mov byte [si - 1], '0'	; avoid kk underflow before start of tail
  5316                                  %endif
  5317                                  .blankloop:
  5318 000020A1 AC                      	lodsb
  5319 000020A2 3C20                    	cmp al, 32
  5320 000020A4 74FB                    	je .blankloop
  5321 000020A6 3C09                    	cmp al, 9
  5322 000020A8 74F7                    	je .blankloop
  5323                                  
  5324                                  		; Process the /? switch (or the [switchar]? switch).
  5325                                  		; If switchar != / and /? occurs, make sure nothing follows.
  5326 000020AA 3A06[0000]              	cmp al, byte [switchar]
  5327 000020AE 7503E9DB00              	je .switch		; if switch character -->
  5328 000020B3 3C2F                    	cmp al, '/'
  5329 000020B5 7403E92908              	jne .noswitches		; if not the help switch -->
  5330 000020BA 8A04                    	mov al, byte [ si ]
  5331 000020BC 3C3F                    	cmp al, '?'
  5332 000020BE 7403E92008              	jne .noswitches		; if not /?
  5333 000020C3 8A4401                  	mov al, byte [ si+1 ]
  5334 000020C6 3C20                    	cmp al, 32
  5335 000020C8 740B                    	je .help		; if nothing after /?
  5336 000020CA 3C09                    	cmp al, 9
  5337 000020CC 7407                    	je .help		; ditto
  5338 000020CE 3C0D                    	cmp al, 13
  5339 000020D0 7403E90E08              	jne .noswitches		; if something after /? -->
  5340                                  
  5341                                  		; Print a help message
  5342                                  .help:
  5343 000020D5 1E                      	push ds
  5344                                  %if _DEVICE
  5345                                   %if _APPLICATION
  5346 000020D6 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  5347 000020DB 742A                    	jz .help_not_device
  5348                                   %endif
  5349                                  
  5350                                  		; We modify the device command line here.
  5351                                  		;  Is that wise? Seems to work though.
  5352 000020DD 8B36[0000]              	mov si, word [reg_ebx]
  5353 000020E1 8E1E[0000]              	mov ds, word [reg_es]
  5354 000020E5 C57412                  	lds si, [si + 12h]
  5355 000020E8 56                      	push si
  5356                                  @@:
  5357 000020E9 AC                      	lodsb
  5358 000020EA 3C20                    	cmp al, 32
  5359 000020EC 7412                    	je @F
  5360 000020EE 3C09                    	cmp al, 9
  5361 000020F0 740E                    	je @F
  5362 000020F2 3C00                    	cmp al, 0
  5363 000020F4 740A                    	je @F
  5364 000020F6 3C0D                    	cmp al, 13
  5365 000020F8 7406                    	je @F
  5366 000020FA 3C0A                    	cmp al, 10
  5367 000020FC 7402                    	je @F
  5368 000020FE EBE9                    	jmp @B
  5369                                  
  5370                                  @@:
  5371 00002100 C644FF00                	mov byte [si - 1], 0
  5372 00002104 5E                      	pop si
  5373 00002105 EB1B                    	jmp .help_common
  5374                                  
  5375                                  .help_not_device:
  5376                                  %endif
  5377                                  %if _APPLICATION
  5378 00002107 A12C00                  	mov ax, word [2Ch]	; => environment
  5379 0000210A 85C0                    	test ax, ax
  5380 0000210C 7476                    	jz .help.no_name
  5381 0000210E 8ED8                    	mov ds, ax
  5382 00002110 31F6                    	xor si, si
  5383                                  @@:
  5384 00002112 AC                      	lodsb
  5385 00002113 84C0                    	test al, al
  5386 00002115 75FB                    	jnz @B
  5387 00002117 AC                      	lodsb
  5388 00002118 84C0                    	test al, al
  5389 0000211A 75F6                    	jnz @B
  5390 0000211C AD                      	lodsw
  5391 0000211D 83F801                  	cmp ax, 1
  5392 00002120 7562                    	jne .help.no_name
  5393                                  %endif
  5394                                  .help_common:
  5395                                  @@:
  5396 00002122 89F3                    	mov bx, si
  5397                                  @@:
  5398 00002124 AC                      	lodsb
  5399 00002125 3C61                    	cmp al, 'a'
  5400 00002127 7208                    	jb @F
  5401 00002129 3C7A                    	cmp al, 'z'
  5402 0000212B 7704                    	ja @F
  5403 0000212D 806CFF20                	sub byte [si - 1], 'a' - 'A'
  5404                                  @@:
  5405 00002131 3C5C                    	cmp al, '\'
  5406 00002133 74ED                    	je @BBB
  5407 00002135 3C2F                    	cmp al, '/'
  5408 00002137 74E9                    	je @BBB
  5409 00002139 84C0                    	test al, al
  5410 0000213B 75E7                    	jnz @BB
  5411                                  
  5412 0000213D 89F1                    	mov cx, si
  5413 0000213F 49                      	dec cx
  5414 00002140 29D9                    	sub cx, bx
  5415                                  
  5416                                  @@:
  5417 00002142 4E                      	dec si
  5418 00002143 39DE                    	cmp si, bx
  5419 00002145 7209                    	jb @F
  5420 00002147 803C2E                  	cmp byte [si], '.'
  5421 0000214A 75F6                    	jne @B
  5422                                  
  5423 0000214C 89F1                    	mov cx, si
  5424 0000214E 29D9                    	sub cx, bx
  5425                                  @@:
  5426 00002150 E332                    	jcxz .help.no_name
  5427                                  @@:
  5428 00002152 BA[0211]                	mov dx, imsg.help.1	; command-line help message
  5429 00002155 E885F9                  	call init_putsz_cs
  5430 00002158 BA[5211]                	mov dx, imsg.help.1a
  5431 0000215B E87FF9                  	call init_putsz_cs
  5432 0000215E 53                      	push bx
  5433 0000215F 89DA                    	mov dx, bx
  5434 00002161 E8BDF9                  	call init_puts_ds
  5435 00002164 BA[5C11]                	mov dx, imsg.help.2
  5436 00002167 E873F9                  	call init_putsz_cs
  5437 0000216A 5A                      	pop dx
  5438 0000216B E8B3F9                  	call init_puts_ds
  5439 0000216E BA[E415]                	mov dx, imsg.help.3
  5440 00002171 E869F9                  	call init_putsz_cs
  5441 00002174 1F                      	pop ds
  5442                                  .helpterminate:
  5443                                  %if _DEVICE && _APPLICATION
  5444 00002175 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  5445 0000217A 7403E98AEB              	jnz init_device_error_late
  5446                                  %elif _DEVICE
  5447                                  	jmp init_device_error_late
  5448                                  %endif
  5449                                  %if _APPLICATION
  5450 0000217F B8004C                  	mov ax, 4C00h
  5451 00002182 CD21                    	int 21h			; done
  5452                                  %endif
  5453                                  
  5454                                  .help.no_name:
  5455 00002184 0E                      	push cs
  5456 00002185 1F                      	pop ds
  5457 00002186 BB[FC10]                	mov bx, imsg.help.defaultfilename
  5458 00002189 B90600                  	mov cx, imsg.help.defaultfilename.length
  5459 0000218C EBC4                    	jmp @B
  5460                                  
  5461                                  
  5462                                  		; Do the (proper) switches.
  5463 0000218E AC                      .switch:lodsb
  5464 0000218F 3C3F                    	cmp al,'?'
  5465 00002191 7503E93FFF              	je .help		; if -?
  5466 00002196 E84911                  	call init_capitalise
  5467                                  %if _EXTHELP
  5468 00002199 3C55                    	cmp al, 'U'
  5469 0000219B 7503E96D10              	je switch_u
  5470                                  %endif
  5471                                  %if _CONFIG
  5472 000021A0 3C49                    	cmp al, 'I'
  5473 000021A2 7503E98400              	je .switch_i
  5474                                  %endif
  5475 000021A7 3C43                    	cmp al, 'C'
  5476 000021A9 7503E99E00              	je .switch_c
  5477 000021AE 3C50                    	cmp al, 'P'
  5478 000021B0 7503E90901              	je .switch_p
  5479 000021B5 3C46                    	cmp al, 'F'
  5480 000021B7 7503E99D01              	je .switch_f
  5481 000021BC 3C45                    	cmp al, 'E'
  5482 000021BE 7503E9C601              	je .switch_e
  5483 000021C3 3C42                    	cmp al, 'B'
  5484 000021C5 7503E9EB00              	je .switch_b
  5485 000021CA 3C41                    	cmp al, 'A'
  5486 000021CC 7503E9F605              	je .switch_a
  5487 000021D1 3C54                    	cmp al, 'T'
  5488 000021D3 7503E9A202              	je .switch_t
  5489 000021D8 3C52                    	cmp al, 'R'
  5490 000021DA 7503E9A606              	je .switch_r
  5491                                  %if _VXCHG
  5492 000021DF 3C56                    	cmp al, 'V'
  5493 000021E1 7503E9D001              	je .switch_v
  5494                                  %endif
  5495                                  %if _ALTVID
  5496 000021E6 3C32                    	cmp al, '2'
  5497 000021E8 7503E90302              	je .switch_2
  5498                                  %endif
  5499                                  %if _MCLOPT
  5500                                  	cmp al, 'M'
  5501                                  	je .switch_m
  5502                                  %endif
  5503                                  
  5504                                  %if _SYMBOLIC
  5505                                  	cmp al, 'S'
  5506                                  	je .switch_s
  5507                                  %endif
  5508                                  
  5509                                  %if 1 || (_DEBUG && _DEBUG_COND)
  5510 000021ED 3C44                    	cmp al, 'D'
  5511 000021EF 7503E9EF01              	je .switch_d
  5512                                  %endif
  5513                                  
  5514                                  %if _EXTENSIONS
  5515 000021F4 3C58                    	cmp al, 'X'
  5516 000021F6 7503E99D03              	je .switch_x
  5517 000021FB 3C59                    	cmp al, 'Y'
  5518 000021FD 7503E94D04              	je .switch_y
  5519                                  %endif
  5520                                  %if _HISTORY_SEPARATE_FIXED && _HISTORY
  5521 00002202 3C48                    	cmp al, 'H'
  5522 00002204 7503E9FE04              	je .switch_h
  5523                                  %endif
  5524                                  
  5525                                  		; Other switches may go here.
  5526 00002209 2EA2[4B16]              	mov [ cs:imsg.invalidswitch_a ], al
  5527 0000220D BA[3A16]                	mov dx, imsg.invalidswitch	; Invalid switch
  5528                                  ..@init_cmdline_error:
  5529 00002210 E8CAF8                  	call init_putsz_cs	; print string
  5530                                  %if _DEVICE && _APPLICATION
  5531 00002213 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  5532 00002218 7403E9ECEA              	jnz init_device_error_late
  5533                                  %elif _DEVICE
  5534                                  	jmp init_device_error_late
  5535                                  %endif
  5536                                  %if _APPLICATION
  5537 0000221D B8014C                  	mov ax, 4C01h		; Quit and return error status
  5538 00002220 CD21                    	int 21h
  5539                                  %endif
  5540                                  
  5541                                  ..@init_cmdline_switch_error:
  5542 00002222 2EA2[5716]              	mov byte [cs:imsg.switch_x_error_a], al
  5543 00002226 BA[4F16]                	mov dx, imsg.switch_x_error
  5544 00002229 EBE5                    	jmp ..@init_cmdline_error
  5545                                  
  5546                                  
  5547                                  %if _CONFIG
  5548                                  .switch_i:
  5549 0000222B AC                      	lodsb
  5550 0000222C 3C4E                    	cmp al, 'N'
  5551 0000222E 7408                    	je @F
  5552 00002230 3C6E                    	cmp al, 'n'
  5553 00002232 7404                    	je @F
  5554 00002234 B049                    	mov al, 'I'
  5555 00002236 EBEA                    	jmp ..@init_cmdline_switch_error
  5556                                  
  5557                                  @@:
  5558 00002238 8026[0100]FE            	clropt [internalflags3], dif3_input_cmdline
  5559 0000223D C606[0000]00            	mov byte [cmdline_buffer], 0
  5560 00002242 2EC706[3A0E][0000]      	mov word [cs:cmdline_buffer_start], cmdline_buffer
  5561 00002249 E955FE                  	jmp .blankloop
  5562                                  %endif
  5563                                  
  5564                                  .switch_c:
  5565                                  @@:
  5566 0000224C AC                      	lodsb
  5567 0000224D 3C3D                    	cmp al, '='
  5568 0000224F 74FB                    	je @B
  5569 00002251 3C3A                    	cmp al, ':'
  5570 00002253 74F7                    	je @B
  5571                                  
  5572 00002255 2E8B3E[3A0E]            	mov di, [cs:cmdline_buffer_start]
  5573 0000225A B400                    	mov ah, 0		; initialise to 0 = unquoted
  5574 0000225C A9                      	db __TEST_IMM16
  5575                                  .switch_c_loop:
  5576 0000225D AA                      	stosb
  5577                                  .switch_c_quoted:
  5578 0000225E AC                      	lodsb
  5579                                  .switch_c_loop_after_semicolon:
  5580                                  
  5581 0000225F 3C0D                    	cmp al, 13
  5582 00002261 7442                    	je .switch_c_eol
  5583 00002263 38E0                    	cmp al, ah		; close quote mark ?
  5584 00002265 7508                    	jne @F			; no -->
  5585 00002267 3C00                    	cmp al, 0
  5586 00002269 743A                    	je .switch_c_eol
  5587 0000226B B400                    	mov ah, 0		; continue unquoted
  5588 0000226D EBEF                    	jmp .switch_c_quoted	; and load next character -->
  5589                                  
  5590                                  @@:
  5591 0000226F 84E4                    	test ah, ah		; currently quoted ?
  5592 00002271 7514                    	jnz .switch_c_not_blank	; yes -->
  5593                                  
  5594 00002273 3C22                    	cmp al, '"'		; open quote mark ?
  5595 00002275 7404                    	je @F
  5596 00002277 3C27                    	cmp al, "'"
  5597 00002279 7504                    	jne @FF			; no -->
  5598                                  @@:
  5599 0000227B 88C4                    	mov ah, al		; remember quoted state
  5600 0000227D EBDF                    	jmp .switch_c_quoted	; and load next character -->
  5601                                  
  5602                                  @@:
  5603 0000227F 3C20                    	cmp al, 32		; blank while unquoted ?
  5604 00002281 7426                    	je .unquoted_blank
  5605 00002283 3C09                    	cmp al, 9
  5606 00002285 7422                    	je .unquoted_blank	; yes -->
  5607                                  .switch_c_not_blank:
  5608 00002287 3C3B                    	cmp al, ';'		; unescaped semicolon ?
  5609 00002289 750C                    	jne .switch_c_not_semicolon
  5610 0000228B B00D                    	mov al, 13		; yes, replace by CR
  5611 0000228D AA                      	stosb
  5612 0000228E 84E4                    	test ah, ah
  5613 00002290 74CC                    	jz .switch_c_quoted
  5614 00002292 E89210                  	call init_skipwhite
  5615 00002295 EBC8                    	jmp .switch_c_loop_after_semicolon
  5616                                  
  5617                                  .switch_c_not_semicolon:
  5618 00002297 3C5C                    	cmp al, '\'		; escape ?
  5619 00002299 75C2                    	jne .switch_c_loop	; no, store literal -->
  5620 0000229B AC                      	lodsb			; load escaped character
  5621                                  				;  (may be backslash, semicolon, quote)
  5622 0000229C 3C0D                    	cmp al, 13		; guard against EOL
  5623 0000229E 75BD                    	jne .switch_c_loop
  5624                                  .switch_c_error:
  5625 000022A0 B043                    	mov al, 'C'
  5626 000022A2 E97DFF                  	jmp ..@init_cmdline_switch_error
  5627                                  
  5628                                  .switch_c_eol:
  5629 000022A5 84E4                    	test ah, ah		; in quoted state ?
  5630 000022A7 75F7                    	jnz .switch_c_error	; yes, error -->
  5631                                  .unquoted_blank:
  5632 000022A9 B000                    	mov al, 0
  5633 000022AB AA                      	stosb			; terminate command line buffer
  5634 000022AC 800E[0100]01            	setopt [internalflags3], dif3_input_cmdline
  5635 000022B1 4E                      	dec si
  5636 000022B2 E9ECFD                  	jmp .blankloop
  5637                                  
  5638                                  
  5639                                  .switch_b:
  5640 000022B5 2EC606[E328]CC          	mov byte [cs:.breakpoint], 0CCh	; SMC in section init, set point
  5641 000022BB E9E3FD                  	jmp .blankloop
  5642                                  
  5643                                  
  5644                                  .switch_p:
  5645 000022BE AC                      	lodsb
  5646 000022BF E82010                  	call init_capitalise
  5647 000022C2 BBFFFF                  	mov bx, 0FFFFh		; or 0FFFFh
  5648 000022C5 89DA                    	mov dx, bx		; and 0FFFFh
  5649 000022C7 4E                      	dec si
  5650 000022C8 3C20                    	cmp al, 32
  5651 000022CA 7478                    	je @F
  5652 000022CC 3C09                    	cmp al, 9
  5653 000022CE 7474                    	je @F
  5654 000022D0 3C0D                    	cmp al, 13
  5655 000022D2 7470                    	je @F
  5656 000022D4 46                      	inc si
  5657 000022D5 3C2B                    	cmp al, '+'
  5658 000022D7 746B                    	je @F
  5659 000022D9 42                      	inc dx			; and 0000h
  5660 000022DA 3C2D                    	cmp al, '-'
  5661 000022DC 7466                    	je @F
  5662                                  
  5663                                  .switch_p_not_plusminus:
  5664 000022DE 3C53                    	cmp al, 'S'
  5665 000022E0 751E                    	jne .switch_p_not_s
  5666 000022E2 B700                    	mov bh, 00h		; or 0FFh
  5667 000022E4 4A                      	dec dx			; and 0FFFFh
  5668 000022E5 AC                      	lodsb
  5669 000022E6 4E                      	dec si
  5670 000022E7 3C20                    	cmp al, 32
  5671 000022E9 7459                    	je @F
  5672 000022EB 3C09                    	cmp al, 9
  5673 000022ED 7455                    	je @F
  5674 000022EF 3C0D                    	cmp al, 13
  5675 000022F1 7451                    	je @F
  5676 000022F3 46                      	inc si
  5677 000022F4 3C2B                    	cmp al, '+'
  5678 000022F6 744C                    	je @F
  5679 000022F8 B200                    	mov dl, 00h		; and 0FF00h
  5680 000022FA 3C2D                    	cmp al, '-'
  5681 000022FC 7446                    	je @F
  5682 000022FE EB3F                    	jmp .switch_p_error
  5683                                  
  5684                                  .switch_p_not_s:
  5685 00002300 3C45                    	cmp al, 'E'
  5686 00002302 751E                    	jne .switch_p_not_e
  5687 00002304 B300                    	mov bl, 00h		; or 0FF00h
  5688 00002306 4A                      	dec dx			; and 0FFFFh
  5689 00002307 AC                      	lodsb
  5690 00002308 4E                      	dec si
  5691 00002309 3C20                    	cmp al, 32
  5692 0000230B 7437                    	je @F
  5693 0000230D 3C09                    	cmp al, 9
  5694 0000230F 7433                    	je @F
  5695 00002311 3C0D                    	cmp al, 13
  5696 00002313 742F                    	je @F
  5697 00002315 46                      	inc si
  5698 00002316 3C2B                    	cmp al, '+'
  5699 00002318 742A                    	je @F
  5700 0000231A B600                    	mov dh, 00h		; and 00FFh
  5701 0000231C 3C2D                    	cmp al, '-'
  5702 0000231E 7424                    	je @F
  5703 00002320 EB1D                    	jmp .switch_p_error
  5704                                  
  5705                                  .switch_p_not_e:
  5706 00002322 3C57                    	cmp al, 'W'
  5707 00002324 7519                    	jne .switch_p_not_w
  5708                                  		; bl = 0FFh
  5709 00002326 AC                      	lodsb
  5710 00002327 4E                      	dec si
  5711 00002328 3C20                    	cmp al, 32
  5712 0000232A 7425                    	je @FF
  5713 0000232C 3C09                    	cmp al, 9
  5714 0000232E 7421                    	je @FF
  5715 00002330 3C0D                    	cmp al, 13
  5716 00002332 741D                    	je @FF
  5717 00002334 46                      	inc si
  5718 00002335 3C2B                    	cmp al, '+'
  5719 00002337 7418                    	je @FF
  5720 00002339 B300                    	mov bl, 00h
  5721 0000233B 3C2D                    	cmp al, '-'
  5722 0000233D 7412                    	je @FF
  5723                                  	; jmp .switch_p_error
  5724                                  
  5725                                  .switch_p_not_w:
  5726                                  .switch_p_error:
  5727 0000233F B050                    	mov al, 'P'
  5728 00002341 E9DEFE                  	jmp ..@init_cmdline_switch_error
  5729                                  @@:
  5730 00002344 2E091E[480E]            	or [cs:init_switch_p_low_pathsearch_high_guessextension], bx
  5731 00002349 2E2116[480E]            	and [cs:init_switch_p_low_pathsearch_high_guessextension], dx
  5732 0000234E E950FD                  	jmp .blankloop
  5733                                  
  5734                                  @@:
  5735 00002351 2E881E[6C0E]            	mov [cs:init_switch_pw], bl
  5736 00002356 E948FD                  	jmp .blankloop
  5737                                  
  5738                                  
  5739                                  .switch_f:
  5740 00002359 AC                      	lodsb
  5741 0000235A BB000C                  	mov bx, opt6_flat_binary + opt6_big_stack
  5742 0000235D 4E                      	dec si
  5743 0000235E 3C20                    	cmp al, 32
  5744 00002360 741B                    	je @F
  5745 00002362 3C09                    	cmp al, 9
  5746 00002364 7417                    	je @F
  5747 00002366 3C0D                    	cmp al, 13
  5748 00002368 7413                    	je @F
  5749 0000236A BB0004                  	mov bx, opt6_flat_binary
  5750 0000236D 46                      	inc si
  5751 0000236E 3C2B                    	cmp al, '+'
  5752 00002370 740B                    	je @F
  5753 00002372 31DB                    	xor bx, bx
  5754 00002374 3C2D                    	cmp al, '-'
  5755 00002376 7405                    	je @F
  5756                                  .switch_f_error:
  5757 00002378 B046                    	mov al, 'F'
  5758 0000237A E9A5FE                  	jmp ..@init_cmdline_switch_error
  5759                                  @@:
  5760 0000237D 8026[0100]FB            	clropt [options6], opt6_flat_binary
  5761 00002382 091E[0000]              	or word [options6], bx
  5762 00002386 E918FD                  	jmp .blankloop
  5763                                  
  5764                                  .switch_e:
  5765 00002389 AC                      	lodsb
  5766 0000238A BB0008                  	mov bx, opt6_big_stack
  5767 0000238D 4E                      	dec si
  5768 0000238E 3C20                    	cmp al, 32
  5769 00002390 7418                    	je @F
  5770 00002392 3C09                    	cmp al, 9
  5771 00002394 7414                    	je @F
  5772 00002396 3C0D                    	cmp al, 13
  5773 00002398 7410                    	je @F
  5774 0000239A 46                      	inc si
  5775 0000239B 3C2B                    	cmp al, '+'
  5776 0000239D 740B                    	je @F
  5777 0000239F 31DB                    	xor bx, bx
  5778 000023A1 3C2D                    	cmp al, '-'
  5779 000023A3 7405                    	je @F
  5780                                  .switch_e_error:
  5781 000023A5 B045                    	mov al, 'E'
  5782 000023A7 E978FE                  	jmp ..@init_cmdline_switch_error
  5783                                  @@:
  5784 000023AA 8026[0100]F7            	clropt [options6], opt6_big_stack
  5785 000023AF 091E[0000]              	or word [options6], bx
  5786 000023B3 E9EBFC                  	jmp .blankloop
  5787                                  
  5788                                  %if _MCLOPT
  5789                                  .switch_m:
  5790                                  	lodsb
  5791                                  	mov bl, 20h
  5792                                  	dec si
  5793                                  	cmp al, 32
  5794                                  	je @F
  5795                                  	cmp al, 9
  5796                                  	je @F
  5797                                  	cmp al, 13
  5798                                  	je @F
  5799                                  	inc si
  5800                                  	cmp al, '+'
  5801                                  	je @F
  5802                                  	mov bl, 8
  5803                                  	cmp al, '-'
  5804                                  	je @F
  5805                                  .switch_m_error:
  5806                                  	mov al, 'M'
  5807                                  	jmp ..@init_cmdline_switch_error
  5808                                  @@:
  5809                                  	mov byte [master_pic_base], bl
  5810                                  	jmp .blankloop
  5811                                  %endif
  5812                                  
  5813                                  %if _VXCHG
  5814                                  .switch_v:
  5815 000023B6 AC                      	lodsb
  5816 000023B7 BB0100                  	mov bx, opt6_vv_mode
  5817 000023BA 4E                      	dec si
  5818 000023BB 3C20                    	cmp al, 32
  5819 000023BD 7418                    	je @F
  5820 000023BF 3C09                    	cmp al, 9
  5821 000023C1 7414                    	je @F
  5822 000023C3 3C0D                    	cmp al, 13
  5823 000023C5 7410                    	je @F
  5824 000023C7 46                      	inc si
  5825 000023C8 3C2B                    	cmp al, '+'
  5826 000023CA 740B                    	je @F
  5827 000023CC 31DB                    	xor bx, bx
  5828 000023CE 3C2D                    	cmp al, '-'
  5829 000023D0 7405                    	je @F
  5830                                  .switch_v_error:
  5831 000023D2 B056                    	mov al, 'V'
  5832 000023D4 E94BFE                  	jmp ..@init_cmdline_switch_error
  5833                                  @@:
  5834 000023D7 8026[0000]FE            	clropt [options6], opt6_vv_mode
  5835 000023DC 091E[0000]              	or word [options6], bx
  5836 000023E0 E9BEFC                  	jmp .blankloop
  5837                                  %endif
  5838                                  
  5839                                  %if _DEBUG && _DEBUG_COND
  5840                                  .switch_d:
  5841                                  	lodsb
  5842                                  	mov bx, dif6_debug_mode
  5843                                  	dec si
  5844                                  	cmp al, 32
  5845                                  	je @F
  5846                                  	cmp al, 9
  5847                                  	je @F
  5848                                  	cmp al, 13
  5849                                  	je @F
  5850                                  	inc si
  5851                                  	cmp al, '+'
  5852                                  	je @F
  5853                                  	xor bx, bx
  5854                                  	cmp al, '-'
  5855                                  	je @F
  5856                                  .switch_d_error:
  5857                                  	mov al, 'D'
  5858                                  	jmp ..@init_cmdline_switch_error
  5859                                  @@:
  5860                                  	clropt [internalflags6], dif6_debug_mode
  5861                                  	clropt [options6], opt6_debug_mode
  5862                                  	or word [internalflags6], bx
  5863                                  	or word [options6], bx
  5864                                   %if dif6_debug_mode != opt6_debug_mode
  5865                                    %error Mismatch of flag and option
  5866                                   %endif
  5867                                  	jmp .blankloop
  5868                                  %else
  5869                                  .switch_d:
  5870 000023E3 AC                      	lodsb
  5871                                   %if _DEBUG
  5872                                  	dec si
  5873                                  	cmp al, 32
  5874                                  	je @F
  5875                                  	cmp al, 9
  5876                                  	je @F
  5877                                  	cmp al, 13
  5878                                  	je @F
  5879                                  	inc si
  5880                                  	cmp al, '+'
  5881                                  @@:
  5882                                   %else
  5883 000023E4 3C2D                    	cmp al, '-'
  5884                                   %endif
  5885 000023E6 7503E9B6FC              	je .blankloop
  5886 000023EB B044                    	mov al, 'D'
  5887 000023ED E932FE                  	jmp ..@init_cmdline_switch_error
  5888                                  %endif
  5889                                  
  5890                                  
  5891                                  %if _ALTVID
  5892                                  .switch_2:
  5893 000023F0 AC                      	lodsb
  5894 000023F1 B31E                    	mov bl, 1Eh			; "push ds"
  5895 000023F3 4E                      	dec si
  5896 000023F4 3C20                    	cmp al, 32
  5897 000023F6 7418                    	je @F
  5898 000023F8 3C09                    	cmp al, 9
  5899 000023FA 7414                    	je @F
  5900 000023FC 3C0D                    	cmp al, 13
  5901 000023FE 7410                    	je @F
  5902 00002400 46                      	inc si
  5903 00002401 3C2B                    	cmp al, '+'
  5904 00002403 740B                    	je @F
  5905 00002405 B3C3                    	mov bl, 0C3h			; "retn"
  5906 00002407 3C2D                    	cmp al, '-'
  5907 00002409 7405                    	je @F
  5908                                  .switch_2_error:
  5909 0000240B B032                    	mov al, '2'
  5910 0000240D E912FE                  	jmp ..@init_cmdline_switch_error
  5911                                  @@:
  5912 00002410 8E06[0000]              	mov es, [code_seg]
  5913 00002414 26881E[0000]            	mov byte [es:setscreen], bl
  5914 00002419 16                      	push ss
  5915 0000241A 07                      	pop es
  5916 0000241B 80FBC3                  	cmp bl, 0C3h
  5917 0000241E 7445                    	je .noaltvid
  5918 00002420 B8001A                  	mov ax, 1A00h
  5919 00002423 CD10                    	int 10h
  5920 00002425 3C1A                    	cmp al, 1Ah
  5921 00002427 753C                    	jnz .noaltvid
  5922 00002429 80FF00                  	cmp bh, 0
  5923 0000242C 7437                    	jz .noaltvid
  5924                                  
  5925 0000242E 1E                      	push ds
  5926 0000242F B84000                  	mov ax, 40h
  5927 00002432 8ED8                    	mov ds, ax
  5928 00002434 8B166300                	mov dx, [63h]
  5929 00002438 1F                      	pop ds
  5930 00002439 80F260                  	xor dl, 60h
  5931 0000243C 8916[0000]              	mov [oldcrtp], dx
  5932 00002440 B007                    	mov al, 7
  5933 00002442 80FAB4                  	cmp dl, 0B4h
  5934 00002445 7402                    	jz @F
  5935 00002447 B003                    	mov al, 3
  5936                                  @@:
  5937 00002449 A2[0000]                	mov [oldmode], al
  5938 0000244C B00E                    	mov al, 0Eh
  5939 0000244E EE                      	out dx, al
  5940 0000244F 42                      	inc dx
  5941 00002450 EC                      	in al, dx
  5942 00002451 88C4                    	mov ah, al
  5943 00002453 4A                      	dec dx
  5944 00002454 B00F                    	mov al, 0Fh
  5945 00002456 EE                      	out dx, al
  5946 00002457 42                      	inc dx
  5947 00002458 EC                      	in al, dx
  5948 00002459 B350                    	mov bl, 80
  5949 0000245B F6F3                    	div bl
  5950 0000245D 86C4                    	xchg al, ah
  5951 0000245F A3[0000]                	mov [oldcsrpos], ax
  5952 00002462 E93CFC                  	jmp .blankloop
  5953                                  
  5954                                  .noaltvid:
  5955 00002465 BA[C310]                	mov dx, imsg.noaltvid
  5956 00002468 E872F6                  	call init_putsz_cs
  5957 0000246B 8E06[0000]              	mov es, [code_seg]
  5958 0000246F 26C606[0000]C3          	mov byte [es:setscreen], 0C3h
  5959 00002475 16                      	push ss
  5960 00002476 07                      	pop es
  5961 00002477 E927FC                  	jmp .blankloop
  5962                                  %endif
  5963                                  
  5964                                  
  5965                                  %if _SYMBOLIC
  5966                                  .switch_s:
  5967                                  	mov dx, si
  5968                                  	lodsb
  5969                                  	mov ah, 0		; flag for not quoted
  5970                                  	cmp al, '"'
  5971                                  	je .s_quoted
  5972                                  	cmp al, "'"
  5973                                  	jne .s_unquoted
  5974                                  .s_quoted:
  5975                                  	mov ah, al		; save away our quote mark
  5976                                  	inc dx			; -> behind the quote mark
  5977                                  @@:
  5978                                  	lodsb
  5979                                  	cmp al, 13
  5980                                  	je .switch_s_error
  5981                                  	cmp al, 0
  5982                                  	je .switch_s_error
  5983                                  	cmp al, ah		; closing quote mark ?
  5984                                  	jne @B			; not yet -->
  5985                                  	jmp .s_end
  5986                                  
  5987                                  	db __TEST_IMM8		; (skip lodsb)
  5988                                  @@:
  5989                                  	lodsb
  5990                                  .s_unquoted:
  5991                                  	cmp al, 32
  5992                                  	ja @B
  5993                                  
  5994                                  .s_end:
  5995                                  	dec si			; -> blank or terminator or closing quote
  5996                                  	push ax
  5997                                  	push si
  5998                                  	mov byte [si], 13	; put in a CR for good measure
  5999                                  	mov si, dx
  6000                                  
  6001                                  	push word [errret]
  6002                                  	push word [throwret]
  6003                                  	push word [throwsp]
  6004                                  
  6005                                  	push cs
  6006                                  	call .jump
  6007                                  
  6008                                  	pop word [throwsp]
  6009                                  	pop word [throwret]	; restore throw destination
  6010                                  	pop word [errret]
  6011                                  	pop si
  6012                                  	pop ax
  6013                                  	mov byte [si], al	; restore if it wasn't CR
  6014                                  		; si -> next character to process
  6015                                  	test dx, dx
  6016                                  	jz @F
  6017                                  
  6018                                  	cmp dx, si
  6019                                  	je @F
  6020                                  
  6021                                  	mov dx, imsg.switch_s_garbage
  6022                                  	call init_putsz_cs
  6023                                  
  6024                                  @@:
  6025                                  	test ah, ah		; was quoted ?
  6026                                  	jz @F			; no -->
  6027                                  	inc si			; skip closing quote mark
  6028                                  @@:
  6029                                  	jmp .blankloop
  6030                                  
  6031                                  .switch_s_error:
  6032                                  	mov al, 'S'
  6033                                  	jmp ..@init_cmdline_switch_error
  6034                                  
  6035                                  .jump:
  6036                                  	mov word [errret], ..@switch_s_catch
  6037                                  	mov word [throwret], ..@switch_s_catch
  6038                                  	mov word [throwsp], sp
  6039                                  
  6040                                  	mov ax, ..@switch_s_cont
  6041                                  	push word [code_seg]
  6042                                  	push ax
  6043                                  	retf
  6044                                  %endif
  6045                                  
  6046                                  
  6047                                  	usesection INIT
  6047          ------------------       note: usesection INIT
  6048                                  
  6049                                  .switch_t:
  6050 0000247A B3FF                    	mov bl, 0FFh
  6051 0000247C 31FF                    	xor di, di
  6052                                  .switch_t_loop:
  6053                                  @@:
  6054 0000247E AC                      	lodsb
  6055 0000247F 3C3D                    	cmp al, '='
  6056 00002481 74FB                    	je @B
  6057 00002483 3C3A                    	cmp al, ':'
  6058 00002485 74F7                    	je @B
  6059 00002487 3C2C                    	cmp al, ','
  6060 00002489 74F3                    	je @B
  6061 0000248B 4E                      	dec si
  6062 0000248C 3C20                    	cmp al, 32
  6063 0000248E 7503E9A800              	je @F
  6064 00002493 3C09                    	cmp al, 9
  6065 00002495 7503E9A100              	je @F
  6066 0000249A 3C0D                    	cmp al, 13
  6067 0000249C 7503E99A00              	je @F
  6068 000024A1 46                      	inc si
  6069 000024A2 3C2B                    	cmp al, '+'
  6070 000024A4 7503E98C00              	je .switch_t_set
  6071 000024A9 3C2D                    	cmp al, '-'
  6072 000024AB 7503E98900              	je .switch_t_clear
  6073                                  
  6074 000024B0 2E8A1E[6D0E]            	mov bl, byte [cs:init_switch_t]
  6075 000024B5 E82A0E                  	call init_capitalise
  6076 000024B8 3C49                    	cmp al, 'I'		; ignore ?
  6077 000024BA 7508                    	jne .t_notignore
  6078 000024BC 2EC606[6E0E]FF          	mov byte [cs:init_switch_t_ignore], 0FFh
  6079 000024C2 EBBA                    	jmp @B
  6080                                  
  6081                                  .t_notignore:
  6082 000024C4 3C4F                    	cmp al, 'O'		; only ?
  6083 000024C6 7508                    	jne .t_notonly
  6084 000024C8 2EC606[6E0E]00          	mov byte [cs:init_switch_t_ignore], 0
  6085 000024CE EBAE                    	jmp @B
  6086                                  
  6087                                  .t_notonly:
  6088 000024D0 3C50                    	cmp al, 'P'		; point ?
  6089 000024D2 7508                    	jne .t_notpoint
  6090 000024D4 2EC606[6F0E]FF          	mov byte [cs:init_switch_t_break], 0FFh
  6091 000024DA EBA2                    	jmp @B
  6092                                  
  6093                                  .t_notpoint:
  6094 000024DC 3C56                    	cmp al, 'V'		; variable ?
  6095 000024DE 7508                    	jne .t_notvar
  6096 000024E0 2EC606[700E]FF          	mov byte [cs:init_switch_t_variable], 0FFh
  6097 000024E6 EB96                    	jmp @B
  6098                                  
  6099                                  .t_notvar:
  6100 000024E8 3C55                    	cmp al, 'U'		; enable UMA ?
  6101 000024EA 7509                    	jne .t_notupper
  6102 000024EC 2EC785[540E]0100        	mov word [cs:init_switch_t_umblink + di], 1
  6103 000024F3 EB89                    	jmp @B
  6104                                  
  6105                                  .t_notupper:
  6106 000024F5 3C4C                    	cmp al, 'L'		; restrict to LMA ?
  6107 000024F7 750A                    	jne .t_notlower
  6108 000024F9 2EC785[540E]0000        	mov word [cs:init_switch_t_umblink + di], 0
  6109 00002500 E97BFF                  	jmp @B
  6110                                  
  6111                                  .t_notlower:
  6112 00002503 3C58                    	cmp al, 'X'
  6113 00002505 7505                    	jne .t_not_x
  6114 00002507 31FF                    	xor di, di
  6115 00002509 E972FF                  	jmp @B
  6116                                  
  6117                                  .t_not_x:
  6118 0000250C 3C59                    	cmp al, 'Y'
  6119 0000250E 7506                    	jne .t_not_y
  6120 00002510 BF0200                  	mov di, 2
  6121 00002513 E968FF                  	jmp @B
  6122                                  
  6123                                  .t_not_y:
  6124 00002516 3C5A                    	cmp al, 'Z'
  6125 00002518 7506                    	jne .t_not_z
  6126 0000251A BF0400                  	mov di, 4
  6127 0000251D E95EFF                  	jmp @B
  6128                                  
  6129                                  .t_not_z:
  6130 00002520 3C30                    	cmp al, '0'
  6131 00002522 720C                    	jb .switch_t_error
  6132 00002524 3C39                    	cmp al, '9'
  6133 00002526 7626                    	jbe .switch_t_numeric
  6134 00002528 3C41                    	cmp al, 'A'
  6135 0000252A 7204                    	jb .switch_t_error
  6136 0000252C 3C46                    	cmp al, 'F'
  6137 0000252E 761E                    	jbe .switch_t_numeric
  6138                                  .switch_t_error:
  6139 00002530 B054                    	mov al, 'T'
  6140 00002532 E9EDFC                  	jmp ..@init_cmdline_switch_error
  6141                                  
  6142                                  .switch_t_set:
  6143 00002535 B3FF                    	mov bl, 0FFh
  6144 00002537 EB02                    	jmp @F
  6145                                  
  6146                                  .switch_t_clear:
  6147 00002539 31DB                    	xor bx, bx
  6148                                  
  6149                                  @@:
  6150                                  %if _DEVICE
  6151 0000253B 84DB                    	test bl, bl
  6152 0000253D 7407                    	jz @F
  6153 0000253F F606[0200]40            	testopt [internalflags6], dif6_device_mode
  6154 00002544 75EA                    	jnz .switch_t_error
  6155                                  @@:
  6156                                  %endif
  6157 00002546 2E881E[6D0E]            	mov byte [cs:init_switch_t], bl
  6158 0000254B E953FB                  	jmp .blankloop
  6159                                  
  6160                                  .switch_t_numeric:
  6161 0000254E 31D2                    	xor dx, dx
  6162 00002550 A8                      	db __TEST_IMM8		; (skip lodsb)
  6163                                  @@:
  6164 00002551 AC                      	lodsb
  6165 00002552 3C2C                    	cmp al, ','
  6166 00002554 7439                    	je @F
  6167 00002556 3C20                    	cmp al, 32
  6168 00002558 7435                    	je @F
  6169 0000255A 3C09                    	cmp al, 9
  6170 0000255C 7431                    	je @F
  6171 0000255E 3C0D                    	cmp al, 13
  6172 00002560 742D                    	je @F
  6173 00002562 E87D0D                  	call init_capitalise
  6174 00002565 B400                    	mov ah, 0
  6175 00002567 3C30                    	cmp al, '0'			; decimal digit ?
  6176 00002569 72C5                    	jb .switch_t_error
  6177 0000256B 3C39                    	cmp al, '9'
  6178 0000256D 7714                    	ja .switch_t_notdec
  6179 0000256F 2C30                    	sub al, '0'			; ax = digit
  6180                                  .switch_t_gotdigit:
  6181 00002571 81FA0010                	cmp dx, 1000h
  6182 00002575 73B9                    	jae .switch_t_error
  6183 00002577 01D2                    	add dx, dx
  6184 00002579 01D2                    	add dx, dx
  6185 0000257B 01D2                    	add dx, dx
  6186 0000257D 01D2                    	add dx, dx			; * 16
  6187 0000257F 01C2                    	add dx, ax
  6188 00002581 EBCE                    	jmp @B
  6189                                  
  6190                                  .switch_t_notdec:
  6191 00002583 3C41                    	cmp al, 'A'			; alphabetic ?
  6192 00002585 72A9                    	jb .switch_t_error
  6193 00002587 3C46                    	cmp al, 'F'
  6194 00002589 77A5                    	ja .switch_t_error
  6195 0000258B 04C9                    	add al, 10 - 'A'		; ax = digit
  6196 0000258D EBE2                    	jmp .switch_t_gotdigit
  6197                                  
  6198                                  @@:
  6199 0000258F 2E8995[5A0E]            	mov word [cs:init_switch_t_strategy + di], dx
  6200 00002594 4E                      	dec si
  6201 00002595 E9E6FE                  	jmp .switch_t_loop
  6202                                  
  6203                                  %if _EXTENSIONS
  6204                                  .switch_x:
  6205 00002598 BBF0FF                  	mov bx, _EXT_CODE_SIZE
  6206 0000259B AC                      	lodsb
  6207 0000259C 3C09                    	cmp al, 9
  6208 0000259E 7503E9A100              	je .switch_x_got
  6209 000025A3 3C20                    	cmp al, 32
  6210 000025A5 7503E99A00              	je .switch_x_got
  6211 000025AA 3C0D                    	cmp al, 13
  6212 000025AC 7503E99300              	je .switch_x_got
  6213 000025B1 3C3A                    	cmp al, ':'
  6214 000025B3 7404                    	je @F
  6215 000025B5 3C3D                    	cmp al, '='
  6216 000025B7 7501                    	jne @FF
  6217                                  @@:
  6218 000025B9 AC                      	lodsb
  6219                                  @@:
  6220 000025BA 4E                      	dec si
  6221 000025BB 0E                      	push cs
  6222 000025BC 07                      	pop es
  6223 000025BD BA[280F]                	mov dx, imsg.max
  6224 000025C0 E8C90C                  	call init_isstring?
  6225 000025C3 747E                    	je .switch_x_got.lodsb
  6226 000025C5 BB0000                  	mov bx, 0
  6227 000025C8 BA[2C0F]                	mov dx, imsg.min
  6228 000025CB E8BE0C                  	call init_isstring?
  6229 000025CE 7473                    	je .switch_x_got.lodsb
  6230 000025D0 BB0040                  	mov bx, _EXT_CODE_DEFAULT_SIZE
  6231 000025D3 BA[300F]                	mov dx, imsg.default
  6232 000025D6 E8B30C                  	call init_isstring?
  6233 000025D9 7468                    	je .switch_x_got.lodsb
  6234                                  
  6235 000025DB BA1000                  	mov dx, 16
  6236 000025DE 803C23                  	cmp byte [si], '#'
  6237 000025E1 7503                    	jne .switch_x_zero
  6238 000025E3 46                      	inc si
  6239 000025E4 B20A                    	mov dl, 10
  6240                                  .switch_x_zero:
  6241 000025E6 31DB                    	xor bx, bx
  6242                                  .switch_x_num:
  6243 000025E8 AC                      	lodsb
  6244 000025E9 3C20                    	cmp al, 32			; end of number ?
  6245 000025EB 7450                    	je .switch_x_check
  6246 000025ED 3C09                    	cmp al, 9
  6247 000025EF 744C                    	je .switch_x_check
  6248 000025F1 3C0D                    	cmp al, 13
  6249 000025F3 7448                    	je .switch_x_check		; yes -->
  6250 000025F5 3C5F                    	cmp al, '_'			; separator ?
  6251 000025F7 74EF                    	je .switch_x_num
  6252 000025F9 3C23                    	cmp al, '#'			; base change ?
  6253 000025FB 7432                    	je .switch_x_base
  6254 000025FD E8E20C                  	call init_capitalise
  6255 00002600 B400                    	mov ah, 0
  6256 00002602 3C30                    	cmp al, '0'			; decimal digit ?
  6257 00002604 7224                    	jb .switch_x_error
  6258 00002606 3C39                    	cmp al, '9'
  6259 00002608 7712                    	ja .switch_x_notdec
  6260 0000260A 2C30                    	sub al, '0'			; ax = digit
  6261                                  .switch_x_gotdigit:
  6262 0000260C 93                      	xchg ax, bx			; ax = prior
  6263 0000260D 52                      	push dx
  6264 0000260E F7E2                    	mul dx				; dx:ax = prior * base
  6265 00002610 85D2                    	test dx, dx			; >= 64 KiB ?
  6266 00002612 7516                    	jnz .switch_x_error		; error -->
  6267 00002614 5A                      	pop dx
  6268 00002615 93                      	xchg bx, ax			; return bx = prior
  6269 00002616 01C3                    	add bx, ax			; prior += next
  6270 00002618 7210                    	jc .switch_x_error
  6271 0000261A EBCC                    	jmp .switch_x_num
  6272                                  
  6273                                  .switch_x_notdec:
  6274 0000261C 3C41                    	cmp al, 'A'			; alphabetic ?
  6275 0000261E 720A                    	jb .switch_x_error
  6276 00002620 3C5A                    	cmp al, 'Z'
  6277 00002622 7706                    	ja .switch_x_error
  6278 00002624 04C9                    	add al, 10 - 'A'		; ax = digit
  6279 00002626 39D0                    	cmp ax, dx
  6280 00002628 72E2                    	jb .switch_x_gotdigit
  6281                                  	; jae .switch_x_error
  6282                                  .switch_x_error:
  6283                                  ..@init_cmdline_switch_x_error:
  6284 0000262A B058                    	mov al, 'X'
  6285 0000262C E9F3FB                  	jmp ..@init_cmdline_switch_error
  6286                                  
  6287                                  .switch_x_base:
  6288 0000262F 83FB02                  	cmp bx, 2
  6289 00002632 72F6                    	jb .switch_x_error
  6290 00002634 83FB24                  	cmp bx, 36
  6291 00002637 77F1                    	ja .switch_x_error
  6292 00002639 89DA                    	mov dx, bx
  6293 0000263B EBA9                    	jmp .switch_x_zero
  6294                                  
  6295                                  .switch_x_check:
  6296 0000263D 83FBF0                  	cmp bx, _EXT_CODE_SIZE
  6297 00002640 77E8                    	ja .switch_x_error
  6298                                  
  6299 00002642 A8                      	db __TEST_IMM8			; (skip lodsb)
  6300                                  .switch_x_got.lodsb:
  6301 00002643 AC                      	lodsb
  6302                                  .switch_x_got:
  6303 00002644 1E                      	push ds
  6304 00002645 07                      	pop es
  6305 00002646 2E891E[420E]            	mov word [cs:init_ext_want], bx
  6306 0000264B 4E                      	dec si
  6307 0000264C E952FA                  	jmp .blankloop
  6308                                  
  6309                                  
  6310                                  .switch_y:
  6311                                  %ifn _LINK
  6312                                  	mov bx, ext_data_max_size_equate
  6313                                  %else
  6314 0000264F BB[F0FF]                	mov bx, relocatedzero + 0FFF0h
  6315                                   wlcalc word_minusext_ext_data_area, equ $ - 2
  6316                                  %endif
  6317 00002652 AC                      	lodsb
  6318 00002653 3C09                    	cmp al, 9
  6319 00002655 7503E9A200              	je .switch_y_got
  6320 0000265A 3C20                    	cmp al, 32
  6321 0000265C 7503E99B00              	je .switch_y_got
  6322 00002661 3C0D                    	cmp al, 13
  6323 00002663 7503E99400              	je .switch_y_got
  6324 00002668 3C3A                    	cmp al, ':'
  6325 0000266A 7404                    	je @F
  6326 0000266C 3C3D                    	cmp al, '='
  6327 0000266E 7501                    	jne @FF
  6328                                  @@:
  6329 00002670 AC                      	lodsb
  6330                                  @@:
  6331 00002671 4E                      	dec si
  6332 00002672 0E                      	push cs
  6333 00002673 07                      	pop es
  6334 00002674 BA[280F]                	mov dx, imsg.max
  6335 00002677 E8120C                  	call init_isstring?
  6336 0000267A 747F                    	je .switch_y_got.lodsb
  6337 0000267C BB0000                  	mov bx, 0
  6338 0000267F BA[2C0F]                	mov dx, imsg.min
  6339 00002682 E8070C                  	call init_isstring?
  6340 00002685 7474                    	je .switch_y_got.lodsb
  6341 00002687 BB0040                  	mov bx, _EXT_DATA_DEFAULT_SIZE
  6342 0000268A BA[300F]                	mov dx, imsg.default
  6343 0000268D E8FC0B                  	call init_isstring?
  6344 00002690 7469                    	je .switch_y_got.lodsb
  6345                                  
  6346 00002692 BA1000                  	mov dx, 16
  6347 00002695 803C23                  	cmp byte [si], '#'
  6348 00002698 7503                    	jne .switch_y_zero
  6349 0000269A 46                      	inc si
  6350 0000269B B20A                    	mov dl, 10
  6351                                  .switch_y_zero:
  6352 0000269D 31DB                    	xor bx, bx
  6353                                  .switch_y_num:
  6354 0000269F AC                      	lodsb
  6355 000026A0 3C20                    	cmp al, 32			; end of number ?
  6356 000026A2 7450                    	je .switch_y_check
  6357 000026A4 3C09                    	cmp al, 9
  6358 000026A6 744C                    	je .switch_y_check
  6359 000026A8 3C0D                    	cmp al, 13
  6360 000026AA 7448                    	je .switch_y_check		; yes -->
  6361 000026AC 3C5F                    	cmp al, '_'			; separator ?
  6362 000026AE 74EF                    	je .switch_y_num
  6363 000026B0 3C23                    	cmp al, '#'			; base change ?
  6364 000026B2 7432                    	je .switch_y_base
  6365 000026B4 E82B0C                  	call init_capitalise
  6366 000026B7 B400                    	mov ah, 0
  6367 000026B9 3C30                    	cmp al, '0'			; decimal digit ?
  6368 000026BB 7224                    	jb .switch_y_error
  6369 000026BD 3C39                    	cmp al, '9'
  6370 000026BF 7712                    	ja .switch_y_notdec
  6371 000026C1 2C30                    	sub al, '0'			; ax = digit
  6372                                  .switch_y_gotdigit:
  6373 000026C3 93                      	xchg ax, bx			; ax = prior
  6374 000026C4 52                      	push dx
  6375 000026C5 F7E2                    	mul dx				; dx:ax = prior * base
  6376 000026C7 85D2                    	test dx, dx			; >= 64 KiB ?
  6377 000026C9 7516                    	jnz .switch_y_error		; error -->
  6378 000026CB 5A                      	pop dx
  6379 000026CC 93                      	xchg bx, ax			; return bx = prior
  6380 000026CD 01C3                    	add bx, ax			; prior += next
  6381 000026CF 7210                    	jc .switch_y_error
  6382 000026D1 EBCC                    	jmp .switch_y_num
  6383                                  
  6384                                  .switch_y_notdec:
  6385 000026D3 3C41                    	cmp al, 'A'			; alphabetic ?
  6386 000026D5 720A                    	jb .switch_y_error
  6387 000026D7 3C5A                    	cmp al, 'Z'
  6388 000026D9 7706                    	ja .switch_y_error
  6389 000026DB 04C9                    	add al, 10 - 'A'		; ax = digit
  6390 000026DD 39D0                    	cmp ax, dx
  6391 000026DF 72E2                    	jb .switch_y_gotdigit
  6392                                  	; jae .switch_y_error
  6393                                  .switch_y_error:
  6394                                  ..@init_cmdline_switch_y_error:
  6395 000026E1 B059                    	mov al, 'Y'
  6396 000026E3 E93CFB                  	jmp ..@init_cmdline_switch_error
  6397                                  
  6398                                  .switch_y_base:
  6399 000026E6 83FB02                  	cmp bx, 2
  6400 000026E9 72F6                    	jb .switch_y_error
  6401 000026EB 83FB24                  	cmp bx, 36
  6402 000026EE 77F1                    	ja .switch_y_error
  6403 000026F0 89DA                    	mov dx, bx
  6404 000026F2 EBA9                    	jmp .switch_y_zero
  6405                                  
  6406                                  .switch_y_check:
  6407                                  %ifn _LINK
  6408                                  	cmp bx, ext_data_max_size_equate
  6409                                  %else
  6410 000026F4 81FB[F0FF]              	cmp bx, strict word relocatedzero + 0FFF0h
  6411                                   wlcalc word_minusext_ext_data_area, equ $ - 2
  6412                                  %endif
  6413 000026F8 77E7                    	ja .switch_y_error
  6414                                  
  6415 000026FA A8                      	db __TEST_IMM8			; (skip lodsb)
  6416                                  .switch_y_got.lodsb:
  6417 000026FB AC                      	lodsb
  6418                                  .switch_y_got:
  6419 000026FC 1E                      	push ds
  6420 000026FD 07                      	pop es
  6421 000026FE 2E891E[440E]            	mov word [cs:init_extdata_want], bx
  6422 00002703 4E                      	dec si
  6423 00002704 E99AF9                  	jmp .blankloop
  6424                                  %endif
  6425                                  
  6426                                  
  6427                                  %if _HISTORY_SEPARATE_FIXED && _HISTORY
  6428                                  .switch_h:
  6429 00002707 BBF0FF                  	mov bx, 0FFF0h
  6430 0000270A AC                      	lodsb
  6431 0000270B 3C09                    	cmp al, 9
  6432 0000270D 7503E9AA00              	je .switch_h_got
  6433 00002712 3C20                    	cmp al, 32
  6434 00002714 7503E9A300              	je .switch_h_got
  6435 00002719 3C0D                    	cmp al, 13
  6436 0000271B 7503E99C00              	je .switch_h_got
  6437 00002720 3C3A                    	cmp al, ':'
  6438 00002722 7404                    	je @F
  6439 00002724 3C3D                    	cmp al, '='
  6440 00002726 7501                    	jne @FF
  6441                                  @@:
  6442 00002728 AC                      	lodsb
  6443                                  @@:
  6444 00002729 4E                      	dec si
  6445 0000272A 0E                      	push cs
  6446 0000272B 07                      	pop es
  6447 0000272C BA[280F]                	mov dx, imsg.max
  6448 0000272F E85A0B                  	call init_isstring?
  6449 00002732 7503E98400              	je .switch_h_got.lodsb
  6450 00002737 BB0401                  	mov bx, 260
  6451 0000273A BA[2C0F]                	mov dx, imsg.min
  6452 0000273D E84C0B                  	call init_isstring?
  6453 00002740 7479                    	je .switch_h_got.lodsb
  6454 00002742 BB0020                  	mov bx, _HISTORY_WANT_SIZE
  6455 00002745 BA[300F]                	mov dx, imsg.default
  6456 00002748 E8410B                  	call init_isstring?
  6457 0000274B 746E                    	je .switch_h_got.lodsb
  6458                                  
  6459 0000274D BA1000                  	mov dx, 16
  6460 00002750 803C23                  	cmp byte [si], '#'
  6461 00002753 7503                    	jne .switch_h_zero
  6462 00002755 46                      	inc si
  6463 00002756 B20A                    	mov dl, 10
  6464                                  .switch_h_zero:
  6465 00002758 31DB                    	xor bx, bx
  6466                                  .switch_h_num:
  6467 0000275A AC                      	lodsb
  6468 0000275B 3C20                    	cmp al, 32			; end of number ?
  6469 0000275D 7450                    	je .switch_h_check
  6470 0000275F 3C09                    	cmp al, 9
  6471 00002761 744C                    	je .switch_h_check
  6472 00002763 3C0D                    	cmp al, 13
  6473 00002765 7448                    	je .switch_h_check		; yes -->
  6474 00002767 3C5F                    	cmp al, '_'			; separator ?
  6475 00002769 74EF                    	je .switch_h_num
  6476 0000276B 3C23                    	cmp al, '#'			; base change ?
  6477 0000276D 7432                    	je .switch_h_base
  6478 0000276F E8700B                  	call init_capitalise
  6479 00002772 B400                    	mov ah, 0
  6480 00002774 3C30                    	cmp al, '0'			; decimal digit ?
  6481 00002776 7224                    	jb .switch_h_error
  6482 00002778 3C39                    	cmp al, '9'
  6483 0000277A 7712                    	ja .switch_h_notdec
  6484 0000277C 2C30                    	sub al, '0'			; ax = digit
  6485                                  .switch_h_gotdigit:
  6486 0000277E 93                      	xchg ax, bx			; ax = prior
  6487 0000277F 52                      	push dx
  6488 00002780 F7E2                    	mul dx				; dx:ax = prior * base
  6489 00002782 85D2                    	test dx, dx			; >= 64 KiB ?
  6490 00002784 7516                    	jnz .switch_h_error		; error -->
  6491 00002786 5A                      	pop dx
  6492 00002787 93                      	xchg bx, ax			; return bx = prior
  6493 00002788 01C3                    	add bx, ax			; prior += next
  6494 0000278A 7210                    	jc .switch_h_error
  6495 0000278C EBCC                    	jmp .switch_h_num
  6496                                  
  6497                                  .switch_h_notdec:
  6498 0000278E 3C41                    	cmp al, 'A'			; alphabetic ?
  6499 00002790 720A                    	jb .switch_h_error
  6500 00002792 3C5A                    	cmp al, 'Z'
  6501 00002794 7706                    	ja .switch_h_error
  6502 00002796 04C9                    	add al, 10 - 'A'		; ax = digit
  6503 00002798 39D0                    	cmp ax, dx
  6504 0000279A 72E2                    	jb .switch_h_gotdigit
  6505                                  	; jae .switch_h_error
  6506                                  .switch_h_error:
  6507                                  ..@init_cmdline_switch_h_error:
  6508 0000279C B048                    	mov al, 'H'
  6509 0000279E E981FA                  	jmp ..@init_cmdline_switch_error
  6510                                  
  6511                                  .switch_h_base:
  6512 000027A1 83FB02                  	cmp bx, 2
  6513 000027A4 72F6                    	jb .switch_h_error
  6514 000027A6 83FB24                  	cmp bx, 36
  6515 000027A9 77F1                    	ja .switch_h_error
  6516 000027AB 89DA                    	mov dx, bx
  6517 000027AD EBA9                    	jmp .switch_h_zero
  6518                                  
  6519                                  .switch_h_check:
  6520 000027AF 83FBF0                  	cmp bx, 0FFF0h
  6521 000027B2 77E8                    	ja .switch_h_error
  6522 000027B4 81FB0401                	cmp bx, 260
  6523 000027B8 72E2                    	jb .switch_h_error
  6524                                  
  6525 000027BA A8                      	db __TEST_IMM8			; (skip lodsb)
  6526                                  .switch_h_got.lodsb:
  6527 000027BB AC                      	lodsb
  6528                                  .switch_h_got:
  6529 000027BC 1E                      	push ds
  6530 000027BD 07                      	pop es
  6531 000027BE 2E891E[460E]            	mov word [cs:init_history_want], bx
  6532 000027C3 4E                      	dec si
  6533 000027C4 E9DAF8                  	jmp .blankloop
  6534                                  %endif
  6535                                  
  6536                                  
  6537                                  .switch_a:
  6538 000027C7 BB0060                  	mov bx, _AUXBUFFMAXSIZE
  6539 000027CA AC                      	lodsb
  6540 000027CB 3C09                    	cmp al, 9
  6541 000027CD 7503E9A800              	je .switch_a_got
  6542 000027D2 3C20                    	cmp al, 32
  6543 000027D4 7503E9A100              	je .switch_a_got
  6544 000027D9 3C0D                    	cmp al, 13
  6545 000027DB 7503E99A00              	je .switch_a_got
  6546 000027E0 3C3A                    	cmp al, ':'
  6547 000027E2 7404                    	je @F
  6548 000027E4 3C3D                    	cmp al, '='
  6549 000027E6 7501                    	jne @FF
  6550                                  @@:
  6551 000027E8 AC                      	lodsb
  6552                                  @@:
  6553 000027E9 4E                      	dec si
  6554 000027EA 0E                      	push cs
  6555 000027EB 07                      	pop es
  6556 000027EC BA[280F]                	mov dx, imsg.max
  6557 000027EF E89A0A                  	call init_isstring?
  6558 000027F2 7503E98200              	je .switch_a_got.lodsb
  6559 000027F7 BB1020                  	mov bx, _AUXBUFFSIZE
  6560 000027FA BA[2C0F]                	mov dx, imsg.min
  6561 000027FD E88C0A                  	call init_isstring?
  6562 00002800 7477                    	je .switch_a_got.lodsb
  6563                                  	; default == minimum
  6564 00002802 BA[300F]                	mov dx, imsg.default
  6565 00002805 E8840A                  	call init_isstring?
  6566 00002808 746F                    	je .switch_a_got.lodsb
  6567                                  
  6568 0000280A BA1000                  	mov dx, 16
  6569 0000280D 803C23                  	cmp byte [si], '#'
  6570 00002810 7503                    	jne .switch_a_zero
  6571 00002812 46                      	inc si
  6572 00002813 B20A                    	mov dl, 10
  6573                                  .switch_a_zero:
  6574 00002815 31DB                    	xor bx, bx
  6575                                  .switch_a_num:
  6576 00002817 AC                      	lodsb
  6577 00002818 3C20                    	cmp al, 32			; end of number ?
  6578 0000281A 7450                    	je .switch_a_check
  6579 0000281C 3C09                    	cmp al, 9
  6580 0000281E 744C                    	je .switch_a_check
  6581 00002820 3C0D                    	cmp al, 13
  6582 00002822 7448                    	je .switch_a_check		; yes -->
  6583 00002824 3C5F                    	cmp al, '_'			; separator ?
  6584 00002826 74EF                    	je .switch_a_num
  6585 00002828 3C23                    	cmp al, '#'			; base change ?
  6586 0000282A 7432                    	je .switch_a_base
  6587 0000282C E8B30A                  	call init_capitalise
  6588 0000282F B400                    	mov ah, 0
  6589 00002831 3C30                    	cmp al, '0'			; decimal digit ?
  6590 00002833 7224                    	jb .switch_a_error
  6591 00002835 3C39                    	cmp al, '9'
  6592 00002837 7712                    	ja .switch_a_notdec
  6593 00002839 2C30                    	sub al, '0'			; ax = digit
  6594                                  .switch_a_gotdigit:
  6595 0000283B 93                      	xchg ax, bx			; ax = prior
  6596 0000283C 52                      	push dx
  6597 0000283D F7E2                    	mul dx				; dx:ax = prior * base
  6598 0000283F 85D2                    	test dx, dx			; >= 64 KiB ?
  6599 00002841 7516                    	jnz .switch_a_error		; error -->
  6600 00002843 5A                      	pop dx
  6601 00002844 93                      	xchg bx, ax			; return bx = prior
  6602 00002845 01C3                    	add bx, ax			; prior += next
  6603 00002847 7210                    	jc .switch_a_error
  6604 00002849 EBCC                    	jmp .switch_a_num
  6605                                  
  6606                                  .switch_a_notdec:
  6607 0000284B 3C41                    	cmp al, 'A'			; alphabetic ?
  6608 0000284D 720A                    	jb .switch_a_error
  6609 0000284F 3C5A                    	cmp al, 'Z'
  6610 00002851 7706                    	ja .switch_a_error
  6611 00002853 04C9                    	add al, 10 - 'A'		; ax = digit
  6612 00002855 39D0                    	cmp ax, dx
  6613 00002857 72E2                    	jb .switch_a_gotdigit
  6614                                  	; jae .switch_a_error
  6615                                  .switch_a_error:
  6616                                  ..@init_cmdline_switch_a_error:
  6617 00002859 B041                    	mov al, 'A'
  6618 0000285B E9C4F9                  	jmp ..@init_cmdline_switch_error
  6619                                  
  6620                                  .switch_a_base:
  6621 0000285E 83FB02                  	cmp bx, 2
  6622 00002861 72F6                    	jb .switch_a_error
  6623 00002863 83FB24                  	cmp bx, 36
  6624 00002866 77F1                    	ja .switch_a_error
  6625 00002868 89DA                    	mov dx, bx
  6626 0000286A EBA9                    	jmp .switch_a_zero
  6627                                  
  6628                                  .switch_a_check:
  6629 0000286C 81FB1020                	cmp bx, _AUXBUFFSIZE
  6630 00002870 72E7                    	jb .switch_a_error
  6631 00002872 81FB0060                	cmp bx, _AUXBUFFMAXSIZE
  6632 00002876 77E1                    	ja .switch_a_error
  6633                                  
  6634 00002878 A8                      	db __TEST_IMM8			; (skip lodsb)
  6635                                  .switch_a_got.lodsb:
  6636 00002879 AC                      	lodsb
  6637                                  .switch_a_got:
  6638 0000287A 1E                      	push ds
  6639 0000287B 07                      	pop es
  6640 0000287C 2E891E[400E]            	mov word [cs:init_auxbuff_want], bx
  6641 00002881 4E                      	dec si
  6642 00002882 E91CF8                  	jmp .blankloop
  6643                                  
  6644                                  
  6645                                  .switch_r:
  6646 00002885 AC                      	lodsb
  6647 00002886 3C3A                    	cmp al, ':'
  6648 00002888 7404                    	je @F
  6649 0000288A 3C3D                    	cmp al, '='
  6650 0000288C 7501                    	jne @FF
  6651                                  @@:
  6652 0000288E A8                      	db __TEST_IMM8			; skip dec
  6653                                  @@:
  6654 0000288F 4E                      	dec si
  6655 00002890 BA1000                  	mov dx, 16
  6656 00002893 31DB                    	xor bx, bx
  6657                                  .switch_r_num:
  6658 00002895 AC                      	lodsb
  6659 00002896 3C20                    	cmp al, 32			; end of number ?
  6660 00002898 743E                    	je .switch_r_check
  6661 0000289A 3C09                    	cmp al, 9
  6662 0000289C 743A                    	je .switch_r_check
  6663 0000289E 3C0D                    	cmp al, 13
  6664 000028A0 7436                    	je .switch_r_check		; yes -->
  6665 000028A2 3C5F                    	cmp al, '_'			; separator ?
  6666 000028A4 74EF                    	je .switch_r_num
  6667 000028A6 E8390A                  	call init_capitalise
  6668 000028A9 B400                    	mov ah, 0
  6669 000028AB 3C30                    	cmp al, '0'			; decimal digit ?
  6670 000028AD 7224                    	jb .switch_r_error
  6671 000028AF 3C39                    	cmp al, '9'
  6672 000028B1 7712                    	ja .switch_r_notdec
  6673 000028B3 2C30                    	sub al, '0'			; ax = digit
  6674                                  .switch_r_gotdigit:
  6675 000028B5 93                      	xchg ax, bx			; ax = prior
  6676 000028B6 52                      	push dx
  6677 000028B7 F7E2                    	mul dx				; dx:ax = prior * base
  6678 000028B9 85D2                    	test dx, dx			; >= 64 KiB ?
  6679 000028BB 7516                    	jnz .switch_r_error		; error -->
  6680 000028BD 5A                      	pop dx
  6681 000028BE 93                      	xchg bx, ax			; return bx = prior
  6682 000028BF 01C3                    	add bx, ax			; prior += next
  6683 000028C1 7210                    	jc .switch_r_error
  6684 000028C3 EBD0                    	jmp .switch_r_num
  6685                                  
  6686                                  .switch_r_notdec:
  6687 000028C5 3C41                    	cmp al, 'A'			; alphabetic ?
  6688 000028C7 720A                    	jb .switch_r_error
  6689 000028C9 3C5A                    	cmp al, 'Z'
  6690 000028CB 7706                    	ja .switch_r_error
  6691 000028CD 04C9                    	add al, 10 - 'A'		; ax = digit
  6692 000028CF 39D0                    	cmp ax, dx
  6693 000028D1 72E2                    	jb .switch_r_gotdigit
  6694                                  	; jae .switch_r_error
  6695                                  .switch_r_error:
  6696                                  ..@init_cmdline_switch_r_error:
  6697 000028D3 B052                    	mov al, 'R'
  6698 000028D5 E94AF9                  	jmp ..@init_cmdline_switch_error
  6699                                  
  6700                                  .switch_r_check:
  6701                                  .switch_r_got:
  6702 000028D8 1E                      	push ds
  6703 000028D9 07                      	pop es
  6704 000028DA 2E891E[4E0E]            	mov word [cs:init_switch_r], bx
  6705 000028DF 4E                      	dec si
  6706 000028E0 E9BEF7                  	jmp .blankloop
  6707                                  
  6708                                  
  6709                                  .noswitches:
  6710                                  .breakpoint:
  6711 000028E3 90                      	nop			; SMC in section init
  6712                                  		; Feed the remaining command line to the 'n' command.
  6713 000028E4 4E                      	dec si
  6714 000028E5 E8100A                  	call init_skipcomma
  6715 000028E8 4E                      	dec si
  6716 000028E9 56                      	push si
  6717                                  
  6718                                  
  6719                                  %assign ELD 0
  6720                                  %assign INTERC3 0
  6721                                  %assign PART1 1
  6722                                  %assign PART2 0
  6723                                  %assign PART3 0
  6724                                  %define init_data_segment cs
  6725                                  
  6726                                   %imacro internalcoderelocation 0-*.nolist
  6727                                   %endmacro
  6728                                   %imacro internaldatarelocation 0-*.nolist
  6729                                   %endmacro
  6730                                   %imacro linkdatarelocation 0-*.nolist
  6731                                   %endmacro
  6732                                   %define relocated(address) address
  6733                                  
  6734                                  %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 000028EA 89F3                <1> 	mov bx, si
    31 000028EC 31D2                <1> 	xor dx, dx
    32 000028EE B000                <1> 	mov al, 0
    33                              <1> @@:
    34 000028F0 3C2F                <1> 	cmp al, '/'
    35 000028F2 7410                <1> 	je .slash
    36 000028F4 3C5C                <1> 	cmp al, '\'
    37 000028F6 740C                <1> 	je .slash
    38 000028F8 3C3A                <1> 	cmp al, ':'
    39 000028FA 7408                <1> 	je .colon
    40 000028FC 3C2E                <1> 	cmp al, '.'
    41 000028FE 7507                <1> 	jne .next
    42                              <1> .dot:
    43 00002900 B201                <1> 	mov dl, 1		; set dl (fn with dot)
    44 00002902 EB03                <1> 	jmp .next
    45                              <1> 
    46                              <1> .slash:
    47                              <1> .colon:
    48 00002904 BA0001              <1> 	mov dx, 100h		; set dh (is a pathname), reset dl (fn with dot)
    49                              <1> .next:
    50 00002907 AC                  <1> 	lodsb
    51 00002908 E87208              <1> 	call init_ifsep
    52 0000290B 75E3                <1> 	jne @B
    53 0000290D 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 0000290E 16                  <1> 	push ss
    57 0000290F 07                  <1> 	pop es
    58 00002910 89F1                <1> 	mov cx, si
    59 00002912 29D9                <1> 	sub cx, bx		; es:bx -> name, cx = length
    60                              <1> 
    61                              <1> 
    62                              <1> init_check_warn_extension:
    63 00002914 52                  <1> 	push dx
    64 00002915 06                  <1> 	push es
    65                              <1> 
    66 00002916 84D2                <1> 	test dl, dl		; last component has a dot ?
    67 00002918 7433                <1> 	jz .done		; no, do not warn -->
    68                              <1> 
    69 0000291A 2ED006[6C0E]        <1> 	rol byte [init_data_segment:init_switch_pw], 1
    70                              <1> internaldatarelocation
    71 0000291F 732C                <1> 	jnc .done		; warning disabled -->
    72                              <1> 
    73 00002921 83F904              <1> 	cmp cx, 4		; can fit an expected extension ?
    74 00002924 7221                <1> 	jb .warn		; no, warn -->
    75                              <1> 
    76 00002926 83EE04              <1> 	sub si, 4		; -> possible extension
    77 00002929 0E                  <1> 	push init_data_segment
    78 0000292A 07                  <1> 	pop es
    79 0000292B BF[720E]            <1> 	mov di, imsg.no_warn_extensions
    80                              <1> internaldatarelocation		; es:di -> allowed extensions
    81                              <1> .loop:
    82 0000292E B000                <1> 	mov al, 0
    83 00002930 2E864504            <1> 	xchg byte [init_data_segment:di+4], al
    84                              <1> 				; NUL-terminate the candidate extension
    85 00002934 50                  <1> 	push ax
    86 00002935 89FA                <1> 	mov dx, di
    87 00002937 E85209              <1> 	call init_isstring?	; is it this one ?
    88 0000293A 58                  <1> 	pop ax
    89 0000293B 2E884504            <1> 	mov byte [init_data_segment:di+4], al
    90                              <1> 				; restore next extension text
    91 0000293F 740C                <1> 	je .done		; yes, do not warn -->
    92 00002941 AF                  <1> 	scasw
    93 00002942 AF                  <1> 	scasw			; di += 4
    94 00002943 84C0                <1> 	test al, al		; was last ?
    95 00002945 75E7                <1> 	jnz .loop
    96                              <1> .warn:
    97 00002947 BA[8C0E]            <1> 	mov dx, imsg.extension_warning
    98                              <1> internaldatarelocation
    99 0000294A E890F1              <1> 	call init_putsz_cs
   100                              <1> 
   101                              <1> .done:
   102 0000294D 07                  <1> 	pop es
   103 0000294E 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 0000294F 2E833E[480E]00      <1> 	cmp word [init_data_segment:		init_switch_p_low_pathsearch_high_guessextension], strict byte 0
   116                              <1> internaldatarelocation -3
   117 00002955 740E                <1> 	je .done_j
   118                              <1> 
   119 00002957 E30C                <1> 	jcxz .done_j		; if no filename given -->
   120                              <1> 
   121                              <1> 				; es:bx -> name, cx = length
   122 00002959 BF[0000]            <1> 	mov di, relocated(while_buffer)
   123                              <1> linkdatarelocation while_buffer	; ss:while_buffer -> prefix, ss:di -> after end
   124                              <1> 
   125 0000295C E84008              <1> 	call init_check_filename
   126 0000295F 736C                <1> 	jnc .found
   127                              <1> 
   128 00002961 84F6                <1> 	test dh, dh
   129 00002963 7403                <1> 	jz @F
   130                              <1> .done_j:
   131 00002965 E99800              <1> 	jmp .done
   132                              <1> @@:
   133 00002968 2ED006[480E]        <1> 	rol byte [init_data_segment:init_switch_p_pathsearch], 1
   134                              <1> internaldatarelocation
   135 0000296D 73F6                <1> 	jnc .done_j
   136                              <1> 
   137                              <1> %if _DEVICE && _APPLICATION && ! ELD && ! INTERC3
   138 0000296F F606[0200]40        <1> 	testopt [internalflags6], dif6_device_mode
   139 00002974 7505                <1> 	jnz .device
   140                              <1> %endif
   141                              <1> %if _APPLICATION || ELD || INTERC3
   142 00002976 A12C00              <1> 	mov ax, [2Ch]
   143                              <1>  %if _DEVICE && ! ELD && ! INTERC3
   144 00002979 EB03                <1> 	jmp @F
   145                              <1>  %endif
   146                              <1> %endif
   147                              <1> 
   148                              <1> %if _DEVICE && ! ELD && ! INTERC3
   149                              <1> .device:
   150 0000297B E816E3              <1> 	call init_device_get_environment
   151                              <1> @@:
   152                              <1> %endif
   153                              <1> 
   154 0000297E 51                  <1> 	push cx
   155 0000297F BF[870E]            <1> 	mov di, imsg.varpath
   156                              <1> internaldatarelocation
   157 00002982 B90500              <1> 	mov cx, imsg.varpath.length
   158 00002985 E85D08              <1> 	call init_findvar
   159 00002988 7275                <1> 	jc .done_pop
   160                              <1> 
   161                              <1> .pathloop:
   162 0000298A 56                  <1> 	push si
   163 0000298B B98000              <1> 	mov cx, 128		; put a limit
   164                              <1> @@:
   165 0000298E AC                  <1> 	lodsb			; get next text
   166 0000298F 3C3B                <1> 	cmp al, ';'		; separator ?
   167 00002991 7408                <1> 	je @F			; yes -->
   168 00002993 3C00                <1> 	cmp al, 0		; separator ?
   169 00002995 7404                <1> 	je @F			; yes -->
   170 00002997 E2F5                <1> 	loop @B			; loop up to limit
   171 00002999 EB5D                <1> 	jmp .pathtoolong	; error -->
   172                              <1> @@:
   173 0000299B 89F1                <1> 	mov cx, si
   174 0000299D 49                  <1> 	dec cx			; -> terminator
   175 0000299E 5E                  <1> 	pop si			; -> content text
   176 0000299F 29F1                <1> 	sub cx, si		; = length excluding terminator
   177 000029A1 16                  <1> 	 push ss
   178 000029A2 07                  <1> 	 pop es
   179 000029A3 BF[0000]            <1> 	mov di, relocated(while_buffer)
   180                              <1> linkdatarelocation while_buffer	; es:di -> buffer
   181                              <1> 
   182 000029A6 B000                <1> 	mov al, 0		; no backslash if empty
   183 000029A8 E30A                <1> 	jcxz @FFF		; skip loop if empty -->
   184                              <1> @@:
   185 000029AA AC                  <1> 	lodsb			; load from variable
   186 000029AB 3C2F                <1> 	cmp al, '/'		; forward slash ?
   187 000029AD 7502                <1> 	jne @F			; no -->
   188 000029AF B05C                <1> 	mov al, '\'		; replace by backslash
   189                              <1> @@:
   190 000029B1 AA                  <1> 	stosb			; store
   191 000029B2 E2F6                <1> 	loop @BB		; loop for cx = count
   192                              <1> @@:
   193 000029B4 3C5C                <1> 	cmp al, '\'		; trailing backslash ?
   194 000029B6 7403                <1> 	je @F			; yes -->
   195 000029B8 B05C                <1> 	mov al, '\'
   196 000029BA AA                  <1> 	stosb			; append it
   197                              <1> @@:
   198 000029BB 59                  <1> 	pop cx
   199                              <1> 
   200 000029BC 1E                  <1> 	push ds
   201 000029BD 56                  <1> 	push si
   202                              <1> 				; ss = es, es:bx -> name, cx = length
   203                              <1> 				; ss:while_buffer -> prefix, ss:di -> after end
   204 000029BE E8DE07              <1> 	call init_check_filename
   205 000029C1 5E                  <1> 	pop si
   206 000029C2 1F                  <1> 	pop ds			; ds:si -> terminator of path element
   207 000029C3 7308                <1> 	jnc .found
   208                              <1> 
   209 000029C5 AC                  <1> 	lodsb			; get terminator
   210 000029C6 3C3B                <1> 	cmp al, ';'		; semicolon ?
   211 000029C8 7536                <1> 	jne .done		; no -->
   212 000029CA 51                  <1> 	push cx
   213 000029CB EBBD                <1> 	jmp .pathloop		; try next -->
   214                              <1> 
   215                              <1> 
   216                              <1> .found:
   217 000029CD 16                  <1> 	push ss
   218 000029CE 1F                  <1> 	pop ds			; ds => PSP
   219 000029CF 5E                  <1> 	 pop si
   220 000029D0 01CE                <1> 	add si, cx		; ds:si -> behind original name
   221 000029D2 16                  <1> 	push ss
   222 000029D3 07                  <1> 	pop es
   223 000029D4 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 000029D5 EB07                <1> 	jmp @FF			; skip store on first iteration
   230                              <1> 
   231                              <1> @@:
   232 000029D7 81FF[FEFF]          <1> 	cmp di, relocated(while_buffer.end) - 2
   233                              <1> linkdatarelocation while_buffer.end
   234 000029DB 7713                <1> 	ja .toolong
   235 000029DD AA                  <1> 	stosb
   236                              <1> @@:
   237 000029DE AC                  <1> 	lodsb
   238 000029DF 3C00                <1> 	cmp al, 0
   239 000029E1 7404                <1> 	je @F
   240 000029E3 3C0D                <1> 	cmp al, 13
   241 000029E5 75F0                <1> 	jne @BB
   242                              <1> @@:			; (targeted from both directions)
   243 000029E7 B00D                <1> 	mov al, 13
   244 000029E9 AA                  <1> 	stosb
   245 000029EA BE[0000]            <1> 	mov si, relocated(while_buffer)
   246                              <1> linkdatarelocation while_buffer
   247 000029ED 56                  <1> 	 push si		; offset for N/K command (kk)
   248 000029EE EB10                <1> 	jmp .done
   249                              <1> 
   250                              <1> .toolong:
   251 000029F0 BA[C60E]            <1> 	mov dx, imsg.kktoolong
   252                              <1> internaldatarelocation
   253 000029F3 E8E7F0              <1> 	call init_putsz_cs
   254 000029F6 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 000029F8 BA[F40E]            <1> 	mov dx, imsg.pathtoolong
   262                              <1> internaldatarelocation
   263 000029FB E8DFF0              <1> 	call init_putsz_cs
   264                              <1> 
   265 000029FE 58                  <1> 	pop ax			; (discard si)
   266                              <1> .done_pop:
   267 000029FF 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
  6735                                  
  6736                                   %undef extcall
  6737                                   %undef extcallcall
  6738                                   %unimacro internalcoderelocation 0-*.nolist
  6739                                   %unimacro internaldatarelocation 0-*.nolist
  6740                                   %unimacro linkdatarelocation 0-*.nolist
  6741                                   %undef relocated
  6742                                  
  6743                                  
  6744                                  %if _APP_ENV_SIZE
  6745                                  init_copy_app_env:
  6746 00002A00 16                      	push ss
  6747 00002A01 1F                      	pop ds
  6748                                   %if _DEVICE
  6749 00002A02 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  6750 00002A07 755F                    	jnz .skip
  6751                                   %endif
  6752 00002A09 2EC706[380E]8000        	mov word [cs:mem_envsize], paras(app_env_size)
  6753 00002A10 8B16[0000]              	mov dx, word [envseg]		; => pseudo MCB
  6754 00002A14 42                      	inc dx				; => space for environment
  6755 00002A15 A12C00                  	mov ax, word [2Ch]
  6756 00002A18 1E                      	push ds
  6757 00002A19 85C0                    	test ax, ax
  6758 00002A1B 7446                    	jz @F
  6759 00002A1D 8ED8                    	mov ds, ax
  6760 00002A1F 8EC2                    	mov es, dx
  6761 00002A21 31FF                    	xor di, di
  6762 00002A23 31F6                    	xor si, si
  6763                                  .loop_env:
  6764 00002A25 E8DC07                  	call init_nextvar
  6765 00002A28 75FB                    	jne .loop_env
  6766 00002A2A 46                      	inc si
  6767 00002A2B AD                      	lodsw
  6768 00002A2C 83F801                  	cmp ax, 1
  6769 00002A2F 7504                    	jne .notrail
  6770 00002A31 E8D007                  	call init_nextvar
  6771 00002A34 A9                      	db __TEST_IMM16
  6772                                  .notrail:
  6773 00002A35 4E                      	dec si
  6774 00002A36 4E                      	dec si
  6775 00002A37 81FEEE07                	cmp si, app_env_size - 16 - 2
  6776 00002A3B 7610                    	jbe .copy_env
  6777 00002A3D BA[530F]                	mov dx, imsg.app_env_too_large
  6778 00002A40 E89AF0                  	call init_putsz_cs
  6779                                  .no_reloc:
  6780 00002A43 2EC606[710E]FF          	mov byte [cs:app_env_allocation], 0FFh
  6781 00002A49 8CDA                    	mov dx, ds
  6782 00002A4B EB16                    	jmp @F
  6783                                  
  6784                                  .copy_env:
  6785 00002A4D 2ED006[700E]            	rol byte [cs:init_switch_t_variable], 1
  6786 00002A52 72EF                    	jc .no_reloc
  6787 00002A54 89F1                    	mov cx, si
  6788 00002A56 31F6                    	xor si, si
  6789 00002A58 F3A4                    	rep movsb
  6790 00002A5A 31C0                    	xor ax, ax
  6791 00002A5C AB                      	stosw
  6792 00002A5D 1E                      	push ds
  6793 00002A5E 07                      	pop es
  6794 00002A5F B449                    	mov ah, 49h
  6795 00002A61 CD21                    	int 21h
  6796                                  @@:
  6797 00002A63 1F                      	pop ds
  6798 00002A64 89162C00                	mov word [2Ch], dx
  6799                                  
  6800                                  .skip:
  6801                                  %endif
  6802                                  
  6803                                  
  6804                                  init_relocate_init:
  6805 00002A68 16                      	push ss
  6806 00002A69 1F                      	pop ds
  6807 00002A6A 16                      	push ss
  6808 00002A6B 07                      	pop es
  6809                                  %if _AUXBUFFSIZE != _AUXBUFFMAXSIZE
  6810 00002A6C 2EA1[400E]              	mov ax, word [cs:init_auxbuff_want]
  6811 00002A70 83C00F                  	add ax, 15			; cannot carry, ax <= _AUXBUFFMAXSIZE
  6812 00002A73 24F0                    	and al, 0F0h
  6813 00002A75 B104                    	mov cl, 4
  6814 00002A77 89C3                    	mov bx, ax
  6815 00002A79 D3EB                    	shr bx, cl
  6816 00002A7B BEFFFD                  	mov si, - paras(_AUXBUFFSIZE)
  6817 00002A7E 01DE                    	add si, bx			; want size - init size = how much to add
  6818 00002A80 31D2                    	xor dx, dx			; always positive
  6819                                  %else
  6820                                  	xor si, si			; = 0
  6821                                  	xor dx, dx
  6822                                  %endif
  6823                                  
  6824                                  %if _EXTENSIONS
  6825 00002A82 2EA1[440E]              	mov ax, word [cs:init_extdata_want]
  6826 00002A86 83C00F                  	add ax, 15
  6827 00002A89 24F0                    	and al, 0F0h
  6828                                  
  6829 00002A8B B104                    	mov cl, 4
  6830 00002A8D 89C3                    	mov bx, ax
  6831 00002A8F D3EB                    	shr bx, cl
  6832 00002A91 BF00FC                  	mov di, - paras(_EXT_DATA_BOOT_SIZE)
  6833 00002A94 01DF                    	add di, bx			; want size - init size = how much to add
  6834                                  					;  negative if to subtract
  6835 00002A96 19DB                    	sbb bx, bx			; -1 if >= 0 to add
  6836 00002A98 F7D3                    	not bx				; -1 if negative
  6837 00002A9A 01FE                    	add si, di
  6838 00002A9C 11DA                    	adc dx, bx			; add positive or negative dword
  6839                                  
  6840                                  
  6841 00002A9E 2EA1[420E]              	mov ax, word [cs:init_ext_want]
  6842 00002AA2 83C00F                  	add ax, 15
  6843 00002AA5 24F0                    	and al, 0F0h
  6844                                  
  6845 00002AA7 B104                    	mov cl, 4
  6846 00002AA9 89C3                    	mov bx, ax
  6847 00002AAB D3EB                    	shr bx, cl
  6848 00002AAD BF00FE                  	mov di, - paras(_EXT_CODE_INIT_SIZE)
  6849 00002AB0 01DF                    	add di, bx			; want size - init size = how much to add
  6850                                  					;  negative if to subtract
  6851 00002AB2 19DB                    	sbb bx, bx			; -1 if >= 0 to add
  6852 00002AB4 F7D3                    	not bx
  6853 00002AB6 01FE                    	add si, di
  6854 00002AB8 11DA                    	adc dx, bx			; add positive or negative dword
  6855                                  %endif
  6856                                  
  6857                                  %if _HISTORY_SEPARATE_FIXED && _HISTORY
  6858 00002ABA 2EA1[460E]              	mov ax, word [cs:init_history_want]
  6859 00002ABE 83C00F                  	add ax, 15
  6860 00002AC1 24F0                    	and al, 0F0h
  6861                                  
  6862 00002AC3 B104                    	mov cl, 4
  6863 00002AC5 89C3                    	mov bx, ax
  6864 00002AC7 D3EB                    	shr bx, cl
  6865 00002AC9 BF00FE                  	mov di, - paras(historysegment_size)
  6866 00002ACC 01DF                    	add di, bx			; want size - init size = how much to add
  6867                                  					;  negative if to subtract
  6868 00002ACE 19DB                    	sbb bx, bx			; -1 if >= 0 to add
  6869 00002AD0 F7D3                    	not bx				; -1 if negative
  6870 00002AD2 01FE                    	add si, di
  6871 00002AD4 11DA                    	adc dx, bx			; add positive or negative dword
  6872                                  %endif
  6873                                  
  6874 00002AD6 85D2                    	test dx, dx			; add paras is negative ?
  6875 00002AD8 7567                    	jnz .done			; yes -->
  6876 00002ADA 85F6                    	test si, si
  6877 00002ADC 7463                    	jz .done			; if to add == 0 -->
  6878                                  
  6879                                  .reloc:
  6880 00002ADE 2E0336[360E]            	add si, word [cs:memsize]	; = new memsize
  6881 00002AE3 7256                    	jc .error
  6882 00002AE5 8CD8                    	mov ax, ds
  6883 00002AE7 01C6                    	add si, ax			; => past want alloc
  6884 00002AE9 7250                    	jc .error
  6885                                  %if _DEVICE
  6886 00002AEB F606[0200]40            	testopt [internalflags6], dif6_device_mode
  6887 00002AF0 7403                    	jz @F
  6888 00002AF2 46                      	inc si				; account for container paragraph
  6889 00002AF3 7446                    	jz .error
  6890                                  @@:
  6891                                  %endif
  6892 00002AF5 8CCB                    	mov bx, cs
  6893 00002AF7 39DE                    	cmp si, bx			; below-or-equal cs ?
  6894 00002AF9 7646                    	jbe .done			; yes, no need to relocate -->
  6895                                  
  6896                                  %ifn _LINK
  6897                                  	mov cx, init_size_p		; size of init
  6898                                  %else
  6899 00002AFB B9[0000]                	mov cx, relocatedzero + 0
  6900                                   wlcalc word_wrt_INIT_extpara_behind_init, equ $ - 2
  6901                                  %endif
  6902 00002AFE 01CB                    	add bx, cx			; => minimum init reloc target
  6903 00002B00 39DE                    	cmp si, bx
  6904 00002B02 7602                    	jbe .havetarget
  6905 00002B04 89F3                    	mov bx, si			; => needed init reloc target
  6906                                  
  6907                                  .havetarget:
  6908 00002B06 89DA                    	mov dx, bx			; dx => target
  6909 00002B08 01CB                    	add bx, cx			; bx => behind target
  6910 00002B0A 722F                    	jc .error
  6911                                  %if _DEVICE
  6912 00002B0C F606[0200]40            	testopt [internalflags6], dif6_device_mode
  6913 00002B11 7409                    	jz @F
  6914 00002B13 2E3B1E[3E0E]            	cmp bx, word [cs:dev_memory_end]; enough space ?
  6915 00002B18 7721                    	ja .error			; no -->
  6916 00002B1A EB14                    	jmp .movp
  6917                                  
  6918                                  @@:
  6919                                  %endif
  6920 00002B1C 8CD8                    	mov ax, ds
  6921 00002B1E 29C3                    	sub bx, ax			; = amount paragraphs needed
  6922 00002B20 2E891E[520E]            	mov word [cs:init_target_size], bx
  6923 00002B25 2E891E[500E]            	mov word [cs:init_base_size], bx
  6924 00002B2A B44A                    	mov ah, 4Ah
  6925 00002B2C CD21                    	int 21h				; resize memory block = es
  6926 00002B2E 720B                    	jc .error			; if error -->
  6927                                  
  6928                                  .movp:
  6929 00002B30 8CC8                    	mov ax, cs
  6930 00002B32 E817EF                  	call init_movp			; move init
  6931 00002B35 52                      	push dx				; => relocated init
  6932 00002B36 E8F5D6                  	call init_retf			; ttansfer control
  6933 00002B39 EB06                    	jmp .done			; done
  6934                                  
  6935                                  .error:
  6936 00002B3B BA[CE0F]                	mov dx, imsg.init_relocate_failure
  6937 00002B3E E9CFF6                  	jmp ..@init_cmdline_error
  6938                                  
  6939                                  .done:
  6940                                  
  6941                                  
  6942                                  init_change_auxbuff_size:
  6943 00002B41 16                      	push ss
  6944 00002B42 1F                      	pop ds
  6945 00002B43 16                      	push ss
  6946 00002B44 07                      	pop es
  6947                                  %if _AUXBUFFSIZE != _AUXBUFFMAXSIZE
  6948 00002B45 2EA1[400E]              	mov ax, word [cs:init_auxbuff_want]
  6949 00002B49 83C00F                  	add ax, 15			; cannot carry, ax <= _AUXBUFFMAXSIZE
  6950 00002B4C 24F0                    	and al, 0F0h
  6951                                  
  6952 00002B4E 89C7                    	mov di, ax
  6953 00002B50 83EF18                  	sub di, 8 * 3
  6954 00002B53 A3[0000]                	mov word [auxbuff_current_size], ax
  6955 00002B56 893E[0000]              	mov word [auxbuff_current_size_minus_24], di
  6956                                  
  6957 00002B5A B104                    	mov cl, 4
  6958 00002B5C 89C3                    	mov bx, ax
  6959 00002B5E D3EB                    	shr bx, cl
  6960 00002B60 BEFFFD                  	mov si, - paras(_AUXBUFFSIZE)
  6961 00002B63 01DE                    	add si, bx
  6962 00002B65 740E                    	jz @F				; if to keep minimum size
  6963                                  
  6964                                  		; INP:	ax = wanted size (rounded to paragraph boundary)
  6965                                  		;	bx = wanted size paragraphs
  6966                                  		;	si = bx - paragraphs of minimum size = how much to enlarge
  6967                                  		;	ip -> function depending on layout
  6968                                  		; STT:	ss = ds = es
  6969                                  		; OUT:	NC if success
  6970                                  		;	CY if error, branch to command line error
  6971 00002B67 2EFF16[3C0E]            	call near [cs:init_layout]
  6972 00002B6C 16                      	push ss
  6973 00002B6D 1F                      	pop ds
  6974 00002B6E 16                      	push ss
  6975 00002B6F 07                      	pop es
  6976 00002B70 7303E9E4FC              	jc ..@init_cmdline_switch_a_error
  6977                                  @@:
  6978                                  %endif
  6979                                  
  6980                                  
  6981                                  %if _EXTENSIONS
  6982                                  init_change_extdata_size_and_init:
  6983 00002B75 2EA1[440E]              	mov ax, word [cs:init_extdata_want]
  6984 00002B79 83C00F                  	add ax, 15
  6985 00002B7C 24F0                    	and al, 0F0h
  6986 00002B7E A3[0000]                	mov word [extdata_size], ax
  6987                                  
  6988 00002B81 89C1                    	mov cx, ax
  6989 00002B83 81E90040                	sub cx, fromparas(paras(_EXT_DATA_BOOT_SIZE))
  6990 00002B87 010E[0000]              	add word [entryseg_size], cx
  6991                                  
  6992 00002B8B B104                    	mov cl, 4
  6993 00002B8D 89C3                    	mov bx, ax
  6994 00002B8F D3EB                    	shr bx, cl
  6995 00002B91 BE0004                  	mov si, paras(_EXT_DATA_BOOT_SIZE)
  6996 00002B94 29DE                    	sub si, bx			; init size - want
  6997                                  		; negative if larger want than init
  6998 00002B96 7503E99300              	jz .keep			; if to keep init size
  6999 00002B9B 19FF                    	sbb di, di			; -1 if negative
  7000 00002B9D F7D7                    	not di				; -1 if positive (smaller want than init)
  7001 00002B9F 2E893E[4C0E]            	mov word [cs:relocate_down], di	; relocating down if smaller want
  7002                                  
  7003 00002BA4 2E8B0E[360E]            	mov cx, word [cs:memsize]	; how many paragraphs do we have
  7004                                   %if _DEVICE
  7005 00002BA9 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  7006 00002BAE 7401                    	jz @F
  7007 00002BB0 41                      	inc cx				; account for container paragraph
  7008                                  @@:
  7009                                   %endif
  7010 00002BB1 2E2936[360E]            	sub word [cs:memsize], si
  7011                                  
  7012 00002BB6 8CD8                    	mov ax, ds
  7013                                  %ifn _LINK
  7014                                  	add ax, paras(100h + DATAENTRYTABLESIZE + datastack_size)
  7015                                  	mov dx, ax
  7016                                  	sub dx, si
  7017                                  	sub cx, paras(100h + DATAENTRYTABLESIZE + datastack_size)
  7018                                  %else
  7019 00002BB8 05[0000]                	add ax, strict word relocatedzero + 0
  7020                                   wlcalc word_wrt_@@lDEBUG_DATA_ENTRY@_extpara_end_of_datastack, equ $ - 2
  7021 00002BBB 89C2                    	mov dx, ax
  7022 00002BBD 29F2                    	sub dx, si
  7023 00002BBF 81E9[0000]              	sub cx, strict word relocatedzero + 0
  7024                                   wlcalc word_wrt_@@lDEBUG_DATA_ENTRY@_extpara_end_of_datastack, equ $ - 2
  7025                                  %endif
  7026 00002BC3 E886EE                  	call init_movp
  7027                                  
  7028                                   %if _DEVICE
  7029 00002BC6 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  7030 00002BCB 7416                    	jz @F
  7031                                  
  7032 00002BCD 2936[0000]              	sub word [device_mcb_paragraphs], si
  7033                                  					; fix our variable
  7034 00002BD1 2936[0000]              	sub word [alloc_size], si	; this one too
  7035 00002BD5 8E06[0000]              	mov es, word [reg_es]
  7036 00002BD9 8B1E[0000]              	mov bx, word [reg_ebx]		; -> device request header
  7037 00002BDD 26297710                	sub word [es:bx + 0Eh + 2], si	; -> behind memory in use
  7038 00002BE1 16                      	push ss
  7039 00002BE2 07                      	pop es
  7040                                   %endif
  7041                                  @@:
  7042                                  
  7043 00002BE3 F7DE                    	neg si
  7044                                  
  7045                                  %if _HISTORY_SEPARATE_FIXED && _HISTORY
  7046                                  .relocate_history:
  7047 00002BE5 0136[0000]              	add word [history.segorsel + soaSegSel], si
  7048                                  %if _PM
  7049 00002BE9 0136[0200]              	add word [history.segorsel + soaSegment], si
  7050                                  %endif
  7051                                  %endif
  7052                                  
  7053                                  %if _APP_ENV_SIZE || _DEV_ENV_SIZE
  7054                                  .relocate_env:
  7055 00002BED 2ED006[710E]            	rol byte [cs:app_env_allocation], 1
  7056 00002BF2 7204                    	jc @F
  7057 00002BF4 01362C00                	add word [2Ch], si
  7058                                  @@:
  7059 00002BF8 833E[0000]00            	cmp word [envseg], 0
  7060 00002BFD 7404                    	je @F
  7061 00002BFF 0136[0000]              	add word [envseg], si
  7062                                  @@:
  7063                                  %endif
  7064                                  
  7065                                  %if _EXTENSIONS
  7066                                  .relocate_ext:
  7067 00002C03 0136[0000]              	add word [extseg], si
  7068                                  %endif
  7069                                  
  7070                                  .relocate_code:
  7071 00002C07 A1[0000]                	mov ax, word [code_seg]
  7072 00002C0A 89C2                    	mov dx, ax
  7073 00002C0C 01F2                    	add dx, si
  7074                                  
  7075 00002C0E 8EC2                    	mov es, dx
  7076 00002C10 0136[0000]              	add word [code_seg], si
  7077                                  %if _DUALCODE
  7078 00002C14 0136[0000]              	add word [code2_seg], si
  7079 00002C18 8B16[0000]              	mov dx, word [code2_seg]
  7080 00002C1C 56                      	push si
  7081                                   %if ! _PM
  7082                                  	mov si, relocate_from_code
  7083                                  	mov di, relocate_from_code.end
  7084                                  	call .relocate_code_patch
  7085                                  	mov si, relocate_from_code2
  7086                                  	mov di, relocate_from_code2.end
  7087                                   %endif
  7088 00002C1D 06                      	push es
  7089 00002C1E 8EC2                    	mov es, dx
  7090 00002C20 5A                      	pop dx
  7091                                   %if ! _PM
  7092                                  	call .relocate_code_patch
  7093                                  	jmp .relocate_code_done
  7094                                  
  7095                                  .relocate_code_loop:
  7096                                  	cs lodsw
  7097                                  	xchg bx, ax
  7098                                  	mov word [es:bx], dx
  7099                                  .relocate_code_patch:
  7100                                  	cmp si, di
  7101                                  	jb .relocate_code_loop
  7102                                  	retn
  7103                                  
  7104                                  .relocate_code_done:
  7105                                   %endif
  7106 00002C21 5E                      	pop si
  7107                                  %endif
  7108                                  
  7109                                  %if _AREAS && _AREAS_HOOK_CLIENT
  7110                                  	mov ax, si
  7111                                  	mov dx, word [cs:relocate_down]
  7112                                  	call add_to_areas_linear_code1.dxax
  7113                                   %if _DUALCODE && _EXPRDUALCODE
  7114                                  	mov ax, si
  7115                                  	mov dx, word [cs:relocate_down]
  7116                                  	call add_to_areas_linear_code2.dxax
  7117                                   %endif
  7118                                  %endif
  7119                                  
  7120                                  
  7121                                  .relocate_auxbuff:
  7122 00002C22 0136[0000]              	add word [auxbuff_segorsel + soaSegSel], si
  7123                                  %if _PM
  7124 00002C26 0136[0200]              	add word [auxbuff_segorsel + soaSegment], si
  7125                                  					; initialise auxbuff references
  7126                                  %endif
  7127                                  %if _IMMASM  && _IMMASM_AUXBUFF
  7128                                  	add word [immseg], si
  7129                                  %endif
  7130                                  
  7131                                  
  7132                                  %if _MESSAGESEGMENT
  7133                                  .relocate_messagesegment:
  7134 00002C2A 0136[0000]              	add word [messageseg], si
  7135                                   %if _HELP_COMPRESSED && ! _PM
  7136                                  	add word [hshrink_memory_source.segment], si
  7137                                   %endif
  7138                                  %endif
  7139                                  
  7140                                  .keep:
  7141 00002C2E 8B0E[0000]              	mov cx, word [extdata_size]
  7142 00002C32 16                      	push ss
  7143 00002C33 07                      	pop es
  7144 00002C34 BF[0000]                	mov di, ext_data_area
  7145 00002C37 B000                    	mov al, 0
  7146 00002C39 F3AA                    	rep stosb			; init ext data area
  7147                                  %endif
  7148                                  
  7149                                  
  7150                                  %if _EXTENSIONS
  7151                                  init_change_ext_size:
  7152 00002C3B 2EA1[420E]              	mov ax, word [cs:init_ext_want]
  7153 00002C3F 83C00F                  	add ax, 15
  7154 00002C42 24F0                    	and al, 0F0h
  7155 00002C44 A3[0000]                	mov word [extseg_size], ax
  7156                                  
  7157 00002C47 B104                    	mov cl, 4
  7158 00002C49 89C3                    	mov bx, ax
  7159 00002C4B D3EB                    	shr bx, cl
  7160 00002C4D BE0002                  	mov si, paras(_EXT_CODE_INIT_SIZE)
  7161 00002C50 29DE                    	sub si, bx			; init size - want
  7162                                  		; negative if larger want than init
  7163 00002C52 7441                    	jz @F				; if to keep init size
  7164                                  
  7165 00002C54 2E2936[360E]            	sub word [cs:memsize], si
  7166                                  
  7167 00002C59 85F6                    	test si, si
  7168 00002C5B 7911                    	jns .smaller
  7169 00002C5D BF0020                  	mov di, _EXT_CODE_INIT_SIZE
  7170 00002C60 8E06[0000]              	mov es, word [extseg]
  7171 00002C64 8B0E[0000]              	mov cx, word [extseg_size]
  7172 00002C68 29F9                    	sub cx, di
  7173 00002C6A B000                    	mov al, 0
  7174 00002C6C F3AA                    	rep stosb			; init trailer
  7175                                  .smaller:
  7176                                  
  7177                                   %if _DEVICE
  7178 00002C6E F606[0200]40            	testopt [internalflags6], dif6_device_mode
  7179 00002C73 7420                    	jz @F
  7180                                  
  7181 00002C75 2936[0000]              	sub word [device_mcb_paragraphs], si
  7182                                  					; fix our variable
  7183 00002C79 2936[0000]              	sub word [alloc_size], si	; this one too
  7184 00002C7D 8CD8                    	mov ax, ds			; => PSP
  7185 00002C7F 2E0306[360E]            	add ax, word [cs:memsize]	; => where to place container sig
  7186 00002C84 E8E5DE                  	call init_dev_place_container_signature
  7187                                  					; CHG: es, di, cx, si
  7188                                  					; ax => behind memory used for device
  7189 00002C87 8E06[0000]              	mov es, word [reg_es]
  7190 00002C8B 8B1E[0000]              	mov bx, word [reg_ebx]		; -> device request header
  7191 00002C8F 26894710                	mov word [es:bx + 0Eh + 2], ax	; -> behind memory in use
  7192 00002C93 16                      	push ss
  7193 00002C94 07                      	pop es
  7194                                   %endif
  7195                                  @@:
  7196                                  %endif
  7197                                  
  7198                                  
  7199                                  %if _HISTORY_SEPARATE_FIXED && _HISTORY
  7200                                  init_change_history_size:
  7201 00002C95 2EA1[460E]              	mov ax, word [cs:init_history_want]
  7202 00002C99 83C00F                  	add ax, 15
  7203 00002C9C 24F0                    	and al, 0F0h
  7204 00002C9E A3[0000]                	mov word [historyseg_size], ax
  7205 00002CA1 89C3                    	mov bx, ax
  7206                                  
  7207 00002CA3 48                      	dec ax
  7208 00002CA4 48                      	dec ax
  7209 00002CA5 A3[0000]                	mov word [history.first], ax
  7210 00002CA8 A3[0000]                	mov word [history.last], ax
  7211                                  
  7212 00002CAB B104                    	mov cl, 4
  7213 00002CAD D3EB                    	shr bx, cl
  7214 00002CAF BE0002                  	mov si, paras(historysegment_size)
  7215 00002CB2 29DE                    	sub si, bx			; init size - want
  7216                                  		; negative if larger want than init
  7217 00002CB4 7467                    	jz .keep			; if to keep init size
  7218 00002CB6 19FF                    	sbb di, di			; -1 if negative
  7219 00002CB8 F7D7                    	not di				; -1 if positive (smaller want than init)
  7220 00002CBA 2E893E[4C0E]            	mov word [cs:relocate_down], di	; relocating down if smaller want
  7221                                  
  7222 00002CBF 2E8B0E[360E]            	mov cx, word [cs:memsize]	; how many paragraphs do we have
  7223                                   %if _DEVICE
  7224 00002CC4 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  7225 00002CC9 7401                    	jz @F
  7226 00002CCB 41                      	inc cx				; account for container paragraph
  7227                                  @@:
  7228                                   %endif
  7229 00002CCC 2E2936[360E]            	sub word [cs:memsize], si
  7230                                  
  7231 00002CD1 8CD8                    	mov ax, ds
  7232 00002CD3 01C1                    	add cx, ax
  7233 00002CD5 A1[0000]                	mov ax, word [history.segorsel + soaSegSel]
  7234 00002CD8 89C2                    	mov dx, ax
  7235 00002CDA 050002                  	add ax, paras(historysegment_size)
  7236                                  					; => source
  7237 00002CDD 01DA                    	add dx, bx			; => destination
  7238 00002CDF 29C1                    	sub cx, ax
  7239 00002CE1 E868ED                  	call init_movp
  7240                                  
  7241                                   %if _DEVICE
  7242 00002CE4 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  7243 00002CE9 7416                    	jz @F
  7244                                  
  7245 00002CEB 2936[0000]              	sub word [device_mcb_paragraphs], si
  7246                                  					; fix our variable
  7247 00002CEF 2936[0000]              	sub word [alloc_size], si	; this one too
  7248 00002CF3 8E06[0000]              	mov es, word [reg_es]
  7249 00002CF7 8B1E[0000]              	mov bx, word [reg_ebx]		; -> device request header
  7250 00002CFB 26297710                	sub word [es:bx + 0Eh + 2], si	; -> behind memory in use
  7251 00002CFF 16                      	push ss
  7252 00002D00 07                      	pop es
  7253                                   %endif
  7254                                  @@:
  7255                                  
  7256 00002D01 F7DE                    	neg si
  7257                                  
  7258                                  %if _APP_ENV_SIZE || _DEV_ENV_SIZE
  7259                                  .relocate_env:
  7260 00002D03 2ED006[710E]            	rol byte [cs:app_env_allocation], 1
  7261 00002D08 7204                    	jc @F
  7262 00002D0A 01362C00                	add word [2Ch], si
  7263                                  @@:
  7264 00002D0E 833E[0000]00            	cmp word [envseg], 0
  7265 00002D13 7404                    	je @F
  7266 00002D15 0136[0000]              	add word [envseg], si
  7267                                  @@:
  7268                                  %endif
  7269                                  
  7270                                  %if _EXTENSIONS
  7271                                  .relocate_ext:
  7272 00002D19 0136[0000]              	add word [extseg], si
  7273                                  %endif
  7274                                  
  7275                                  .keep:
  7276 00002D1D 8B0E[0000]              	mov cx, word [historyseg_size]
  7277 00002D21 8E06[0000]              	mov es, word [history.segorsel + soaSegSel]
  7278 00002D25 31FF                    	xor di, di
  7279 00002D27 B000                    	mov al, 0
  7280 00002D29 F3AA                    	rep stosb			; init history buffer
  7281                                  %endif
  7282                                  
  7283                                  
  7284                                  init_relocate:
  7285 00002D2B 2ED006[6D0E]            	rol byte [cs:init_switch_t], 1
  7286 00002D30 7203E9E601              	jnc .done_outer
  7287                                  %if _DEVICE
  7288 00002D35 F606[0200]40            	testopt [internalflags6], dif6_device_mode
  7289 00002D3A 7403E9D601              	jnz .error_outer
  7290                                  %endif
  7291                                  
  7292 00002D3F 2ED006[6F0E]            	rol byte [cs:init_switch_t_break], 1
  7293 00002D44 7301                    	jnc @F
  7294 00002D46 CC                      	int3
  7295                                  @@:
  7296                                  
  7297 00002D47 B80258                  		mov ax, 5802h			; Get UMB link state
  7298 00002D4A CD21                    		int 21h
  7299 00002D4C 30E4                    		xor ah, ah
  7300 00002D4E 50                      		push ax				; Save UMB link state
  7301 00002D4F B80058                  		mov ax, 5800h			; Get allocation strategy
  7302 00002D52 CD21                    		int 21h
  7303 00002D54 50                      		push ax				; Save allocation strategy
  7304                                  
  7305 00002D55 31FF                    	xor di, di				; first set
  7306                                  .retry_alloc:
  7307 00002D57 B80358                  		mov ax, 5803h			; Set UMB link state:
  7308 00002D5A 2E8B9D[540E]            		mov bx, [cs:init_switch_t_umblink + di]
  7309 00002D5F 83FBFF                  		cmp bx, -1			; not set ?
  7310 00002D62 7503E98A01              		je .error_no_alloc_retry	; then error out -->
  7311 00002D67 CD21                    		int 21h
  7312 00002D69 B80158                  		mov ax, 5801h			; Set allocation strategy:
  7313 00002D6C 2E8B9D[5A0E]            		mov bx, [cs:init_switch_t_strategy + di]
  7314 00002D71 CD21                    		int 21h
  7315                                  
  7316                                  		; allocate new memory block for process
  7317 00002D73 2E8B1E[360E]            	mov bx, word [cs:memsize]
  7318 00002D78 B448                    	mov ah, 48h
  7319 00002D7A CD21                    	int 21h
  7320 00002D7C 7303E97001              	jc .error_no_alloc_retry
  7321                                  
  7322 00002D81 92                      	xchg dx, ax			; dx => new process block
  7323                                  
  7324                                  		; allocate new memory block for environment
  7325                                  %if _APP_ENV_SIZE
  7326 00002D82 2ED006[710E]            	rol byte [cs:app_env_allocation], 1
  7327 00002D87 732D                    	jnc @F
  7328                                  %endif
  7329 00002D89 A12C00                  	mov ax, word [2Ch]
  7330 00002D8C 85C0                    	test ax, ax			; zero ?
  7331 00002D8E 7426                    	jz .allocated			; yes, nothing to relocate -->
  7332 00002D90 48                      	dec ax
  7333 00002D91 8EC0                    	mov es, ax			; es => MCB
  7334 00002D93 268B1E0300              	mov bx, word [es:3]		; = MCB size
  7335 00002D98 B448                    	mov ah, 48h
  7336 00002D9A CD21                    	int 21h				; allocate
  7337 00002D9C 7303E94A01              	jc .error_no_alloc_retry_free_dx
  7338                                  
  7339                                  		; relocate environment
  7340 00002DA1 52                      	push dx
  7341 00002DA2 92                      	xchg dx, ax			; dx => target
  7342 00002DA3 A12C00                  	mov ax, word [2Ch]		; ax => source
  7343 00002DA6 89D9                    	mov cx, bx			; cx = amount paragraphs
  7344 00002DA8 E8A1EC                  	call init_movp
  7345 00002DAB 89162C00                	mov word [2Ch], dx		; relocate environment
  7346 00002DAF 5A                      	pop dx				; => process memory block target
  7347 00002DB0 8EC0                    	mov es, ax
  7348 00002DB2 B449                    	mov ah, 49h
  7349 00002DB4 CD21                    	int 21h				; explicitly free old environment
  7350                                  					;  (not needed depending on method)
  7351                                  @@:
  7352                                  
  7353                                  .allocated:	; dx => new process block
  7354 00002DB6 8CD0                    	mov ax, ss			; => source process block
  7355 00002DB8 2E8B0E[360E]            	mov cx, word [cs:memsize]	; cx = amount paragraphs
  7356 00002DBD 2E890E[520E]            	mov word [cs:init_target_size], cx
  7357 00002DC2 E887EC                  	call init_movp
  7358                                  
  7359 00002DC5 2EA3[4A0E]              	mov word [cs:relocate_source], ax
  7360 00002DC9 48                      	dec ax
  7361 00002DCA 1E                      	push ds
  7362 00002DCB 8ED8                    	mov ds, ax			; ds => original block MCB
  7363 00002DCD 89160100                	mov word [1], dx		; set original block owner to new
  7364                                  
  7365 00002DD1 89D0                    	mov ax, dx
  7366 00002DD3 48                      	dec ax
  7367 00002DD4 8EC0                    	mov es, ax			; es => new block MCB
  7368 00002DD6 2689160100              	mov word [es:1], dx		; set new block owner to new
  7369                                  
  7370 00002DDB BF0800                  	mov di, 8		; es:di-> MCB name field
  7371 00002DDE 89FE                    	mov si, di
  7372 00002DE0 A5                      	movsw
  7373 00002DE1 A5                      	movsw
  7374 00002DE2 A5                      	movsw
  7375 00002DE3 A5                      	movsw			; Force MCB string
  7376 00002DE4 1F                      	pop ds			; restore => old block
  7377                                  
  7378 00002DE5 A12C00                  	mov ax, word [2Ch]		; => environment, or zero
  7379 00002DE8 85C0                    	test ax, ax
  7380 00002DEA 7408                    	jz @F
  7381 00002DEC 48                      	dec ax
  7382 00002DED 8EC0                    	mov es, ax			; => environment MCB
  7383 00002DEF 2689160100              	mov word [es:1], dx		; set environment block owner to new
  7384                                  @@:
  7385                                  
  7386 00002DF4 8CD0                    	mov ax, ss			; ax => old PSP
  7387 00002DF6 8ED2                    	mov ss, dx			; relocate stack
  7388 00002DF8 90                      	nop
  7389                                  					; ds still => old PSP
  7390 00002DF9 92                      	xchg ax, dx			; ax => new PSP, dx => old PSP
  7391                                  
  7392                                  		; code from ecm TSR
  7393 00002DFA 8EC0                    	mov es, ax		; es = new PSP
  7394 00002DFC BF1800                  	mov di, 18h
  7395 00002DFF B91400                  	mov cx, 20
  7396 00002E02 26A33600                	mov word [ es:34h+2 ], ax
  7397 00002E06 26893E3400              	mov word [ es:34h ], di	; fix the new PSP's PHT pointer
  7398 00002E0B 26890E3200              	mov word [ es:32h ], cx	;  and the count of PHT entries field
  7399 00002E10 50                      	 push ax
  7400 00002E11 B0FF                    	mov al, -1
  7401 00002E13 57                      	 push di
  7402 00002E14 89CB                    	mov bx, cx		; = 20
  7403 00002E16 F3AA                    	rep stosb		; initialise new PHT with empty entries
  7404 00002E18 5F                      	 pop di
  7405 00002E19 8B0E3200                	mov cx, word [ 32h ]	; cx = count of PHT entries
  7406 00002E1D 39D9                    	cmp cx, bx		; >= 20 ?
  7407 00002E1F 7202                    	jb .shortertable	; no -->
  7408 00002E21 89D9                    	mov cx, bx		; limit to 20
  7409                                  .shortertable:
  7410 00002E23 C5363400                	lds si, [ 34h ]		; ds:si-> old PHT
  7411 00002E27 56                      	push si
  7412 00002E28 51                      	push cx
  7413 00002E29 F3A4                    	rep movsb		; get all entries
  7414 00002E2B 59                      	pop cx
  7415 00002E2C 5F                      	pop di
  7416 00002E2D 1E                      	 push ds
  7417 00002E2E 07                      	 pop es			; es:di-> old PHT
  7418 00002E2F F3AA                    	rep stosb		; fill moved entries with -1 (closed)
  7419 00002E31 58                      	 pop ax
  7420 00002E32 8EDA                    	mov ds, dx		; ds = old PSP
  7421 00002E34 C7060A00[692E]          	mov word [ 0Ah ], .terminated
  7422 00002E3A 8C0E0C00                	mov word [ 0Ah+2 ], cs	; Parent Return Address -> us
  7423                                  %if 0		; (not used)
  7424                                  	mov word [ 0Eh ], i23
  7425                                  	mov word [ 0Eh+2 ], ax
  7426                                  	mov word [ 12h ], i24
  7427                                  	mov word [ 12h+2 ], ax	; set interrupt vectors to ours
  7428                                  %endif
  7429 00002E3E A31600                  	mov word [ 16h ], ax	; set parent PSP to the relocated one
  7430 00002E41 36A33000                	mov word [ ss:2Eh+2 ], ax
  7431                                  				; set SS used by process termination
  7432                                  
  7433 00002E45 93                      	xchg ax, bx		; bx = new location, dx = old location
  7434 00002E46 B85D33                  	mov ax, 335Dh
  7435 00002E49 CD21                    	int 21h			; PSP relocated call-out
  7436                                  
  7437                                  		; In order to set the correct stack address here,
  7438                                  		; the last Int21 call to a usual function (such as
  7439                                  		; Int21.48, .49) must've been made with the same stack
  7440                                  		; pointer as the Int21.4C call below gets.
  7441                                  		;
  7442                                  		; Update: dosemu2 does weird things to the stack.
  7443                                  		;  In particular, it inserts an additional iret
  7444                                  		;  frame depending on some conditions.
  7445                                  		; Only the interrupt 21h subfunctions 00h, 26h,
  7446                                  		;  31h, 4Bh, and 4Ch are handled differently.
  7447                                  		;  As a workaround we can call service 4Bh as the
  7448                                  		;  last interrupt 21h function before terminating.
  7449                                  		; Refer to https://github.com/dosemu2/dosemu2/blob/d7402eec84478c051d25e7b26dd8515514c186e2/src/base/core/int.c#L1633-L1639
  7450                                  
  7451                                  	; rol byte [j_flags.invalidexec], 1
  7452                                  	; jnc @F
  7453                                  
  7454 00002E4B 0E                      	push cs
  7455 00002E4C 1F                      	pop ds
  7456 00002E4D BA[632E]                	mov dx, .nullbyte	; just in case, ds:dx -> zero value byte
  7457 00002E50 B87F4B                  	mov ax, 4B7Fh		; 21.4B with invalid subfunction in al
  7458                                  				;  (note that FreeDOS masks off 80h)
  7459 00002E53 CD21                    	int 21h
  7460                                  @@:
  7461                                  
  7462 00002E55 2E8E06[4A0E]            	mov es, word [cs:relocate_source]
  7463 00002E5A 26FF362E00              	push word [ es:2Eh ]
  7464 00002E5F 368F062E00              	pop word [ ss:2Eh ]	; set SP used by process termination
  7465                                  .nullbyte: equ $ - 1
  7466                                  
  7467 00002E64 B8004C                  	mov ax, 4C00h
  7468 00002E67 CD21                    	int 21h			; terminate, and make the new PSP active
  7469                                  				; also handles freeing all memory allocated to the old PSP
  7470                                  				; also closes any handles >20 if PHT larger
  7471                                  			; (not used) also relocates Int23, Int24
  7472                                  				; also notifies resident software old PSP is no longer valid
  7473                                  .terminated:			; (ax, bx, es might be changed)
  7474 00002E69 16                      	push ss
  7475 00002E6A 1F                      	pop ds
  7476 00002E6B 16                      	push ss
  7477 00002E6C 07                      	pop es
  7478                                  		; end code from ecm TSR
  7479                                  
  7480                                  
  7481                                  .relocate:
  7482 00002E6D 2E8326[4C0E]00          	and word [cs:relocate_down], 0	; = 0
  7483 00002E73 8CD6                    	mov si, ss
  7484 00002E75 2E2B36[4A0E]            	sub si, word [cs:relocate_source]
  7485 00002E7A 7305                    	jnc @F
  7486 00002E7C 2EF716[4C0E]            	not word [cs:relocate_down]	; = 0FFFFh
  7487                                  @@:
  7488                                  		; target - source = delta
  7489                                  		; delta + source = target
  7490                                  		;  because target - source + source = target
  7491                                  
  7492                                  %if _HISTORY_SEPARATE_FIXED && _HISTORY
  7493                                  .relocate_history:
  7494 00002E81 0136[0000]              	add word [history.segorsel + soaSegSel], si
  7495                                  %if _PM
  7496 00002E85 0136[0200]              	add word [history.segorsel + soaSegment], si
  7497                                  %endif
  7498                                  %endif
  7499                                  
  7500                                  %if _APP_ENV_SIZE
  7501                                  .relocate_env:
  7502 00002E89 2ED006[710E]            	rol byte [cs:app_env_allocation], 1
  7503 00002E8E 7204                    	jc @F
  7504 00002E90 01362C00                	add word [2Ch], si
  7505                                  @@:
  7506 00002E94 833E[0000]00            	cmp word [envseg], 0
  7507 00002E99 7404                    	je @F
  7508 00002E9B 0136[0000]              	add word [envseg], si
  7509                                  @@:
  7510                                  %endif
  7511                                  
  7512                                  %if _EXTENSIONS
  7513                                  .relocate_ext:
  7514 00002E9F 0136[0000]              	add word [extseg], si
  7515                                  %endif
  7516                                  
  7517                                  .relocate_code:
  7518 00002EA3 A1[0000]                	mov ax, word [code_seg]
  7519 00002EA6 89C2                    	mov dx, ax
  7520 00002EA8 01F2                    	add dx, si
  7521                                  
  7522 00002EAA 8EC2                    	mov es, dx
  7523 00002EAC 0136[0000]              	add word [code_seg], si
  7524                                  %if _DUALCODE
  7525 00002EB0 0136[0000]              	add word [code2_seg], si
  7526 00002EB4 8B16[0000]              	mov dx, word [code2_seg]
  7527 00002EB8 56                      	push si
  7528                                   %if ! _PM
  7529                                  	mov si, relocate_from_code
  7530                                  	mov di, relocate_from_code.end
  7531                                  	call .relocate_code_patch
  7532                                  	mov si, relocate_from_code2
  7533                                  	mov di, relocate_from_code2.end
  7534                                   %endif
  7535 00002EB9 06                      	push es
  7536 00002EBA 8EC2                    	mov es, dx
  7537 00002EBC 5A                      	pop dx
  7538                                   %if ! _PM
  7539                                  	call .relocate_code_patch
  7540                                  	jmp .relocate_code_done
  7541                                  
  7542                                  .relocate_code_loop:
  7543                                  	cs lodsw
  7544                                  	xchg bx, ax
  7545                                  	mov word [es:bx], dx
  7546                                  .relocate_code_patch:
  7547                                  	cmp si, di
  7548                                  	jb .relocate_code_loop
  7549                                  	retn
  7550                                  
  7551                                  .relocate_code_done:
  7552                                   %endif
  7553 00002EBD 5E                      	pop si
  7554                                  %endif
  7555                                  
  7556                                  %if _AREAS && _AREAS_HOOK_CLIENT
  7557                                  	mov ax, si
  7558                                  	mov dx, word [cs:relocate_down]
  7559                                  	call add_to_areas_linear_code1.dxax
  7560                                   %if _DUALCODE && _EXPRDUALCODE
  7561                                  	mov ax, si
  7562                                  	mov dx, word [cs:relocate_down]
  7563                                  	call add_to_areas_linear_code2.dxax
  7564                                   %endif
  7565                                  %endif
  7566                                  
  7567                                  
  7568                                  .relocate_auxbuff:
  7569 00002EBE 0136[0000]              	add word [auxbuff_segorsel + soaSegSel], si
  7570                                  %if _PM
  7571 00002EC2 0136[0200]              	add word [auxbuff_segorsel + soaSegment], si
  7572                                  					; initialise auxbuff references
  7573                                  %endif
  7574                                  %if _IMMASM  && _IMMASM_AUXBUFF
  7575                                  	add word [immseg], si
  7576                                  %endif
  7577                                  
  7578                                  
  7579                                  %if _MESSAGESEGMENT
  7580                                  .relocate_messagesegment:
  7581 00002EC6 0136[0000]              	add word [messageseg], si
  7582                                   %if _HELP_COMPRESSED && ! _PM
  7583                                  	add word [hshrink_memory_source.segment], si
  7584                                   %endif
  7585                                  %endif
  7586                                  
  7587                                  
  7588                                  .relocate_old_initcode_variables:
  7589 00002ECA 8CD8                    	mov ax, ds
  7590 00002ECC A3[0200]                	mov word [execblk.cmdline + 2], ax
  7591 00002ECF A3[0200]                	mov word [execblk.fcb1 + 2], ax
  7592 00002ED2 A3[0200]                	mov word [execblk.fcb2 + 2], ax	; set up parameter block for exec command
  7593 00002ED5 A3[0000]                	mov word [pspdbg], ax
  7594                                  
  7595                                  %if _IMMASM  && !_IMMASM_AUXBUFF
  7596                                   %ifn _LINK
  7597                                  	add ax, (immasm_buffer + DATASECTIONFIXUP) >> 4
  7598                                   %else
  7599 00002ED8 05[0000]                	add ax, strict word immasm_buffer
  7600                                   wlcalc word_shr_4, equ $ - 2
  7601                                   %endif
  7602 00002EDB A3[0000]                	mov word [immseg], ax
  7603                                  %endif
  7604                                  
  7605                                  
  7606                                  %if _AREAS_HOOK_SERVER
  7607                                  .relocate_areas:
  7608 00002EDE 8CD8                    	mov ax, ds
  7609 00002EE0 A3[0200]                	mov word [ddebugareas.next + 2], ax
  7610 00002EE3 A3[0200]                	mov word [ddebugareas.prev + 2], ax
  7611 00002EE6 A3[0000]                	mov word [..@patch_entry_seg], ax
  7612                                  %endif
  7613                                  
  7614                                  
  7615                                  .relocate_done:
  7616 00002EE9 EB16                    	jmp .done
  7617                                  
  7618                                  
  7619                                  		; environment could not be allocated
  7620                                  .error_no_alloc_retry_free_dx:
  7621 00002EEB 8EC2                    	mov es, dx
  7622 00002EED B449                    	mov ah, 49h
  7623 00002EEF CD21                    	int 21h				; free allocated block
  7624                                  
  7625                                  		; some memory could not be allocated
  7626                                  .error_no_alloc_retry:
  7627 00002EF1 AF                      	scasw				; di += 2
  7628 00002EF2 83FF06                  	cmp di, 6
  7629 00002EF5 7303E95DFE              	jb .retry_alloc
  7630                                  
  7631                                  .error_no_retry:
  7632 00002EFA 2ED006[6E0E]            	rol byte [cs:init_switch_t_ignore], 1
  7633 00002EFF 7301                    	jnc .error
  7634                                  
  7635                                  .done:
  7636 00002F01 A8                      	db __TEST_IMM8			; (skip stc, NC)
  7637                                  .error:
  7638 00002F02 F9                      	stc				; CY
  7639                                  .status:
  7640 00002F03 19D2                    	sbb dx, dx				; 0 = NC, -1 = CY
  7641 00002F05 5B                      		pop bx				; saved allocation strategy
  7642 00002F06 B80158                  		mov ax, 5801h
  7643 00002F09 CD21                    		int 21h				; Set allocation strategy
  7644 00002F0B 5B                      		pop bx				; saved UMB link state
  7645 00002F0C B80358                  		mov ax, 5803h
  7646 00002F0F CD21                    		int 21h				; Set UMB link state
  7647 00002F11 85D2                    	test dx, dx
  7648 00002F13 7406                    	jz .done_outer
  7649                                  .error_outer:
  7650 00002F15 BA[B00F]                	mov dx, imsg.relocate_failure
  7651 00002F18 E9F5F2                  	jmp ..@init_cmdline_error
  7652                                  
  7653                                  .done_outer:
  7654                                  
  7655                                  
  7656                                  %if _EXECUTABLE
  7657                                  init_executable:
  7658 00002F1B 16                      	push ss
  7659 00002F1C 1F                      	pop ds
  7660 00002F1D 16                      	push ss
  7661 00002F1E 07                      	pop es
  7662 00002F1F F606[0200]40            	testopt [internalflags6], dif6_device_mode
  7663 00002F24 7539                    	jnz .device
  7664                                  
  7665                                  .application:
  7666 00002F26 8B162C00                	mov dx, word [2Ch]
  7667 00002F2A 85D2                    	test dx, dx
  7668 00002F2C 746B                    	jz .unable
  7669 00002F2E 8EC2                    	mov es, dx
  7670 00002F30 B90080                  	mov cx, 8000h
  7671 00002F33 31F6                    	xor si, si
  7672                                  @@:
  7673 00002F35 E81900                  	call .nextvar
  7674 00002F38 725F                    	jc .unable
  7675 00002F3A 75F9                    	jne @B
  7676 00002F3C 46                      	inc si
  7677 00002F3D 26AD                    	es lodsw
  7678 00002F3F 83F801                  	cmp ax, 1
  7679 00002F42 7555                    	jne .unable
  7680                                  
  7681 00002F44 06                      	push es
  7682 00002F45 1F                      	pop ds				; => env
  7683 00002F46 16                      	push ss
  7684 00002F47 07                      	pop es				; => data entry
  7685 00002F48 BF[0000]                	mov di, init_executable_pathname
  7686 00002F4B B460                    	mov ah, 60h
  7687 00002F4D CD21                    	int 21h
  7688 00002F4F EB48                    	jmp .done
  7689                                  
  7690                                  .nextvar:
  7691                                  @@:
  7692 00002F51 26AC                    	es lodsb
  7693 00002F53 84C0                    	test al, al
  7694 00002F55 E0FA                    	loopnz @B
  7695 00002F57 F9                      	stc
  7696 00002F58 7504                    	jnz @F
  7697 00002F5A 26803C00                	cmp byte [es:si], 0
  7698                                  @@:
  7699 00002F5E C3                      	retn
  7700                                  
  7701                                  
  7702                                  .device:
  7703 00002F5F 8B36[0000]              	mov si, word [reg_ebx]
  7704 00002F63 8E1E[0000]              	mov ds, word [reg_es]
  7705 00002F67 C57412                  	lds si, [si + 12h]
  7706                                  
  7707 00002F6A 89F7                    	mov di, si
  7708                                  @@:
  7709 00002F6C AC                      	lodsb
  7710 00002F6D 3C20                    	cmp al, 32
  7711 00002F6F 7412                    	je @F
  7712 00002F71 3C09                    	cmp al, 9
  7713 00002F73 740E                    	je @F
  7714 00002F75 3C00                    	cmp al, 0
  7715 00002F77 740A                    	je @F
  7716 00002F79 3C0D                    	cmp al, 13
  7717 00002F7B 7406                    	je @F
  7718 00002F7D 3C0A                    	cmp al, 10
  7719 00002F7F 7402                    	je @F
  7720 00002F81 EBE9                    	jmp @B
  7721                                  
  7722                                  @@:
  7723 00002F83 FF74FF                  	push word [si - 1]
  7724 00002F86 56                      	push si
  7725 00002F87 C644FF00                	mov byte [si - 1], 0
  7726 00002F8B 89FE                    	mov si, di
  7727 00002F8D BF[0000]                	mov di, init_executable_pathname
  7728 00002F90 B460                    	mov ah, 60h
  7729 00002F92 CD21                    	int 21h
  7730 00002F94 5E                      	pop si
  7731 00002F95 58                      	pop ax
  7732 00002F96 8844FF                  	mov byte [si - 1], al
  7733                                  
  7734                                  .done:
  7735                                  .unable:
  7736 00002F99 16                      	push ss
  7737 00002F9A 1F                      	pop ds
  7738 00002F9B 16                      	push ss
  7739 00002F9C 07                      	pop es
  7740                                  
  7741 00002F9D BF[0000]                	mov di, init_executable_pathname
  7742 00002FA0 31C0                    	xor ax, ax
  7743 00002FA2 B98000                  	mov cx, 128
  7744 00002FA5 F2AE                    	repne scasb
  7745 00002FA7 4F                      	dec di
  7746 00002FA8 893E[0000]              	mov word [init_executable_pathname.end], di
  7747                                  %endif
  7748                                  
  7749                                  
  7750                                  init_hook_interrupts:
  7751                                  %if CATCHINTAMOUNT
  7752                                  		; Set up interrupt vectors.
  7753                                  %if _CATCHINT06 && _DETECT95LX
  7754 00002FAC 8B0E[0000]              	mov cx, word [inttab_number_variable]
  7755                                  %else
  7756                                  	mov cx, inttab_number
  7757                                  %endif
  7758 00002FB0 E319                    	jcxz .intend
  7759 00002FB2 BE[0000]                	mov si, inttab
  7760                                  .intloop:
  7761 00002FB5 AC                      	lodsb
  7762 00002FB6 B435                    	mov ah, 35h
  7763 00002FB8 CD21                    	int 21h			; get vector
  7764 00002FBA 97                      	xchg ax, di
  7765 00002FBB AD                      	lodsw
  7766 00002FBC 97                      	xchg ax, di
  7767                                  %if _DEBUG && !_DEBUG_COND
  7768                                  				; vectors are set only when debuggee runs
  7769                                  %else
  7770                                   %if _DEBUG
  7771                                  	testopt [internalflags6], dif6_debug_mode
  7772                                  	jnz @F
  7773                                   %endif
  7774 00002FBD 895D02                  	mov word [ di + ieNext ], bx
  7775 00002FC0 8C4504                  	mov word [ di + ieNext + 2 ], es
  7776                                  				; store it
  7777 00002FC3 89FA                    	mov dx, di
  7778 00002FC5 B425                    	mov ah, 25h		; set interrupt vector
  7779 00002FC7 CD21                    	int 21h			; ds => lDEBUG_DATA_ENTRY
  7780                                  @@:
  7781                                  %endif
  7782 00002FC9 E2EA                    	loop .intloop
  7783                                  
  7784                                  .intend:
  7785                                  %endif
  7786                                  
  7787                                  
  7788                                  		; Disabled this. hook2F (debug.asm) now detects this condition.
  7789                                  %if _PM && 0
  7790                                  		; Windows 9x and DosEmu are among those hosts which handle some
  7791                                  		; V86 Ints internally without first calling the interrupt chain.
  7792                                  		; This causes various sorts of troubles and incompatibilities;
  7793                                  		; in our case, hooking interrupt 2Fh would not intercept calls
  7794                                  		; made to the DPMI interface because the host sees them first.
  7795                                   %if _WIN9XSUPP
  7796                                    %if _GUARD_86M_INT2F
  7797                                  	push es
  7798                                  	xor ax, ax
  7799                                  	mov es, ax		; (only used in 86 Mode)
  7800                                  	mov ax, [es:2Fh * 4]
  7801                                  	cmp ax, -1
  7802                                  	je @F			; --> (ZR)
  7803                                  	or ax, [es:2Fh * 4 + 2]
  7804                                  @@:
  7805                                  	pop es
  7806                                  	jz @F
  7807                                    %endif
  7808                                  	mov ax, 1600h		; running in a Win9x DOS box?
  7809                                  	int 2Fh
  7810                                  	cmp al, 4
  7811                                  	jge .no2Fhook		; this is intentionally a signed comparison!
  7812                                  @@:
  7813                                   %endif
  7814                                   %if _DOSEMU
  7815                                  	testopt [internalflags], runningdosemu
  7816                                  	jnz .no2Fhook
  7817                                   %endif
  7818                                   %if _WIN9XSUPP || _DOSEMU
  7819                                  	jmp short .dpmihostchecked
  7820                                  .no2Fhook:
  7821                                  	clropt [options4], opt4_int_2F_hook
  7822                                  .dpmihostchecked:
  7823                                   %endif
  7824                                  %endif
  7825                                  
  7826                                  %if _EXTENSIONS
  7827                                  init_eld_app_dev:
  7828 00002FCB E83D04                  	call init_eld
  7829                                  %else
  7830                                  	push ds
  7831                                  	pop es
  7832                                  %endif
  7833                                  
  7834                                  set_parent_pra:
  7835                                  		; Save, then modify termination address and parent PSP.
  7836                                  %if _DEVICE && _APPLICATION
  7837 00002FCE F606[0200]40            	testopt [internalflags6], dif6_device_mode
  7838 00002FD3 7403E94201              	jnz final_device
  7839                                  %elif _DEVICE
  7840                                  	jmp final_device
  7841                                  %endif
  7842                                  %if _APPLICATION
  7843 00002FD8 BE0A00                  	mov si, TPIV
  7844 00002FDB BF[0000]                	mov di, psp22
  7845 00002FDE A5                      	movsw
  7846 00002FDF A5                      	movsw				; save Int22
  7847 00002FE0 BA[0000]                	mov dx, debug22
  7848 00002FE3 8954FC                  	mov word [ si-4 ], dx
  7849 00002FE6 8C5CFE                  	mov word [ si-2 ], ds		; set pspInt22 (required)
  7850 00002FE9 BE1600                  	mov si, 16h
  7851 00002FEC A5                      	movsw				; save parent
  7852 00002FED 8C5CFE                  	mov word [ si-2 ], ds		; set pspParent
  7853 00002FF0 B82225                  	mov ax, 2522h			; set Int22
  7854 00002FF3 CD21                    	int 21h				; (not really required)
  7855                                  
  7856                                  init_app_allocate_reserved:
  7857 00002FF5 B80258                  		mov ax, 5802h			; Get UMB link state
  7858 00002FF8 CD21                    		int 21h
  7859 00002FFA 30E4                    		xor ah, ah
  7860 00002FFC 50                      		push ax				; Save UMB link state
  7861 00002FFD B80058                  		mov ax, 5800h			; Get allocation strategy
  7862 00003000 CD21                    		int 21h
  7863 00003002 50                      		push ax				; Save allocation strategy
  7864                                  
  7865 00003003 B80358                  		mov ax, 5803h			; Set UMB link state:
  7866 00003006 BB0100                  		mov bx, 1			; enabled
  7867 00003009 CD21                    		int 21h
  7868 0000300B B80158                  		mov ax, 5801h			; Set allocation strategy:
  7869 0000300E 31DB                    		xor bx, bx			; first fit, LMA then UMA
  7870 00003010 CD21                    		int 21h
  7871                                  
  7872 00003012 2E8B16[4E0E]            	mov dx, word [cs:init_switch_r]
  7873                                  .loop:
  7874 00003017 31DB                    	xor bx, bx
  7875 00003019 B448                    	mov ah, 48h
  7876 0000301B CD21                    	int 21h
  7877 0000301D 722D                    	jc .done
  7878 0000301F 8EC0                    	mov es, ax
  7879 00003021 39D0                    	cmp ax, dx
  7880 00003023 7606                    	jbe .grow
  7881                                  .free:
  7882 00003025 B449                    	mov ah, 49h
  7883 00003027 CD21                    	int 21h
  7884 00003029 EB21                    	jmp .done
  7885                                  
  7886                                  .grow:
  7887 0000302B 50                      	push ax
  7888 0000302C 93                      	xchg bx, ax
  7889 0000302D F7DB                    	neg bx
  7890 0000302F 01D3                    	add bx, dx				; = dx - bx
  7891 00003031 B44A                    	mov ah, 4Ah
  7892 00003033 CD21                    	int 21h					; grow up to desired segment
  7893 00003035 58                      	pop ax					;  (if not free grow less)
  7894                                  
  7895 00003036 85DB                    	test bx, bx
  7896 00003038 7501                    	jnz .nonempty
  7897 0000303A 48                      	dec ax					; => MCB (hack into the name field)
  7898                                  .nonempty:
  7899 0000303B 8EC0                    	mov es, ax
  7900 0000303D 26891E0C00              	mov word [es:12], bx			; size (0 if in MCB)
  7901 00003042 8706[0000]              	xchg ax, word [next_reserved_segment]	; :12 -> chain
  7902 00003046 26A30E00                	mov word [es:14], ax			; => next in chain
  7903 0000304A EBCB                    	jmp .loop
  7904                                  
  7905                                  .done:
  7906 0000304C 5B                      		pop bx				; saved allocation strategy
  7907 0000304D B80158                  		mov ax, 5801h
  7908 00003050 CD21                    		int 21h				; Set allocation strategy
  7909 00003052 5B                      		pop bx				; saved UMB link state
  7910 00003053 B80358                  		mov ax, 5803h
  7911 00003056 CD21                    		int 21h				; Set UMB link state
  7912                                  
  7913                                  init_app_resize:
  7914                                  		; shrink to required resident size
  7915 00003058 1E                      	push ds
  7916 00003059 07                      	pop es
  7917 0000305A 2EA1[360E]              	mov ax, word [cs:memsize]
  7918 0000305E A3[0000]                	mov word [alloc_size_not_reserved], ax
  7919 00003061 8CD8                    	mov ax, ds
  7920 00003063 2E8B16[4E0E]            	mov dx, word [cs:init_switch_r]
  7921 00003068 8916[0000]              	mov word [reserved_address], dx
  7922 0000306C 39D0                    	cmp ax, dx
  7923 0000306E 7325                    	jae @F
  7924 00003070 2E8B1E[520E]            	mov bx, word [cs:init_target_size]
  7925 00003075 01D8                    	add ax, bx
  7926 00003077 39D0                    	cmp ax, dx
  7927 00003079 7215                    	jb .fulltargetsize
  7928 0000307B 8CD8                    	mov ax, ds
  7929 0000307D 2E0306[360E]            	add ax, word [cs:memsize]
  7930 00003082 39D0                    	cmp ax, dx
  7931 00003084 730F                    	jae @F					; no action needed
  7932 00003086 89D3                    	mov bx, dx
  7933 00003088 8CD8                    	mov ax, ds
  7934 0000308A 29C3                    	sub bx, ax				; grow it up to /R (or less)
  7935 0000308C B44A                    	mov ah, 4Ah
  7936 0000308E CD21                    	int 21h					; get bx = actual size
  7937                                  .fulltargetsize:
  7938 00003090 2E891E[360E]            	mov word [cs:memsize], bx
  7939                                  @@:
  7940 00003095 B44A                    	mov ah, 4Ah
  7941 00003097 2E8B1E[360E]            	mov bx, word [cs:memsize]
  7942 0000309C 891E[0000]              	mov word [alloc_size], bx
  7943 000030A0 8C1E[0000]              	mov word [alloc_seg], ds
  7944                                  
  7945                                  
  7946 000030A4 2ED006[6D0E]            	rol byte [cs:init_switch_t], 1
  7947 000030A9 7209                    	jc .application_relocate
  7948                                  
  7949                                  .application_no_relocate:
  7950 000030AB BE[0000]                	mov si, initcont
  7951 000030AE FF36[0000]              	push word [code_seg]
  7952 000030B2 56                      	push si
  7953 000030B3 CB                      	retf
  7954                                  
  7955                                  .application_relocate:
  7956 000030B4 83EC08                  	sub sp, .relocate_trampoline_size_w * 2
  7957 000030B7 89E7                    	mov di, sp			; es:di -> stack space
  7958 000030B9 0E                      	push cs
  7959 000030BA 1F                      	pop ds
  7960 000030BB BE[1231]                	mov si, .relocate_trampoline	; ds:si -> trampoline code
  7961 000030BE B90400                  	mov cx, .relocate_trampoline_size_w
  7962 000030C1 57                      	 push di
  7963 000030C2 F3A5                    	rep movsw			; place trampoline
  7964 000030C4 5F                      	 pop di
  7965                                  
  7966 000030C5 BE[0000]                	mov si, initcont
  7967 000030C8 36FF36[0000]            	push word [ss:code_seg]
  7968 000030CD 56                      	push si				; place our return address
  7969                                  
  7970 000030CE 06                      	push es
  7971 000030CF 53                      	push bx
  7972 000030D0 50                      	push ax				; stack for trampoline
  7973                                  
  7974 000030D1 B549                    	mov ch, 49h			; set up to free original block
  7975 000030D3 A1[4A0E]                	mov ax, word [relocate_source]
  7976 000030D6 50                      	 push ax			; => source block
  7977 000030D7 8B16[4E0E]              	mov dx, word [init_switch_r]
  7978 000030DB 39D0                    	cmp ax, dx
  7979 000030DD 732A                    	jae @F
  7980 000030DF 2E8B1E[500E]            	mov bx, word [cs:init_base_size]
  7981 000030E4 01D8                    	add ax, bx
  7982 000030E6 39D0                    	cmp ax, dx
  7983 000030E8 7206                    	jb .fullbasesize
  7984 000030EA 89D3                    	mov bx, dx
  7985 000030EC 58                      	 pop ax
  7986 000030ED 50                      	 push ax
  7987 000030EE 29C3                    	sub bx, ax
  7988                                  .fullbasesize:
  7989 000030F0 B54A                    	mov ch, 4Ah			; resize instead
  7990                                  
  7991 000030F2 58                      	 pop ax
  7992 000030F3 50                      	 push ax
  7993 000030F4 85DB                    	test bx, bx
  7994 000030F6 7501                    	jnz .nonempty
  7995 000030F8 48                      	dec ax					; => MCB (hack into the name field)
  7996                                  .nonempty:
  7997 000030F9 8EC0                    	mov es, ax
  7998 000030FB 26891E0C00              	mov word [es:12], bx			; size (0 if in MCB)
  7999 00003100 368706[0000]            	xchg ax, word [ss:next_reserved_segment]; :12 -> chain
  8000 00003105 26A30E00                	mov word [es:14], ax			; => next in chain
  8001                                  @@:
  8002 00003109 58                      	 pop ax
  8003 0000310A 8EC0                    	mov es, ax			; => relocate source
  8004 0000310C 91                      	xchg ax, cx			; ah = 49h or 4Ah
  8005                                  
  8006 0000310D 16                      	 push ss
  8007 0000310E 1F                      	 pop ds				; reset ds
  8008 0000310F 16                      	push ss
  8009 00003110 57                      	push di				; -> placed trampoline
  8010 00003111 CB                      	retf				; jump to trampoline
  8011                                  
  8012                                  
  8013                                  	align 2, nop
  8014                                  .relocate_trampoline:
  8015 00003112 CD21                    	int 21h				; free original process block
  8016 00003114 58                      	pop ax				; ah = 4Ah
  8017 00003115 5B                      	pop bx				; bx = memory size
  8018 00003116 07                      	pop es				; es => new block
  8019                                  		; (we do not really need to resize the block here
  8020                                  		;  as it was already allocated the wanted size.)
  8021 00003117 CA0800                  	retf .relocate_trampoline_size_w * 2
  8022                                  	align 2, nop
  8023                                   endarea .relocate_trampoline
  8024                                  
  8025                                  %endif
  8026                                  
  8027                                  
  8028                                  %if _DEVICE
  8029                                  final_device:
  8030 0000311A BE8000                  	mov si, 80h			; -> command line tail
  8031 0000311D 89F1                    	mov cx, si			; = 128
  8032 0000311F 29CC                    	sub sp, cx			; -> buffer on stack
  8033 00003121 89E7                    	mov di, sp
  8034 00003123 F3A4                    	rep movsb			; preserve it
  8035                                  
  8036                                   %if _DEV_ENV_SIZE
  8037 00003125 FF362C00                	push word [2Ch]
  8038                                   %endif
  8039                                  
  8040 00003129 8CDA                    	mov dx, ds
  8041 0000312B B455                    	mov ah, 55h
  8042 0000312D F8                      	clc
  8043 0000312E CD21                    	int 21h				; create child PSP
  8044                                  
  8045 00003130 BE0E00                  	mov si, TPIV + 4
  8046 00003133 BA[0000]                	mov dx, debug22
  8047 00003136 8954FC                  	mov word [ si-4 ], dx
  8048 00003139 8C5CFE                  	mov word [ si-2 ], ds		; set pspInt22 (required)
  8049                                   %if _DEVICE_SET_2324
  8050 0000313C C704[0000]              	mov word [ si ], devint23
  8051 00003140 8C5C02                  	mov word [ si + 2 ], ds		; set pspInt23
  8052 00003143 C74404[0000]            	mov word [ si + 4 ], devint24
  8053 00003148 8C5C06                  	mov word [ si + 6 ], ds		; set pspInt24
  8054                                   %endif
  8055 0000314B BE1800                  	mov si, 16h + 2
  8056 0000314E 8C5CFE                  	mov word [ si-2 ], ds		; set pspParent
  8057                                  	; mov ax, 2522h			; set Int22
  8058                                  	; int 21h			; (not really required)
  8059                                  
  8060                                   %if _DEV_ENV_SIZE
  8061 00003151 8F062C00                	pop word [2Ch]
  8062                                   %else
  8063                                  	xor ax, ax
  8064                                  	mov word [2Ch], ax		; set environment to none
  8065                                   %endif
  8066                                  
  8067 00003155 BB0500                  	mov bx, 5			; close file handles past std (5)
  8068 00003158 8B0E3200                	mov cx, word [32h]		; = number of file handles
  8069 0000315C 29D9                    	sub cx, bx			; = number past std handles
  8070 0000315E 7607                    	jbe @FF				; if <= 0 handles to close -->
  8071                                  @@:
  8072 00003160 B43E                    	mov ah, 3Eh
  8073 00003162 CD21                    	int 21h				; close file handle
  8074 00003164 43                      	inc bx				; next handle
  8075 00003165 E2F9                    	loop @B				; loop -->
  8076                                  @@:
  8077                                  
  8078 00003167 89E6                    	mov si, sp			; -> buffer on stack
  8079 00003169 BF8000                  	mov di, 80h			; -> command line tail buffer in PSP
  8080 0000316C 89F8                    	mov ax, di			; = 128
  8081 0000316E 89F9                    	mov cx, di			; = 128
  8082 00003170 F3A4                    	rep movsb			;
  8083 00003172 01C4                    	add sp, ax			; discard buffer
  8084                                  
  8085 00003174 BE[0000]                	mov si, initcont.device
  8086 00003177 FF36[0000]              	push word [code_seg]
  8087 0000317B 56                      	push si
  8088 0000317C CB                      	retf
  8089                                  %endif
  8090                                  %endif
  8091                                  
  8092                                  
  8093                                  %assign ELD 0
  8094                                  %assign INTERC3 0
  8095                                  %assign PART1 0
  8096                                  %assign PART2 1
  8097                                  %assign PART3 0
  8098                                  %define init_data_segment cs
  8099                                  
  8100                                   %imacro internalcoderelocation 0-*.nolist
  8101                                   %endmacro
  8102                                   %imacro internaldatarelocation 0-*.nolist
  8103                                   %endmacro
  8104                                   %imacro linkdatarelocation 0-*.nolist
  8105                                   %endmacro
  8106                                   %define relocated(address) address
  8107                                  
  8108                                  %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 0000317D 3C00                <1> 	cmp al, 0
   282 0000317F 741D                <1> 	je .return
   283 00003181 3C0D                <1> 	cmp al, 13
   284 00003183 7419                <1> 	je .return
   285 00003185 3C3B                <1> 	cmp al, ';'
   286 00003187 7415                <1> 	je .return
   287 00003189 3C20                <1> 	cmp al, 32
   288 0000318B 7411                <1> 	je .return
   289 0000318D 3C09                <1> 	cmp al, 9
   290 0000318F 740D                <1> 	je .return
   291 00003191 3C2C                <1> 	cmp al, ','
   292 00003193 7409                <1> 	je .return
   293 00003195 3C3D                <1> 	cmp al, '='
   294 00003197 7405                <1> 	je .return
   295 00003199 363A06[0000]        <1> 	cmp al, byte [ss:relocated(swch1)]
   296                              <1> linkdatarelocation swch1
   297                              <1> .return:
   298 0000319E 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 0000319F 06                  <1> 	push es
   312 000031A0 51                  <1> 	push cx
   313                              <1> 
   314 000031A1 06                  <1> 	push es
   315 000031A2 1F                  <1> 	pop ds
   316 000031A3 89DE                <1> 	mov si, bx		; ds:si -> name
   317 000031A5 16                  <1> 	 push ss
   318 000031A6 07                  <1> 	 pop es			; es:di -> where to append name
   319 000031A7 F3A4                <1> 	rep movsb		; append the name
   320 000031A9 57                  <1> 	push di			; on stack: at initial terminator
   321 000031AA BE[7A0E]            <1> 	mov si, imsg.p_extensions
   322                              <1> internaldatarelocation
   323                              <1> 				; cs:si -> extensions to try
   324                              <1> .loop:
   325 000031AD B000                <1> 	mov al, 0
   326 000031AF AA                  <1> 	stosb			; zero-terminate name
   327 000031B0 B80043              <1> 	mov ax, 4300h		; get attributes
   328 000031B3 52                  <1> 	push dx
   329 000031B4 16                  <1> 	 push ss
   330 000031B5 1F                  <1> 	 pop ds
   331 000031B6 BA[0000]            <1> 	mov dx, relocated(while_buffer)	; ds:dx -> pathname to try
   332                              <1> linkdatarelocation while_buffer
   333 000031B9 F9                  <1> 	stc
   334                              <1> %if ELD
   335                              <1> 	extcallcall _doscall
   336                              <1> %else
   337 000031BA CD21                <1> 	int 21h			; try to get attributes
   338                              <1> %endif
   339 000031BC 7206                <1> 	jc @F			; not found --> CY
   340 000031BE F6C110              <1> 	test cl, 10h		; directory ?
   341 000031C1 7401                <1> 	jz @F			; no --> NC
   342 000031C3 F9                  <1> 	stc			; yes, handle as not found: CY
   343                              <1> @@:
   344 000031C4 5A                  <1> 	pop dx
   345 000031C5 731A                <1> 	jnc .ret		; --> (NC)
   346 000031C7 84D2                <1> 	test dl, dl		; had an extension originally ?
   347 000031C9 7515                <1> 	jnz .ret_CY		; yes, do not try to append one -->
   348 000031CB 2ED006[490E]        <1> 	rol byte [init_data_segment:init_switch_p_guessextension], 1
   349                              <1> internaldatarelocation
   350 000031D0 730E                <1> 	jnc .ret_CY		; if no guessing extension -->
   351 000031D2 5F                  <1> 	pop di
   352 000031D3 57                  <1> 	push di
   353 000031D4 2E803C00            <1> 	cmp byte [init_data_segment:si], 0
   354                              <1> 				; last attempt done ?
   355 000031D8 7406                <1> 	je .ret_CY		; yes -->
   356 000031DA 2EA5                <1> 	init_data_segment movsw	; ".C"
   357 000031DC 2EA5                <1> 	init_data_segment movsw	; "OM"
   358 000031DE EBCD                <1> 	jmp .loop
   359                              <1> 
   360                              <1> .ret_CY:
   361 000031E0 F9                  <1> 	stc			; CY
   362                              <1> .ret:
   363 000031E1 58                  <1> 	pop ax			; (discard)
   364 000031E2 59                  <1> 	pop cx
   365 000031E3 07                  <1> 	pop es
   366 000031E4 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 000031E5 85C0                <1> 	test ax, ax
   379 000031E7 7415                <1> 	jz .notvar
   380 000031E9 8ED8                <1> 	mov ds, ax
   381 000031EB 31F6                <1> 	xor si, si
   382                              <1> 
   383                              <1> @@:
   384 000031ED 0E                  <1> 	push init_data_segment
   385 000031EE 07                  <1> 	pop es
   386 000031EF 51                  <1> 	push cx
   387 000031F0 57                  <1> 	push di
   388 000031F1 56                  <1> 	push si
   389 000031F2 F3A6                <1> 	repe cmpsb
   390 000031F4 740A                <1> 	je .foundvar		; --> (NC)
   391 000031F6 5E                  <1> 	pop si
   392 000031F7 5F                  <1> 	pop di
   393 000031F8 59                  <1> 	pop cx
   394 000031F9 E80800              <1> 	call init_nextvar
   395 000031FC 75EF                <1> 	jnz @B
   396                              <1> .notvar:
   397 000031FE F9                  <1> 	stc
   398 000031FF C3                  <1> 	retn
   399                              <1> 
   400                              <1> .foundvar:
   401 00003200 58                  <1> 	pop ax
   402 00003201 58                  <1> 	pop ax
   403 00003202 58                  <1> 	pop ax
   404 00003203 C3                  <1> 	retn
   405                              <1> 
   406                              <1> 
   407                              <1> init_nextvar:
   408                              <1> @@:
   409 00003204 AC                  <1> 	lodsb
   410 00003205 84C0                <1> 	test al, al
   411 00003207 75FB                <1> 	jnz @B
   412 00003209 803C00              <1> 	cmp byte [si], 0
   413 0000320C 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
  8109                                  
  8110                                   %undef extcall
  8111                                   %undef extcallcall
  8112                                   %unimacro internalcoderelocation 0-*.nolist
  8113                                   %unimacro internaldatarelocation 0-*.nolist
  8114                                   %unimacro linkdatarelocation 0-*.nolist
  8115                                   %undef relocated
  8116                                  
  8117                                  
  8118                                  %if _EXTHELP
  8119                                  switch_u:
  8120 0000320D 800E[0000]10            	setopt [options], nonpagingdevice
  8121                                  
  8122 00003212 AC                      	lodsb
  8123 00003213 E8CC00                  	call init_capitalise
  8124 00003216 3C4C                    	cmp al, 'L'
  8125 00003218 741B                    	je .license
  8126 0000321A 3C52                    	cmp al, 'R'
  8127 0000321C 7514                    	jne .both
  8128                                  .revision:
  8129 0000321E E80200                  	call .do_revision
  8130 00003221 EB1E                    	jmp .done
  8131                                  
  8132                                  .do_revision:
  8133 00003223 BB[0000]                	mov bx, msg.build_array
  8134 00003226 B9[0000]                	mov cx, msg.build_short_amount
  8135 00003229 E81800                  	call .putsz_spec_multi
  8136 0000322C BA[AD0F]                	mov dx, imsg.crlf
  8137 0000322F E9ABE8                  	jmp init_putsz_cs
  8138                                  
  8139                                  .both:
  8140 00003232 E8EEFF                  	call .do_revision
  8141                                  .license:
  8142 00003235 BA[0000]                	mov dx, msg.license
  8143 00003238 E81300                  	call init_transfer_to_putsz_exthelp
  8144 0000323B BA[AD0F]                	mov dx, imsg.crlf
  8145 0000323E E89CE8                  	call init_putsz_cs
  8146                                  .done:
  8147 00003241 E931EF                  	jmp commandline.helpterminate
  8148                                  
  8149                                  .putsz_spec_multi:
  8150                                  @@:
  8151 00003244 8B17                    	mov dx, word [bx]
  8152 00003246 E80500                  	call init_transfer_to_putsz_exthelp
  8153 00003249 43                      	inc bx
  8154 0000324A 43                      	inc bx
  8155 0000324B E2F7                    	loop @B
  8156 0000324D C3                      	retn
  8157                                  
  8158                                  
  8159                                  init_transfer_to_putsz_exthelp:
  8160                                  	lframe 0
  8161                                  	lpar word, in_ip_out_far_cs
  8162                                  	 ; near call ip
  8163                                  	lpar word, in_ax_out_far_ip
  8164 0000324E 50                      	 push ax			; push into ?in_ax_out_far_ip
  8165                                  	lpar word, out_near_ip
  8166 0000324F B8[0000]                	mov ax, code_retf
  8167 00003252 50                      	 push ax			; push into ?out_near_ip
  8168                                  	lpar dword, destination
  8169 00003253 FF36[0000]              	 push word [code_seg]		; push into ?destination + 2
  8170 00003257 B8[0000]                	mov ax, putsz_exthelp
  8171 0000325A 50                      	 push ax			; push into ?destination + 0
  8172 0000325B 5589E5                  	lenter
  8173 0000325E 8CC8                    	mov ax, cs			; = cs
  8174 00003260 87460A                  	xchg ax, word [bp + ?in_ip_out_far_cs]
  8175                                  					; ax = ip, var = cs
  8176 00003263 874608                  	xchg ax, word [bp + ?in_ax_out_far_ip]
  8177                                  					; ax = ax, var = ip
  8178 00003266 5D                      	lleave
  8179 00003267 CB                      	retf
  8180                                  %endif
  8181                                  
  8182                                  
  8183                                  %if _CONFIG
  8184                                  		; INP:	ax => environment, zero if none
  8185                                  		;	cs:di -> variable name, including '=' terminator
  8186                                  		;	cx = variable name length, including '=' terminator
  8187                                  		;	ss:dx -> buffer to write to, 256 bytes
  8188                                  		; OUT:	es = ds = ss
  8189                                  		;	CY if not found
  8190                                  		;	NC if found,
  8191                                  		;	 buffer filled
  8192                                  init_copyvar:
  8193 00003268 E87AFF                  	call init_findvar
  8194 0000326B 721A                    	jc .endvar
  8195                                  
  8196                                  .foundvar:
  8197 0000326D 1E                      	push ds
  8198 0000326E 07                      	pop es
  8199 0000326F 89F7                    	mov di, si
  8200 00003271 B000                    	mov al, 0
  8201 00003273 B9FF00                  	mov cx, 255
  8202 00003276 F2AE                    	repne scasb
  8203                                  
  8204 00003278 29F7                    	sub di, si
  8205 0000327A 4F                      	dec di
  8206 0000327B 89F9                    	mov cx, di
  8207                                  
  8208 0000327D 16                      	push ss
  8209 0000327E 07                      	pop es
  8210 0000327F 89D7                    	mov di, dx
  8211 00003281 F3A4                    	rep movsb
  8212 00003283 B000                    	mov al, 0
  8213 00003285 AA                      	stosb
  8214 00003286 F8                      	clc
  8215                                  
  8216                                  .endvar:
  8217 00003287 16                      	push ss
  8218 00003288 1F                      	pop ds
  8219 00003289 16                      	push ss
  8220 0000328A 07                      	pop es
  8221 0000328B C3                      	retn
  8222                                  %endif
  8223                                  
  8224                                  
  8225                                  %assign ELD 0
  8226                                  %define PREFIX init_
  8227                                  %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 0000328C 56                  <1> 	push si
    34 0000328D 87D7                <1> 	xchg dx, di
    35                              <1> .loop:
    36 0000328F AC                  <1> 	lodsb
    37 00003290 E84F00              <1> 	call %[PREFIX]capitalise
    38 00003293 AE                  <1> 	scasb
    39 00003294 7506                <1> 	jne .mismatch
    40 00003296 84C0                <1> 	test al, al		; NC
    41 00003298 75F5                <1> 	jne .loop
    42                              <1> 				; ZR
    43 0000329A EB40                <1> 	jmp .matched_zr_nc
    44                              <1> 
    45                              <1> .mismatch:
    46 0000329C E84E00              <1> 	call %[PREFIX]iseol?
    47 0000329F 7434                <1> 	je .checkend
    48 000032A1 3C20                <1> 	cmp al, 32
    49 000032A3 7430                <1> 	je .checkend
    50 000032A5 3C09                <1> 	cmp al, 9
    51 000032A7 742C                <1> 	je .checkend
    52 000032A9 3C2E                <1> 	cmp al, '.'
    53 000032AB 7428                <1> 	je .checkend
    54 000032AD 3C2C                <1> 	cmp al, ','
    55 000032AF 7424                <1> 	je .checkend
    56 000032B1 3C3D                <1> 	cmp al, '='
    57 000032B3 7420                <1> 	je .checkend
    58 000032B5 3C3A                <1> 	cmp al, ':'
    59 000032B7 741C                <1> 	je .checkend
    60 000032B9 3C5B                <1> 	cmp al, '['
    61 000032BB 7418                <1> 	je .checkend
    62 000032BD 3C5D                <1> 	cmp al, ']'
    63 000032BF 7414                <1> 	je .checkend
    64 000032C1 3C28                <1> 	cmp al, '('
    65 000032C3 7410                <1> 	je .checkend
    66 000032C5 3C29                <1> 	cmp al, ')'
    67 000032C7 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 000032C9 363A06[0000]        <1> 	cmp al, byte [ss:swch1]
    74                              <1>  %endif
    75 000032CE 7405                <1> 	je .checkend
    76                              <1> %endif
    77                              <1> .ret_nz:	; NZ
    78 000032D0 5E                  <1> 	pop si
    79 000032D1 F9                  <1> 	stc			; CY
    80                              <1> .ret:
    81 000032D2 87D7                <1> 	xchg dx, di
    82 000032D4 C3                  <1> 	retn
    83                              <1> 
    84                              <1> .checkend:
    85 000032D5 26807DFF00          <1> 	cmp byte [es:di - 1], 0
    86 000032DA 75F4                <1> 	jne .ret_nz
    87                              <1> 				; ZR, NC
    88                              <1> .matched_zr_nc:	; ZR, NC
    89 000032DC 5F                  <1> 	pop di			; (discard)
    90 000032DD 8D74FF              <1> 	lea si, [si - 1]	; -> separator (preserve ZR)
    91 000032E0 EBF0                <1> 	jmp .ret
    92                              <1> 
    93                              <1> 
    94                              <1> %[PREFIX]capitalise: section_of_function
    95 000032E2 3C61                <1> 	cmp al, 'a'
    96 000032E4 7206                <1> 	jb .ret
    97 000032E6 3C7A                <1> 	cmp al, 'z'
    98 000032E8 7702                <1> 	ja .ret
    99 000032EA 24DF                <1> 	and al, TOUPPER
   100                              <1> .ret:
   101 000032EC 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 000032ED 3C3B                <1> 	cmp al, ';'
   118 000032EF 7406                <1> 	je .ret
   119                              <1> .notsemicolon:
   120 000032F1 3C0D                <1> 	cmp al, 13		; this *IS* iseol?
   121 000032F3 7402                <1> 	je .ret
   122 000032F5 3C00                <1> 	cmp al, 0
   123                              <1> .ret:
   124 000032F7 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 000032F8 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 000032F9 E82C00              <1> 	call %[PREFIX]skipwh0
   140 000032FC 3C2C                <1> 	cmp al, ','
   141 000032FE 7510                <1> 	jne .return		; if no comma
   142 00003300 56                  <1> 	push si
   143 00003301 E82300              <1> 	call %[PREFIX]skipwhite
   144 00003304 E8E6FF              <1> 	call %[PREFIX]iseol?
   145 00003307 7504                <1> 	jne .noteol		; if not end of line
   146 00003309 5E                  <1> 	pop si
   147 0000330A B02C                <1> 	mov al, ','
   148 0000330C C3                  <1> 	retn
   149                              <1> .noteol:
   150 0000330D 83C402              <1> 	add sp, byte 2		; pop si into nowhere
   151                              <1> .return:
   152 00003310 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 00003311 AC                  <1> 	lodsb
   158                              <1> %[PREFIX]skipequ0:
   159 00003312 E81300              <1> 	call %[PREFIX]skipwh0
   160 00003315 3C3D                <1> 	cmp al, '='
   161 00003317 7503                <1> 	jne .return
   162 00003319 E80B00              <1> 	call %[PREFIX]skipwhite
   163                              <1> .return:
   164 0000331C 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 0000331D AC                  <1> 	lodsb
   176 0000331E 24DF                <1> 	and al, TOUPPER
   177 00003320 2C41                <1> 	sub al, 'A'
   178 00003322 3C19                <1> 	cmp al, 'Z'-'A'
   179 00003324 76F7                <1> 	jbe .
   180 00003326 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 00003327 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 00003328 3C20                <1> 	cmp al, 32
   204 0000332A 74FB                <1> 	je %[PREFIX]skipwhite
   205 0000332C 3C09                <1> 	cmp al, 9
   206 0000332E 74F7                <1> 	je %[PREFIX]skipwhite
   207 00003330 F8                  <1> 	clc
   208 00003331 C3                  <1> 	retn
  8228                                  
  8229                                  
  8230                                  		; INP:	bx => destination for auxbuff
  8231                                  		;	(The following are not actually used by this function,
  8232                                  		;	 they're just what is passed in and preserved to
  8233                                  		;	 be used by the caller after returning.)
  8234                                  		;	dx => destination for code image
  8235                                  		;	(if boot-loaded:) cx => destination for pseudo-PSP
  8236                                  		;		(implies cx+10h => destination for data_entry)
  8237                                  		;	ax => segment for history buffer
  8238                                  
  8239                                  init_app_layout_1:
  8240                                  %if 0
  8241                                  	mov bx, ds
  8242                                  	mov dx, bx
  8243                                  	add bx, paras(AUXTARGET1)
  8244                                  	add dx, paras(CODETARGET1)
  8245                                   %if _HISTORY_SEPARATE_FIXED && _HISTORY
  8246                                  	mov ax, bx
  8247                                  	add ax, paras(auxbuff_size)
  8248                                    %if AUXTARGET1_equate <= CODETARGET1_equate
  8249                                  	...
  8250                                    %endif
  8251                                   %endif
  8252                                  	mov cx, dx
  8253                                  %endif
  8254                                  
  8255                                  		; REM:	Only history segment and extsegment are behind auxbuff.
  8256                                   %if _EXTENSIONS || _HISTORY_SEPARATE_FIXED && _HISTORY || 	_DEV_ENV_SIZE || _APP_ENV_SIZE
  8258                                    %if _HISTORY_SEPARATE_FIXED && _HISTORY
  8259 00003332 A1[0000]                	mov ax, word [history.segorsel + soaSegSel]
  8260                                  					; => history segment
  8261                                    %elif (_DEV_ENV_SIZE || _APP_ENV_SIZE) && _EXTENSIONS
  8262                                  	mov ax, word [envseg]
  8263                                  	test ax, ax
  8264                                  	jnz @F
  8265                                  	mov ax, word [extseg]
  8266                                  @@:
  8267                                    %elif (_DEV_ENV_SIZE || _APP_ENV_SIZE)
  8268                                  	mov ax, word [envseg]
  8269                                  		; if here then no history segment and no ext segment,
  8270                                  		;  so we do not want to copy anything if envseg unused.
  8271                                  		;  in this case hope that mem_envsize is 0 so the movp
  8272                                  		;  call below is a no-op.
  8273                                  		; better fix: just include a check for zero here.
  8274                                  	test ax, ax
  8275                                  	jz .skip_env_reloc
  8276                                    %elif _EXTENSIONS
  8277                                  	mov ax, word [extseg]
  8278                                    %else
  8279                                     %error Unexpected condition
  8280                                    %endif
  8281 00003335 89C2                    	mov dx, ax
  8282 00003337 01F2                    	add dx, si
  8283 00003339 B90004                  	mov cx, paras(historysegment_size + extsegment_size)
  8284                                  		; This runs before init_change_history_size
  8285                                  		;  and init_change_ext_size.
  8286                                  %if (_DEV_ENV_SIZE || _APP_ENV_SIZE)
  8287 0000333C 2E030E[380E]            	add cx, word [cs:mem_envsize]
  8288                                  %endif
  8289 00003341 E808E7                  	call init_movp
  8290                                  .skip_env_reloc:
  8291                                  init_app_layout_common:
  8292                                    %if _HISTORY_SEPARATE_FIXED && _HISTORY
  8293 00003344 0136[0000]              	add word [history.segorsel + soaSegSel], si
  8294                                  %if _PM
  8295 00003348 0136[0200]              	add word [history.segorsel + soaSegment], si
  8296                                  %endif
  8297                                    %endif
  8298                                    %if _EXTENSIONS
  8299 0000334C 0136[0000]              	add word [extseg], si
  8300                                    %endif
  8301                                    %if (_DEV_ENV_SIZE || _APP_ENV_SIZE)
  8302 00003350 2ED006[710E]            	rol byte [cs:app_env_allocation], 1
  8303 00003355 7204                    	jc @F
  8304 00003357 01362C00                	add word [2Ch], si
  8305                                  @@:
  8306 0000335B 833E[0000]00            	cmp word [envseg], 0
  8307 00003360 7404                    	je @F
  8308 00003362 0136[0000]              	add word [envseg], si
  8309                                  @@:
  8310                                    %endif
  8311                                   %else
  8312                                  init_app_layout_common:
  8313                                   %endif
  8314 00003366 2E0136[360E]            	add word [cs:memsize], si
  8315 0000336B 8E06[0000]              	mov es, word [auxbuff_segorsel + soaSegSel]
  8316 0000336F BF1020                  	mov di, fromwords(words(_AUXBUFFSIZE))
  8317 00003372 89F1                    	mov cx, si			; = amount paragraphs added
  8318 00003374 D1E1                    	shl cx, 1			; = amount qwords
  8319 00003376 D1E1                    	shl cx, 1			; = amount dwords
  8320 00003378 D1E1                    	shl cx, 1			; = amount words
  8321 0000337A 31C0                    	xor ax, ax
  8322 0000337C F3AB                    	rep stosw			; initialise auxbuff trail
  8323 0000337E F8                      	clc
  8324 0000337F C3                      	retn
  8325                                  
  8326                                  
  8327                                  init_app_layout_2:
  8328                                  %if 0
  8329                                  	mov bx, ds
  8330                                  	mov dx, bx
  8331                                  	add bx, paras(AUXTARGET2)
  8332                                  	add dx, paras(CODETARGET2)
  8333                                   %if _HISTORY_SEPARATE_FIXED && _HISTORY
  8334                                    %if (paras(AUXTARGET1_equate) + paras(auxbuff_size_equate)) 	!= (paras(CODETARGET2_equate) + paras(ldebug_codes_truncated_size_equate))
  8336                                  	...
  8337                                    %endif
  8338                                   %endif
  8339                                  %endif
  8340                                  
  8341                                  		; REM:	Code1/code2 and history segment are behind auxbuff.
  8342 00003380 A1[0000]                	mov ax, word [code_seg]
  8343 00003383 89C2                    	mov dx, ax
  8344 00003385 01F2                    	add dx, si
  8345                                  %ifn _LINK
  8346                                  	mov cx, ldebug_code_bootldr_truncated_size_p 		+ ldebug_code2_size_p 		+ paras(historysegment_size) 		+ paras(extsegment_size)
  8350                                  %else
  8351 00003387 B9[0004]                	mov cx, relocatedzero + 0 		+ paras(historysegment_size) 		+ paras(extsegment_size)
  8354                                   wlcalc word_wrt_@@lDEBUG_CODE@_extpara_behind_code_truncated, equ $ - 2
  8355                                   wlcalc word_wrt_@@lDEBUG_CODE2@_extpara_behind_code2, equ $ - 2
  8356                                  %endif
  8357                                  
  8358                                  		; This runs before init_change_history_size
  8359                                  		;  and init_change_ext_size.
  8360                                  %if (_DEV_ENV_SIZE || _APP_ENV_SIZE)
  8361 0000338A 2E030E[380E]            	add cx, word [cs:mem_envsize]
  8362                                  %endif
  8363 0000338F E8BAE6                  	call init_movp
  8364                                  
  8365 00003392 8EC2                    	mov es, dx
  8366 00003394 0136[0000]              	add word [code_seg], si
  8367                                  %if _DUALCODE
  8368 00003398 0136[0000]              	add word [code2_seg], si
  8369 0000339C 8B16[0000]              	mov dx, word [code2_seg]
  8370                                  repatch_relocate:
  8371 000033A0 56                      	push si
  8372                                   %if ! _PM
  8373                                  	mov si, relocate_from_code
  8374                                  	mov di, relocate_from_code.end
  8375                                  	call .patch
  8376                                  	mov si, relocate_from_code2
  8377                                  	mov di, relocate_from_code2.end
  8378                                   %endif
  8379 000033A1 06                      	push es
  8380 000033A2 8EC2                    	mov es, dx
  8381 000033A4 5A                      	pop dx
  8382                                   %if ! _PM
  8383                                  	call .patch
  8384                                  	jmp .done
  8385                                  
  8386                                  .loop:
  8387                                  	cs lodsw
  8388                                  	xchg bx, ax
  8389                                  	mov word [es:bx], dx
  8390                                  .patch:
  8391                                  	cmp si, di
  8392                                  	jb .loop
  8393                                  	retn
  8394                                  
  8395                                  .done:
  8396                                   %endif
  8397 000033A5 5E                      	pop si
  8398                                  %endif
  8399                                  
  8400                                  %if _AREAS && _AREAS_HOOK_CLIENT
  8401                                  	mov ax, si
  8402                                  	call add_to_areas_linear_code1
  8403                                   %if _DUALCODE && _EXPRDUALCODE
  8404                                  	mov ax, si
  8405                                  	call add_to_areas_linear_code2
  8406                                   %endif
  8407                                  %endif
  8408                                  
  8409 000033A6 EB9C                    	jmp init_app_layout_common
  8410                                  
  8411                                  
  8412                                  		; REM:	Only history segment is behind auxbuff.
  8413                                  init_app_layout_3: equ init_app_layout_1
  8414                                  %if 0
  8415                                  		; If both prior attempts failed, we allocate
  8416                                  		;  an additional 8 KiB and move the buffer to
  8417                                  		;  that. This should always succeed.
  8418                                  	mov word [cs:memsize], paras(AUXTARGET3 			+ auxbuff_size 			+ historysegment_size)
  8421                                  				; enlarge the final memory block size
  8422                                  
  8423                                  	mov bx, ds
  8424                                  	add bx, paras(AUXTARGET3)
  8425                                  	mov dx, cx
  8426                                   %if _HISTORY_SEPARATE_FIXED && _HISTORY
  8427                                  	mov ax, bx
  8428                                  	add ax, paras(auxbuff_size)
  8429                                   %endif
  8430                                  %endif
  8431                                  
  8432                                  
  8433                                  %if _DEVICE
  8434                                  init_dev_layout_1:
  8435                                  %if 0
  8436                                  	mov bx, ds
  8437                                  	add bx, paras(DEVICEADJUST)
  8438                                  	mov dx, bx
  8439                                  	add bx, paras(AUXTARGET1)
  8440                                  	add dx, paras(CODETARGET1)
  8441                                   %if _HISTORY_SEPARATE_FIXED && _HISTORY
  8442                                  	mov ax, bx
  8443                                  	add ax, paras(auxbuff_size)
  8444                                   %endif
  8445                                  	mov cx, dx
  8446                                  %endif
  8447 000033A8 E887FF                  	call init_app_layout_1
  8448 000033AB EB08                    	jmp init_dev_layout_common
  8449                                  
  8450                                  
  8451                                  init_dev_layout_2:
  8452                                  %if 0
  8453                                  	mov bx, ds
  8454                                  	add bx, paras(DEVICEADJUST)
  8455                                  	mov dx, bx
  8456                                  	add bx, paras(AUXTARGET2)
  8457                                  	add dx, paras(CODETARGET2)
  8458                                  %endif
  8459 000033AD E8D0FF                  	call init_app_layout_2
  8460 000033B0 EB03                    	jmp init_dev_layout_common
  8461                                  
  8462                                  
  8463                                  init_dev_layout_3:
  8464                                  %if 0
  8465                                  	mov word [cs:memsize], paras(AUXTARGET3 			+ auxbuff_size 			+ historysegment_size)
  8468                                  				; enlarge the final memory block size
  8469                                  
  8470                                  	mov bx, ds
  8471                                  	add bx, paras(DEVICEADJUST)
  8472                                  	add bx, paras(AUXTARGET3)
  8473                                  	mov dx, cx
  8474                                   %if _HISTORY_SEPARATE_FIXED && _HISTORY
  8475                                  	mov ax, bx
  8476                                  	add ax, paras(auxbuff_size)
  8477                                   %endif
  8478                                  %endif
  8479                                  
  8480 000033B2 E87DFF                  	call init_app_layout_3
  8481                                  init_dev_layout_common:
  8482 000033B5 0136[0000]              	add word [device_mcb_paragraphs], si
  8483                                  					; fix our variable
  8484 000033B9 0136[0000]              	add word [alloc_size], si	; this one too
  8485 000033BD 8CD8                    	mov ax, ds			; => PSP
  8486 000033BF 2E0306[360E]            	add ax, word [cs:memsize]	; => where to place container sig
  8487 000033C4 E8A5D7                  	call init_dev_place_container_signature
  8488                                  					; CHG: es, di, cx, si
  8489                                  					; ax => behind memory used for device
  8490 000033C7 8E06[0000]              	mov es, word [reg_es]
  8491 000033CB 8B1E[0000]              	mov bx, word [reg_ebx]		; -> device request header
  8492 000033CF 26894710                	mov word [es:bx + 0Eh + 2], ax	; -> behind memory in use
  8493 000033D3 F8                      	clc
  8494 000033D4 C3                      	retn
  8495                                  %endif
  8496                                  
  8497                                  
  8498                                  init_layout_none:
  8499 000033D5 F9                      	stc
  8500 000033D6 C3                      	retn
  8501                                  
  8502                                  
  8503                                  %if _AREAS && _AREAS_HOOK_CLIENT
  8504                                  add_to_areas_linear_code1:
  8505                                  	xor dx, dx
  8506                                  .dxax:
  8507                                  	mov cx, 4
  8508                                  @@:
  8509                                  	shl ax, 1
  8510                                  	rcl dx, 1
  8511                                  	loop @B
  8512                                  
  8513                                  	add word [areas_sub + areastrucsubLinear], ax
  8514                                  	adc word [areas_sub + areastrucsubLinear + 2], dx
  8515                                  	add word [areas_sub + areastrucsubLinearEnd], ax
  8516                                  	adc word [areas_sub + areastrucsubLinearEnd + 2], dx
  8517                                  
  8518                                  	add word [areas_fun + areastrucfunLinear], ax
  8519                                  	adc word [areas_fun + areastrucfunLinear + 2], dx
  8520                                  	add word [areas_fun + areastrucfunLinearEnd], ax
  8521                                  	adc word [areas_fun + areastrucfunLinearEnd + 2], dx
  8522                                  	retn
  8523                                  
  8524                                   %if _DUALCODE && _EXPRDUALCODE
  8525                                  add_to_areas_linear_code2:
  8526                                  	xor dx, dx
  8527                                  .dxax:
  8528                                  	mov cx, 4
  8529                                  @@:
  8530                                  	shl ax, 1
  8531                                  	rcl dx, 1
  8532                                  	loop @B
  8533                                  
  8534                                  	add word [areas_sub + AREASTRUCSUB_size + areastrucsubLinear], ax
  8535                                  	adc word [areas_sub + AREASTRUCSUB_size + areastrucsubLinear + 2], dx
  8536                                  	add word [areas_sub + AREASTRUCSUB_size + areastrucsubLinearEnd], ax
  8537                                  	adc word [areas_sub + AREASTRUCSUB_size + areastrucsubLinearEnd + 2], dx
  8538                                  	retn
  8539                                   %endif
  8540                                  %endif
  8541                                  
  8542                                  
  8543                                  %if _CONFIG
  8544                                  do_truename:
  8545                                  .:
  8546 000033D7 16                      	push ss
  8547 000033D8 1F                      	pop ds
  8548 000033D9 89D6                    	mov si, dx		; ds:si -> source
  8549 000033DB 16                      	push ss
  8550 000033DC 07                      	pop es
  8551 000033DD 89D7                    	mov di, dx		; es:di -> destination (same)
  8552 000033DF B460                    	mov ah, 60h
  8553 000033E1 CD21                    	int 21h
  8554 000033E3 7309                    	jnc .done
  8555 000033E5 803C00                  	cmp byte [si], 0	; empty ? (kernel rejects this)
  8556 000033E8 C7042E00                	mov word [si], "."	; make a dot + NUL (current directory)
  8557 000033EC 74E9                    	je .			; if expected failure then repeat -->
  8558                                  
  8559                                  .done:
  8560 000033EE B000                    	mov al, 0
  8561 000033F0 B98000                  	mov cx, 128
  8562 000033F3 F2AE                    	repne scasb		; scan for NUL
  8563 000033F5 4F                      	dec di			; -> at the NUL
  8564                                  
  8565                                  @@:
  8566 000033F6 39F7                    	cmp di, si
  8567 000033F8 760C                    	jbe @F
  8568 000033FA 807DFF2F                	cmp byte [di - 1], '/'
  8569 000033FE 740A                    	je @FF
  8570 00003400 807DFF5C                	cmp byte [di - 1], '\'
  8571 00003404 7404                    	je @FF
  8572                                  @@:
  8573 00003406 C6055C                  	mov byte [di], '\'
  8574 00003409 47                      	inc di
  8575                                  @@:
  8576 0000340A C3                      	retn
  8577                                  %endif
  8578                                  
  8579                                  
  8580                                  %if _EXTENSIONS
  8581                                  init_eld:
  8582 0000340B 16                      	push ss
  8583 0000340C 1F                      	pop ds
  8584                                  
  8585                                  	numdef ELD_DEBUG_LINKCALL_NONZERO, 0, 32
  8586                                  %if _ELD_DEBUG_LINKCALL_NONZERO
  8587                                   %if _ELD_DEBUG_LINKCALL_NONZERO & 15
  8588                                    %error Invalid size
  8589                                   %endif
  8590                                   %if _ELD_DEBUG_LINKCALL_NONZERO < 32
  8591                                    %error Invalid size
  8592                                   %endif
  8593                                   %if _ELD_DEBUG_LINKCALL_NONZERO > 65520
  8594                                    %error Invalid size
  8595                                   %endif
  8596                                  	mov ax, word [extseg_size]
  8597                                  	mov di, word [extseg_used]
  8598                                  	sub ax, di			; = amount free space
  8599                                  	jc @F
  8600                                  	mov cx, _ELD_DEBUG_LINKCALL_NONZERO
  8601                                  	cmp ax, cx
  8602                                  	jb @F
  8603                                  	mov es, word [extseg]		; es:di -> where to place ELD instance
  8604                                  	xor ax, ax
  8605                                  	push di
  8606                                  	shr cx, 1			; = amount words
  8607                                  	rep stosw			; zero
  8608                                  	mov word [extseg_used], di	; -> behind ELD
  8609                                  	xchg ax, di			; ax -> behind ELD
  8610                                  	pop di
  8611                                  	mov word [es:di + eldiStartCode], di
  8612                                  	mov word [es:di + eldiEndCode], ax
  8613                                  	mov ax, "--"
  8614                                  	mov cl, 4
  8615                                  	add di, eldiIdentifier
  8616                                  	rep stosw
  8617                                  
  8618                                  @@:
  8619                                  %endif
  8620                                  
  8621 0000340D A1[0000]                	mov ax, word [extseg_size]
  8622 00003410 8B3E[0000]              	mov di, word [extseg_used]
  8623 00003414 29F8                    	sub ax, di			; = amount free space
  8624 00003416 7239                    	jc .ret
  8625 00003418 3D8000                  	cmp ax, eld_linkcall_size	; enough ?
  8626 0000341B 7234                    	jb .ret
  8627 0000341D 89F8                    	mov ax, di			; -> where to install this ELD
  8628 0000341F 8E06[0000]              	mov es, word [extseg]		; es:di -> where to place ELD instance
  8629 00003423 0E                      	push cs
  8630 00003424 1F                      	pop ds				; ! ds no longer equals ss
  8631 00003425 BE[B20D]                	mov si, eld_linkcall + 2	; ds:si -> ELD source plus one word
  8632 00003428 B93E00                  	mov cx, eld_linkcall_size_w - 2	; cx = length less two words
  8633 0000342B AB                      	stosw				; init eldiStartCode
  8634 0000342C A5                      	movsw
  8635 0000342D 260145FE                	add word [es:di - 2], ax	; init eldiEndCode
  8636 00003431 F3A5                    	rep movsw			; write our ELD
  8637 00003433 16                      	push ss
  8638 00003434 1F                      	pop ds
  8639 00003435 893E[0000]              	mov word [extseg_used], di	; -> behind ELD
  8640 00003439 83C028                  	add ax, eld_linkcall.to_code1 - eld_linkcall
  8641 0000343C A3[0000]                	mov word [linkcall_table.code1], ax
  8642                                   %if _DUALCODE
  8643 0000343F 83C008                  	add ax, eld_linkcall.to_code2 - eld_linkcall.to_code1
  8644 00003442 A3[0000]                	mov word [linkcall_table.code2], ax
  8645 00003445 83C0F0                  	add ax, eld_linkcall.to_entry - eld_linkcall.to_code2
  8646                                   %else
  8647                                  	add ax, eld_linkcall.to_entry - eld_linkcall.to_code1
  8648                                   %endif
  8649 00003448 A3[0000]                	mov word [linkcall_table.entry], ax
  8650 0000344B C706[0000]0100          	mov word [linkcall_table.init], 1
  8651                                  .ret:
  8652 00003451 16                      	push ss
  8653 00003452 1F                      	pop ds
  8654 00003453 16                      	push ss
  8655 00003454 07                      	pop es
  8656 00003455 C3                      	retn
  8657                                  %endif
  8658                                  
  8659                                  %if !_LINK && _LINK_COMPAT
  8660                                  %ifn _ONLY386 || _ONLYNON386
  8661                                  	align 2, db 0
  8662                                  		; Table of patches that are to be set NOP if running on a 386.
  8663                                  writepatchtable patch_386_table, PATCH_386_TABLE
  8664                                  %undef PATCH_386_TABLE
  8665                                  
  8666                                  	align 2, db 0				; align on word boundary
  8667                                  		; Table of patches that are to be set NOP if not running on a 386.
  8668                                  writepatchtable patch_no386_table, PATCH_NO386_TABLE
  8669                                  %undef PATCH_NO386_TABLE
  8670                                  
  8671                                  %if _DUALCODE
  8672                                  	align 2, db 0
  8673                                  		; Table of patches that are to be set NOP if running on a 386.
  8674                                  writepatchtable patch_386_table2, PATCH_386_TABLE2
  8675                                  %undef PATCH_386_TABLE2
  8676                                  
  8677                                  	align 2, db 0				; align on word boundary
  8678                                  		; Table of patches that are to be set NOP if not running on a 386.
  8679                                  writepatchtable patch_no386_table2, PATCH_NO386_TABLE2
  8680                                  %undef PATCH_NO386_TABLE2
  8681                                  %else
  8682                                   %assign __patch_no386_table2_method 0
  8683                                   %assign __patch_386_table2_method 0
  8684                                  %endif
  8685                                  
  8686                                  	align 2, db 0
  8687                                  		; Table of patches that are to be set NOP if running on a 386.
  8688                                  writepatchtable patch_386_tableentry, PATCH_386_TABLEENTRY
  8689                                  %undef PATCH_386_TABLEENTRY
  8690                                  
  8691                                  	align 2, db 0				; align on word boundary
  8692                                  		; Table of patches that are to be set NOP if not running on a 386.
  8693                                  writepatchtable patch_no386_tableentry, PATCH_NO386_TABLEENTRY
  8694                                  %undef PATCH_NO386_TABLEENTRY
  8695                                  %endif
  8696                                  
  8697                                  %if _DUALCODE && ! _PM
  8698                                  	align 2, db 0
  8699                                  relocate_from_code:
  8700                                  	dw  PATCH_RELOCATE_FROM_lDEBUG_CODE
  8701                                  .end:
  8702                                  	align 2, db 0
  8703                                  relocate_from_code2:
  8704                                  	dw  PATCH_RELOCATE_FROM_lDEBUG_CODE2
  8705                                  .end:
  8706                                  
  8707                                  %unimacro dualcall 1.nolist
  8708                                  	; make sure we do not allow later uses
  8709                                  %endif
  8710                                  %endif
