     1                                  
     2                                  %if 0
     3                                  
     4                                  lDebug "boot" commands - boot loading
     5                                  
     6                                  Copyright (C) 2008-2026 E. C. Masloch
     7                                  
     8                                  Usage of the works is permitted provided that this
     9                                  instrument is retained with the works, so that any entity
    10                                  that uses the works is notified of this instrument.
    11                                  
    12                                  DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                                  
    14                                  %endif
    15                                  
    16                                  %define SOURCEFILENAME "boot.asm"
    17                                  %ifidni __OUTPUT_FORMAT__, obj
    18                                   %include "debug.mac"
     1                              <1> [list -]
    14                              <3> [list -]
    14                              <2> [list -]
    86                              <1> [list -]
    86          ------------------  <1>  note: Disable usesection detection
    86          ------------------  <1>  note: usesection lDEBUG_DATA_ENTRY
    86          ------------------  <1>  note: usesection ASMTABLE1
    86          ------------------  <1>  note: usesection ASMTABLE2
    86          ------------------  <1>  note: usesection DATASTACKBASE
    86          ------------------  <1>  note: usesection MESSAGESEGMENT
    86          ------------------  <1>  note: usesection lDEBUG_CODE
    86          ------------------  <1>  note: usesection lDEBUG_CODE2
    86          ------------------  <1>  note: usesection INIT
    86          ------------------  <1>  note: usesection WLEMITALIGNINITEND
    86          ------------------  <1>  note: usesection DEVICESHIM
    86          ------------------  <1>  note: usesection WLEMITALIGNRELOCZERO
    68                              <2> %endif
    69                              <2> 
    70                              <2> 
    71                              <2> 	usesection lDEBUG_CODE
    71          ------------------  <2>  note: usesection lDEBUG_CODE
    72                              <2> section_of puts, trimputs, puts_ext_done, puts_ext_next
    73                              <2> section_of putsz_exthelp, code_retf
    74                              <2> section_of puts_getline_ext_done
    75                              <2> section_of puts_copyoutput_ext_done
    76                              <2> section_of guard_auxbuff, guard_re
    77                              <2> section_of handle_serial_flags_ctrl_c
    78                              <2> section_of hexword_high
    79                              <2> section_of call_int2D
    80                              <2> section_of copy_single_counted_string
    81                              <2> section_of intchk
    82                              <2> section_of IsIISPEntry?
    83                              <2> section_of dd_store
    84                              <2> section_of dohack, getsegmented, hexbyte, hexnyb, iseol?.notsemicolon
    85                              <2> section_of peekc, getc, prephack, readmem, setds2si, setds2bx, setes2dx
    86                              <2> section_of silence_get_start, silence_get_start.have_di, silence_count_zeroes
    87                              <2> section_of setrmlimit, skipcomm0, unhack
    88                              <2> section_of skipequals
    89                              <2> section_of to_errret_pop
    90                              <2> section_of cmd3.have_cx_convenience
    91                              <2> section_of verifysegm, verifysegm_or_error
    92                              <2> section_of pp16, resetmode, resetmode_and_test_d_b_bit
    93                              <2> section_of pp_fix32bitflags, proceedbreakpoint
    94                              <2> section_of putsz, hexword, skipcomma, cmd3, cmd3_not_ext, cmd3_preprocessed
    95                              <2> section_of hexdword
    96                              <2> section_of cmd3_not_inject, cmd3_injected
    97                              <2> section_of aa_not_inject, aa_injected, aa_before_getline, aa_after_getline
    98                              <2> section_of transfer_ext_cx_nearcall_from_code2
    99                              <2> section_of traceone, unexpectedinterrupt, dumpregs_no_disasm
   100                              <2> section_of aa_imm_entry, ia_restore_a_addr, ia_restore_u_addr, disasm
   101                              <2> section_of ia_restore_ds
   102                              <2> %ifn _SYMBOLIC
   103                              <2> section_of selector_to_segment
   104                              <2> %endif
   105                              <2> section_of disp_al, disp_al_hex, disp_al_nybble_hex, disp_ax_dec, disp_ax_hex
   106                              <2> section_of disp_dxax_times_cx_width_bx_size
   107                              <2> section_of disp_dxax_times_cx_width_bx_size.store
   108                              <2> section_of disp_message, disp_message_length_cx
   109                              <2> section_of ispm
   110                              <2> section_of setrc, error
   111                              <2> section_of _doscall, _doscall_return_es, _doscall_return_es_parameter_es_ds
   112                              <2> section_of intcall_ext_return_es, close_ext, doscall_extseg
   113                              <2> section_of yy_reset_buf
   114                              <2> section_of init_bootcmd
   115                              <2> 
   116                              <2> section_of InDOS, bootgetmemorysize
   117                              <2> section_of chkeol, decword, decdword
   118                              <2> section_of dec_dword_minwidth
   119                              <2> section_of getexpression.lit_isdigit?, getexpression.lit_ishexdigit?
   120                              <2> section_of getlinearaddr
   121                              <2> section_of getlinear_d_b
   122                              <2> section_of getlinear_high_limit
   123                              <2> section_of getlinear_32bit
   124                              <2> section_of getlinear_high_limit.do_not_use_test
   125                              <2> section_of getlinear_common
   126                              <2> section_of ifsep, iseol?, isseparator?, isstring?, movp
   127                              <2> section_of putc, putsline, putsline_crlf, putsz_error
   128                              <2> section_of setrmsegm
   129                              <2> section_of skipwh0, skipwhite
   130                              <2> section_of test_d_b_bit, test_high_limit, push_cxdx_or_edx
   131                              <2> section_of capitalise
   132                              <2> section_of setes2ax
   133                              <2> section_of zz_copy_strings_to_str_buffer
   134                              <2> section_of call_xms_move, zz_call_xms, zz_detect_xms
   135                              <2> section_of code2_to_code_ret_to_ext
   136                              <2> section_of yy_dos_parse_name, yy_open_file, yy_check_lfn
   137                              <2> section_of yy_common_parse_name
   138                              <2> section_of yy_common_parse_name_bx_buffer
   139                              <2> section_of retry_open_scriptspath
   140                              <2> section_of yy_boot_read.bx, yy_boot_seek_start.bx, yy_boot_seek_current.bx
   141                              <2> section_of yy_boot_parse_name, yy_boot_open_file
   142                              <2> section_of yy_boot_parse_name_bx_buffer
   143                              <2> section_of near_transfer_ext_return, scan_dir_aux, read_sector
   144                              <2> section_of yy_boot_init_dir, got_yyentry, scan_dir_entry
   145                              <2> section_of ..@yy_filename_empty, boot_parse_fn
   146                              <2> section_of count_store, count_store.maybe_0
   147                              <2> section_of loader_get_resident_address, loader_prepare_resident
   148                              <2> 
   149                              <2> 
   150                              <2>  %if _SYMBOLIC && _DUALCODE && _SYMBOLASMDUALCODE
   151                              <2> 	usesection lDEBUG_CODE2
   152                              <2>  %else
   153                              <2> 	usesection lDEBUG_CODE
   153          ------------------  <2>  note: usesection lDEBUG_CODE
   154                              <2>  %endif
   155                              <2> section_of bxcx_to_cx_paragraphs
   156                              <2> section_of zz_list_symbol.first, zz_list_symbol.subsequent
   157                              <2> section_of zz_xms_to_86mm, zz_xms_try_free, zz_xms_try_free_handle
   158                              <2> section_of zz_86mm_to_xms, zz_del_match.add_poison_entrypoint
   159                              <2> section_of zz_free_nonxms, zz_free_xms, zz_free_reset, zz_free_dos
   160                              <2> section_of zz_get_literal, zz_restore_strat, zz_save_strat
   161                              <2> section_of zz_switch_s, zz_transfer_buffer
   162                              <2> 
   163                              <2> 
   164                              <2> %if _SYMBOLIC
   165                              <2>  %if _DUALCODE && _SYMBOLICDUALCODE
   166                              <2> 	usesection lDEBUG_CODE2
   167                              <2>  %else
   168                              <2> 	usesection lDEBUG_CODE
   169                              <2>  %endif
   170                              <2> section_of shift_left_4_bxcx
   171                              <2> section_of selector_to_segment
   172                              <2> 
   173                              <2> section_of anti_normalise_pointer_with_displacement_bxcx, displaystring
   174                              <2> section_of getfarpointer.hash, getfarpointer.main, getfarpointer.str
   175                              <2> section_of move_delete_farpointer.hash, move_delete_farpointer.hash.sidi
   176                              <2> section_of move_delete_farpointer.main, move_delete_farpointer.str.sidi
   177                              <2> section_of move_insert_farpointer.hash, move_insert_farpointer.hash.sidi
   178                              <2> section_of move_insert_farpointer.main, move_insert_farpointer.main.sidi
   179                              <2> section_of move_insert_farpointer.str.sidi
   180                              <2> section_of normalise_pointer, normalise_pointer_with_displacement_bxcx
   181                              <2> section_of pointer_to_linear
   182                              <2> section_of save_slice_farpointer.hash, save_slice_farpointer.main
   183                              <2> section_of save_slice_farpointer.str
   184                              <2> section_of segment_to_selector
   185                              <2> section_of zz_insert, zz_match_symbol, zz_match_symbol.continue, zz_relocate
   186                              <2> 
   187                              <2> section_of binsearchhash, binsearchmain
   188                              <2> section_of check_second_slice
   189                              <2> section_of disp_size_hash, disp_size_main, disp_size_str
   190                              <2> section_of displayresult, getstring1, getstring2
   191                              <2> section_of increment_ss_ref_count
   192                              <2> section_of list_sym_storage_usage, str_index_to_pointer
   193                              <2> section_of zz_commit_insert, zz_compact, zz_compact_expand_check_nonxms
   194                              <2> section_of zz_compact_expand_check_xms
   195                              <2> section_of zz_delete_hash, zz_delete_main, zz_delete_main_and_its_hash
   196                              <2> section_of zz_delete_string, zz_expand, zz_expand_common
   197                              <2> section_of zz_get_symstr_length_bytes
   198                              <2> section_of zz_get_symstr_length_bytes.ssLength_in_cx
   199                              <2> section_of zz_get_symstr_length_indices
   200                              <2> section_of zz_get_symstr_length_indices.ssLength_in_cx
   201                              <2> section_of zz_hash, zz_hash.bx_init
   202                              <2> section_of zz_insert_main.linklist, zz_reloc_main, zz_reloc_str
   203                              <2> section_of zz_store_pre_str, zz_store_string, zz_store_string.hash_bx
   204                              <2> section_of zz_unlink_main_next
   205                              <2> %endif
   206                              <2> 
   207                              <2> %if _DUALCODE
   208                              <2> 	usesection lDEBUG_CODE2
   208          ------------------  <2>  note: usesection lDEBUG_CODE2
   209                              <2> %else
   210                              <2> 	usesection lDEBUG_CODE
   211                              <2> %endif
   212                              <2> section_of FloatToStr
   213                              <2> 
   214                              <2> 
   215                              <2>  %if _DUALCODE && _EXPRDUALCODE
   216                              <2> 	usesection lDEBUG_CODE2
   216          ------------------  <2>  note: usesection lDEBUG_CODE2
   217                              <2>  %else
   218                              <2> 	usesection lDEBUG_CODE
   219                              <2>  %endif
   220                              <2> 
   221                              <2> section_of getofsforbx, checkpointer, getrangeX
   222                              <2> section_of getrangeX_have_address_need_length
   223                              <2> section_of getrange, getaddr, getofsforbx_remember_bitness
   224                              <2> section_of remember_bitness, getaddr_taken
   225                              <2> section_of getstr, get_length, get_length_keyword
   226                              <2> section_of isbracketorunaryoperator?, isunaryoperator?, isoperator?
   227                              <2> section_of ..@call_operator_dispatchers
   228                              <2> section_of isseparator?, istype?, isunsignedtype?
   229                              <2> section_of handlesegment, handle3byte, handlebyte, handleword
   230                              <2> section_of handledword, handlepointer
   231                              <2> section_of uoh_abs, uoh_minus, calculate_minus_bxdx, uoh_plus
   232                              <2> section_of uoh_not_bitwise, uoh_not_boolean
   233                              <2> section_of od_minus, od_plus, od_multiply, od_divide, od_modulo, od_retn
   234                              <2> section_of od_above, od_below, od_equal, od_not, od_or, od_and, od_xor
   235                              <2> section_of od_cond, od_o, od_a, od_x, od_c, od_string_common
   236                              <2> section_of of_modulo, of_minus, of_plus, or_hhtype, of_multiply
   237                              <2> section_of set_hhtype, of_divide, of_power
   238                              <2> section_of of_compare_below_equal, of_compare_below, of_compare_not_equal
   239                              <2> section_of of_compare_equal, of_compare_above_equal, of_compare_above
   240                              <2> section_of toboolean, of_helper_compare_true, of_rightop, of_helper_compare
   241                              <2> section_of of_shift_right, of_shift_right_signed, of_shift_left
   242                              <2> section_of of_helper_getshiftdata, of_bit_mirror
   243                              <2> section_of of_or_bitwise, or_hhtype_1, of_or_boolean, of_clr_bitwise
   244                              <2> section_of of_and_bitwise, of_and_boolean, of_xor_bitwise, of_xor_boolean
   245                              <2> section_of of_helper_retbool, of_helper_getbool
   246                              <2> 
   247                              <2> section_of var_cip_setup, var_csp_setup, var_lfsr_setup, var_reverselfsr_setup
   248                              <2> section_of var_dpspsel_setup, var_seldbg_setup, var_mt_setup
   249                              <2> section_of var_ioi_setup, var_psps_setup, var_ppr_setup, var_ppi_setup
   250                              <2> section_of var_iok_setup, var_rhcount_setup
   251                              <2> section_of var_get_psp_segment, var_get_psp_selector
   252                              <2> section_of var_bootldpunit_setup, var_bootsdpunit_setup, var_bootydpunit_setup
   253                              <2> section_of var_bootldppart_setup, var_bootsdppart_setup, var_bootydppart_setup
   254                              <2> section_of var_bootunitflags_setup
   255                              <2> 
   256                              <2> section_of issymbol?, isvariable?, var_mm_setup, var_ri_setup, var_ysf_setup
   257                              <2> section_of default_variable_setup
   258                              <2> section_of var_ext_setup
   259                              <2> section_of var_ext_setup_done
   260                              <2> 
   261                              <2> section_of getstmmxdigit
   262                              <2> section_of getexpression.lit_ishexdigit?, getexpression.lit_isdigit?
   263                              <2> section_of of_cond, count_unary_operators, count_unary_operators_restrict
   264                              <2> section_of get3byte.checksignificantbits, getbyte, checksignificantbitscommon
   265                              <2> section_of getnyb, get_value_range
   266                              <2> 
   267                              <2> section_of getaddrX, getword, getdword, getexpression
   268                              <2> 
   269                              <2> section_of getrangeX.lines, getrangeX.ecx_and_0_valid
   270                              <2> section_of getrange.lines, getrange.ecx_and_0_valid, get_length.lines
   271                              <2> section_of getrangeX.lines_and_uu, getrange.lines_and_uu
   272                              <2> section_of isseparator?.except_L_or_dot, isvariable?.return_name
   273                              <2> section_of getword.checksignificantbits, getbyte.checksignificantbits
   274                              <2> 
   275                              <2> section_of seg_bx_to_sel
   276                              <2> section_of getexpression.countsignificantbits
   277                              <2> section_of ..@rr_checksignificantbits, ..@rr_operatordispatchers
   278                              <2> section_of ..@rr_operatorfunctions, ..@parsecm_getaddr
   279                              <2> section_of stack_check.internal
   280                              <2> 
   281                              <2> 
   282                              <2> 	usesection INIT
   282          ------------------  <2>  note: usesection INIT
   283                              <2> section_of init_capitalise
   284                              <2> section_of init_skipwhite, init_skipwh0
   285                              <2> section_of init_skipcomma, init_skipcomm0
   286                              <2> section_of init_skipequals
   287                              <2> 
   288                              <2> 
   289                              <2> 	usesection lDEBUG_DATA_ENTRY
   289          ------------------  <2>  note: usesection lDEBUG_DATA_ENTRY
   290                              <2> section_of entry_retn
   291                              <2> 
   292                              <2> 
   293                              <2> %if _LINK
   294                              <2>  %include "extern.mac"
     1                              <3> 
     2                              <3> ; expr.asm
     3                              <3>  extern PPLEN, PPLEN_ONLY_PREFIXES, a_addr, alloc_seg, alloc_size
     4                              <3>  extern amis_multiplex_number, asm_options, asm_startoptions
     5                              <3>  extern auxbuff_current_size, auxbuff_segorsel, behind_r_u_addr
     6                              <3>  extern bp_offset, code_seg, code_size, d_addr, dcount_addr
     7                              <3>  extern dcpm_addr, dd_default_length, dd_default_lines, dd_text_and
     8                              <3>  extern debuggerfunction, default_pp_count, default_tp_count
     9                              <3>  extern default_tt_count, device_header_address, device_mcb_paragraphs
    10                              <3>  extern dwcount_addr, dz_addr, e_addr, encodedmach87, entryseg_size
    11                              <3>  extern env_size, envseg, erc, errret
    12                              <3>  extern extdata, extdata_size, extdata_used, extseg, extseg_size
    13                              <3>  extern extseg_used, flagbits.amount, flagnames, flagvaron
    14                              <3>  extern getrange_is_uu, getrange_lines, has_mmx, hhresult
    15                              <3>  extern history.segorsel, historyseg_size, immseg, input_file_handles
    16                              <3>  extern input_file_handles.active, internalflags, internalflags2
    17                              <3>  extern internalflags3, intr8_limit, io_columns, io_columns_getline
    18                              <3>  extern io_end_buffer, io_flags, io_levels, io_rows, io_start_buffer
    19                              <3>  extern line_out, line_out_end, linkinfoaddress, load_data
    20                              <3>  extern load_input_file, load_input_file.active, load_unit_flags
    21                              <3>  extern loaddata_loadedfrom, machine, maxmachinetype, messageseg
    22                              <3>  extern messageseg_size, mmxbuff, msg.as, msg.end, msg.executing
    23                              <3>  extern msg.executing_value_range, msg.from, msg.in, msg.length
    24                              <3>  extern msg.linear, msg.lines, msg.lr, msg.nd, msg.nottaken
    25                              <3>  extern msg.nt, msg.or, msg.questionmark, msg.r, msg.stack_overflow
    26                              <3>  extern msg.stack_overflow.caller, msg.stack_overflow.cond
    27                              <3>  extern msg.stack_overflow.indirection, msg.stack_overflow.linear
    28                              <3>  extern msg.stack_overflow.parens, msg.stack_overflow.precedence
    29                              <3>  extern msg.stack_overflow.value_in, msg.t, msg.taken, msg.to
    30                              <3>  extern msg.value, msgtable_value_range, options, options2, parent
    31                              <3>  extern ppbytes, priorrc, psp22, pspdbe, pspdbg
    32                              <3>  extern qqtermcode, rc_count, rc_limit, re_count, re_limit
    33                              <3>  extern reading_access_variables, reg16names, reg8names, reg_cs
    34                              <3>  extern reg_ds, reg_efl, reg_eip, reg_esp, search_results
    35                              <3>  extern serial_columns, serial_fifo_size, serial_keep_timeout
    36                              <3>  extern serial_rows, serial_use_baseport, serial_use_dl
    37                              <3>  extern serial_use_fifo, serial_use_intnum, serial_use_irqmask
    38                              <3>  extern serial_use_params, serial_var_baseport, serial_var_dl
    39                              <3>  extern serial_var_fifo, serial_var_intnum, serial_var_irqmask
    40                              <3>  extern serial_var_params, sscounter, stack, startoptions
    41                              <3>  extern table_length_keywords, throwsp, transfer_ext_cx
    42                              <3>  extern try_amis_multiplex_number, try_debugger_amis_multiplex_number
    43                              <3>  extern types, types.addresses_minus_end, types.end, u_addr
    44                              <3>  extern usertermcode, uu_default_length, uu_default_lines, vregs
    45                              <3>  extern vregs.amount, writing_access_variables
    46                              <3>  extern flagbits, regs
    47                              <3> 
    48                              <3> ; run.asm
    49                              <3>  extern ..@aa_access_end, ..@aa_access_start, ..@dd_access_end
    50                              <3>  extern ..@dd_access_start, ..@ee_access_end, ..@ee_access_start
    51                              <3>  extern ..@ee_interactive_access_end, ..@ee_interactive_access_start
    52                              <3>  extern ..@hh_indirection_memory_access_end
    53                              <3>  extern ..@hh_indirection_memory_access_start
    54                              <3>  extern ..@readmem_fault_skip_4_near_call, ..@rr_access_end
    55                              <3>  extern ..@rr_access_start, ..@rr_variable_read_access_end
    56                              <3>  extern ..@rr_variable_read_access_start
    57                              <3>  extern ..@rr_variable_write_access_end
    58                              <3>  extern ..@rr_variable_write_access_start, ..@sss_access_end
    59                              <3>  extern ..@sss_access_start, ..@uu_access_end, ..@uu_access_start
    60                              <3>  extern ..@uu_referenced_memory_access_end
    61                              <3>  extern ..@uu_referenced_memory_access_start, ..@uu_simulate_cmps_end
    62                              <3>  extern ..@uu_simulate_cmps_start, ..@uu_simulate_scas_end
    63                              <3>  extern ..@uu_simulate_scas_start, InDOS_or_BIOS_IO, PPLEN_ONLY_STRING
    64                              <3>  extern auxbuff_behind_last_silent
    65                              <3>  extern auxbuff_start_silent, bInDbg, b_bplist.bp, b_bplist.counter
    66                              <3>  extern b_bplist.disabled_mask, b_bplist.idbuffer, b_bplist.used_mask
    67                              <3>  extern b_bplist.when, bb_deferred_message_in_lineout_behind
    68                              <3>  extern bp_display_offset, calcpointbit, cmd2_reset_re, cmd_goto
    69                              <3>  extern debug22.cleartraceflag, decbyte, dmycmd, dumpregs_extended
    70                              <3>  extern enable_rh, entry_to_code_seg, entry_to_code_segsel, eqflag
    71                              <3>  extern eqladdr, exccsip, exception_csip, exception_stack, excloc
    72                              <3>  extern g_bplist.bp, g_bplist.used_count, get_set_id_offset_length
    73                              <3>  extern getc_if_any, getcseipbyte, getint2324, getpsp
    74                              <3>  extern gg_deferred_message, gg_first_cseip_linear
    75                              <3>  extern gg_next_cseip_linear, guard_auxbuff.1_or_2, idle, in_getinput
    76                              <3>  extern int19msg, internalflags6, intr8_counter, lastcmd, msg.again
    77                              <3>  extern msg.alreadytsr, msg.area_aa_access, msg.area_dd_access
    78                              <3>  extern msg.area_ee_access, msg.area_ee_interactive_access
    79                              <3>  extern msg.area_hh_indirection_memory_access, msg.area_rr_access
    80                              <3>  extern msg.area_rr_variable_read_access
    81                              <3>  extern msg.area_rr_variable_write_access, msg.area_run_access
    82                              <3>  extern msg.area_sss_access, msg.area_uu_access
    83                              <3>  extern msg.area_uu_referenced_memory_access
    84                              <3>  extern msg.area_uu_simulate_cmps, msg.area_uu_simulate_scas
    85                              <3>  extern msg.bb_hit.1, msg.bb_hit.2.counter, msg.bb_hitpass_id.after
    86                              <3>  extern msg.bb_hitpass_id.long, msg.bb_hitpass_id.short, msg.bb_pass.1
    87                              <3>  extern msg.cant_bp_linear, msg.cant_bp_linear.address1
    88                              <3>  extern msg.cant_bp_reason, msg.cant_bp_reason0, msg.cant_bp_reason1
    89                              <3>  extern msg.cant_bp_reason2, msg.cant_bp_reason3
    90                              <3>  extern msg.cant_bp_reason3.value, msg.cant_bp_reasonu
    91                              <3>  extern msg.cant_bp_restore, msg.cant_bp_restore.value
    92                              <3>  extern msg.cant_bp_the, msg.cant_bp_type_gg
    93                              <3>  extern msg.cant_bp_type_permanent, msg.cant_bp_type_permanent.index
    94                              <3>  extern msg.cant_bp_type_proceed, msg.cant_bp_write, msg.ctrlc
    95                              <3>  extern msg.empty_message, msg.goto, msg.invalidpsp, msg.list
    96                              <3>  extern msg.list_bp.address1, msg.list_bp.first, msg.list_bp.second
    97                              <3>  extern msg.list_bp.third, msg.list_bp.value, msg.list_bp_csip_16
    98                              <3>  extern msg.list_bp_none, msg.list_bp_not_cseip, msg.notyettsr
    99                              <3>  extern msg.nowattached, msg.nowtsr1, msg.nowtsr2, msg.psphooked
   100                              <3>  extern msg.pspnotfound, msg.remember, msg.selfownedpsp, msg.silent
   101                              <3>  extern msg.warnprefix, msg.while, msg.while_not_true
   102                              <3>  extern msg.while_terminated_after, msg.while_terminated_before
   103                              <3>  extern oldcols, oldcrtp, oldcsrpos, oldmr, options3
   104                              <3>  extern options6, pp_instruction, pp_operand, progexit, progtrm
   105                              <3>  extern rc, reg_eax, reg_es, reg_gs, reg_ss
   106                              <3>  extern run_int, run_sp, run_sp_reserve, savesp, setcseipbyte
   107                              <3>  extern setint2324, setpsp, setpspdbg
   108                              <3>  extern showstring, silence_dump, spadjust, swapscreen
   109                              <3>  extern tmode0, tmode1, tmodes, tmodev, tpg_possible_breakpoint
   110                              <3>  extern tpg_proceed_bp, tt_silent_mode_number, vpage, vrows
   111                              <3>  extern while_buffer, while_buffer.length, writemem
   112                              <3> 
   113                              <3>  extern ..@getcseipbyte_fault_skip_2_near_call
   114                              <3>  extern ..@setcseipbyte_fault_skip_2_near_call
   115                              <3>  extern ..@writemem_fault_skip_4_near_call_a
   116                              <3>  extern ..@writemem_fault_skip_4_near_call_b, int0Cmsg, int0Dmsg
   117                              <3>  extern int0msg, int18msg, int1msg, int3msg, int6msg
   118                              <3>  extern int8_kbd_msg, int8msg, runint_ctrlc_msg, serial_flags
   119                              <3> 
   120                              <3> ; bb.asm
   121                              <3>  extern ..@bb_id_length, ..@bb_id_start, ..@bb_saved_linear
   122                              <3>  extern ..@bb_when_length, ..@bb_when_start, b_bplist.id
   123                              <3>  extern b_bplist.idbuffer.free
   124                              <3>  extern b_bplist.whenbuffer, b_bplist.whenbuffer.free
   125                              <3>  extern bootcmd, crlf, msg.all, msg.at
   126                              <3>  extern msg.bb_no_new, msg.bb_when, msg.boot, msg.bp, msg.bpaddress
   127                              <3>  extern msg.bpcontent, msg.bpcounter, msg.bpdisabled, msg.bpenabled
   128                              <3>  extern msg.bpnone, msg.bpnone_at, msg.bpunused, msg.counter
   129                              <3>  extern msg.existing, msg.id, msg.new, msg.notbu, msg.number
   130                              <3>  extern msg.offset, msg.when, prnquit
   131                              <3> 
   132                              <3> ; rr.asm
   133                              <3>  extern InDOS_or_BIOS_output, cmdline_buffer
   134                              <3>  extern cmdline_buffer.end, cmdline_buffer.position, disflags, ee0a
   135                              <3>  extern error_expr, flagbits_for_40, flagbits_for_80, flagsoff
   136                              <3>  extern flagsoff_style2, flagsoff_style3, flagson, flagson_style23
   137                              <3>  extern get_memref_index_bx, getline00, getline_reset_notatty
   138                              <3>  extern guard_rc, hexnyb.common, hhtype, hhvar, in_re
   139                              <3>  extern mask_4byte, masks, memrefs, memrefs.free, msg.3byte
   140                              <3>  extern msg.abort, msg.append, msg.byte, msg.count, msg.dword
   141                              <3>  extern msg.highlight, msg.internal_error_no_mmx, msg.readonly
   142                              <3>  extern msg.readonly_mem, msg.regs386, msg.regs386_off, msg.regs386_on
   143                              <3>  extern msg.replace, msg.rh, msg.rv_mode.before, msg.rv_mode_r86m
   144                              <3>  extern msg.rv_mode_v86m, msg.rvd, msg.rvd_deviceheader
   145                              <3>  extern msg.rvd_not_device, msg.rvd_size, msg.rvm, msg.rvp
   146                              <3>  extern msg.rvp_application, msg.rvp_boot, msg.rvp_device
   147                              <3>  extern msg.rvp_device_attached, msg.rvp_tsr, msg.rvv
   148                              <3>  extern msg.unexpected_auxbuff_guard, msg.unhighlight, msg.vm_auxseg
   149                              <3>  extern msg.vm_codeseg, msg.vm_dataseg, msg.vm_entryseg, msg.vm_hisseg
   150                              <3>  extern msg.vm_messageseg, msg.vp_dparent, msg.vp_dpra
   151                              <3>  extern msg.vp_dpspsegment, msg.vp_parent, msg.vp_pra
   152                              <3>  extern msg.vp_pspsegment, msg.word, operatorfunctions, psp_parent
   153                              <3>  extern psp_pra, puts_break_line_more, putsline_break_line, re_buffer
   154                              <3>  extern re_buffer.end, re_buffer.position, re_sp, regs_prior
   155                              <3>  extern regs_prior.size, retn_expr, rh_count_number
   156                              <3>  extern rh_display_with_count, shortflagbits, shortflagbits.amount
   157                              <3>  extern shortflagsoff, shortflagson, silence_dump.rh
   158                              <3>  extern silence_dump.rh.all, table_getline_prepare_ldebug
   159                              <3>  extern table_getline_prepare_ms_debug, terminate_silent_dump
   160                              <3>  extern terminate_silent_dump.if_nonnull
   161                              <3> 
   162                              <3> ; rr.asm
   163                              <3>  extern flagbits_for_shl, regs_prior.size_w
   164                              <3> 
   165                              <3> ; aa.asm
   166                              <3>  extern REP_LEN, SEGP_LEN, attach
   167                              <3>  extern ext_aa_after_getline_handler, ext_aa_before_getline_handler
   168                              <3>  extern ext_aa_inject_handler, immasm_length, immasm_rel1632_target
   169                              <3>  extern immasm_rel8_target, msg.aa_internal_error, msg.attach
   170                              <3>  extern prefixlist.after_segment, replist, segprfxtab, showmach
   171                              <3>  extern skipalpha, sm1
   172                              <3> 
   173                              <3> ; uu.asm
   174                              <3>  extern A32P_LEN, GROUP7, MN_DB, MN_LOCK, MN_LOOP
   175                              <3>  extern MN_LOOPNZ, MN_LOOPZ, MN_REP, MN_REPE, MN_REPNE
   176                              <3>  extern MN_SEG, MN_WAIT, N_LOCK, N_LTABA, N_LTABO
   177                              <3>  extern N_WTAB, O32P_AMOUNT, OPTYPES_BASE, REP_DIFF_LEN, REP_SAME_LEN
   178                              <3>  extern SFPGROUP3, SGROUP4, SPARSE_BASE, a32prfxtab, dismach
   179                              <3>  extern dmflags, has_87, immasm_far_target, immasm_imm16, locktab
   180                              <3>  extern ltaba1, ltabo1, mach_87, mnlist, mnlist_a_suffix_allowed
   181                              <3>  extern mnlist_o_suffix_allowed, mnlist_o_suffix_required
   182                              <3>  extern msg.condjump, msg.condnotjump, msg.memrefs_invalid_internal
   183                              <3>  extern msg.uninstall, msg.uu_internal_error, msg.uu_too_many_repeat
   184                              <3>  extern needsmath, needsmath_L, needsmsg, needsmsg.digit_6_ofs
   185                              <3>  extern needsmsg.digit_x_ofs, needsmsg_L, o32prfxtab, obsmach
   186                              <3>  extern obsolete, obsolete_L, opindex, opinfo, oplists
   187                              <3>  extern optypes, ppbytes.string, ppbytes.string_amount, reg_ebp
   188                              <3>  extern reg_ebx, reg_ecx, reg_edi, reg_esi, reg_fs
   189                              <3>  extern regmem, rgnam16, rgnam816, segrgnam, sibbyte
   190                              <3>  extern sqztab, tab_to, uninstall, unused, wtab1
   191                              <3> 
   192                              <3> ; uu.asm
   193                              <3>  extern reg_edx
   194                              <3> 
   195                              <3> ; uu.asm
   196                              <3>  extern MN_BSWAP, MN_O32
   197                              <3> 
   198                              <3> ; uu.asm
   199                              <3>  extern MN_A32
   200                              <3> 
   201                              <3> ; amis.asm
   202                              <3>  extern amisintr_offset, deviceshim_size, ext_amis_handler
   203                              <3> 
   204                              <3> ; boot.asm
   205                              <3>  extern boot_remember_seek_handle
   206                              <3>  extern boot_remember_seek_offset, chkeol_or_then, cmd_goto.yy_entry
   207                              <3>  extern display_y_or_ext, ext_cmdline, ext_finish.boot
   208                              <3>  extern if_exists_found_open, if_exists_not_found
   209                              <3>  extern if_exists_then_address, iseol?_or_then, loadoptiontable
   210                              <3>  extern loadoptiontable.incompatible, loadsettings
   211                              <3>  extern msdos7_message_table, msdos7_message_table.size
   212                              <3>  extern msg.boot_access_error, msg.boot_and, msg.boot_auxbuff_crossing
   213                              <3>  extern msg.boot_badchain, msg.boot_badclusters, msg.boot_badfat
   214                              <3>  extern msg.boot_bpb_load_overlap, msg.boot_bpb_too_low
   215                              <3>  extern msg.boot_cannot_set_both, msg.boot_dot_crlf
   216                              <3>  extern msg.boot_file_not_found, msg.boot_file_too_big_error
   217                              <3>  extern msg.boot_file_too_small_error, msg.boot_internal_error
   218                              <3>  extern msg.boot_invalid_filename, msg.boot_invalid_heads
   219                              <3>  extern msg.boot_invalid_sectors, msg.boot_out_of_memory_error
   220                              <3>  extern msg.boot_partition_cycle_error, msg.boot_partition_not_found
   221                              <3>  extern msg.boot_quit_fail, msg.boot_sector_not_power
   222                              <3>  extern msg.boot_sector_too_large, msg.boot_sector_too_small
   223                              <3>  extern msg.boot_segment_too_low, msg.boot_too_many_partitions_error
   224                              <3>  extern msg.bootfail, msg.bootfail_check_mismatch
   225                              <3>  extern msg.bootfail_check_mismatch.check_got
   226                              <3>  extern msg.bootfail_check_mismatch.check_offset
   227                              <3>  extern msg.bootfail_check_mismatch.check_value, msg.bootfail_code
   228                              <3>  extern msg.bootfail_read, msg.bootfail_read_errorcode
   229                              <3>  extern msg.bootfail_secsizediffer, msg.bootfail_sig
   230                              <3>  extern msg.bootfail_sig_parttable, msg.bootfail_stack_underflow
   231                              <3>  extern msg.bpb, msg.checkoffset, msg.checkvalue, msg.dir
   232                              <3>  extern msg.dirinsteadsize, msg.emptydirname, msg.entry
   233                              <3>  extern msg.guard_auxbuff_error, msg.hidden, msg.hiddenadd
   234                              <3>  extern msg.maxpara, msg.minpara, msg.protocol, msg.quit, msg.read
   235                              <3>  extern msg.sector, msg.sector_alt, msg.segment, msg.write
   236                              <3>  extern msg.yy_empty, msg.yy_filename_empty, msg.yy_no_file
   237                              <3>  extern msg.yy_requires_filename, msg.yy_too_large
   238                              <3>  extern msg.yy_too_many_handles, terminator_in_line_in.offset
   239                              <3>  extern terminator_in_line_in.value, throwret
   240                              <3>  extern yy_boot_attempt_open_pathname, yy_boot_attempt_open_stack
   241                              <3>  extern yy_is_script
   242                              <3> 
   243                              <3> ; cc.asm
   244                              <3>  extern count_var, hh.single, msg.clear, msg.clear_sequence
   245                              <3>  extern msg.range, parsecm
   246                              <3> 
   247                              <3> ; dd.asm
   248                              <3>  extern auxbuff_current_size_minus_24, charcounter
   249                              <3>  extern dstringaddr, dstringtype, firstmcb, firstumcb, intaddress
   250                              <3>  extern lastint, lastint_is_86m_and_mcb, msg.di_empty, msg.di_error
   251                              <3>  extern msg.di_freedos_reloc, msg.di_hidden, msg.di_hma, msg.di_iisp
   252                              <3>  extern msg.di_jmpfar, msg.di_jmpfarindirect, msg.di_multiplex.1
   253                              <3>  extern msg.di_multiplex.2, msg.di_multiplex.3, msg.di_nonstd_iisp
   254                              <3>  extern msg.di_system_low, msg.di_system_mcb, msg.di_system_upper
   255                              <3>  extern msg.di_testhook, msg.di_toomany, msg.di_uninst_iisp
   256                              <3>  extern msg.header, msg.header.length, msg.invmcbadr, msg.prefixes
   257                              <3>  extern msg.tableheader, msg.tableheadertop, msg.top, msg.trailer
   258                              <3>  extern msg.trailer.length, smcbmsg_unknown, smcbtypes
   259                              <3> 
   260                              <3> ; debug.asm
   261                              <3>  extern UnhookInterruptForce, UnhookInterruptForceSim, aa
   262                              <3>  extern adusetup, bb, boot_ebdaflag, boot_initcode
   263                              <3>  extern boot_new_memsizekib, boot_old_memsizekib, cc, code_start, ddd
   264                              <3>  extern device_initcode, driveno, dumpregs_extended.exit, ee
   265                              <3>  extern eld_linkcall.call_cmd3, end_of_ldebug_code, entry_int3_retf
   266                              <3>  extern errcarat, ff, get_86m_interrupt_handler_no_dos, get_columns
   267                              <3>  extern getline_close_file, getline_close_file.resetstuff, gg, hh
   268                              <3>  extern hh_depth, hh_depth_of_single_term, hhflag, ia_restore, ii
   269                              <3>  extern immasm, install_86m_interrupt_handler, int22, int2D, intr0
   270                              <3>  extern intr0C, intr0D, intr1, intr18, intr19
   271                              <3>  extern intr3, intr6, intr8, linkinfo, ll
   272                              <3>  extern ll3, ll_copy_cmdline_and_fcbs
   273                              <3>  extern ll_copy_cmdline_and_fcbs.have_cx
   274                              <3>  extern mm, msg.NULblank, msg.asmoptions_1, msg.boothelp
   275                              <3>  extern msg.build_array, msg.build_long_amount, msg.build_short_amount
   276                              <3>  extern msg.build_version_amount, msg.cannot_hook_2D.invalid
   277                              <3>  extern msg.cannot_hook_2D.nofree, msg.cannotbootquit_memsizes
   278                              <3>  extern msg.condhelp, msg.ensure_no_memory, msg.expressionhelp
   279                              <3>  extern msg.flaghelp, msg.flags_1, msg.guard_rc_error
   280                              <3>  extern msg.guard_re_error, msg.help_array, msg.help_array_amount
   281                              <3>  extern msg.help_re, msg.help_run, msg.help_source, msg.keep
   282                              <3>  extern msg.license, msg.line_out_overflow, msg.n_toolongname
   283                              <3>  extern msg.n_toolongtail, msg.nobootsupp, msg.options_array
   284                              <3>  extern msg.options_array_amount, msg.options_pages, msg.options_scan
   285                              <3>  extern msg.options_scan_amount, msg.qq_a_terminated
   286                              <3>  extern msg.qq_a_unterminated, msg.qq_device_no_c, msg.qq_device_no_d
   287                              <3>  extern msg.qq_device_none_selected, msg.qq_unterm
   288                              <3>  extern msg.rc_limit_reached, msg.re, msg.re_limit_reached
   289                              <3>  extern msg.reghelp, msg.rh_disabled, msg.rh_enabled, msg.run
   290                              <3>  extern msg.serial_cannot_hook, msg.serial_cannot_hook.new_int
   291                              <3>  extern msg.serial_cannot_hook.old_int, msg.serial_cannot_unhook
   292                              <3>  extern msg.serial_cannot_unhook.int, msg.serial_cannot_unhook.nowarn
   293                              <3>  extern msg.serial_late_unhook, msg.serial_late_unhook.int
   294                              <3>  extern msg.serial_no_keep_enter, msg.serial_no_keep_timer
   295                              <3>  extern msg.serial_request_keep, msg.source, msg.string_build
   296                              <3>  extern msg.string_options, msg.string_version
   297                              <3>  extern msg.tsr_cannot_terminate_attached, msg.varhelp, oo, ph_msg, pp
   298                              <3>  extern putrunint, putsz_exthelp, rr, run, section.DEVICESHIM.vstart
   299                              <3>  extern serial_clean_up, serial_clear_fifos, serial_eoi
   300                              <3>  extern serial_init_UART, serial_install_interrupt_handler
   301                              <3>  extern serial_interrupt_handler, serial_uninstall_interrupt_handler
   302                              <3>  extern set_irq, setscreen, sleep_delta_limit, sleep_highest_delta
   303                              <3>  extern sss, tpg_initialise_empty_auxbuff.reset
   304                              <3>  extern transfer_to_ext_puts_getline, tt, update_inttab_optional, uu
   305                              <3>  extern vv, vv_disable, vv_set, ww, yy
   306                              <3> 
   307                              <3> ; debug.asm
   308                              <3>  extern eld_linkcall
   309                              <3> 
   310                              <3> ; ee.asm
   311                              <3>  extern bufend, bufnext, fillbuf, fullbsout
   312                              <3>  extern getline_is_input_file?, line_in, linecounter, load_extension
   313                              <3>  extern msg.ext, notatty, prehak1, run2324
   314                              <3> 
   315                              <3> ; hh.asm
   316                              <3>  extern hh_div_active, hh_div_dividend, hh_div_divisor
   317                              <3>  extern msg.base, msg.group, msg.hh_div_remainder, msg.width
   318                              <3> 
   319                              <3> ; iioo.asm
   320                              <3>  extern if_exists_length, if_exists_si, if_exists_sp
   321                              <3>  extern install, msg.exists, msg.install, msg.not, msg.then
   322                              <3>  extern msg.y, resetrc, yy_or_ext_no_guard_re
   323                              <3> 
   324                              <3> ; immasm.asm
   325                              <3>  extern aa_ret, addrr, condmsg, error_mirror, index
   326                              <3>  extern msg.immasm_error_eip, presizeflags, reg32addr, segmnt
   327                              <3>  extern segrgaddr
   328                              <3> 
   329                              <3> ; msg.asm
   330                              <3>  extern ..@boot_scan_dir_return_fat16_root_entry
   331                              <3>  extern ..@boot_scan_dir_return_filenotfound
   332                              <3>  extern ..@boot_scan_dir_return_subdir_or_fat32_entry
   333                              <3>  extern alloc_size_not_reserved, asciitablenames, boot_init_foundname
   334                              <3>  extern configpath, configpath.dir_end, device_quittable_regs, dpmi32
   335                              <3>  extern execblk.cmdline, ext_command_handler, ext_finish.bp_is_set
   336                              <3>  extern ext_handle, ext_inject_handler, ext_preprocess_handler
   337                              <3>  extern ext_puts_copyoutput_handler, ext_puts_getline_handler
   338                              <3>  extern ext_puts_handler, ext_var, ext_var_amount, ext_var_format
   339                              <3>  extern ext_var_size, extcssel, extdssel, handle_scan_dir_entry
   340                              <3>  extern handle_scan_dir_not_found, history.first, history.last
   341                              <3>  extern indirect_array_errfix, init_executable_pathname
   342                              <3>  extern init_executable_pathname.end, internalflags4, internalflags5
   343                              <3>  extern internalflags7, isvariable_morebyte_nameheaders.ext
   344                              <3>  extern lastcmd_transfer_ext_address, lastcmd_transfer_ext_entry
   345                              <3>  extern line_in.end, linkcall_table, load_adr_dirbuf_segment
   346                              <3>  extern load_check_dir_attr, load_data_lowest, load_kernel_name
   347                              <3>  extern load_yy_direntry, load_yyname_input, load_yyname_next
   348                              <3>  extern near_transfer_ext_address, near_transfer_ext_entry
   349                              <3>  extern next_reserved_segment, options4, options5, options7
   350                              <3>  extern patcharea_intrtn, patcharea_intrtn.segment
   351                              <3>  extern patcharea_intrtn.size, patcharea_run, patcharea_run.segment
   352                              <3>  extern patcharea_run.size, pm_2_86m_0, promptlen, reserved_address
   353                              <3>  extern scriptspath, scriptspath.dir_end
   354                              <3>  extern sss_silent_count, sss_silent_count_used, stack_end, swch1
   355                              <3>  extern while_buffer.end
   356                              <3> 
   357                              <3> ; msg.asm
   358                              <3>  extern install_trying
   359                              <3> 
   360                              <3> ; init.asm
   361                              <3>  extern ..@init_behind, ..@init_first
   362                              <3>  extern ..@patch_no386_ds_6_DATA_ENTRY
   363                              <3>  extern ..@patch_no386_ds_code_or_entry
   364                              <3>  extern ..@patch_no386_iret_code_or_entry, behind_code_truncated
   365                              <3>  extern behind_init, behind_messagesegment_nobits
   366                              <3>  extern behind_messagesegment_nobits_truncated, debug22
   367                              <3>  extern device_header.next, devint23, devint24, entry_retf
   368                              <3>  extern execblk.fcb1, execblk.fcb2, ext_data_area, extcall_table.ret
   369                              <3>  extern extcall_table.segsel, fileext, hVdd, immasm_buffer, initcont
   370                              <3>  extern initcont.boot_entry, initcont.device, inttab, inttab.i06
   371                              <3>  extern inttab.i2D, inttab_number_variable, line_out_overflow
   372                              <3>  extern linkcall_table.code1, linkcall_table.entry
   373                              <3>  extern linkcall_table.init, oldmode, pInDOS, pSDA, regs.size
   374                              <3>  extern switchar, trim_overflow, var_addr_entries
   375                              <3>  extern var_addr_entries.amount
   376                              <3> 
   377                              <3> ; install.asm
   378                              <3>  extern installflags, msg.alreadydisabled
   379                              <3>  extern msg.alreadyenabled, msg.toggle, msg.trydisable, msg.tryenable
   380                              <3> 
   381                              <3> ; ints.asm
   382                              <3>  extern debuggeramissig, inttab_optional
   383                              <3> 
   384                              <3> ; lineio.asm
   385                              <3>  extern auxbuff_amount_silent, cmd3_set_options
   386                              <3>  extern determine_quiet_output, eldheader, getc_repeat_idle
   387                              <3>  extern getline_timer_func, handle_ctrl_c, if_exists_found_closed
   388                              <3>  extern if_exists_found_ext_open, indos_remember_seek_function
   389                              <3>  extern indos_remember_seek_handle, indos_remember_seek_offset
   390                              <3>  extern input_file_handles.to_close, msg.configkeyword
   391                              <3>  extern msg.eld_error_code, msg.eld_load_error, msg.emptykeyword
   392                              <3>  extern msg.eof, msg.executablekeyword, msg.ext_error_internal
   393                              <3>  extern msg.ext_error_invalid, msg.ext_error_io, msg.ext_error_oom
   394                              <3>  extern msg.freedos_ctrlc_workaround, msg.goto_empty
   395                              <3>  extern msg.goto_not_file, msg.goto_not_found.1, msg.goto_not_found.2
   396                              <3>  extern msg.history_internal_error, msg.more, msg.more_over
   397                              <3>  extern msg.more_over_size, msg.more_size, msg.rh_step.1
   398                              <3>  extern msg.rh_step.2, msg.scriptskeyword, msg.silent_error, msg.sof
   399                              <3>  extern msg.unexpected_noneol_rc, msg.unexpected_noneol_re
   400                              <3>  extern msg.yy_error_file_open, msg.yy_filename_missing_unquote
   401                              <3>  extern msg.yy_no_dos, qq, section.DATASTACK.vstart
   402                              <3>  extern serial_check_receive_char, serial_receive_char
   403                              <3>  extern serial_send_char, skip_rh, yy_boot
   404                              <3>  extern yy_boot_clear_remember_seek, yy_boot_close_file, yy_boot_read
   405                              <3>  extern yy_boot_remember_seek, yy_boot_seek_current
   406                              <3>  extern yy_boot_seek_start, yy_try_scriptspath
   407                              <3>  extern yy_try_scriptspath.didnotyettry
   408                              <3>  extern yy_try_scriptspath.nokeywordused
   409                              <3> 
   410                              <3> ; ll.asm
   411                              <3>  extern doserr8, ensuredebuggeeloaded, execblk, execblk.csip
   412                              <3>  extern execblk.sssp, msg.hexerror, msg.ll_unterm, msg.not_while_indos
   413                              <3>  extern msg.tsr_cannot_ll, parselw, reading
   414                              <3>  extern terminate_attached_process, ww1, ww15, zeroregs
   415                              <3> 
   416                              <3> ; mm.asm
   417                              <3>  extern has_287, has_copr, msg.c0, msg.cr, msg8088
   418                              <3>  extern msgx86, no_copr, parsecm_have_address
   419                              <3> 
   420                              <3> ; serialp.asm
   421                              <3>  extern baseport, msg.no_progress, rxfifo, rxhead
   422                              <3>  extern rxtail, serial_fcr_setting, serial_installed_intnum
   423                              <3>  extern serial_save_dl, serial_save_ier, serial_save_irq_mask
   424                              <3>  extern serial_save_irq_off, serial_save_lcr, serial_save_mcr, txfifo
   425                              <3>  extern txhead, txtail
   426                              <3> 
   427                              <3> ; ss.asm
   428                              <3>  extern msg.matches, msg.reverse, msg.seconds, msg.sleep
   429                              <3>  extern msg.ticks, sleep_repeat_idle
   430                              <3> 
   431                              <3> ; vv.asm
   432                              <3>  extern csrpos, msg.nokeep, msg.off, msg.on, msg.vv_disabled
   433                              <3>  extern msg.vv_enable_failure, xmsdrv, xmsmove
   434                              <3> 
   435                              <3> ; ww.asm
   436                              <3>  extern diskful, doserr11, doserr2, doserr3, doserr5
   437                              <3>  extern drive, drivenumber, dskerrs, not_while_indos, nowhexe
   438                              <3>  extern nownull, openerr, openerr1, writing, wwmsg1
   439                              <3>  extern wwmsg2
   440                              <3> 
   441                              <3> 
   442                              <3>  extern bCSAttr, lDEBUG_CODE_to_lDEBUG_CODE2_nearcall_helper
   443                              <3> 
   444                              <3>  extern hook2F.not_in_dos
   445                              <3> 
   446                              <3>  extern cmd4.int3, lDEBUG_CODE2_dualret_helper
   447                              <3>  extern lDEBUG_CODE2_to_lDEBUG_CODE_nearcall_helper
   448                              <3>  extern lDEBUG_CODE_to_lDEBUG_CODE2_dualcall_helper, msg.bu
   449                              <3>  extern msg.bu_relocated, msg.bu_relocated.sign
   450                              <3> 
   451                              <3>  extern nopmsupp
   452                              <3> 
   453                              <3>  extern bAddr32
   454                              <3> 
   455                              <3>  extern descriptor, descriptor.attrib, descriptor.base
   456                              <3>  extern descriptor.limit, gatewrong, msg.d.a_error, msg.d.a_error_code
   457                              <3>  extern msg.d.a_success, msg.d.a_success_sel, msg.d.b_error
   458                              <3>  extern msg.d.b_error_code, msg.d.b_success, msg.d.d_error
   459                              <3>  extern msg.d.d_error_code, msg.d.d_success, msg.d.l_error
   460                              <3>  extern msg.d.l_error_code, msg.d.l_success, msg.d.t_error
   461                              <3>  extern msg.d.t_error_code, msg.d.t_success, msg.deschelp, msg.ofs32
   462                              <3>  extern nodesc
   463                              <3> 
   464                              <3>  extern ..@patch_tsr_quit_run, areastruc_entry.qq_entry, cssel
   465                              <3>  extern ddebugareas.next, debug2F, dpmidisable, dpmientry, dpmihook
   466                              <3>  extern dpmihookamis, dpmihookcs, dpmiwatch, end_of_ldebug_code2
   467                              <3>  extern findinstalleddebugger, get_messagesegsel, handle_mode_changed
   468                              <3>  extern i23pm, msg.cannotpmquit, msg.desc, msg.dpmi_no_hook, msg.msdos
   469                              <3>  extern msg.qq_device_pm, msg.qq_still_pm, msg.qqlate_areas_error
   470                              <3>  extern msg.readonly_verifysegm, msg.readonly_verifysegm.selector
   471                              <3>  extern mydpmientry, nodosext, oldi2F, pm_reset_handlers, scratchsel
   472                              <3>  extern sr_state, switchmode, uninstall_areas.qq_entry
   473                              <3> 
   474                              <3>  extern i24pm
   475                              <3> 
   476                              <3>  extern auxbuff_switchbuffer_size, code2_seg, code2_sel, code2_size
   477                              <3>  extern code_sel, daresult, dssel, immsel
   478                              <3>  extern lDEBUG_CODE2_to_lDEBUG_CODE_dualcall_helper
   479                              <3>  extern lDEBUG_CODE_dualret_helper, messagesel, msg.desctype
   480                              <3>  extern msg.stack_overflow.desctype
   481                              <3> 
   482                              <3>  extern cmd3_mirror
   483                              <3> 
   484                              <3>  extern ..@patch_entry_seg, ..@patch_no386_ds_4, ..@patch_no386_ds_5
   485                              <3>  extern ..@patch_no386_ds_entry_pmint21_1
   486                              <3>  extern ..@patch_no386_ds_entry_pmint21_2, areas_fun, areas_sub
   487                              <3>  extern ddebugareas.prev, linkcall_table.code2
   488                              <3> 
   489                              <3>  extern areas_struc, msg.areasalreadyinstalled
   490                              <3>  extern msg.areasalreadyuninstalled, msg.areasinstalled
   491                              <3>  extern msg.areasnodebuggerfound, msg.areasnotinstalled
   492                              <3>  extern msg.areasnotinstalled.code, msg.areasnotsupported
   493                              <3>  extern msg.areasuninstalled, msg.areasuninstalled.code
   494                              <3> 
   495                              <3>  extern intcall_return_parameter_es_parameter_ds
   496                              <3>  extern lDEBUG_CODE_to_lDEBUG_CODE_dualcall_helper, pop_if, push_if
   497                              <3> 
   498                              <3>  extern isextenderavailable, msg.cannotpmload, nodosextinst
   499                              <3> 
   500                              <3>  extern install_areas, patcharea_pm_exc, patcharea_pm_exc.segment
   501                              <3>  extern patcharea_pm_exc.size
   502                              <3> 
   503                              <3>  extern pmint21
   504                              <3> 
   505                              <3>  extern debuggerexception, entry_to_code_sel, exc6msg, excCmsg
   506                              <3>  extern excDmsg, excEmsg, intrtn2_entry, pmintsave.int21
   507                              <3> 
   508                              <3>  extern convsegs, convsegs.amount_fixed, convsegs.end_fixed
   509                              <3>  extern dpmi_pm2rm, dpmi_pmsav, dpmi_rm2pm, dpmi_rmsav, endexctab
   510                              <3>  extern exc_first, exc_second, excsave, exctab, installdpmimsg
   511                              <3>  extern intrtn_entry.from_installdpmi, pmintsave, pminttab
   512                              <3>  extern pminttab.end, setrmaddr, silence_delete_one_string.internal
   513                              <3> 
   514                              <3>  extern msg.rv_mode_dpmi_16, msg.rv_mode_dpmi_32, msg.vm_code2seg
   515                              <3>  extern msg.vm_selector, msg.vp_dpspsel, msg.vp_pspsel, psp_selector
   516                              <3> 
   517                              <3>  extern ..@getcseipbyte_fault_skip_6_near_call
   518                              <3>  extern ..@hh_code1_indirection_memory_access_end
   519                              <3>  extern ..@hh_code1_indirection_memory_access_start
   520                              <3>  extern ..@readmem_fault_skip_2_near_call
   521                              <3>  extern ..@setcseipbyte_fault_skip_6_near_call
   522                              <3>  extern ..@writemem_fault_skip_2_near_call_a
   523                              <3>  extern ..@writemem_fault_skip_2_near_call_b, behind_code
   524                              <3>  extern behind_code2, convsegs.amount, ddebugareas
   525                              <3>  extern getline_extra_int22.cleartraceflag, msg.list_bp_cseip_32
   526                              <3> 
   527                              <3>  extern MN_O16
   528                              <3> 
   529                              <3>  extern MN_A16
   530                              <3> 
   531                              <3>  extern relocatedzero
   532                              <3> 
   533                              <3>  extern msg.bu_disabled
   534                              <3> 
   535                              <3>  extern reset_interrupts, set_interrupts
   536                              <3> 
   537                              <3>  extern startoptions6
   538                              <3> 
   539                              <3>  extern currentposition, msg.loader_bottom_not_allowed
   540                              <3>  extern msg.loader_too_low_load
   541                              <3> 
   542                              <3>  extern intr_loader_18, intr_loader_19, moveloader_hook_ints
   543                              <3> 
   544                              <3>  extern loader_query, loader_transfer_cmd3, loader_transfer_relocate
   545                              <3> 
   546                              <3>  extern cmd3_int_disable.set_bx_to_dx, cmd3_int_enable.set_bx_to_dx
   547                              <3>  extern ldebug_code_size, movesegrefstable, movetable
   548                              <3>  extern movetable.bottom, msg.isalready, msg.isnow, msg.loader_error
   549                              <3>  extern msg.move, msg.move_auxbuff_error, msg.move_auxdown
   550                              <3>  extern msg.move_auxup, msg.move_ebdanottop, msg.move_empty
   551                              <3>  extern msg.move_int_error, msg.move_int_panic
   552                              <3>  extern msg.move_must_be_bottom, msg.move_nottop, msg.move_oom
   553                              <3>  extern msg.move_rpl, msg.move_toolargeebda, msg.unsupportedmove
   554                              <3>  extern qq_int_unhook_sim.set_bx_to_dx
   555                              <3> 
   556                              <3>  extern moveloader.already, moveloader.bottom_to_hidden
   557                              <3>  extern moveloader.bottom_to_top, moveloader.hidden_to_bottom
   558                              <3>  extern moveloader.hidden_to_top, moveloader.top_to_bottom
   559                              <3>  extern moveloader.top_to_hidden
   560                              <3> 
   561                              <3>  extern moveloader.specificerror, moveloader_check_serial, msg.godebug
   562                              <3>  extern msg.loader_extra, msg.loader_flag, msg.loader_loadseg_low
   563                              <3>  extern msg.loader_must_be_hidden, msg.loader_sign, msg.loader_stack
   564                              <3>  extern msg.loadsupportsignature, msg.loadsupportsignature.size
   565                              <3> 
   566                              <3>  extern depack, hshrink_memory_source.offset
   567                              <3>  extern hshrink_memory_source.segment, indirect_hshrink_message_buffer
   568                              <3>  extern msg.hshrink_error, nontruncated_hshrink_message_buffer
   569                              <3> 
   570                              <3>  extern truncated_hshrink_message_buffer
   571                              <3> 
   572                              <3>  extern patch_boothelp_uncompressed
   573                              <3> 
   574                              <3>  extern msg.copybpb
   295                              <2> %endif
   710                              <1> %endif
   711                              <1> [list -]
   714                              <1> 
   715                              <1> %include "eld.mac"
     1                              <2> %if 0
     2                              <2> 
     3                              <2> Extensions for lDebug macros
     4                              <2> 
     5                              <2> Copyright (C) 2008-2025 E. C. Masloch
     6                              <2> 
     7                              <2> Usage of the works is permitted provided that this
     8                              <2> instrument is retained with the works, so that any entity
     9                              <2> that uses the works is notified of this instrument.
    10                              <2> 
    11                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    12                              <2> 
    13                              <2> %endif
    14                              <2> 
    15                              <2> %ifndef ELD_MAC
    16                              <2> %define ELD_MAC 1
    17                              <2> 
    18                              <2> %include "lmacros3.mac"
     1                              <3> [list -]
    19                              <2> 
    20                              <2> 		; ELD executable header
    21                              <2> 	struc ELD_HEADER
    22 00000000 ????????            <2> eldhSignature:		resb 4	; "ELD1"
    23 00000004 ??????              <2> 			resb 3	; reserved
    24 00000007 ??                  <2> 			resb 1	; 26 (Ctrl-Z)
    25 00000008 ????????            <2> eldhCodeOffset:		resd 1	; position displacement from eldhSignature
    26 0000000C ????                <2> eldhCodeImageLength:	resw 1	; amount bytes, at least 32
    27 0000000E ????                <2> eldhCodeAllocLength:	resw 1	; amount bytes, added to prior. sum < 64 KiB
    28 00000010 ????????            <2> eldhDataOffset:		resd 1
    29 00000014 ????                <2> eldhDataImageLength:	resw 1	; (zero allowed)
    30 00000016 ????                <2> eldhDataAllocLength:	resw 1	; (zero allowed)
    31 00000018 ????                <2> eldhCodeEntrypoint:	resw 1	; within code section, used as displacement
    32 0000001A ????????            <2> eldhReserved:		resb 4	; reserved
    33 0000001E ????                <2> eldhExtensionSize:	resw 1	; from eldhSignature, -> past eldhx fields in use
    34                              <2> 	endstruc
    35                              <2> 	endarea ELD_HEADER, 1
    36                              <2> 
    37                              <2> 	struc ELD_HEADERX
    38 00000000 <res 20h>           <2> eldhxHeader:		resb ELD_HEADER_size
    39 00000020 ????????            <2> eldhxDescriptionOffset:	resd 1	; zero if none, from eldhxHeader. <= 128 Bytes
    40 00000024 ????????            <2> eldhxHelpOffset:	resd 1	; zero if none, from eldhxHeader
    41 00000028 ????????            <2> eldhxLibTable:		resd 1	; zero if none, from eldhxHeader
    42 0000002C ????????            <2> eldhxDateTimeOffset:	resd 1	; zero if none, from eldhxHeader
    43                              <2> 	alignb 16
    44                              <2> 	endstruc
    45                              <2> 
    46                              <2> 	struc ELD_TRAILER_HEADER
    47 00000000 ????????????????    <2> eldthSignature:		resb 8	; "ELD1TAIL"
    48 00000008 ????????            <2> eldthHeaderOffset:	resd 1	; negative displacement from eldthSignature,
    49                              <2> 				;  add this dword to the seek offset
    50 0000000C ????                <2> eldthReserved:		resw 1	; reserved, must be initialised to zero
    51 0000000E ????                <2> eldthChecksum:		resw 1	; sum of all words in trailer header = 0
    52                              <2> 	endstruc
    53                              <2> 	endarea ELD_TRAILER_HEADER, 1
    54                              <2> 
    55                              <2> 	struc ELD_LIBTABLE
    56 00000000 ????                <2> eldltFormat:		resw 1
    57                              <2> 	; 0 = uncompressed
    58                              <2> 	; 2 = heatshrink compressed
    59                              <2> 	; 3 = lzexedat -4 compressed
    60                              <2> 	; 4 = lzexedat -4 -l compressed
    61 00000002 ????                <2> eldltAmount:		resw 1
    62 00000004 ????????            <2> eldltOffset:		resd 1	; from eldhxHeader
    63                              <2> eldltCompressedLength:		; (dword, only present if format 2, 3, or 4)
    64                              <2> 	endstruc
    65                              <2> 	endarea ELD_LIBTABLE, 1
    66                              <2> 
    67                              <2> 		; ELD instance header
    68                              <2> 	struc ELD_INSTANCE
    69 00000000 ????                <2> eldiStartCode:		resw 1	; -> this structure itself (para aligned)
    70 00000002 ????                <2> eldiEndCode:		resw 1	; -> behind memory used by instance (para aligned)
    71 00000004 ????                <2> eldiStartData:		resw 1	; -> data in data entry section (para aligned), or 0
    72 00000006 ????                <2> eldiEndData:		resw 1	; -> behind data (para aligned), or 0
    73 00000008 ????????????????    <2> eldiIdentifier:		resb 8	; blank-filled text
    74 00000010 ????                <2> eldiFlags:		resw 1	; flags
    75                              <2> eldiListing_size equ 14
    76 00000012 <res Eh>            <2> eldiListing:		resb eldiListing_size
    77                              <2> 				; ASCIZ listing file name
    78                              <2> 	endstruc
    79                              <2> 		; flags for eldiFlags:
    80                              <2> eldifResident:		equ 1
    81                              <2> 
    82                              <2> 		; ELD link info header
    83                              <2> 	struc ELD_LINKINFO
    84 00000000 ????                <2> eldlSignature:		resw 1	; 0E1D1h
    85 00000002 ????????            <2> eldlReserved:		resw 2
    86 00000006 ????                <2> eldlUseLinkHash:	resw 1
    87 00000008 ????                <2> eldlDataAmount:		resw 1
    88 0000000A ????                <2> eldlDataPrefixes:	resw 1
    89 0000000C ????                <2> eldlDataEntries:	resw 1
    90 0000000E ????                <2> eldlDataAddresses:	resw 1
    91 00000010 ????                <2> eldlCodeAmount:		resw 1
    92 00000012 ????                <2> eldlCodePrefixes:	resw 1
    93 00000014 ????                <2> eldlCodeEntries:	resw 1
    94 00000016 ????                <2> eldlCodeAddresses:	resw 1
    95                              <2> 	endstruc
    96                              <2> 
    97                              <2> 	numdef ELD_CODE_VSTART, 9001h
    98                              <2> 	numdef ELD_DATA_VSTART, 8000h
    99                              <2> 	numdef ELD_RELOC_VSTART, 8000h
   100                              <2> 
   101                              <2> 	numdef ELD_RECLAIM_HINT, 0
   102                              <2> 	strdef ELD_LISTING, ""
   103                              <2> 	numdef ELD_DATETIME, 0
   104                              <2> 
   105                              <2> %if _ELD_DATETIME
   106                              <2>  %define PUT_ELDHX_DATETIME_OFFSET at eldhxDateTimeOffset, dd DATAOFFSET + datetime - datastart
   107                              <2>  %macro PUT_ELD_DATETIME 0.nolist
   108                              <2> datetime:	asciz __UTC_DATE__,'T',__UTC_TIME__,'Z'
   109                              <2> 		asciz		; for future extension
   110                              <2>  %endmacro
   111                              <2> %else
   112                              <2>  %define PUT_ELDHX_DATETIME_OFFSET
   113                              <2>  %define PUT_ELD_DATETIME
   114                              <2> %endif
   115                              <2> 
   116                              <2> %endif
   716                              <1> 
   717                              <1> %include "install.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug INSTALL command macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2023 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 	struc INSTALLFLAG
    17 00000000 ????                <2> ifKeyword:	resw 1
    18 00000002 ????                <2> ifDescription:	resw 1
    19 00000004 ????                <2> ifOptions:	resw 1
    20 00000006 ????                <2> ifValue:	resw 1
    21 00000008 ????                <2> ifTrying:	resw 1
    22 0000000A ????                <2> ifReserved:	resw 1
    23                              <2> 	endstruc
    24                              <2> 
   718                              <1> 
   719                              <1> %if _SYMBOLIC
   720                              <1> 	defaulting 0			; disable defaulting
   721                              <1> %include "symbols.mac"
   722                              <1> [list -]
   723                              <1> 		; symbolic branch defines *without* defaulting!
   724                              <1> 	numdef ZZ_INSERT_TEMP, 1
   725                              <1> 	numdef XMS_SYMBOL_TABLE, 1
   726                              <1> 	numdef BUFFER_86MM_SLICE, 0
   727                              <1> 	numdef SECOND_SLICE, 0
   728                              <1> 
   729                              <1> 	defaulting 1			; re-enable defaulting
   730                              <1> 
   731                              <1> 		; symbolic branch defines
   732                              <1> 	numdef 86MM_SYMBOL_TABLE_MAX, 256, 256
   733                              <1> %endif
   734                              <1> 
   735                              <1> 	struc SEGADR
   736 00000000 ????????            <1> saOffset:	resd 1
   737 00000004 ????                <1> saSegSel:	resw 1
   738                              <1> %if _PM
   739 00000006 ????                <1> saSegment:	resw 1
   740 00000008 ????                <1> saSelector:	resw 1
   741                              <1> %endif
   742                              <1> 	endstruc
   743                              <1> 
   744                              <1> 	%macro segmentedaddress 0.nolist
   745                              <1> 	istruc SEGADR
   746                              <1> 	iend
   747                              <1> 	%endmacro
   748                              <1> 
   749                              <1> 	struc SEGOFS16ADR
   750 00000000 ????                <1> so16aOffset:	resw 1
   751 00000002 ????                <1> so16aSegSel:	resw 1
   752                              <1> %if _PM
   753 00000004 ????                <1> so16aSegment:	resw 1
   754 00000006 ????                <1> so16aSelector:	resw 1
   755                              <1> %endif
   756                              <1> 	endstruc
   757                              <1> 
   758                              <1> 	%macro segofs16address 0-1.nolist zero
   759                              <1> 	istruc SEGOFS16ADR
   760                              <1> %ifidni %1,zero
   761                              <1> %elifidni %1,minusone
   762                              <1> at so16aOffset,		dw -1
   763                              <1> at so16aSegSel,		dw -1
   764                              <1>  %if _PM
   765                              <1> at so16aSegment,	dw -1
   766                              <1> at so16aSelector,	dw -1
   767                              <1>  %endif
   768                              <1> %else
   769                              <1>  %error Unexpected initialiser keyword
   770                              <1> %endif
   771                              <1> 	iend
   772                              <1> 	%endmacro
   773                              <1> 
   774                              <1> 	struc SEGONLYADR
   775 00000000 ????                <1> soaSegSel:	resw 1
   776                              <1> %if _PM
   777 00000002 ????                <1> soaSegment:	resw 1
   778 00000004 ????                <1> soaSelector:	resw 1
   779                              <1> %endif
   780                              <1> 	endstruc
   781                              <1> 
   782                              <1> 	%macro segonlyaddress 0.nolist
   783                              <1> 	istruc SEGONLYADR
   784                              <1> 	iend
   785                              <1> 	%endmacro
   786                              <1> 
   787                              <1> 
   788                              <1> %if _LOADER
   789                              <1> 	struc MOVETABLEENTRY
   790                              <1> mteIdentifier:		resw 1
   791                              <1> mteArrayIndex:		resw 1
   792                              <1> mteStatusMessage:	resw 1
   793                              <1> mteFromArray:
   794                              <1> mteFromBottom:		resw 1
   795                              <1> mteFromTop:		resw 1
   796                              <1> mteFromHidden:		resw 1
   797                              <1> 	endstruc
   798                              <1> %endif
   799                              <1> 
   800                              <1> %if _BOOTLDR
   801                              <1>  %include "iniload.mac"
     1                              <2> %if 0
     2                              <2> 
     3                              <2> lDebug iniload/boot interfacing structs and macros
     4                              <2> 
     5                              <2> Copyright (C) 2008-2025 E. C. Masloch
     6                              <2> 
     7                              <2> Usage of the works is permitted provided that this
     8                              <2> instrument is retained with the works, so that any entity
     9                              <2> that uses the works is notified of this instrument.
    10                              <2> 
    11                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    12                              <2> 
    13                              <2> %endif
    14                              <2> 
    15                              <2> 
    16                              <2> 	struc BS
    17 00000000 ??????              <2> bsJump:	resb 3
    18 00000003 ????????????????    <2> bsOEM:	resb 8
    19                              <2> bsBPB:
    20                              <2> 	endstruc
    21                              <2> 
    22                              <2> 	struc EBPB		;        BPB sec
    23 00000000 ????                <2> bpbBytesPerSector:	resw 1	; offset 00h 0Bh
    24 00000002 ??                  <2> bpbSectorsPerCluster:	resb 1	; offset 02h 0Dh
    25 00000003 ????                <2> bpbReservedSectors:	resw 1	; offset 03h 0Eh
    26 00000005 ??                  <2> bpbNumFATs:		resb 1	; offset 05h 10h
    27 00000006 ????                <2> bpbNumRootDirEnts:	resw 1	; offset 06h 11h -- 0 for FAT32
    28 00000008 ????                <2> bpbTotalSectors:	resw 1	; offset 08h 13h
    29 0000000A ??                  <2> bpbMediaID:		resb 1	; offset 0Ah 15h
    30 0000000B ????                <2> bpbSectorsPerFAT:	resw 1	; offset 0Bh 16h -- 0 for FAT32
    31 0000000D ????                <2> bpbCHSSectors:		resw 1	; offset 0Dh 18h
    32 0000000F ????                <2> bpbCHSHeads:		resw 1	; offset 0Fh 1Ah
    33 00000011 ????????            <2> bpbHiddenSectors:	resd 1	; offset 11h 1Ch
    34 00000015 ????????            <2> bpbTotalSectorsLarge:	resd 1	; offset 15h 20h
    35                              <2> bpbNew:				; offset 19h 24h
    36                              <2> 
    37 00000019 ????????            <2> ebpbSectorsPerFATLarge:	resd 1	; offset 19h 24h
    38 0000001D ????                <2> ebpbFSFlags:		resw 1	; offset 1Dh 28h
    39 0000001F ????                <2> ebpbFSVersion:		resw 1	; offset 1Fh 2Ah
    40 00000021 ????????            <2> ebpbRootCluster:	resd 1	; offset 21h 2Ch
    41 00000025 ????                <2> ebpbFSINFOSector:	resw 1	; offset 25h 30h
    42 00000027 ????                <2> ebpbBackupSector:	resw 1	; offset 27h 32h
    43 00000029 <res Ch>            <2> ebpbReserved:		resb 12	; offset 29h 34h
    44                              <2> ebpbNew:			; offset 35h 40h
    45                              <2> 	endstruc
    46                              <2> 
    47                              <2> 	struc BPBN		; ofs B16 S16 B32 S32
    48 00000000 ??                  <2> bpbnBootUnit:		resb 1	; 00h 19h 24h 35h 40h
    49 00000001 ??                  <2> 			resb 1	; 01h 1Ah 25h 36h 41h
    50 00000002 ??                  <2> bpbnExtBPBSignature:	resb 1	; 02h 1Bh 26h 37h 42h -- 29h for valid BPBN
    51 00000003 ????????            <2> bpbnSerialNumber:	resd 1	; 03h 1Ch 27h 38h 43h
    52 00000007 <res Bh>            <2> bpbnVolumeLabel:	resb 11	; 07h 20h 2Bh 3Ch 47h
    53 00000012 ????????????????    <2> bpbnFilesystemID:	resb 8	; 12h 2Bh 36h 47h 52h
    54                              <2> 	endstruc		; 1Ah 33h 3Eh 4Fh 5Ah
    55                              <2> 
    56                              <2> 	struc DIRENTRY
    57 00000000 ????????????????    <2> deName:		resb 8
    58 00000008 ??????              <2> deExt:		resb 3
    59 0000000B ??                  <2> deAttrib:	resb 1
    60 0000000C ??                  <2> dePlusSize:	resb 1
    61 0000000D ??????????????      <2> 		resb 7
    62 00000014 ????                <2> deClusterHigh:	resw 1
    63 00000016 ????                <2> deTime:		resw 1
    64 00000018 ????                <2> deDate:		resw 1
    65 0000001A ????                <2> deClusterLow:	resw 1
    66 0000001C ????????            <2> deSize:		resd 1
    67                              <2> 	endstruc
    68                              <2> 
    69                              <2> ATTR_READONLY	equ 1
    70                              <2> ATTR_HIDDEN	equ 2
    71                              <2> ATTR_SYSTEM	equ 4
    72                              <2> ATTR_VOLLABEL	equ 8
    73                              <2> ATTR_DIRECTORY	equ 10h
    74                              <2> ATTR_ARCHIVE	equ 20h
    75                              <2> 
    76                              <2> lsvclSignature		equ "CL"
    77                              <2> lsvclBufferLength	equ 256
    78                              <2> 
    79                              <2> 	struc LOADSTACKVARS, -10h
    80 FFFFFFF0 ????????            <2> lsvFirstCluster:	resd 1
    81 FFFFFFF4 ????????            <2> lsvFATSector:		resd 1
    82 FFFFFFF8 ????                <2> lsvFATSeg:		resw 1
    83 FFFFFFFA ????                <2> lsvLoadSeg:		resw 1
    84 FFFFFFFC ????????            <2> lsvDataStart:		resd 1
    85                              <2> 	endstruc
    86                              <2> 
    87                              <2> 	struc LOADDATA, LOADSTACKVARS - 10h
    88 FFFFFFE0 ????                <2> ldMemoryTop:	resw 1
    89 FFFFFFE2 ????                <2> ldLoadTop:	resw 1
    90 FFFFFFE4 ????                <2> ldSectorSeg:	resw 1
    91 FFFFFFE6 ??                  <2> ldFATType:	resb 1
    92                              <2> ldFlags:
    93 FFFFFFE7 ??                  <2> ldHasLBA:	resb 1
    94 FFFFFFE8 ????                <2> ldClusterSize:	resw 1
    95 FFFFFFEA ????                <2> ldParaPerSector:resw 1
    96                              <2> ldDirCluster:			; dword
    97                              <2> ldLoadingSeg:		; word
    98                              <2> ldQueryPatchValue:	; word
    99                              <2> lsvCommandLine:		; word
   100                              <2> .start:		equ $ - lsvclBufferLength
   101 FFFFFFEC ????                <2> .signature:	resw 1
   102                              <2> ldLoadUntilSeg:		; word
   103                              <2> lsvExtra:		; word
   104 FFFFFFEE ??                  <2> .partition:	resb 1	; byte
   105 FFFFFFEF ??                  <2> .flags:		resb 1	; byte
   106                              <2> 	endstruc
   107                              <2> 
   108                              <2> ldhlfPreserveLoader	equ 4
   109                              <2> 
   110                              <2> lsvefNoDataStart	equ 1
   111                              <2> lsvefPartitionNumber	equ 2
   112                              <2> lsvefPreserveLoader	equ 4
   113                              <2> 
   114                              <2> %if lsvefPreserveLoader != ldhlfPreserveLoader
   115                              <2>  %error Unexpected flag values
   116                              <2> %endif
   117                              <2> 
   118                              <2> 	struc LOADCMDLINE, LOADDATA - lsvclBufferLength
   119                              <2> ldCommandLine:
   120 FFFFFEE0 <res 100h>          <2> .start:		resb lsvclBufferLength
   121                              <2> 	endstruc
   122                              <2> 
   123                              <2> ldfHasLBA:	equ 1
   124                              <2> ldfFATInvalid:	equ 2
   125                              <2> ldfFATBuffered:	equ 4
   126                              <2> ldfDataBuffered: equ 8
   127                              <2> 
   128                              <2> 	struc LOADDATA2, LOADDATA - 10h
   129 FFFFFFD0 ????????            <2> ldRootSector:		resd 1
   130 FFFFFFD4 ????                <2> ldEntriesPerSector:	resw 1
   131                              <2> ldDataSegment:		; word
   132 FFFFFFD6 ????                <2> ldLastAvailableSector:	resw 1
   133                              <2> ldDataSector:		; dword
   134 FFFFFFD8 ????                <2> ldParasLeft:		resw 1
   135 FFFFFFDA ????                <2> ldParasDone:		resw 1
   136                              <2> 	endstruc
   137                              <2> 
   138                              <2> 	struc LOADDATA3, LOADDATA2 - 10h
   139 FFFFFFC0 ????????            <2> ldMaxCluster:		resd 1
   140 FFFFFFC4 ????????            <2> ldFileSize:		resd 1
   141 FFFFFFC8 ????????            <2> ldCurrentCluster:	resd 1
   142 FFFFFFCC ????????            <2> ldCurrentSeek:		resd 1
   143                              <2> 	endstruc
   144                              <2> 
   145                              <2> 	struc LOADERIMAGEIDENT
   146 00000000 ????????            <2> liiSignature:		resb 4		; "NLDR"
   147 00000004 ????                <2> liiVersion:		resb 2		; "00"
   148 00000006 ????                <2> liiChecksum:		resw 1		; word sum of first 8 words = 0
   149 00000008 ????                <2> liiAmountParagraphs:	resw 1
   150 0000000A ????????????        <2> liiReserved:		resw 3
   151 00000010 ????                <2> liiEntryQuerySize:	resw 1		; 0 if not supported
   152                              <2> 		; INP:	cs => NLDR image ident
   153                              <2> 		;	ip = this word field content
   154                              <2> 		;	ax = 60h
   155                              <2> 		; OUT:	ax => behind memory requested (should be >= 60h)
   156                              <2> 		; CHG:	es, ds, di, si, bx, cx, dx
   157                              <2> 		; STT:	far called, UP, EI
   158 00000012 ????                <2> liiEntryRelocate:	resw 1		; 0 if not supported
   159                              <2> 		; INP:	cs => NLDR image ident
   160                              <2> 		;	ip = this word field content
   161                              <2> 		;	ax = 60h
   162                              <2> 		; OUT:	ax => relocated NLDR segment (usually 60h)
   163                              <2> 		; CHG:	es, ds, di, si, bx, cx, dx
   164                              <2> 		; STT:	far called, UP, EI
   165 00000014 ????                <2> liiEntryDebug:		resw 1		; 0 if not supported
   166                              <2> 		; INP:	es = ds = cs = ss => relocated NLDR
   167                              <2> 		;	ip = this word field content
   168                              <2> 		;	sp = next word field content
   169                              <2> 		; STT:	running as debuggee, UP, EI
   170 00000016 ????                <2> liiStackPointer:	resw 1
   171                              <2> 	endstruc
   172                              <2> 
   173                              <2> 	struc LBAPACKET
   174 00000000 ????                <2> lpSize:		resw 1
   175 00000002 ????                <2> lpCount:	resw 1
   176 00000004 ????????            <2> lpBuffer:	resd 1
   177 00000008 ????????????????    <2> lpSector:	resq 1
   178                              <2> 	endstruc
   179                              <2> 
   180                              <2> 	struc PARTINFO
   181 00000000 ??                  <2> piBoot:		resb 1
   182 00000001 ??????              <2> piStartCHS:	resb 3
   183 00000004 ??                  <2> piType:		resb 1
   184 00000005 ??????              <2> piEndCHS:	resb 3
   185 00000008 ????????            <2> piStart:	resd 1
   186 0000000C ????????            <2> piLength:	resd 1
   187                              <2> 	endstruc
   188                              <2> 
   189                              <2> ptEmpty:		equ 0
   190                              <2> ptFAT12:		equ 1
   191                              <2> ptFAT16_16BIT_CHS:	equ 4
   192                              <2> ptExtendedCHS:		equ 5
   193                              <2> ptFAT16_CHS:		equ 6
   194                              <2> ptFAT32_CHS:		equ 0Bh
   195                              <2> ptFAT32:		equ 0Ch
   196                              <2> ptFAT16:		equ 0Eh
   197                              <2> ptExtended:		equ 0Fh
   198                              <2> ptLinux:		equ 83h
   199                              <2> ptExtendedLinux:	equ 85h
   200                              <2> 
   201                              <2> 
   202                              <2> 		; Flags of load_unit_flags
   203                              <2> lufForceCHS:		equ 1
   204                              <2> lufForceLBA:		equ 2
   205                              <2> lufForceGeometry:	equ 4
   206                              <2> luf_mask_writable equ lufForceCHS | lufForceLBA | lufForceGeometry
   802                              <1> 
   803                              <1> LOAD_INPUT_FILE_SIZE equ fromparas(paras(-LOADDATA3 + bsBPB + ebpbNew + BPBN_size))
   804                              <1> 
   805                              <1> 	struc LOADSETTINGS
   806 00000000 ????                <1> lsKernelName:	resw 1	; -> kernel file default name
   807 00000002 ????                <1> lsAddName:	resw 1	; -> additional file default name, may be empty string
   808 00000004 ????                <1> lsMinPara:	resw 1	; how much to load at least, fail if file smaller
   809 00000006 ????                <1> lsMaxPara:	resw 1	; how much to load at most (will round up to sector size)
   810 00000008 ????                <1> lsOptions:	resw 1	; option flags
   811 0000000A ????                <1> lsSegment:	resw 1	; => where to load file
   812 0000000C ????????            <1> lsEntry:	resd 1	; relative segment for CS, value for IP
   813 00000010 ????????            <1> lsBPB:		resd 1	; segment for BPB (-1 auto-BPB), offset for BPB
   814 00000014 ????????            <1> lsCopyBPB:	resd 1	; if not all-zeroes, copy BPB to far pointer
   815 00000018 ????                <1> lsCheckOffset:	resw 1	; offset in file segment of word to check
   816 0000001A ????                <1> lsCheckValue:	resw 1	; value to check for word, 0 if unused
   817 0000001C ????????????????    <1> lsName:		resq 1	; ASCIZ load protocol name
   818                              <1> 	endstruc
   819                              <1> 
   820                              <1> 		numdef LUF_DEFAULT_DISKETTE, 0
   821                              <1> 		numdef LUF_DEFAULT_HARDDISK, 0
   822                              <1> %endif
   823                              <1> 
   824                              <1> 
   825                              <1> %include "mzheader.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug MZ .EXE header macros
     5                              <2> 
     6                              <2> Copyright (C) 1995-2003 Paul Vojta
     7                              <2> Copyright (C) 2008-2023 E. C. Masloch
     8                              <2> 
     9                              <2> Usage of the works is permitted provided that this
    10                              <2> instrument is retained with the works, so that any entity
    11                              <2> that uses the works is notified of this instrument.
    12                              <2> 
    13                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    14                              <2> 
    15                              <2> %endif
    16                              <2> 
    17                              <2> 
    18                              <2> 	struc EXEHEADER
    19 00000000 ????                <2> exact_struc_at 00h, exeSignature:	resw 1
    20 00000002 ????                <2> exact_struc_at 02h, exeExtraBytes:	resw 1	; bytes in last page
    21 00000004 ????                <2> exact_struc_at 04h, exePages:		resw 1	; number of 512-byte pages. includes the header!
    22 00000006 ????                <2> exact_struc_at 06h, exeRelocItems:	resw 1	; number of relocation items
    23 00000008 ????                <2> exact_struc_at 08h, exeHeaderSize:	resw 1	; header size in 16-byte paragraphs
    24 0000000A ????                <2> exact_struc_at 0Ah, exeMinAlloc:	resw 1	; minimum (bss) allocation in paragraphs
    25 0000000C ????                <2> exact_struc_at 0Ch, exeMaxAlloc:	resw 1	; maximum (bss) allocation in paragraphs
    26 0000000E ????                <2> exact_struc_at 0Eh, exeInitSS:		resw 1	; init ss (is relocated)
    27 00000010 ????                <2> exact_struc_at 10h, exeInitSP:		resw 1	; init sp
    28 00000012 ????                <2> exact_struc_at 12h, exeChecksum:	resw 1
    29                              <2> exact_struc_at 14h, exeInitCSIP:
    30 00000014 ????                <2> exact_struc_at 14h, exeInitIP:		resw 1	; init ip
    31 00000016 ????                <2> exact_struc_at 16h, exeInitCS:		resw 1	; init cs (is relocated)
    32 00000018 ????                <2> exact_struc_at 18h, exeRelocTable:	resw 1	; byte offset of relocation table
    33                              <2> 		; Each relocation item is a word offset and a word segment.
    34                              <2> 		;  The segment of the item itself is relocated as well.
    35 0000001A ????                <2> exact_struc_at 1Ah, exeOverlayNum:	resw 1
    36                              <2> exact_struc_at 1Ch
    37                              <2> 	endstruc
   826                              <1> 
   827                              <1> 
   828                              <1> 	struc INPUTFILEHANDLE
   829 00000000 ????                <1> ifhHandle:	resw 1
   830 00000002 ????                <1> ifhFlags:	resw 1
   831 00000004 ????????            <1> ifhParentSeek:	resd 1
   832                              <1> 	endstruc
   833                              <1> 
   834                              <1> ifhfIsDup:		equ  100h	; before closing, seek it back
   835                              <1> 	; same value as LBA flag for boot load input files
   836                              <1> ifhfTestReserved1:	equ 1000h
   837                              <1> ifhfTestReserved2:	equ 2000h
   838                              <1> ifhfQuietInput:		equ 4000h	; do not display prompt and input
   839                              <1> ifhfQuietOutput:	equ 8000h	; do not display normal output
   840                              <1> 	; these four are valid for both input file handles and
   841                              <1> 	;  boot load input files.
   842                              <1> 
   843                              <1> 
   844                              <1> 	struc AREASTRUC
   845 00000000 <res 18h>           <1> areastrucEntry:		resb 24
   846 00000018 ????????            <1> areastrucNext:		resd 1
   847 0000001C ????????            <1> areastrucPrev:		resd 1
   848 00000020 ????                <1> areastrucSubAmount:	resw 1
   849 00000022 ????                <1> areastrucSubOffset:	resw 1
   850 00000024 ????                <1> areastrucFunAmount:	resw 1
   851 00000026 ????                <1> areastrucFunOffset:	resw 1
   852                              <1> 	endstruc
   853                              <1> 
   854                              <1> 	struc AREASTRUCSUB
   855 00000000 ????????            <1> areastrucsubLinear:	resd 1
   856 00000004 ????????            <1> areastrucsubLinearEnd:	resd 1
   857 00000008 ????                <1> areastrucsubListOffset:	resw 1
   858 0000000A ????                <1> areastrucsubListAmount:	resw 1
   859                              <1> 	endstruc
   860                              <1> 
   861                              <1> 	struc AREASTRUCFUN
   862 00000000 ????????            <1> areastrucfunLinear:	resd 1
   863 00000004 ????????            <1> areastrucfunLinearEnd:	resd 1
   864 00000008 ????                <1> areastrucfunListOffset:	resw 1
   865 0000000A ????                <1> areastrucfunListAmount:	resw 1
   866                              <1> 	endstruc
   867                              <1> 
   868                              <1> 	struc AREA
   869 00000000 ????                <1> areastart:		resw 1
   870 00000002 ????                <1> areaend:		resw 1
   871 00000004 ????                <1> areamessage:		resw 1
   872 00000006 ????                <1> 			resw 1
   873                              <1> 	endstruc
   874                              <1> 
   875                              <1> 
   876                              <1> %include "isvariab.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug isvariable? function strutures and macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2025 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 
    17                              <2> 	struc ISVARIABLESTRUC
    18 00000000 ????                <2> ivName:		resw 1		; -> name (up to 13 bytes, but actually only 11)
    19                              <2> 				;  (search for ivfNameLengthLimit for limit)
    20                              <2> 				;  (length given by ivFlags & ivfNameLengthMask)
    21                              <2> 	; The ivName pointer is only used for more-byte names. It actually
    22                              <2> 	;  contains the trailer of the name, excluding the prefix formed by
    23                              <2> 	;  the first two bytes. This suffix can be the empty string if the
    24                              <2> 	;  variable in question has a two-byte name.
    25                              <2> 	; (For one-byte names this field is unused and contains zero.)
    26 00000002 ????                <2> ivFlags:	resw 1
    27 00000004 ????                <2> ivAddress:	resw 1		; default -> variable
    28                              <2> 	; The ivAddress field is used by default_variable_setup as the base
    29                              <2> 	;  address for the variable(s). It is also used by var_ext_setup as
    30                              <2> 	;  the ELD code section offset to transfer control to. Otherwise, it
    31                              <2> 	;  is usually set to zero and unused.
    32 00000006 ????                <2> ivSetup:	resw 1		; -> set up code (in expr code section)
    33                              <2> 	; INP:	ax = array index (0-based)
    34                              <2> 	;	di = 0
    35                              <2> 	;	cl = default size of variable (1..4)
    36                              <2> 	;	ch = length of variable name
    37                              <2> 	;	bx -> ISVARIABLESTRUC structure
    38                              <2> 	; CHG:	ax, bx, cx, dx, si, di
    39                              <2> 	; OUT:	NC if valid,
    40                              <2> 	;	 bx -> var, di = 0 or di -> mask
    41                              <2> 	;	 cl = size of variable (1..4)
    42                              <2> 	;	 ch = length of variable name
    43 00000008 ??                  <2> ivArrayLast:	resb 1		; 0 if no array, FFh = 256 entries
    44                              <2> 	; The ivArrayLast field is used by the dispatcher to determine
    45                              <2> 	;  whether to support array index expressions. It is checked
    46                              <2> 	;  before decrementing the index if ivfArrayOneBased is set.
    47 00000009 ??                  <2> ivArrayBetween: resb 1		; how many bytes to skip for each index
    48                              <2> 	; The ivArrayBetween field is only used by default_variable_setup.
    49                              <2> 	endstruc
    50                              <2> 
    51                              <2> ivfNameLengthMask:	equ 15	; gives name trailer length, 0 to 11
    52                              <2> ivfNameLengthLimit:	equ 13
    53                              <2> ivfVarLengthShift:	equ 4
    54                              <2> ivfVarLengthMask:	equ 3 << ivfVarLengthShift
    55                              <2> 				; gives default variable size minus 1
    56                              <2> ivfReadOnly:		equ 80h	; variable cannot be written at all
    57                              <2> ivfArrayOneBased:	equ 100h; first array entry is 1 not 0 (ivArrayLast > 0)
    58                              <2> ivfArrayOptional:	equ 200h; array index expression is optional
    59                              <2> ivfSeparatorSpecial:	equ 400h; used for RIxxP/L/S/O
    60                              <2> 
    61                              <2> %define ISVARIABLESTRINGS db "",db ""
    62                              <2> %define IVS_ONEBYTE_NAMES ""
    63                              <2> %define IVS_MOREBYTE_NAMEHEADERS ""
    64                              <2> %assign IVS_HAVE_ONEBYTE 0
    65                              <2> %assign IVS_SINGLE_ONEBYTE 1
    66                              <2> 
    67                              <2> 		; %1 = name string
    68                              <2> 		; %2 = default variable length, 1 to 4
    69                              <2> 		; %3 = flags to set (except name length and var length)
    70                              <2> 		; %4 = ivAddress value
    71                              <2> 		; %5 = ivArrayLast, defaults to 0 (no array)
    72                              <2> 		; %6 = ivArrayBetween, defaults to 0 (immediately consecutive)
    73                              <2> 		; %7 = ivSetup, defaults to default_variable_setup
    74                              <2> 	%macro isvariablestruc 4-7.nolist 0, 0, default_variable_setup
    75                              <2> %push
    76                              <2> %strlen %$namelength %1
    77                              <2> %if %$namelength > ivfNameLengthLimit
    78                              <2>  %error Expected at most 13-byte name (or adjust isvariable? code)
    79                              <2> %endif
    80                              <2> %if IVS_ONEBYTE && %$namelength != 1
    81                              <2>  %error Expected a one-byte name
    82                              <2> %elif ! IVS_ONEBYTE && %$namelength < 2
    83                              <2>  %error Expected at least a two-byte name
    84                              <2> %endif
    85                              <2> %if IVS_ONEBYTE
    86                              <2>  %define IVS_SINGLE_ONEBYTE_NAME %1
    87                              <2>  %if IVS_HAVE_ONEBYTE
    88                              <2>   %assign IVS_SINGLE_ONEBYTE 0
    89                              <2>  %endif
    90                              <2>  %assign IVS_HAVE_ONEBYTE 1
    91                              <2>  %assign %$namelength 0
    92                              <2>  %xdefine IVS_ONEBYTE_NAMES IVS_ONEBYTE_NAMES, %1
    93                              <2>  %%name equ 0
    94                              <2> %else
    95                              <2>  %assign %$namelength %$namelength - 2
    96                              <2>  %substr %$nametrailer %1 3,-1
    97                              <2>  %substr %$nameheader %1 1,2
    98                              <2>  %xdefine IVS_MOREBYTE_NAMEHEADERS IVS_MOREBYTE_NAMEHEADERS, %$nameheader
    99                              <2>  %xdefine ISVARIABLESTRINGS ISVARIABLESTRINGS, %%name:, {db %$nametrailer}
   100                              <2> %endif
   101                              <2> 
   102                              <2> %assign %$varlength %2 - 1	; 0 means one byte, 1 means two bytes,
   103                              <2> 				;  2 means three bytes, 3 means four bytes
   104                              <2> 	istruc ISVARIABLESTRUC
   105                              <2> at ivName,		dw %%name
   106                              <2>  IV_NAME_RELOCATION
   107                              <2> at ivFlags,		dw %$$namelength | (%$$varlength << ivfVarLengthShift) | %3
   108                              <2> at ivAddress,		dw %4
   109                              <2>  IV_ADDRESS_RELOCATION
   110                              <2> at ivSetup,		dw %7
   111                              <2>  IV_SETUP_RELOCATION
   112                              <2> at ivArrayLast,		db %5
   113                              <2> at ivArrayBetween,	db %6
   114                              <2> 	iend
   115                              <2> %pop
   116                              <2> %ifndef SECTION_OF_%7
   117                              <2>  %error Unknown target section for symbol %7
   118                              <2> %elifnidni %[SECTION_OF_%7], _EXPR_SECTION
   119                              <2>  %error Wrong section for symbol %7: section_of=SECTION_OF_%7, expr=_EXPR_SECTION
   120                              <2> %endif
   121                              <2> 	%endmacro
   122                              <2> 
   123                              <2> %define IV_NAME_RELOCATION
   124                              <2> %define IV_ADDRESS_RELOCATION
   125                              <2> %define IV_SETUP_RELOCATION
   126                              <2> 
   127                              <2> 	%macro isvariablestrings 2-*.nolist
   128                              <2> %rep %0
   129                              <2>  %1
   130                              <2>  %rotate 1
   131                              <2> %endrep
   132                              <2> 	%endmacro
   877                              <1> 
   878                              <1> 
   879                              <1> %include "386.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug 386 patch macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2026 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 	numdef LINK, 0
    17                              <2> 
    18                              <2> 	numdef WPT_LABELS, 0
    19                              <2> 		; This used to be required, because CODESECTIONFIXUP used
    20                              <2> 		;  ldebug_data_entry_size, which is not yet defined during
    21                              <2> 		;  assembling of (most) lDEBUG_CODE fragments.
    22                              <2> 		; However, assembling DebugX with this option selected
    23                              <2> 		;  took more than 2 minutes, so the non-label variant
    24                              <2> 		;  is clearly to be preferred when available.
    25                              <2> 		; Now that lDEBUG_CODE has vstart=0 we can use the
    26                              <2> 		;  CODESECTIONFIXUP again and thus disable this option.
    27                              <2> 
    28                              <2> %ifn _LINK
    29                              <2> %define PATCH_NO386_TABLE ""
    30                              <2> %define PATCH_386_TABLE ""
    31                              <2> %define PATCH_NO386_TABLE2 ""
    32                              <2> %define PATCH_386_TABLE2 ""
    33                              <2> %define PATCH_NO386_TABLEENTRY ""
    34                              <2> %define PATCH_386_TABLEENTRY ""
    35                              <2> %endif
    36                              <2> 
    37                              <2> %if _ONLY386
    38                              <2> 		; Default patch macros if only running on 386+.
    39                              <2> %define _386_o32 o32
    40                              <2> %define _386_a32 a32
    41                              <2> %define _386_jmps jmp short
    42                              <2> %define _386_jmpn jmp near
    43                              <2> %define _no386_jmps comment
    44                              <2> %define _no386_jmpn comment
    45                              <2> 	%macro _386 0-1+.nolist
    46                              <2> [cpu 386]			; change CPU type
    47                              <2> 		%1		; write instruction
    48                              <2> __CPU__				; reset CPU type
    49                              <2> 	%endmacro
    50                              <2> %define _no386 comment
    51                              <2> %elif _ONLYNON386
    52                              <2> 		; Default patch macros if only running on non-386.
    53                              <2> %define _386_o32
    54                              <2> %define _386_a32
    55                              <2> %define _386_jmps comment
    56                              <2> %define _386_jmpn comment
    57                              <2> %define _no386_jmps jmp short
    58                              <2> %define _no386_jmpn jmp near
    59                              <2> %define _386 comment
    60                              <2> %define _no386
    61                              <2> %else
    62                              <2> 
    63                              <2> ; These macros are to make DEBUG's 386 support as small as
    64                              <2> ; possible. To achieve this, two patch tables are created
    65                              <2> ; in the initialisation code. One of the tables is used if
    66                              <2> ; the CPU is a 386+, the other one if it isn't. The bytes
    67                              <2> ; pointed to in the used table are over-written with NOP
    68                              <2> ; instructions. (The patched bytes are usually address or
    69                              <2> ; operand size prefixes or jumps that branch to 386/non-386
    70                              <2> ; code.)
    71                              <2> 
    72                              <2> ; There are a few special patches that require the
    73                              <2> ; initialisation code to write specific bytes other than
    74                              <2> ; NOP instructions for lower resident memory usage.
    75                              <2> ; Two are in the run: code, three in pmentry.asm.
    76                              <2> 
    77                              <2> %if _LINK
    78                              <2> 
    79                              <2> %imacro wllist 1-3.nolist
    80                              <2> %ifnempty %3
    81                              <2>  %deftok %%filenametoken %3
    82                              <2> %else
    83                              <2>  %deftok %%filenametoken __FILE__
    84                              <2> %endif
    85                              <2>  global ..@wllist_%1?%[%%l]%[%%filenametoken]
    86                              <2> ..@wllist_%1?%[%%l]%[%%filenametoken]: %2
    87                              <2> %endmacro
    88                              <2> 
    89                              <2> 	%macro patch386 2-3.nolist 1
    90                              <2> %define %%repeat
    91                              <2> %if %3 != 1
    92                              <2>  %define %%repeat r%3_
    93                              <2> %endif
    94                              <2> %ifidn _CURRENT_SECTION, lDEBUG_CODE
    95                              <2>  wllist %[%%repeat]Lpatch_%{1}386_table, %2
    96                              <2> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
    97                              <2>  wllist %[%%repeat]Lpatch_%{1}386_table2, %2
    98                              <2> %elifidn _CURRENT_SECTION, lDEBUG_DATA_ENTRY
    99                              <2>  wllist %[%%repeat]Lpatch_%{1}386_tableentry, %2
   100                              <2> %else
   101                              <2>  %error Wrong section
   102                              <2> %endif
   103                              <2> 	%endmacro
   104                              <2> 
   105                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   106                              <2> 	%macro _386_o32 0-1+.nolist
   107                              <2> _386		o32
   108                              <2> 		%1
   109                              <2> 	%endmacro
   110                              <2> 
   111                              <2> 		; Address size 32-bit prefix if 386+ CPU
   112                              <2> 	%macro _386_a32 0-1+.nolist
   113                              <2> _386		a32
   114                              <2> 		%1
   115                              <2> 	%endmacro
   116                              <2> 
   117                              <2> 		; Short jump if 386+ CPU
   118                              <2> 	%macro _386_jmps 1.nolist
   119                              <2> _386		jmp short %1
   120                              <2> 	%endmacro
   121                              <2> 
   122                              <2> 		; Near jump if 386+ CPU
   123                              <2> 	%macro _386_jmpn 1.nolist
   124                              <2> _386		jmp near %1
   125                              <2> 	%endmacro
   126                              <2> 
   127                              <2> 		; Short jump if no 386+ CPU
   128                              <2> 	%macro _no386_jmps 1.nolist
   129                              <2> _no386		jmp short %1
   130                              <2> 	%endmacro
   131                              <2> 
   132                              <2> 		; Near jump if no 386+ CPU
   133                              <2> 	%macro _no386_jmpn 1.nolist
   134                              <2> _no386		jmp near %1
   135                              <2> 	%endmacro
   136                              <2> 
   137                              <2> 		; Instruction if 386+ CPU
   138                              <2> 	%macro _386 0-1+.nolist
   139                              <2> [cpu 386]			; change CPU type
   140                              <2> %%entry:
   141                              <2> 		%1		; write instruction
   142                              <2> __CPU__				; reset CPU type
   143                              <2> %assign %%length ($ - %%entry)
   144                              <2>  patch386 no, equ %%entry, %%length
   145                              <2> 	%endmacro
   146                              <2> 
   147                              <2> 		; Instruction if no 386+ CPU
   148                              <2> 	%macro _no386 0-1+.nolist
   149                              <2> %%entry:
   150                              <2> 		%1		; write instruction
   151                              <2> %assign %%length ($ - %%entry)
   152                              <2>  patch386 , equ %%entry, %%length
   153                              <2> 	%endmacro
   154                              <2> 
   155                              <2> %else
   156                              <2> 	%macro patch386 2+.nolist
   157                              <2> %ifidn _CURRENT_SECTION, lDEBUG_CODE
   158                              <2>  %define PATCH_%{1}386_TABLE %[PATCH_%{1}386_TABLE], %2
   159                              <2> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
   160                              <2>  %define PATCH_%{1}386_TABLE2 %[PATCH_%{1}386_TABLE2], %2
   161                              <2> %elifidn _CURRENT_SECTION, lDEBUG_DATA_ENTRY
   162                              <2>  %define PATCH_%{1}386_TABLEENTRY %[PATCH_%{1}386_TABLEENTRY], %2
   163                              <2> %else
   164                              <2>  %error Wrong section
   165                              <2> %endif
   166                              <2> 	%endmacro
   167                              <2> 
   168                              <2> %if _WPT_LABELS
   169                              <2> 	; These forms provide verbose info by defining a
   170                              <2> 	; meaningful label for each patch. That fills up
   171                              <2> 	; the map file and might take longer though.
   172                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   173                              <2> 	%macro _386_o32 0-1+.nolist
   174                              <2> %%386_o32:	o32
   175                              <2> patch386 NO, %%386_o32
   176                              <2> 		%1
   177                              <2> 	%endmacro
   178                              <2> 
   179                              <2> 		; Address size 32-bit prefix if 386+ CPU
   180                              <2> 	%macro _386_a32 0-1+.nolist
   181                              <2> %%386_a32:	a32
   182                              <2> patch386 NO, %%386_a32
   183                              <2> 		%1
   184                              <2> 	%endmacro
   185                              <2> 
   186                              <2> 		; Short jump if 386+ CPU
   187                              <2> 	%macro _386_jmps 1.nolist
   188                              <2> %%386_jmps:	jmp short %1
   189                              <2> patch386 NO, %%386_jmps,%%386_jmps+1
   190                              <2> 	%endmacro
   191                              <2> 
   192                              <2> 		; Near jump if 386+ CPU
   193                              <2> 	%macro _386_jmpn 1.nolist
   194                              <2> %%386_jmpn:	jmp near %1
   195                              <2> patch386 NO, %%386_jmpn,%%386_jmpn+1,%%386_jmpn+2
   196                              <2> 	%endmacro
   197                              <2> 
   198                              <2> 		; Short jump if no 386+ CPU
   199                              <2> 	%macro _no386_jmps 1.nolist
   200                              <2> %%no386_jmps:	jmp short %1
   201                              <2> patch386 , %%no386_jmps,%%no386_jmps+1
   202                              <2> 	%endmacro
   203                              <2> 
   204                              <2> 		; Near jump if no 386+ CPU
   205                              <2> 	%macro _no386_jmpn 1.nolist
   206                              <2> %%no386_jmpn:	jmp near %1
   207                              <2> patch386 , %%no386_jmpn,%%no386_jmpn+1,%%no386_jmpn+2
   208                              <2> 	%endmacro
   209                              <2> 
   210                              <2> 		; Instruction if 386+ CPU
   211                              <2> 	%macro _386 0-1+.nolist
   212                              <2> [cpu 386]			; change CPU type
   213                              <2> %%386_instr:	%1		; write instruction
   214                              <2> __CPU__				; reset CPU type
   215                              <2> 
   216                              <2> %assign %%INSTRCOUNT 0
   217                              <2> %rep $-%%386_instr		; count size of instruction
   218                              <2>  patch386 NO, %%386_instr+%[%%INSTRCOUNT]
   219                              <2> 				; write a patch for each byte
   220                              <2>  %assign %%INSTRCOUNT %%INSTRCOUNT+1
   221                              <2> %endrep
   222                              <2> %undef %%INSTRCOUNT
   223                              <2> 	%endmacro
   224                              <2> 
   225                              <2> 		; Instruction if no 386+ CPU
   226                              <2> 	%macro _no386 0-1+.nolist
   227                              <2> %%no386_instr:	%1		; write instruction
   228                              <2> 
   229                              <2> %assign %%INSTRCOUNT 0
   230                              <2> %rep $-%%no386_instr		; count size of instruction
   231                              <2>  patch386 , %%no386_instr+%[%%INSTRCOUNT]
   232                              <2> 				; write a patch for each byte
   233                              <2>  %assign %%INSTRCOUNT %%INSTRCOUNT+1
   234                              <2> %endrep
   235                              <2> %undef %%INSTRCOUNT
   236                              <2> 	%endmacro
   237                              <2> %else	; _WPT_LABELS
   238                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   239                              <2> 	%macro _386_o32 0-1+.nolist
   240                              <2> _386		o32
   241                              <2> 		%1
   242                              <2> 	%endmacro
   243                              <2> 
   244                              <2> 		; Address size 32-bit prefix if 386+ CPU
   245                              <2> 	%macro _386_a32 0-1+.nolist
   246                              <2> _386		a32
   247                              <2> 		%1
   248                              <2> 	%endmacro
   249                              <2> 
   250                              <2> 		; Short jump if 386+ CPU
   251                              <2> 	%macro _386_jmps 1.nolist
   252                              <2> _386		jmp short %1
   253                              <2> 	%endmacro
   254                              <2> 
   255                              <2> 		; Near jump if 386+ CPU
   256                              <2> 	%macro _386_jmpn 1.nolist
   257                              <2> _386		jmp near %1
   258                              <2> 	%endmacro
   259                              <2> 
   260                              <2> 		; Short jump if no 386+ CPU
   261                              <2> 	%macro _no386_jmps 1.nolist
   262                              <2> _no386		jmp short %1
   263                              <2> 	%endmacro
   264                              <2> 
   265                              <2> 		; Near jump if no 386+ CPU
   266                              <2> 	%macro _no386_jmpn 1.nolist
   267                              <2> _no386		jmp near %1
   268                              <2> 	%endmacro
   269                              <2> 
   270                              <2> 		; Instruction if 386+ CPU
   271                              <2> 	%macro _386 0-1+.nolist
   272                              <2> %push
   273                              <2> [cpu 386]			; change CPU type
   274                              <2> %assign %$entry $ + _CURRENT_SECTION %+ FIXUP
   275                              <2> 		%1		; write instruction
   276                              <2> __CPU__				; reset CPU type
   277                              <2> 
   278                              <2> %rep ($ + _CURRENT_SECTION %+ FIXUP) - %$entry
   279                              <2> 				; count size of instruction
   280                              <2>  patch386 NO, %[%$entry]	; write a patch for each byte
   281                              <2>  %assign %$entry %$entry+1
   282                              <2> %endrep
   283                              <2> %pop
   284                              <2> 	%endmacro
   285                              <2> 
   286                              <2> 		; Instruction if no 386+ CPU
   287                              <2> 	%macro _no386 0-1+.nolist
   288                              <2> %push
   289                              <2> %assign %$entry $ + _CURRENT_SECTION %+ FIXUP
   290                              <2> 		%1		; write instruction
   291                              <2> 
   292                              <2> %rep ($ + _CURRENT_SECTION %+ FIXUP) - %$entry
   293                              <2> 				; count size of instruction
   294                              <2>  patch386 , %[%$entry]		; write a patch for each byte
   295                              <2>  %assign %$entry %$entry+1
   296                              <2> %endrep
   297                              <2> %pop
   298                              <2> 	%endmacro
   299                              <2> %endif	; _WPT_LABELS
   300                              <2> %endif	; _LINK
   301                              <2> 
   302                              <2> %endif
   303                              <2> 
   304                              <2> 		; Patch macros but for cases where the 386+
   305                              <2> 		; instructions should only be generated for
   306                              <2> 		; DEBUGX (i.e. for 32-bit DPMI addressing code).
   307                              <2> %if _PM
   308                              <2> %define _386_PM_o32	_386_o32
   309                              <2> %define _386_PM_a32	_386_a32
   310                              <2> %define _386_PM_jmps	_386_jmps
   311                              <2> %define _386_PM_jmpn	_386_jmpn
   312                              <2> %define _386_PM		_386
   313                              <2> %else
   314                              <2> %define _386_PM_o32
   315                              <2> %define _386_PM_a32
   316                              <2> %define _386_PM_jmps	comment
   317                              <2> %define _386_PM_jmpn	comment
   318                              <2> %define _386_PM		comment
   319                              <2> %endif
   320                              <2> 
   321                              <2> 
   322                              <2> %ifn _LINK
   323                              <2> %macro __writepatchtable2 0-*.nolist
   324                              <2> %if %0 & 1
   325                              <2>  %fatal Expected even number of arguments
   326                              <2> %endif
   327                              <2> %rep %0 >> 1
   328                              <2> 	%1 %2
   329                              <2> %rotate 2
   330                              <2> %endrep
   331                              <2> %endmacro
   332                              <2> 
   333                              <2> %macro __patchtable2_entry 0.nolist
   334                              <2>   ; only if this isn't the first (pseudo-)entry
   335                              <2>   %if %$lastcount != 0
   336                              <2>     %assign %$runscount %[%$runscount]+1
   337                              <2>    ; if the offset from %$previous is less than 255
   338                              <2>    %if (%$last-%$previous) < 255
   339                              <2>     %assign %$$method2tablesize %$$method2tablesize+1
   340                              <2>     ; then write a single byte (number of bytes not to patch between)
   341                              <2>     %xdefine %$$method2list %$$method2list,db,%$last-%$previous
   342                              <2>    %else
   343                              <2>     ; otherwise write a 255 ("reposition") and write the 16-bit address afterwards
   344                              <2>     %assign %$$method2tablesize %$$method2tablesize+3
   345                              <2>     %xdefine %$$method2list %$$method2list,db,255,dw,%$last
   346                              <2>     %assign %$reposcount %[%$reposcount]+1
   347                              <2>    %endif
   348                              <2>    %if %$lastcount == 1
   349                              <2>     %assign %$onecount %[%$onecount]+1
   350                              <2>    %endif
   351                              <2>    %assign %$$method2tablesize %$$method2tablesize+1
   352                              <2>    ; and write the number of bytes to be patched
   353                              <2>    %xdefine %$$method2list %$$method2list,db,%$lastcount
   354                              <2>    ; define %$previous for the next entry: it points to the next non-patched byte
   355                              <2>    %define %$previous (%[%$last]+%[%$lastcount])
   356                              <2>   %endif
   357                              <2> %endmacro
   358                              <2> 
   359                              <2> %macro writepatchtable 2-*.nolist
   360                              <2> 
   361                              <2> 	numdef %{1}_FORCE_METHOD, 0
   362                              <2> %push
   363                              <2> 		; Determine length of simple table:
   364                              <2> %assign %$method1tablesize (%0 - 2)*2
   365                              <2> 
   366                              <2> %if !_%{1}_FORCE_METHOD || _%{1}_FORCE_METHOD == 2
   367                              <2> 		; Determine length of complicated table:
   368                              <2> %assign %$method2tablesize 0
   369                              <2> %define %$method2list db,""
   370                              <2> %push
   371                              <2> %if _WPT_LABELS
   372                              <2>  %define %$previous code_start	; if list contains labels
   373                              <2> %else
   374                              <2>  %define %$previous 0
   375                              <2> %endif
   376                              <2> %define %$last %[%$previous]
   377                              <2> %assign %$lastcount 0
   378                              <2> %assign %$onecount 0
   379                              <2> %assign %$reposcount 0
   380                              <2> %assign %$bytescount %0 - 2
   381                              <2> %assign %$runscount 0
   382                              <2> %rotate 1
   383                              <2> %rep %0 - 2
   384                              <2>  %rotate 1
   385                              <2>  ;if  it continues the previous patch   and not too long   and this isn't the first
   386                              <2>  %if ((%$last+%$lastcount) == %1) && (%$lastcount < 255) && (%$lastcount != 0)
   387                              <2>   ; then do not write an entry, just increase the patch's size
   388                              <2>   %assign %$lastcount %[%$lastcount]+1
   389                              <2>  %else
   390                              <2>   ; otherwise write the last entry
   391                              <2>   __patchtable2_entry
   392                              <2>   ; define new %$last to this parameter, %$lastcount to one
   393                              <2>   %define %$last %1
   394                              <2>   %assign %$lastcount 1
   395                              <2>  %endif
   396                              <2> %endrep
   397                              <2> __patchtable2_entry
   398                              <2> 
   399                              <2> ; at the end, there's a patch with offset 0, size 0
   400                              <2> %assign %$$method2tablesize %$$method2tablesize+2
   401                              <2> %xdefine %$$method2list %$$method2list,db,0,db,0
   402                              <2> 
   403                              <2> %assign %$$onecount %$onecount
   404                              <2> %assign %$$reposcount %$reposcount
   405                              <2> %assign %$$bytescount %$bytescount
   406                              <2> %assign %$$runscount %$runscount
   407                              <2> %pop
   408                              <2> %rotate 1
   409                              <2> %endif
   410                              <2> 
   411                              <2> %if _%{1}_FORCE_METHOD == 2
   412                              <2>  %define __%{1}_method 2
   413                              <2> %elif _%{1}_FORCE_METHOD == 1
   414                              <2>  %define __%{1}_method 1
   415                              <2> %else
   416                              <2>  %if _%{1}_FORCE_METHOD
   417                              <2>   %fatal Invalid forced method selected: _%{1}_FORCE_METHOD
   418                              <2>  %endif
   419                              <2>  %if %$method1tablesize > (%$method2tablesize+20)
   420                              <2>   %define __%{1}_method 2
   421                              <2>  %else
   422                              <2>   %define __%{1}_method 1
   423                              <2>  %endif
   424                              <2> %endif
   425                              <2> 
   426                              <2> 
   427                              <2> %1:
   428                              <2> %if __%{1}_method == 2
   429                              <2> 	__writepatchtable2 %$method2list
   430                              <2> 	endarea %1
   431                              <2> %assign %$size %1_size
   432                              <2> %warning %1: %$size bytes (Method 2)
   433                              <2> %warning 1B=%$onecount repo=%$reposcount run=%$runscount byte=%$bytescount
   434                              <2> %else
   435                              <2> %rotate 1
   436                              <2> %rep %0 - 2
   437                              <2> %rotate 1
   438                              <2> 	dw %1
   439                              <2> %endrep
   440                              <2> %rotate 1
   441                              <2> 	endarea %1
   442                              <2> %assign %$size %1_size
   443                              <2> %warning %1: %$size bytes (Method 1)
   444                              <2> %1.amount equ %1_size_w
   445                              <2> %endif
   446                              <2> %pop
   447                              <2> %endmacro
   448                              <2> %endif
   880                              <1> 
   881                              <1> 
   882                              <1> %if _VDD
   883                              <1> ; standard BOPs for communication with DEBXXVDD on NT platforms
   884                              <1> %macro RegisterModule 0.nolist
   885                              <1> 	db 0C4h, 0C4h, 58h, 0
   886                              <1> 	nop
   887                              <1> %endmacro
   888                              <1> %macro UnRegisterModule 0.nolist
   889                              <1> 	db 0C4h, 0C4h, 58h, 1
   890                              <1> 	nop
   891                              <1> %endmacro
   892                              <1> %macro DispatchCall 0.nolist
   893                              <1> 	db 0C4h, 0C4h, 58h, 2
   894                              <1> 	nop
   895                              <1> %endmacro
   896                              <1> %endif
   897                              <1> 
   898                              <1> %assign CODE_INSURE_COUNT 0
   899                              <1> 
   900                              <1> 		; The entry_to_code_seg/_sel dispatcher in lDEBUG_DATA_ENTRY
   901                              <1> 		;  detects mistaken debugger breakpoints in its
   902                              <1> 		;  in-code-parameter by checking for a low-byte
   903                              <1> 		;  value equal to 0CCh (one-byte int3 opcode).
   904                              <1> 		; Therefore, we insure that all destinations jumped to
   905                              <1> 		;  via that dispatcher do not happen to be located
   906                              <1> 		;  on an offset that gives 0CCh in the low byte.
   907                              <1> 	%imacro code_insure_low_byte_not_0CCh 0.nolist
   908                              <1> %ifn _LINK
   909                              <1>  %if (($ - _CURRENT_SECTION %+ _start) & 0FFh) == 0CCh
   910                              <1> 	nop
   911                              <1>   %assign CODE_INSURE_COUNT 1 + CODE_INSURE_COUNT
   912                              <1>  %endif
   913                              <1> %endif
   914                              <1> 	%endmacro
   915                              <1> 
   916                              <1> 
   917                              <1> 		; dual code segments
   918                              <1> %if _DUALCODE && _PM
   919                              <1> 
   920                              <1> %if _DEBUG
   921                              <1> %idefine dualfunction comment
   922                              <1> %else
   923                              <1> %idefine dualfunction code_insure_low_byte_not_0CCh
   924                              <1> %endif
   925                              <1> 
   926                              <1> %idefine dualreturn call _CURRENT_SECTION %+ _dualret_helper
   927                              <1> %idefine dualdistance far
   928                              <1> 	%imacro dualcall 1.nolist
   929                              <1> %ifndef SECTION_OF_%1
   930                              <1>  %error Unknown target section for symbol %1
   931                              <1> %endif
   932                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _dualcall_helper
   933                              <1>  %if _DEBUG
   934                              <1> 	jmp strict short %%skipdata
   935                              <1>  %endif
   936                              <1> 	dw %1
   937                              <1> %%skipdata:
   938                              <1> 	%endmacro
   939                              <1> 	%imacro nearcall 1.nolist
   940                              <1> %ifndef SECTION_OF_%1
   941                              <1>  %error Unknown target section for symbol %1
   942                              <1> %endif
   943                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
   944                              <1> 	call %1
   945                              <1> %else
   946                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _nearcall_helper
   947                              <1>  %if _DEBUG
   948                              <1> 	jmp strict short %%skipdata
   949                              <1>  %endif
   950                              <1> 	dw %1
   951                              <1> %%skipdata:
   952                              <1> %endif
   953                              <1> 	%endmacro
   954                              <1> 
   955                              <1> %elif _DUALCODE && ! _PM
   956                              <1> 
   957                              <1> %idefine dualfunction comment
   958                              <1> %idefine dualreturn
   959                              <1> %idefine dualdistance far
   960                              <1> 
   961                              <1> %ifn _LINK
   962                              <1> %define PATCH_RELOCATE_FROM_lDEBUG_CODE ""
   963                              <1> %define PATCH_RELOCATE_FROM_lDEBUG_CODE2 ""
   964                              <1> 	%imacro dualcall 1.nolist
   965                              <1> %ifndef SECTION_OF_%1
   966                              <1>  %error Unknown target section for symbol %1
   967                              <1> %endif
   968                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
   969                              <1> 	push cs
   970                              <1> 	call %1
   971                              <1> %else
   972                              <1> 	call relocatedzero:%1
   973                              <1> %push
   974                              <1> %assign %$entry ($ + _CURRENT_SECTION %+ FIXUP) - 2
   975                              <1> 	relocatelist _CURRENT_SECTION, %$entry
   976                              <1> %pop
   977                              <1> %endif
   978                              <1> 	%endmacro
   979                              <1> 	%imacro relocatelist 2.nolist
   980                              <1>  %define PATCH_RELOCATE_FROM_%1 %[PATCH_RELOCATE_FROM_%1],%2
   981                              <1> 	%endmacro
   982                              <1> %else		; _LINK
   983                              <1> 	%idefine dualcall dualcall_with_filename __FILE__,
   984                              <1> 	%imacro dualcall_with_filename 2.nolist
   985                              <1> %ifndef SECTION_OF_%2
   986                              <1>  %error Unknown target section for symbol %2
   987                              <1> %endif
   988                              <1> %ifidni %[SECTION_OF_%2], _CURRENT_SECTION
   989                              <1> 	push cs
   990                              <1> 	call %2
   991                              <1> %else
   992                              <1> 	call relocatedzero:%2
   993                              <1> %ifidn _CURRENT_SECTION, lDEBUG_CODE
   994                              <1>  wllist Lrelocate_from_code, equ $ - 2, %1
   995                              <1> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
   996                              <1>  wllist Lrelocate_from_code2, equ $ - 2, %1
   997                              <1> %else
   998                              <1>  %error Wrong section
   999                              <1> %endif
  1000                              <1> %endif
  1001                              <1> 	%endmacro
  1002                              <1> %endif		; _LINK
  1003                              <1>  %if _DUALCODENEARDUAL
  1004                              <1> 
  1005                              <1> %if _LINK
  1006                              <1> 	%idefine nearcall nearcall_with_filename __FILE__,
  1007                              <1> 	%imacro nearcall_with_filename 2
  1008                              <1> %ifndef SECTION_OF_%2
  1009                              <1>  %error Unknown target section for symbol %2
  1010                              <1> %endif
  1011                              <1> %ifidni %[SECTION_OF_%2], _CURRENT_SECTION
  1012                              <1> 	call %2
  1013                              <1> %else
  1014                              <1>  %push
  1015                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1016                              <1>  %xdefine %$targetsection SECTION_OF_%2
  1017                              <1>  %deftok %%filenametoken SOURCEFILENAME
  1018                              <1>   %ifndef NEARCALL_THUNK_TO_%2%[%%filenametoken]
  1019                              <1> 	hiddenusesection %$targetsection
  1020                              <1> %define NEARCALL_THUNK_TO_%2%[%%filenametoken] %%nearcall_thunk_to_%2%[%%filenametoken]
  1021                              <1> section_of %%nearcall_thunk_to_%2%[%%filenametoken]
  1022                              <1> dualfunction
  1023                              <1> %%nearcall_thunk_to_%2%[%%filenametoken]:
  1024                              <1> 	call %2
  1025                              <1> 	dualreturn
  1026                              <1> 	retf
  1027                              <1> 
  1028                              <1> 	hiddenusesection %$originalsection
  1029                              <1>   %endif
  1030                              <1>  %pop
  1031                              <1> 	dualcall_with_filename %1, NEARCALL_THUNK_TO_%2%[%%filenametoken]
  1032                              <1> %endif
  1033                              <1> 	%endmacro
  1034                              <1> %elif _LINK_COMPAT	; _LINK
  1035                              <1> 	%imacro nearcall 1
  1036                              <1> %ifndef SECTION_OF_%1
  1037                              <1>  %error Unknown target section for symbol %1
  1038                              <1> %endif
  1039                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1040                              <1> 	call %1
  1041                              <1> %else
  1042                              <1>  %push
  1043                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1044                              <1>  %xdefine %$targetsection SECTION_OF_%1
  1045                              <1>  %deftok %%filenametoken SOURCEFILENAME
  1046                              <1>   %ifndef NEARCALL_THUNK_TO_%1%[%%filenametoken]
  1047                              <1> 	hiddenusesection %$targetsection
  1048                              <1> %define NEARCALL_THUNK_TO_%1%[%%filenametoken] %%nearcall_thunk_to_%1%[%%filenametoken]
  1049                              <1> section_of %%nearcall_thunk_to_%1%[%%filenametoken]
  1050                              <1> dualfunction
  1051                              <1> %%nearcall_thunk_to_%1%[%%filenametoken]:
  1052                              <1> 	call %1
  1053                              <1> 	dualreturn
  1054                              <1> 	retf
  1055                              <1> 
  1056                              <1> 	hiddenusesection %$originalsection
  1057                              <1>   %endif
  1058                              <1>  %pop
  1059                              <1> 	dualcall NEARCALL_THUNK_TO_%1%[%%filenametoken]
  1060                              <1> %endif
  1061                              <1> 	%endmacro
  1062                              <1> %else		; _LINK, _LINK_COMPAT
  1063                              <1> 	%imacro nearcall 1
  1064                              <1> %ifndef SECTION_OF_%1
  1065                              <1>  %error Unknown target section for symbol %1
  1066                              <1> %endif
  1067                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1068                              <1> 	call %1
  1069                              <1> %else
  1070                              <1>  %push
  1071                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1072                              <1>  %xdefine %$targetsection SECTION_OF_%1
  1073                              <1>   %ifndef NEARCALL_THUNK_TO_%1
  1074                              <1> 	hiddenusesection %$targetsection
  1075                              <1> %define NEARCALL_THUNK_TO_%1 %%nearcall_thunk_to_%1
  1076                              <1> section_of %%nearcall_thunk_to_%1
  1077                              <1> dualfunction
  1078                              <1> %%nearcall_thunk_to_%1:
  1079                              <1> 	call %1
  1080                              <1> 	dualreturn
  1081                              <1> 	retf
  1082                              <1> 
  1083                              <1> 	hiddenusesection %$originalsection
  1084                              <1>   %endif
  1085                              <1>  %pop
  1086                              <1> 	dualcall NEARCALL_THUNK_TO_%1
  1087                              <1> %endif
  1088                              <1> 	%endmacro
  1089                              <1> %endif		; _LINK, _LINK_COMPAT
  1090                              <1>  %else
  1091                              <1> 	%imacro nearcall 1.nolist
  1092                              <1> %ifndef SECTION_OF_%1
  1093                              <1>  %error Unknown target section for symbol %1
  1094                              <1> %endif
  1095                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1096                              <1> 	call %1
  1097                              <1> %else
  1098                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _nearcall_helper
  1099                              <1>  %if _DEBUG
  1100                              <1> 	jmp strict short %%skipdata
  1101                              <1>  %endif
  1102                              <1> 	dw %1
  1103                              <1> %%skipdata:
  1104                              <1> %endif
  1105                              <1> 	%endmacro
  1106                              <1>  %endif
  1107                              <1> %elif ! _DUALCODE
  1108                              <1> 
  1109                              <1> %idefine dualfunction comment
  1110                              <1> %idefine dualreturn
  1111                              <1> %idefine dualdistance near
  1112                              <1> 	%imacro dualcall 1.nolist
  1113                              <1> 	call %1
  1114                              <1> 	%endmacro
  1115                              <1> 	%imacro nearcall 1.nolist
  1116                              <1> 	call %1
  1117                              <1> 	%endmacro
  1118                              <1> %assign _SYMBOLICDUALCODE 0
  1119                              <1> %assign _SYMBOLASMDUALCODE 0
  1120                              <1> 
  1121                              <1> %else
  1122                              <1>  %error Unexpected defines
  1123                              <1> %endif
  1124                              <1> 
  1125                              <1> %ifn _SYMBOLICDUALCODE
  1126                              <1>  %assign _SYMBOLASMDUALCODE 0
  1127                              <1> %endif
  1128                              <1> 
  1129                              <1>  %if _SYMBOLIC && _DUALCODE && _SYMBOLASMDUALCODE
  1130                              <1> %idefine dual2function	dualfunction
  1131                              <1> %idefine dual2return	dualreturn
  1132                              <1> %idefine dual2distance	dualdistance
  1133                              <1> %idefine dual2call	dualcall
  1134                              <1>  %else
  1135                              <1> %idefine dual2function comment
  1136                              <1> %idefine dual2return
  1137                              <1> %idefine dual2distance near
  1138                              <1> 	%imacro dual2call 1.nolist
  1139                              <1> 	call %1
  1140                              <1> 	%endmacro
  1141                              <1>  %endif
  1142                              <1> 
  1143                              <1> 
  1144                              <1> 	numdef CHECKSECTION, 0
  1145                              <1> 	numdef CHECKCALLSECTION, _CHECKSECTION
  1146                              <1> 	numdef CHECKJMPSECTION, _CHECKSECTION
  1147                              <1> 	numdef CHECKJCCSECTION, _CHECKSECTION
  1148                              <1> 
  1149                              <1> %if _CHECKCALLSECTION
  1150                              <1> 	%imacro call 1.nolist
  1151                              <1> 	%? %1
  1152                              <1> checksection %1, %?, call
  1153                              <1> 	%endmacro
  1154                              <1> %endif
  1155                              <1> %if _CHECKJMPSECTION
  1156                              <1> 	%imacro jmp 1.nolist
  1157                              <1> 	%? %1
  1158                              <1> checksection %1, %?, jmp
  1159                              <1> 	%endmacro
  1160                              <1> %endif
  1161                              <1> %if _CHECKJCCSECTION
  1162                              <1> 	%imacro je 1.nolist
  1163                              <1> 	%? %1
  1164                              <1> checksection %1, %?, jcc
  1165                              <1> 	%endmacro
  1166                              <1> 	%imacro jne 1.nolist
  1167                              <1> 	%? %1
  1168                              <1> checksection %1, %?, jcc
  1169                              <1> 	%endmacro
  1170                              <1> 	%imacro jz 1.nolist
  1171                              <1> 	%? %1
  1172                              <1> checksection %1, %?, jcc
  1173                              <1> 	%endmacro
  1174                              <1> 	%imacro jnz 1.nolist
  1175                              <1> 	%? %1
  1176                              <1> checksection %1, %?, jcc
  1177                              <1> 	%endmacro
  1178                              <1> 
  1179                              <1> 	%imacro jb 1.nolist
  1180                              <1> 	%? %1
  1181                              <1> checksection %1, %?, jcc
  1182                              <1> 	%endmacro
  1183                              <1> 	%imacro jnb 1.nolist
  1184                              <1> 	%? %1
  1185                              <1> checksection %1, %?, jcc
  1186                              <1> 	%endmacro
  1187                              <1> 	%imacro jbe 1.nolist
  1188                              <1> 	%? %1
  1189                              <1> checksection %1, %?, jcc
  1190                              <1> 	%endmacro
  1191                              <1> 	%imacro jnbe 1.nolist
  1192                              <1> 	%? %1
  1193                              <1> checksection %1, %?, jcc
  1194                              <1> 	%endmacro
  1195                              <1> 	%imacro jc 1.nolist
  1196                              <1> 	%? %1
  1197                              <1> checksection %1, %?, jcc
  1198                              <1> 	%endmacro
  1199                              <1> 	%imacro jnc 1.nolist
  1200                              <1> 	%? %1
  1201                              <1> checksection %1, %?, jcc
  1202                              <1> 	%endmacro
  1203                              <1> 	%imacro ja 1.nolist
  1204                              <1> 	%? %1
  1205                              <1> checksection %1, %?, jcc
  1206                              <1> 	%endmacro
  1207                              <1> 	%imacro jna 1.nolist
  1208                              <1> 	%? %1
  1209                              <1> checksection %1, %?, jcc
  1210                              <1> 	%endmacro
  1211                              <1> 	%imacro jae 1.nolist
  1212                              <1> 	%? %1
  1213                              <1> checksection %1, %?, jcc
  1214                              <1> 	%endmacro
  1215                              <1> 	%imacro jnae 1.nolist
  1216                              <1> 	%? %1
  1217                              <1> checksection %1, %?, jcc
  1218                              <1> 	%endmacro
  1219                              <1> 
  1220                              <1> 	%imacro jl 1.nolist
  1221                              <1> 	%? %1
  1222                              <1> checksection %1, %?, jcc
  1223                              <1> 	%endmacro
  1224                              <1> 	%imacro jnl 1.nolist
  1225                              <1> 	%? %1
  1226                              <1> checksection %1, %?, jcc
  1227                              <1> 	%endmacro
  1228                              <1> 	%imacro jle 1.nolist
  1229                              <1> 	%? %1
  1230                              <1> checksection %1, %?, jcc
  1231                              <1> 	%endmacro
  1232                              <1> 	%imacro jnle 1.nolist
  1233                              <1> 	%? %1
  1234                              <1> checksection %1, %?, jcc
  1235                              <1> 	%endmacro
  1236                              <1> 	%imacro jg 1.nolist
  1237                              <1> 	%? %1
  1238                              <1> checksection %1, %?, jcc
  1239                              <1> 	%endmacro
  1240                              <1> 	%imacro jng 1.nolist
  1241                              <1> 	%? %1
  1242                              <1> checksection %1, %?, jcc
  1243                              <1> 	%endmacro
  1244                              <1> 	%imacro jge 1.nolist
  1245                              <1> 	%? %1
  1246                              <1> checksection %1, %?, jcc
  1247                              <1> 	%endmacro
  1248                              <1> 	%imacro jnge 1.nolist
  1249                              <1> 	%? %1
  1250                              <1> checksection %1, %?, jcc
  1251                              <1> 	%endmacro
  1252                              <1> 
  1253                              <1> 	%imacro jo 1.nolist
  1254                              <1> 	%? %1
  1255                              <1> checksection %1, %?, jcc
  1256                              <1> 	%endmacro
  1257                              <1> 	%imacro jno 1.nolist
  1258                              <1> 	%? %1
  1259                              <1> checksection %1, %?, jcc
  1260                              <1> 	%endmacro
  1261                              <1> 	%imacro jp 1.nolist
  1262                              <1> 	%? %1
  1263                              <1> checksection %1, %?, jcc
  1264                              <1> 	%endmacro
  1265                              <1> 	%imacro jnp 1.nolist
  1266                              <1> 	%? %1
  1267                              <1> checksection %1, %?, jcc
  1268                              <1> 	%endmacro
  1269                              <1> 	%imacro jpe 1.nolist
  1270                              <1> 	%? %1
  1271                              <1> checksection %1, %?, jcc
  1272                              <1> 	%endmacro
  1273                              <1> 	%imacro jnpe 1.nolist
  1274                              <1> 	%? %1
  1275                              <1> checksection %1, %?, jcc
  1276                              <1> 	%endmacro
  1277                              <1> 	%imacro jpo 1.nolist
  1278                              <1> 	%? %1
  1279                              <1> checksection %1, %?, jcc
  1280                              <1> 	%endmacro
  1281                              <1> 	%imacro jnpo 1.nolist
  1282                              <1> 	%? %1
  1283                              <1> checksection %1, %?, jcc
  1284                              <1> 	%endmacro
  1285                              <1> 	%imacro js 1.nolist
  1286                              <1> 	%? %1
  1287                              <1> checksection %1, %?, jcc
  1288                              <1> 	%endmacro
  1289                              <1> 	%imacro jns 1.nolist
  1290                              <1> 	%? %1
  1291                              <1> checksection %1, %?, jcc
  1292                              <1> 	%endmacro
  1293                              <1> 
  1294                              <1> 	%imacro jcxz 1.nolist
  1295                              <1> 	%? %1
  1296                              <1> checksection %1, %?, jcc
  1297                              <1> 	%endmacro
  1298                              <1> 	%imacro jecxz 1.nolist
  1299                              <1> 	%? %1
  1300                              <1> checksection %1, %?, jcc
  1301                              <1> 	%endmacro
  1302                              <1> 	%imacro loop 1.nolist
  1303                              <1> 	%? %1
  1304                              <1> checksection %1, %?, jcc
  1305                              <1> 	%endmacro
  1306                              <1> 	%imacro loopz 1.nolist
  1307                              <1> 	%? %1
  1308                              <1> checksection %1, %?, jcc
  1309                              <1> 	%endmacro
  1310                              <1> 	%imacro loopnz 1.nolist
  1311                              <1> 	%? %1
  1312                              <1> checksection %1, %?, jcc
  1313                              <1> 	%endmacro
  1314                              <1> 	%imacro loope 1.nolist
  1315                              <1> 	%? %1
  1316                              <1> checksection %1, %?, jcc
  1317                              <1> 	%endmacro
  1318                              <1> 	%imacro loopne 1.nolist
  1319                              <1> 	%? %1
  1320                              <1> checksection %1, %?, jcc
  1321                              <1> 	%endmacro
  1322                              <1> %endif
  1323                              <1> 
  1324                              <1> 	%imacro checksection 3.nolist
  1325                              <1> %push
  1326                              <1>  %defstr %$string %1
  1327                              <1>  %substr %$shortword %$string 1, 5
  1328                              <1>  %substr %$shortsep %$string 6, 1
  1329                              <1>  %substr %$nearword %$string 1, 4
  1330                              <1>  %substr %$nearsep %$string 5, 1
  1331                              <1>  %substr %$farword %$string 1, 3
  1332                              <1>  %substr %$farsep %$string 4, 1
  1333                              <1>  %assign %$isshort 0
  1334                              <1>  %ifidni %$shortword, "short"
  1335                              <1>   %if %$shortsep == 32 || %$shortsep == 9
  1336                              <1>    %assign %$isshort 1
  1337                              <1>    %substr %$string %$string 7, -1
  1338                              <1>   %elif %$shortsep == '['
  1339                              <1>    %assign %$isshort 1
  1340                              <1>    %substr %$string %$string 6, -1
  1341                              <1>   %endif
  1342                              <1>  %endif
  1343                              <1>  %assign %$isnear 0
  1344                              <1>  %ifidni %$nearword, "near"
  1345                              <1>   %if %$nearsep == 32 || %$nearsep == 9
  1346                              <1>    %assign %$isnear 1
  1347                              <1>    %substr %$string %$string 6, -1
  1348                              <1>   %elif %$nearsep == '['
  1349                              <1>    %assign %$isnear 1
  1350                              <1>    %substr %$string %$string 5, -1
  1351                              <1>   %endif
  1352                              <1>  %endif
  1353                              <1>  %assign %$isfar 0
  1354                              <1>  %ifidni %$farword, "far"
  1355                              <1>   %if %$farsep == 32 || %$farsep == 9
  1356                              <1>    %assign %$isfar 1
  1357                              <1>    %substr %$string %$string 5, -1
  1358                              <1>   %elif %$farsep == '['
  1359                              <1>    %assign %$isfar 1
  1360                              <1>    %substr %$string %$string 4, -1
  1361                              <1>   %endif
  1362                              <1>  %endif
  1363                              <1> 
  1364                              <1>  %deftok %$token %$string
  1365                              <1> 
  1366                              <1>  %assign %$size 2
  1367                              <1>  %assign %$isreg 0
  1368                              <1>  %assign %$exit 0
  1369                              <1>  %rep 2
  1370                              <1>   %ifn %$exit
  1371                              <1>    %if %$size == 2
  1372                              <1>     %define %$regnames "ax  cx  dx  bx  sp  bp  si  di  "
  1373                              <1>    %elif %$size == 4
  1374                              <1>     %define %$regnames "eax ecx edx ebx esp ebp esi edi "
  1375                              <1>    %endif
  1376                              <1>    %assign %$index 0
  1377                              <1>    %rep 8
  1378                              <1>     %ifn %$exit
  1379                              <1>      %substr %$reg %$regnames %$index * 4 + 1, 4
  1380                              <1>      %deftok %$reg %$reg
  1381                              <1>      %ifnempty %$reg
  1382                              <1>       %ifidni %$reg, %$token
  1383                              <1>        %assign %$isreg %$size
  1384                              <1>        %assign %$exit 1
  1385                              <1>        %exitrep
  1386                              <1>       %endif
  1387                              <1>      %endif
  1388                              <1>     %endif
  1389                              <1>     %assign %$index %$index + 1
  1390                              <1>    %endrep
  1391                              <1>    %if %$exit
  1392                              <1>     %exitrep
  1393                              <1>    %endif
  1394                              <1>    %assign %$size %$size * 2
  1395                              <1>   %endif
  1396                              <1>  %endrep
  1397                              <1> 
  1398                              <1>  %assign %$ismulti 0
  1399                              <1>  %assign %$ismem 0
  1400                              <1>  %strlen %$length %$string
  1401                              <1>  %assign %$ii 0
  1402                              <1>  %rep %$length
  1403                              <1>   %substr %$point %$string %$ii + 1, 1
  1404                              <1>   %if %$point == 32 || %$point == 9
  1405                              <1>    %assign %$ismulti 1
  1406                              <1>   %endif
  1407                              <1>   %ifidn %$point, '['
  1408                              <1>    %assign %$ismem 1
  1409                              <1>   %endif
  1410                              <1>   %assign %$ii %$ii + 1
  1411                              <1>  %endrep
  1412                              <1> 
  1413                              <1>  %assign %$islocal 0
  1414                              <1>  %substr %$point %$string 1, 1
  1415                              <1>  %substr %$prefix %$string 1, 3
  1416                              <1>  %ifidn %$point, '.'
  1417                              <1>   %ifnidn %$prefix, '..@'
  1418                              <1>    %assign %$islocal 1
  1419                              <1>   %endif
  1420                              <1>  %endif
  1421                              <1> 
  1422                              <1>  %if %$isreg
  1423                              <1>   %if %$isreg == 4
  1424                              <1>    %warning 32-bit reg %3: %2 %1
  1425                              <1>   %else
  1426                              <1>    %warning 16-bit reg %3: %2 %1
  1427                              <1>   %endif
  1428                              <1>  %elif %$ismulti || %$ismem
  1429                              <1>   %warning not single %3: %2 %1
  1430                              <1>  %elif %$islocal
  1431                              <1>   %ifidni %3, call
  1432                              <1>    %warning local %3: %2 %1
  1433                              <1>   %endif
  1434                              <1>  %elifdef SECTION_OF_%[%$token]
  1435                              <1>   %ifnidni SECTION_OF_%[%$token], _CURRENT_SECTION
  1436                              <1>    %error Symbol %$token called wrongly: section_of=SECTION_OF_%[%$token], current=_CURRENT_SECTION
  1437                              <1>   %endif
  1438                              <1>  %endif
  1439                              <1> %pop
  1440                              <1> 	%endmacro
  1441                              <1> 
  1442                              <1> 
  1443                              <1> 	struc MEMREF
  1444 00000000 ????????            <1> mrLinear:		resd 1
  1445 00000004 ????????            <1> mrOffset:		resd 1
  1446 00000008 ????                <1> mrSegmentSelector:	resw 1
  1447 0000000A ????                <1> mrFlags:		resw 1
  1448 0000000C ????????            <1> mrLength:		resd 1
  1449                              <1> 	endstruc
  1450                              <1> 
  1451                              <1> 		; Currently only direct branches are allowed when
  1452                              <1> 		;  disassembling from the U command. (That is,
  1453                              <1> 		;  [disflags] & DIS_F_SHOW is clear.) All other
  1454                              <1> 		;  types of references depend on segment registers
  1455                              <1> 		;  and sometimes base and index registers, which are
  1456                              <1> 		;  not known ahead of time. They are only known for
  1457                              <1> 		;  the R command's disassembly. (DIS_F_SHOW set.)
  1458                              <1> 		; (When a mov ss or pop to ss will change ss, a
  1459                              <1> 		;  subsequent instruction using ss will not be
  1460                              <1> 		;  disassembled with the correct ss value.
  1461                              <1> 		;  This should be rare though. We may at a later
  1462                              <1> 		;  point detect this condition and not display
  1463                              <1> 		;  references with ss then.)
  1464                              <1> mrfBranchDirect:	equ    1
  1465                              <1> mrfMem:			equ    2
  1466                              <1> mrfMemSource:		equ    4
  1467                              <1> mrfMemDest:		equ    8
  1468                              <1> mrfA32:			equ   10h
  1469                              <1> mrfString:		equ   20h
  1470                              <1> mrfStringSource:	equ   40h
  1471                              <1> mrfStringDest:		equ   80h
  1472                              <1> mrfUsesSS:		equ  100h
  1473                              <1> mrfBranchIndirect:	equ  200h
  1474                              <1> 
  1475                              <1> 
  1476                              <1> %if _VXCHG && ! _VXCHGBIOS
  1477                              <1> 	struc XMSM
  1478 00000000 ????????            <1> .size_:		resd 1
  1479 00000004 ????                <1> .srchdl:	resw 1
  1480 00000006 ????????            <1> .srcadr:	resd 1
  1481 0000000A ????                <1> .dsthdl:	resw 1
  1482 0000000C ????????            <1> .dstadr:	resd 1
  1483                              <1> 	endstruc
  1484                              <1> %endif
  1485                              <1> 
  1486                              <1> 
  1487                              <1> 	; doscall is used by symbols.asm and run.asm and in
  1488                              <1> 	;  cmd3_close_handle, so define it prior
  1489                              <1> %if _PM && _NOEXTENDER
  1490                              <1> %macro doscall 0
  1491                              <1> 	nearcall _doscall
  1492                              <1> %endmacro
  1493                              <1> %else
  1494                              <1> 		; When we don't support non-extended DPMI all Int21 calls
  1495                              <1> 		; are either in Real Mode or extended (all are real Int21
  1496                              <1> 		; instructions).
  1497                              <1> %macro doscall 0
  1498                              <1> 	int 21h
  1499                              <1> %endmacro
  1500                              <1> %endif
  1501                              <1> 
  1502                              <1> 
  1503                              <1> %if _LINK
  1504                              <1> %imacro wlcalc 1-2.nolist
  1505                              <1> %deftok %%filenametoken __FILE__
  1506                              <1>  global wlcalc_%1?%[%%l]%[%%filenametoken]
  1507                              <1> wlcalc_%1?%[%%l]%[%%filenametoken]: %2
  1508                              <1> %endmacro
  1509                              <1> %endif
  1510                              <1> 
  1511                              <1> %if _BOOTLDR && _LINK
  1512                              <1> %macro lot_equate 2.nolist
  1513                              <1> LOAD_%2 equ %1
  1514                              <1> %endmacro
  1515                              <1> 
  1516                              <1> 	lot_equate    1, SET_DL_UNIT
  1517                              <1> 	lot_equate    2, SET_BL_UNIT
  1518                              <1> 	lot_equate    4, SET_SIDI_CLUSTER
  1519                              <1> 	lot_equate  10h, SET_DSSI_DPT
  1520                              <1> 	lot_equate  20h, PUSH_DPT
  1521                              <1> 	lot_equate  40h, DATASTART_HIDDEN
  1522                              <1> 	lot_equate  80h, SET_AXBX_DATASTART
  1523                              <1> 	lot_equate 100h, SET_DSBP_BPB
  1524                              <1> 	lot_equate 200h, LBA_SET_TYPE
  1525                              <1> 	lot_equate 400h, MESSAGE_TABLE
  1526                              <1> 	lot_equate 800h, SET_AXBX_ROOT_HIDDEN
  1527                              <1> 	lot_equate 1000h, CMDLINE
  1528                              <1> 	lot_equate 2000h, NO_BPB
  1529                              <1> 	lot_equate 4000h, SET_DSSI_PARTINFO
  1530                              <1> %endif
  1531                              <1> 
  1532                              <1> %if _HELP_COMPRESSED
  1533                              <1>  %assign NONCOMPRESSEDFLAG 1
  1534                              <1> %else
  1535                              <1>  %assign NONCOMPRESSEDFLAG 0
  1536                              <1> %endif
  1537                              <1> 
  1538                              <1> [list +]
  1539                              <1> 
  1540                              <1> %if _LINK
  1541                              <1>  %if _ONLY386
  1542                              <1> 	cpu 386
  1543                              <1>  %else
  1544                              <1> 	cpu 8086
  1545                              <1>  %endif
  1546                              <1> 
  1547                              <1> auxbuff_size: equ (_AUXBUFFSIZE+15) & ~15
  1548                              <1> 	endarea auxbuff, 1
  1549                              <1> 
  1550                              <1> auxbuff_max_size: equ (_AUXBUFFMAXSIZE+15) & ~15
  1551                              <1> 	endarea auxbuff_max, 1
  1552                              <1> 
  1553                              <1> %if _INIT_MAX
  1554                              <1>  auxbuff_init_size: equ (_AUXBUFFMAXSIZE+15) & ~15
  1555                              <1> %else
  1556                              <1>  auxbuff_init_size: equ (_AUXBUFFSIZE+15) & ~15
  1557                              <1> %endif
  1558                              <1> 	endarea auxbuff_init, 1
  1559                              <1> 
  1560                              <1>  %include "options.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug options and internal flags
     5                              <2> 
     6                              <2> Copyright (C) 2008-2025 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 
    17                              <2> dispregs32	equ	  1	; RX: 32-bit register display (R, T/P/G)
    18                              <2> traceints	equ	  2	; TM: trace into interrupts (T)
    19                              <2> cpdepchars	equ	  4	; allow dumping of CP-dependent characters (D, DX)
    20                              <2> fakeindos	equ	  8	; always assume InDOS flag non-zero (all)
    21                              <2> nonpagingdevice	equ	 10h	; disallow paged output with [more] prompt (all exc. P, T)
    22                              <2> 	; This option was never used anywhere:
    23                              <2> ; pagingdevice	equ	 20h	; allow paged output with [more] prompt (all exc. P, T)
    24                              <2> 				; paged output is by default on if the output device is StdOut, else off
    25                              <2> hexrn		equ	 40h	; display raw hexadecimal content of FPU registers (RN)
    26                              <2> ;novdd		equ	 80h	; don't use a registered NTVDM VDD (L, W)
    27                              <2> nondospaging	equ	100h	; paging: don't use DOS for input when waiting for a key
    28                              <2> opt1_86mnohlt	equ	200h	; (86 Mode:) HLT doesn't work, don't use it
    29                              <2> biosidles	equ	400h	; don't idle with HLT or Int2F.1680, only call BIOS Int16.00
    30                              <2> opt_usegetinput	equ	800h	; use getinput for int 21h interactive input
    31                              <2> use_si_units	equ    1000h	; in disp_*_size use SI units (kB = 1000, etc)
    32                              <2> use_jedec_units	equ    2000h	; in disp_*_size use JEDEC units (kB = 1024)
    33                              <2> enable_serial	equ    4000h	; enable serial I/O (preferred over DOS or BIOS terminal)
    34                              <2> int8_disable_serial equ	   8000h	; disable serial I/O when breaking due to intr8
    35                              <2> gg_do_not_skip_bp equ	 1_0000h	; gg: do not skip a breakpoint (bb or gg)
    36                              <2> gg_no_autorepeat equ	 2_0000h	; gg: do not auto-repeat
    37                              <2> tp_do_not_skip_bp equ	 4_0000h	; T/TP/P: do not skip a (bb) breakpoint
    38                              <2> gg_bb_hit_no_repeat equ	 8_0000h	; gg: do not auto-repeat after bb hit
    39                              <2> tp_bb_hit_no_repeat equ	10_0000h	; T/TP/P: do not auto-repeat after bb hit
    40                              <2> gg_unexpected_no_repeat equ 20_0000h	; gg: do not auto-repeat after unexpectedinterrupt
    41                              <2> tp_unexpected_no_repeat equ 40_0000h	; T/TP/P
    42                              <2> ss_no_dump:		equ 80_0000h
    43                              <2> %if _SYMBOLIC
    44                              <2> dd_no_blanks_sym:	equ 100_0000h
    45                              <2> zz_no_pm_xms:		equ 200_0000h
    46                              <2> %endif
    47                              <2> rr_disasm_no_rept:	equ 1000_0000h
    48                              <2> rr_disasm_no_show:	equ 2000_0000h
    49                              <2> opt_cmdline_quiet_input:equ 4000_0000h
    50                              <2> opt_cmdline_quiet_output:equ 8000_0000h
    51                              <2> %if _SYMBOLIC
    52                              <2> DEFAULTOPTIONS	equ zz_no_pm_xms
    53                              <2> %else
    54                              <2> DEFAULTOPTIONS	equ 0
    55                              <2> %endif
    56                              <2> 
    57                              <2> 
    58                              <2> opt2_db_header:		equ 1
    59                              <2> opt2_db_trailer:	equ 2
    60                              <2> opt2_dw_header:		equ 10h
    61                              <2> opt2_dw_trailer:	equ 20h
    62                              <2> opt2_dd_header:		equ 100h
    63                              <2> opt2_dd_trailer:	equ 200h
    64                              <2> opt2_getinput_dpmi:	equ 800h
    65                              <2> opt2_hh_compat:		equ 1000h
    66                              <2> opt2_getc_idle:		equ 2000h
    67                              <2> opt2_getc_idle_dpmi:	equ 4000h
    68                              <2> opt2_re_cancel_tpg:	equ 8000h
    69                              <2> opt2_nn_compat:		equ 1_0000h
    70                              <2> opt2_nn_capitalise:	equ 2_0000h
    71                              <2> %if _MS_0RANGE_COMPAT
    72                              <2> opt2_0range_compat:	equ 4_0000h
    73                              <2> %endif
    74                              <2> opt2_rr16_compat:	equ 8_0000h
    75                              <2> opt2_r_prompt_compat:	equ 10_0000h
    76                              <2> opt2_r_separate:	equ 20_0000h
    77                              <2> opt2_r_linebreak_always:equ 40_0000h
    78                              <2> opt2_dpminohlt:		equ 8000_0000h	; DPMI doesn't like hlt
    79                              <2> DEFAULTOPTIONS2	equ opt2_dw_header | opt2_dd_header | opt2_getc_idle_dpmi | opt2_dpminohlt
    80                              <2> 
    81                              <2> 
    82                              <2> opt3_tt_no_paging:	equ 1
    83                              <2> opt3_tp_no_paging:	equ 2
    84                              <2> opt3_pp_no_paging:	equ 4
    85                              <2> opt3_gg_no_paging:	equ 8
    86                              <2> opt3_silence_paging_set:equ 100h
    87                              <2> opt3_silence_paging_on:	equ 200h
    88                              <2> opt3_paging_rc:		equ 1000h
    89                              <2> opt3_paging_yy:		equ 2000h
    90                              <2> opt3_paging_re:		equ 4000h
    91                              <2> opt3_r_highlight_diff:	equ 10000h
    92                              <2> opt3_r_highlight_dumb:	equ 20000h
    93                              <2> opt3_r_highlight_full:	equ 40000h
    94                              <2> opt3_r_highlight_eip:	equ 80000h
    95                              <2> %if _PM
    96                              <2> opt3_ss_b_bit_set:	equ   10_0000h
    97                              <2>  %if _BREAK_INSTALLDPMI
    98                              <2> opt3_break_installdpmi:	equ   20_0000h
    99                              <2>  %endif
   100                              <2> %endif
   101                              <2> %if _DHIGHLIGHT
   102                              <2> opt3_d_highlight:	equ   80_0000h
   103                              <2> %endif
   104                              <2> %if _GETLINEHIGHLIGHT
   105                              <2> opt3_getline_highlight:	equ  100_0000h
   106                              <2> %endif
   107                              <2> opt3_no_idle_2F:	equ  200_0000h
   108                              <2> %if _DELAY_BEFORE_BP
   109                              <2> opt3_delay_before_bp:	equ  400_0000h
   110                              <2> %endif
   111                              <2> opt3_no_call_amis:	equ  800_0000h
   112                              <2> opt3_disable_autorepeat:equ 1000_0000h
   113                              <2> opt3_check_ctrlc_keyb:	equ 2000_0000h
   114                              <2> opt3_check_ctrlc_0bh:	equ 4000_0000h
   115                              <2> opt3_tsr_quit_leave_tf:	equ 8000_0000h
   116                              <2> DEFAULTOPTIONS3	equ opt3_tt_no_paging | opt3_tp_no_paging 		| opt3_pp_no_paging | opt3_gg_no_paging 		| opt3_check_ctrlc_keyb | opt3_check_ctrlc_0bh
   119                              <2> 
   120                              <2> 
   121                              <2> opt4_int_2F_hook:	equ 2
   122                              <2> opt4_int_08_hook:	equ 4
   123                              <2> opt4_int_2D_hook:	equ 8
   124                              <2> %if _CATCHINTFAULTCOND
   125                              <2> opt4_int_fault_hook:	equ 10h
   126                              <2> %endif
   127                              <2> opt4_int_serial_force:	equ 1_0000h
   128                              <2> opt4_int_2F_force:	equ 2_0000h
   129                              <2> opt4_int_08_force:	equ 4_0000h
   130                              <2> opt4_int_2D_force:	equ 8_0000h
   131                              <2> %if _CATCHINT0D
   132                              <2> opt4_int_0D_force:	equ   10_0000h
   133                              <2> %endif
   134                              <2> %if _CATCHINT0C
   135                              <2> opt4_int_0C_force:	equ   20_0000h
   136                              <2> %endif
   137                              <2> opt4_int_00_force:	equ  100_0000h
   138                              <2> opt4_int_01_force:	equ  200_0000h
   139                              <2> opt4_int_03_force:	equ  400_0000h
   140                              <2> opt4_int_06_force:	equ  800_0000h
   141                              <2> opt4_int_18_force:	equ 1000_0000h
   142                              <2> opt4_int_19_force:	equ 2000_0000h
   143                              <2> opt4_int_09_force:	equ 4000_0000h	; not used at the same time as 15h
   144                              <2> opt4_int_15_force:	equ 4000_0000h	; not used at the same time as 09h
   145                              <2> opt4_int_07_force:	equ 8000_0000h
   146                              <2> DEFAULTOPTIONS4 equ opt4_int_2F_hook
   147                              <2> 
   148                              <2> 
   149                              <2> %if _VXCHG
   150                              <2> opt6_vv_mode:		equ 1
   151                              <2> opt6_vv_keep:		equ 2
   152                              <2> opt6_vv_int16:		equ 10h
   153                              <2>  %if _VXCHG_DEFAULT_ON
   154                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq | opt6_vv_mode
   155                              <2>  %else
   156                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq
   157                              <2>  %endif
   158                              <2> %else
   159                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq
   160                              <2> %endif
   161                              <2> %if _DEBUG
   162                              <2> opt6_debug_exception_late:	equ  20h
   163                              <2> opt6_debug_exception_early:	equ  40h
   164                              <2>  %if _DEBUG_COND
   165                              <2> opt6_debug_exception:	equ  80h
   166                              <2> opt6_debug_mode:	equ 100h
   167                              <2>  %endif
   168                              <2> %endif
   169                              <2> opt6_bios_output:	equ 200h
   170                              <2> opt6_flat_binary:	equ 400h
   171                              <2> opt6_big_stack:		equ 800h
   172                              <2> opt6_40_columns:	equ 1000h
   173                              <2> opt6_40_indent_odd:	equ 2000h
   174                              <2> opt6_40_dash:		equ 4000h
   175                              <2> opt6_share_serial_irq:	equ 1_0000h
   176                              <2> opt6_serial_EOI_call:	equ 2_0000h
   177                              <2> %if _RH
   178                              <2> opt6_rh_mode:		equ 10_0000h
   179                              <2> %endif
   180                              <2> %if _DEBUG
   181                              <2> opt6_debug_putrunint_early:	equ  40_0000h
   182                              <2>  %if _DEBUG_COND
   183                              <2> opt6_debug_putrunint:		equ  80_0000h
   184                              <2>  %endif
   185                              <2> %endif
   186                              <2> opt6_bios_io:		equ 100_0000h
   187                              <2> opt6_immasm_display_uu:	equ 200_0000h
   188                              <2> opt6_immasm_debug:	equ 400_0000h
   189                              <2> opt6_immasm_flag:	equ 800_0000h
   190                              <2> opt6_immasm_nobranch:	equ 1000_0000h
   191                              <2> opt6_r_flags_style2:	equ 2000_0000h
   192                              <2> opt6_r_flags_style3:	equ 4000_0000h
   193                              <2> opt6_r_linebreak_conditional:	equ 8000_0000h
   194                              <2> 
   195                              <2> 
   196                              <2> DEFAULTOPTIONS7 equ opt7_no_tsr_ll
   197                              <2> opt7_no_free_oneshot_eld:	equ 1
   198                              <2> opt7_debug_optional_link:	equ 2
   199                              <2> opt7_quiet_install:		equ 4
   200                              <2> opt7_quick_run:			equ 8
   201                              <2> opt7_houdini:			equ 100h
   202                              <2> opt7_debug_run:			equ 200h
   203                              <2> opt7_no_ensure:			equ 1000h
   204                              <2> opt7_no_tsr_ll:			equ 2000h
   205                              <2> 
   206                              <2> 
   207                              <2> oldpacket	equ	  1	; Int25/Int26 packet method available (L, W)
   208                              <2> newpacket	equ	  2	; Int21.7305 packet method available (L, W)
   209                              <2> ntpacket	equ	  4	; VDD registered and usable (L, W)
   210                              <2> pagedcommand	equ	  8	; allows paging in puts
   211                              <2> notstdinput	equ	 10h	; DEBUG's StdIn isn't a device with StdIn bit (is file or other device)
   212                              <2> inputfile	equ	 20h	; DEBUG's StdIn is a file, notstdinput also set
   213                              <2> notstdoutput	equ	 40h	; DEBUG's StdOut isn't a device with StdOut bit (is file or other device)
   214                              <2> outputfile	equ	  80h	; DEBUG's StdOut is a file, notstdoutput also set
   215                              <2> hooked2F	equ	 100h	; Int2F hooked
   216                              <2> nohook2F	equ	 200h	; don't hook Int2F.1687 (required for Win9x, DosEmu?)
   217                              <2> unused_dif1_dpminohlt equ 400h	; DPMI doesn't like hlt
   218                              <2> protectedmode	equ	 800h	; in (DPMI) protected mode
   219                              <2> debuggeeA20	equ	1000h	; state of debuggee's A20
   220                              <2> debuggerA20	equ	2000h	; state of debugger's A20 (will be on if possible)
   221                              <2> nodosloaded	equ	4000h	; No DOS loaded currently (Boot loader mode)
   222                              <2> has386		equ	8000h	; CPU is a 386
   223                              <2> usecharcounter	equ    1_0000h	; don't reset charcounter between calls to puts
   224                              <2> runningnt	equ    2_0000h	; running in NTVDM
   225                              <2> canswitchmode	equ    4_0000h	; can switch modes (auxbuff large enough, DPMI mode switch set up)
   226                              <2> modeswitched	equ    8_0000h	; switched mode (now in the mode that we weren't entered in)
   227                              <2> promptwaiting	equ   10_0000h	; puts: any more output needs to display a prompt first
   228                              <2> switchbuffer	equ   20_0000h	; mode switch needs a buffer (auxbuff)
   229                              <2> tsrmode		equ   40_0000h	; in TSR mode; DPI and DPP not valid
   230                              <2> attachedterm	equ   80_0000h	; the attached process terminated
   231                              <2> runningdosemu	equ  100_0000h	; running in dosemu
   232                              <2> ; load_is_ldp	equ  200_0000h	; boot load: partition specified as "ldp"
   233                              <2> tt_while:	equ  400_0000h	; tt: while condition specified
   234                              <2> tt_p:		equ  800_0000h	; tt: proceed past repeated string instructions
   235                              <2> tt_silent_mode:	equ 1000_0000h	; tt: run should be silent (dump at end)
   236                              <2> tt_silence:	equ 2000_0000h	; tt: silent writing (write to auxbuff instead)
   237                              <2> tt_no_bb:	equ 4000_0000h	; tt: do not use bb breakpoints
   238                              <2> tt_no_bb_first:	equ 8000_0000h	; tt: do not use bb breakpoints at first
   239                              <2> 
   240                              <2> 
   241                              <2> dif2_gg_is_first:	equ   1
   242                              <2> dif2_gg_skip_non_cseip:	equ   2
   243                              <2> dif2_gg_skip_cseip:	equ   4
   244                              <2> dif2_gg_is_gg:		equ   8
   245                              <2> dif2_gg_first_detected:	equ  10h
   246                              <2> dif2_gg_again:		equ  20h
   247                              <2> dif2_tpg_proceed_bp_set:equ  40h
   248                              <2> dif2_tpg_keep_proceed_bp: equ 80h
   249                              <2> dif2_tpg_have_bp:	equ 100h
   250                              <2> dif2_tpg_adjusted_cseip:equ 200h
   251                              <2> dif2_tpg_do_not_adjust:	equ 400h
   252                              <2> dif2_bp_failure:	equ 800h
   253                              <2> dif2_is_pp:		equ 1000h
   254                              <2> %if _SYMBOLIC
   255                              <2> dif2_createdprocess:	equ 800_0000h	; created empty debuggee process
   256                              <2> dif2_sym_req_xms:	equ 2000h
   257                              <2> dif2_sym_req_86mm:	equ 4000h
   258                              <2> dif2_sym_req_mask equ dif2_sym_req_86mm | dif2_sym_req_xms
   259                              <2> dif2_no_pm_xms:		equ 1_0000h
   260                              <2> dif2_xms_detection_done:equ 2_0000h
   261                              <2> %endif
   262                              <2> %if _INPUT_FILE_HANDLES
   263                              <2> dif2_input_file:	equ 10_0000h
   264                              <2> dif2_closed_input_file:	equ 20_0000h
   265                              <2> %endif
   266                              <2> dif2_did_getline_file:	equ 40_0000h
   267                              <2> %if _SYMBOLIC
   268                              <2> dif2_poison:		equ 80_0000h
   269                              <2> %endif
   270                              <2> dif2_boot_loaded_kernel:equ 100_0000h
   271                              <2> %if _INPUT_FILE_BOOT
   272                              <2> dif2_input_file_boot:	equ 200_0000h
   273                              <2> dif2_closed_input_file_boot:	equ 400_0000h
   274                              <2> %endif
   275                              <2> dif2_in_silence_dump:	equ 1000_0000h
   276                              <2> dif2_int31_segment:	equ 2000_0000h
   277                              <2> dif2_nn_compat:		equ 4000_0000h
   278                              <2> dif2_nn_capitalise:	equ 8000_0000h
   279                              <2> 
   280                              <2> 
   281                              <2> dif3_load_is_ldp:	equ 1	; boot load: partition specified as "ldp"
   282                              <2> dif3_load_is_sdp:	equ 2	; boot load: partition specified as "sdp"
   283                              <2> dif3_load_is_ydp:	equ 4	; boot load: partition specified as "ydp"
   284                              <2> dif3_load_is_dp:	equ dif3_load_is_ldp 				| dif3_load_is_sdp 				| dif3_load_is_ydp
   287                              <2> dif3_load_dir_dir:	equ 8
   288                              <2> dif3_input_terminal_override:	equ 10h
   289                              <2> dif3_input_serial_override:	equ 20h
   290                              <2> dif3_if_not:		equ 40h
   291                              <2> dif3_partition_changed:	equ 80h
   292                              <2> ;
   293                              <2> dif3_input_cmdline:	equ 100h; input reading from cmdline_buffer
   294                              <2> dif3_input_cmdline_closed: equ 200h
   295                              <2> dif3_at_line_end:	equ 400h
   296                              <2> dif3_quiet_input_single:equ 800h
   297                              <2> dif3_quiet_output:	equ 1000h
   298                              <2> dif3_unquiet_error:	equ 2000h
   299                              <2> dif3_unquiet_prompt:	equ 4000h
   300                              <2> dif3_unquiet:		equ dif3_unquiet_error | dif3_unquiet_prompt
   301                              <2> dif3_return_eof:	equ 8000h
   302                              <2> dif3_highlighting:	equ 1_0000h
   303                              <2> dif3_do_not_highlight:	equ 2_0000h
   304                              <2> dif3_int10_highlight:	equ 2_0000h
   305                              <2> dif3_nosymbols_1:	equ 4_0000h
   306                              <2> dif3_nosymbols_2:	equ 8_0000h
   307                              <2> %if _PM
   308                              <2> dif3_ss_b_bit_set:	equ  10_0000h
   309                              <2> %endif
   310                              <2> dif3_gotint19:		equ  20_0000h
   311                              <2> dif3_prior_pm:		equ  40_0000h
   312                              <2> %if _DELAY_BEFORE_BP
   313                              <2> dif3_delayed		equ  80_0000h
   314                              <2> %endif
   315                              <2> dif3_input_re:		equ 100_0000h	; input reading from re_buffer
   316                              <2> dif3_input_re_closed:	equ 200_0000h
   317                              <2> dif3_accept_getrange_0:	equ 400_0000h
   318                              <2> %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
   319                              <2> dif3_in_if:		equ 800_0000h
   320                              <2> %endif
   321                              <2> dif3_auxbuff_guarded_1:	equ 1000_0000h
   322                              <2> dif3_auxbuff_guarded_2:	equ 2000_0000h
   323                              <2> dif3_auxbuff_guarded_3:	equ 4000_0000h
   324                              <2> dif3_sss_is_reverse:	equ 8000_0000h
   325                              <2> 
   326                              <2> 
   327                              <2> dif4_int_serial_hooked:	equ 1
   328                              <2> dif4_int_2F_hooked:	equ 2
   329                              <2> dif4_int_08_hooked:	equ 4
   330                              <2> dif4_int_2D_hooked:	equ 8
   331                              <2> %if _CATCHINTFAULTCOND && _CATCHINT0D
   332                              <2> dif4_int_0D_hooked:	equ 10h
   333                              <2> %endif
   334                              <2> %if _CATCHINTFAULTCOND && _CATCHINT0C
   335                              <2> dif4_int_0C_hooked:	equ 20h
   336                              <2> %endif
   337                              <2> %if _LOADER
   338                              <2> dif4_int_18_hooked:	equ 1000h
   339                              <2> dif4_int_19_hooked:	equ 2000h
   340                              <2> %endif
   341                              <2> 
   342                              <2> 
   343                              <2> %if _VXCHG
   344                              <2> dif6_vv_mode:		equ 1
   345                              <2> %endif
   346                              <2> dif6_in_hook2F:		equ 2
   347                              <2> dif6_in_amis_hook2F:	equ 4
   348                              <2> dif6_debug_mode:	equ 100h
   349                              <2> dif6_locked:		equ 200h
   350                              <2> dif6_mcp:		equ 400h
   351                              <2> %if _RH
   352                              <2> dif6_rh_mode_was:	equ  8_0000h
   353                              <2> dif6_rh_mode:		equ 10_0000h
   354                              <2> dif6_rh_mode_2:		equ 20_0000h
   355                              <2> %endif
   356                              <2> dif6_device_mode:	equ 40_0000h
   357                              <2> dif6_cpdepchars:	equ 80_0000h
   358                              <2> %if _IMMASM
   359                              <2> dif6_immasm_no_output:	equ 100_0000h
   360                              <2> dif6_immasm:		equ 200_0000h
   361                              <2> dif6_immasm_rel8:	equ 400_0000h
   362                              <2> %endif
   363                              <2> 
   364                              <2> 
   365                              <2> disasm_lowercase	equ 1
   366                              <2> disasm_commablank	equ 2
   367                              <2> disasm_nasm		equ 4
   368                              <2> disasm_lowercase_refmem:equ 8
   369                              <2> disasm_show_short:	equ 10h
   370                              <2> disasm_show_near:	equ 20h
   371                              <2> disasm_show_far:	equ 40h
   372                              <2> disasm_nec:		equ 80h
   373                              <2> disasm_40_columns:	equ 100h
   374                              <2> disasm_no_indent:	equ 200h
   375                              <2> disasm_msdebug_mnemonofs: equ 400h
   376                              <2> disasm_a16_memref:	equ 1000h
   377                              <2> disasm_a32_memref:	equ 2000h
   378                              <2> disasm_a16_string:	equ 4000h
   379                              <2> disasm_a32_string:	equ 8000h
   380                              <2> disasm_hide_modrm:	equ 10000h
   381                              <2> disasm_asize_loop_nasm:	equ 20000h
   382                              <2> disasm_modrm_always:	equ 40000h
   383                              <2> DEFAULTASMOPTIONS equ disasm_lowercase|disasm_commablank|disasm_nasm 	| disasm_a16_memref | disasm_a32_memref 	| disasm_a16_string | disasm_a32_string
   386                              <2> 
   387                              <2> 	; serial_flags values
   388                              <2> sf_init_done:	equ 1
   389                              <2> sf_ctrl_c:	equ 2
   390                              <2> sf_double_ctrl_c:	equ 4
   391                              <2> sf_built_in_fifo:	equ 8
   392                              <2> sf_use_serial:		equ 10h
  1561                              <1> %endif
    19                                  %endif
    20                                  
    21                                  
    22                                  %if _LINK && !_BOOTLDR
    23                                  	usesection lDEBUG_CODE2
    24                                  behind_code_truncated:
    25                                  %endif
    26                                  
    27                                  %if !_LINK || _BOOTLDR
    28                                  	usesection lDEBUG_DATA_ENTRY
    28          ------------------       note: usesection lDEBUG_DATA_ENTRY
    29                                  
    30                                  	align 16, db 0
    31                                  load_unit_flags:
    32 00000000 00<rep 80h>             	times 128 db _LUF_DEFAULT_DISKETTE
    33 00000080 00<rep 80h>             	times 128 db _LUF_DEFAULT_HARDDISK
    34                                  
    35                                  	align 16, db 0
    36 00000100 00<rep 40h>             load_partition_table:	times 16 * 4 db 0
    37                                  .end:
    38                                  
    39                                  	align 16, db 0
    40                                  		; Data passed to us from loader (in case we booted)
    41                                  loaddata_loadedfrom:
    42 00000140 00<rep 7Ah>             	times (-LOADDATA + bsBPB + ebpbNew + BPBN_size) db 0
    43                                  
    44 000001BA 00<rep 6h>              	align 16, db 0
    45                                  load_data_lowest:
    46 000001C0 00<rep 10h>             	times LOADDATA3_size db 0
    47                                  		; data used to access storage
    48                                  load_data:
    49 000001D0 00<rep 8Ah>             	times (-LOADDATA2 + bsBPB + ebpbNew + BPBN_size) db 0
    50 0000025A 00<rep 6h>              	align 16, db 0
    51                                  load_current_settings:
    52                                  	istruc LOADSETTINGS
    53 00000260 0000                    at lsKernelName,	load_kernelname_default:	dw 0
    54 00000262 0000                    at lsAddName,		load_addname_default:		dw 0
    55 00000264 0000                    at lsMinPara,		load_minpara:			dw 0
    56 00000266 0000                    at lsMaxPara,		load_maxpara:			dw 0
    57 00000268 0000                    at lsOptions,		load_options:			dw 0
    58 0000026A 0000                    at lsSegment,		load_loadseg:			dw 0
    59 0000026C 00000000                at lsEntry,		load_entrypoint:		dd 0
    60 00000270 00000000                at lsBPB,		load_bpb:			dd 0
    61 00000274 00000000                at lsCopyBPB,		load_copy_bpb:			dd 0
    62 00000278 0000                    at lsCheckOffset,	load_check_offset:		dw 0
    63 0000027A 0000                    at lsCheckValue,	load_check_value:		dw 0
    64                                  at lsName
    65                                  	;	iend
    66                                  	%pop		; (pop off the istruc context)
    67                                  
    68                                  %if _INPUT_FILE_BOOT || _EXTENSIONS
    69 0000027C 00<rep 4h>              	align 16, db 0
    70                                  load_yy_direntry:
    71 00000280 00<rep 20h>             	times DIRENTRY_size db 0
    72                                  %endif
    73                                  
    74                                  %if _INPUT_FILE_BOOT
    75                                  	align 16, db 0
    76                                  load_input_file:
    77 000002A0 00<rep 280h>            	times _INPUT_FILE_BOOT * LOAD_INPUT_FILE_SIZE db 0
    78                                  .active:
    79 00000520 0000                    	dw 0
    80                                  .goto_offset:
    81 00000522 0000                    	dw 0
    82                                  %endif
    83                                  
    84                                  	align 4, db 0
    85 00000524 00000000                load_bpb_dest:		dd 0
    86                                  load_sectors:		equ load_data - LOADDATA2 + bsBPB + bpbCHSSectors
    87                                  load_heads:		equ load_data - LOADDATA2 + bsBPB + bpbCHSHeads
    88                                  load_sectorsize:	equ load_data - LOADDATA2 + bsBPB + bpbBytesPerSector
    89                                  load_sectorsizepara:	equ load_data - LOADDATA2 + ldParaPerSector
    90                                  load_sectorseg:		equ load_data - LOADDATA2 + ldSectorSeg
    91 00000528 00000000                load_partition_sector:	dd 0
    92                                  load_ldp_sector:	equ loaddata_loadedfrom - LOADDATA + bsBPB + bpbHiddenSectors
    93 0000052C 00000000                load_sdp_sector:	dd 0
    94 00000530 0000                    load_partition_cycle:	dw 0
    95 00000532 0000                    load_cmdline:		dw 0
    96                                  load_ldflags:		equ load_data - LOADDATA2 + ldFlags
    97                                  load_unit:		equ load_data - LOADDATA2 + bsBPB + ebpbNew + bpbnBootUnit
    98 00000534 00000000                load_partition_entry:	dw 0, 0		; far pointer
    99 00000538 00                      load_partition:		db 0
   100 00000539 00                      load_current_partition:	db 0
   101 0000053A 00                      load_found_partition:	db 0
   102 0000053B 00                      load_check_dir_attr:	db 0
   103 0000053C 00                      load_sector_alt:	db 0
   104 0000053D 00                      load_sdp_unit:		db 0
   105 0000053E 00                      load_cmdline_first:	db 0
   106                                  
   107 0000053F 00                      	align 4, db 0
   108 00000540 00<rep Ch>              load_kernel_name:	times 11 + 1 db 0
   109                                  	align 2, db 0
   110                                  ;	load_kernelname_default:dw 0
   111                                  		; ASCIZ filename for if load_kernelname_input terminates in '/'
   112 0000054C 0000                    load_kernelname_input:	dw 0
   113                                  		; input (ASCIZ '/'-terminated pathnames + optional filename)
   114 0000054E 0000                    load_kernelname_next:	dw 0
   115                                  		; next element in ASCIZ load_kernelname_input,
   116                                  		;  empty string if pathname terminated in '/'
   117                                  ;	load_addname_default:	dw 0
   118 00000550 0000                    load_addname_input:	dw 0
   119 00000552 0000                    load_addname_next:	dw 0
   120                                  %if _INPUT_FILE_BOOT || _EXTENSIONS
   121 00000554 0000                    load_yyname_input:	dw 0
   122 00000556 0000                    load_yyname_next:	dw 0
   123                                  %endif
   124                                  
   125                                  	align 2, db 0
   126 00000558 0000                    load_adr_dirbuf_segment:dw 0
   127 0000055A 0000                    boot_new_memsizekib:	dw 0
   128 0000055C 0000                    boot_old_memsizekib:	dw 0
   129 0000055E 00                      boot_ebdaflag:	db 0		; EBDA flag: non-zero if present
   130                                  
   131 0000055F 00                      	align 4, db 0
   132 00000560 00000000                load_readwrite_sector:	dd 0
   133 00000564 0000                    load_readwrite_buffer:	dw 0
   134 00000566 0000                    load_readwrite_count:	dw 0
   135 00000568 0000                    load_readwrite_function:dw 0
   136                                  
   137                                  
   138                                  	usesection lDEBUG_CODE
   138          ------------------       note: usesection lDEBUG_CODE
   139                                  %if _LINK_COMPAT
   140                                  	align 4, db 0
   141                                  %endif
   142                                  %if _LINK && _BOOTLDR_DISCARD
   143                                  behind_code_truncated:
   144                                  %endif
   145                                  
   146                                  init_bootcmd: section_of_function
   147 00000000 E8(0000)                	call guard_re
   148 00000003 BD[0002]                	mov bp, load_data - LOADDATA2
   149                                  
   150 00000006 F606[0000]80            	testopt [internalflags3], dif3_partition_changed
   151 0000000B 7429                    	jz @F
   152                                  
   153 0000000D FF761E                  	push word [bp + bsBPB + bpbHiddenSectors + 2]
   154 00000010 FF761C                  	push word [bp + bsBPB + bpbHiddenSectors]
   155 00000013 8F06[2805]              	pop word [load_partition_sector]
   156 00000017 8F06[2A05]              	pop word [load_partition_sector + 2]
   157 0000001B 8A0E[4002]              	mov cl, byte [load_data - LOADDATA2 			+ bsBPB + ebpbNew + bpbnBootUnit]
   159 0000001F 880E[3D05]              	mov byte [load_sdp_unit], cl
   160 00000023 FF761E                  	push word [bp + bsBPB + bpbHiddenSectors + 2]
   161 00000026 FF761C                  	push word [bp + bsBPB + bpbHiddenSectors]
   162 00000029 8F06[2C05]              	pop word [load_sdp_sector]
   163 0000002D 8F06[2E05]              	pop word [load_sdp_sector + 2]
   164 00000031 8026[0000]7F            	clropt [internalflags3], dif3_partition_changed
   165                                  @@:
   166                                  
   167 00000036 31C9                    	xor cx, cx
   168 00000038 894E1C                  	mov [bp + bsBPB + bpbHiddenSectors + 0], cx
   169 0000003B 894E1E                  	mov [bp + bsBPB + bpbHiddenSectors + 2], cx
   170 0000003E 880E[3C05]              	mov byte [load_sector_alt], cl
   171                                  %if _CONFIG
   172 00000042 890E[0000]              	mov word [yy_boot_attempt_open_pathname], cx
   173                                  %endif
   174 00000046 C3                      	retn
   175                                  
   176                                  
   177                                  	usesection lDEBUG_DATA_ENTRY
   177          ------------------       note: usesection lDEBUG_DATA_ENTRY
   178                                  
   179 0000056A 00<rep 2h>              	align 4, db 0
   180                                  bootcmd_dispatch:
   181 0000056C [7305]                  	dw bootcmd.list
   182 0000056E [0000]                  	dw msg.list
   183 00000570 [7300]                  	dw bootcmd.quit
   184 00000572 [0000]                  	dw msg.quit
   185 00000574 [9409]                  	dw boot_read
   186 00000576 [0000]                  	dw msg.read
   187 00000578 [9C09]                  	dw boot_write
   188 0000057A [0000]                  	dw msg.write
   189 0000057C [6212]                  	dw boot_dir
   190 0000057E [0000]                  	dw msg.dir
   191 00000580 [A900]                  	dw bootcmd.protocol
   192 00000582 [0000]                  	dw msg.protocol
   193 00000584 0000                    	dw 0			; table end marker
   194                                  
   195                                  
   196                                  	usesection lDEBUG_CODE
   196          ------------------       note: usesection lDEBUG_CODE
   197                                  
   198                                  bootcmd:
   199                                  %if _PM
   200 00000047 E8(0000)                	call ispm
   201 0000004A 750C                    	jnz .rm
   202 0000004C BA[0000]                	mov dx, nopmsupp
   203 0000004F B80102                  	mov ax, 0201h
   204 00000052 E8(0000)                	call setrc
   205 00000055 E9(0000)                	jmp putsz_error
   206                                  .rm:
   207                                  %endif
   208                                  d4	call d4message
   209                                  d4	asciz "In bootcmd",13,10
   210                                  
   211 00000058 E8A5FF                  	call init_bootcmd
   212                                  
   213 0000005B E8(0000)                	call skipcomma
   214 0000005E 4E                      	dec si
   215 0000005F BB[6C05]                	mov bx, bootcmd_dispatch
   216                                  @@:
   217 00000062 8B0F                    	mov cx, [bx]
   218 00000064 8B5702                  	mov dx, [bx + 2]
   219 00000067 83C304                  	add bx, 4
   220 0000006A E370                    	jcxz .notproto
   221 0000006C E8(0000)                	call isstring?
   222 0000006F 75F1                    	jne @B
   223 00000071 FFE1                    	jmp cx
   224                                  
   225                                  
   226                                  .quit:
   227                                   %if _DOSEMU
   228 00000073 F606[0300]01            	testopt [internalflags], runningdosemu
   229 00000078 7407                    	jz .quit_not_dosemu
   230                                  
   231 0000007A 31DB                    	xor bx, bx
   232 0000007C B8FFFF                  	mov ax, -1
   233 0000007F CDE6                    	int 0E6h			; dosemu quit
   234                                  
   235                                  .quit_not_dosemu:
   236                                   %endif
   237                                  
   238                                  ; from https://stackoverflow.com/a/5240330/738287
   239 00000081 B80153                  	mov ax, 5301h
   240 00000084 31DB                    	xor bx, bx
   241 00000086 CD15                    	int 15h				; connect to APM API
   242                                  
   243 00000088 B80E53                  	mov ax, 530Eh
   244 0000008B 31DB                    	xor bx, bx
   245 0000008D B90201                  	mov cx, 0102h
   246 00000090 CD15                    	int 15h				; set APM version to 1.02
   247                                  
   248 00000092 B80753                  	mov ax, 5307h
   249 00000095 BB0100                  	mov bx, 1
   250 00000098 B90300                  	mov cx, 3
   251 0000009B CD15                    	int 15h				; shut down system
   252                                  
   253 0000009D BA[0000]                	mov dx, msg.boot_quit_fail
   254 000000A0 B80202                  	mov ax, 0202h
   255 000000A3 E8(0000)                	call setrc
   256 000000A6 E9(0000)                	jmp putsz_error
   257                                  
   258                                  
   259                                  .protocol:
   260 000000A9 E8(0000)                	call skipequals
   261 000000AC 4E                      	dec si
   262 000000AD BA[0000]                	mov dx, msg.sector
   263 000000B0 E8(0000)                	call isstring?
   264 000000B3 7423                    	je .proto_sector
   265                                  
   266 000000B5 BA[0000]                	mov dx, msg.sector_alt
   267 000000B8 E8(0000)                	call isstring?
   268 000000BB 7416                    	je .proto_sector_alt
   269                                  
   270 000000BD BB[0000]                	mov bx, loadsettings
   271                                  .proto_settings_next:
   272 000000C0 8D571C                  	lea dx, [bx + lsName]
   273 000000C3 E8(0000)                	call isstring?
   274 000000C6 7421                    	je .proto_settings
   275 000000C8 83C324                  	add bx, LOADSETTINGS_size
   276 000000CB 833F00                  	cmp word [bx], 0
   277 000000CE 75F0                    	jne .proto_settings_next
   278                                  
   279 000000D0 E9(0000)                	jmp error
   280                                  
   281                                  .proto_sector_alt:
   282 000000D3 C606[3C05]01            	mov byte [load_sector_alt], 1
   283                                  .proto_sector:
   284 000000D8 E8(0000)                	call skipcomma
   285 000000DB A8                      	db __TEST_IMM8
   286                                  .notproto:
   287 000000DC AC                      	lodsb
   288 000000DD E88B06                  	call parseloadunit_default_sdp
   289 000000E0 E99103                  	jmp .load
   290                                  
   291                                  
   292                                  .errordec:
   293 000000E3 4E                      	dec si
   294                                  .error:
   295 000000E4 A8                      	db __TEST_IMM8		; skip pop
   296                                  .errorpop:
   297 000000E5 5E                      	pop si
   298 000000E6 E9(0000)                	jmp error
   299                                  
   300                                  
   301                                  .proto_settings:
   302 000000E9 56                      	push si
   303 000000EA 89DE                    	mov si, bx
   304 000000EC BF[6002]                	mov di, load_current_settings
   305 000000EF B90E00                  	mov cx, lsName >> 1
   306 000000F2 F3A5                    	rep movsw
   307                                  %if lsName & 1
   308                                  	movsb
   309                                  %endif
   310 000000F4 FF75E4                  	push word [load_kernelname_default - (load_current_settings + lsName) + di]
   311 000000F7 8F85D002                	pop word [load_kernelname_input - (load_current_settings + lsName) + di]
   312 000000FB FF75E6                  	push word [load_addname_default - (load_current_settings + lsName) + di]
   313 000000FE 8F85D402                	pop word [load_addname_input - (load_current_settings + lsName) + di]
   314                                  
   315 00000102 5E                      	pop si
   316                                  
   317                                  d4	call d4message
   318                                  d4	asciz "In bootcmd.proto_settings",13,10
   319                                  
   320                                  .proto_next:
   321 00000103 E8(0000)                	call skipcomma
   322 00000106 4E                      	dec si
   323 00000107 BA[0000]                	mov dx, msg.segment
   324 0000010A E8(0000)                	call isstring?
   325 0000010D 7503E98700              	je .proto_segment
   326 00000112 BA[0000]                	mov dx, msg.entry
   327 00000115 E8(0000)                	call isstring?
   328 00000118 7503E99D00              	je .proto_entry
   329 0000011D BA[0000]                	mov dx, msg.bpb
   330 00000120 E8(0000)                	call isstring?
   331 00000123 7503E9B300              	je .proto_bpb
   332 00000128 BA[0000]                	mov dx, msg.copybpb
   333 0000012B E8(0000)                	call isstring?
   334 0000012E 7503E9C900              	je .proto_copybpb
   335 00000133 BA[0000]                	mov dx, msg.minpara
   336 00000136 E8(0000)                	call isstring?
   337 00000139 7503E9DF00              	je .proto_minpara
   338 0000013E BA[0000]                	mov dx, msg.maxpara
   339 00000141 E8(0000)                	call isstring?
   340 00000144 7503E9E400              	je .proto_maxpara
   341 00000149 BA[0000]                	mov dx, msg.checkoffset
   342 0000014C E8(0000)                	call isstring?
   343 0000014F 7503E9E900              	je .proto_checkoffset
   344 00000154 BA[0000]                	mov dx, msg.checkvalue
   345 00000157 E8(0000)                	call isstring?
   346 0000015A 7503E9F900              	je .proto_checkvalue
   347                                  
   348 0000015F BB[0000]                	mov bx, loadoptiontable
   349                                  .proto_lot_next:
   350 00000162 8B0F                    	mov cx, [bx]		; flag
   351 00000164 8B5702                  	mov dx, [bx + 2]	; -> ASCIZ message
   352 00000167 85C9                    	test cx, cx
   353 00000169 7503E9FA00              	jz .proto_done
   354 0000016E E8(0000)                	call isstring?
   355 00000171 7405                    	je .proto_lot
   356 00000173 83C304                  	add bx, 4
   357 00000176 EBEA                    	jmp .proto_lot_next
   358                                  
   359                                  .proto_lot:
   360 00000178 E8(0000)                	call skipequals
   361 0000017B 89CA                    	mov dx, cx
   362 0000017D F7D2                    	not dx
   363 0000017F 2116[6802]              	and word [load_options], dx
   364 00000183 E8(0000)[0000]          	nearcall getexpression
   365 00000188 E8(0000)[0000]          	nearcall toboolean
   366 0000018D 85D2                    	test dx, dx
   367 0000018F 7404                    	jz @F
   368 00000191 090E[6802]              	or word [load_options], cx
   369                                  @@:
   370 00000195 4E                      	dec si
   371 00000196 E96AFF                  	jmp .proto_next
   372                                  
   373                                  .proto_segment:
   374 00000199 E8(0000)                	call skipequals
   375 0000019C E8(0000)[0000]          	nearcall getword	; dx = word
   376 000001A1 83FA50                  	cmp dx, 50h
   377 000001A4 7208                    	jb @F
   378 000001A6 8916[6A02]              	mov word [load_loadseg], dx
   379 000001AA 4E                      	dec si
   380 000001AB E955FF                  	jmp .proto_next
   381                                  
   382                                  @@:
   383 000001AE BA[0000]                	mov dx, msg.boot_segment_too_low
   384 000001B1 B81002                  	mov ax, 0210h
   385 000001B4 E8(0000)                	call setrc
   386 000001B7 E9A203                  	jmp .fail
   387                                  
   388                                  
   389                                  .proto_entry:
   390 000001BA E8(0000)                	call skipequals
   391 000001BD 31DB                    	xor bx, bx
   392 000001BF E8(0000)[0000]          	nearcall getaddr	; bx:(e)dx = addr
   393 000001C4 66F7C20000FFFF          _386_PM	test edx, 0_FFFF_0000h
   394 000001CB 0F8515FF                _386_PM	jnz .error
   395 000001CF 8916[6C02]              	mov word [load_entrypoint], dx
   396 000001D3 891E[6E02]              	mov word [load_entrypoint + 2], bx
   397 000001D7 4E                      	dec si
   398 000001D8 E928FF                  	jmp .proto_next
   399                                  
   400                                  .proto_bpb:
   401 000001DB E8(0000)                	call skipequals
   402 000001DE 31DB                    	xor bx, bx
   403 000001E0 E8(0000)[0000]          	nearcall getaddr	; bx:(e)dx = addr
   404 000001E5 66F7C20000FFFF          _386_PM	test edx, 0_FFFF_0000h
   405 000001EC 0F85F4FE                _386_PM	jnz .error
   406 000001F0 8916[7002]              	mov word [load_bpb], dx
   407 000001F4 891E[7202]              	mov word [load_bpb + 2], bx
   408 000001F8 4E                      	dec si
   409 000001F9 E907FF                  	jmp .proto_next
   410                                  
   411                                  .proto_copybpb:
   412 000001FC E8(0000)                	call skipequals
   413 000001FF 31DB                    	xor bx, bx
   414 00000201 E8(0000)[0000]          	nearcall getaddr	; bx:(e)dx = addr
   415 00000206 66F7C20000FFFF          _386_PM	test edx, 0_FFFF_0000h
   416 0000020D 0F85D3FE                _386_PM	jnz .error
   417 00000211 8916[7402]              	mov word [load_copy_bpb], dx
   418 00000215 891E[7602]              	mov word [load_copy_bpb + 2], bx
   419 00000219 4E                      	dec si
   420 0000021A E9E6FE                  	jmp .proto_next
   421                                  
   422                                  .proto_minpara:
   423 0000021D E8(0000)                	call skipequals
   424 00000220 E8(0000)[0000]          	nearcall getword	; dx = word
   425 00000225 8916[6402]              	mov word [load_minpara], dx
   426 00000229 4E                      	dec si
   427 0000022A E9D6FE                  	jmp .proto_next
   428                                  
   429                                  .proto_maxpara:
   430 0000022D E8(0000)                	call skipequals
   431 00000230 E8(0000)[0000]          	nearcall getword	; dx = word
   432 00000235 8916[6602]              	mov word [load_maxpara], dx
   433 00000239 4E                      	dec si
   434 0000023A E9C6FE                  	jmp .proto_next
   435                                  
   436                                  .proto_checkoffset:
   437 0000023D E8(0000)                	call skipequals
   438 00000240 E8(0000)[0000]          	nearcall getword	; dx = word
   439 00000245 89D0                    	mov ax, dx
   440 00000247 241F                    	and al, 31
   441 00000249 3C1F                    	cmp al, 31
   442 0000024B 7503E994FE              	je .error
   443                                  		; Previously we rejected all odd values here. Now,
   444                                  		;  we only reject a subset of odd values, namely
   445                                  		;  those that may actually cross a sector boundary.
   446                                  		; Note that sectors may be as small as 32 bytes.
   447                                  		; This insures the checked word never crosses a sector
   448                                  		;  boundary. Thus, loading a single sector suffices.
   449 00000250 8916[7802]              	mov word [load_check_offset], dx
   450 00000254 4E                      	dec si
   451 00000255 E9ABFE                  	jmp .proto_next
   452                                  
   453                                  .proto_checkvalue:
   454 00000258 E8(0000)                	call skipequals
   455 0000025B E8(0000)[0000]          	nearcall getword	; dx = word
   456 00000260 8916[7A02]              	mov word [load_check_value], dx
   457 00000264 4E                      	dec si
   458 00000265 E99BFE                  	jmp .proto_next
   459                                  
   460                                  .proto_done:
   461 00000268 BB[0000]                	mov bx, loadoptiontable.incompatible
   462                                  @@:
   463 0000026B 8B0F                    	mov cx, [bx]
   464 0000026D 0B4F02                  	or cx, [bx + 2]
   465 00000270 746B                    	jz .proto_compatible
   466 00000272 8B16[6802]              	mov dx, word [load_options]
   467 00000276 21CA                    	and dx, cx
   468 00000278 39CA                    	cmp dx, cx
   469 0000027A 7405                    	je .proto_incompatible
   470 0000027C 83C304                  	add bx, 4
   471 0000027F EBEA                    	jmp @B
   472                                  
   473                                  .proto_incompatible:
   474 00000281 16                      	 push ss
   475 00000282 07                      	 pop es
   476 00000283 B80302                  	mov ax, 0203h
   477 00000286 E8(0000)                	call setrc
   478 00000289 BA[0000]                	mov dx, msg.bootfail
   479 0000028C E8(0000)                	call putsz_error
   480 0000028F BA[0000]                	mov dx, msg.boot_cannot_set_both
   481 00000292 E8(0000)                	call putsz_error
   482 00000295 8B07                    	 mov ax, word [bx]
   483 00000297 E82200                  	 call .proto_incompatible_get_label
   484 0000029A E8(0000)                	 call putsz_error
   485 0000029D BA[0000]                	mov dx, msg.boot_and
   486 000002A0 E8(0000)                	call putsz_error
   487 000002A3 8B4702                  	 mov ax, word [bx + 2]
   488 000002A6 E81300                  	 call .proto_incompatible_get_label
   489 000002A9 E8(0000)                	 call putsz_error
   490 000002AC BA[0000]                	mov dx, msg.boot_dot_crlf
   491                                  .putsz_errret:
   492 000002AF B80402                  	mov ax, 0204h
   493 000002B2 E8(0000)                	call setrc
   494 000002B5 E8(0000)                	call putsz_error
   495 000002B8 FF26[0000]              	jmp near word [errret]
   496                                  
   497                                  .proto_incompatible_get_label:
   498 000002BC 53                      	push bx
   499 000002BD BB[0000]                	mov bx, loadoptiontable
   500                                  @@:
   501 000002C0 8B0F                    	mov cx, [bx]
   502 000002C2 E30E                    	jcxz .proto_internal_error
   503 000002C4 39C8                    	cmp ax, cx
   504 000002C6 8B5702                  	mov dx, word [bx + 2]
   505 000002C9 7405                    	je @F
   506 000002CB 83C304                  	add bx, 4
   507 000002CE EBF0                    	jmp @B
   508                                  
   509                                  @@:
   510 000002D0 5B                      	pop bx
   511 000002D1 C3                      	retn
   512                                  
   513                                  .proto_internal_error:
   514 000002D2 BA[0000]                	mov dx, msg.boot_internal_error
   515 000002D5 B80502                  	mov ax, 0205h
   516 000002D8 E8(0000)                	call setrc
   517 000002DB EBD2                    	jmp .putsz_errret
   518                                  
   519                                  
   520                                  .proto_compatible:
   521 000002DD AC                      	lodsb
   522 000002DE E88A04                  	call parseloadunit_default_sdp
   523 000002E1 7503E98C00              	jz .fn_done_eol		; no filename given, use defaults -->
   524                                  		; al was = '/' or '\' or first pathname's first character
   525                                  		; si-> next char
   526 000002E6 BB[4C05]                	mov bx, load_kernelname_input
   527 000002E9 E83900                  	call .pathname_parse_super
   528                                  
   529 000002EC 56                      	push si
   530 000002ED 50                      	push ax
   531 000002EE E8(0000)                	call skipwh0
   532 000002F1 E8(0000)                	call iseol?
   533 000002F4 58                      	pop ax
   534 000002F5 5E                      	pop si
   535 000002F6 747C                    	je .fn_done
   536                                  
   537 000002F8 BB[5005]                	mov bx, load_addname_input
   538                                  
   539 000002FB E8(0000)                	call skipwh0
   540 000002FE 3C2F                    	cmp al, '/'
   541 00000300 7404                    	je @F
   542 00000302 3C5C                    	cmp al, '\'
   543 00000304 751A                    	jne .proto_not_double_slash
   544                                  @@:
   545 00000306 803C2F                  	cmp byte [si], '/'
   546 00000309 7405                    	je @F
   547 0000030B 803C5C                  	cmp byte [si], '\'
   548 0000030E 7510                    	jne .proto_not_double_slash
   549                                  @@:
   550 00000310 4E                      	dec si
   551 00000311 8937                    	mov word [bx], si
   552 00000313 C7042F2F                	mov word [si], "//"
   553 00000317 46                      	inc si
   554 00000318 46                      	inc si
   555 00000319 AC                      	lodsb
   556 0000031A C644FF00                	mov byte [si - 1], 0
   557 0000031E EB54                    	jmp .fn_done
   558                                  
   559                                  .proto_not_double_slash:
   560 00000320 E80200                  	call .pathname_parse_super
   561 00000323 EB4F                    	jmp .fn_done
   562                                  
   563                                  
   564                                  		; INP:	bx -> word variable to hold filename
   565                                  		; OUT:	word [bx] -> list of /-separated pathnames, zero-terminated
   566                                  		; CHG:	ax, cx, si, di, [es:load_kernel_name]
   567                                  .pathname_parse_super:
   568                                  d4	call d4message
   569                                  d4	asciz "In bootcmd.pathname_parse_super",13,10
   570                                  
   571 00000325 E8(0000)                	call skipwh0
   572 00000328 3C2F                    	cmp al, '/'
   573 0000032A 7404                    	je @F
   574 0000032C 3C5C                    	cmp al, '\'
   575 0000032E 7506                    	jne @FF
   576                                  @@:
   577 00000330 4E                      	dec si
   578 00000331 8937                    	mov word [bx], si
   579 00000333 46                      	inc si
   580 00000334 EB13                    	jmp .pathname_check
   581                                  
   582                                  @@:
   583 00000336 4E                      	dec si
   584 00000337 8937                    	mov word [bx], si
   585                                  
   586                                  .pathname_parse:
   587                                  .pathname_next:
   588                                  d4	call d4message
   589                                  d4	asciz "In bootcmd.pathname_parse",13,10
   590 00000339 E87107                  	call boot_parse_fn
   591 0000033C 7303                    	jnc @F
   592 0000033E 7401                    	je @F			; CY ZR (have slash, si already -> next)
   593 00000340 46                      	inc si			; increment si -> past separator
   594                                  @@:
   595                                  		; al = separator char
   596                                  		; si -> next char after that (if any)
   597 00000341 3C2F                    	cmp al, '/'		; path separator?
   598 00000343 7404                    	je .pathname_check
   599 00000345 3C5C                    	cmp al, '\'
   600 00000347 7517                    	jne .pathname_none	; no, this was the filename -->
   601                                  .pathname_check:
   602                                  d4	call d4message
   603                                  d4	asciz "In bootcmd.pathname_parse_check",13,10
   604 00000349 C644FF2F                	mov byte [si - 1], '/'	; normalise path separator
   605 0000034D AC                      	lodsb
   606 0000034E 3C20                    	cmp al, 32		; space ?
   607 00000350 740E                    	je .pathname_gotfirst
   608 00000352 3C09                    	cmp al, 9
   609 00000354 740A                    	je .pathname_gotfirst	; yes, allow for second name -->
   610 00000356 4E                      	dec si
   611 00000357 E8(0000)                	call iseol?		; EOL ?
   612 0000035A 75DD                    	jne .pathname_next	; no, next pathname element -->
   613 0000035C C60400                  	mov byte [si], 0	; terminate after trailing path sep
   614 0000035F C3                      	retn
   615                                  
   616                                  .pathname_gotfirst:
   617                                  .pathname_none:
   618 00000360 B000                    	mov al, 0
   619 00000362 4E                      	dec si
   620 00000363 8604                    	xchg al, byte [si]	; terminate after filename
   621 00000365 84C0                    	test al, al
   622 00000367 7407                    	jz @F
   623 00000369 8936[0000]              	mov word [terminator_in_line_in.offset], si
   624 0000036D A2[0000]                	mov byte [terminator_in_line_in.value], al
   625                                  @@:
   626 00000370 46                      	inc si
   627 00000371 C3                      	retn
   628                                  
   629                                  
   630                                  		; DPR:word [load_kernelname_input] -> ASCIZ pathname.
   631                                  		; if it ends in '/', append DPR:word [load_kernelname_default]
   632                                  		; DPR:word [load_addname_input] -> ASCIZ pathname.
   633                                  		; if it ends in '/', append DPR:word [load_addname_default]
   634                                  		; if it's empty (and no trailing '/' in front of the zero)
   635                                  		;  then no additional name is given.
   636                                  .fn_done_eol:
   637 00000372 B00D                    	mov al, 13
   638                                  .fn_done:
   639                                  d4	call d4message
   640                                  d4	asciz "In bootcmd.fn_done",13,10
   641                                  
   642 00000374 8326[3205]00            	and word [load_cmdline], 0
   643                                  
   644 00000379 E8(0000)                	call skipwh0
   645 0000037C E8(0000)                	call iseol?.notsemicolon
   646 0000037F 7450                    	je @F
   647                                  
   648 00000381 F606[6902]10            	testopt [load_options], LOAD_CMDLINE
   649 00000386 7509                    	jnz .cmdline
   650 00000388 3C3B                    	cmp al, ';'
   651 0000038A 7403E9(0000)            	jne error
   652 0000038F EB40                    	jmp @F
   653                                  .cmdline:
   654                                  
   655 00000391 B400                    	mov ah, 0
   656 00000393 8826[3E05]              	mov byte [load_cmdline_first], ah
   657 00000397 3C22                    	cmp al, '"'
   658 00000399 7404                    	je .cmdline_quote
   659 0000039B 3C27                    	cmp al, "'"
   660 0000039D 7504                    	jne .cmdline_no_quote
   661                                  .cmdline_quote:
   662 0000039F 88C4                    	mov ah, al
   663 000003A1 EB0B                    	jmp .cmdline_loop_1
   664                                  .cmdline_no_quote:
   665 000003A3 4E                      	dec si
   666 000003A4 8936[3205]              	mov word [load_cmdline], si
   667 000003A8 46                      	inc si
   668 000003A9 A2[3E05]                	mov byte [load_cmdline_first], al
   669 000003AC EB05                    	jmp .cmdline_loop_2
   670                                  
   671                                  .cmdline_loop_1:
   672 000003AE 8936[3205]              	mov word [load_cmdline], si
   673                                  .cmdline_loop:
   674 000003B2 AC                      	lodsb
   675                                  .cmdline_loop_2:
   676 000003B3 E8(0000)                	call iseol?.notsemicolon
   677 000003B6 740E                    	je .cmdline_eol
   678 000003B8 38E0                    	cmp al, ah
   679 000003BA 75F6                    	jne .cmdline_loop
   680                                  .cmdline_quote_eol:
   681 000003BC C644FF00                	mov byte [si - 1], 0
   682 000003C0 AC                      	lodsb
   683 000003C1 E8(0000)                	call chkeol
   684 000003C4 EB0B                    	jmp @F
   685                                  
   686                                  .cmdline_eol:
   687 000003C6 84E4                    	test ah, ah
   688 000003C8 7403E9(0000)            	jnz error
   689 000003CD C644FF00                	mov byte [si - 1], 0
   690                                  
   691                                  @@:
   692 000003D1 F606[0000]07            	testopt [internalflags3], dif3_load_is_dp
   693 000003D6 7527                    	jnz .load_kernel_from_ldp
   694                                  
   695 000003D8 8A1E[3805]              	mov bl, [load_partition]
   696 000003DC 803E[4002]80            	cmp byte [load_unit], 80h
   697 000003E1 7228                    	jb .p_f_is_diskette
   698 000003E3 84DB                    	test bl, bl		; partition specified ?
   699 000003E5 7503E9FAFC              	jz .error		; no, error -->
   700                                  
   701 000003EA E80616                  	call query_geometry
   702                                  
   703 000003ED B9[B20B]                	mov cx, load_freedos_from_partition
   704 000003F0 E85214                  	call scan_partitions
   705 000003F3 BA[0000]                	mov dx, msg.boot_partition_not_found
   706 000003F6 B81102                  	mov ax, 0211h
   707 000003F9 E8(0000)                	call setrc
   708 000003FC E95D01                  	jmp .fail
   709                                  
   710                                  
   711                                  .load_kernel_from_ldp:
   712 000003FF E8F115                  	call query_geometry
   713 00000402 A1[2805]                	mov ax, word [load_partition_sector]
   714 00000405 8B16[2A05]              	mov dx, word [load_partition_sector + 2]
   715 00000409 EB0E                    	jmp @F
   716                                  
   717                                  
   718                                  .p_f_is_diskette:
   719 0000040B 84DB                    	test bl, bl		; partition specified ?
   720 0000040D 7403E9D2FC              	jnz .error		; yes, error -->
   721                                  
   722 00000412 E8DE15                  	call query_geometry
   723                                  
   724 00000415 31C0                    	xor ax, ax
   725 00000417 31D2                    	xor dx, dx
   726                                  @@:
   727 00000419 8B1E[0000]              	mov bx, word [auxbuff_segorsel]	; bx => auxbuff
   728 0000041D 52                      	 push dx
   729 0000041E 50                      	 push ax
   730 0000041F E89D17                  	call read_ae_512_bytes
   731                                  
   732 00000422 26813EFE0155AA          	cmp word [es:510], 0AA55h
   733 00000429 7403E9531C              	jne boot_sigmismatch
   734 0000042E 58                      	 pop ax
   735 0000042F 5A                      	 pop dx
   736                                  
   737                                  %if _LOADER
   738                                  	mov bx, 60h
   739                                  	cmp byte [currentposition], 0
   740                                  	ja .notbottom
   741                                  	mov bx, ds
   742                                  	add bx, word [liiAmountParagraphs]
   743                                  .notbottom:
   744                                  	mov [loader_lowest_free], bx
   745                                  %endif
   746                                  
   747 00000430 06                      	push es
   748 00000431 F606[6902]40            	testopt [load_options], LOAD_SET_DSSI_PARTINFO
   749 00000436 7438                    	jz @F
   750                                  
   751 00000438 50                      	push ax
   752                                  %if _LOADER
   753                                  	mov es, bx
   754                                  	xor di, di
   755                                  	cmp bx, 60h
   756                                  	ja .loader
   757                                  %endif
   758 00000439 31FF                    	xor di, di
   759 0000043B 8EC7                    	mov es, di
   760 0000043D BF0006                  	mov di, 600h
   761                                  .loader:
   762 00000440 B8CD19                  	mov ax, 19CDh
   763 00000443 AB                      	stosw				; fake boot sector loader
   764 00000444 B9FE00                  	mov cx, 508 / 2
   765 00000447 31C0                    	xor ax, ax
   766 00000449 F3AB                    	rep stosw			; initialise pseudo MBR
   767 0000044B B855AA                  	mov ax, 0AA55h
   768 0000044E AB                      	stosw				; fake boot sector signature
   769 0000044F 58                      	pop ax
   770                                  
   771 00000450 8D75BE                  	lea si, [di - 2 - 64]		; -> first partition table entry
   772                                  
   773 00000453 26894408                	mov word [es:si + 8], ax
   774 00000457 2689540A                	mov word [es:si + 8 + 2], dx	; store in partition table entry
   775 0000045B 26C60480                	mov byte [es:si + piBoot], 80h	; fake primary active
   776 0000045F 26C64404FF              	mov byte [es:si + piType], 0FFh	; fake a type
   777 00000464 26FE440C                	inc byte [es:si + piLength]	; fake a size
   778                                  
   779 00000468 8C06[3605]              	mov word [load_partition_entry + 2], es
   780 0000046C 8936[3405]              	mov word [load_partition_entry], si
   781                                  @@:
   782 00000470 07                      	pop es
   783                                  
   784 00000471 E9B707                  	jmp load_freedos_common
   785                                  
   786                                  
   787                                  .load:
   788 00000474 7403E96BFC              	jnz bootcmd.error
   789                                  
   790 00000479 F606[0000]07            	testopt [internalflags3], dif3_load_is_dp
   791 0000047E 751C                    	jnz .load_sector_from_ldp
   792                                  
   793 00000480 803E[3805]00            	cmp byte [load_partition], 0
   794 00000485 7421                    	je .load_boot
   795                                  
   796 00000487 E86915                  	call query_geometry
   797                                  
   798                                  %if _LOADER
   799                                  	cmp byte [currentposition], 0
   800                                  	je ..@loader_bottom_not_allowed
   801                                  %endif
   802                                  
   803                                  d4	call d4message
   804                                  d4	asciz "In bootcmd.load (before call to scan_partitions)",13,10
   805                                  
   806 0000048A B9[3F0B]                	mov cx, load_from_partition
   807 0000048D E8B513                  	call scan_partitions
   808 00000490 BA[0000]                	mov dx, msg.boot_partition_not_found
   809 00000493 B81202                  	mov ax, 0212h
   810 00000496 E8(0000)                	call setrc
   811 00000499 E9C000                  	jmp .fail
   812                                  
   813                                  %if _LOADER
   814                                  ..@loader_bottom_not_allowed:
   815                                  	mov dx, msg.loader_bottom_not_allowed
   816                                  	mov ax, 0288h
   817                                  	jmp @F
   818                                  
   819                                  ..@loader_too_low_load:
   820                                  	mov dx, msg.loader_too_low_load
   821                                  	mov ax, 0289h
   822                                  @@:
   823                                  	call setrc
   824                                  	call putsz_error
   825                                  	jmp cmd3
   826                                  %endif
   827                                  
   828                                  
   829                                  .load_sector_from_ldp:
   830 0000049C E85415                  	call query_geometry
   831 0000049F A1[2805]                	mov ax, word [load_partition_sector]
   832 000004A2 8B16[2A05]              	mov dx, word [load_partition_sector + 2]
   833 000004A6 EB07                    	jmp @F
   834                                  
   835                                  .load_boot:
   836 000004A8 E84815                  	call query_geometry
   837                                  
   838 000004AB 31C0                    	xor ax, ax
   839 000004AD 31D2                    	xor dx, dx
   840                                  @@:
   841                                  
   842                                  %if _LOADER
   843                                  	cmp byte [currentposition], 0
   844                                  	je ..@loader_bottom_not_allowed
   845                                  %endif
   846                                  
   847 000004AF BBC007                  	mov bx, 7C0h
   848                                  d4	call d4dumpregs
   849                                  d4	call d4message
   850                                  d4	asciz 13,10,"In bootcmd.load_boot (before call to read_sector)",13,10
   851 000004B2 52                      	 push dx
   852 000004B3 50                      	 push ax
   853 000004B4 E80817                  	call read_ae_512_bytes
   854                                  d4	call d4message
   855                                  d4	asciz "In bootcmd.load_boot (after call to read_sector)",13,10
   856 000004B7 31D2                    	xor dx, dx
   857 000004B9 8EC2                    	mov es, dx
   858                                  
   859 000004BB A0[4002]                	mov al, byte [load_unit]	; al = boot unit
   860 000004BE BB007C                  	mov bx, 7C00h
   861                                  
   862 000004C1 26813EFE7D55AA          	cmp word [es:7C00h + 510], 0AA55h
   863 000004C8 7403E9B41B              	jne boot_sigmismatch
   864                                  
   865 000004CD 26833F00                	cmp word [es:bx], 0
   866 000004D1 7503E9B71B              	je boot_codemismatch
   867                                  
   868 000004D6 50                      	push ax
   869 000004D7 B9FF00                  	mov cx, 510 / 2
   870 000004DA BF0006                  	mov di, 600h			; MBR location
   871 000004DD 31C0                    	xor ax, ax
   872 000004DF F3AB                    	rep stosw			; initialise (sector and all entries)
   873 000004E1 B855AA                  	mov ax, 0AA55h
   874 000004E4 AB                      	stosw				; initialise boot sector signature
   875 000004E5 26C7060006CD19          	mov word [es:600h], 019CDh	; initialise boot sector code
   876 000004EC BFBE07                  	mov di, 600h + 510 - 4*16	; -> first partition table entry
   877 000004EF 58                      	pop ax
   878 000004F0 268F4508                	 pop word [es:di + piStart]
   879 000004F4 268F450A                	 pop word [es:di + piStart + 2]	; = boot sector LBA
   880 000004F8 26C60580                	mov byte [es:di + 0], 80h	; "bootable" flag set
   881 000004FC 26C64504FF              	mov byte [es:di + 4], 0FFh	; dummy value for FS type (nonzero)
   882 00000501 26C6450C01              	mov byte [es:di + 12], 1	; dummy value for length (nonzero)
   883                                  
   884                                  load_partition_common: equ $
   885 00000506 8126[0000]FFF8          	and word [reg_efl], ~(400h|200h|100h)	; UP, DI, TF=0
   886 0000050C 893E[0000]              	mov word [reg_esi], di
   887 00000510 893E[0000]              	mov word [reg_ebp], di
   888 00000514 890E[0000]              	mov word [reg_ds], cx		; ds:si -> 0:600h + offset to first entry
   889 00000518 A2[0000]                	mov byte [reg_edx], al		; dl = boot unit
   890 0000051B 891E[0000]              	mov word [reg_eip], bx
   891 0000051F 890E[0200]              	mov word [reg_eip + 2], cx
   892 00000523 890E[0000]              	mov word [reg_cs], cx		; cs:eip = 0:7C00h
   893 00000527 803E[3C05]00            	 cmp byte [load_sector_alt], 0
   894 0000052C 740A                    	 je @F
   895 0000052E 890E[0000]              	 mov word [reg_eip], cx
   896 00000532 C706[0000]C007          	 mov word [reg_cs], 7C0h	; cs:eip = 07C0h:0
   897                                  @@:
   898 00000538 891E[0000]              	mov word [reg_esp], bx
   899 0000053C 890E[0200]              	mov word [reg_esp + 2], cx
   900 00000540 890E[0000]              	mov word [reg_ss], cx		; ss:esp = 0:7C00h
   901 00000544 800E[0300]01            	setopt [internalflags2], dif2_boot_loaded_kernel
   902 00000549 C3                      	retn
   903                                  
   904                                  
   905                                  .fail_read:
   906 0000054A 16                      	 push ss
   907 0000054B 07                      	 pop es
   908 0000054C BF[0000]                	mov di, msg.bootfail_read_errorcode
   909 0000054F 88E0                    	mov al, ah
   910 00000551 B404                    	mov ah, 04h
   911 00000553 E8(0000)                	call setrc
   912 00000556 E8(0000)                	call hexbyte
   913 00000559 BA[0000]                	mov dx, msg.bootfail_read
   914                                  
   915                                  .fail:
   916 0000055C 16                      	 push ss
   917 0000055D 07                      	 pop es
   918 0000055E 52                      	push dx
   919 0000055F BA[0000]                	mov dx, msg.bootfail
   920 00000562 E8(0000)                	call putsz_error
   921 00000565 5A                      	pop dx
   922 00000566 E8(0000)                	call putsz_error
   923 00000569 B8FF02                  	mov ax, 02FFh
   924 0000056C E8(0000)                	call setrc
   925 0000056F FF26[0000]              	jmp near word [errret]
   926                                  
   927                                  
   928                                  bootcmd.list:
   929 00000573 E8(0000)                	call skipcomma
   930                                  
   931 00000576 E8F201                  	call parseloadunit_default_sdp
   932 00000579 7403E966FB              	jnz bootcmd.error
   933                                  
   934 0000057E E87214                  	call query_geometry
   935                                  
   936 00000581 F606[0000]07            	testopt [internalflags3], dif3_load_is_dp
   937 00000586 752B                    	jnz .list_ldp
   938                                  
   939 00000588 803E[3805]00            	cmp byte [load_partition], 0
   940 0000058D 741E                    	je .listall
   941                                  
   942 0000058F C606[3A05]00            	mov byte [load_found_partition], 0
   943 00000594 B9[EC05]                	mov cx, list_single_partition
   944 00000597 E8AB12                  	call scan_partitions
   945 0000059A 803E[3A05]00            	cmp byte [load_found_partition], 0
   946 0000059F 750B                    	jne @F
   947 000005A1 BA[0000]                	mov dx, msg.boot_partition_not_found
   948 000005A4 B81302                  	mov ax, 0213h
   949 000005A7 E8(0000)                	call setrc
   950 000005AA EBB0                    	jmp bootcmd.fail
   951                                  @@:
   952 000005AC C3                      	retn
   953                                  
   954                                  .listall:
   955 000005AD B9[FA05]                	mov cx, list_any_partition
   956 000005B0 E99212                  	jmp scan_partitions
   957                                  
   958                                  .list_ldp:
   959 000005B3 C606[3A05]00            	mov byte [load_found_partition], 0
   960 000005B8 B9[D105]                	mov cx, list_partition_if_ldp
   961 000005BB E88712                  	call scan_partitions
   962 000005BE 803E[3A05]00            	cmp byte [load_found_partition], 0
   963 000005C3 750B                    	jne @F
   964 000005C5 BA[0000]                	mov dx, msg.boot_partition_not_found
   965 000005C8 B81402                  	mov ax, 0214h
   966 000005CB E8(0000)                	call setrc
   967 000005CE EB8C                    	jmp bootcmd.fail
   968                                  @@:
   969 000005D0 C3                      	retn
   970                                  
   971                                  
   972                                  list_partition_if_ldp:
   973                                  d4	call d4message
   974                                  d4	asciz "In list_partition_if_ldp",13,10
   975                                  
   976 000005D1 8B43F8                  	mov ax, word [bp + di - 8]
   977 000005D4 8B53FA                  	mov dx, word [bp + di - 6]	; root
   978 000005D7 26034408                	add ax, word [es:si + 8]
   979 000005DB 2613540A                	adc dx, word [es:si + 8 + 2]	; add partition offset
   980 000005DF 3906[2805]              	cmp word [load_partition_sector], ax
   981 000005E3 7506                    	jne @F
   982 000005E5 3916[2A05]              	cmp word [load_partition_sector + 2], dx
   983 000005E9 740B                    	je list_single_partition.gotit
   984                                  @@:
   985 000005EB C3                      	retn
   986                                  
   987                                  list_single_partition:
   988                                  d4	call d4message
   989                                  d4	asciz "In list_single_partition",13,10
   990                                  
   991 000005EC A0[3905]                	mov al, byte [load_current_partition]
   992 000005EF 3A06[3805]              	cmp al, byte [load_partition]
   993 000005F3 7401                    	je .gotit
   994 000005F5 C3                      	retn
   995                                  
   996                                  .gotit:
   997 000005F6 FE06[3A05]              	inc byte [load_found_partition]
   998                                  
   999                                  		; INP:	es:si -> partition table entry,
  1000                                  		;	 si = load_partition_table .. load_partition_table+48,
  1001                                  		;	 es = ss
  1002                                  		;	bp + di -> above part table metadata,
  1003                                  		;	 dwo [bp + di - 4] = root (outermost extended position)
  1004                                  		;	 dwo [bp + di - 8] = base (current table position)
  1005                                  		; CHG:	ax, bx, (cx), dx
  1006                                  list_any_partition:
  1007 000005FA 06                      	 push es
  1008 000005FB 51                      	 push cx
  1009 000005FC 56                      	 push si
  1010 000005FD 57                      	 push di
  1011                                  
  1012 000005FE BF[0000]                	mov di, line_out	; reset di
  1013 00000601 B075                    	mov al, "u"
  1014 00000603 AA                      	stosb
  1015 00000604 A0[4002]                	mov al, byte [load_unit]
  1016 00000607 E8(0000)                	call hexbyte
  1017 0000060A 84C0                    	test al, al
  1018 0000060C B02E                    	mov al, '.'
  1019 0000060E AA                      	stosb
  1020 0000060F 7806                    	js @F
  1021 00000611 B020                    	mov al, 32
  1022 00000613 AA                      	stosb
  1023 00000614 AA                      	stosb
  1024 00000615 EB0D                    	jmp @FF
  1025                                  
  1026                                  @@:
  1027 00000617 A0[3905]                	mov al, byte [load_current_partition]
  1028 0000061A E8(0000)                	call decbyte
  1029 0000061D 3C0A                    	cmp al, 10
  1030 0000061F B020                    	mov al, 32
  1031 00000621 7301                    	jae @F
  1032 00000623 AA                      	stosb
  1033                                  @@:
  1034 00000624 AA                      	stosb
  1035                                  
  1036 00000625 A0[4002]                	mov al, byte [load_unit]
  1037 00000628 50                      	push ax
  1038 00000629 BB6664                  	mov bx, "fd"
  1039 0000062C 3C80                    	cmp al, 80h
  1040 0000062E 7202                    	jb @F
  1041 00000630 B368                    	mov bl, "h"
  1042                                  @@:
  1043 00000632 247F                    	and al, ~80h
  1044 00000634 0461                    	add al, 'a'
  1045 00000636 3C7A                    	cmp al, 'z'
  1046 00000638 760A                    	jbe @F
  1047 0000063A 58                      	pop ax
  1048 0000063B B020                    	mov al, 32
  1049 0000063D B90500                  	mov cx, 3 + 2
  1050 00000640 F3AA                    	rep stosb
  1051 00000642 EB1C                    	jmp .beyondZ
  1052                                  
  1053                                  @@:
  1054 00000644 93                      	xchg ax, bx
  1055 00000645 AB                      	stosw
  1056 00000646 93                      	xchg ax, bx
  1057 00000647 AA                      	stosb
  1058 00000648 58                      	pop ax
  1059 00000649 84C0                    	test al, al
  1060 0000064B 7806                    	js @F
  1061 0000064D B020                    	mov al, 32
  1062 0000064F AA                      	stosb
  1063 00000650 AA                      	stosb
  1064 00000651 EB0D                    	jmp @FF
  1065                                  
  1066                                  @@:
  1067 00000653 A0[3905]                	mov al, byte [load_current_partition]
  1068 00000656 E8(0000)                	call decbyte
  1069 00000659 3C0A                    	cmp al, 10
  1070 0000065B B020                    	mov al, 32
  1071 0000065D 7301                    	jae @F
  1072 0000065F AA                      	stosb
  1073                                  @@:
  1074                                  .beyondZ:
  1075 00000660 AA                      	stosb
  1076                                  
  1077 00000661 8A4404                  	mov al, byte [si + 4]
  1078 00000664 E8(0000)                	call hexbyte
  1079                                  
  1080 00000667 B020                    	mov al, 32
  1081 00000669 AA                      	stosb
  1082                                  
  1083 0000066A 89F9                    	mov cx, di		; (preserve di in line_out)
  1084 0000066C 5F                      	 pop di			; get di of scan_partitions
  1085 0000066D 57                      	 push di
  1086 0000066E 8B43F8                  	mov ax, word [bp + di - 8]
  1087 00000671 8B53FA                  	mov dx, word [bp + di - 6]	; root
  1088 00000674 89CF                    	mov di, cx		; (preserve di in line_out)
  1089 00000676 034408                  	add ax, word [si + 8]
  1090 00000679 13540A                  	adc dx, word [si + 8 + 2]	; add partition offset
  1091 0000067C 92                      	xchg ax, dx
  1092 0000067D E8(0000)                	call hexword
  1093 00000680 92                      	xchg ax, dx
  1094 00000681 E8(0000)                	call hexword
  1095                                  
  1096 00000684 50                      	 push ax
  1097 00000685 B82028                  	mov ax, " ("
  1098 00000688 AB                      	stosw
  1099 00000689 58                      	 pop ax
  1100 0000068A 51                      	  push cx
  1101 0000068B 53                      	  push bx
  1102 0000068C 8B0E[0B02]              	mov cx, [load_sectorsize]
  1103 00000690 BB0800                  	mov bx, 4+4
  1104 00000693 E8(0000)                	call disp_dxax_times_cx_width_bx_size.store
  1105 00000696 50                      	 push ax
  1106 00000697 B82920                  	mov ax, ") "
  1107 0000069A AB                      	stosw
  1108 0000069B 58                      	 pop ax
  1109                                  
  1110 0000069C 52                      	push dx
  1111 0000069D 50                      	push ax
  1112                                  
  1113 0000069E 8B440C                  	mov ax, word [si + 12]
  1114 000006A1 8B540E                  	mov dx, word [si + 12 + 2]
  1115 000006A4 92                      	xchg ax, dx
  1116 000006A5 E8(0000)                	call hexword
  1117 000006A8 92                      	xchg ax, dx
  1118 000006A9 E8(0000)                	call hexword
  1119                                  
  1120 000006AC 50                      	 push ax
  1121 000006AD B82028                  	mov ax, " ("
  1122 000006B0 AB                      	stosw
  1123 000006B1 58                      	 pop ax
  1124 000006B2 E8(0000)                	call disp_dxax_times_cx_width_bx_size.store
  1125 000006B5 B029                    	mov al, ")"
  1126 000006B7 AA                      	stosb
  1127                                  
  1128 000006B8 58                      	pop ax
  1129 000006B9 5A                      	pop dx
  1130                                  
  1131 000006BA 5B                      	  pop bx
  1132 000006BB 59                      	  pop cx
  1133                                  
  1134 000006BC 807C0483                	cmp byte [si + piType], ptLinux
  1135 000006C0 753D                    	jne .notlinux
  1136                                  
  1137 000006C2 8B1E[0000]              	mov bx, word [auxbuff_segorsel]	; bx => auxbuff
  1138 000006C6 E8E514                  	call read_ae_1536_bytes
  1139                                  
  1140 000006C9 26813E380453EF          	cmp word [es:1024 + 56], 0xEF53	; s_magic == EXT2_SUPER_MAGIC ?
  1141 000006D0 7510                    	jne .nolabel_j
  1142                                  
  1143 000006D2 26833E4E0400            	cmp word [es:1024 + 76 + 2], 0
  1144 000006D8 7508                    	jne .nolabel_j
  1145 000006DA 26833E4C0401            	cmp word [es:1024 + 76], 1	; s_rev_level == EXT2_DYNAMIC_REV ?
  1146 000006E0 7402                    	je @F
  1147                                  .nolabel_j:
  1148 000006E2 EB7D                    	jmp .nolabel
  1149                                  @@:
  1150                                  
  1151 000006E4 06                      	push es
  1152 000006E5 1F                      	pop ds
  1153 000006E6 BE7804                  	mov si, 1024 + 120
  1154 000006E9 B91000                  	mov cx, 16
  1155 000006EC 16                      	push ss
  1156 000006ED 07                      	pop es
  1157                                  
  1158 000006EE B020                    	mov al, 32
  1159 000006F0 AA                      	stosb
  1160                                  @@:
  1161 000006F1 AC                      	lodsb
  1162 000006F2 84C0                    	test al, al
  1163 000006F4 7403                    	jz @F
  1164 000006F6 AA                      	stosb
  1165 000006F7 E2F8                    	loop @B
  1166                                  @@:
  1167                                  
  1168 000006F9 16                      	push ss
  1169 000006FA 1F                      	pop ds
  1170                                  
  1171 000006FB 59                      	pop cx
  1172 000006FC 5E                      	pop si
  1173 000006FD 56                      	push si				; get si of scan_partitions
  1174 000006FE 51                      	push cx
  1175                                  
  1176                                  .notlinux:
  1177 000006FF 8A5C04                  	mov bl, byte [si + piType]
  1178 00000702 80FB01                  	cmp bl, ptFAT12
  1179 00000705 7419                    	je .isfat
  1180 00000707 80FB04                  	cmp bl, ptFAT16_16BIT_CHS
  1181 0000070A 7414                    	je .isfat
  1182 0000070C 80FB06                  	cmp bl, ptFAT16_CHS
  1183 0000070F 740F                    	je .isfat
  1184 00000711 80FB0B                  	cmp bl, ptFAT32_CHS
  1185 00000714 740A                    	je .isfat
  1186 00000716 80FB0C                  	cmp bl, ptFAT32
  1187 00000719 7405                    	je .isfat
  1188 0000071B 80FB0E                  	cmp bl, ptFAT16
  1189 0000071E 7541                    	jne .notfat
  1190                                  .isfat:
  1191                                  
  1192 00000720 8B1E[0000]              	mov bx, word [auxbuff_segorsel]	; bx => auxbuff
  1193 00000724 E89814                  	call read_ae_512_bytes
  1194                                  
  1195 00000727 26813EFE0155AA          	cmp word [es:510], 0AA55h
  1196 0000072E 7531                    	jne .nolabel
  1197 00000730 26833E0B0000            	cmp word [es:bsBPB + bpbBytesPerSector], 0
  1198 00000736 7429                    	je .nolabel
  1199 00000738 BE2B00                  	mov si, bsBPB + bpbNew + bpbnVolumeLabel
  1200 0000073B 26833E160000            	cmp word [es:bsBPB + bpbSectorsPerFAT], 0
  1201 00000741 7503                    	jne @F
  1202 00000743 BE4700                  	mov si, bsBPB + ebpbNew + bpbnVolumeLabel
  1203                                  @@:
  1204 00000746 26807CFB29              	cmp byte [es:si - bpbnVolumeLabel + bpbnExtBPBSignature], 29h
  1205 0000074B 7514                    	jne .nolabel
  1206 0000074D B90B00                  	mov cx, 11
  1207                                  
  1208 00000750 06                      	push es
  1209 00000751 1F                      	pop ds
  1210 00000752 16                      	push ss
  1211 00000753 07                      	pop es
  1212                                  
  1213 00000754 B020                    	mov al, 32
  1214 00000756 AA                      	stosb
  1215                                  @@:
  1216 00000757 AC                      	lodsb
  1217 00000758 84C0                    	test al, al
  1218 0000075A 7403                    	jz @F
  1219 0000075C AA                      	stosb
  1220 0000075D E2F8                    	loop @B
  1221                                  @@:
  1222                                  
  1223 0000075F 16                      	push ss
  1224 00000760 1F                      	pop ds
  1225                                  .notfat:
  1226                                  .nolabel:
  1227 00000761 16                      	push ss
  1228 00000762 07                      	pop es
  1229 00000763 E8(0000)                	call putsline_crlf
  1230                                  
  1231 00000766 5F                      	 pop di
  1232 00000767 5E                      	 pop si
  1233 00000768 59                      	 pop cx
  1234 00000769 07                      	 pop es
  1235 0000076A C3                      	retn
  1236                                  
  1237                                  
  1238                                  		; INP:	al = first character
  1239                                  		;	si -> next
  1240                                  		; OUT:	NC
  1241                                  		;	byte [load_unit] set
  1242                                  		;	byte [load_partition] set
  1243                                  		;	 (zero if none specified, -1 if ldp or sdp)
  1244                                  		;	opt [internalflags3] & dif3_load_is_ldp
  1245                                  		;	opt [internalflags3] & dif3_load_is_sdp
  1246                                  		;	dword [load_partition_sector] set if ldp or sdp
  1247                                  		;	ZR if no filename specified (at end of input)
  1248                                  		;	NZ if presumably a filename specified,
  1249                                  		;	 al = first character (slash or whatever non-blank)
  1250                                  		;	 si -> next
  1251                                  		; CHG:	bx, cx, dx, ax, si, di
  1252                                  		; STT:	ds = es = ss
  1253                                  parseloadunit_default_sdp:
  1254 0000076B F8                      	clc
  1255                                  .cf:
  1256 0000076C E82C00                  	call parseloadunit
  1257 0000076F 7329                    	jnc @F
  1258                                  
  1259 00000771 8A16[3D05]              	mov dl, byte [load_sdp_unit]
  1260 00000775 8816[4002]              	mov byte [load_unit], dl
  1261 00000779 FF36[2E05]              	 push word [load_sdp_sector + 2]
  1262 0000077D FF36[2C05]              	 push word [load_sdp_sector]
  1263 00000781 8F06[2805]              	 pop word [load_partition_sector]
  1264 00000785 8F06[2A05]              	 pop word [load_partition_sector + 2]
  1265 00000789 C606[3805]FF            	mov byte [load_partition], -1
  1266 0000078E 800E[0000]02            	or byte [internalflags3], dif3_load_is_sdp
  1267                                  
  1268 00000793 E8(0000)                	call skipwh0
  1269 00000796 E8(0000)                	call iseol?
  1270 00000799 F8                      	clc
  1271                                  @@:
  1272 0000079A C3                      	retn
  1273                                  
  1274                                  
  1275                                  		; INP:	al = first character
  1276                                  		;	si -> next
  1277                                  		;	CY if not to set sdp
  1278                                  		; OUT:	CY if no load unit
  1279                                  		;	 (not "HD[A-Z]", "FD[A-Z]", "LD[P]", "SD[P]", "U[0-9A-F]")
  1280                                  		;	 note: this is barely used!
  1281                                  		;	NC else,
  1282                                  		;	 byte [load_unit] set
  1283                                  		;	 byte [load_partition] set
  1284                                  		;	  (zero if none specified, -1 if ldp or sdp)
  1285                                  		;	 opt [internalflags3] & dif3_load_is_ldp
  1286                                  		;	 opt [internalflags3] & dif3_load_is_sdp
  1287                                  		;	 dword [load_partition_sector] set if ldp or sdp
  1288                                  		;	 ZR if no filename specified (at end of input)
  1289                                  		;	 NZ if presumably a filename specified,
  1290                                  		;	  al = first character (slash or whatever non-blank)
  1291                                  		;	  si -> next
  1292                                  		; CHG:	bx, cx, dx, ax, si, di
  1293                                  		; STT:	ds = es = ss
  1294                                  parseloadunit:
  1295                                  	lframe near
  1296                                  	lvar word,	unit_low_partition_high
  1297                                  	lequ ?unit_low_partition_high,		unit
  1298                                  	lequ ?unit_low_partition_high + 1,	partition
  1299 0000079B 5589E550                	lenter
  1300                                  	lvar word,	bit0_no_set_sdp
  1301 0000079F 9C                      	 pushf
  1302 000007A0 31DB                    	xor bx, bx
  1303                                  	lvar word,	dif3_set
  1304 000007A2 53                      	 push bx
  1305                                  	lvar dword,	load_partition_sector
  1306 000007A3 FF36[2E05]              	 push word [load_sdp_sector + 2]
  1307 000007A7 FF36[2C05]              	 push word [load_sdp_sector]
  1308                                  
  1309 000007AB 89F7                    	mov di, si
  1310 000007AD 8026[0000]F8            	clropt [internalflags3], dif3_load_is_dp
  1311 000007B2 E8(0000)                	call capitalise
  1312 000007B5 3C48                    	cmp al, 'H'
  1313 000007B7 7503E9F100              	je .load_hd
  1314 000007BC 3C46                    	cmp al, 'F'
  1315 000007BE 7503E9E700              	je .load_fd
  1316 000007C3 B401                    	mov ah, dif3_load_is_ldp
  1317 000007C5 3C4C                    	cmp al, 'L'
  1318 000007C7 7419                    	je .load_ld_sd
  1319 000007C9 B402                    	mov ah, dif3_load_is_sdp
  1320 000007CB 3C53                    	cmp al, 'S'
  1321 000007CD 7413                    	je .load_ld_sd
  1322                                  %if _INPUT_FILE_BOOT
  1323 000007CF B404                    	mov ah, dif3_load_is_ydp
  1324 000007D1 3C59                    	cmp al, 'Y'
  1325 000007D3 740D                    	je .load_ld_sd
  1326                                  %endif
  1327 000007D5 3C55                    	cmp al, 'U'
  1328 000007D7 747C                    	je .load_u
  1329                                  .retc:
  1330 000007D9 89FE                    	mov si, di
  1331 000007DB 4E                      	dec si
  1332 000007DC AC                      	lodsb
  1333 000007DD F9                      	stc
  1334                                  .ret:
  1335 000007DE 89EC5D                  	lleave code
  1336 000007E1 C3                      	lret
  1337                                  
  1338                                  .load_ld_sd:
  1339 000007E2 AC                      	lodsb
  1340 000007E3 E8(0000)                	call capitalise
  1341 000007E6 3C44                    	cmp al, 'D'
  1342 000007E8 75EF                    	jne .retc
  1343                                  
  1344                                  d4	call d4message
  1345                                  d4	asciz "In parseloadunit.load_ld_sd",13,10
  1346                                  
  1347 000007EA 8A16[3D05]              	mov dl, byte [load_sdp_unit]
  1348 000007EE 80FC02                  	cmp ah, dif3_load_is_sdp
  1349 000007F1 741D                    	je @F
  1350 000007F3 8A16[A001]              	mov dl, byte [loaddata_loadedfrom - LOADDATA 			+ bsBPB + ebpbNew + bpbnBootUnit]
  1352                                  %if _INPUT_FILE_BOOT
  1353 000007F7 80FC01                  	cmp ah, dif3_load_is_ldp
  1354 000007FA 7414                    	je @F
  1355 000007FC F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  1356 00000801 74D6                    	jz .retc
  1357                                  
  1358 00000803 93                      	xchg ax, bx
  1359 00000804 B8A000                  	mov ax, LOAD_INPUT_FILE_SIZE
  1360 00000807 F726[2005]              	mul word [load_input_file.active]
  1361                                  
  1362                                  ;	test dx, dx
  1363                                  ;	jnz .error
  1364                                  
  1365 0000080B 93                      	xchg ax, bx
  1366 0000080C 8A97[2003]              	mov dl, byte [load_input_file + bx - LOADDATA3 			+ bsBPB + ebpbNew + bpbnBootUnit]
  1368                                  %endif
  1369                                  @@:
  1370 00000810 AC                      	lodsb
  1371 00000811 E8(0000)                	call capitalise
  1372 00000814 3C50                    	cmp al, 'P'
  1373 00000816 7403E9AF00              	jne .got_unit
  1374                                  
  1375                                  d4	call d4message
  1376                                  d4	asciz "In parseloadunit.load_ld_sd with ldp",13,10
  1377                                  
  1378 0000081B 8856FE                  	mov byte [bp + ?unit], dl
  1379 0000081E C646FFFF                	mov byte [bp + ?partition], -1
  1380 00000822 0866FA                  	or byte [bp + ?dif3_set], ah
  1381                                  
  1382 00000825 80FC02                  	cmp ah, dif3_load_is_sdp
  1383 00000828 741D                    	je @F
  1384                                  %if _INPUT_FILE_BOOT
  1385 0000082A 80FC01                  	cmp ah, dif3_load_is_ldp
  1386 0000082D 740A                    	je .is_ldp
  1387 0000082F FFB7[FE02]              	push word [load_input_file + bx - LOADDATA3 			+ bsBPB + bpbHiddenSectors + 2]
  1389 00000833 FFB7[FC02]              	push word [load_input_file + bx - LOADDATA3 			+ bsBPB + bpbHiddenSectors]
  1391 00000837 EB08                    	jmp .is_ldp_ydp
  1392                                  
  1393                                  %endif
  1394                                  .is_ldp:
  1395 00000839 FF36[7E01]              	push word [load_ldp_sector + 2]
  1396 0000083D FF36[7C01]              	push word [load_ldp_sector]
  1397                                  .is_ldp_ydp:
  1398 00000841 8F46F6                  	pop word [bp + ?load_partition_sector]
  1399 00000844 8F46F8                  	pop word [bp + ?load_partition_sector + 2]
  1400                                  @@:
  1401                                  
  1402 00000847 E8(0000)                	call skipwhite
  1403 0000084A E8(0000)                	call iseol?
  1404 0000084D 7403E90701              	jne .fn
  1405 00000852 E90001                  	jmp .ret_nc
  1406                                  
  1407                                  .load_u:
  1408 00000855 AC                      	lodsb
  1409 00000856 E8(0000)                	call capitalise
  1410                                  
  1411 00000859 3C28                    	cmp al, '('
  1412 0000085B 7419                    	je @F
  1413 0000085D 3C30                    	cmp al, '0'
  1414 0000085F 7303E975FF              	jb .retc
  1415 00000864 3C39                    	cmp al, '9'
  1416 00000866 760E                    	jbe @F
  1417 00000868 3C41                    	cmp al, 'A'
  1418 0000086A 7303E96AFF              	jb .retc
  1419 0000086F 3C46                    	cmp al, 'F'
  1420 00000871 7603E963FF              	ja .retc
  1421                                  @@:
  1422                                  
  1423 00000876 3C28                    	cmp al, '('
  1424 00000878 7513                    	jne .u_not_expr
  1425 0000087A AC                      	lodsb
  1426 0000087B E8(0000)[0000]          	nearcall getexpression
  1427 00000880 E8(0000)                	call skipwh0
  1428 00000883 3C29                    	cmp al, ')'
  1429 00000885 AC                      	lodsb
  1430 00000886 7403E958F8              	jne bootcmd.errordec
  1431 0000088B EB03                    	jmp .u_check_dot
  1432                                  
  1433                                  .u_not_expr:
  1434 0000088D E80811                  	call boot_get_hexadecimal_literal
  1435                                  .u_check_dot:
  1436 00000890 3C2E                    	cmp al, '.'
  1437 00000892 7403E94DF8              	jne bootcmd.error
  1438 00000897 AC                      	lodsb
  1439 00000898 85DB                    	test bx, bx
  1440 0000089A 7403E945F8              	jnz bootcmd.error
  1441 0000089F 81FA0001                	cmp dx, 256
  1442 000008A3 7203E93CF8              	jae bootcmd.error
  1443 000008A8 EB20                    	jmp .got_unit
  1444                                  
  1445                                  .load_fd:
  1446 000008AA B200                    	mov dl, 0
  1447                                  
  1448                                  d4	call d4message
  1449                                  d4	asciz "In parseloadunit.load_fd",13,10
  1450                                  
  1451 000008AC A9                      	db __TEST_IMM16		; skip mov
  1452                                  .load_hd:
  1453 000008AD B280                    	mov dl, 80h
  1454                                  d4	call d4message
  1455                                  d4	asciz "In parseloadunit.load_fd or .load_hd",13,10
  1456                                  
  1457 000008AF AC                      	lodsb
  1458 000008B0 E8(0000)                	call capitalise
  1459 000008B3 3C44                    	cmp al, 'D'
  1460 000008B5 7403E91FFF              	jne .retc
  1461 000008BA AC                      	lodsb
  1462 000008BB E8(0000)                	call capitalise
  1463 000008BE 2C41                    	sub al, 'A'
  1464 000008C0 3C19                    	cmp al, 'Z' - 'A'
  1465 000008C2 7603E912FF              	ja .retc
  1466 000008C7 08C2                    	or dl, al			; hdX: 80h + number, fdX: 0 + number
  1467 000008C9 AC                      	lodsb
  1468                                  
  1469                                  .got_unit:
  1470 000008CA 89D1                    	mov cx, dx
  1471 000008CC 884EFE                  	mov byte [bp + ?unit], cl
  1472 000008CF C646FF00                	mov byte [bp + ?partition], 0
  1473 000008D3 3C2F                    	cmp al, '/'			; slash ?
  1474 000008D5 7414                    	je .fn_j
  1475 000008D7 3C5C                    	cmp al, '\'
  1476 000008D9 7410                    	je .fn_j			; got a filename -->
  1477 000008DB 3C20                    	cmp al, 32			; or blank ?
  1478 000008DD 7404                    	je @F
  1479 000008DF 3C09                    	cmp al, 9
  1480 000008E1 750A                    	jne .checkeol			; check for EOL -- but no filename
  1481                                  		;  (hdd1name is invalid -- must be hdd1/name or hdd1 name)
  1482                                  @@:					; was blank
  1483 000008E3 E8(0000)                	call skipwh0			; skip blanks
  1484 000008E6 E8(0000)                	call iseol?			; EOL ?
  1485 000008E9 7402                    	je .checkeol
  1486                                  .fn_j:
  1487 000008EB EB6C                    	jmp .fn				; no, is filename -->
  1488                                  					; will jump after this
  1489                                  .checkeol:
  1490 000008ED E8(0000)                	call iseol?			; EOL ?
  1491 000008F0 7463                    	je .ret_nc			; yes, no filename -->
  1492                                  
  1493 000008F2 3C28                    	cmp al, '('
  1494 000008F4 740E                    	je @F
  1495 000008F6 3C30                    	cmp al, '0'
  1496 000008F8 7303E9DCFE              	jb .retc
  1497 000008FD 3C39                    	cmp al, '9'
  1498 000008FF 7603E9D5FE              	ja .retc
  1499                                  @@:
  1500                                  
  1501                                  d4	call d4message
  1502                                  d4	asciz "In parseloadunit (after no EOL found)",13,10
  1503 00000904 51                      	push cx
  1504 00000905 3C28                    	cmp al, '('
  1505 00000907 751B                    	jne .not_expr
  1506 00000909 AC                      	lodsb				; skip opening paren
  1507                                  
  1508                                  d4	call d4message
  1509                                  d4	asciz "In parseloadunit (before call to getexpression)",13,10
  1510                                  
  1511 0000090A E8(0000)[0000]          	nearcall getexpression
  1512                                  
  1513                                  d4	call d4message
  1514                                  d4	asciz "In parseloadunit (after call to getexpression)",13,10
  1515 0000090F E8(0000)                	call skipwh0
  1516 00000912 3C29                    	cmp al, ')'
  1517 00000914 AC                      	lodsb
  1518 00000915 7509                    	jne .errordec
  1519 00000917 89D1                    	mov cx, dx
  1520 00000919 09D9                    	or cx, bx
  1521 0000091B 750A                    	jnz .got_expr
  1522 0000091D 5A                      	pop dx
  1523 0000091E EBAA                    	jmp .got_unit
  1524                                  
  1525                                  .errordec:
  1526 00000920 4E                      	dec si
  1527                                  .error:
  1528 00000921 E9C0F7                  	jmp bootcmd.error
  1529                                  
  1530                                  .not_expr:
  1531                                  d4	call d4message
  1532                                  d4	asciz "In parseloadunit (before call to boot_get_decimal_literal)",13,10
  1533 00000924 E86910                  	call boot_get_decimal_literal
  1534                                  .got_expr:			; bx:dx = load partition number
  1535                                  d4	call d4message
  1536                                  d4	asciz "In parseloadunit.got_expr",13,10
  1537 00000927 59                      	pop cx			; cl = load unit
  1538 00000928 80F980                  	cmp cl, 80h
  1539 0000092B 7303E9B4F7              	jb bootcmd.error		; diskettes aren't partitioned
  1540 00000930 85DB                    	test bx, bx
  1541 00000932 7403E9ADF7              	jnz bootcmd.error
  1542 00000937 81FAFF00                	cmp dx, 255
  1543 0000093B 7603E9A4F7              	ja bootcmd.error
  1544 00000940 85D2                    	test dx, dx
  1545 00000942 7503E99DF7              	jz bootcmd.error
  1546 00000947 E8(0000)                	call skipwh0
  1547 0000094A 8856FF                  	mov byte [bp + ?partition], dl
  1548 0000094D 884EFE                  	mov byte [bp + ?unit], cl
  1549 00000950 E8(0000)                	call iseol?
  1550 00000953 7504                    	jne .fn
  1551                                  .ret_nc:
  1552 00000955 31DB                    	xor bx, bx		; NC, ZR
  1553 00000957 EB06                    	jmp @F
  1554                                  
  1555                                  .fn:
  1556 00000959 E8(0000)                	call skipwh0
  1557 0000095C 83CB01                  	or bx, 1		; NC, NZ
  1558                                  @@:
  1559 0000095F 9C                      	pushf
  1560 00000960 8B5EFE                  	mov bx, word [bp + ?unit_low_partition_high]
  1561 00000963 881E[4002]              	mov byte [load_unit], bl
  1562 00000967 883E[3805]              	mov byte [load_partition], bh
  1563 0000096B 8A5EFA                  	mov bl, byte [bp + ?dif3_set]
  1564 0000096E 081E[0000]              	or byte [internalflags3], bl
  1565 00000972 F646FC01                	test byte [bp + ?bit0_no_set_sdp], 1
  1566 00000976 750E                    	jnz @F
  1567 00000978 FF76F8                  	 push word [bp + ?load_partition_sector + 2]
  1568 0000097B FF76F6                  	 push word [bp + ?load_partition_sector]
  1569 0000097E 8F06[2C05]              	 pop word [load_sdp_sector]
  1570 00000982 8F06[2E05]              	 pop word [load_sdp_sector + 2]
  1571                                  @@:
  1572 00000986 9D                      	popf			; ZF, CF
  1573 00000987 8F06[2805]              	 pop word [load_partition_sector]
  1574 0000098B 8F06[2A05]              	 pop word [load_partition_sector + 2]
  1575                                  				; pop from ?load_partition_sector
  1576 0000098F E94CFE                  	jmp .ret
  1577                                  
  1578                                  	lleave ctx
  1579                                  
  1580                                  
  1581 00000992 00<rep 2h>              	align 4, db 0
  1582                                  
  1583                                  boot_read:
  1584 00000994 C706[6805][D11B]        	mov word [load_readwrite_function], read_sector
  1585 0000099A EB06                    	jmp boot_readwrite
  1586                                  
  1587                                  boot_write:
  1588 0000099C C706[6805][D01B]        	mov word [load_readwrite_function], write_sector
  1589                                  
  1590                                  boot_readwrite:
  1591                                  
  1592                                  d4	call d4message
  1593                                  d4	asciz "In boot_readwrite",13,10
  1594                                  
  1595 000009A2 E8(0000)                	call skipequals
  1596 000009A5 E8C3FD                  	call parseloadunit_default_sdp
  1597 000009A8 7503E9FD00              	jz .error
  1598                                  
  1599                                  %if 0
  1600                                  	call skipwh0
  1601                                  	mov bx, word [reg_ds]	; default segment
  1602                                  	nearcall getaddr	; get buffer address into bx:(e)dx
  1603                                  
  1604                                  _386_PM	test edx, 0FFFF_0000h
  1605                                  _386_PM	jnz .error
  1606                                  
  1607                                  		; (variable must be a dword!)
  1608                                  	mov word [load_readwrite_buffer], dx
  1609                                  	mov word [load_readwrite_buffer + 2], bx
  1610                                  %else
  1611 000009AD E8(0000)[0000]          	nearcall getword
  1612                                  		; (variable is a word)
  1613 000009B2 8916[6405]              	mov word [load_readwrite_buffer], dx
  1614                                  %endif
  1615                                  
  1616 000009B6 31DB                    	xor bx, bx
  1617 000009B8 53                      	push bx			; hidden specified flag (0)
  1618 000009B9 53                      	push bx
  1619 000009BA 53                      	push bx			; hidden number
  1620 000009BB E8(0000)                	call skipwh0
  1621 000009BE E8(0000)                	call iseol?
  1622 000009C1 750F                    	jne @F
  1623                                  
  1624                                  d4	call d4message
  1625                                  d4	asciz "In boot_readwrite no sector given no count given",13,10
  1626                                  
  1627 000009C3 8326[6005]00            	and word [load_readwrite_sector], 0
  1628 000009C8 8326[6205]00            	and word [load_readwrite_sector + 2], 0
  1629 000009CD BA0100                  	mov dx, 1
  1630 000009D0 EB50                    	jmp @FF
  1631                                  
  1632                                  @@:
  1633 000009D2 BA[0000]                	mov dx, msg.hidden
  1634 000009D5 4E                      	dec si
  1635 000009D6 E8(0000)                	call isstring?
  1636 000009D9 7516                    	jne .nothidden
  1637                                  
  1638 000009DB 83C406                  	add sp, 6		; discard hidden number and specified flag
  1639 000009DE BA0100                  	mov dx, 1
  1640                                  
  1641                                  .hiddencommon:
  1642 000009E1 52                      	push dx			; hidden specified flag (1 or 2)
  1643                                  
  1644 000009E2 E8(0000)                	call skipequals
  1645                                  
  1646 000009E5 E8(0000)[0000]          	nearcall getdword
  1647 000009EA 53                      	push bx
  1648 000009EB 52                      	push dx			; hidden number
  1649 000009EC E8(0000)                	call skipwh0
  1650                                  
  1651 000009EF EB11                    	jmp .hiddendone
  1652                                  .nothidden:
  1653 000009F1 BA[0000]                	mov dx, msg.hiddenadd
  1654 000009F4 E8(0000)                	call isstring?
  1655 000009F7 7508                    	jne .nothiddenadd
  1656                                  
  1657 000009F9 83C406                  	add sp, 6		; discard hidden number and specified flag
  1658 000009FC BA0200                  	mov dx, 2
  1659 000009FF EBE0                    	jmp .hiddencommon
  1660                                  
  1661                                  .nothiddenadd:
  1662 00000A01 AC                      	lodsb
  1663                                  .hiddendone:
  1664 00000A02 E8(0000)[0000]          	nearcall getexpression	; bx:dx = value
  1665                                  
  1666 00000A07 8916[6005]              	mov word [load_readwrite_sector], dx
  1667 00000A0B 891E[6205]              	mov word [load_readwrite_sector + 2], bx
  1668                                  
  1669 00000A0F E8(0000)                	call skipwh0
  1670 00000A12 BA0100                  	mov dx, 1
  1671 00000A15 E8(0000)                	call iseol?
  1672 00000A18 7408                    	je @F
  1673 00000A1A E8(0000)[0000]          	nearcall getword
  1674 00000A1F E8(0000)                	call chkeol
  1675                                  @@:
  1676 00000A22 8916[6605]              	mov word [load_readwrite_count], dx
  1677                                  
  1678 00000A26 E8CA0F                  	call query_geometry
  1679                                  
  1680 00000A29 F606[0000]07            	testopt [internalflags3], dif3_load_is_dp
  1681 00000A2E 753C                    	jnz .ldp
  1682                                  
  1683 00000A30 803E[3805]00            	cmp byte [load_partition], 0
  1684 00000A35 7447                    	je .whole_unit
  1685                                  
  1686 00000A37 C606[3A05]00            	mov byte [load_found_partition], 0
  1687 00000A3C B9[4E0A]                	mov cx, .single_partition
  1688 00000A3F E8030E                  	call scan_partitions
  1689                                  ;	cmp byte [load_found_partition], 0
  1690                                  ;	jne @F
  1691 00000A42 BA[0000]                	mov dx, msg.boot_partition_not_found
  1692 00000A45 B81502                  	mov ax, 0215h
  1693 00000A48 E8(0000)                	call setrc
  1694 00000A4B E90EFB                  	jmp bootcmd.fail
  1695                                  ;@@:
  1696                                  ;	retn
  1697                                  
  1698                                  
  1699                                  .single_partition:
  1700                                  		; INP:	es:si -> partition table entry,
  1701                                  		;	 si = load_partition_table .. load_partition_table+48,
  1702                                  		;	 es = ss
  1703                                  		;	bp + di -> above part table metadata,
  1704                                  		;	 dwo [bp + di - 4] = root (outermost extended position)
  1705                                  		;	 dwo [bp + di - 8] = base (current table position)
  1706                                  		;; CHG:	ax, bx, (cx), dx
  1707                                  		; CHG:	all
  1708                                  
  1709                                  d4	call d4message
  1710                                  d4	asciz "In boot_readwrite.single_partition",13,10
  1711                                  
  1712 00000A4E A0[3905]                	mov al, byte [load_current_partition]
  1713 00000A51 3A06[3805]              	cmp al, byte [load_partition]
  1714 00000A55 7401                    	je .gotit
  1715 00000A57 C3                      	retn
  1716                                  
  1717                                  .gotit:
  1718                                  d4	call d4message
  1719                                  d4	asciz "In boot_readwrite.gotit",13,10
  1720                                  
  1721                                  ;	inc byte [load_found_partition]
  1722                                  
  1723 00000A58 8B43F8                  	mov ax, [bp + di - 8]
  1724 00000A5B 8B53FA                  	mov dx, [bp + di - 6]		; base (current table position)
  1725                                  
  1726 00000A5E 26034408                	add ax, [es:si + 8]
  1727 00000A62 2613540A                	adc dx, [es:si + 8 + 2]		; add offset to logical partition
  1728                                  
  1729 00000A66 89EC                    	mov sp, bp
  1730 00000A68 5D                      	pop bp				; restore bp (scan_partitions)
  1731 00000A69 5B                      	pop bx				; discard ret address (scan_partitions)
  1732 00000A6A EB07                    	jmp .gotbase_dxax
  1733                                  
  1734                                  
  1735                                  .ldp:
  1736 00000A6C A1[2805]                	mov ax, word [load_partition_sector]
  1737 00000A6F 8B16[2A05]              	mov dx, word [load_partition_sector + 2]
  1738                                  
  1739                                  .gotbase_dxax:
  1740 00000A73 89461C                  	mov word [bp + bsBPB + bpbHiddenSectors + 0], ax
  1741 00000A76 89561E                  	mov word [bp + bsBPB + bpbHiddenSectors + 2], dx
  1742 00000A79 800E[0000]80            	setopt [internalflags3], dif3_partition_changed
  1743                                  
  1744                                  .whole_unit:
  1745 00000A7E 5A                      	pop dx
  1746 00000A7F 5B                      	pop bx				; hidden number (or zero)
  1747 00000A80 59                      	pop cx				; hidden specified flag
  1748 00000A81 E30F                    	jcxz @FF			; if not specified -->
  1749 00000A83 49                      	dec cx				; hidden flag is 1 ?
  1750 00000A84 7406                    	jz @F				; yes, replacce -->
  1751 00000A86 03561C                  	add dx, word [bp + bsBPB + bpbHiddenSectors + 0]
  1752 00000A89 135E1E                  	adc bx, word [bp + bsBPB + bpbHiddenSectors + 2]
  1753                                  					; add to hidden (HIDDENADD=)
  1754                                  
  1755                                  @@:
  1756 00000A8C 89561C                  	mov word [bp + bsBPB + bpbHiddenSectors + 0], dx
  1757 00000A8F 895E1E                  	mov word [bp + bsBPB + bpbHiddenSectors + 2], bx
  1758                                  					; overwrite hidden number with this
  1759                                  @@:
  1760                                  
  1761 00000A92 A1[6005]                	mov ax, word [load_readwrite_sector]
  1762 00000A95 8B16[6205]              	mov dx, word [load_readwrite_sector + 2]
  1763 00000A99 8B0E[6605]              	mov cx, word [load_readwrite_count]
  1764 00000A9D 8B1E[6405]              	mov bx, word [load_readwrite_buffer]
  1765                                  
  1766 00000AA1 E306                    	jcxz @FF
  1767                                  @@:
  1768 00000AA3 FF16[6805]              	call near word [load_readwrite_function]
  1769 00000AA7 E2FA                    	loop @B
  1770                                  @@:
  1771 00000AA9 C3                      	retn
  1772                                  
  1773                                  .error:
  1774 00000AAA E9(0000)                	jmp error
  1775                                  
  1776                                  
  1777                                  		; INP:	ds:si-> first letter of name
  1778                                  		;	es:load_kernel_name-> 12-byte buffer (for fn + 0)
  1779                                  		; CHG:	ax, cx, di
  1780                                  		; OUT:	CY if dot EOL, dot blank, or dot/
  1781                                  		;	 al = first text byte after dot (EOL, blank, or slash)
  1782                                  		;	 ZR if dot/,
  1783                                  		;	  si -> next text byte after slash
  1784                                  		;	 NZ if dot EOL or dot blank,
  1785                                  		;	  si -> first text byte after dot (*NOT* next)
  1786                                  		;	 (load_kernel_name rese to empty)
  1787                                  		;	NC if not a single dot component,
  1788                                  		;	 al = first text byte after name (EOL, blank, or slash)
  1789                                  		;	 si -> next text byte after name, if any
  1790                                  		;	 load_kernel_name filled with FCB formatted name
  1791                                  		;	branches to bootcmd.fail on syntax errors
  1792                                  boot_parse_fn: section_of_function
  1793 00000AAD B020                    	mov al, 32
  1794 00000AAF BF[4005]                	mov di, load_kernel_name
  1795 00000AB2 B90B00                  	mov cx, 11
  1796 00000AB5 F3AA                    	rep stosb		; initialise to empty
  1797                                  
  1798 00000AB7 BF[4005]                	mov di, load_kernel_name
  1799 00000ABA B90900                  	mov cx, 9
  1800 00000ABD AC                      	lodsb
  1801 00000ABE 3C2E                    	cmp al, '.'
  1802 00000AC0 7514                    	jne @F
  1803 00000AC2 AC                      	lodsb
  1804 00000AC3 E86500                  	call .separator_or_slash
  1805 00000AC6 751D                    	jne .invalid
  1806 00000AC8 3C2F                    	cmp al, '/'
  1807 00000ACA 7407                    	je .dotret		; --> ZR
  1808 00000ACC 3C5C                    	cmp al, '\'
  1809 00000ACE 7403                    	je .dotret		; --> ZR
  1810 00000AD0 8D74FF                  	lea si, [si - 1]	; NZ, -> at separator (first text after dot)
  1811                                  .dotret:
  1812 00000AD3 F9                      	stc			; CY return
  1813 00000AD4 C3                      	retn
  1814                                  
  1815                                  
  1816                                  .loop_name:
  1817 00000AD5 AC                      	lodsb
  1818                                  @@:
  1819 00000AD6 E8(0000)                	call capitalise
  1820 00000AD9 E84F00                  	call .separator_or_slash
  1821 00000ADC 7435                    	je .loop_name_done
  1822 00000ADE 3C2E                    	cmp al, '.'
  1823 00000AE0 740F                    	je .loop_name_ext
  1824 00000AE2 AA                      	stosb
  1825 00000AE3 E2F0                    	loop .loop_name
  1826                                  .invalid:
  1827 00000AE5 BA[0000]                	mov dx, msg.boot_invalid_filename
  1828 00000AE8 B81602                  	mov ax, 0216h
  1829 00000AEB E8(0000)                	call setrc
  1830 00000AEE E96BFA                  	jmp bootcmd.fail
  1831                                  
  1832                                  .loop_name_ext:
  1833 00000AF1 83F909                  	cmp cx, 9
  1834 00000AF4 74EF                    	je .invalid
  1835 00000AF6 B90400                  	mov cx, 4
  1836 00000AF9 BF[4805]                	mov di, load_kernel_name + 8
  1837                                  .loop_ext:
  1838 00000AFC AC                      	lodsb
  1839 00000AFD E8(0000)                	call capitalise
  1840 00000B00 E82800                  	call .separator_or_slash
  1841 00000B03 7409                    	je .loop_ext_done
  1842 00000B05 3C2E                    	cmp al, '.'
  1843 00000B07 74DC                    	je .invalid
  1844 00000B09 AA                      	stosb
  1845 00000B0A E2F0                    	loop .loop_ext
  1846 00000B0C EBD7                    	jmp .invalid
  1847                                  
  1848                                  .loop_ext_done:
  1849 00000B0E 83F904                  	cmp cx, 4
  1850 00000B11 74D2                    	je .invalid
  1851                                  .loop_name_done:
  1852 00000B13 83F909                  	cmp cx, 9
  1853 00000B16 74CD                    	je .invalid
  1854 00000B18 C606[4B05]00            	mov byte [load_kernel_name + 11], 0
  1855 00000B1D 803E[4005]E5            	cmp byte [load_kernel_name], 0E5h
  1856 00000B22 7505                    	jne @F
  1857 00000B24 C606[4005]05            	mov byte [load_kernel_name], 05h
  1858                                  @@:
  1859 00000B29 F8                      	clc			; NC return
  1860 00000B2A C3                      	retn
  1861                                  
  1862                                  .separator_or_slash:
  1863 00000B2B E8(0000)                	call iseol?
  1864 00000B2E 740E                    	je @F
  1865 00000B30 3C20                    	cmp al, 32
  1866 00000B32 740A                    	je @F
  1867 00000B34 3C09                    	cmp al, 9
  1868 00000B36 7406                    	je @F
  1869 00000B38 3C2F                    	cmp al, '/'
  1870 00000B3A 7402                    	je @F
  1871 00000B3C 3C5C                    	cmp al, '\'
  1872                                  @@:
  1873 00000B3E C3                      	retn
  1874                                  
  1875                                  
  1876                                  		; INP:	es:si -> partition table entry,
  1877                                  		;	 si = load_partition_table .. load_partition_table+48,
  1878                                  		;	 es = ss
  1879                                  		;	bp + di -> above part table metadata,
  1880                                  		;	 dwo [bp + di - 4] = root (outermost extended position)
  1881                                  		;	 dwo [bp + di - 8] = base (current table position)
  1882                                  		; CHG:	ax, bx, (cx), dx
  1883                                  load_from_partition:
  1884                                  d4	call d4message
  1885                                  d4	asciz "In load_from_partition",13,10
  1886                                  
  1887 00000B3F A0[3905]                	mov al, byte [load_current_partition]
  1888 00000B42 3A06[3805]              	cmp al, byte [load_partition]
  1889 00000B46 7401                    	je .gotit
  1890 00000B48 C3                      	retn
  1891                                  
  1892                                  .gotit:
  1893                                  d4	call d4message
  1894                                  d4	asciz "In load_from_partition.gotit",13,10
  1895                                  
  1896 00000B49 8B43F8                  	mov ax, [bp + di - 8]
  1897 00000B4C 8B53FA                  	mov dx, [bp + di - 6]		; base (current table position)
  1898                                  
  1899 00000B4F 52                      	push dx
  1900 00000B50 50                      	push ax
  1901 00000B51 06                      	push es
  1902 00000B52 BB6000                  	mov bx, 60h
  1903 00000B55 E86710                  	call read_ae_512_bytes		; load partition table to 0:600h
  1904 00000B58 07                      	pop es
  1905 00000B59 58                      	pop ax
  1906 00000B5A 5A                      	pop dx
  1907                                  
  1908 00000B5B 26034408                	add ax, [es:si + 8]
  1909 00000B5F 2613540A                	adc dx, [es:si + 8 + 2]		; add offset to logical partition
  1910                                  
  1911 00000B63 26894408                	mov word [es:si + 8], ax
  1912 00000B67 2689540A                	mov word [es:si + 8 + 2], dx	; store in partition table entry
  1913                                  
  1914 00000B6B 31C9                    	xor cx, cx
  1915 00000B6D 8EC1                    	mov es, cx			; es = 0
  1916                                  %if _LINK_COMPAT
  1917 00000B6F 8DB4BE07                	lea si, [si + 600h + (510 - 64)]
  1918 00000B73 81EE[0001]              	sub si, load_partition_table
  1919                                  %else
  1920                                  	lea si, [si - (load_partition_table + DATASECTIONFIXUP) + 600h + (510 - 64)]
  1921                                  %endif
  1922                                  					; si = 600h + 510-64 .. 600h + 510-16
  1923 00000B77 26894408                	mov word [es:si + 8], ax
  1924 00000B7B 2689540A                	mov word [es:si + 8 + 2], dx	; store in partition table entry
  1925                                  
  1926                                  					; dx:ax = absolute sector number
  1927 00000B7F BBC007                  	mov bx, 7C0h			; bx:0 = 7C0h:0 -> boot sector area
  1928 00000B82 E83A10                  	call read_ae_512_bytes		; load partition boot sector to 0:7C00h
  1929                                  
  1930 00000B85 89EC                    	mov sp, bp
  1931 00000B87 5D                      	pop bp				; restore bp (scan_partitions)
  1932 00000B88 58                      	pop ax				; discard ret address (scan_partitions)
  1933                                  
  1934 00000B89 26813EFE0155AA          	cmp word [es:510], 0AA55h
  1935 00000B90 7403E9EC14              	jne boot_sigmismatch
  1936                                  
  1937 00000B95 31C9                    	xor cx, cx
  1938 00000B97 26390E0000              	cmp word [es:0], cx
  1939 00000B9C 7503E9EC14              	je boot_codemismatch
  1940                                  
  1941 00000BA1 8EC1                    	mov es, cx			; cx = 0, es = 0
  1942 00000BA3 89F7                    	mov di, si			; di -> partition table entry (seg 0)
  1943 00000BA5 26800D80                	or byte [es:di + 0], 80h	; set bootable flag
  1944 00000BA9 A0[4002]                	mov al, byte [load_unit]	; al = unit
  1945 00000BAC BB007C                  	mov bx, 7C00h			; bx = 7C00h
  1946 00000BAF E954F9                  	jmp load_partition_common
  1947                                  
  1948                                  
  1949                                  		; INP:	es:si -> partition table entry,
  1950                                  		;	 si = load_partition_table .. load_partition_table+48,
  1951                                  		;	 es = ss
  1952                                  		;	bp + di -> above part table metadata,
  1953                                  		;	 dwo [bp + di - 4] = root (outermost extended position)
  1954                                  		;	 dwo [bp + di - 8] = base (current table position)
  1955                                  		; CHG:	ax, bx, (cx), dx
  1956                                  load_freedos_from_partition:
  1957                                  d4	call d4message
  1958                                  d4	asciz "In load_freedos_from_partition",13,10
  1959                                  
  1960 00000BB2 A0[3905]                	mov al, byte [load_current_partition]
  1961 00000BB5 3A06[3805]              	cmp al, byte [load_partition]
  1962 00000BB9 7401                    	je .gotit
  1963 00000BBB C3                      	retn
  1964                                  
  1965                                  .gotit:
  1966                                  d4	call d4message
  1967                                  d4	asciz "In load_freedos_from_partition.gotit",13,10
  1968                                  
  1969 00000BBC 8B43F8                  	mov ax, [bp + di - 8]
  1970 00000BBF 8B53FA                  	mov dx, [bp + di - 6]		; base (current table position)
  1971                                  
  1972 00000BC2 26034408                	add ax, [es:si + 8]
  1973 00000BC6 2613540A                	adc dx, [es:si + 8 + 2]		; add offset to logical partition
  1974                                  
  1975 00000BCA 26894408                	mov word [es:si + 8], ax
  1976 00000BCE 2689540A                	mov word [es:si + 8 + 2], dx	; store in partition table entry
  1977 00000BD2 26800C80                	or byte [es:si + 0], 80h	; set bootable flag
  1978                                  
  1979                                  %if _LOADER
  1980                                  	mov bx, 60h
  1981                                  	cmp byte [currentposition], 0
  1982                                  	ja .notbottom
  1983                                  	mov bx, ds
  1984                                  	add bx, word [liiAmountParagraphs]
  1985                                  .notbottom:
  1986                                  	mov [loader_lowest_free], bx
  1987                                  %endif
  1988                                  
  1989 00000BD6 F606[6902]40            	testopt [load_options], LOAD_SET_DSSI_PARTINFO
  1990 00000BDB 7431                    	jz @F
  1991                                  
  1992 00000BDD 52                      	push dx
  1993 00000BDE 50                      	push ax
  1994                                  
  1995 00000BDF 8B43F8                  	mov ax, [bp + di - 8]
  1996 00000BE2 8B53FA                  	mov dx, [bp + di - 6]		; base (current table position)
  1997                                  
  1998 00000BE5 52                      	push dx
  1999 00000BE6 50                      	push ax
  2000 00000BE7 06                      	push es
  2001                                  %if _LOADER
  2002                                  	mov bx, [loader_lowest_free]
  2003                                  	push bx
  2004                                  %else
  2005 00000BE8 BB6000                  	mov bx, 60h
  2006                                  %endif
  2007 00000BEB E8D10F                  	call read_ae_512_bytes		; load partition table to 0:600h
  2008                                  %if _LOADER
  2009                                  	pop cx
  2010                                  	mov [loader_lowest_free], bx
  2011                                  %endif
  2012 00000BEE 07                      	pop es
  2013 00000BEF 58                      	pop ax
  2014 00000BF0 5A                      	pop dx
  2015                                  
  2016                                  %if _LOADER
  2017                                  	mov es, cx
  2018                                  %if _LINK_COMPAT
  2019                                  	lea di, [si + (510 - 64)]
  2020                                  	sub di, load_partition_table
  2021                                  %else
  2022                                  	lea di, [si - (load_partition_table + DATASECTIONFIXUP) + (510 - 64)]
  2023                                  %endif
  2024                                  					; si = 510-64 .. 600h + 510-16
  2025                                  	cmp byte [currentposition], 0
  2026                                  	jbe .loader
  2027                                  %endif
  2028 00000BF1 31C9                    	xor cx, cx
  2029 00000BF3 8EC1                    	mov es, cx			; es = 0
  2030                                  %if _LINK_COMPAT
  2031 00000BF5 8DBCBE07                	lea di, [si + 600h + (510 - 64)]
  2032 00000BF9 81EF[0001]              	sub di, load_partition_table
  2033                                  %else
  2034                                  	lea di, [si - (load_partition_table + DATASECTIONFIXUP) + 600h + (510 - 64)]
  2035                                  %endif
  2036                                  					; si = 600h + 510-64 .. 600h + 510-16
  2037                                  .loader:
  2038 00000BFD B90800                  	mov cx, 16 / 2
  2039 00000C00 06                      	 push es
  2040 00000C01 57                      	 push di
  2041 00000C02 F3A5                    	rep movsw
  2042 00000C04 8F06[3405]              	 pop word [load_partition_entry]
  2043 00000C08 8F06[3605]              	 pop word [load_partition_entry + 2]
  2044                                  
  2045 00000C0C 58                      	pop ax
  2046 00000C0D 5A                      	pop dx
  2047                                  @@:
  2048                                  
  2049                                  
  2050 00000C0E 89EC                    	mov sp, bp
  2051 00000C10 5D                      	pop bp				; restore bp (scan_partitions)
  2052 00000C11 5B                      	pop bx				; discard ret address (scan_partitions)
  2053                                  
  2054                                  					; dx:ax = absolute sector number
  2055 00000C12 8B1E[0000]              	mov bx, word [auxbuff_segorsel]	; bx => auxbuff
  2056 00000C16 50                      	push ax
  2057 00000C17 52                      	push dx
  2058 00000C18 E8A40F                  	call read_ae_512_bytes		; load partition boot sector
  2059                                  
  2060 00000C1B 26813EFE0155AA          	cmp word [es:510], 0AA55h
  2061 00000C22 7403E95A14              	jne boot_sigmismatch
  2062                                  
  2063 00000C27 31C9                    	xor cx, cx
  2064                                  ;	cmp word [es:0], cx
  2065                                  ;	je boot_codemismatch
  2066                                  
  2067 00000C29 5A                      	pop dx
  2068 00000C2A 58                      	pop ax
  2069                                  
  2070                                  		; dx:ax = boot sector
  2071                                  		; byte [load_unit] = unit
  2072                                  		; es:0-> read sector
  2073                                  load_freedos_common:
  2074 00000C2B 26A31C00                	mov word [es:bsBPB + bpbHiddenSectors], ax
  2075 00000C2F 2689161E00              	mov word [es:bsBPB + bpbHiddenSectors + 2], dx
  2076                                  
  2077 00000C34 8B5E0B                  	mov bx, [bp + bsBPB + bpbBytesPerSector]
  2078 00000C37 263B1E0B00              	cmp bx, [es:bsBPB + bpbBytesPerSector]
  2079 00000C3C 7403E95414              	jne boot_secsizemismatch
  2080                                  
  2081                                  		; preserve some variables from our pseudo BPB
  2082 00000C41 31C0                    	xor ax, ax
  2083 00000C43 FF7618                  	push word [bp + bsBPB + bpbCHSSectors]
  2084 00000C46 268F061800              	pop word [es:bsBPB + bpbCHSSectors]
  2085 00000C4B FF761A                  	push word [bp + bsBPB + bpbCHSHeads]
  2086 00000C4E 268F061A00              	pop word [es:bsBPB + bpbCHSHeads]	; preserve geometry
  2087                                  
  2088 00000C53 8B5EEA                  	mov bx, word [bp + ldParaPerSector]
  2089 00000C56 D1EB                    	shr bx, 1
  2090 00000C58 895ED4                  	mov word [bp + ldEntriesPerSector], bx
  2091                                  
  2092 00000C5B 2639061600              	cmp word [es:bsBPB + bpbSectorsPerFAT], ax
  2093 00000C60 8A5E40                  	mov bl, byte [bp + bsBPB + ebpbNew + bpbnBootUnit]
  2094 00000C63 7407                    	je .is_fat32
  2095 00000C65 26881E2400              	mov byte [es:bsBPB + bpbNew + bpbnBootUnit], bl
  2096 00000C6A EB05                    	jmp short .was_fat1612
  2097                                  .is_fat32:
  2098 00000C6C 26881E4000              	mov byte [es:bsBPB + ebpbNew + bpbnBootUnit], bl
  2099                                  .was_fat1612:
  2100                                  
  2101 00000C71 06                      	 push es
  2102 00000C72 1E                      	 push ds
  2103 00000C73 06                      	push es
  2104 00000C74 1F                      	pop ds
  2105 00000C75 31F6                    	xor si, si				; -> BPB from boot partition
  2106 00000C77 16                      	push ss
  2107 00000C78 07                      	pop es
  2108 00000C79 BF[0002]                	mov di, load_data - LOADDATA2		; -> our copy of a BPB
  2109 00000C7C B95A00                  	mov cx, (bsBPB + ebpbNew + BPBN_size)
  2110 00000C7F F3A4                    	rep movsb				; get the BPB
  2111                                  
  2112 00000C81 1F                      	 pop ds
  2113 00000C82 800E[0000]80            	setopt [internalflags3], dif3_partition_changed
  2114                                  
  2115 00000C87 394616                  	cmp word [bp + bsBPB + bpbSectorsPerFAT], ax
  2116 00000C8A 740B                    	je @F					; is FAT32 -->
  2117 00000C8C BE[2402]                	mov si, load_data - LOADDATA2 + bsBPB + bpbNew
  2118 00000C8F BF[4002]                	mov di, load_data - LOADDATA2 + bsBPB + ebpbNew
  2119 00000C92 B91A00                  	mov cx, BPBN_size
  2120 00000C95 F3A4                    	rep movsb				; clone the FAT16 / FAT12 BPBN
  2121                                  						; to where the FAT32 BPBN lives
  2122                                  @@:
  2123 00000C97 07                      	 pop es
  2124                                  
  2125 00000C98 E8(0000)                	call bootgetmemorysize
  2126 00000C9B 8956E0                  	mov word [bp + ldMemoryTop], dx
  2127 00000C9E 81EA0005                	sub dx, (20 * 1024) >> 4
  2128                                  		; leave 20 KiB free at the top, to
  2129                                  		; allow loading with the lDOS protocol (needs BPB and FAT seg
  2130                                  		; to live below its destination buffers for these)
  2131 00000CA2 7303                    	jnc @F
  2132                                  .outofmem:
  2133 00000CA4 E9CD0E                  	jmp query_geometry.out_of_memory_error
  2134                                  @@:
  2135                                  
  2136                                  %if _LOADER
  2137                                  	cmp byte [currentposition], 1
  2138                                  	jne @F
  2139                                  	mov ax, ss
  2140                                  	cmp dx, ax
  2141                                  	jbe @F
  2142                                  	xchg dx, ax
  2143                                  @@:
  2144                                  %endif
  2145                                  
  2146 00000CA7 81EA0002                	sub dx, 8192 >> 4
  2147 00000CAB 72F7                    	jc .outofmem
  2148 00000CAD 8956F8                  	mov word [bp + lsvFATSeg], dx
  2149 00000CB0 B8FFFF                  	mov ax, -1
  2150 00000CB3 8946F4                  	mov word [bp + lsvFATSector], ax
  2151 00000CB6 8946F6                  	mov word [bp + lsvFATSector + 2], ax
  2152                                  
  2153 00000CB9 A1[6A02]                	mov ax, word [load_loadseg]
  2154 00000CBC 8946FA                  	mov word [bp + lsvLoadSeg], ax
  2155                                  %if _LOADER
  2156                                  	cmp ax, [loader_lowest_free]
  2157                                  	jb ..@loader_too_low_load
  2158                                  %endif
  2159 00000CBF 31DB                    	xor bx, bx
  2160 00000CC1 B98000                  	mov cx, ((256 + 15) & ~15) >> 1
  2161 00000CC4 F606[6902]20            	testopt [load_options], LOAD_NO_BPB
  2162 00000CC9 7506                    	jnz @F
  2163 00000CCB BB0002                  	mov bx, 512
  2164 00000CCE B98001                  	mov cx, ((512 + 256 + 15) & ~15) >> 1
  2165                                  @@:
  2166 00000CD1 F606[6902]10            	testopt [load_options], LOAD_CMDLINE
  2167 00000CD6 7404                    	jz @F
  2168 00000CD8 81C18000                	add cx, (256) >> 1
  2169                                  @@:
  2170                                  
  2171 00000CDC 833E[7202]FF            	cmp word [load_bpb + 2], -1
  2172 00000CE1 7475                    	je .auto_bpb
  2173                                  
  2174 00000CE3 A1[7002]                	mov ax, [load_bpb]
  2175 00000CE6 D1E8                    	shr ax, 1
  2176 00000CE8 D1E8                    	shr ax, 1
  2177 00000CEA D1E8                    	shr ax, 1
  2178 00000CEC D1E8                    	shr ax, 1		; round down: start of BPB
  2179 00000CEE 0306[7202]              	add ax, [load_bpb + 2]	; start of BPB
  2180 00000CF2 83E810                  	sub ax, (256) >> 4	; start of stack area
  2181 00000CF5 720A                    	jc @F
  2182 00000CF7 F606[6902]10            	testopt [load_options], LOAD_CMDLINE
  2183 00000CFC 7403                    	jz @F
  2184 00000CFE 83E810                  	sub ax, (256) >> 4
  2185                                  @@:
  2186 00000D01 50                      	push ax
  2187 00000D02 7235                    	jc .bpb_too_low
  2188                                  
  2189 00000D04 3B46FA                  	cmp ax, word [bp + lsvLoadSeg]
  2190 00000D07 773B                    	ja .loads_below_bpb
  2191                                  
  2192                                  %if _LOADER
  2193                                  	cmp ax, [loader_lowest_free]
  2194                                  %else
  2195 00000D09 83F860                  	cmp ax, 60h
  2196                                  %endif
  2197 00000D0C 722B                    	jb .bpb_too_low
  2198                                  
  2199 00000D0E A1[7002]                	mov ax, [load_bpb]
  2200 00000D11 01D8                    	add ax, bx
  2201 00000D13 83C00F                  	add ax, 15
  2202 00000D16 D1E8                    	shr ax, 1
  2203 00000D18 D1E8                    	shr ax, 1
  2204 00000D1A D1E8                    	shr ax, 1
  2205 00000D1C D1E8                    	shr ax, 1
  2206 00000D1E 0306[7202]              	add ax, [load_bpb + 2]	; end of BPB / pseudo-boot-sector
  2207                                  
  2208 00000D22 3B46FA                  	cmp ax, word [bp + lsvLoadSeg]
  2209 00000D25 761F                    	jbe .loads_above_bpb
  2210                                  
  2211 00000D27 BA[0000]                	mov dx, msg.boot_bpb_load_overlap
  2212 00000D2A B81702                  	mov ax, 0217h
  2213 00000D2D E8(0000)                	call setrc
  2214                                  .fail:
  2215 00000D30 B81802                  	mov ax, 0218h
  2216 00000D33 E8(0000)                	call setrc
  2217 00000D36 E923F8                  	jmp bootcmd.fail
  2218                                  
  2219                                  .bpb_too_low:
  2220 00000D39 BA[0000]                	mov dx, msg.boot_bpb_too_low
  2221 00000D3C B81902                  	mov ax, 0219h
  2222 00000D3F E8(0000)                	call setrc
  2223 00000D42 EBEC                    	jmp .fail
  2224                                  
  2225                                  
  2226                                  
  2227                                  .loads_below_bpb:
  2228 00000D44 89C2                    	mov dx, ax		; set load top to before BPB/lsv/stack
  2229                                  
  2230                                  .loads_above_bpb:		; dx = word [bp + ldLoadTop] = word [bp + lsvFATSeg]
  2231 00000D46 FF36[7202]              	push word [load_bpb + 2]
  2232 00000D4A 8F06[2605]              	pop word [load_bpb_dest + 2]
  2233 00000D4E FF36[7002]              	push word [load_bpb]
  2234 00000D52 8F06[2405]              	pop word [load_bpb_dest]
  2235 00000D56 EB50                    	jmp .got_bpb_set_load_top
  2236                                  
  2237                                  
  2238                                  		; auto-BPB: allocate BPB at top and load below that
  2239                                  .auto_bpb:
  2240 00000D58 83EA10                  	sub dx, (256 + 15) >> 4
  2241 00000D5B 7303E944FF              	jc .outofmem
  2242 00000D60 F606[6902]10            	testopt [load_options], LOAD_CMDLINE
  2243 00000D65 7408                    	jz @F
  2244 00000D67 83EA10                  	sub dx, (256) >> 4
  2245 00000D6A 7303E935FF              	jc .outofmem
  2246                                  @@:
  2247 00000D6F 85DB                    	test bx, bx
  2248 00000D71 7408                    	jz @F
  2249 00000D73 83EA20                  	sub dx, 512 >> 4
  2250 00000D76 7303E929FF              	jc .outofmem
  2251                                  @@:
  2252                                  
  2253 00000D7B 52                      	push dx
  2254 00000D7C 89D0                    	mov ax, dx
  2255                                  			; eg dx = 800h
  2256                                  			; want (((800h<<4) + 4096 - LOADSTACKVARS) - 7C00h) >> 4
  2257                                  			; which is 143h
  2258                                  			; which :7C00h = 903h:0
  2259                                  			; dx + ( 4096 - LOADSTACKVARS - 7C00h) / 16
  2260                                  			; dx - (-4096 + LOADSTACKVARS + 7C00h) / 16
  2261 00000D7E BB00FF                  	mov bx, (- 256)
  2262 00000D81 F606[6902]10            	testopt [load_options], LOAD_CMDLINE
  2263 00000D86 7404                    	jz @F
  2264 00000D88 81EB0001                	sub bx, (256)
  2265                                  @@:
  2266 00000D8C 031E[7002]              	add bx, word [load_bpb]
  2267 00000D90 51                      	push cx
  2268 00000D91 B104                    	mov cl, 4
  2269 00000D93 D3EB                    	shr bx, cl
  2270 00000D95 59                      	pop cx
  2271 00000D96 29D8                    	sub ax, bx
  2272                                  	; sub ax, (-256 + 7C00h) / 16
  2273 00000D98 7303E907FF              	jc .outofmem
  2274                                  	; mov word [load_bpb_dest], 7C00h
  2275 00000D9D FF36[7002]              	push word [load_bpb]
  2276 00000DA1 8F06[2405]              	pop word [load_bpb_dest]
  2277 00000DA5 A3[2605]                	mov word [load_bpb_dest + 2], ax
  2278                                  .got_bpb_set_load_top:
  2279 00000DA8 8956E2                  	mov word [bp + ldLoadTop], dx
  2280                                  
  2281                                  .got_bpb:		; cx = how many words are used for stack/lsv/BPB
  2282 00000DAB 58                      	pop ax		; -> stack area
  2283 00000DAC 06                      	push es
  2284 00000DAD 8EC0                    	mov es, ax
  2285 00000DAF 31FF                    	xor di, di
  2286 00000DB1 31C0                    	xor ax, ax
  2287 00000DB3 F3AB                    	rep stosw
  2288 00000DB5 07                      	pop es
  2289                                  
  2290 00000DB6 E8A118                  	call initialise_fs
  2291                                  
  2292 00000DB9 C606[3B05]00            	mov byte [load_check_dir_attr], 0
  2293 00000DBE 8B36[4C05]              	mov si, word [load_kernelname_input]
  2294 00000DC2 803C2F                  	cmp byte [si], '/'
  2295 00000DC5 7501                    	jne @F
  2296 00000DC7 46                      	inc si
  2297                                  @@:
  2298                                  .dotcomponent:
  2299 00000DC8 803C00                  	cmp byte [si], 0
  2300 00000DCB 7504                    	jne @F
  2301 00000DCD 8B36[6002]              	mov si, word [load_kernelname_default]
  2302                                  @@:
  2303 00000DD1 16                      	 push ss
  2304 00000DD2 07                      	 pop es
  2305 00000DD3 E8D7FC                  	call boot_parse_fn	; get next pathname
  2306 00000DD6 72F0                    	jc .dotcomponent
  2307 00000DD8 3C2F                    	cmp al, '/'
  2308 00000DDA 7509                    	jne @F
  2309 00000DDC C606[3B05]10            	mov byte [load_check_dir_attr], ATTR_DIRECTORY
  2310 00000DE1 8936[4E05]              	mov word [load_kernelname_next], si
  2311                                  @@:
  2312                                  
  2313 00000DE5 BFFFFF                  	mov di, -1
  2314 00000DE8 89FE                    	mov si, di
  2315 00000DEA 897EF4                  	mov [bp + lsvFATSector], di
  2316 00000DED 8976F6                  	mov [bp + lsvFATSector + 2], si
  2317                                  
  2318 00000DF0 31C0                    	xor ax, ax
  2319 00000DF2 31D2                    	xor dx, dx
  2320                                  
  2321                                  scan_dir_kernelname_loop:
  2322 00000DF4 8946EC                  	mov word [bp + ldDirCluster], ax
  2323 00000DF7 8956EE                  	mov word [bp + ldDirCluster + 2], dx
  2324                                  
  2325 00000DFA 31DB                    	xor bx, bx
  2326 00000DFC 8EC3                    	mov es, bx
  2327 00000DFE BB0005                  	mov bx, 500h
  2328 00000E01 E8FA07                  	call scan_dir_aux_for_file
  2329                                  
  2330 00000E04 803E[3B05]10            	cmp byte [load_check_dir_attr], ATTR_DIRECTORY
  2331 00000E09 753E                    	jne got_kernelentry
  2332                                  
  2333 00000E0B 56                      	push si
  2334 00000E0C 57                      	push di
  2335 00000E0D C606[3B05]00            	mov byte [load_check_dir_attr], 0
  2336 00000E12 8B36[4E05]              	mov si, word [load_kernelname_next]
  2337                                  .dotcomponent_next:
  2338 00000E16 803C00                  	cmp byte [si], 0
  2339 00000E19 7504                    	jne @F
  2340 00000E1B 8B36[6002]              	mov si, word [load_kernelname_default]
  2341                                  @@:
  2342 00000E1F 06                      	push es
  2343 00000E20 16                      	 push ss
  2344 00000E21 07                      	 pop es
  2345 00000E22 E888FC                  	call boot_parse_fn	; get next pathname
  2346 00000E25 07                      	pop es
  2347 00000E26 72EE                    	jc .dotcomponent_next
  2348 00000E28 3C2F                    	cmp al, '/'
  2349 00000E2A 7509                    	jne @F
  2350 00000E2C C606[3B05]10            	mov byte [load_check_dir_attr], ATTR_DIRECTORY
  2351 00000E31 8936[4E05]              	mov word [load_kernelname_next], si
  2352                                  @@:
  2353 00000E35 5F                      	pop di
  2354 00000E36 5E                      	pop si
  2355                                  
  2356 00000E37 31D2                    	xor dx, dx
  2357 00000E39 268B471A                	mov ax, [es:bx + deClusterLow]
  2358                                  				; = first cluster (not FAT32)
  2359 00000E3D 807EE620                	cmp byte [bp + ldFATType], 32
  2360 00000E41 7504                    	jne @F
  2361 00000E43 268B5714                	mov dx, [es:bx + deClusterHigh]
  2362                                  				; dx:ax = first cluster (FAT32)
  2363                                  @@:
  2364                                  
  2365 00000E47 EBAB                    	jmp scan_dir_kernelname_loop
  2366                                  
  2367                                  
  2368                                  got_kernelentry:
  2369 00000E49 56                      	push si
  2370 00000E4A 57                      	push di
  2371                                  
  2372 00000E4B C606[3B05]00            	mov byte [load_check_dir_attr], 0
  2373 00000E50 8B36[5005]              	mov si, word [load_addname_input]
  2374 00000E54 803C2F                  	cmp byte [si], '/'
  2375 00000E57 7511                    	jne @F
  2376 00000E59 46                      	inc si
  2377 00000E5A 803C2F                  	cmp byte [si], '/'
  2378 00000E5D 7503E9A800              	je got_no_addentry.no_dxax_on_stack
  2379                                  
  2380 00000E62 31C0                    	xor ax, ax
  2381 00000E64 8946EC                  	mov word [bp + ldDirCluster], ax
  2382 00000E67 8946EE                  	mov word [bp + ldDirCluster + 2], ax
  2383                                  				; search from root directory
  2384                                  @@:
  2385                                  .dotcomponent_next:
  2386 00000E6A 803C00                  	cmp byte [si], 0
  2387 00000E6D 750C                    	jne @F
  2388 00000E6F 8B36[6202]              	mov si, word [load_addname_default]
  2389 00000E73 803C00                  	cmp byte [si], 0
  2390 00000E76 7503E98F00              	je got_no_addentry.no_dxax_on_stack
  2391                                  @@:
  2392 00000E7B 16                      	 push ss
  2393 00000E7C 07                      	 pop es
  2394 00000E7D E82DFC                  	call boot_parse_fn	; get next pathname
  2395 00000E80 72E8                    	jc .dotcomponent_next
  2396 00000E82 3C2F                    	cmp al, '/'
  2397 00000E84 7509                    	jne @F
  2398 00000E86 C606[3B05]10            	mov byte [load_check_dir_attr], ATTR_DIRECTORY
  2399 00000E8B 8936[5205]              	mov word [load_addname_next], si
  2400                                  @@:
  2401 00000E8F 5F                      	pop di
  2402 00000E90 5E                      	pop si
  2403 00000E91 EB06                    	jmp @F
  2404                                  
  2405                                  
  2406                                  scan_dir_addname_loop:
  2407 00000E93 8946EC                  	mov word [bp + ldDirCluster], ax
  2408 00000E96 8956EE                  	mov word [bp + ldDirCluster + 2], dx
  2409                                  
  2410                                  @@:
  2411 00000E99 31DB                    	xor bx, bx
  2412 00000E9B 8EC3                    	mov es, bx
  2413 00000E9D BB2005                  	mov bx, 520h	;  0:bx -> space for second directory entry
  2414 00000EA0 E85B07                  	call scan_dir_aux_for_file
  2415                                  
  2416 00000EA3 803E[3B05]10            	cmp byte [load_check_dir_attr], ATTR_DIRECTORY
  2417 00000EA8 756E                    	jne got_addentry
  2418                                  
  2419 00000EAA 56                      	push si
  2420 00000EAB 57                      	push di
  2421 00000EAC 52                      	push dx
  2422 00000EAD 50                      	push ax
  2423 00000EAE C606[3B05]00            	mov byte [load_check_dir_attr], 0
  2424 00000EB3 8B36[5205]              	mov si, word [load_addname_next]
  2425                                  .dotcomponent_next:
  2426 00000EB7 803C00                  	cmp byte [si], 0
  2427 00000EBA 7509                    	jne @F
  2428 00000EBC 8B36[6202]              	mov si, word [load_addname_default]
  2429 00000EC0 803C00                  	cmp byte [si], 0
  2430 00000EC3 7443                    	je got_no_addentry
  2431                                  @@:
  2432 00000EC5 06                      	push es
  2433 00000EC6 16                      	 push ss
  2434 00000EC7 07                      	 pop es
  2435 00000EC8 E8E2FB                  	call boot_parse_fn	; get next pathname
  2436 00000ECB 07                      	pop es
  2437 00000ECC 72E9                    	jc .dotcomponent_next
  2438 00000ECE 3C2F                    	cmp al, '/'
  2439 00000ED0 7509                    	jne @F
  2440 00000ED2 C606[3B05]10            	mov byte [load_check_dir_attr], ATTR_DIRECTORY
  2441 00000ED7 8936[5205]              	mov word [load_addname_next], si
  2442                                  @@:
  2443 00000EDB 58                      	pop ax
  2444 00000EDC 5A                      	pop dx
  2445 00000EDD 5F                      	pop di
  2446 00000EDE 5E                      	pop si
  2447                                  
  2448 00000EDF 31D2                    	xor dx, dx
  2449 00000EE1 268B471A                	mov ax, [es:bx + deClusterLow]
  2450                                  				; = first cluster (not FAT32)
  2451 00000EE5 807EE620                	cmp byte [bp + ldFATType], 32
  2452 00000EE9 7504                    	jne @F
  2453 00000EEB 268B5714                	mov dx, [es:bx + deClusterHigh]
  2454                                  				; dx:ax = first cluster (FAT32)
  2455                                  @@:
  2456                                  
  2457 00000EEF EBA2                    	jmp scan_dir_addname_loop
  2458                                  
  2459                                  
  2460                                  		; INP:	dl:ax:bx = 40-bit size
  2461                                  		; OUT:	If input <= 0FFFF0h,
  2462                                  		;	 dx = size in paragraphs, rounded down
  2463                                  		;	Else,
  2464                                  		;	 dx = 0FFFFh
  2465                                  		;	cx = 0
  2466                                  		; CHG:	ax, bx
  2467                                  helper_shift_down_and_clamp:
  2468 00000EF1 B90400                  	mov cx, 4
  2469                                  @@:
  2470 00000EF4 D0EA                    	shr dl, 1
  2471 00000EF6 D1D8                    	rcr ax, 1
  2472 00000EF8 D1DB                    	rcr bx, 1
  2473 00000EFA E2F8                    	loop @B			; cx = 0
  2474                                  
  2475 00000EFC 08D0                    	or al, dl
  2476 00000EFE 89DA                    	mov dx, bx		; size in paragraphs
  2477 00000F00 85C0                    	test ax, ax		; > 0FFFFh ?
  2478 00000F02 7403                    	jz @F			; no, take actual size -->
  2479 00000F04 BAFFFF                  	mov dx, 0FFFFh		; clamp to 0FFFFh
  2480                                  @@:
  2481 00000F07 C3                      	retn
  2482                                  
  2483                                  
  2484                                  got_no_addentry:
  2485 00000F08 58                      	pop ax
  2486 00000F09 5A                      	pop dx
  2487                                  .no_dxax_on_stack:
  2488                                  ;	push ax
  2489 00000F0A B91000                  	mov cx, 16
  2490 00000F0D 31C0                    	xor ax, ax
  2491 00000F0F 8EC0                    	mov es, ax
  2492 00000F11 BF2005                  	mov di, 520h	; es:di -> space for second directory entry
  2493 00000F14 F3AB                    	rep stosw	; store zeros
  2494                                  ;	pop ax
  2495                                  
  2496 00000F16 5F                      	pop di
  2497 00000F17 5E                      	pop si
  2498                                  
  2499                                  got_addentry:
  2500 00000F18 31C0                    	xor ax, ax
  2501 00000F1A 8EC0                    	mov es, ax
  2502                                  
  2503                                  
  2504                                  ; (boot32.asm code starts here)
  2505                                  
  2506 00000F1C 8B46E2                  	mov ax, word [bp + ldLoadTop]
  2507 00000F1F 2B46EA                  	sub ax, word [bp + ldParaPerSector]
  2508 00000F22 7303E97DFD              	jc load_freedos_common.outofmem
  2509 00000F27 8946D6                  	mov [bp + ldLastAvailableSector], ax
  2510                                  
  2511 00000F2A 268B1E1C05              		mov bx, [es:500h + deSize]
  2512 00000F2F 26A11E05                		mov ax, [es:500h + deSize + 2] ; ax:bx = file size
  2513 00000F33 268A160C05              		mov dl, [es:500h + 12]	; dl = FAT+ size bits
  2514 00000F38 88D6                    		mov dh, dl
  2515 00000F3A 81E207E0                		and dx, 0E007h		; obtain bits 7-5 and 2-0
  2516 00000F3E D0EE                    		shr dh, 1
  2517 00000F40 D0EE                    		shr dh, 1
  2518 00000F42 08F2                    		or dl, dh		; dl:ax:bx = file size
  2519 00000F44 52                      		push dx
  2520 00000F45 50                      		push ax
  2521 00000F46 53                      		push bx
  2522                                  
  2523 00000F47 E8A7FF                  		call helper_shift_down_and_clamp
  2524                                  					; round down to next paragraph boundary
  2525 00000F4A 3916[6402]              		cmp word [load_minpara], dx
  2526                                  					; compare size (rounded down) to minpara
  2527 00000F4E 7603E9A200              		ja error_filetoosmall	; too small -->
  2528                                  
  2529 00000F53 5B                      		pop bx
  2530 00000F54 58                      		pop ax
  2531 00000F55 5A                      		pop dx
  2532 00000F56 8B4E0B                  		mov cx, [bp + bsBPB + bpbBytesPerSector]
  2533 00000F59 49                      		dec cx			; BpS - 1
  2534 00000F5A 01CB                    		add bx, cx
  2535 00000F5C 83D000                  		adc ax, 0
  2536 00000F5F 80D200                  		adc dl, 0		; round up to next sector
  2537 00000F62 F7D1                    		not cx			; ~ (BpS - 1)
  2538 00000F64 21CB                    		and bx, cx		; mask to limit to rounded-up sector
  2539 00000F66 E888FF                  		call helper_shift_down_and_clamp
  2540                                  
  2541                                  			; dx = size in paragraphs, rounded up to sector
  2542 00000F69 A1[6602]                		mov ax, word [load_maxpara]
  2543 00000F6C 39C2                    		cmp dx, ax		; actual size below maximum ?
  2544 00000F6E 7602                    		jbe @F			; yes, use actual size -->
  2545 00000F70 89C2                    		mov dx, ax		; use maximum size (or 0)
  2546                                  @@:
  2547 00000F72 8956D8                  		mov word [bp + ldParasLeft], dx
  2548 00000F75 894EDA                  		mov word [bp + ldParasDone], cx
  2549                                  					; = 0
  2550                                  
  2551                                  ; get starting cluster of file
  2552 00000F78 31D2                    		xor dx, dx
  2553 00000F7A 26A11A05                		mov ax, [es:500h + deClusterLow]
  2554                                  					; = first cluster (not FAT32)
  2555                                  
  2556 00000F7E 807EE620                		cmp byte [bp + ldFATType], 32
  2557 00000F82 7505                    		jne @F
  2558 00000F84 268B161405              		mov dx, [es:500h + deClusterHigh]
  2559                                  					; dx:ax = first cluster (FAT32)
  2560                                  @@:
  2561                                  
  2562 00000F89 8946F0                  		mov word [bp + lsvFirstCluster], ax
  2563 00000F8C 8956F2                  		mov word [bp + lsvFirstCluster + 2], dx
  2564                                  
  2565 00000F8F E88108                  		call check_clust
  2566 00000F92 7303E90017              		jc error_badchain
  2567                                  
  2568                                  next_load_cluster:
  2569 00000F97 E84E07                  		call clust_to_first_sector
  2570                                  			; dx:ax = first sector of cluster
  2571                                  			; cx:bx = cluster value
  2572 00000F9A 51                      		push cx
  2573 00000F9B 53                      		push bx			; preserve cluster number for later
  2574                                  
  2575 00000F9C 8B4EE8                  		mov cx, [bp + ldClusterSize]
  2576                                  
  2577 00000F9F 8B5EFA                  		mov bx, [bp + lsvLoadSeg]
  2578                                  ; xxx - this will always load an entire cluster (e.g. 64 sectors),
  2579                                  ; even if the file is shorter than this
  2580                                  @@:
  2581 00000FA2 3B5ED6                  		cmp bx, [bp + ldLastAvailableSector]
  2582 00000FA5 7613                    		jbe @F
  2583 00000FA7 833E[6602]00            		cmp word [load_maxpara], 0
  2584 00000FAC 743D                    		je @FF			; if to allow partial load -->
  2585 00000FAE BA[0000]                		mov dx, msg.boot_file_too_big_error
  2586 00000FB1 B81A02                  		mov ax, 021Ah
  2587 00000FB4 E8(0000)                		call setrc
  2588 00000FB7 E9A2F5                  		jmp bootcmd.fail
  2589                                  
  2590                                  @@:
  2591 00000FBA 06                      		push es		; (must preserve ADR_FATBUF reference)
  2592 00000FBB E8130C                  		call read_sector
  2593 00000FBE 07                      		pop es
  2594 00000FBF 895EFA                  		mov [bp + lsvLoadSeg], bx	; => after last read data
  2595                                  
  2596 00000FC2 50                      		push ax
  2597 00000FC3 8B46EA                  		mov ax, [bp + ldParaPerSector]
  2598 00000FC6 0146DA                  		add word [bp + ldParasDone], ax
  2599 00000FC9 833E[6602]00            		cmp word [load_maxpara], 0
  2600 00000FCE 7407                    		je .donotuseleft
  2601 00000FD0 2946D8                  		sub word [bp + ldParasLeft], ax
  2602 00000FD3 58                      		pop ax
  2603 00000FD4 7615                    		jbe @F		; read enough -->
  2604 00000FD6 A8                      		db __TEST_IMM8	; (skip pop)
  2605                                  .donotuseleft:
  2606 00000FD7 58                      		pop ax
  2607                                  
  2608 00000FD8 E2C8                    		loop @BB
  2609 00000FDA 5B                      		pop bx
  2610 00000FDB 59                      		pop cx
  2611                                  
  2612 00000FDC E83207                  		call clust_next
  2613 00000FDF 73B6                    		jnc next_load_cluster
  2614 00000FE1 40                      		inc ax
  2615 00000FE2 40                      		inc ax
  2616 00000FE3 A808                    		test al, 8	; set in 0FFF_FFF8h--0FFF_FFFFh,
  2617                                  				;  clear in 0, 1, and 0FFF_FFF7h
  2618 00000FE5 7503E9AD16              		jz error_badchain
  2619 00000FEA A9                      		db __TEST_IMM16
  2620                                  @@:
  2621 00000FEB 5B                      		pop bx
  2622 00000FEC 59                      		pop cx
  2623                                  
  2624 00000FED A1[6402]                		mov ax, word [load_minpara]
  2625 00000FF0 3B46DA                  		cmp ax, word [bp + ldParasDone]
  2626 00000FF3 760C                    		jbe @F
  2627                                  error_filetoosmall:
  2628 00000FF5 BA[0000]                		mov dx, msg.boot_file_too_small_error
  2629 00000FF8 B81B02                  		mov ax, 021Bh
  2630 00000FFB E8(0000)                		call setrc
  2631 00000FFE E95BF5                  		jmp bootcmd.fail
  2632                                  @@:
  2633                                  
  2634                                  
  2635 00001001 8E06[6A02]              	mov es, word [load_loadseg]
  2636 00001005 8B3E[7802]              	mov di, word [load_check_offset]
  2637 00001009 A1[7A02]                	mov ax, word [load_check_value]
  2638 0000100C 85C0                    	test ax, ax
  2639 0000100E 7406                    	jz @F
  2640 00001010 AF                      	scasw
  2641 00001011 7403E91902              	jne .error_check_mismatch
  2642                                  @@:
  2643                                  
  2644                                  ; turn off floppy motor
  2645 00001016 BAF203                  		mov dx,3F2h
  2646 00001019 B000                    		mov al,0
  2647 0000101B EE                      		out dx,al
  2648                                  
  2649                                  ; Set-up registers for and jump to loaded file
  2650                                  
  2651 0000101C 8A5640                  		mov dl, [bp + bsBPB + ebpbNew + bpbnBootUnit]
  2652                                  ;		testopt [load_options], LOAD_SET_DL_UNIT
  2653                                  ;		jz @F
  2654                                  	; (always set dl)
  2655 0000101F 8816[0000]              		mov byte [reg_edx], dl
  2656                                  @@:
  2657                                  
  2658                                  ;		testopt [load_options], LOAD_SET_BL_UNIT
  2659                                  ;		jz @F
  2660                                  	; (always set bl -- overwritten later if LOAD_SET_AXBX_DATASTART)
  2661 00001023 8816[0000]              		mov byte [reg_ebx], dl
  2662                                  @@:
  2663                                  
  2664 00001027 8A6E15                  		mov ch, byte [bp + bsBPB + bpbMediaID]
  2665 0000102A 882E[0100]              		mov byte [reg_ecx + 1], ch
  2666                                  
  2667 0000102E F606[6802]40            		testopt [load_options], LOAD_DATASTART_HIDDEN
  2668 00001033 740C                    		jz @F
  2669 00001035 8B5E1C                  		mov bx, [bp + bsBPB + bpbHiddenSectors]
  2670 00001038 8B461E                  		mov ax, [bp + bsBPB + bpbHiddenSectors + 2]
  2671 0000103B 015EFC                  		add word [bp + lsvDataStart], bx
  2672 0000103E 1146FE                  		adc word [bp + lsvDataStart + 2], ax
  2673                                  @@:
  2674                                  
  2675 00001041 F606[6802]80            		testopt [load_options], LOAD_SET_AXBX_DATASTART
  2676 00001046 740D                    		jz @F
  2677 00001048 8B5EFC                  		mov bx, word [bp + lsvDataStart]
  2678 0000104B 8B46FE                  		mov ax, word [bp + lsvDataStart + 2]
  2679 0000104E 891E[0000]              		mov word [reg_ebx], bx
  2680 00001052 A3[0000]                		mov word [reg_eax], ax
  2681                                  @@:
  2682                                  
  2683 00001055 F606[6902]08            		testopt [load_options], LOAD_SET_AXBX_ROOT_HIDDEN
  2684 0000105A 7413                    		jz @F
  2685 0000105C 8B5ED0                  		mov bx, word [bp + ldRootSector]
  2686 0000105F 8B46D2                  		mov ax, word [bp + ldRootSector + 2]
  2687 00001062 035E1C                  		add bx, word [bp + bsBPB + bpbHiddenSectors]
  2688 00001065 13461E                  		adc ax, word [bp + bsBPB + bpbHiddenSectors + 2]
  2689 00001068 891E[0000]              		mov word [reg_ebx], bx
  2690 0000106C A3[0000]                		mov word [reg_eax], ax
  2691                                  @@:
  2692                                  
  2693 0000106F F606[6802]04            		testopt [load_options], LOAD_SET_SIDI_CLUSTER
  2694 00001074 740D                    		jz @F
  2695 00001076 8B56F2                  		mov dx, word [bp + lsvFirstCluster + 2]
  2696 00001079 8B46F0                  		mov ax, word [bp + lsvFirstCluster]
  2697 0000107C 8916[0000]              		mov word [reg_esi], dx
  2698 00001080 A3[0000]                		mov word [reg_edi], ax
  2699                                  @@:
  2700                                  
  2701                                  ; (boot.asm code ends here)
  2702                                  
  2703                                  
  2704 00001083 C43E[2405]              	les di, [load_bpb_dest]
  2705 00001087 57                      	push di
  2706 00001088 83EF10                  	sub di, -LOADSTACKVARS
  2707 0000108B BE[F001]                	mov si, load_data - LOADDATA2 + LOADSTACKVARS
  2708 0000108E B91000                  	mov cx, -LOADSTACKVARS
  2709 00001091 F606[6902]20            	testopt [load_options], LOAD_NO_BPB
  2710 00001096 7568                    	jnz .no_bpb_movsb
  2711 00001098 B93400                  	mov cx, -LOADSTACKVARS + bsBPB + bpbNew
  2712 0000109B F3A4                    	rep movsb		; move common BPB part
  2713                                  
  2714 0000109D 394E16                  	cmp word [bp + bsBPB + bpbSectorsPerFAT], cx
  2715 000010A0 B93600                  	mov cx, ebpbNew - bpbNew + BPBN_size	; move FAT32 EBPB part + BPBN
  2716 000010A3 7406                    	je @F
  2717 000010A5 83C61C                  	add si, ebpbNew - bpbNew; -> BPBN
  2718 000010A8 B91A00                  	mov cx, BPBN_size	; move only BPBN
  2719                                  @@:
  2720 000010AB F3A4                    	rep movsb
  2721                                  
  2722 000010AD 89F8                    	mov ax, di
  2723 000010AF 5F                      	pop di
  2724 000010B0 29F8                    	sub ax, di
  2725 000010B2 48                      	dec ax
  2726 000010B3 48                      	dec ax
  2727 000010B4 86C4                    	xchg al, ah
  2728 000010B6 B0EB                    	mov al, 0EBh
  2729 000010B8 268905                  	mov word [es:di], ax
  2730 000010BB 26C6450290              	mov byte [es:di + 2], 90h
  2731                                  
  2732 000010C0 F606[6902]02            		testopt [load_options], LOAD_LBA_SET_TYPE
  2733 000010C5 7416                    		jz @F
  2734 000010C7 F646E701                	test byte [bp + ldFlags], ldfHasLBA
  2735 000010CB 7410                    	jz @F
  2736                                  
  2737 000010CD 26C645020E              	mov byte [es:di + 2], 0Eh	; (LBA-enabled) FAT16 FS partition type
  2738 000010D2 807EE620                	cmp byte [bp + ldFATType], 32
  2739 000010D6 7205                    	jb @F
  2740 000010D8 26C645020C              	mov byte [es:di + 2], 0Ch	; (LBA-enabled) FAT32 FS partition type
  2741                                  @@:
  2742                                  
  2743 000010DD 26C785FE0155AA          	mov word [es:di + 510], 0AA55h
  2744 000010E4 1E                      	 push ds
  2745 000010E5 31C9                    	xor cx, cx
  2746 000010E7 8ED9                    	mov ds, cx
  2747 000010E9 BE0005                  	mov si, 500h
  2748 000010EC 57                      	 push di
  2749 000010ED 81C7D601                	add di, 512 - 2 - 2 - 14 - 12 - 12
  2750                                  			; 2: AA55 sig, 2: null word, 14: MS-DOS 7 protocol
  2751                                  			;  message table pointer lives here,
  2752                                  			;  12: add name, 12: kernel name
  2753 000010F1 B10B                    	mov cl, 11
  2754 000010F3 F3A4                    	rep movsb	; put kernel filename into the pseudo boot sector
  2755 000010F5 47                      	inc di
  2756 000010F6 BE2005                  	mov si, 520h
  2757 000010F9 B10B                    	mov cl, 11
  2758 000010FB F3A4                    	rep movsb	; put additional filename (if any), cx = 0
  2759 000010FD 5F                      	 pop di
  2760 000010FE 1F                      	 pop ds
  2761                                  
  2762                                  			; cx = 0
  2763 000010FF A8                      	db __TEST_IMM8	; (skip pop)
  2764                                  .no_bpb_movsb:
  2765 00001100 58                      	pop ax		; discard word on stack
  2766 00001101 F3A4                    	rep movsb
  2767                                  
  2768 00001103 8126[0000]FFF8          	and word [reg_efl], ~(400h|200h|100h)	; UP, DI, TF=0
  2769                                  
  2770 00001109 890E[0200]              	mov word [reg_eip + 2], cx
  2771 0000110D FF36[6C02]              	push word [load_entrypoint]
  2772 00001111 8F06[0000]              	pop word [reg_eip]
  2773 00001115 A1[6E02]                	mov ax, word [load_entrypoint + 2]
  2774 00001118 0306[6A02]              	add ax, word [load_loadseg]
  2775 0000111C A3[0000]                	mov word [reg_cs], ax
  2776                                  
  2777 0000111F A1[2605]                	mov ax, word [load_bpb_dest + 2]
  2778 00001122 A3[0000]                	mov word [reg_ss], ax
  2779                                  ;	testopt [load_options], LOAD_SET_DSBP_BPB
  2780                                  ;	jz @F
  2781                                  		; (always set ds -- overwritten later if LOAD_SET_DSSI_DPT)
  2782 00001125 A3[0000]                	mov word [reg_ds], ax
  2783                                  @@:
  2784 00001128 8B1E[2405]              	mov bx, word [load_bpb_dest]
  2785 0000112C 890E[0200]              	mov word [reg_ebp + 2], cx
  2786 00001130 891E[0000]              	mov word [reg_ebp], bx
  2787 00001134 89D8                    	mov ax, bx
  2788 00001136 83EB10                  	sub bx, -LOADSTACKVARS	; (subtracts --10h)
  2789 00001139 890E[0200]              	mov word [reg_esp + 2], cx
  2790 0000113D 891E[0000]              	mov word [reg_esp], bx
  2791                                  
  2792 00001141 F606[6902]20            	testopt [load_options], LOAD_NO_BPB
  2793 00001146 751B                    	jnz @F
  2794                                  
  2795 00001148 F606[6902]04            		testopt [load_options], LOAD_MESSAGE_TABLE
  2796 0000114D 7414                    		jz @F
  2797 0000114F B96000                  	mov cx, (bsBPB + ebpbNew + BPBN_size + 2 + 15) & ~15
  2798 00001152 01C8                    	add ax, cx
  2799 00001154 268985EE01              	mov word [es:di + 1EEh], ax
  2800                                  		; this pointer points to the MS-DOS 7 message table.
  2801                                  		;
  2802                                  		; note that in actual MS-DOS 7 boot sectors, this value is
  2803                                  		; eg 17Fh, which is incorrectly used with the boot sector's
  2804                                  		; ss to load the table into the initial loader.
  2805                                  		;
  2806                                  		; refer to comments in msg.asm about msdos7_message_table.
  2807 00001159 BE[0000]                	mov si, msdos7_message_table
  2808 0000115C 01CF                    	add di, cx
  2809 0000115E B9[0000]                	mov cx, msdos7_message_table.size
  2810 00001161 F3A4                    	rep movsb
  2811                                  @@:
  2812                                  
  2813 00001163 F606[6902]10            	testopt [load_options], LOAD_CMDLINE
  2814 00001168 7450                    	jz .no_cmdline
  2815                                  
  2816 0000116A 8B36[3205]              	mov si, word [load_cmdline]
  2817 0000116E 85F6                    	test si, si
  2818 00001170 7508                    	jnz @F
  2819 00001172 C606[3E05]00            	mov byte [load_cmdline_first], 0
  2820 00001177 BE[3205]                	mov si, load_cmdline
  2821                                  @@:
  2822                                  
  2823                                  		; due to the size of our line_in buffer,
  2824                                  		;  the command line is never too long for
  2825                                  		;  the lsv command line buffer (256 bytes).
  2826 0000117A B98000                  	mov cx, lsvclBufferLength / 2
  2827 0000117D 812E[0000]0401          	sub word [reg_esp], - lsvCommandLine.start + LOADSTACKVARS
  2828                                  		; hazard: if sp is too low, this underflows!
  2829 00001183 7303E9CE00              	jc .error_stack_underflow
  2830 00001188 8E06[0000]              	mov es, [reg_ss]
  2831 0000118C 8B3E[0000]              	mov di, [reg_esp]	; es:di -> stack area for the pointers
  2832 00001190 81FF0001                	cmp di, 256
  2833 00001194 7303E9BD00              	jb .error_stack_underflow
  2834 00001199 57                      	push di
  2835 0000119A A0[3E05]                	mov al, byte [load_cmdline_first]
  2836 0000119D 84C0                    	test al, al		; have another first byte ?
  2837 0000119F 7404                    	jz @F			; no -->
  2838 000011A1 AA                      	stosb			; store it
  2839 000011A2 46                      	inc si			; skip source
  2840 000011A3 A4                      	movsb			; make it even (1st word done)
  2841 000011A4 49                      	dec cx			; one word less
  2842                                  @@:
  2843 000011A5 F3A5                    	rep movsw
  2844 000011A7 26884DFF                	mov byte [es:di - 1], cl; truncate command line if too long
  2845 000011AB B8434C                  	mov ax, lsvclSignature
  2846 000011AE AB                      	stosw			; write lsvCommandLine.signature
  2847 000011AF 31C0                    	xor ax, ax
  2848 000011B1 AB                      	stosw			; write lsvExtra
  2849 000011B2 5F                      	pop di
  2850 000011B3 B90001                  	mov cx, lsvclBufferLength
  2851 000011B6 F2AE                    	repne scasb		; search terminator
  2852 000011B8 F3AA                    	rep stosb		; zero buffer behind terminator
  2853                                  .no_cmdline:
  2854                                  
  2855 000011BA 31C0                    		xor ax, ax
  2856 000011BC 8EC0                    		mov es, ax
  2857 000011BE BF7800                  		mov di, 1Eh * 4
  2858 000011C1 268B5502                		mov dx, word [es:di + 2]
  2859 000011C5 268B1D                  		mov bx, word [es:di]
  2860                                  
  2861 000011C8 F606[6802]10            		testopt [load_options], LOAD_SET_DSSI_DPT
  2862 000011CD 7408                    		jz @F
  2863 000011CF 8916[0000]              		mov word [reg_ds], dx
  2864 000011D3 891E[0000]              		mov word [reg_esi], bx
  2865                                  @@:
  2866 000011D7 F606[6802]20            		testopt [load_options], LOAD_PUSH_DPT
  2867 000011DC 7419                    		jz @F
  2868                                  
  2869 000011DE 06                      		 push es
  2870 000011DF 57                      		 push di
  2871 000011E0 832E[0000]08            		sub word [reg_esp], 4 * 2	; push four words
  2872 000011E5 8E06[0000]              		mov es, [reg_ss]
  2873 000011E9 8B3E[0000]              		mov di, [reg_esp]	; es:di -> stack area for the pointers
  2874 000011ED 58                      		 pop ax		; di (1Eh * 4)
  2875 000011EE AB                      		stosw
  2876 000011EF 58                      		 pop ax		; es (0)
  2877 000011F0 AB                      		stosw
  2878 000011F1 89D8                    		mov ax, bx
  2879 000011F3 AB                      		stosw		; si (Int1E offset)
  2880 000011F4 89D0                    		mov ax, dx
  2881 000011F6 AB                      		stosw		; ds (Int1E segment)
  2882                                  @@:
  2883                                  
  2884 000011F7 F606[6902]40            	testopt [load_options], LOAD_SET_DSSI_PARTINFO
  2885 000011FC 7416                    	jz @F
  2886 000011FE A1[3605]                	mov ax, word [load_partition_entry + 2]
  2887 00001201 A3[0000]                	mov word [reg_ds], ax
  2888 00001204 A1[3405]                	mov ax, word [load_partition_entry]
  2889 00001207 A3[0000]                	mov word [reg_esi], ax
  2890 0000120A F606[6902]20            	testopt [load_options], LOAD_NO_BPB
  2891 0000120F 7403                    	jz @F
  2892 00001211 A3[0000]                	mov word [reg_ebp], ax
  2893                                  @@:
  2894 00001214 C43E[7402]              	les di, [load_copy_bpb]
  2895 00001218 8CC0                    	mov ax, es
  2896 0000121A 09F8                    	or ax, di
  2897 0000121C 740B                    	jz @F
  2898 0000121E C536[2405]              	lds si, [load_bpb_dest]
  2899 00001222 B90001                  	mov cx, words(512)
  2900 00001225 F3A5                    	rep movsw
  2901 00001227 16                      	push ss
  2902 00001228 1F                      	pop ds
  2903                                  @@:
  2904                                  
  2905 00001229 800E[0300]01            	setopt [internalflags2], dif2_boot_loaded_kernel
  2906 0000122E C3                      	retn
  2907                                  
  2908                                  
  2909                                  .error_check_mismatch:
  2910 0000122F 4F                      	dec di
  2911 00001230 4F                      	dec di			; = offset into file
  2912 00001231 26FF35                  	push word [es:di]	; = value we got in file
  2913 00001234 57                      	push di			; = offset
  2914 00001235 16                      	 push ss
  2915 00001236 07                      	 pop es			; set STT
  2916 00001237 BF[0000]                	mov di, msg.bootfail_check_mismatch.check_value
  2917 0000123A E8(0000)                	call hexword		; write expected value
  2918 0000123D 58                      	pop ax
  2919 0000123E BF[0000]                	mov di, msg.bootfail_check_mismatch.check_offset
  2920 00001241 E8(0000)                	call hexword		; write offset
  2921 00001244 58                      	pop ax
  2922 00001245 BF[0000]                	mov di, msg.bootfail_check_mismatch.check_got
  2923 00001248 E8(0000)                	call hexword		; write what we got in file
  2924                                  
  2925 0000124B BA[0000]                	mov dx, msg.bootfail_check_mismatch
  2926 0000124E B81C02                  	mov ax, 021Ch
  2927 00001251 E8(0000)                	call setrc
  2928 00001254 EB09                    	jmp @F			; fail with error message
  2929                                  
  2930                                  .error_stack_underflow:
  2931 00001256 BA[0000]                	mov dx, msg.bootfail_stack_underflow
  2932 00001259 B81D02                  	mov ax, 021Dh
  2933 0000125C E8(0000)                	call setrc
  2934                                  @@:
  2935 0000125F E9FAF2                  	jmp bootcmd.fail
  2936                                  
  2937                                  
  2938                                  boot_dir:
  2939 00001262 8026[0000]F7            	clropt [internalflags3], dif3_load_dir_dir
  2940 00001267 E8(0000)                	call skipwhite
  2941 0000126A 4E                      	dec si
  2942 0000126B BA[0000]                	mov dx, msg.dir
  2943 0000126E E8(0000)                	call isstring?
  2944 00001271 7505                    	jne @F
  2945 00001273 800E[0000]08            	setopt [internalflags3], dif3_load_dir_dir
  2946                                  @@:
  2947 00001278 C706[4C05][0000]        	mov word [load_kernelname_input], msg.emptydirname
  2948 0000127E AC                      	lodsb
  2949 0000127F E8(0000)                	call yy_common_parse_name
  2950 00001282 E8(0000)                	call chkeol
  2951 00001285 89DE                    	mov si, bx
  2952 00001287 AC                      	lodsb
  2953 00001288 E8E0F4                  	call parseloadunit_default_sdp
  2954 0000128B 7406                    	jz .fn_done_eol		; no filename given, use defaults -->
  2955                                  		; al was = '/' or '\' or first pathname's first character
  2956                                  		; si-> next char
  2957 0000128D BB[4C05]                	mov bx, load_kernelname_input
  2958 00001290 E892F0                  	call bootcmd.pathname_parse_super
  2959                                  
  2960                                  .fn_done_eol:
  2961 00001293 F606[0000]07            	testopt [internalflags3], dif3_load_is_dp
  2962 00001298 7527                    	jnz .boot_dir_from_ldp
  2963                                  
  2964 0000129A 8A1E[3805]              	mov bl, [load_partition]
  2965 0000129E 803E[4002]80            	cmp byte [load_unit], 80h
  2966 000012A3 7228                    	jb .boot_dir_is_diskette
  2967 000012A5 84DB                    	test bl, bl		; partition specified ?
  2968 000012A7 7503E938EE              	jz bootcmd.error	; no, error -->
  2969                                  
  2970 000012AC E84407                  	call query_geometry
  2971                                  
  2972 000012AF B9[F412]                	mov cx, boot_dir_from_partition
  2973 000012B2 E89005                  	call scan_partitions
  2974 000012B5 BA[0000]                	mov dx, msg.boot_partition_not_found
  2975 000012B8 B81102                  	mov ax, 0211h
  2976 000012BB E8(0000)                	call setrc
  2977 000012BE E99BF2                  	jmp bootcmd.fail
  2978                                  
  2979                                  
  2980                                  .boot_dir_from_ldp:
  2981 000012C1 E82F07                  	call query_geometry
  2982 000012C4 A1[2805]                	mov ax, word [load_partition_sector]
  2983 000012C7 8B16[2A05]              	mov dx, word [load_partition_sector + 2]
  2984 000012CB EB0E                    	jmp @F
  2985                                  
  2986                                  
  2987                                  .boot_dir_is_diskette:
  2988 000012CD 84DB                    	test bl, bl		; partition specified ?
  2989 000012CF 7403E910EE              	jnz bootcmd.error	; yes, error -->
  2990                                  
  2991 000012D4 E81C07                  	call query_geometry
  2992                                  
  2993 000012D7 31C0                    	xor ax, ax
  2994 000012D9 31D2                    	xor dx, dx
  2995                                  @@:
  2996 000012DB 8B1E[0000]              	mov bx, word [auxbuff_segorsel]	; bx => auxbuff
  2997 000012DF 52                      	 push dx
  2998 000012E0 50                      	 push ax
  2999 000012E1 E8DB08                  	call read_ae_512_bytes
  3000                                  
  3001 000012E4 26813EFE0155AA          	cmp word [es:510], 0AA55h
  3002 000012EB 7403E9910D              	jne boot_sigmismatch
  3003 000012F0 58                      	 pop ax
  3004 000012F1 5A                      	 pop dx
  3005                                  
  3006 000012F2 EB41                    	jmp boot_dir_common
  3007                                  
  3008                                  
  3009                                  		; INP:	es:si -> partition table entry,
  3010                                  		;	 si = load_partition_table .. load_partition_table+48,
  3011                                  		;	 es = ss
  3012                                  		;	bp + di -> above part table metadata,
  3013                                  		;	 dwo [bp + di - 4] = root (outermost extended position)
  3014                                  		;	 dwo [bp + di - 8] = base (current table position)
  3015                                  		; CHG:	ax, bx, (cx), dx
  3016                                  boot_dir_from_partition:
  3017                                  d4	call d4message
  3018                                  d4	asciz "In boot_dir_from_partition",13,10
  3019                                  
  3020 000012F4 A0[3905]                	mov al, byte [load_current_partition]
  3021 000012F7 3A06[3805]              	cmp al, byte [load_partition]
  3022 000012FB 7401                    	je .gotit
  3023 000012FD C3                      	retn
  3024                                  
  3025                                  .gotit:
  3026                                  d4	call d4message
  3027                                  d4	asciz "In boot_dir_from_partition.gotit",13,10
  3028                                  
  3029 000012FE 8B43F8                  	mov ax, [bp + di - 8]
  3030 00001301 8B53FA                  	mov dx, [bp + di - 6]		; base (current table position)
  3031                                  
  3032 00001304 26034408                	add ax, [es:si + 8]
  3033 00001308 2613540A                	adc dx, [es:si + 8 + 2]		; add offset to logical partition
  3034                                  
  3035 0000130C 26894408                	mov word [es:si + 8], ax
  3036 00001310 2689540A                	mov word [es:si + 8 + 2], dx	; store in partition table entry
  3037 00001314 26800C80                	or byte [es:si + 0], 80h	; set bootable flag
  3038                                  
  3039 00001318 89EC                    	mov sp, bp
  3040 0000131A 5D                      	pop bp				; restore bp (scan_partitions)
  3041 0000131B 5B                      	pop bx				; discard ret address (scan_partitions)
  3042                                  
  3043                                  					; dx:ax = absolute sector number
  3044 0000131C 8B1E[0000]              	mov bx, word [auxbuff_segorsel]	; bx => auxbuff
  3045 00001320 50                      	push ax
  3046 00001321 52                      	push dx
  3047 00001322 E89A08                  	call read_ae_512_bytes		; load partition boot sector
  3048                                  
  3049 00001325 26813EFE0155AA          	cmp word [es:510], 0AA55h
  3050 0000132C 7403E9500D              	jne boot_sigmismatch
  3051                                  
  3052 00001331 31C9                    	xor cx, cx
  3053                                  ;	cmp word [es:0], cx
  3054                                  ;	je boot_codemismatch
  3055                                  
  3056 00001333 5A                      	pop dx
  3057 00001334 58                      	pop ax
  3058                                  
  3059                                  		; dx:ax = boot sector
  3060                                  		; byte [load_unit] = unit
  3061                                  		; es:0-> read sector
  3062                                  boot_dir_common:
  3063 00001335 26A31C00                	mov word [es:bsBPB + bpbHiddenSectors], ax
  3064 00001339 2689161E00              	mov word [es:bsBPB + bpbHiddenSectors + 2], dx
  3065                                  
  3066 0000133E 8B5E0B                  	mov bx, [bp + bsBPB + bpbBytesPerSector]
  3067 00001341 263B1E0B00              	cmp bx, [es:bsBPB + bpbBytesPerSector]
  3068 00001346 7403E94A0D              	jne boot_secsizemismatch
  3069                                  
  3070                                  		; preserve some variables from our pseudo BPB
  3071 0000134B 31C0                    	xor ax, ax
  3072 0000134D FF7618                  	push word [bp + bsBPB + bpbCHSSectors]
  3073 00001350 268F061800              	pop word [es:bsBPB + bpbCHSSectors]
  3074 00001355 FF761A                  	push word [bp + bsBPB + bpbCHSHeads]
  3075 00001358 268F061A00              	pop word [es:bsBPB + bpbCHSHeads]	; preserve geometry
  3076                                  
  3077 0000135D 8B5EEA                  	mov bx, word [bp + ldParaPerSector]
  3078 00001360 D1EB                    	shr bx, 1
  3079 00001362 895ED4                  	mov word [bp + ldEntriesPerSector], bx
  3080                                  
  3081 00001365 2639061600              	cmp word [es:bsBPB + bpbSectorsPerFAT], ax
  3082 0000136A 8A5E40                  	mov bl, byte [bp + bsBPB + ebpbNew + bpbnBootUnit]
  3083 0000136D 7407                    	je .is_fat32
  3084 0000136F 26881E2400              	mov byte [es:bsBPB + bpbNew + bpbnBootUnit], bl
  3085 00001374 EB05                    	jmp short .was_fat1612
  3086                                  .is_fat32:
  3087 00001376 26881E4000              	mov byte [es:bsBPB + ebpbNew + bpbnBootUnit], bl
  3088                                  .was_fat1612:
  3089                                  
  3090 0000137B 06                      	 push es
  3091 0000137C 1E                      	 push ds
  3092 0000137D 06                      	push es
  3093 0000137E 1F                      	pop ds
  3094 0000137F 31F6                    	xor si, si				; -> BPB from boot partition
  3095 00001381 16                      	push ss
  3096 00001382 07                      	pop es
  3097 00001383 BF[0002]                	mov di, load_data - LOADDATA2		; -> our copy of a BPB
  3098 00001386 B95A00                  	mov cx, (bsBPB + ebpbNew + BPBN_size)
  3099 00001389 F3A4                    	rep movsb				; get the BPB
  3100                                  
  3101 0000138B 1F                      	 pop ds
  3102 0000138C 800E[0000]80            	setopt [internalflags3], dif3_partition_changed
  3103                                  
  3104 00001391 394616                  	cmp word [bp + bsBPB + bpbSectorsPerFAT], ax
  3105 00001394 740B                    	je @F					; is FAT32 -->
  3106 00001396 BE[2402]                	mov si, load_data - LOADDATA2 + bsBPB + bpbNew
  3107 00001399 BF[4002]                	mov di, load_data - LOADDATA2 + bsBPB + ebpbNew
  3108 0000139C B91A00                  	mov cx, BPBN_size
  3109 0000139F F3A4                    	rep movsb				; clone the FAT16 / FAT12 BPBN
  3110                                  						; to where the FAT32 BPBN lives
  3111                                  @@:
  3112 000013A1 07                      	 pop es
  3113                                  
  3114 000013A2 FF36[0000]              	push word [auxbuff_segorsel]
  3115 000013A6 8F46F8                  	pop word [bp + lsvFATSeg]
  3116 000013A9 804EE702                	or byte [bp + ldFlags], ldfFATInvalid
  3117 000013AD B8FFFF                  	mov ax, -1
  3118 000013B0 8946F4                  	mov word [bp + lsvFATSector], ax
  3119 000013B3 8946F6                  	mov word [bp + lsvFATSector + 2], ax
  3120                                  
  3121 000013B6 E8A112                  	call initialise_fs
  3122                                  
  3123 000013B9 C706[8605][CF15]        	mov word [handle_scan_dir_entry], scan_dir_entry
  3124                                  
  3125 000013BF C606[3B05]00            	mov byte [load_check_dir_attr], 0
  3126 000013C4 8B36[4C05]              	mov si, word [load_kernelname_input]
  3127 000013C8 803C2F                  	cmp byte [si], '/'
  3128 000013CB 7501                    	jne @F
  3129 000013CD 46                      	inc si
  3130                                  @@:
  3131                                  .dotcomponent:
  3132 000013CE 803C00                  	cmp byte [si], 0
  3133 000013D1 7503E99F00              	je .root
  3134 000013D6 16                      	 push ss
  3135 000013D7 07                      	 pop es
  3136 000013D8 E8D2F6                  	call boot_parse_fn	; get next pathname
  3137 000013DB 72F1                    	jc .dotcomponent
  3138 000013DD 3C2F                    	cmp al, '/'
  3139 000013DF 7509                    	jne @F
  3140 000013E1 C606[3B05]10            	mov byte [load_check_dir_attr], ATTR_DIRECTORY
  3141 000013E6 8936[4E05]              	mov word [load_kernelname_next], si
  3142                                  @@:
  3143 000013EA 84C0                    	test al, al
  3144 000013EC 7506                    	jnz @F
  3145 000013EE C706[8605][CC15]        	mov word [handle_scan_dir_entry], scan_dir_entry_dir_or_file
  3146                                  @@:
  3147                                  
  3148 000013F4 BFFFFF                  	mov di, -1
  3149 000013F7 89FE                    	mov si, di
  3150 000013F9 897EF4                  	mov [bp + lsvFATSector], di
  3151 000013FC 8976F6                  	mov [bp + lsvFATSector + 2], si
  3152                                  
  3153 000013FF 31C0                    	xor ax, ax
  3154 00001401 31D2                    	xor dx, dx
  3155                                  
  3156 00001403 83EC20                  	sub sp, 32
  3157                                  
  3158                                  .scan_dir_dirname_loop:
  3159 00001406 8946EC                  	mov word [bp + ldDirCluster], ax
  3160 00001409 8956EE                  	mov word [bp + ldDirCluster + 2], dx
  3161                                  
  3162 0000140C 16                      	push ss
  3163 0000140D 07                      	pop es
  3164 0000140E 89E3                    	mov bx, sp
  3165 00001410 E8F101                  	call scan_dir_aux_with_error
  3166                                  
  3167 00001413 803E[3B05]10            	cmp byte [load_check_dir_attr], ATTR_DIRECTORY
  3168 00001418 7544                    	jne .got_direntry
  3169                                  
  3170 0000141A 56                      	push si
  3171 0000141B 57                      	push di
  3172 0000141C C606[3B05]00            	mov byte [load_check_dir_attr], 0
  3173 00001421 8B36[4E05]              	mov si, word [load_kernelname_next]
  3174                                  .dotcomponent2_next:
  3175 00001425 803C00                  	cmp byte [si], 0
  3176 00001428 7451                    	je .sub
  3177                                  
  3178 0000142A 06                      	push es
  3179 0000142B 16                      	 push ss
  3180 0000142C 07                      	 pop es
  3181 0000142D E87DF6                  	call boot_parse_fn	; get next pathname
  3182 00001430 07                      	pop es
  3183 00001431 72F2                    	jc .dotcomponent2_next
  3184 00001433 3C2F                    	cmp al, '/'
  3185 00001435 7509                    	jne @F
  3186 00001437 C606[3B05]10            	mov byte [load_check_dir_attr], ATTR_DIRECTORY
  3187 0000143C 8936[4E05]              	mov word [load_kernelname_next], si
  3188                                  @@:
  3189 00001440 84C0                    	test al, al
  3190 00001442 7506                    	jnz @F
  3191 00001444 C706[8605][CC15]        	mov word [handle_scan_dir_entry], scan_dir_entry_dir_or_file
  3192                                  @@:
  3193                                  
  3194 0000144A 5F                      	pop di
  3195 0000144B 5E                      	pop si
  3196                                  
  3197 0000144C 31D2                    	xor dx, dx
  3198 0000144E 268B471A                	mov ax, [es:bx + deClusterLow]
  3199                                  				; = first cluster (not FAT32)
  3200 00001452 807EE620                	cmp byte [bp + ldFATType], 32
  3201 00001456 7504                    	jne @F
  3202 00001458 268B5714                	mov dx, [es:bx + deClusterHigh]
  3203                                  				; dx:ax = first cluster (FAT32)
  3204                                  @@:
  3205                                  
  3206 0000145C EBA8                    	jmp .scan_dir_dirname_loop
  3207                                  
  3208                                  
  3209                                  .got_direntry:
  3210 0000145E F606[0000]08            	testopt [internalflags3], dif3_load_dir_dir
  3211 00001463 7507                    	jnz @F
  3212 00001465 26F6470B10              	test byte [es:bx + deAttrib], ATTR_DIRECTORY
  3213 0000146A 7511                    	jnz @FF
  3214                                  @@:
  3215 0000146C 89DF                    	mov di, bx
  3216 0000146E E83400                  	call list_dir_entry
  3217 00001471 83C420                  	add sp, 32
  3218 00001474 C3                      	retn
  3219                                  
  3220                                  .root:
  3221 00001475 31C0                    	xor ax, ax
  3222 00001477 31D2                    	xor dx, dx
  3223 00001479 EB15                    	jmp .scan
  3224                                  
  3225                                  .sub:
  3226 0000147B 5F                      	pop di
  3227 0000147C 5E                      	pop si
  3228                                  
  3229                                  @@:
  3230 0000147D 83C420                  	add sp, 32
  3231                                  
  3232 00001480 31D2                    	xor dx, dx
  3233 00001482 268B471A                	mov ax, [es:bx + deClusterLow]
  3234                                  				; = first cluster (not FAT32)
  3235 00001486 807EE620                	cmp byte [bp + ldFATType], 32
  3236 0000148A 7504                    	jne @F
  3237 0000148C 268B5714                	mov dx, [es:bx + deClusterHigh]
  3238                                  				; dx:ax = first cluster (FAT32)
  3239                                  @@:
  3240                                  .scan:
  3241 00001490 8946EC                  	mov word [bp + ldDirCluster], ax
  3242 00001493 8956EE                  	mov word [bp + ldDirCluster + 2], dx
  3243                                  
  3244 00001496 C706[8605][A514]        	mov word [handle_scan_dir_entry], list_dir_entry
  3245 0000149C C706[8805][0000]        	mov word [handle_scan_dir_not_found], dmycmd
  3246                                  
  3247 000014A2 E96501                  	jmp scan_dir_aux
  3248                                  
  3249                                  
  3250                                  list_dir_entry:
  3251 000014A5 26803D00                	cmp byte [es:di], 0
  3252 000014A9 7503E91D01              	je .ret			; (NC, ZR)
  3253 000014AE 26803DE5                	cmp byte [es:di], 0E5h
  3254 000014B2 7504                    	jne @F
  3255 000014B4 80CB01                  	or bl, 1		; (NC, NZ)
  3256 000014B7 C3                      	retn
  3257                                  
  3258                                  @@:
  3259 000014B8 268A5D0B                	mov bl, byte [es:di + deAttrib]
  3260 000014BC F6C308                  	test bl, ATTR_VOLLABEL
  3261 000014BF 7403E90401              	jnz .ret_NC_NZ		; skip volume labels (and LFNs) --> (NZ)
  3262                                  
  3263 000014C4 26803D2E                	cmp byte [es:di], '.'	; dot or dotdot entry ?
  3264 000014C8 7503E9FB00              	je .ret_NC_NZ		; yes, skip -->
  3265                                  
  3266 000014CD 50                      	push ax
  3267 000014CE 53                      	push bx
  3268 000014CF 51                      	push cx
  3269 000014D0 52                      	push dx
  3270 000014D1 56                      	push si
  3271 000014D2 57                      	push di
  3272 000014D3 06                      	push es
  3273 000014D4 1E                      	push ds
  3274 000014D5 06                      	 push es
  3275 000014D6 1F                      	 pop ds
  3276 000014D7 89FE                    	mov si, di
  3277                                  
  3278 000014D9 16                      	 push ss
  3279 000014DA 07                      	 pop es
  3280 000014DB BF[0000]                	mov di, line_out
  3281 000014DE B90800                  	mov cx, 8
  3282 000014E1 F3A4                    	rep movsb
  3283 000014E3 B82020                  	mov ax, 2020h
  3284 000014E6 AA                      	stosb
  3285 000014E7 B103                    	mov cl, 3
  3286 000014E9 F3A4                    	rep movsb
  3287 000014EB AB                      	stosw
  3288                                  
  3289 000014EC 1F                      	pop ds
  3290 000014ED B02D                    	mov al, '-'
  3291 000014EF F6C320                  	test bl, ATTR_ARCHIVE
  3292 000014F2 7402                    	jz @F
  3293 000014F4 B041                    	mov al, 'A'
  3294                                  @@:
  3295 000014F6 AA                      	stosb
  3296 000014F7 B02D                    	mov al, '-'
  3297 000014F9 F6C302                  	test bl, ATTR_HIDDEN
  3298 000014FC 7402                    	jz @F
  3299 000014FE B048                    	mov al, 'H'
  3300                                  @@:
  3301 00001500 AA                      	stosb
  3302 00001501 B02D                    	mov al, '-'
  3303 00001503 F6C301                  	test bl, ATTR_READONLY
  3304 00001506 7402                    	jz @F
  3305 00001508 B052                    	mov al, 'R'
  3306                                  @@:
  3307 0000150A AA                      	stosb
  3308 0000150B B02D                    	mov al, '-'
  3309 0000150D F6C304                  	test bl, ATTR_SYSTEM
  3310 00001510 7402                    	jz @F
  3311 00001512 B053                    	mov al, 'S'
  3312                                  @@:
  3313 00001514 AA                      	stosb
  3314 00001515 B82020                  	mov ax, 2020h
  3315 00001518 AB                      	stosw
  3316                                  
  3317 00001519 F6C310                  	test bl, ATTR_DIRECTORY
  3318 0000151C 7408                    	jz @F
  3319 0000151E BE[0000]                	mov si, msg.dirinsteadsize
  3320 00001521 E8(0000)                	call copy_single_counted_string
  3321 00001524 EB2D                    	jmp @FF
  3322                                  
  3323                                  @@:
  3324 00001526 07                      	 pop es
  3325 00001527 5E                      	 pop si
  3326 00001528 56                      	 push si
  3327 00001529 06                      	 push es
  3328 0000152A 268A440C                	mov al, byte [es:si + dePlusSize]
  3329 0000152E 88C4                    	mov ah, al
  3330 00001530 2507E0                  	and ax, 0E007h
  3331 00001533 88E2                    	mov dl, ah
  3332 00001535 B400                    	mov ah, 0
  3333 00001537 B600                    	mov dh, 0
  3334 00001539 D1EA                    	shr dx, 1
  3335 0000153B D1EA                    	shr dx, 1
  3336 0000153D 09D0                    	or ax, dx
  3337 0000153F 50                      	 push ax
  3338 00001540 268B541E                	mov dx, word [es:si + deSize + 2]
  3339 00001544 268B441C                	mov ax, word [es:si + deSize]
  3340 00001548 5E                      	 pop si
  3341 00001549 16                      	 push ss
  3342 0000154A 07                      	 pop es
  3343 0000154B 31C9                    	xor cx, cx
  3344 0000154D BB0800                  	mov bx, 4+4
  3345 00001550 E8(0000)                	call disp_dxax_times_cx_width_bx_size.store
  3346                                  
  3347                                  @@:
  3348 00001553 B82020                  	mov ax, 2020h
  3349 00001556 AB                      	stosw
  3350 00001557 07                      	 pop es
  3351 00001558 5E                      	 pop si
  3352 00001559 56                      	 push si
  3353 0000155A 06                      	 push es
  3354 0000155B 268B5C18                	mov bx, word [es:si + deDate]
  3355 0000155F 268B7416                	mov si, word [es:si + deTime]
  3356 00001563 16                      	 push ss
  3357 00001564 07                      	 pop es
  3358 00001565 89D8                    	mov ax, bx
  3359 00001567 B90900                  	mov cx, 9
  3360 0000156A D3E8                    	shr ax, cl
  3361 0000156C 05BC07                  	add ax, 1980
  3362 0000156F 31D2                    	xor dx, dx
  3363 00001571 B104                    	mov cl, 4
  3364 00001573 E8(0000)                	call dec_dword_minwidth
  3365 00001576 B02D                    	mov al, '-'
  3366 00001578 AA                      	stosb
  3367 00001579 89D8                    	mov ax, bx
  3368 0000157B B105                    	mov cl, 5
  3369 0000157D D3E8                    	shr ax, cl
  3370 0000157F 83E00F                  	and ax, 15
  3371 00001582 B102                    	mov cl, 2
  3372 00001584 E8(0000)                	call dec_dword_minwidth
  3373 00001587 B02D                    	mov al, '-'
  3374 00001589 AA                      	stosb
  3375 0000158A 89D8                    	mov ax, bx
  3376 0000158C 83E01F                  	and ax, 31
  3377 0000158F E8(0000)                	call dec_dword_minwidth
  3378 00001592 B020                    	mov al, 32
  3379 00001594 AA                      	stosb
  3380 00001595 89F0                    	mov ax, si
  3381 00001597 B10B                    	mov cl, 11
  3382 00001599 D3E8                    	shr ax, cl
  3383 0000159B B102                    	mov cl, 2
  3384 0000159D E8(0000)                	call dec_dword_minwidth
  3385 000015A0 B03A                    	mov al, ':'
  3386 000015A2 AA                      	stosb
  3387 000015A3 89F0                    	mov ax, si
  3388 000015A5 B105                    	mov cl, 5
  3389 000015A7 D3E8                    	shr ax, cl
  3390 000015A9 83E03F                  	and ax, 63
  3391 000015AC B102                    	mov cl, 2
  3392 000015AE E8(0000)                	call dec_dword_minwidth
  3393 000015B1 B03A                    	mov al, ':'
  3394 000015B3 AA                      	stosb
  3395 000015B4 89F0                    	mov ax, si
  3396 000015B6 83E01F                  	and ax, 31
  3397 000015B9 D1E0                    	shl ax, 1
  3398 000015BB E8(0000)                	call dec_dword_minwidth
  3399                                  
  3400 000015BE E8(0000)                	call putsline_crlf
  3401                                  
  3402 000015C1 07                      	pop es
  3403 000015C2 5F                      	pop di
  3404 000015C3 5E                      	pop si
  3405 000015C4 5A                      	pop dx
  3406 000015C5 59                      	pop cx
  3407 000015C6 5B                      	pop bx
  3408 000015C7 58                      	pop ax
  3409                                  
  3410                                  .ret_NC_NZ:
  3411 000015C8 80CB01                  	or bl, 1		; (NC, NZ)
  3412                                  .ret:
  3413 000015CB C3                      	retn
  3414                                  
  3415                                  
  3416                                  	usesection lDEBUG_DATA_ENTRY
  3416          ------------------       note: usesection lDEBUG_DATA_ENTRY
  3417                                  
  3418                                  	align 2, db 0
  3419                                  %if _LOADER
  3420                                  loader_lowest_free:
  3421                                  	dw 0
  3422                                  %endif
  3423                                  handle_scan_dir_entry:
  3424 00000586 [0000]                  	dw error
  3425                                  handle_scan_dir_not_found:
  3426 00000588 [0000]                  	dw error
  3427                                  
  3428                                  	usesection lDEBUG_CODE
  3428          ------------------       note: usesection lDEBUG_CODE
  3429                                  
  3430                                  scan_dir_entry_dir_or_file:
  3431 000015CC B701                    	mov bh, 1
  3432 000015CE A9                      	db __TEST_IMM16		; (skip mov)
  3433                                  
  3434                                  scan_dir_entry:
  3435 000015CF B700                    	mov bh, 0
  3436 000015D1 26803D00                	cmp byte [es:di], 0
  3437 000015D5 F9                      	stc
  3438 000015D6 7425                    	je .ret
  3439 000015D8 268A5D0B                	mov bl, byte [es:di + deAttrib]
  3440 000015DC F6C308                  	test bl, ATTR_VOLLABEL
  3441 000015DF 751B                    	jnz @F			; skip volume labels (and LFNs) --> (NZ)
  3442 000015E1 84FF                    	test bh, bh
  3443 000015E3 7509                    	jnz .no_check_dir
  3444 000015E5 80E310                  	and bl, ATTR_DIRECTORY	; isolate directory bit
  3445 000015E8 3A1E[3B05]              	cmp bl, byte [load_check_dir_attr]	; is it what we're searching?
  3446 000015EC 750E                    	jne @F			; no -->
  3447                                  .no_check_dir:
  3448 000015EE 56                      	push si
  3449 000015EF 57                      	push di
  3450 000015F0 51                      	push cx
  3451 000015F1 BE[4005]                	mov si, load_kernel_name	; ds:si-> name to match
  3452 000015F4 B90B00                  	mov cx, 11		; length of padded 8.3 FAT filename
  3453 000015F7 F3A6                    	repe cmpsb		; check entry
  3454 000015F9 59                      	pop cx
  3455 000015FA 5F                      	pop di
  3456 000015FB 5E                      	pop si
  3457                                  @@:
  3458 000015FC F8                      	clc
  3459                                  .ret:
  3460 000015FD C3                      	retn
  3461                                  
  3462                                  
  3463                                  		; INP:	es:bx -> where to place directory entry
  3464                                  		;	si:di = loaded FAT sector (0 = first FAT sector)
  3465                                  		;	dword [bp + ldDirCluster] = directory cluster to scan,
  3466                                  		;					0 for root dir
  3467                                  		;	byte [bp + ldFATType] = size of FAT entry in bits
  3468                                  		; OUT:	es:bx -> directory entry (es:bx unchanged)
  3469                                  		;	si:di = loaded FAT sector
  3470                                  		; CHG:	dx, ax, si, di, cx
  3471                                  scan_dir_aux_for_file:
  3472 000015FE C706[8605][CF15]        	mov word [handle_scan_dir_entry], scan_dir_entry
  3473                                  
  3474                                  scan_dir_aux_with_error:
  3475 00001604 C706[8805][6216]        	mov word [handle_scan_dir_not_found], error_filenotfound
  3476                                  
  3477                                  scan_dir_aux: section_of_function
  3478 0000160A FF36[0000]              	push word [auxbuff_segorsel]
  3479 0000160E 8F06[5805]              	pop word [load_adr_dirbuf_segment]
  3480                                  
  3481                                  scan_dir:
  3482 00001612 8B46EC                  	mov ax, word [bp + ldDirCluster]
  3483 00001615 8B56EE                  	mov dx, word [bp + ldDirCluster + 2]
  3484                                  
  3485 00001618 85C0                    	test ax, ax
  3486 0000161A 7572                    	jnz fat32_scan_root.dir_clust_dxax
  3487 0000161C 85D2                    	test dx, dx
  3488 0000161E 756E                    	jnz fat32_scan_root.dir_clust_dxax
  3489                                  
  3490                                  		; got to scan root directory. use FAT12/FAT16 walker if so,
  3491                                  		;  else use FAT32 walker
  3492                                  
  3493 00001620 807EE610                	cmp byte [bp + ldFATType], 16
  3494 00001624 7762                    	ja fat32_scan_root
  3495                                  
  3496 00001626 56                      	push si
  3497 00001627 57                      	push di
  3498 00001628 06                      	push es
  3499 00001629 53                      	push bx
  3500                                  
  3501 0000162A 8B7611                  	mov si, word [bp + bsBPB + bpbNumRootDirEnts]
  3502                                  
  3503                                  
  3504                                  ; (boot.asm code starts here)
  3505                                  
  3506                                  fat16_scan_root:
  3507 0000162D 85F6                    	test si, si
  3508 0000162F 7424                    	jz handle_filenotfound_fat16
  3509                                  
  3510 00001631 8B46D0                  	mov ax, [bp + ldRootSector]
  3511 00001634 8B56D2                  	mov dx, [bp + ldRootSector + 2]
  3512                                  
  3513                                  ; Scan root directory for file. We don't bother to check for deleted
  3514                                  ;  entries (E5h) or entries that mark the end of the directory (00h).
  3515                                  		; number of root entries in si here
  3516                                  fat16_next_sect:
  3517 00001637 8B1E[5805]              	mov bx, [load_adr_dirbuf_segment]
  3518 0000163B E89305                  	call read_sector
  3519                                  
  3520 0000163E 8B4ED4                  	mov cx, [bp + ldEntriesPerSector] ; entries per sector as loop counter
  3521 00001641 31FF                    	xor di, di		; es:di-> first entry in this sector
  3522                                  fat16_next_ent:
  3523 00001643 FF16[8605]              	call near word [handle_scan_dir_entry]
  3524                                  ..@boot_scan_dir_return_fat16_root_entry:
  3525 00001647 720C                    	jc handle_filenotfound_fat16
  3526 00001649 8D7D20                  	lea di, [di + DIRENTRY_size]	; bytes/dirent
  3527 0000164C 7423                    	je fat16_found_it	; found entry -->
  3528                                  
  3529 0000164E 4E                      	dec si			; count down entire root's entries
  3530 0000164F E0F2                    	loopnz fat16_next_ent	; count down sector's entries (jumps iff si >0 && cx >0)
  3531 00001651 85F6                    	test si, si		; work around qemu bug
  3532 00001653 75E2                    	jnz fat16_next_sect	; (jumps iff si >0 && cx ==0)
  3533                                  				; ends up here iff si ==0
  3534                                  				;  ie all root entries checked unsuccessfully
  3535                                  %if 0
  3536                                  
  3537                                  qemu prior to 2020-08 has a bug which affects the above
  3538                                  conditionals. The bug is that if NZ is set (like when the
  3539                                  branch to fat16_found_it is not taken) and then another
  3540                                  instruction sets ZR (like the dec si at the end of the root
  3541                                  directory) and then loopnz is used which sets cx to zero
  3542                                  then after the loopnz FL will be NZ leading to the jnz branch
  3543                                  to be taken. Eventually the entire load unit is traversed and
  3544                                  qemu returns error 01h when trying to read past the end of
  3545                                  the unit (at least for 1440 KiB diskettes).
  3546                                  
  3547                                  The bug is now worked around by the comparison with zero at
  3548                                  the fat16_next_ent label. The test si, si serves as another
  3549                                  workaround to forcibly set the flag correctly after loopnz.
  3550                                  It is only really needed when the entire root is filled with
  3551                                  non-zero directory entries and an older qemu is used.
  3552                                  
  3553                                  Reference: https://bugs.launchpad.net/qemu/+bug/1888165
  3554                                  
  3555                                  %endif
  3556                                  
  3557                                  handle_filenotfound_fat16:
  3558 00001655 5B                      	pop bx
  3559 00001656 07                      	pop es
  3560 00001657 5F                      	pop di
  3561 00001658 5E                      	pop si
  3562                                  
  3563 00001659 A9                      	db __TEST_IMM16		; (skip pop and pop)
  3564                                  handle_filenotfound_fat32:
  3565 0000165A 5B                      	pop bx
  3566 0000165B 07                      	pop es
  3567                                  
  3568                                  handle_filenotfound:
  3569 0000165C FF16[8805]              	call near word [handle_scan_dir_not_found]
  3570                                  ..@boot_scan_dir_return_filenotfound:
  3571 00001660 F9                      	stc
  3572 00001661 C3                      	retn
  3573                                  
  3574                                  error_filenotfound:
  3575                                  %if _INPUT_FILE_BOOT
  3576 00001662 E87809                  	call yy_boot_file_not_found
  3577                                  %endif
  3578 00001665 BA[0000]                	mov dx, msg.boot_file_not_found
  3579 00001668 B81E02                  	mov ax, 021Eh
  3580 0000166B E8(0000)                	call setrc
  3581 0000166E E9EBEE                  	jmp bootcmd.fail
  3582                                  
  3583                                  fat16_found_it:
  3584 00001671 5B                      	  pop bx
  3585 00001672 58                      	  pop ax
  3586 00001673 B92000                  	mov cx, 32
  3587 00001676 29CF                    	sub di, cx
  3588 00001678 1E                      	push ds
  3589 00001679 06                      	 push es
  3590 0000167A 1F                      	 pop ds
  3591 0000167B 89FE                    	mov si, di		; ds:si -> entry in directory buffer
  3592 0000167D 89DF                    	mov di, bx
  3593 0000167F 8EC0                    	mov es, ax		; es:di -> destination for entry
  3594 00001681 F3A4                    	rep movsb
  3595 00001683 1F                      	pop ds
  3596 00001684 5F                      	  pop di
  3597 00001685 5E                      	  pop si
  3598 00001686 F8                      	clc
  3599 00001687 C3                      	retn
  3600                                  
  3601                                  
  3602                                  ; (boot32.asm code starts here)
  3603                                  
  3604                                  fat32_scan_root:
  3605 00001688 8B462C                  	mov ax, [bp + bsBPB + ebpbRootCluster]
  3606 0000168B 8B562E                  	mov dx, [bp + bsBPB + ebpbRootCluster + 2]
  3607                                  
  3608                                  .dir_clust_dxax:
  3609 0000168E 06                      	push es
  3610 0000168F 53                      	push bx
  3611                                  
  3612 00001690 E88001                  	call check_clust
  3613 00001693 72C5                    	jc handle_filenotfound_fat32
  3614                                  
  3615                                  fat32_next_root_clust:
  3616 00001695 E85000                  	call clust_to_first_sector
  3617 00001698 51                      	push cx
  3618 00001699 53                      	push bx
  3619 0000169A 8B4EE8                  	mov cx, [bp + ldClusterSize]
  3620                                  fat32_next_root_sect:
  3621 0000169D 51                      	push cx
  3622 0000169E 8B4ED4                  	mov cx, [bp + ldEntriesPerSector]
  3623                                  
  3624                                  ; Scan root directory for file. We don't bother to check for deleted
  3625                                  ;  entries (E5h) or entries that mark the end of the directory (00h).
  3626 000016A1 8B1E[5805]              	mov bx, [load_adr_dirbuf_segment]
  3627 000016A5 E82905                  	call read_sector
  3628                                  
  3629 000016A8 57                      	push di
  3630 000016A9 31FF                    	xor di, di		; es:di-> first entry in this sector
  3631                                  fat32_next_ent:
  3632 000016AB FF16[8605]              	call near word [handle_scan_dir_entry]
  3633                                  ..@boot_scan_dir_return_subdir_or_fat32_entry:
  3634 000016AF 7214                    	jc handle_filenotfound_fat32_pop
  3635 000016B1 8D7D20                  	lea di, [di + DIRENTRY_size]	; bytes/dirent
  3636 000016B4 7415                    	je fat32_found_it	; found entry -->
  3637                                  
  3638 000016B6 E2F3                    	loop fat32_next_ent	; count down sector's entries (jumps iff cx >0)
  3639 000016B8 5F                      	pop di
  3640 000016B9 59                      	pop cx
  3641 000016BA E2E1                    	loop fat32_next_root_sect
  3642 000016BC 5B                      	pop bx
  3643 000016BD 59                      	pop cx
  3644 000016BE E85000                  	call clust_next
  3645 000016C1 73D2                    	jnc fat32_next_root_clust
  3646 000016C3 EB04                    	jmp @F
  3647                                  
  3648                                  handle_filenotfound_fat32_pop:
  3649 000016C5 5F                      	pop di
  3650 000016C6 59                      	pop cx
  3651 000016C7 5B                      	pop bx
  3652 000016C8 59                      	pop cx
  3653                                  @@:
  3654 000016C9 EB8F                    	jmp handle_filenotfound_fat32
  3655                                  
  3656                                  
  3657                                  fat32_found_it:
  3658 000016CB 5A                      	pop dx			; value for di
  3659 000016CC 83C406                  	add sp, 6		; discard sector-in-cluster counter and cluster
  3660 000016CF 5B                      	  pop bx
  3661 000016D0 58                      	  pop ax
  3662 000016D1 B92000                  	mov cx, 32
  3663 000016D4 29CF                    	sub di, cx
  3664 000016D6 1E                      	push ds
  3665 000016D7 06                      	 push es
  3666 000016D8 1F                      	 pop ds
  3667 000016D9 56                      	push si
  3668 000016DA 89FE                    	mov si, di		; ds:si -> entry in directory buffer
  3669 000016DC 89DF                    	mov di, bx
  3670 000016DE 8EC0                    	mov es, ax		; es:di -> destination for entry
  3671 000016E0 F3A4                    	rep movsb
  3672 000016E2 5E                      	pop si
  3673 000016E3 1F                      	pop ds
  3674 000016E4 89D7                    	  mov di, dx		; restore si:di = loaded FAT sector
  3675 000016E6 F8                      	clc
  3676 000016E7 C3                      	retn
  3677                                  
  3678                                  
  3679                                  ; (iniload.asm code continues here)
  3680                                  
  3681                                  		; INP:	dx:ax = cluster - 2 (0-based cluster)
  3682                                  		; OUT:	cx:bx = input dx:ax
  3683                                  		;	dx:ax = first sector of that cluster
  3684                                  		; CHG:	-
  3685                                  clust_to_first_sector:
  3686 000016E8 52                      	push dx
  3687 000016E9 50                      	push ax
  3688 000016EA 52                      	 push dx
  3689 000016EB F726[E801]              	mul word [load_data - LOADDATA2 + ldClusterSize]
  3690 000016EF 93                      	xchg bx, ax
  3691 000016F0 87CA                    	xchg cx, dx
  3692 000016F2 58                      	 pop ax
  3693 000016F3 F726[E801]              	mul word [load_data - LOADDATA2 + ldClusterSize]
  3694 000016F7 85D2                    	test dx, dx
  3695 000016F9 7513                    	jnz .error_badchain
  3696 000016FB 92                      	xchg dx, ax
  3697 000016FC 01CA                    	add dx, cx
  3698 000016FE 720E                    	jc .error_badchain
  3699 00001700 93                      	xchg ax, bx
  3700                                  
  3701 00001701 0306[FC01]              	add ax, [load_data - LOADDATA2 + lsvDataStart]
  3702 00001705 1316[FE01]              	adc dx, [load_data - LOADDATA2 + lsvDataStart + 2]
  3703 00001709 7203                    	jc .error_badchain
  3704                                  				; dx:ax = first sector in cluster
  3705 0000170B 5B                      	pop bx
  3706 0000170C 59                      	pop cx			; cx:bx = cluster
  3707 0000170D C3                      	retn
  3708                                  
  3709                                  .error_badchain:
  3710 0000170E E9860F                  	jmp error_badchain
  3711                                  
  3712                                  
  3713                                  		; INP:	cx:bx = cluster (0-based)
  3714                                  		;	si:di = loaded FAT sector, -1 if none
  3715                                  		; OUT:	CY if no next cluster
  3716                                  		;	NC if next cluster found,
  3717                                  		;	 dx:ax = next cluster value (0-based)
  3718                                  		;	si:di = loaded FAT sector
  3719                                  		; CHG:	cx, bx
  3720                                  clust_next:
  3721 00001711 89D8                    	mov ax, bx
  3722 00001713 89CA                    	mov dx, cx
  3723                                  .dxax:
  3724 00001715 83C002                  	add ax, 2
  3725 00001718 83D200                  	adc dx, 0
  3726                                  
  3727 0000171B 06                      	push es
  3728 0000171C 803E[E601]10            	cmp byte [load_data - LOADDATA2 + ldFATType], 16
  3729 00001721 7503                    	jne @F
  3730 00001723 E98800                  	jmp strict near .fat16
  3731                                  @@:
  3732 00001726 7603                    	jna @F
  3733 00001728 E97F00                  	jmp strict near .fat32
  3734                                  @@:
  3735                                  
  3736                                  .fat12:
  3737                                  ; FAT12 entries are 12 bits, bytes are 8 bits. Ratio is 3 / 2,
  3738                                  ;  so multiply cluster number by 3 first, then divide by 2.
  3739                                  					; ax = cluster number (up to 12 bits set)
  3740 0000172B 89C2                    		mov dx, ax
  3741 0000172D D1E0                    		shl ax, 1		; = 2n (up to 13 bits set)
  3742 0000172F 01D0                    		add ax, dx		; = 2n+n = 3n (up to 14 bits set)
  3743 00001731 D1E8                    		shr ax, 1		; ax = byte offset into FAT (0..6129)
  3744                                  					; CF = whether to use high 12 bits
  3745 00001733 19C9                    		sbb cx, cx		; = -1 iff CY, else 0
  3746                                  
  3747                                  ; Use the calculated byte offset as an offset into the FAT
  3748                                  ;  buffer, which holds all of the FAT's relevant data.
  3749 00001735 8E06[F801]              		mov es, [load_data - LOADDATA2 + lsvFATSeg]
  3750 00001739 89C3                    		mov bx, ax		; -> 16-bit word in FAT to load
  3751                                  
  3752 0000173B F606[E701]02            	test byte [load_ldflags], ldfFATInvalid
  3753 00001740 7459                    	jz .fat12_have_fat	; already have it -->
  3754 00001742 51                      	push cx
  3755 00001743 31D2                    	xor dx, dx
  3756 00001745 F736[0B02]              	div word [load_data - LOADDATA2 + bsBPB + bpbBytesPerSector]
  3757                                  				; dx = remainder, byte offset
  3758                                  				; ax = sector to read
  3759 00001749 52                      	push dx
  3760 0000174A 31D2                    	xor dx, dx
  3761 0000174C 8B1E[F801]              	mov bx, [load_data - LOADDATA2 + lsvFATSeg]
  3762                                  
  3763 00001750 F606[E701]04            	testopt [load_ldflags], ldfFATBuffered
  3764 00001755 742A                    	jz .12_notbuffered
  3765 00001757 8B36[F601]              	mov si, word [load_data - LOADDATA2 + lsvFATSector + 2]
  3766 0000175B 8B3E[F401]              	mov di, word [load_data - LOADDATA2 + lsvFATSector + 0]
  3767                                  	; jmp .12_compare
  3768                                  .12_compare:
  3769 0000175F 39F2                    	cmp dx, si
  3770 00001761 7513                    	jne @F		; read sector
  3771 00001763 39F8                    	cmp ax, di
  3772 00001765 750F                    	jne @F		; read sector
  3773                                  		; sector is already buffered
  3774 00001767 8EC3                    	mov es, bx		; => FAT buffer
  3775 00001769 F9                      	stc
  3776 0000176A 1306[0E02]              	adc ax, [load_data - LOADDATA2 + bsBPB + bpbReservedSectors]
  3777 0000176E 11D2                    	adc dx, dx		; prepare for reading straddling entry sector
  3778 00001770 031E[EA01]              	add bx, word [load_sectorsizepara]
  3779                                  				; prepare for straddling sector
  3780 00001774 EB14                    	jmp @FF
  3781                                  @@:
  3782 00001776 89D6                    	mov si, dx
  3783 00001778 89C7                    	mov di, ax
  3784 0000177A 8916[F601]              	mov word [load_data - LOADDATA2 + lsvFATSector + 2], dx
  3785 0000177E A3[F401]                	mov word [load_data - LOADDATA2 + lsvFATSector + 0], ax
  3786                                  
  3787                                  .12_notbuffered:
  3788 00001781 0306[0E02]              	add ax, [load_data - LOADDATA2 + bsBPB + bpbReservedSectors]
  3789 00001785 11D2                    	adc dx, dx
  3790 00001787 E84704                  	call read_sector
  3791                                  @@:
  3792 0000178A 59                      	pop cx
  3793 0000178B 41                      	inc cx
  3794 0000178C 3B0E[0B02]              	cmp cx, word [load_data - LOADDATA2 + bsBPB + bpbBytesPerSector]
  3795 00001790 7505                    	jne .fat12_have_fat_cx_dec
  3796 00001792 06                      	push es
  3797 00001793 E83B04                  	call read_sector	; read second sector for straddling entry
  3798 00001796 07                      	pop es
  3799                                  
  3800                                  .fat12_have_fat_cx_dec:
  3801 00001797 49                      	dec cx
  3802 00001798 89CB                    	mov bx, cx
  3803 0000179A 59                      	pop cx
  3804                                  
  3805                                  .fat12_have_fat:
  3806                                  
  3807                                  ; get 16 bits from FAT
  3808 0000179B 268B07                  		mov ax, [es:bx]
  3809                                  
  3810 0000179E 80E104                  		and cl, 4	; = 4 iff CY after shift, else 0
  3811 000017A1 D3E8                    		shr ax, cl	; shift down iff odd entry, else unchanged
  3812 000017A3 25FF0F                  		and ax, 0FFFh	; insure it's only 12 bits
  3813 000017A6 31D2                    		xor dx, dx
  3814 000017A8 EB68                    	jmp short .gotvalue
  3815                                  
  3816                                  .fat32:
  3817                                  		; * 4 = byte offset into FAT (0--4000_0000h)
  3818 000017AA 01C0                    	add ax, ax
  3819 000017AC 11D2                    	adc dx, dx
  3820                                  .fat16:
  3821                                  		; * 2 = byte offset into FAT (0--2_0000h)
  3822 000017AE 01C0                    	add ax, ax
  3823 000017B0 11D2                    	adc dx, dx
  3824                                  
  3825 000017B2 50                      	 push ax
  3826 000017B3 92                      	xchg ax, dx
  3827 000017B4 31D2                    	xor dx, dx		; dx:ax = high word
  3828 000017B6 F736[0B02]              	div word [load_data - LOADDATA2 + bsBPB + bpbBytesPerSector]
  3829 000017BA 89C3                    	mov bx, ax
  3830 000017BC 58                      	 pop ax			; dx = remainder, ax = low word
  3831 000017BD F736[0B02]              	div word [load_data - LOADDATA2 + bsBPB + bpbBytesPerSector]
  3832 000017C1 87D3                    	xchg dx, bx		; dx:ax = result, bx = remainder
  3833                                  				; dx:ax = sector offset into FAT (0--200_0000h)
  3834                                  				; bx = byte offset into FAT sector (0--8190)
  3835 000017C3 F606[E701]04            	testopt [load_ldflags], ldfFATBuffered
  3836 000017C8 740A                    	jz .1632_notbuffered
  3837 000017CA 8B36[F601]              	mov si, word [load_data - LOADDATA2 + lsvFATSector + 2]
  3838 000017CE 8B3E[F401]              	mov di, word [load_data - LOADDATA2 + lsvFATSector + 0]
  3839 000017D2 EB07                    	jmp .1632_compare
  3840                                  
  3841                                  .1632_notbuffered:
  3842 000017D4 F606[E701]02            	test byte [load_ldflags], ldfFATInvalid
  3843 000017D9 7513                    	jnz .read_no_store	; always read -->
  3844                                  
  3845                                  .1632_compare:
  3846 000017DB 39F2                    	cmp dx, si
  3847 000017DD 7504                    	jne @F		; read sector
  3848 000017DF 39F8                    	cmp ax, di
  3849 000017E1 741B                    	je @FF		; sector is already buffered
  3850                                  @@:
  3851 000017E3 89D6                    	mov si, dx
  3852 000017E5 89C7                    	mov di, ax
  3853 000017E7 8916[F601]              	mov word [load_data - LOADDATA2 + lsvFATSector + 2], dx
  3854 000017EB A3[F401]                	mov word [load_data - LOADDATA2 + lsvFATSector + 0], ax
  3855                                  
  3856                                  .read_no_store:
  3857 000017EE 53                      	push bx
  3858 000017EF 0306[0E02]              	add ax, [load_data - LOADDATA2 + bsBPB + bpbReservedSectors]
  3859 000017F3 83D200                  	adc dx, 0
  3860 000017F6 8B1E[F801]              	mov bx, [load_data - LOADDATA2 + lsvFATSeg]
  3861 000017FA E8D403                  	call read_sector
  3862 000017FD 5B                      	pop bx
  3863                                  @@:
  3864 000017FE 8E06[F801]              	mov es, [load_data - LOADDATA2 + lsvFATSeg]
  3865 00001802 31D2                    	xor dx, dx
  3866 00001804 268B07                  	mov ax, [es:bx]
  3867                                  
  3868 00001807 803E[E601]10            	cmp byte [load_data - LOADDATA2 + ldFATType], 16
  3869 0000180C 7404                    	je @F
  3870 0000180E 268B5702                	mov dx, [es:bx + 2]
  3871                                  @@:
  3872                                  .gotvalue:
  3873 00001812 07                      	pop es
  3874                                  
  3875                                  		; INP:	dx:ax = cluster value, 2-based
  3876                                  		; OUT:	dx:ax -= 2 (makes it 0-based)
  3877                                  		;	CY iff invalid cluster
  3878                                  check_clust:
  3879 00001813 80E60F                  	and dh, 0Fh
  3880 00001816 83E802                  	sub ax, 2
  3881 00001819 83DA00                  	sbb dx, 0
  3882                                  
  3883 0000181C 803E[E601]10            	cmp byte [load_data - LOADDATA2 + ldFATType], 16
  3884 00001821 7707                    	ja .fat32
  3885 00001823 740B                    	je .fat16
  3886                                  
  3887                                  .fat12:
  3888 00001825 3DF50F                  	cmp ax, 0FF7h - 2
  3889 00001828 EB09                    	jmp short .common
  3890                                  
  3891                                  .fat32:
  3892 0000182A 81FAFF0F                	cmp dx, 0FFFh
  3893 0000182E 7203                    	jb @F		; CY here means valid ...-
  3894                                  
  3895                                  .fat16:
  3896 00001830 83F8F5                  	cmp ax, 0FFF7h - 2
  3897                                  @@:			;  -... or if NC first, CY here also
  3898                                  .common:
  3899 00001833 F5                      	cmc		; NC if valid
  3900 00001834 720E                    	jc .ret
  3901 00001836 3B16[C201]              	cmp dx, word [load_data - LOADDATA2 + ldMaxCluster + 2]
  3902 0000183A 7504                    	jne @F
  3903 0000183C 3B06[C001]              	cmp ax, word [load_data - LOADDATA2 + ldMaxCluster]
  3904                                  @@:
  3905 00001840 7701                    	ja .ret_CY
  3906 00001842 A8                      	db __TEST_IMM8	; (skip stc, NC)
  3907                                  .ret_CY:
  3908 00001843 F9                      	stc
  3909                                  .ret:
  3910 00001844 C3                      	retn
  3911                                  
  3912                                  
  3913                                  partition_table equ load_partition_table
  3914                                  partition_table.end equ load_partition_table.end
  3915                                  %define _SCANPTAB_PREFIX
  3916                                  %define _SCANPTAB_DEBUG4_PREFIX
  3917                                  %assign _PARTITION_TABLE_IN_CS 0
  3918                                  %define _BASE bp
  3919                                  %include "scanptab.asm"
     1                              <1> 
     2                              <1> %if 0
     3                              <1> 
     4                              <1> scanptab - Scan partition table
     5                              <1>  2019, 2025 by E. C. Masloch
     6                              <1> 
     7                              <1> Usage of the works is permitted provided that this
     8                              <1> instrument is retained with the works, so that any entity
     9                              <1> that uses the works is notified of this instrument.
    10                              <1> 
    11                              <1> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    12                              <1> 
    13                              <1> %endif
    14                              <1> 
    15                              <1> 	; _SCANPTAB_PREFIX = prefix for our variables and functions
    16                              <1> 	; _SCANPTAB_DEBUG4_PREFIX = prefix for d4 function calls
    17                              <1> 	numdef PARTITION_TABLE_IN_CS, 1
    18                              <1> 	numdef BOOTCMD_FAIL_ERROR, 1
    19                              <1> 	numdef SPT_ELD, 0
    20                              <1> 	numdef SPT_MULTIPASS, 0
    21                              <1> %if _SPT_ELD
    22                              <1>  %define sptrel reloc
    23                              <1>  %define sptinternal internaldatarelocation
    24                              <1>  %define sptexternal linkdatarelocation
    25                              <1> 	numdef MODE, 1
    26                              <1> %else
    27                              <1>  %define sptrel
    28                              <1>  %define sptinternal comment
    29                              <1>  %define sptexternal comment
    30                              <1> 	numdef MODE, 0
    31                              <1> %endif
    32                              <1> 	gendef BASE, ss:bx
    33                              <1> %ifidn _BASE, ss:bx
    34                              <1> %elifidn _BASE, bp
    35                              <1> %else
    36                              <1>  %error Invalid base
    37                              <1> %endif
    38                              <1> 
    39                              <1> %if _MODE
    40                              <1>  %include "scanptab.mac"
    41                              <1> %endif
    42                              <1> 
    43                              <1> 
    44                              <1> 		; INP:	byte [%load_unit] = unit to scan
    45                              <1> 		;	cx = function to call for each partition
    46                              <1> 		; OUT:	function called for each partition
    47                              <1> 		; CHG:	di, si, ax, bx, (cx), dx, es
    48                              <1> 		; STT:	ds => data segment (used for %load_* variables, unless bp-based)
    49                              <1> 		;
    50                              <1> 		; Note:	Calls %read_partition_table (in this module),
    51                              <1> 		;	 which calls %read_ae_512_bytes, which calls
    52                              <1> 		;	 read_sector. The read_sector base must be
    53                              <1> 		;	 zero and the geometry must be initialised.
    54                              <1> 
    55                              <1> 		; Function in cx is called with:
    56                              <1> 		; INP:	es:si -> partition table entry,
    57                              <1> 		;	 si = %partition_table .. %partition_table+48,
    58                              <1> 		;	 es = ss (if not _PARTITION_TABLE_IN_CS)
    59                              <1> 		;	 es = cs (if _PARTITION_TABLE_IN_CS)
    60                              <1> 		;	byte [%load_current_partition] = partition number,
    61                              <1> 		;	 0 for diskette (unpartitioned),
    62                              <1> 		;	 1 to 4 for primary partitions,
    63                              <1> 		;	 5+ for logical partitions
    64                              <1> 		;	_BASE + di -> above part table metadata,
    65                              <1> 		;	 dword [_BASE + di - 4] = root (outermost extended position)
    66                              <1> 		;	 dword [_BASE + di - 8] = base (current table position)
    67                              <1> 		;	 dword [es:si + piStart] = local partition start
    68                              <1> 		;	 base + local start = absolute partition start
    69                              <1> 		;	_BASE -> bp value (dummy if _BASE is not bp),
    70                              <1> 		;		near return address of scan_partitions
    71                              <1> 		; CHG:	ax, (cx), dx, bx (unless part of _BASE)
    72                              <1> 		; STT:	ds => data segment (used for load_* variables, unless bp-based)
    73                              <1> 		; Note:	preserves (cx), si, di, ds, es, (bp), _BASE
    74                              <1> 		;
    75                              <1> 		; Note:	If the function returns to scan_partitions,
    76                              <1> 		;	 cx must be left as the function to call for
    77                              <1> 		;	 subsequent partitions afterwards.
    78                              <1> 		; Note:	May load sp from _BASE then pop bp then return
    79                              <1> 		;	 near if the scan should stop after the call.
    80                              <1> %if _SPT_MULTIPASS
    81                              <1> %[_SCANPTAB_PREFIX]scan_priority_primary:
    82                              <1> %else
    83                              <1> %[_SCANPTAB_PREFIX]scan_partitions:
    84                              <1> %endif
    85 00001845 8326[3005]00        <1> sptrel	and word [ %[_SCANPTAB_PREFIX]load_partition_cycle], 0
    86                              <1> sptinternal -3
    87                              <1> d4	call %[_SCANPTAB_DEBUG4_PREFIX]d4message
    88                              <1> d4	asciz "In scan_partitions",13,10
    89                              <1> 
    90 0000184A 55                  <1> 	push bp
    91                              <1> %ifidn _BASE, ss:bx
    92                              <1> 	mov bx, sp
    93                              <1> %elifidn _BASE, bp
    94 0000184B 89E5                <1> 	mov bp, sp
    95                              <1> %endif
    96 0000184D 31FF                <1> 	xor di, di
    97 0000184F 57                  <1> 	push di		; [_BASE+di-2]
    98 00001850 57                  <1> 	push di		; [_BASE+di-4]
    99 00001851 57                  <1> 	push di		; [_BASE+di-6]
   100 00001852 57                  <1> 	push di		; [_BASE+di-8]
   101                              <1> %if _MODE
   102                              <1> sptrel	mov word [ %[_SCANPTAB_PREFIX]load_scan_flags ], di
   103                              <1> sptinternal
   104                              <1> %endif
   105                              <1> 
   106 00001853 803E[4002]80        <1> sptrel	cmp byte [ %[_SCANPTAB_PREFIX]load_unit], 80h
   107                              <1> sptinternal -3
   108 00001858 7325                <1> 	jae @F
   109                              <1> 
   110 0000185A 57                  <1> 	push di
   111 0000185B 51                  <1> 	push cx
   112                              <1> %if _PARTITION_TABLE_IN_CS
   113                              <1> 	 push cs
   114                              <1> %else
   115 0000185C 16                  <1> 	 push ss
   116                              <1> %endif
   117 0000185D 07                  <1> 	 pop es
   118 0000185E BF[0001]            <1> sptrel	mov di, %[_SCANPTAB_PREFIX]partition_table
   119                              <1> sptinternal
   120 00001861 31C0                <1> 	xor ax, ax
   121 00001863 B92000              <1> 	mov cx, (4 * 16) >> 1
   122 00001866 F3AB                <1> 	rep stosw			; initialise fake partition table
   123 00001868 59                  <1> 	pop cx
   124 00001869 5F                  <1> 	pop di
   125 0000186A BE[0001]            <1> sptrel	mov si, %[_SCANPTAB_PREFIX]partition_table
   126                              <1> sptinternal
   127                              <1> 					; -> fake PARTINFO
   128 0000186D 26C60480            <1> 	mov byte [es:si + piBoot], 80h	; fake primary active
   129 00001871 26C64404FF          <1> 	mov byte [es:si + piType], 0FFh	; fake a type
   130 00001876 C606[3905]00        <1> sptrel	mov byte [ %[_SCANPTAB_PREFIX]load_current_partition], 0	; special: 0 = diskette
   131                              <1> sptinternal -3				; piLength is 0, too
   132 0000187B FFD1                <1> 	call cx
   133                              <1> 
   134 0000187D EB66                <1> 	jmp %[_SCANPTAB_PREFIX]scan_logical.end
   135                              <1> 
   136                              <1> 
   137                              <1> @@:
   138                              <1>  %if _SPT_MULTIPASS
   139                              <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_active_priority
   140                              <1> sptinternal -3			; active primary first ?
   141                              <1> 	jz .end
   142                              <1>  %endif
   143                              <1> 
   144 0000187F 31C0                <1> 	xor ax, ax
   145 00001881 31D2                <1> 	xor dx, dx
   146                              <1> d4	call %[_SCANPTAB_DEBUG4_PREFIX]d4message
   147                              <1> d4	asciz "In scan_partitions (before first call to read_partition_table)",13,10
   148 00001883 E8DA00              <1> 	call %[_SCANPTAB_PREFIX]read_partition_table.first
   149                              <1> d4	call %[_SCANPTAB_DEBUG4_PREFIX]d4message
   150                              <1> d4	asciz "In scan_partitions (after first call to read_partition_table)",13,10
   151 00001886 BE[0001]            <1> sptrel	mov si, %[_SCANPTAB_PREFIX]partition_table
   152                              <1> sptinternal
   153 00001889 8816[3905]          <1> sptrel	mov byte [ %[_SCANPTAB_PREFIX]load_current_partition], dl	; = 0
   154                              <1> sptinternal
   155                              <1> %if _SPT_ELD
   156                              <1> sptrel	mov word [ %[_SCANPTAB_PREFIX]load_current_extended_and_is], dx	; = 0
   157                              <1> sptinternal
   158                              <1> %endif
   159                              <1> 
   160                              <1> %if _MODE
   161                              <1>  %ifn _SPT_MULTIPASS
   162                              <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_active_priority
   163                              <1> sptinternal -3			; active primary first ?
   164                              <1> 	jz .active_ignored
   165                              <1>  %endif
   166                              <1> 
   167                              <1> .loop_active_primary:
   168                              <1> 
   169                              <1> sptrel	inc byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   170                              <1> sptinternal
   171                              <1> 	mov al, byte [es:si + piType]
   172                              <1> 	cmp al, 0
   173                              <1> 	je .loop_active_primary_skip
   174                              <1> 	cmp byte [es:si + piBoot], 0
   175                              <1> 	je .loop_active_primary_skip
   176                              <1> 
   177                              <1> 		; INP:	al = partition type
   178                              <1> 		; OUT:	CY if an LBA or FAT32 type that's disabled
   179                              <1> 		;	NC, ZR if known type we can access
   180                              <1> 		;	NC, NZ if unknown type
   181                              <1> 	call %[_SCANPTAB_PREFIX]load_is_known
   182                              <1> 	jc .loop_active_primary_skip
   183                              <1> 	jnz .loop_active_primary_skip
   184                              <1> 
   185                              <1> 	call cx			; es:si -> partition table entry
   186                              <1> 				; byte [load_current_partition] = which
   187                              <1> 	jmp .active_done
   188                              <1> 
   189                              <1> .loop_active_primary_skip:
   190                              <1> 	add si, 16
   191                              <1> sptrel	cmp si, strict word %[_SCANPTAB_PREFIX]partition_table.end
   192                              <1> sptinternal
   193                              <1> 	jb .loop_active_primary
   194                              <1> 
   195                              <1> .active_done:
   196                              <1> %if _SPT_MULTIPASS
   197                              <1> .end:
   198                              <1> %ifidn _BASE, bp
   199                              <1> 	mov sp, bp		; restore sp
   200                              <1> 	pop bp
   201                              <1> %else
   202                              <1> 	mov sp, bx		; restore sp
   203                              <1> 	pop ax			; (discard dummy bp value)
   204                              <1> %endif
   205                              <1> 	retn			; and bye
   206                              <1> 
   207                              <1> 
   208                              <1> %[_SCANPTAB_PREFIX]scan_early_primary:
   209                              <1> sptrel	and word [ %[_SCANPTAB_PREFIX]load_partition_cycle], 0
   210                              <1> sptinternal -3
   211                              <1> 
   212                              <1> 	push bp
   213                              <1> %ifidn _BASE, ss:bx
   214                              <1> 	mov bx, sp
   215                              <1> %elifidn _BASE, bp
   216                              <1> 	mov bp, sp
   217                              <1> %endif
   218                              <1> 	xor di, di
   219                              <1> 	push di		; [_BASE+di-2]
   220                              <1> 	push di		; [_BASE+di-4]
   221                              <1> 	push di		; [_BASE+di-6]
   222                              <1> 	push di		; [_BASE+di-8]
   223                              <1> 	xor ax, ax
   224                              <1> 	xor dx, dx
   225                              <1> 
   226                              <1> %if _MODE
   227                              <1> sptrel	mov word [ %[_SCANPTAB_PREFIX]load_scan_flags ], ax
   228                              <1> sptinternal
   229                              <1> %endif
   230                              <1> 
   231                              <1> 	call %[_SCANPTAB_PREFIX]read_partition_table.first
   232                              <1> sptrel	mov byte [ %[_SCANPTAB_PREFIX]load_current_partition], dl	; = 0
   233                              <1> sptinternal
   234                              <1> %if _SPT_ELD
   235                              <1> sptrel	mov word [ %[_SCANPTAB_PREFIX]load_current_extended_and_is], dx	; = 0
   236                              <1> sptinternal
   237                              <1> %endif
   238                              <1> %else
   239                              <1> sptrel	mov byte [ %[_SCANPTAB_PREFIX]load_current_partition], 0
   240                              <1> sptinternal -3
   241                              <1> %endif
   242                              <1> sptrel	mov si, %[_SCANPTAB_PREFIX]partition_table
   243                              <1> sptinternal
   244                              <1> 
   245                              <1> 
   246                              <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_active_priority
   247                              <1> sptinternal -3			; active primary first ?
   248                              <1> 	jz .active_ignored
   249                              <1> 
   250                              <1> .loop_active_skip:
   251                              <1> 
   252                              <1> sptrel	inc byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   253                              <1> sptinternal
   254                              <1> 	mov al, byte [es:si + piType]
   255                              <1> 	cmp al, 0
   256                              <1> 	je .loop_active_skip_skip
   257                              <1> 	cmp byte [es:si + piBoot], 0
   258                              <1> 	je .loop_active_skip_skip
   259                              <1> 
   260                              <1> 		; INP:	al = partition type
   261                              <1> 		; OUT:	CY if an LBA or FAT32 type that's disabled
   262                              <1> 		;	NC, ZR if known type we can access
   263                              <1> 		;	NC, NZ if unknown type
   264                              <1> 	call %[_SCANPTAB_PREFIX]load_is_known
   265                              <1> 	jc .loop_active_skip_skip
   266                              <1> 	jnz .loop_active_skip_skip
   267                              <1> sptrel	mov al, byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   268                              <1> sptinternal
   269                              <1> sptrel	mov byte [ %[_SCANPTAB_PREFIX]load_scan_flags + 1], al
   270                              <1> sptinternal
   271                              <1> sptrel	setopt [ %[_SCANPTAB_PREFIX]load_scan_flags ], 32
   272                              <1> sptinternal -3			; mark as had a primary partition yet
   273                              <1> 	jmp .active_skip_done
   274                              <1> 
   275                              <1> .loop_active_skip_skip:
   276                              <1> 	add si, 16
   277                              <1> sptrel	cmp si, strict word %[_SCANPTAB_PREFIX]partition_table.end
   278                              <1> sptinternal
   279                              <1> 	jb .loop_active_skip
   280                              <1> 
   281                              <1> .active_skip_done:
   282                              <1> sptrel	mov si, %[_SCANPTAB_PREFIX]partition_table
   283                              <1> sptinternal
   284                              <1> sptrel	mov byte [ %[_SCANPTAB_PREFIX]load_current_partition], 0
   285                              <1> sptinternal -3
   286                              <1> 
   287                              <1> %endif
   288                              <1> 
   289                              <1> .active_ignored:
   290                              <1> .loop_primary_parts:
   291 0000188D FE06[3905]          <1> sptrel	inc byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   292                              <1> sptinternal
   293 00001891 26807C0400          <1> 	cmp byte [es:si + piType], 0
   294 00001896 7402                <1> 	je .loop_primary_skip
   295                              <1> 
   296                              <1> %if _MODE
   297                              <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_active_priority
   298                              <1> sptinternal -3			; active primary first ?
   299                              <1> 	jz @F			; no -->
   300                              <1> sptrel	mov al, byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   301                              <1> sptinternal
   302                              <1> sptrel	cmp byte [ %[_SCANPTAB_PREFIX]load_scan_flags + 1], al
   303                              <1> sptinternal
   304                              <1> 	je .ignoreprimary
   305                              <1> @@:
   306                              <1> 
   307                              <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_scan_flags ], 32
   308                              <1> sptinternal -3			; had a primary partition yet ?
   309                              <1> 	jz .callprimary		; no, accept it -->
   310                              <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_ignore_subsequent_primary
   311                              <1> sptinternal -3			; ignore subsequent primary ?
   312                              <1> 	jnz .ignoreprimary	; yes, ignore it -->
   313                              <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_subsequent_primary_after
   314                              <1> sptinternal -3			; subsequent after ?
   315                              <1> 	jnz .ignoreprimary
   316                              <1> .callprimary:
   317                              <1> %endif
   318 00001898 FFD1                <1> 	call cx			; es:si -> partition table entry
   319                              <1> 				; byte [load_current_partition] = which
   320                              <1> .ignoreprimary:
   321                              <1> .loop_primary_skip:
   322 0000189A 83C610              <1> 	add si, 16
   323 0000189D 81FE[4001]          <1> sptrel	cmp si, strict word %[_SCANPTAB_PREFIX]partition_table.end
   324                              <1> sptinternal
   325 000018A1 72EA                <1> 	jb .loop_primary_parts
   326                              <1> 
   327                              <1> %if _SPT_MULTIPASS
   328                              <1> .end:
   329                              <1> %ifidn _BASE, bp
   330                              <1> 	mov sp, bp		; restore sp
   331                              <1> 	pop bp
   332                              <1> %else
   333                              <1> 	mov sp, bx		; restore sp
   334                              <1> 	pop ax			; (discard dummy bp value)
   335                              <1> %endif
   336                              <1> 	retn			; and bye
   337                              <1> 
   338                              <1> 
   339                              <1> %[_SCANPTAB_PREFIX]scan_logical:
   340                              <1> 	push bp
   341                              <1> %ifidn _BASE, ss:bx
   342                              <1> 	mov bx, sp
   343                              <1> %elifidn _BASE, bp
   344                              <1> 	mov bp, sp
   345                              <1> %endif
   346                              <1> 	xor di, di
   347                              <1> 	push di		; [_BASE+di-2]
   348                              <1> 	push di		; [_BASE+di-4]
   349                              <1> 	push di		; [_BASE+di-6]
   350                              <1> 	push di		; [_BASE+di-8]
   351                              <1> 
   352                              <1> 	xor ax, ax
   353                              <1> 	xor dx, dx
   354                              <1> %if _MODE
   355                              <1> sptrel	mov word [ %[_SCANPTAB_PREFIX]load_scan_flags ], ax
   356                              <1> sptinternal
   357                              <1> %endif
   358                              <1> sptrel	mov word [ %[_SCANPTAB_PREFIX]load_partition_cycle], ax
   359                              <1> sptinternal
   360                              <1> 	call %[_SCANPTAB_PREFIX]read_partition_table.first
   361                              <1> sptrel	mov byte [ %[_SCANPTAB_PREFIX]load_current_partition], 4
   362                              <1> sptinternal -3
   363                              <1> %if _SPT_ELD
   364                              <1> sptrel	mov word [ %[_SCANPTAB_PREFIX]load_current_extended_and_is], dx	; = 0
   365                              <1> sptinternal
   366                              <1> %endif
   367                              <1> %else
   368                              <1> 
   369                              <1> %[_SCANPTAB_PREFIX]scan_logical:
   370                              <1> %endif
   371                              <1> .:
   372                              <1> d4	call %[_SCANPTAB_DEBUG4_PREFIX]d4message
   373                              <1> d4	asciz "In scan_logical.",13,10
   374                              <1> 
   375                              <1> %if _MODE
   376                              <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_traditional_order_logical
   377                              <1> sptinternal -3
   378                              <1> 	jz .nottraditional
   379                              <1> 
   380                              <1> sptrel	mov si, %[_SCANPTAB_PREFIX]partition_table
   381                              <1> sptinternal
   382                              <1> .loop_traditional:
   383                              <1> sptrel	inc word [ %[_SCANPTAB_PREFIX]load_partition_cycle]
   384                              <1> sptinternal
   385                              <1> 	jz .got_partition_cycle
   386                              <1> 
   387                              <1> 	mov al, [es:si + piType]
   388                              <1> 
   389                              <1> %ifidn _BASE, bp
   390                              <1> 	xor bx, bx
   391                              <1> %endif
   392                              <1> 	test al, al
   393                              <1> 	jz .next_traditional
   394                              <1> 	cmp al, 0Fh		; extended partition (LBA aware) ?
   395                              <1> 	je .next_traditional	; yes -->
   396                              <1> 	and al, ~80h		; extended partition Linux (85h) ?
   397                              <1> 	cmp al, 05h		;  or extended partition DOS (05h) ?
   398                              <1> 	je .next_traditional	; yes -->
   399                              <1> 
   400                              <1> %ifidn _BASE, bp
   401                              <1> 	cmp word [_BASE+di-2], bx
   402                              <1> 	jne .logical_traditional
   403                              <1> 	cmp word [_BASE+di-4], bx
   404                              <1> %else
   405                              <1> 	cmp word [_BASE+di-2], 0
   406                              <1> 	jne .logical_traditional
   407                              <1> 	cmp word [_BASE+di-4], 0
   408                              <1> %endif
   409                              <1> 	je .next_traditional
   410                              <1> .logical_traditional:
   411                              <1> 
   412                              <1> %if _MODE
   413                              <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_scan_flags ], 32
   414                              <1> sptinternal -3			; had a logical partition yet ?
   415                              <1> 	jz .calllogicaltrad	; no, accept it -->
   416                              <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_ignore_subsequent_logical
   417                              <1> sptinternal -3			; ignore subsequent logical ?
   418                              <1> 	jnz .ignorelogicaltrad	; yes, ignore it -->
   419                              <1> .calllogicaltrad:
   420                              <1> %endif
   421                              <1> 
   422                              <1> sptrel	inc byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   423                              <1> sptinternal
   424                              <1> 	jz .error_too_many_partitions
   425                              <1> 	call cx			; (sets load_scan_flags & 32 if recognised)
   426                              <1> 		; CHG: ax, (cx), dx, bx if _BASE = bp
   427                              <1> 		; preserve: (cx), si, di, ds, es, bx if _BASE = ss:bx
   428                              <1> .ignorelogicaltrad:
   429                              <1> .next_traditional:
   430                              <1> 	add si, 16		; -> next partition table entry
   431                              <1> sptrel	cmp si, strict word %[_SCANPTAB_PREFIX]partition_table.end
   432                              <1> sptinternal			; was last?
   433                              <1> 	jb .loop_traditional	; no, loop -->
   434                              <1> 
   435                              <1> sptrel	setopt [ %[_SCANPTAB_PREFIX]load_scan_flags ], 32
   436                              <1> sptinternal -3			; mark as had logical
   437                              <1> 
   438                              <1> .nottraditional:
   439                              <1> %endif
   440                              <1> 
   441 000018A3 BE[0001]            <1> sptrel	mov si, %[_SCANPTAB_PREFIX]partition_table
   442                              <1> sptinternal
   443                              <1> .loop:
   444 000018A6 FF06[3005]          <1> sptrel	inc word [ %[_SCANPTAB_PREFIX]load_partition_cycle]
   445                              <1> sptinternal
   446 000018AA 7503E9A500          <1> 	jz .got_partition_cycle
   447                              <1> 
   448 000018AF 268A4404            <1> 	mov al, [es:si + piType]
   449                              <1> 
   450                              <1> %ifidn _BASE, bp
   451 000018B3 31DB                <1> 	xor bx, bx
   452                              <1> %endif
   453 000018B5 84C0                <1> 	test al, al
   454 000018B7 741F                <1> 	jz .next
   455                              <1> %if _MODE
   456                              <1> %ifidn _BASE, bp
   457                              <1> 	cmp word [_BASE+di-2], bx
   458                              <1> 	jne .allextended
   459                              <1> 	cmp word [_BASE+di-4], bx
   460                              <1> %else
   461                              <1> 	cmp word [_BASE+di-2], 0
   462                              <1> 	jne .allextended
   463                              <1> 	cmp word [_BASE+di-4], 0
   464                              <1> %endif
   465                              <1> 	jne .allextended
   466                              <1> 
   467                              <1> sptrel	mov ah, [ %[_SCANPTAB_PREFIX]load_mode ]
   468                              <1> sptinternal
   469                              <1> 	cmp al, 5
   470                              <1> 	je .check
   471                              <1> 	shr ah, 1
   472                              <1> 	shr ah, 1
   473                              <1> 	cmp al, 15
   474                              <1> 	je .check
   475                              <1> 	shr ah, 1
   476                              <1> 	shr ah, 1
   477                              <1> 	cmp al, 85h
   478                              <1> 	jne .notextended
   479                              <1> .check:
   480                              <1> sptrel	clropt [ %[_SCANPTAB_PREFIX]load_scan_flags ], 16
   481                              <1> sptinternal -3			; new outermost extended
   482                              <1> 
   483                              <1> 	test ah, 11b
   484                              <1> 	jz .push		; if it is 00b = all, always accept -->
   485                              <1> 	test ah, 10b		; if prior is NZ but this is zero
   486                              <1> 	jz .ignoreextended	;  then we have 01b, always ignore -->
   487                              <1> 	test ah, 01b		; if prior is NZ and this is NZ,
   488                              <1> 	; jnz .firsttype	;  then we have 11b, accept first of type
   489                              <1> 	mov ah, 1		; flag 1 for 10b
   490                              <1> 	jz @F			; if ZR, we have 10b, accept first of all types with 10b
   491                              <1> .firsttype:
   492                              <1> 	mov ah, 2		; flag 2 for 11b type 5
   493                              <1> 	cmp al, 15
   494                              <1> 	jb @F
   495                              <1> 	mov ah, 4		; flag 4 for 11b type 15
   496                              <1> 	je @F
   497                              <1> 	mov ah, 8		; flag 8 for 11b type 85h
   498                              <1> @@:
   499                              <1> sptrel	test byte [ %[_SCANPTAB_PREFIX]load_scan_flags ], ah
   500                              <1> sptinternal			; seen one of those before ?
   501                              <1> 	jnz .ignoreextended	; yes, ignore -->
   502                              <1> sptrel	or byte [ %[_SCANPTAB_PREFIX]load_scan_flags ], ah
   503                              <1> sptinternal			; no, note seen it now
   504                              <1> 	jmp .push		; and process extended partition -->
   505                              <1> %endif
   506                              <1> 
   507                              <1> .allextended:
   508                              <1> %if _MODE
   509                              <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_ignore_subsequent_nested
   510                              <1> sptinternal -3
   511                              <1> 	jz @F
   512                              <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_scan_flags ], 16
   513                              <1> sptinternal -3
   514                              <1> 	jnz .ignoreextended
   515                              <1> @@:
   516                              <1> %endif
   517 000018B9 3C0F                <1> 	cmp al, 0Fh		; extended partition (LBA aware) ?
   518 000018BB 742C                <1> 	je .push		; yes -->
   519 000018BD 247F                <1> 	and al, ~80h		; extended partition Linux (85h) ?
   520 000018BF 3C05                <1> 	cmp al, 05h		;  or extended partition DOS (05h) ?
   521 000018C1 7426                <1> 	je .push		; yes -->
   522                              <1> .notextended:
   523                              <1> 
   524                              <1> %ifidn _BASE, bp
   525 000018C3 395BFE              <1> 	cmp word [_BASE+di-2], bx
   526 000018C6 7505                <1> 	jne .logical
   527 000018C8 395BFC              <1> 	cmp word [_BASE+di-4], bx
   528                              <1> %else
   529                              <1> 	cmp word [_BASE+di-2], 0
   530                              <1> 	jne .logical
   531                              <1> 	cmp word [_BASE+di-4], 0
   532                              <1> %endif
   533 000018CB 740B                <1> 	je .next
   534                              <1> .logical:
   535                              <1> 
   536                              <1> %if _MODE
   537                              <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_scan_flags ], 32
   538                              <1> sptinternal -3			; had a logical partition yet ?
   539                              <1> 	jz .calllogical		; no, accept it -->
   540                              <1> sptrel	test word [ %[_SCANPTAB_PREFIX]load_mode ], strict word 		mode_ignore_subsequent_logical | mode_traditional_order_logical
   542                              <1> sptinternal -4			; ignore subsequent logical or post-trad run ?
   543                              <1> 	jnz .ignorelogical	; yes, ignore it -->
   544                              <1> .calllogical:
   545                              <1> %endif
   546                              <1> 
   547 000018CD FE06[3905]          <1> sptrel	inc byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   548                              <1> sptinternal
   549 000018D1 7503E98400          <1> 	jz .error_too_many_partitions
   550 000018D6 FFD1                <1> 	call cx			; (sets load_scan_flags & 32 if recognised)
   551                              <1> 		; CHG: ax, (cx), dx, bx if _BASE = bp
   552                              <1> 		; preserve: (cx), si, di, ds, es, bx if _BASE = ss:bx
   553                              <1> .ignorelogical:
   554                              <1> .ignoreextended:
   555                              <1> .next:
   556 000018D8 83C610              <1> 	add si, 16		; -> next partition table entry
   557 000018DB 81FE[4001]          <1> sptrel	cmp si, strict word %[_SCANPTAB_PREFIX]partition_table.end
   558                              <1> sptinternal			; was last?
   559 000018DF 72C5                <1> 	jb .loop		; no, loop -->
   560 000018E1 85FF                <1> 	test di, di		; still some on stack?
   561 000018E3 7546                <1> 	jnz .pop		; yes, pop
   562                              <1> .end:
   563                              <1> %ifidn _BASE, bp
   564 000018E5 89EC                <1> 	mov sp, bp		; restore sp
   565 000018E7 5D                  <1> 	pop bp
   566                              <1> %else
   567                              <1> 	mov sp, bx		; restore sp
   568                              <1> 	pop ax			; (discard dummy bp value)
   569                              <1> %endif
   570                              <1> %if _MODE && ! _SPT_MULTIPASS
   571                              <1> 	jmp scan_subsequent_primary
   572                              <1> %else
   573 000018E8 C3                  <1> 	retn			; and bye
   574                              <1> %endif
   575                              <1> 
   576                              <1> 
   577                              <1> .push:
   578                              <1> d4	call %[_SCANPTAB_DEBUG4_PREFIX]d4message
   579                              <1> d4	asciz "In scan_logical.push",13,10
   580                              <1> 
   581                              <1> %if _SPT_ELD
   582                              <1> sptrel	rol byte [ %[_SCANPTAB_PREFIX]extended], 1
   583                              <1> sptinternal
   584                              <1> 	jnc @F
   585                              <1> sptrel	not byte [ %[_SCANPTAB_PREFIX]load_is_extended]
   586                              <1> sptinternal
   587                              <1> 
   588                              <1> 	push si
   589                              <1> 	sub di, 10			; address temporary root and base
   590                              <1> 	push word [_BASE+di+10-2]
   591                              <1> 	push word [_BASE+di+10-4]	; copy root as root
   592                              <1> 	push word [_BASE+di+10-2]
   593                              <1> 	push word [_BASE+di+10-4]	; copy root as base
   594                              <1> 		; Extended partitions always have LBA start values
   595                              <1> 		;  relative to the outermost extended partition.
   596                              <1> 		;  Therefore the "root" must be used as base for
   597                              <1> 		;  this call to always get the expected address
   598                              <1> 		;  from dword [bp - di - 8] + dword [es:si + 8].
   599                              <1> 
   600                              <1> 	call cx
   601                              <1> 
   602                              <1> 	add sp, 8			; discard temporary root and base
   603                              <1> 	add di, 10			; point back to prior root and base
   604                              <1> 	pop si				; undo last part of the stack frame
   605                              <1> 
   606                              <1> sptrel	not byte [ %[_SCANPTAB_PREFIX]load_is_extended]
   607                              <1> sptinternal
   608                              <1> sptrel	inc byte [ %[_SCANPTAB_PREFIX]load_current_extended]
   609                              <1> sptinternal
   610                              <1> %ifidn _BASE, bp
   611                              <1> 	xor bx, bx
   612                              <1> %endif
   613                              <1> @@:
   614                              <1> %endif
   615                              <1> 
   616 000018E9 56                  <1> 	push si
   617                              <1> .push_check_empty_next:
   618 000018EA 83C610              <1> 	add si, 16		; -> next
   619 000018ED 81FE[4001]          <1> sptrel	cmp si, strict word %[_SCANPTAB_PREFIX]partition_table.end
   620                              <1> sptinternal			; at end?
   621 000018F1 734A                <1> 	jae .replace		; yes, no other partitions found, replace -->
   622 000018F3 26807C0400          <1> 	cmp byte [es:si + piType], 0	; is this a partition?
   623 000018F8 74F0                <1> 	je .push_check_empty_next	; no, check next -->
   624                              <1> 				; found a partition after this, do push
   625                              <1> 				; (possibly logical or another extended)
   626                              <1> .push_check_is_not_empty:
   627                              <1> d4	call %[_SCANPTAB_DEBUG4_PREFIX]d4message
   628                              <1> d4	asciz "In scan_logical.push_check_is_not_empty",13,10
   629                              <1> 
   630                              <1> %if _MODE
   631                              <1> 	xor ax, ax		; sentinel 0 = accept more logicals
   632                              <1> 
   633                              <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_traditional_order_logical
   634                              <1> sptinternal -3
   635                              <1> 	jnz .traditionalsentinel
   636                              <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_scan_flags ], 32
   637                              <1> sptinternal -3			; had a logical partition in this table ?
   638                              <1> 	jz @F			; no, no need to reset -->
   639                              <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_ignore_subsequent_logical
   640                              <1> sptinternal -3			; ignore subsequent logical ?
   641                              <1> 	jz @F			; no -->
   642                              <1> .traditionalsentinel:
   643                              <1> 	mov al, 64		; sentinel 64 = no more logicals
   644                              <1> @@:
   645                              <1> sptrel	clropt [ %[_SCANPTAB_PREFIX]load_scan_flags ], 32
   646                              <1> sptinternal -3			; accept a logical partition in next table
   647                              <1> %endif
   648                              <1> 
   649 000018FA 5E                  <1> 	pop si			; restore -> partition table entry
   650                              <1> %if _MODE
   651                              <1> 	push word [es:si + piStart]
   652                              <1> 	mov dx, word [es:si + piStart + 2]	; get extended partition offset
   653                              <1> 	add si, ax		; now -> behind partition_table if sentinel set
   654                              <1> 	pop ax
   655                              <1> %endif
   656 000018FB 56                  <1> 	push si			; stored at word [_BASE+di-10]
   657 000018FC 83EF0A              <1> 	sub di, 10
   658 000018FF FF7308              <1> 	push word [_BASE+di+10-2]
   659 00001902 FF7306              <1> 	push word [_BASE+di+10-4]	; copy root
   660                              <1> %ifn _MODE
   661 00001905 268B4408            <1> 	mov ax, word [es:si + piStart]
   662 00001909 268B540A            <1> 	mov dx, word [es:si + piStart + 2]	; get extended partition offset
   663                              <1> %endif
   664 0000190D 0343FC              <1> 	add ax, word [_BASE+di-4]
   665 00001910 1353FE              <1> 	adc dx, word [_BASE+di-2]	; add in root to get absolute sector number
   666                              <1> 
   667 00001913 52                  <1> 	push dx
   668 00001914 50                  <1> 	push ax			; new base
   669                              <1> 
   670                              <1> .replace_common:
   671                              <1> %ifidn _BASE, bp
   672 00001915 395BFE              <1> 	cmp word [_BASE+di-2], bx	; have a (nonzero) root?
   673 00001918 750B                <1> 	jne .have_root
   674 0000191A 395BFC              <1> 	cmp word [_BASE+di-4], bx
   675                              <1> %else
   676                              <1> 	cmp word [_BASE+di-2], 0	; have a (nonzero) root?
   677                              <1> 	jne .have_root
   678                              <1> 	cmp word [_BASE+di-4], 0
   679                              <1> %endif
   680 0000191D 7506                <1> 	jne .have_root		; yes -->
   681                              <1> 
   682 0000191F 8953FE              <1> 	mov word [_BASE+di-2], dx
   683 00001922 8943FC              <1> 	mov word [_BASE+di-4], ax	; set root
   684                              <1> .have_root:
   685                              <1> 
   686 00001925 E83800              <1> 	call %[_SCANPTAB_PREFIX]read_partition_table.first
   687 00001928 E978FF              <1> 	jmp .
   688                              <1> 
   689                              <1> .pop:
   690                              <1> d4	call %[_SCANPTAB_DEBUG4_PREFIX]d4message
   691                              <1> d4	asciz "In scan_logical.pop",13,10
   692                              <1> 
   693                              <1> %if _MODE
   694                              <1> sptrel	setopt [ %[_SCANPTAB_PREFIX]load_scan_flags ], 16
   695                              <1> sptinternal -3			; remember we found a nested extended partition
   696                              <1> 				;  so we can ignore others in the same outermost
   697                              <1> %endif
   698                              <1> 
   699 0000192B 83C70A              <1> 	add di, 10
   700 0000192E 83C408              <1> 	add sp, 8
   701 00001931 5E                  <1> 	pop si
   702                              <1> 
   703                              <1> %if _MODE
   704                              <1> sptrel	clropt [ %[_SCANPTAB_PREFIX]load_scan_flags ], 32
   705                              <1> sptinternal -3			; accept a logical partition in this table
   706                              <1> sptrel	cmp si, 64 + %[_SCANPTAB_PREFIX]partition_table
   707                              <1> sptinternal			; sentinel set ?
   708                              <1> 	jb @F			; no -->
   709                              <1> sptrel	setopt [ %[_SCANPTAB_PREFIX]load_scan_flags ], 32
   710                              <1> sptinternal -3			; do not accept a logical partition in this table
   711                              <1> 	sub si, 64		; undo sentinel addition
   712                              <1> @@:
   713                              <1> %endif
   714 00001932 8B43F8              <1> 	mov ax, word [_BASE+di-8]
   715 00001935 8B53FA              <1> 	mov dx, word [_BASE+di-6]
   716 00001938 E82500              <1> 	call %[_SCANPTAB_PREFIX]read_partition_table.reload
   717 0000193B EB9B                <1> 	jmp .next
   718                              <1> 
   719                              <1> .replace:
   720                              <1> d4	call %[_SCANPTAB_DEBUG4_PREFIX]d4message
   721                              <1> d4	asciz "In scan_logical.replace",13,10
   722                              <1> %if _MODE
   723                              <1> sptrel	clropt [ %[_SCANPTAB_PREFIX]load_scan_flags ], 32
   724                              <1> sptinternal -3			; accept a logical partition in next table
   725                              <1> %endif
   726                              <1> 
   727 0000193D 5E                  <1> 	pop si				; (discard)
   728                              <1> .replace_no_pop:
   729 0000193E 268B4408            <1> 	mov ax, word [es:si + piStart]
   730 00001942 268B540A            <1> 	mov dx, word [es:si + piStart + 2]	; get extended partition offset
   731 00001946 0343FC              <1> 	add ax, word [_BASE+di - 4]
   732 00001949 1353FE              <1> 	adc dx, word [_BASE+di - 2]	; add in root
   733 0000194C 8943F8              <1> 	mov word [_BASE+di - 8], ax
   734 0000194F 8953FA              <1> 	mov word [_BASE+di - 6], dx	; set base
   735                              <1> 
   736 00001952 EBC1                <1> 	jmp .replace_common
   737                              <1> 
   738                              <1> 
   739                              <1> %if _BOOTCMD_FAIL_ERROR
   740                              <1> .got_partition_cycle:
   741 00001954 BA[0000]            <1> sptrel	mov dx, msg.boot_partition_cycle_error
   742                              <1> sptinternal
   743 00001957 E902EC              <1> 	jmp bootcmd.fail
   744                              <1> 
   745                              <1> .error_too_many_partitions:
   746 0000195A BA[0000]            <1> sptrel	mov dx, msg.boot_too_many_partitions_error
   747                              <1> sptinternal
   748 0000195D E9FCEB              <1> 	jmp bootcmd.fail
   749                              <1> %endif
   750                              <1> 
   751                              <1> 
   752                              <1> %if _MODE
   753                              <1> @@:
   754                              <1> 	retn
   755                              <1> 
   756                              <1> scan_subsequent_primary:
   757                              <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_ignore_subsequent_primary
   758                              <1> sptinternal -3			; ignore subsequent primary ?
   759                              <1> 	jnz @B			; yes -->
   760                              <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_subsequent_primary_after
   761                              <1> sptinternal -3			; subsequent after ?
   762                              <1> 	jz @B			; no -->
   763                              <1> 
   764                              <1> 	push bp
   765                              <1> %ifidn _BASE, ss:bx
   766                              <1> 	mov bx, sp
   767                              <1> %elifidn _BASE, bp
   768                              <1> 	mov bp, sp
   769                              <1> %endif
   770                              <1> 	xor di, di
   771                              <1> 	push di		; [_BASE+di-2]
   772                              <1> 	push di		; [_BASE+di-4]
   773                              <1> 	push di		; [_BASE+di-6]
   774                              <1> 	push di		; [_BASE+di-8]
   775                              <1> 
   776                              <1> %if ! _SPT_MULTIPASS
   777                              <1> sptrel	mov word [ %[_SCANPTAB_PREFIX]load_scan_flags ], di
   778                              <1> sptinternal
   779                              <1> %endif
   780                              <1> 
   781                              <1> 	xor ax, ax
   782                              <1> 	xor dx, dx
   783                              <1> 
   784                              <1> %if _SPT_MULTIPASS
   785                              <1> sptrel	mov word [ %[_SCANPTAB_PREFIX]load_scan_flags ], ax
   786                              <1> sptinternal
   787                              <1> %endif
   788                              <1> 
   789                              <1> 	call %[_SCANPTAB_PREFIX]read_partition_table.reload
   790                              <1> 				; (re)read MBR
   791                              <1> sptrel	mov si, %[_SCANPTAB_PREFIX]partition_table
   792                              <1> sptinternal
   793                              <1> sptrel	mov byte [ %[_SCANPTAB_PREFIX]load_current_partition], dl	; = 0
   794                              <1> sptinternal
   795                              <1> %if _SPT_ELD
   796                              <1> sptrel	mov word [ %[_SCANPTAB_PREFIX]load_current_extended_and_is], dx	; = 0
   797                              <1> sptinternal
   798                              <1> %endif
   799                              <1> 
   800                              <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_active_priority
   801                              <1> sptinternal -3			; active primary first ?
   802                              <1> 	jz .detect_lowest
   803                              <1> 
   804                              <1> .loop_active_skip:
   805                              <1> 
   806                              <1> sptrel	inc byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   807                              <1> sptinternal
   808                              <1> 	mov al, byte [es:si + piType]
   809                              <1> 	cmp al, 0
   810                              <1> 	je .loop_active_skip_skip
   811                              <1> 	cmp byte [es:si + piBoot], 0
   812                              <1> 	je .loop_active_skip_skip
   813                              <1> 
   814                              <1> 		; INP:	al = partition type
   815                              <1> 		; OUT:	CY if an LBA or FAT32 type that's disabled
   816                              <1> 		;	NC, ZR if known type we can access
   817                              <1> 		;	NC, NZ if unknown type
   818                              <1> 	call %[_SCANPTAB_PREFIX]load_is_known
   819                              <1> 	jc .loop_active_skip_skip
   820                              <1> 	jnz .loop_active_skip_skip
   821                              <1> sptrel	mov al, byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   822                              <1> sptinternal
   823                              <1> sptrel	mov byte [ %[_SCANPTAB_PREFIX]load_scan_flags + 1], al
   824                              <1> sptinternal
   825                              <1> 	jmp .active_skip_done
   826                              <1> 
   827                              <1> .loop_active_skip_skip:
   828                              <1> 	add si, 16
   829                              <1> sptrel	cmp si, strict word %[_SCANPTAB_PREFIX]partition_table.end
   830                              <1> sptinternal
   831                              <1> 	jb .loop_active_skip
   832                              <1> 
   833                              <1> .detect_lowest:
   834                              <1> sptrel	mov si, %[_SCANPTAB_PREFIX]partition_table
   835                              <1> sptinternal
   836                              <1> sptrel	mov byte [ %[_SCANPTAB_PREFIX]load_current_partition], 0
   837                              <1> sptinternal -3
   838                              <1> 
   839                              <1> .loop_lowest:
   840                              <1> sptrel	inc byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   841                              <1> sptinternal
   842                              <1> 	mov al, byte [es:si + piType]
   843                              <1> 	cmp al, 0
   844                              <1> 	je .loop_lowest_skip_skip
   845                              <1> 
   846                              <1> 		; INP:	al = partition type
   847                              <1> 		; OUT:	CY if an LBA or FAT32 type that's disabled
   848                              <1> 		;	NC, ZR if known type we can access
   849                              <1> 		;	NC, NZ if unknown type
   850                              <1> 	call %[_SCANPTAB_PREFIX]load_is_known
   851                              <1> 	jc .loop_lowest_skip_skip
   852                              <1> 	jnz .loop_lowest_skip_skip
   853                              <1> sptrel	mov al, byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   854                              <1> sptinternal
   855                              <1> sptrel	mov byte [ %[_SCANPTAB_PREFIX]load_scan_flags + 1], al
   856                              <1> sptinternal
   857                              <1> 	jmp .lowest_skip_done
   858                              <1> 
   859                              <1> .loop_lowest_skip_skip:
   860                              <1> 	add si, 16
   861                              <1> sptrel	cmp si, strict word %[_SCANPTAB_PREFIX]partition_table.end
   862                              <1> sptinternal
   863                              <1> 	jb .loop_lowest
   864                              <1> 	jmp .end		; none found
   865                              <1> 
   866                              <1> .lowest_skip_done:
   867                              <1> .active_skip_done:
   868                              <1> sptrel	mov si, %[_SCANPTAB_PREFIX]partition_table
   869                              <1> sptinternal
   870                              <1> sptrel	mov byte [ %[_SCANPTAB_PREFIX]load_current_partition], 0
   871                              <1> sptinternal -3
   872                              <1> 
   873                              <1> .loop_primary_parts:
   874                              <1> sptrel	inc byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   875                              <1> sptinternal
   876                              <1> 	cmp byte [es:si + piType], 0
   877                              <1> 	je .loop_primary_skip
   878                              <1> 
   879                              <1> %if _MODE
   880                              <1> sptrel	mov al, byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   881                              <1> sptinternal
   882                              <1> sptrel	cmp byte [ %[_SCANPTAB_PREFIX]load_scan_flags + 1], al
   883                              <1> sptinternal
   884                              <1> 	je .ignoreprimary
   885                              <1> %endif
   886                              <1> 	call cx			; es:si -> partition table entry
   887                              <1> 				; byte [load_current_partition] = which
   888                              <1> .ignoreprimary:
   889                              <1> .loop_primary_skip:
   890                              <1> 	add si, 16
   891                              <1> sptrel	cmp si, strict word %[_SCANPTAB_PREFIX]partition_table.end
   892                              <1> sptinternal
   893                              <1> 	jb .loop_primary_parts
   894                              <1> 
   895                              <1> .end:
   896                              <1> %ifidn _BASE, bp
   897                              <1> 	mov sp, bp		; restore sp
   898                              <1> 	pop bp
   899                              <1> %else
   900                              <1> 	mov sp, bx		; restore sp
   901                              <1> 	pop ax			; (discard dummy bp value)
   902                              <1> %endif
   903                              <1> 	retn
   904                              <1> %endif
   905                              <1> 
   906                              <1> 
   907                              <1> 		; if _PARTITION_TABLE_IN_CS:
   908                              <1> 		; INP:  dx:ax = partition table sector to read
   909                              <1> 		; CHG:	ax, dx
   910                              <1> 		; OUT:  es = cs
   911                              <1> 		;       64 bytes [es:partition_table] = partition table
   912                              <1> 		;       does not return if error
   913                              <1> 
   914                              <1> 		; else:
   915                              <1> 		; INP:  dx:ax = partition table sector to read
   916                              <1> 		; CHG:	ax, dx
   917                              <1> 		; OUT:  es = ss
   918                              <1> 		;       64 bytes [es:partition_table] = partition table
   919                              <1> 		;       does not return if error
   920                              <1> %[_SCANPTAB_PREFIX]read_partition_table:
   921                              <1> %if _SPT_ELD
   922                              <1> .first:
   923                              <1> 	db __TEST_IMM8			; NC, skip stc
   924                              <1> .reload:
   925                              <1> 	stc
   926                              <1> %else
   927                              <1> .first:
   928                              <1> .reload:
   929                              <1> %endif
   930                              <1> 
   931 00001960 53                  <1> 	push bx
   932                              <1> %if _SPT_ELD
   933                              <1> sptrel	mov bx, word [buffersegment]
   934                              <1> sptinternal
   935                              <1> %elifidn _BASE, bp
   936 00001961 8B1E[0000]          <1> 	mov bx, word [auxbuff_segorsel]	; bx => auxbuff
   937                              <1> %else
   938                              <1> 	mov bx, word [bp + ldSectorSeg]
   939                              <1> %endif
   940 00001965 E85702              <1> 	call %[_SCANPTAB_PREFIX]read_ae_512_bytes
   941 00001968 5B                  <1> 	pop bx
   942 00001969 26813EFE0155AA      <1> 	cmp word [es:510], 0AA55h
   943 00001970 7518                <1> 	jne .signature_fail
   944 00001972 1E                  <1> 	 push ds
   945 00001973 57                  <1> 	 push di
   946 00001974 56                  <1> 	 push si
   947 00001975 51                  <1> 	 push cx
   948 00001976 06                  <1> 	push es
   949 00001977 1F                  <1> 	pop ds
   950 00001978 BEBE01              <1> 	mov si, 510 - 4*16		; ds:si -> partition table in sectorseg
   951                              <1> %if _PARTITION_TABLE_IN_CS
   952                              <1> 	push cs
   953                              <1> %else
   954 0000197B 16                  <1> 	push ss
   955                              <1> %endif
   956 0000197C 07                  <1> 	pop es
   957 0000197D BF[0001]            <1> sptrel	mov di, %[_SCANPTAB_PREFIX]partition_table
   958                              <1> sptinternal				; es:di -> cs:%[_SCANPTAB_PREFIX]partition_table
   959 00001980 B92000              <1> 	mov cx, 4*16 / 2
   960 00001983 F3A5                <1> 	rep movsw
   961 00001985 59                  <1> 	 pop cx
   962 00001986 5E                  <1> 	 pop si
   963 00001987 5F                  <1> 	 pop di
   964 00001988 1F                  <1> 	 pop ds
   965 00001989 C3                  <1> 	retn
   966                              <1> 
   967                              <1> 
   968                              <1> %if _BOOTCMD_FAIL_ERROR
   969                              <1> .signature_fail:
   970 0000198A BA[0000]            <1> sptrel	mov dx, msg.bootfail_sig_parttable
   971                              <1> sptinternal
   972 0000198D E9CCEB              <1> 	jmp bootcmd.fail
   973                              <1> %endif
  3920                                  
  3921                                  
  3922                                  		; INP:	al = first character
  3923                                  		;	si -> next
  3924                                  		; OUT:	doesn't return if error
  3925                                  		;	bx:dx = number read
  3926                                  		;	al = character after the number
  3927                                  		;	si -> next
  3928                                  		; CHG:	cx, ax, di
  3929                                  boot_get_decimal_literal:
  3930 00001990 BA0A00                  	mov dx, 10		; set base: decimal
  3931                                  %if 1
  3932 00001993 B93940                  	mov cx, '9' | (('A'-10-1 + 10) << 8)
  3933                                  %else
  3934                                  	mov cl, dl
  3935                                  	add cl, '0'-1
  3936                                  	cmp cl, '9'
  3937                                  	jbe .lit_basebelow11
  3938                                  	mov cl, '9'
  3939                                  .lit_basebelow11:		; cl = highest decimal digit for base ('1'..'9')
  3940                                  	mov ch, dl
  3941                                  	add ch, 'A'-10-1	; ch = highest letter for base ('A'-x..'Z')
  3942                                  %endif
  3943 00001996 EB06                    	jmp @F
  3944                                  
  3945                                  
  3946                                  boot_get_hexadecimal_literal:
  3947 00001998 BA1000                  	mov dx, 16		; set base: hexadecimal
  3948                                  %if 1
  3949 0000199B B93946                  	mov cx, '9' | (('A'-10-1 + 16) << 8)
  3950                                  %else
  3951                                  	mov cl, dl
  3952                                  	add cl, '0'-1
  3953                                  	cmp cl, '9'
  3954                                  	jbe .lit_basebelow11
  3955                                  	mov cl, '9'
  3956                                  .lit_basebelow11:		; cl = highest decimal digit for base ('1'..'9')
  3957                                  	mov ch, dl
  3958                                  	add ch, 'A'-10-1	; ch = highest letter for base ('A'-x..'Z')
  3959                                  %endif
  3960                                  
  3961                                  @@:
  3962 0000199E B400                    	mov ah, 0
  3963 000019A0 31DB                    	xor bx, bx
  3964 000019A2 89D7                    	mov di, dx		; di = base
  3965                                  
  3966 000019A4 E8(0000)[0000]          	nearcall getexpression.lit_isdigit?	; first character must be a digit
  3967 000019A9 7245                    	jc .err2
  3968 000019AB 31D2                    	xor dx, dx		; initialize value
  3969                                  .lit_loopdigit:
  3970 000019AD 3C5F                    	cmp al, '_'
  3971 000019AF 7434                    	je .lit_skip
  3972 000019B1 E8(0000)[0000]          	nearcall getexpression.lit_isdigit?	; was last character ?
  3973 000019B6 7230                    	jc .lit_end		; yes -->
  3974 000019B8 E8(0000)                	call capitalise
  3975 000019BB 2C30                    	sub al, '0'
  3976 000019BD 3C09                    	cmp al, 9		; was decimal digit ?
  3977 000019BF 7602                    	jbe .lit_decimaldigit	; yes -->
  3978 000019C1 2C07                    	sub al, 'A'-('9'+1)	; else adjust for hexadecimal digit
  3979                                  .lit_decimaldigit:
  3980 000019C3 50                      	push ax
  3981 000019C4 89D0                    	mov ax, dx
  3982 000019C6 53                      	push bx
  3983 000019C7 F7E7                    	mul di			; multiply low word with base
  3984 000019C9 89D3                    	mov bx, dx
  3985 000019CB 89C2                    	mov dx, ax
  3986 000019CD 58                      	pop ax
  3987 000019CE 52                      	push dx
  3988 000019CF F7E7                    	mul di			; multiply high word with base
  3989 000019D1 85D2                    	test dx, dx
  3990 000019D3 5A                      	pop dx
  3991 000019D4 751A                    	jnz .err2		; overflow -->
  3992 000019D6 01C3                    	add bx, ax		; add them
  3993 000019D8 58                      	pop ax
  3994 000019D9 7215                    	jc .err2		; overflow -->
  3995 000019DB 00C2                    	add dl, al		; add in the new digit
  3996 000019DD 80D600                  	adc dh, 0
  3997 000019E0 83D300                  	adc bx, byte 0
  3998 000019E3 720B                    	jc .err2		; overflow -->
  3999                                  
  4000                                  .lit_skip:
  4001 000019E5 AC                      	lodsb
  4002 000019E6 EBC5                    	jmp short .lit_loopdigit
  4003                                  
  4004                                  .lit_end:
  4005 000019E8 E8(0000)[0000]          	nearcall isseparator?	; after the number, there must be a separator
  4006 000019ED 7501                    	jne .err2		; none here -->
  4007 000019EF C3                      	retn
  4008                                  
  4009                                  .err2:
  4010 000019F0 E9(0000)                	jmp error
  4011                                  
  4012                                  
  4013                                  query_geometry:
  4014 000019F3 E8(0000)                	call guard_auxbuff
  4015 000019F6 8A16[4002]              	mov dl, [load_unit]
  4016                                  ;	test dl, dl		; floppy?
  4017                                  ;	jns @F			; don't attempt query, might fail -->
  4018                                  	; Note that while the original PC BIOS doesn't support this function
  4019                                  	;  (for its diskettes), it does properly return the error code 01h.
  4020                                  	; https://sites.google.com/site/pcdosretro/ibmpcbios (IBM PC version 1)
  4021 000019FA B408                    	mov ah, 08h
  4022 000019FC 31C9                    	xor cx, cx		; initialise cl to 0
  4023 000019FE 890E[1A02]              	mov [load_heads], cx
  4024 00001A02 890E[1802]              	mov [load_sectors], cx
  4025 00001A06 31DB                    	xor bx, bx
  4026 00001A08 88D3                    	mov bl, dl
  4027 00001A0A F687[0000]04            	testopt [load_unit_flags + bx], lufForceGeometry
  4028 00001A0F 7512                    	jnz .try_bootsector
  4029                                  		; Note:	The int 13h function 08h call may change or
  4030                                  		;	 set ax, bx, cx, dx, es, di. es is left as
  4031                                  		;	 indeterminate afterwards, until the code at
  4032                                  		;	 .try_bootsector runs, or bootcmd.fail, or
  4033                                  		;	 the "mov es" in .got_sectors_heads.
  4034 00001A11 F9                      	stc			; initialise to CY
  4035 00001A12 E84901                  	call .int13_retry	; query drive geometry
  4036 00001A15 720C                    	jc .try_bootsector	; apparently failed -->
  4037 00001A17 88F2                    	mov dl, dh
  4038 00001A19 B600                    	mov dh, 0		; dx = maximum head number
  4039 00001A1B 42                      	inc dx			; dx = number of heads (H is 0-based)
  4040 00001A1C 89C8                    	mov ax, cx		; ax & 3Fh = maximum sector number
  4041 00001A1E 83E03F                  	and ax, 3Fh		; get sectors (number of sectors, S is 1-based)
  4042 00001A21 7523                    	jnz .got_sectors_heads	; valid (S is 1-based), use these -->
  4043                                  				; zero = invalid
  4044                                  .try_bootsector:
  4045 00001A23 8E06[0000]              	mov es, word [auxbuff_segorsel]	; es => auxbuff
  4046 00001A27 31DB                    	xor bx, bx			; es:bx -> auxbuff
  4047 00001A29 B80102                  	mov ax, 0201h			; read sector, 1 sector
  4048 00001A2C B90100                  	mov cx, 1			; sector 1 (1-based!), cylinder 0 (0-based)
  4049 00001A2F B600                    	mov dh, 0			; head 0 (0-based)
  4050 00001A31 8A16[4002]              	mov dl, [load_unit]
  4051 00001A35 F9                      	stc
  4052 00001A36 E82501                  	call .int13_retry
  4053 00001A39 7303E93D01              	jc .access_error
  4054                                  
  4055                                  		; note: the smallest supported sector size, 32 bytes,
  4056                                  		;  does contain these entries (offset 18h and 1Ah in sector)
  4057                                  		;  within the first BPB sector.
  4058 00001A3E 268B4718                	mov ax, word [es:bx + bsBPB + bpbCHSSectors]
  4059 00001A42 268B571A                	mov dx, word [es:bx + bsBPB + bpbCHSHeads]
  4060                                  
  4061                                  .got_sectors_heads:
  4062 00001A46 A3[1802]                	mov word [load_sectors], ax
  4063 00001A49 8916[1A02]              	mov word [load_heads], dx
  4064                                  
  4065 00001A4D 85C0                    	test ax, ax
  4066 00001A4F 7503E94601              	jz .invalid_sectors
  4067 00001A54 83F83F                  	cmp ax, 63
  4068 00001A57 7603E93E01              	ja .invalid_sectors
  4069 00001A5C 85D2                    	test dx, dx
  4070 00001A5E 7503E93E01              	jz .invalid_heads
  4071 00001A63 81FA0001                	cmp dx, 100h
  4072 00001A67 7603E93501              	ja .invalid_heads
  4073                                  
  4074 00001A6C 8E06[0000]              	mov es, word [auxbuff_segorsel]	; es => auxbuff
  4075 00001A70 31DB                    	xor bx, bx			; es:bx -> auxbuff
  4076 00001A72 31C0                    	xor ax, ax
  4077                                  
  4078                                  %if _AUXBUFFSIZE < 8192+2
  4079                                   %error Expecting to use auxbuff as sector size detection buffer
  4080                                  %endif
  4081                                  
  4082                                  d5	call d5dumpregs
  4083                                  d5	call d5message
  4084                                  d5	asciz 13,10,"In query_geometry 0",13,10
  4085                                  
  4086 00001A74 89DF                    	mov di, bx
  4087 00001A76 B90110                  	mov cx, (8192 + 2) >> 1
  4088                                  					; es:bx -> auxbuff, es:di = same
  4089 00001A79 F3AB                    	rep stosw			; fill buffer, di -> behind (auxbuff+8192+2)
  4090 00001A7B B80102                  	mov ax, 0201h			; read sector, 1 sector
  4091 00001A7E 41                      	inc cx				; sector 1 (1-based!), cylinder 0 (0-based)
  4092 00001A7F B600                    	mov dh, 0			; head 0 (0-based)
  4093 00001A81 8A16[4002]              	mov dl, [load_unit]
  4094 00001A85 F9                      	stc
  4095 00001A86 E8D500                  	call .int13_retry
  4096 00001A89 7303E9ED00              	jc .access_error
  4097                                  
  4098 00001A8E FD                      	std				; _AMD_ERRATUM_109_WORKAROUND does not apply
  4099 00001A8F AF                      	scasw				; -> auxbuff+8192 (at last word to sca)
  4100                                  d5	call d5dumpregs
  4101                                  d5	call d5message
  4102                                  d5	asciz 13,10,"In query_geometry 1",13,10
  4103 00001A90 B90110                  	mov cx, (8192 + 2) >> 1
  4104 00001A93 31C0                    	xor ax, ax
  4105 00001A95 F3AF                    	repe scasw
  4106 00001A97 83C704                  	add di, 4			; di -> first differing byte (from top)
  4107 00001A9A FC                      	cld
  4108 00001A9B 57                      	push di
  4109                                  
  4110 00001A9C 89DF                    	mov di, bx
  4111 00001A9E B90110                  	mov cx, (8192 + 2) >> 1
  4112 00001AA1 48                      	dec ax				; = FFFFh
  4113 00001AA2 F3AB                    	rep stosw
  4114                                  
  4115 00001AA4 B80102                  	mov ax, 0201h
  4116 00001AA7 41                      	inc cx
  4117 00001AA8 B600                    	mov dh, 0
  4118 00001AAA 8A16[4002]              	mov dl, [load_unit]
  4119 00001AAE F9                      	stc
  4120 00001AAF E8AC00                  	call .int13_retry
  4121 00001AB2 7303E9C400              	jc .access_error
  4122                                  
  4123 00001AB7 FD                      	std				; _AMD_ERRATUM_109_WORKAROUND does not apply
  4124 00001AB8 AF                      	scasw				; di -> auxbuff+8192 (last word to sca)
  4125                                  d5	call d5dumpregs
  4126                                  d5	call d5message
  4127                                  d5	asciz 13,10,"In query_geometry 2",13,10
  4128 00001AB9 5A                      	pop dx
  4129 00001ABA B8FFFF                  	mov ax, -1
  4130 00001ABD B90110                  	mov cx, (8192 + 2) >> 1
  4131 00001AC0 F3AF                    	repe scasw
  4132                                  %if 0
  4133                                  AAAB
  4134                                     ^
  4135                                  	sca B, match
  4136                                    ^
  4137                                  	sca B, mismatch
  4138                                   ^
  4139                                  	stop
  4140                                  %endif
  4141 00001AC2 83C704                  	add di, 4			; di -> first differing byte (from top)
  4142 00001AC5 FC                      	cld
  4143                                  
  4144                                  %if 0
  4145                                  0000000000000
  4146                                  AAAAAAAA00000
  4147                                  	^
  4148                                  FFFFFFFFFFFFF
  4149                                  AAAAAAAA00FFF
  4150                                  	  ^
  4151                                  %endif
  4152 00001AC6 39FA                    	cmp dx, di			; choose the higher one
  4153 00001AC8 7302                    	jae @F
  4154 00001ACA 89FA                    	mov dx, di
  4155                                  @@:
  4156 00001ACC 29DA                    	sub dx, bx			; dx = sector size
  4157                                  
  4158                                  d5	call d5dumpregs
  4159                                  d5	call d5message
  4160                                  d5	asciz 13,10,"In query_geometry 3",13,10
  4161                                  
  4162 00001ACE 81FA0220                	cmp dx, 8192 + 2
  4163 00001AD2 7203E9AE00              	jae .sector_too_large
  4164 00001AD7 B82000                  	mov ax, 32
  4165 00001ADA 39C2                    	cmp dx, ax
  4166 00001ADC 7303E9AB00              	jb .sector_too_small
  4167                                  @@:
  4168 00001AE1 39C2                    	cmp dx, ax
  4169 00001AE3 740C                    	je .got_match
  4170 00001AE5 3D0020                  	cmp ax, 8192
  4171 00001AE8 7203E9A600              	jae .sector_not_power
  4172 00001AED D1E0                    	shl ax, 1
  4173 00001AEF EBF0                    	jmp @B
  4174                                  
  4175                                  .got_match:
  4176 00001AF1 A3[0B02]                	mov word [load_sectorsize], ax
  4177 00001AF4 B104                    	mov cl, 4
  4178 00001AF6 D3E8                    	shr ax, cl
  4179 00001AF8 A3[EA01]                	mov word [load_sectorsizepara], ax
  4180                                  
  4181 00001AFB C606[E701]00            	mov byte [load_ldflags], 0
  4182 00001B00 8A16[4002]              	mov dl, [load_unit]
  4183 00001B04 31DB                    	xor bx, bx
  4184 00001B06 88D3                    	mov bl, dl
  4185 00001B08 F687[0000]01            	testopt [load_unit_flags + bx], lufForceCHS
  4186 00001B0D 752B                    	jnz .no_lba
  4187 00001B0F F687[0000]02            	testopt [load_unit_flags + bx], lufForceLBA
  4188 00001B14 7520                    	jnz .yes_lba
  4189                                  
  4190 00001B16 1E                      	push ds
  4191 00001B17 BB4000                  	mov bx, 40h	; bx = 40h
  4192 00001B1A 8EDB                    	mov ds, bx	; ds = 40h
  4193                                  ; Setting ds = 40h is a Book8088 bugfix, refer to
  4194                                  ;  http://www.bttr-software.de/forum/forum_entry.php?id=21061
  4195                                  
  4196 00001B1C B80041                  	mov ax, 4100h
  4197 00001B1F BBAA55                  	mov bx, 55AAh
  4198 00001B22 31C9                    	xor cx, cx
  4199 00001B24 30F6                    	xor dh, dh
  4200 00001B26 F9                      	stc
  4201 00001B27 CD13                    	int 13h		; 13.41.bx=55AA extensions installation check
  4202 00001B29 1F                      	pop ds
  4203 00001B2A 720E                    	jc .no_lba
  4204 00001B2C 81FB55AA                	cmp bx, 0AA55h
  4205 00001B30 7508                    	jne .no_lba
  4206 00001B32 D0E9                    	shr cl, 1	; support bitmap bit 0
  4207 00001B34 7304                    	jnc .no_lba
  4208                                  
  4209                                  .yes_lba:
  4210                                  %if ldfHasLBA != 1
  4211                                   %error Assuming ldfHasLBA is 1
  4212                                  %endif
  4213 00001B36 FE06[E701]              	inc byte [load_ldflags]
  4214                                  .no_lba:
  4215                                  
  4216 00001B3A A1[0000]                	mov ax, word [auxbuff_segorsel]	; ax => auxbuff
  4217 00001B3D 89C2                    	mov dx, ax
  4218 00001B3F 81C2FF01                	add dx, (8192 - 16) >> 4
  4219 00001B43 89C3                    	mov bx, ax
  4220 00001B45 89D1                    	mov cx, dx
  4221 00001B47 81E300F0                	and bx, 0F000h
  4222 00001B4B 81E100F0                	and cx, 0F000h
  4223 00001B4F 39D9                    	cmp cx, bx
  4224 00001B51 7504                    	jne @F
  4225 00001B53 A3[E401]                	mov word [load_sectorseg], ax
  4226 00001B56 C3                      	retn
  4227                                  
  4228                                  @@:
  4229 00001B57 BA[0000]                	mov dx, msg.boot_auxbuff_crossing
  4230 00001B5A B020                    	mov al, 20h
  4231 00001B5C EB48                    	jmp .error_common_j
  4232                                  
  4233                                  
  4234                                  .int13_retry:
  4235 00001B5E 9C                      	pushf
  4236 00001B5F 50                      	push ax
  4237 00001B60 CD13                    	int 13h		; first try
  4238 00001B62 730B                    	jnc @F		; NC, success on first attempt -->
  4239                                  
  4240                                  ; reset drive
  4241 00001B64 31C0                    	xor ax, ax
  4242 00001B66 CD13                    	int 13h
  4243 00001B68 7205                    	jc @F		; CY, reset failed, error in ah -->
  4244                                  
  4245                                  ; try read again
  4246 00001B6A 58                      	pop ax		; restore function number
  4247 00001B6B 9D                      	popf		; CF
  4248 00001B6C CD13                    	int 13h		; retry, CF error status, ah error number
  4249 00001B6E C3                      	retn
  4250                                  
  4251                                  @@:			; NC or CY, stack has function number
  4252 00001B6F 44                      	inc sp
  4253 00001B70 44                      	inc sp
  4254 00001B71 44                      	inc sp
  4255 00001B72 44                      	inc sp		; discard two words on stack, preserve CF
  4256 00001B73 C3                      	retn
  4257                                  
  4258                                  
  4259                                  .out_of_memory_error:
  4260 00001B74 BA[0000]                	mov dx, msg.boot_out_of_memory_error
  4261 00001B77 B021                    	mov al, 21h
  4262 00001B79 EB2B                    	jmp .error_common_j
  4263                                  .access_error:
  4264                                  %if _INPUT_FILE_BOOT
  4265 00001B7B E87A04                  	call yy_boot_file_not_found.if
  4266                                  		; harden not to do scriptspath attempt
  4267                                  		;  if some later access errors out
  4268                                  %endif
  4269 00001B7E BA[0000]                	mov dx, msg.boot_access_error
  4270 00001B81 B022                    	mov al, 22h
  4271 00001B83 EB21                    	jmp .error_common_j
  4272                                  .sector_too_large:
  4273 00001B85 BA[0000]                	mov dx, msg.boot_sector_too_large
  4274 00001B88 B023                    	mov al, 23h
  4275 00001B8A EB1A                    	jmp .error_common_j
  4276                                  .sector_too_small:
  4277 00001B8C BA[0000]                	mov dx, msg.boot_sector_too_small
  4278 00001B8F B024                    	mov al, 24h
  4279 00001B91 EB13                    	jmp .error_common_j
  4280                                  .sector_not_power:
  4281 00001B93 BA[0000]                	mov dx, msg.boot_sector_not_power
  4282 00001B96 B025                    	mov al, 25h
  4283 00001B98 EB0C                    	jmp .error_common_j
  4284                                  .invalid_sectors:
  4285 00001B9A BA[0000]                	mov dx, msg.boot_invalid_sectors
  4286 00001B9D B026                    	mov al, 26h
  4287 00001B9F EB05                    	jmp .error_common_j
  4288                                  .invalid_heads:
  4289 00001BA1 BA[0000]                	mov dx, msg.boot_invalid_heads
  4290 00001BA4 B027                    	mov al, 27h
  4291                                  .error_common_j:
  4292 00001BA6 B402                    	mov ah, 02h
  4293 00001BA8 E8(0000)                	call setrc
  4294 00001BAB E9AEE9                  	jmp bootcmd.fail
  4295                                  
  4296                                  
  4297                                  		; INP:	dx:ax = first sector
  4298                                  		;	bx:0 -> buffer
  4299                                  		; OUT:	dx:ax = sector number after last read
  4300                                  		;	es = input bx
  4301                                  		;	bx:0 -> buffer after last written
  4302                                  		; CHG:	-
  4303                                  		; STT:	ds = ss
  4304                                  read_ae_1536_bytes:
  4305 00001BAE 51                      	push cx
  4306 00001BAF 53                      	push bx
  4307 00001BB0 B90006                  	mov cx, 1536
  4308                                  .loop:
  4309 00001BB3 E81B00                  	call read_sector
  4310 00001BB6 2B0E[0B02]              	sub cx, word [load_data - LOADDATA2 + bsBPB + bpbBytesPerSector]
  4311 00001BBA 77F7                    	ja .loop
  4312 00001BBC 07                      	pop es
  4313 00001BBD 59                      	pop cx
  4314 00001BBE C3                      	retn
  4315                                  
  4316                                  		; INP:	dx:ax = first sector
  4317                                  		;	bx:0 -> buffer
  4318                                  		; OUT:	dx:ax = sector number after last read
  4319                                  		;	es = input bx
  4320                                  		;	bx:0 -> buffer after last written
  4321                                  		; CHG:	-
  4322                                  		; STT:	ds = ss
  4323                                  read_ae_512_bytes:
  4324 00001BBF 51                      	push cx
  4325 00001BC0 53                      	push bx
  4326 00001BC1 B90002                  	mov cx, 512
  4327                                  .loop:
  4328 00001BC4 E80A00                  	call read_sector
  4329 00001BC7 2B0E[0B02]              	sub cx, word [load_data - LOADDATA2 + bsBPB + bpbBytesPerSector]
  4330 00001BCB 77F7                    	ja .loop
  4331 00001BCD 07                      	pop es
  4332 00001BCE 59                      	pop cx
  4333 00001BCF C3                      	retn
  4334                                  
  4335                                  
  4336                                  		; Write a sector using Int13.03 or Int13.4300
  4337                                  		;
  4338                                  		; Protocol as for read_sector
  4339                                  write_sector:
  4340 00001BD0 A8                      	db __TEST_IMM8		; (skip stc, NC)
  4341                                  
  4342                                  		; Read a sector using Int13.02 or Int13.42
  4343                                  		;
  4344                                  		; INP:	dx:ax = sector number (within partition)
  4345                                  		;	bx:0-> buffer
  4346                                  		;	(_LBA) ds = ss
  4347                                  		;	dword[load_data - LOADDATA2 + bsBPB + bpbHiddenSectors]
  4348                                  		;	 = base sector number (dx:ax is added to this to get
  4349                                  		;	    the absolute sector number in the selected unit.)
  4350                                  		; OUT:	If unable to read,
  4351                                  		;	 ! jumps to error instead of returning
  4352                                  		;	If sector has been read,
  4353                                  		;	 dx:ax = next sector number (has been incremented)
  4354                                  		;	 bx:0-> next buffer (bx = es+word[load_sectorsizepara])
  4355                                  		;	 es = input bx
  4356                                  		; CHG:	-
  4357                                  		;
  4358                                  		; Note:	If error 09h (data boundary error) is returned,
  4359                                  		;	 the read is done into the load_sectorseg buffer,
  4360                                  		;	 then copied into the user buffer.
  4361                                  read_sector: section_of_function
  4362 00001BD1 F9                      	stc
  4363                                  
  4364                                  read_sector_CY_or_write_sector_NC:
  4365                                  	lframe near
  4366 00001BD2 5589E5                  	lenter
  4367                                  	lvar word, is_read_bit0
  4368 00001BD5 9C                      	 pushf
  4369                                  
  4370                                  .err: equ bootcmd.fail_read
  4371                                  d5	call d5dumpregs
  4372                                  d5	call d5message
  4373                                  d5	asciz 13,10,"In read_sector",13,10
  4374                                  
  4375 00001BD6 52                      	push dx
  4376 00001BD7 51                      	push cx
  4377 00001BD8 50                      	push ax
  4378 00001BD9 56                      	push si
  4379                                  
  4380 00001BDA 8EC3                    	mov es, bx
  4381                                  
  4382                                  ; DX:AX==LBA sector number
  4383                                  ; add partition start (= number of hidden sectors)
  4384 00001BDC 0306[1C02]              		add ax,[load_data - LOADDATA2 + bsBPB + bpbHiddenSectors + 0]
  4385 00001BE0 1316[1E02]              		adc dx,[load_data - LOADDATA2 + bsBPB + bpbHiddenSectors + 2]
  4386                                  
  4387 00001BE4 19F6                    	sbb si, si	; -1 if was CY, 0 else
  4388 00001BE6 F7DE                    	neg si		; 1 if was CY, 0 else
  4389 00001BE8 31C9                    	xor cx, cx
  4390 00001BEA 51                      	push cx
  4391 00001BEB 56                      	push si		; bit 32 = 1 if operating in 33-bit space
  4392 00001BEC 52                      	push dx
  4393 00001BED 50                      	push ax		; qword sector number (lpSector)
  4394 00001BEE 53                      	push bx
  4395 00001BEF 51                      	push cx		; bx:0 -> buffer (lpBuffer)
  4396 00001BF0 41                      	inc cx
  4397 00001BF1 51                      	push cx		; word number of sectors to read (lpCount)
  4398 00001BF2 B110                    	mov cl, 10h
  4399 00001BF4 51                      	push cx		; word size of disk address packet (lpSize)
  4400 00001BF5 89E6                    	mov si, sp	; ds:si -> disk address packet (on stack)
  4401                                  
  4402 00001BF7 F606[E701]01            	test byte [load_data - LOADDATA2 + ldFlags], ldfHasLBA
  4403 00001BFC 7503E9BA00              	jz .no_lba
  4404                                  
  4405                                  d5	call d5message
  4406                                  d5	asciz "In read_sector.lba",13,10
  4407                                  
  4408 00001C01 8A16[4002]              	mov dl, byte [load_unit]
  4409 00001C05 E89001                  	call .set_ah_function_42_or_43
  4410 00001C08 CD13                    	int 13h		; 13.42 extensions read
  4411 00001C0A 7203E9A600              	jnc .lba_done
  4412                                  
  4413 00001C0F 31C0                    	xor ax, ax
  4414 00001C11 CD13                    	int 13h
  4415 00001C13 7303E932E9              	jc .lba_error
  4416                                  
  4417                                  		; have to reset the LBAPACKET's lpCount, as the handler may
  4418                                  		;  set it to "the number of blocks successfully transferred".
  4419                                  		; (in any case, the high byte is still zero.)
  4420 00001C18 C6440201                	mov byte [si + lpCount], 1
  4421                                  
  4422 00001C1C E87901                  	call .set_ah_function_42_or_43
  4423 00001C1F CD13                    	int 13h
  4424 00001C21 7203E98F00              	jnc .lba_done
  4425                                  
  4426 00001C26 80FC09                  	cmp ah, 9	; data boundary error?
  4427 00001C29 7403E91CE9              	jne .lba_error
  4428                                  
  4429                                  .lba_sectorseg:
  4430                                  d4	call d4dumpregs
  4431                                  d4	call d4message
  4432                                  d4	asciz 13,10,"In read_sector.lba_sectorseg",13,10
  4433                                  
  4434 00001C2E F646FE01                	test byte [bp + ?is_read_bit0], 1
  4435 00001C32 7544                    	jnz .lba_sectorseg_read
  4436                                  
  4437                                  .lba_sectorseg_write:
  4438 00001C34 06                      	push es
  4439                                  
  4440 00001C35 1E                      	push ds
  4441 00001C36 56                      	push si
  4442 00001C37 57                      	push di
  4443 00001C38 8B0E[0B02]              	mov cx, word [load_sectorsize]
  4444 00001C3C 8E06[E401]              	mov es, word [load_sectorseg]	; => sectorseg
  4445                                  	; lds si, [si + lpBuffer + 0]
  4446 00001C40 8E5C06                  	mov ds, word [si + lpBuffer + 2]; => user buffer
  4447 00001C43 31F6                    	xor si, si
  4448 00001C45 31FF                    	xor di, di
  4449 00001C47 F3A4                    	rep movsb			; copy data into sectorseg
  4450 00001C49 5F                      	pop di
  4451 00001C4A 5E                      	pop si
  4452 00001C4B 1F                      	pop ds
  4453                                  
  4454 00001C4C 8E06[E401]              	 mov es, word [load_sectorseg]
  4455 00001C50 8C4406                  	 mov word [si + lpBuffer + 2], es
  4456                                  					; => sectorseg
  4457                                  	; and word [si + lpBuffer + 0], byte 0
  4458                                  
  4459 00001C53 C6440201                	mov byte [si + lpCount], 1
  4460 00001C57 B80043                  	mov ax, 4300h
  4461 00001C5A CD13                    	int 13h
  4462 00001C5C 7317                    	jnc @F
  4463                                  
  4464 00001C5E 31C0                    	xor ax, ax
  4465 00001C60 CD13                    	int 13h
  4466 00001C62 7303E9E3E8              	jc .lba_error
  4467                                  
  4468 00001C67 C6440201                	mov byte [si + lpCount], 1
  4469 00001C6B B80043                  	mov ax, 4300h
  4470 00001C6E CD13                    	int 13h
  4471 00001C70 7303E9D5E8              	jc .lba_error
  4472                                  @@:
  4473                                  
  4474 00001C75 07                      	pop es
  4475 00001C76 EB3D                    	jmp .lba_done
  4476                                  
  4477                                  
  4478                                  .lba_sectorseg_read:
  4479                                  		; the offset part of the pointer is already zero!
  4480                                  	; push word [si + lpBuffer + 0]
  4481 00001C78 06                      	push es				; => user buffer
  4482 00001C79 8E06[E401]              	 mov es, word [load_sectorseg]
  4483 00001C7D 8C4406                  	 mov word [si + lpBuffer + 2], es
  4484                                  	; and word [si + lpBuffer + 0], byte 0
  4485                                  
  4486 00001C80 C6440201                	mov byte [si + lpCount], 1
  4487 00001C84 E81101                  	call .set_ah_function_42_or_43
  4488 00001C87 CD13                    	int 13h
  4489 00001C89 7317                    	jnc .lba_sectorseg_done
  4490                                  
  4491 00001C8B 31C0                    	xor ax, ax
  4492 00001C8D CD13                    	int 13h
  4493 00001C8F 7303E9B6E8              	jc .lba_error
  4494                                  
  4495 00001C94 C6440201                	mov byte [si + lpCount], 1
  4496 00001C98 E8FD00                  	call .set_ah_function_42_or_43
  4497 00001C9B CD13                    	int 13h
  4498 00001C9D 7303E9A8E8              	jc .lba_error
  4499                                  .lba_sectorseg_done:
  4500                                  
  4501 00001CA2 31F6                    	xor si, si
  4502 00001CA4 07                      	pop es
  4503                                  	; pop cx
  4504 00001CA5 57                      	 push di
  4505                                  	; mov di, cx
  4506 00001CA6 31FF                    	xor di, di
  4507 00001CA8 8B0E[0B02]              	mov cx, word [load_sectorsize]
  4508 00001CAC 8E1E[E401]              	mov ds, word [load_sectorseg]
  4509 00001CB0 F3A4                    	rep movsb
  4510 00001CB2 5F                      	 pop di
  4511                                  
  4512 00001CB3 16                      	push ss
  4513 00001CB4 1F                      	pop ds
  4514                                  .lba_done:
  4515 00001CB5 83C410                  	add sp, 10h
  4516 00001CB8 E9CB00                  	jmp .done
  4517                                  
  4518                                  .lba_error: equ .err
  4519                                  
  4520                                  .no_lba:
  4521 00001CBB 83C408                  	add sp, 8
  4522 00001CBE 58                      	pop ax
  4523 00001CBF 5A                      	pop dx
  4524 00001CC0 5E                      	pop si
  4525 00001CC1 59                      	pop cx
  4526 00001CC2 85F6                    	test si, si
  4527 00001CC4 7532                    	jnz .err_4_NZ
  4528                                  
  4529                                  ; DX:AX=LBA sector number
  4530                                  ; divide by number of sectors per track to get sector number
  4531                                  ; Use 32:16 DIV instead of 64:32 DIV for 8088 compatability
  4532                                  ; Use two-step 32:16 divide to avoid overflow
  4533 00001CC6 89C1                    			mov cx,ax
  4534 00001CC8 89D0                    			mov ax,dx
  4535 00001CCA 31D2                    			xor dx,dx
  4536 00001CCC F736[1802]              			div word [load_sectors]
  4537 00001CD0 91                      			xchg cx,ax
  4538 00001CD1 F736[1802]              			div word [load_sectors]
  4539 00001CD5 87CA                    			xchg cx,dx
  4540                                  
  4541                                  ; DX:AX=quotient, CX=remainder=sector (S) - 1
  4542                                  ; divide quotient by number of heads
  4543 00001CD7 89C3                    			mov bx, ax
  4544 00001CD9 92                      			xchg ax, dx
  4545 00001CDA 31D2                    			xor dx, dx
  4546 00001CDC F736[1A02]              			div word [load_heads]
  4547 00001CE0 93                      			xchg bx, ax
  4548 00001CE1 F736[1A02]              			div word [load_heads]
  4549                                  
  4550                                  ; bx:ax=quotient=cylinder (C), dx=remainder=head (H)
  4551                                  ; move variables into registers for INT 13h AH=02h
  4552 00001CE5 88D6                    			mov dh, dl	; dh = head
  4553 00001CE7 41                      			inc cx		; cl5:0 = sector
  4554 00001CE8 86E8                    			xchg ch, al	; ch = cylinder 7:0, al = 0
  4555 00001CEA D1E8                    			shr ax, 1
  4556 00001CEC D1E8                    			shr ax, 1	; al7:6 = cylinder 9:8
  4557                                  	; bx has bits set iff it's > 0, indicating a cylinder >= 65536.
  4558 00001CEE 08FB                    			 or bl, bh	; collect set bits from bh
  4559 00001CF0 08C1                    			or cl, al	; cl7:6 = cylinder 9:8
  4560                                  	; ah has bits set iff it was >= 4, indicating a cylinder >= 1024.
  4561 00001CF2 08E3                    			 or bl, ah	; collect set bits from ah
  4562 00001CF4 8A16[4002]              			mov dl, [load_unit]
  4563                                  					; dl = drive
  4564                                  .err_4_NZ:
  4565 00001CF8 B404                    			mov ah, 04h	; error number: sector not found
  4566 00001CFA 7403E94BE8              			 jnz .err	; error if cylinder >= 1024 -->
  4567                                  					; ! bx = 0 (for 13.02 call)
  4568                                  
  4569                                  ; we call INT 13h AH=02h once for each sector. Multi-sector reads
  4570                                  ; may fail if we cross a track or 64K boundary
  4571 00001CFF BE1100                  			mov si, 16 + 1
  4572                                  .loop_chs_retry_repeat:
  4573 00001D02 E89F00                  			call .set_ax_function_0201_or_0301
  4574 00001D05 CD13                    			int 13h		; read one sector
  4575 00001D07 7349                    			jnc .done_j
  4576 00001D09 50                      			push ax
  4577 00001D0A 31C0                    			xor ax, ax
  4578 00001D0C CD13                    			int 13h		; reset disk
  4579 00001D0E 58                      			pop ax
  4580 00001D0F 4E                      			dec si		; another attempt ?
  4581 00001D10 75F0                    			jnz .loop_chs_retry_repeat	; yes -->
  4582                                  
  4583 00001D12 80FC09                  	cmp ah, 9	; data boundary error?
  4584 00001D15 7403E930E8              	jne .err
  4585                                  
  4586                                  .chs_sectorseg:
  4587                                  d4	call d4dumpregs
  4588                                  d4	call d4message
  4589                                  d4	asciz 13,10,"In read_sector.chs_sectorseg",13,10
  4590                                  
  4591 00001D1A F646FE01                	test byte [bp + ?is_read_bit0], 1
  4592 00001D1E 7534                    	jnz .chs_sectorseg_read
  4593                                  
  4594                                  .chs_sectorseg_write:
  4595 00001D20 06                      	push es
  4596                                  
  4597 00001D21 1E                      	push ds
  4598 00001D22 57                      	push di
  4599 00001D23 51                      	push cx
  4600 00001D24 8B0E[0B02]              	mov cx, word [load_sectorsize]
  4601 00001D28 06                      	push es
  4602 00001D29 8E06[E401]              	mov es, word [load_sectorseg]	; => sectorseg
  4603 00001D2D 1F                      	pop ds				; => user buffer
  4604 00001D2E 31F6                    	xor si, si
  4605 00001D30 31FF                    	xor di, di
  4606 00001D32 F3A4                    	rep movsb			; copy data into sectorseg
  4607 00001D34 59                      	pop cx
  4608 00001D35 5F                      	pop di
  4609 00001D36 1F                      	pop ds
  4610                                  
  4611 00001D37 B80103                  	mov ax, 0301h
  4612 00001D3A CD13                    	int 13h
  4613 00001D3C 7313                    	jnc @F
  4614                                  
  4615 00001D3E 31C0                    	xor ax, ax
  4616 00001D40 CD13                    	int 13h
  4617 00001D42 7303E903E8              	jc .err
  4618                                  
  4619 00001D47 B80103                  	mov ax, 0301h
  4620 00001D4A CD13                    	int 13h
  4621 00001D4C 7303E9F9E7              	jc .err
  4622                                  @@:
  4623 00001D51 07                      	pop es
  4624                                  .done_j:
  4625 00001D52 EB32                    	jmp .done
  4626                                  
  4627                                  
  4628                                  .chs_sectorseg_read:
  4629                                  
  4630 00001D54 06                      	push es		; user buffer
  4631 00001D55 8E06[E401]              	 mov es, word [load_sectorseg]
  4632                                  
  4633 00001D59 E84800                  	call .set_ax_function_0201_or_0301
  4634 00001D5C CD13                    	int 13h
  4635 00001D5E 7313                    	jnc .chs_sectorseg_done
  4636                                  
  4637 00001D60 31C0                    	xor ax, ax
  4638 00001D62 CD13                    	int 13h
  4639 00001D64 7303E9E1E7              	jc .err
  4640                                  
  4641 00001D69 E83800                  	call .set_ax_function_0201_or_0301
  4642 00001D6C CD13                    	int 13h
  4643 00001D6E 7303E9D7E7              	jc .err
  4644                                  .chs_sectorseg_done:
  4645                                  
  4646 00001D73 31F6                    	xor si, si
  4647 00001D75 07                      	pop es
  4648 00001D76 57                      	 push di
  4649 00001D77 31FF                    	xor di, di
  4650 00001D79 8B0E[0B02]              	mov cx, word [load_sectorsize]
  4651 00001D7D 8E1E[E401]              	mov ds, word [load_sectorseg]
  4652 00001D81 F3A4                    	rep movsb
  4653 00001D83 5F                      	 pop di
  4654                                  
  4655 00001D84 16                      	push ss
  4656 00001D85 1F                      	pop ds
  4657                                  .done:
  4658                                  ; increment segment
  4659 00001D86 8CC3                    	mov bx, es
  4660 00001D88 031E[EA01]              	add bx, word [load_sectorsizepara]
  4661                                  
  4662 00001D8C 5E                      	pop si
  4663 00001D8D 58                      	pop ax
  4664 00001D8E 59                      	pop cx
  4665 00001D8F 5A                      	pop dx
  4666                                  ; increment LBA sector number
  4667 00001D90 40                      	inc ax
  4668 00001D91 7501                    	jne @F
  4669 00001D93 42                      	inc dx
  4670                                  @@:
  4671 00001D94 89EC5D                  	lleave code
  4672 00001D97 C3                      	retn
  4673                                  
  4674                                  .set_ah_function_42_or_43:
  4675 00001D98 B442                    	mov ah, 42h
  4676 00001D9A F646FE01                	test byte [bp + ?is_read_bit0], 1
  4677 00001D9E 7503                    	jnz @F
  4678 00001DA0 B80043                  	mov ax, 4300h
  4679                                  @@:
  4680 00001DA3 C3                      	retn
  4681                                  
  4682                                  .set_ax_function_0201_or_0301:
  4683 00001DA4 B001                    	mov al, 1
  4684                                  .set_ah_function_02_or_03:
  4685 00001DA6 B402                    	mov ah, 02h
  4686 00001DA8 F646FE01                	test byte [bp + ?is_read_bit0], 1
  4687 00001DAC 7502                    	jnz @F
  4688 00001DAE B403                    	mov ah, 03h
  4689                                  @@:
  4690 00001DB0 C3                      	retn
  4691                                  
  4692                                  	lleave ctx
  4693                                  
  4694                                  
  4695                                  %if _INPUT_FILE_BOOT || _EXTENSIONS
  4696                                  yy_boot_error:
  4697 00001DB1 52                      	push dx
  4698 00001DB2 BA[0000]                	mov dx, msg.bootfail
  4699 00001DB5 E8(0000)                	call putsz_error
  4700 00001DB8 5A                      	pop dx
  4701 00001DB9 EB03                    	jmp @F
  4702                                  
  4703                                  yy_boot_disp_error_1:
  4704 00001DBB B80002                  	mov ax, 0200h
  4705                                  @@:
  4706 00001DBE E8(0000)                	call setrc
  4707 00001DC1 E8(0000)                	call display_y_or_ext
  4708 00001DC4 E8(0000)                	call putsz_error
  4709 00001DC7 FF26[0000]              	jmp near word [errret]
  4710                                  
  4711                                  yy_boot_parse_name: section_of_function
  4712 00001DCB 8D5CFF                  	lea bx, [si - 1]	; -> start of name
  4713                                  yy_boot_parse_name_bx_buffer: section_of_function
  4714 00001DCE E82FE2                  	call init_bootcmd
  4715 00001DD1 E9(0000)                	jmp yy_common_parse_name_bx_buffer
  4716                                  
  4717                                  yy_boot:
  4718                                  %if _EXTENSIONS
  4719                                   %if _INPUT_FILE_BOOT
  4720 00001DD4 D006[0000]              	rol byte [yy_is_script], 1
  4721 00001DD8 7203E9DF00              	jnc ext_boot
  4722                                   %endif
  4723                                  %endif
  4724                                  
  4725                                  %if _INPUT_FILE_BOOT
  4726                                  yy_script_boot:
  4727 00001DDD E8EBFF                  	call yy_boot_parse_name
  4728                                  
  4729 00001DE0 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  4730 00001DE5 740C                    	jz @F
  4731 00001DE7 833E[2005]03            	cmp word [load_input_file.active], _INPUT_FILE_BOOT - 1
  4732 00001DEC 7205                    	jb @F
  4733                                  
  4734 00001DEE BA[0000]                	mov dx, msg.yy_too_many_handles
  4735 00001DF1 EBC8                    	jmp yy_boot_disp_error_1
  4736                                  @@:
  4737                                  
  4738 00001DF3 803F3A                  	cmp byte [bx], ':'
  4739 00001DF6 752D                    	jne .not_yy_goto_subfunction
  4740                                  
  4741 00001DF8 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  4742 00001DFD 7421                    	jz @F
  4743                                  
  4744 00001DFF 8B3E[0000]              	mov di, word [terminator_in_line_in.offset]
  4745 00001E03 A0[0000]                	mov al, byte [terminator_in_line_in.value]
  4746 00001E06 8805                    	mov byte [di], al
  4747                                  
  4748 00001E08 43                      	inc bx
  4749 00001E09 89DE                    	mov si, bx
  4750 00001E0B E8(0000)                	call skipwhite
  4751 00001E0E 4E                      	dec si
  4752 00001E0F 8936[2205]              	mov word [load_input_file.goto_offset], si
  4753                                  
  4754 00001E13 E87303                  	call yy_calculate_structure
  4755 00001E16 E85003                  	call yy_boot_get.bx
  4756 00001E19 800E[0000]80            	setopt [internalflags3], dif3_partition_changed
  4757 00001E1E EB44                    	jmp .finish
  4758                                  
  4759                                  @@:
  4760 00001E20 BA[0000]                	mov dx, msg.yy_no_file
  4761 00001E23 EB96                    	jmp yy_boot_disp_error_1
  4762                                  
  4763                                  .not_yy_goto_subfunction:
  4764 00001E25 8326[2205]00            	and word [load_input_file.goto_offset], 0
  4765 00001E2A E8(0000)                	call skipcomm0
  4766 00001E2D 8936[0000]              	mov word [if_exists_then_address], si
  4767 00001E31 E8(0000)                	call iseol?_or_then
  4768 00001E34 742B                    	je .not_yy_goto
  4769                                  
  4770 00001E36 3C3A                    	cmp al, ':'
  4771 00001E38 7403E9(0000)            	jne error
  4772                                  
  4773 00001E3D E8(0000)                	call skipwhite
  4774 00001E40 4E                      	dec si
  4775 00001E41 8936[2205]              	mov word [load_input_file.goto_offset], si
  4776                                  
  4777                                  @@:
  4778 00001E45 AC                      	lodsb
  4779 00001E46 3C20                    	cmp al, 32
  4780 00001E48 740D                    	je @F
  4781 00001E4A 3C09                    	cmp al, 9
  4782 00001E4C 7409                    	je @F
  4783 00001E4E 3C2C                    	cmp al, ','
  4784 00001E50 7405                    	je @F
  4785 00001E52 E8(0000)                	call iseol?
  4786 00001E55 75EE                    	jne @B
  4787                                  @@:
  4788 00001E57 E8(0000)                	call skipcomm0
  4789 00001E5A 8936[0000]              	mov word [if_exists_then_address], si
  4790 00001E5E E8(0000)                	call chkeol_or_then
  4791                                  
  4792                                  .not_yy_goto:
  4793 00001E61 E87700                  	call yy_boot_open_file
  4794                                  
  4795                                  .finish:
  4796 00001E64 31ED                    	xor bp, bp
  4797 00001E66 31DB                    	xor bx, bx
  4798 00001E68 BE[C001]                	mov si, load_data_lowest
  4799 00001E6B B95000                  	mov cx, (LOAD_INPUT_FILE_SIZE + 1) >> 1
  4800                                  
  4801 00001E6E BF[A002]                	mov di, load_input_file
  4802 00001E71 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  4803 00001E76 7415                    	jz @F
  4804 00001E78 8B1E[2005]              	mov bx, word [load_input_file.active]
  4805 00001E7C 43                      	inc bx
  4806 00001E7D B8A000                  	mov ax, LOAD_INPUT_FILE_SIZE
  4807 00001E80 F7E3                    	mul bx
  4808                                  	; test dx, dx
  4809                                  	; jnz error
  4810 00001E82 01C7                    	add di, ax
  4811 00001E84 8B5586                  	mov dx, word [di - LOAD_INPUT_FILE_SIZE - LOADDATA3 + ldFATType]
  4812 00001E87 81E200F0                	and dx, ifhfTestReserved1 | ifhfTestReserved2 		| ifhfQuietInput | ifhfQuietOutput
  4814 00001E8B 09D5                    	or bp, dx
  4815                                  
  4816                                  @@:
  4817                                  
  4818 00001E8D 092E[E601]              	or word [load_data - LOADDATA2 + ldFATType], bp
  4819 00001E91 16                      	push ss
  4820 00001E92 07                      	pop es
  4821 00001E93 F3A5                    	rep movsw
  4822                                  
  4823                                  		; hazard: this uses load_input_file and
  4824                                  		;  load_data_lowest if we are already in
  4825                                  		;  a yy_boot script.
  4826 00001E95 8026[0300]EF            	clropt [internalflags3], dif3_auxbuff_guarded_1
  4827 00001E9A E8(0000)                	call yy_reset_buf
  4828                                  
  4829 00001E9D 891E[2005]              	mov word [load_input_file.active], bx
  4830 00001EA1 800E[0300]02            	setopt [internalflags2], dif2_input_file_boot
  4831                                  
  4832 00001EA6 8B36[2205]              	mov si, word [load_input_file.goto_offset]
  4833 00001EAA 85F6                    	test si, si
  4834 00001EAC 7403E9(0000)            	jnz cmd_goto.yy_entry
  4835                                  
  4836 00001EB1 F606[0300]08            	testopt [internalflags3], dif3_in_if
  4837 00001EB6 7403E9(0000)            	jnz if_exists_found_open
  4838 00001EBB C3                      	retn
  4839                                  %endif
  4840                                  
  4841                                  
  4842                                  %if _EXTENSIONS
  4843                                  ext_boot:
  4844 00001EBC E80CFF                  	call yy_boot_parse_name
  4845 00001EBF 8D54FF                  	lea dx, [si - 1]
  4846 00001EC2 8916[0000]              	mov word [ext_cmdline], dx
  4847 00001EC6 E8(0000)                	call skipcomm0
  4848 00001EC9 8936[0000]              	mov word [if_exists_then_address], si
  4849 00001ECD E80B00                  	call yy_boot_open_file
  4850 00001ED0 BB[C001]                	mov bx, load_data_lowest ; make yy_boot_get and yy_boot_update no-ops
  4851 00001ED3 8026[0300]EF            	clropt [internalflags3], dif3_auxbuff_guarded_1
  4852 00001ED8 E9(0000)                	jmp ext_finish.boot
  4853                                  %endif
  4854                                  
  4855                                  
  4856                                  yy_boot_open_file: section_of_function
  4857                                  %if _CONFIG
  4858 00001EDB 8926[0000]              	mov word [yy_boot_attempt_open_stack], sp
  4859 00001EDF 891E[0000]              	mov word [yy_boot_attempt_open_pathname], bx
  4860                                  %endif
  4861 00001EE3 E81D01                  	call yy_boot_init_dir
  4862 00001EE6 C606[3B05]00            	mov byte [load_check_dir_attr], 0
  4863 00001EEB 8B36[5405]              	mov si, word [load_yyname_input]
  4864 00001EEF 803C2F                  	cmp byte [si], '/'
  4865 00001EF2 7501                    	jne @F
  4866 00001EF4 46                      	inc si
  4867                                  @@:
  4868                                  .dotcomponent:
  4869 00001EF5 803C00                  	cmp byte [si], 0
  4870 00001EF8 7509                    	jne @F
  4871                                  ..@yy_filename_empty: section_of_function
  4872 00001EFA BA[0000]                	mov dx, msg.yy_filename_empty
  4873 00001EFD B80A02                  	mov ax, 020Ah
  4874 00001F00 E9AEFE                  	jmp yy_boot_error
  4875                                  @@:
  4876 00001F03 16                      	 push ss
  4877 00001F04 07                      	 pop es
  4878 00001F05 E8A5EB                  	call boot_parse_fn	; get next pathname
  4879 00001F08 72EB                    	jc .dotcomponent
  4880 00001F0A 3C2F                    	cmp al, '/'
  4881 00001F0C 7509                    	jne @F
  4882 00001F0E C606[3B05]10            	mov byte [load_check_dir_attr], ATTR_DIRECTORY
  4883 00001F13 8936[5605]              	mov word [load_yyname_next], si
  4884                                  @@:
  4885                                  
  4886 00001F17 BFFFFF                  	mov di, -1
  4887 00001F1A 89FE                    	mov si, di
  4888 00001F1C 897EF4                  	mov [bp + lsvFATSector], di
  4889 00001F1F 8976F6                  	mov [bp + lsvFATSector + 2], si
  4890                                  
  4891 00001F22 31C0                    	xor ax, ax
  4892 00001F24 31D2                    	xor dx, dx
  4893                                  
  4894                                  scan_dir_yyname_loop:
  4895 00001F26 8946EC                  	mov word [bp + ldDirCluster], ax
  4896 00001F29 8956EE                  	mov word [bp + ldDirCluster + 2], dx
  4897                                  
  4898 00001F2C 16                      	push ss
  4899 00001F2D 07                      	pop es
  4900 00001F2E BB[8002]                	mov bx, load_yy_direntry
  4901                                  
  4902 00001F31 E8CAF6                  	call scan_dir_aux_for_file
  4903                                  
  4904 00001F34 803E[3B05]10            	cmp byte [load_check_dir_attr], ATTR_DIRECTORY
  4905 00001F39 753C                    	jne got_yyentry
  4906                                  
  4907 00001F3B 56                      	push si
  4908 00001F3C 57                      	push di
  4909 00001F3D C606[3B05]00            	mov byte [load_check_dir_attr], 0
  4910 00001F42 8B36[5605]              	mov si, word [load_yyname_next]
  4911                                  .dotcomponent_next:
  4912 00001F46 803C00                  	cmp byte [si], 0
  4913 00001F49 7502                    	jne @F
  4914 00001F4B EBAD                    	jmp ..@yy_filename_empty
  4915                                  @@:
  4916 00001F4D 06                      	push es
  4917 00001F4E 16                      	 push ss
  4918 00001F4F 07                      	 pop es
  4919 00001F50 E85AEB                  	call boot_parse_fn	; get next pathname
  4920 00001F53 07                      	pop es
  4921 00001F54 72F0                    	jc .dotcomponent_next
  4922 00001F56 3C2F                    	cmp al, '/'
  4923 00001F58 7509                    	jne @F
  4924 00001F5A C606[3B05]10            	mov byte [load_check_dir_attr], ATTR_DIRECTORY
  4925 00001F5F 8936[5605]              	mov word [load_yyname_next], si
  4926                                  @@:
  4927 00001F63 5F                      	pop di
  4928 00001F64 5E                      	pop si
  4929                                  
  4930 00001F65 31D2                    	xor dx, dx
  4931 00001F67 268B471A                	mov ax, [es:bx + deClusterLow]
  4932                                  				; = first cluster (not FAT32)
  4933 00001F6B 807EE620                	cmp byte [bp + ldFATType], 32
  4934 00001F6F 7504                    	jne @F
  4935 00001F71 268B5714                	mov dx, [es:bx + deClusterHigh]
  4936                                  				; dx:ax = first cluster (FAT32)
  4937                                  @@:
  4938                                  
  4939 00001F75 EBAF                    	jmp scan_dir_yyname_loop
  4940                                  
  4941                                  
  4942                                  got_yyentry: section_of_function
  4943                                  
  4944                                  
  4945                                  ; (boot32.asm code starts here)
  4946                                  
  4947 00001F77 8B1E[9C02]              		mov bx, [load_yy_direntry + deSize]
  4948 00001F7B A1[9E02]                		mov ax, [load_yy_direntry + deSize + 2]
  4949                                  					 ; ax:bx = file size
  4950 00001F7E 8A16[8C02]              		mov dl, [load_yy_direntry + 12]
  4951                                  					; dl = FAT+ size bits
  4952 00001F82 88D6                    		mov dh, dl
  4953 00001F84 81E207E0                		and dx, 0E007h		; obtain bits 7-5 and 2-0
  4954 00001F88 7409                    		jz @F
  4955 00001F8A BA[0000]                	mov dx, msg.yy_too_large
  4956 00001F8D B80B02                  	mov ax, 020Bh
  4957 00001F90 E91EFE                  	jmp yy_boot_error
  4958                                  @@:
  4959 00001F93 895EC4                  	mov word [bp + ldFileSize], bx
  4960 00001F96 8946C6                  	mov word [bp + ldFileSize + 2], ax
  4961                                  
  4962 00001F99 09D8                    	or ax, bx
  4963 00001F9B 750C                    	jnz @F
  4964                                  
  4965 00001F9D E83D00                  	call yy_boot_file_not_found
  4966 00001FA0 BA[0000]                	mov dx, msg.yy_empty
  4967 00001FA3 B80C02                  	mov ax, 020Ch
  4968 00001FA6 E908FE                  	jmp yy_boot_error
  4969                                  @@:
  4970                                  
  4971                                  ; get starting cluster of file
  4972 00001FA9 31D2                    		xor dx, dx
  4973 00001FAB A1[9A02]                		mov ax, [load_yy_direntry + deClusterLow]
  4974                                  					; = first cluster (not FAT32)
  4975                                  
  4976 00001FAE 807EE620                		cmp byte [bp + ldFATType], 32
  4977 00001FB2 7504                    		jne @F
  4978 00001FB4 8B16[9402]              		mov dx, [load_yy_direntry + deClusterHigh]
  4979                                  					; dx:ax = first cluster (FAT32)
  4980                                  @@:
  4981                                  
  4982 00001FB8 80E60F                  	and dh, 0Fh
  4983 00001FBB 8946F0                  		mov word [bp + lsvFirstCluster], ax
  4984 00001FBE 8956F2                  		mov word [bp + lsvFirstCluster + 2], dx
  4985                                  
  4986 00001FC1 8946C8                  	mov word [bp + ldCurrentCluster], ax
  4987 00001FC4 8956CA                  	mov word [bp + ldCurrentCluster + 2], dx
  4988 00001FC7 31DB                    	xor bx, bx
  4989 00001FC9 895ECC                  	mov word [bp + ldCurrentSeek], bx
  4990 00001FCC 895ECE                  	mov word [bp + ldCurrentSeek + 2], bx
  4991 00001FCF E841F8                  		call check_clust
  4992 00001FD2 7303E9C006              		jc error_badchain
  4993                                  
  4994 00001FD7 800E[0000]80            	setopt [internalflags3], dif3_partition_changed
  4995                                  
  4996 00001FDC C3                      	retn
  4997                                  
  4998                                  
  4999                                  yy_boot_file_not_found:
  5000                                  %if _CONFIG
  5001 00001FDD 8B3E[0000]              	mov di, word [yy_boot_attempt_open_pathname]
  5002 00001FE1 85FF                    	test di, di
  5003 00001FE3 7413                    	jz @F
  5004 00001FE5 16                      	push ss
  5005 00001FE6 07                      	pop es
  5006 00001FE7 E8(0000)                	call retry_open_scriptspath
  5007 00001FEA 750C                    	jnz @F
  5008 00001FEC 8B26[0000]              	mov sp, word [yy_boot_attempt_open_stack]
  5009 00001FF0 8026[0300]EF            	clropt [internalflags3], dif3_auxbuff_guarded_1
  5010 00001FF5 E9E3FE                  	jmp yy_boot_open_file
  5011                                  %endif
  5012                                  @@:
  5013                                  .if:
  5014 00001FF8 F606[0300]08            	testopt [internalflags3], dif3_in_if
  5015 00001FFD 7403E9(0000)            	jnz if_exists_not_found
  5016 00002002 C3                      	retn
  5017                                  
  5018                                  
  5019                                  yy_boot_init_dir: section_of_function
  5020 00002003 31C0                    	xor ax, ax
  5021 00002005 89461C                  	mov [bp + bsBPB + bpbHiddenSectors + 0], ax
  5022 00002008 89461E                  	mov [bp + bsBPB + bpbHiddenSectors + 2], ax
  5023 0000200B F9                      	stc
  5024 0000200C 89DE                    	mov si, bx
  5025 0000200E AC                      	lodsb
  5026 0000200F E85AE7                  	call parseloadunit_default_sdp.cf
  5027 00002012 7506                    	jnz .have_filename
  5028                                  
  5029 00002014 BA[0000]                	mov dx, msg.yy_requires_filename
  5030 00002017 E9A1FD                  	jmp yy_boot_disp_error_1
  5031                                  
  5032                                  .have_filename:
  5033 0000201A BB[5405]                	mov bx, load_yyname_input
  5034 0000201D E805E3                  	call bootcmd.pathname_parse_super
  5035                                  
  5036 00002020 F606[0000]07            	testopt [internalflags3], dif3_load_is_dp
  5037 00002025 754E                    	jnz .load_yy_from_ldp
  5038                                  
  5039 00002027 8A1E[3805]              	mov bl, [load_partition]
  5040 0000202B 803E[4002]80            	cmp byte [load_unit], 80h
  5041 00002030 721F                    	jb .p_f_is_diskette
  5042 00002032 84DB                    	test bl, bl		; partition specified ?
  5043 00002034 7503E9(0000)            	jz error		; no, error -->
  5044                                  
  5045 00002039 E8B7F9                  	call query_geometry
  5046                                  
  5047 0000203C B9[9D20]                	mov cx, load_yy_from_partition
  5048 0000203F E803F8                  	call scan_partitions
  5049 00002042 E898FF                  	call yy_boot_file_not_found
  5050 00002045 BA[0000]                	mov dx, msg.boot_partition_not_found
  5051 00002048 B80602                  	mov ax, 0206h
  5052 0000204B E8(0000)                	call setrc
  5053 0000204E E90BE5                  	jmp bootcmd.fail
  5054                                  
  5055                                  
  5056                                  .p_f_is_diskette:
  5057 00002051 84DB                    	test bl, bl		; partition specified ?
  5058 00002053 7403E9(0000)            	jnz error		; yes, error -->
  5059                                  
  5060 00002058 E898F9                  	call query_geometry
  5061                                  
  5062 0000205B 31C0                    	xor ax, ax
  5063 0000205D 31D2                    	xor dx, dx
  5064                                  @@:
  5065 0000205F 8B1E[0000]              	mov bx, word [auxbuff_segorsel]	; bx => auxbuff
  5066 00002063 52                      	 push dx
  5067 00002064 50                      	 push ax
  5068 00002065 E857FB                  	call read_ae_512_bytes
  5069                                  
  5070 00002068 26813EFE0155AA          	cmp word [es:510], 0AA55h
  5071 0000206F 7510                    	jne boot_sigmismatch
  5072 00002071 58                      	 pop ax
  5073 00002072 5A                      	 pop dx
  5074                                  
  5075 00002073 EB62                    	jmp load_yy_common
  5076                                  
  5077                                  
  5078                                  .load_yy_from_ldp:
  5079 00002075 E87BF9                  	call query_geometry
  5080 00002078 A1[2805]                	mov ax, word [load_partition_sector]
  5081 0000207B 8B16[2A05]              	mov dx, word [load_partition_sector + 2]
  5082 0000207F EBDE                    	jmp @B
  5083                                  %endif
  5084                                  
  5085                                  
  5086                                  boot_sigmismatch:
  5087 00002081 BA[0000]                	mov dx, msg.bootfail_sig
  5088 00002084 B80702                  	mov ax, 0207h
  5089                                  @@:
  5090 00002087 E8(0000)                	call setrc
  5091 0000208A E9CFE4                  	jmp bootcmd.fail
  5092                                  
  5093                                  boot_codemismatch:
  5094 0000208D BA[0000]                	mov dx, msg.bootfail_code
  5095 00002090 B80802                  	mov ax, 0208h
  5096 00002093 EBF2                    	jmp @B
  5097                                  
  5098                                  boot_secsizemismatch:
  5099 00002095 BA[0000]                	mov dx, msg.bootfail_secsizediffer
  5100 00002098 B80902                  	mov ax, 0209h
  5101 0000209B EBEA                    	jmp @B
  5102                                  
  5103                                  
  5104                                  %if _INPUT_FILE_BOOT || _EXTENSIONS
  5105                                  		; INP:	es:si -> partition table entry,
  5106                                  		;	 si = load_partition_table .. load_partition_table+48,
  5107                                  		;	 es = ss
  5108                                  		;	bp + di -> above part table metadata,
  5109                                  		;	 dwo [bp + di - 4] = root (outermost extended position)
  5110                                  		;	 dwo [bp + di - 8] = base (current table position)
  5111                                  		; CHG:	ax, bx, (cx), dx
  5112                                  load_yy_from_partition:
  5113                                  d4	call d4message
  5114                                  d4	asciz "In load_yy_from_partition",13,10
  5115                                  
  5116 0000209D A0[3905]                	mov al, byte [load_current_partition]
  5117 000020A0 3A06[3805]              	cmp al, byte [load_partition]
  5118 000020A4 7401                    	je .gotit
  5119 000020A6 C3                      	retn
  5120                                  
  5121                                  .gotit:
  5122                                  d4	call d4message
  5123                                  d4	asciz "In load_yy_from_partition.gotit",13,10
  5124                                  
  5125 000020A7 8B43F8                  	mov ax, [bp + di - 8]
  5126 000020AA 8B53FA                  	mov dx, [bp + di - 6]		; base (current table position)
  5127                                  
  5128 000020AD 26034408                	add ax, [es:si + 8]
  5129 000020B1 2613540A                	adc dx, [es:si + 8 + 2]		; add offset to logical partition
  5130                                  
  5131 000020B5 26894408                	mov word [es:si + 8], ax
  5132 000020B9 2689540A                	mov word [es:si + 8 + 2], dx	; store in partition table entry
  5133                                  
  5134 000020BD 89EC                    	mov sp, bp
  5135 000020BF 5D                      	pop bp				; restore bp (scan_partitions)
  5136 000020C0 5B                      	pop bx				; discard ret address (scan_partitions)
  5137                                  
  5138                                  					; dx:ax = absolute sector number
  5139 000020C1 8B1E[0000]              	mov bx, word [auxbuff_segorsel]	; bx => auxbuff
  5140 000020C5 50                      	push ax
  5141 000020C6 52                      	push dx
  5142 000020C7 E8F5FA                  	call read_ae_512_bytes		; load partition boot sector
  5143                                  
  5144 000020CA 26813EFE0155AA          	cmp word [es:510], 0AA55h
  5145 000020D1 75AE                    	jne boot_sigmismatch
  5146                                  
  5147 000020D3 31C9                    	xor cx, cx
  5148                                  ;	cmp word [es:0], cx
  5149                                  ;	je boot_codemismatch
  5150                                  
  5151 000020D5 5A                      	pop dx
  5152 000020D6 58                      	pop ax
  5153                                  
  5154                                  		; dx:ax = boot sector
  5155                                  		; byte [load_unit] = unit
  5156                                  		; es:0-> read sector
  5157                                  load_yy_common:
  5158 000020D7 26A31C00                	mov word [es:bsBPB + bpbHiddenSectors], ax
  5159 000020DB 2689161E00              	mov word [es:bsBPB + bpbHiddenSectors + 2], dx
  5160                                  
  5161 000020E0 8B5E0B                  	mov bx, [bp + bsBPB + bpbBytesPerSector]
  5162 000020E3 263B1E0B00              	cmp bx, [es:bsBPB + bpbBytesPerSector]
  5163 000020E8 75AB                    	jne boot_secsizemismatch
  5164                                  
  5165                                  		; preserve some variables from our pseudo BPB
  5166 000020EA 31C0                    	xor ax, ax
  5167 000020EC FF7618                  	push word [bp + bsBPB + bpbCHSSectors]
  5168 000020EF 268F061800              	pop word [es:bsBPB + bpbCHSSectors]
  5169 000020F4 FF761A                  	push word [bp + bsBPB + bpbCHSHeads]
  5170 000020F7 268F061A00              	pop word [es:bsBPB + bpbCHSHeads]	; preserve geometry
  5171                                  
  5172 000020FC 8B5EEA                  	mov bx, word [bp + ldParaPerSector]
  5173 000020FF D1EB                    	shr bx, 1
  5174 00002101 895ED4                  	mov word [bp + ldEntriesPerSector], bx
  5175                                  
  5176 00002104 2639061600              	cmp word [es:bsBPB + bpbSectorsPerFAT], ax
  5177 00002109 8A5E40                  	mov bl, byte [bp + bsBPB + ebpbNew + bpbnBootUnit]
  5178 0000210C 7407                    	je .is_fat32
  5179 0000210E 26881E2400              	mov byte [es:bsBPB + bpbNew + bpbnBootUnit], bl
  5180 00002113 EB05                    	jmp short .was_fat1612
  5181                                  .is_fat32:
  5182 00002115 26881E4000              	mov byte [es:bsBPB + ebpbNew + bpbnBootUnit], bl
  5183                                  .was_fat1612:
  5184                                  
  5185 0000211A 06                      	 push es
  5186 0000211B 1E                      	 push ds
  5187 0000211C 06                      	push es
  5188 0000211D 1F                      	pop ds
  5189 0000211E 31F6                    	xor si, si				; -> BPB from boot partition
  5190 00002120 16                      	push ss
  5191 00002121 07                      	pop es
  5192 00002122 BF[0002]                	mov di, load_data - LOADDATA2		; -> our copy of a BPB
  5193 00002125 B95A00                  	mov cx, (bsBPB + ebpbNew + BPBN_size)
  5194 00002128 F3A4                    	rep movsb				; get the BPB
  5195                                  
  5196 0000212A 1F                      	 pop ds
  5197                                  
  5198 0000212B 394616                  	cmp word [bp + bsBPB + bpbSectorsPerFAT], ax
  5199 0000212E 740B                    	je @F					; is FAT32 -->
  5200 00002130 BE[2402]                	mov si, load_data - LOADDATA2 + bsBPB + bpbNew
  5201 00002133 BF[4002]                	mov di, load_data - LOADDATA2 + bsBPB + ebpbNew
  5202 00002136 B91A00                  	mov cx, BPBN_size
  5203 00002139 F3A4                    	rep movsb				; clone the FAT16 / FAT12 BPBN
  5204                                  						; to where the FAT32 BPBN lives
  5205                                  @@:
  5206 0000213B 07                      	 pop es
  5207                                  
  5208                                  .outofmem: equ query_geometry.out_of_memory_error
  5209                                  
  5210 0000213C FF36[0000]              	push word [auxbuff_segorsel]
  5211 00002140 8F46F8                  	pop word [bp + lsvFATSeg]
  5212 00002143 804EE702                	or byte [bp + ldFlags], ldfFATInvalid
  5213 00002147 B8FFFF                  	mov ax, -1
  5214 0000214A 8946F4                  	mov word [bp + lsvFATSector], ax
  5215 0000214D 8946F6                  	mov word [bp + lsvFATSector + 2], ax
  5216                                  
  5217 00002150 E80705                  	call initialise_fs
  5218 00002153 C3                      	retn
  5219                                  
  5220                                  
  5221                                  %if _INPUT_FILE_BOOT
  5222                                  		; INP:	[load_input_file], dif2_input_file_boot
  5223                                  		; OUT:	most recent file closed, flag cleared if no longer file
  5224                                  		; CHG:	di, bx, ax
  5225                                  yy_boot_close_file:
  5226 00002154 A1[2005]                	mov ax, word [load_input_file.active]
  5227 00002157 48                      	dec ax
  5228 00002158 790B                    	jns .next
  5229 0000215A 8026[0300]FD            	clropt [internalflags2], dif2_input_file_boot
  5230 0000215F 800E[0300]04            	setopt [internalflags2], dif2_closed_input_file_boot
  5231 00002164 C3                      	retn
  5232                                  .next:
  5233 00002165 A3[2005]                	mov word [load_input_file.active], ax
  5234 00002168 C3                      	retn
  5235                                  %endif
  5236                                  
  5237                                  
  5238                                  		; INP:	bx -> load data to get
  5239                                  		; OUT:	[load_data_lowest] = LOADDATA[123], lsv, BPB
  5240                                  		; CHG:	es, ax, di, si
  5241                                  yy_boot_get.bx:
  5242 00002169 16                      	push ss
  5243 0000216A 07                      	pop es
  5244                                  
  5245                                  %if _INPUT_FILE_BOOT
  5246 0000216B 51                      	push cx
  5247 0000216C BF[C001]                	mov di, load_data_lowest
  5248 0000216F B95000                  	mov cx, (LOAD_INPUT_FILE_SIZE + 1) >> 1
  5249 00002172 89DE                    	mov si, bx
  5250 00002174 F3A5                    	rep movsw
  5251 00002176 59                      	pop cx
  5252                                  %endif
  5253 00002177 C3                      	retn
  5254                                  
  5255                                  
  5256                                  		; INP:	[load_data_lowest] = LOADDATA3
  5257                                  		;	bx -> load data to set
  5258                                  		; CHG:	es, ax, di, si
  5259                                  		; Note:	Preserves flags (ZF, CF)
  5260                                  yy_boot_update.bx:
  5261 00002178 9C                      	pushf
  5262                                  
  5263 00002179 16                      	push ss
  5264 0000217A 07                      	pop es
  5265                                  
  5266                                  %if _INPUT_FILE_BOOT
  5267 0000217B 51                      	push cx
  5268 0000217C BE[C001]                	mov si, load_data_lowest
  5269 0000217F B90800                  	mov cx, LOADDATA3_size >> 1
  5270 00002182 89DF                    	mov di, bx
  5271 00002184 F3A5                    	rep movsw
  5272 00002186 59                      	pop cx
  5273                                  %endif
  5274 00002187 9D                      	popf			; ZF, CF
  5275 00002188 C3                      	retn
  5276                                  
  5277                                  
  5278                                  %if _INPUT_FILE_BOOT
  5279                                  		; INP:	word [load_input_file.active]
  5280                                  		; OUT:	bx -> load input data structure
  5281                                  		; CHG:	ax
  5282                                  yy_calculate_structure:
  5283 00002189 52                      	push dx
  5284 0000218A B8A000                  	mov ax, LOAD_INPUT_FILE_SIZE
  5285 0000218D F726[2005]              	mul word [load_input_file.active]
  5286                                  
  5287                                  ;	test dx, dx
  5288                                  ;	jnz .error
  5289 00002191 5A                      	pop dx
  5290                                  
  5291 00002192 93                      	xchg bx, ax
  5292 00002193 81C3[A002]              	add bx, load_input_file
  5293 00002197 C3                      	retn
  5294                                  %endif
  5295                                  
  5296                                  
  5297                                  guard_auxbuff_return:
  5298 00002198 F606[0300]70            	testopt [internalflags3], dif3_auxbuff_guarded_1 		| dif3_auxbuff_guarded_2 		| dif3_auxbuff_guarded_3
  5301 0000219D 7506                    	jnz @F
  5302 0000219F 800E[0300]10            	setopt [internalflags3], dif3_auxbuff_guarded_1
  5303                                  					; (NC)
  5304 000021A4 C3                      	retn
  5305                                  
  5306                                  @@:
  5307 000021A5 BA[0000]                	mov dx, msg.guard_auxbuff_error
  5308 000021A8 E8(0000)                	call putsz
  5309 000021AB F9                      	stc				; (CY)
  5310 000021AC C3                      	retn
  5311                                  
  5312                                  
  5313                                  		; INP:	[load_input_file] = active file
  5314                                  		;	cx = how many bytes to read
  5315                                  		;	es:dx -> buffer
  5316                                  		; OUT:	CY if error reading
  5317                                  		;	NC if success
  5318                                  		;	ax = how many bytes read
  5319                                  		; CHG:	bx
  5320                                  		; STT:	ds = ss
  5321                                  %if _INPUT_FILE_BOOT
  5322                                  yy_boot_read:
  5323 000021AD E8D9FF                  	call yy_calculate_structure
  5324                                  
  5325                                  .bx: section_of_function yy_boot_read
  5326                                  %else
  5327                                  yy_boot_read.bx: section_of_function
  5328                                  %endif
  5329                                  	lframe near
  5330                                  	lvar word, length
  5331                                  	lvar word, length_this_cluster
  5332                                  	lvar dword, bytes_per_cluster
  5333                                  	lvar dword, how_far_in_cluster
  5334 000021B0 5589E58D66F4            	lenter
  5335                                  	lvar dword, pointer
  5336 000021B6 06                      	 push es
  5337 000021B7 52                      	 push dx
  5338                                  	lvar word, load_input_file_structure
  5339 000021B8 53                      	 push bx
  5340 000021B9 31C0                    	xor ax, ax
  5341                                  	lvar word, did_guard_auxbuff
  5342 000021BB 50                      	 push ax
  5343                                  	lvar word, read_how_many
  5344 000021BC 50                      	 push ax
  5345 000021BD 52                      	push dx
  5346 000021BE 56                      	push si
  5347 000021BF 57                      	push di
  5348 000021C0 51                      	push cx
  5349                                  
  5350 000021C1 FF36[0000]              	push word [errret]
  5351 000021C5 FF36[0000]              	push word [throwret]
  5352 000021C9 FF36[0000]              	push word [throwsp]
  5353                                  
  5354 000021CD 55                      	push bp
  5355                                  
  5356 000021CE C706[0000][C323]        	mov word [errret], .err_ret
  5357 000021D4 C706[0000][C323]        	mov word [throwret], .err_ret
  5358 000021DA 8926[0000]              	mov word [throwsp], sp
  5359                                  
  5360                                  		; bx -> load_input_file structure
  5361 000021DE E888FF                  	call yy_boot_get.bx
  5362                                  
  5363 000021E1 E8B4FF                  	call guard_auxbuff_return
  5364 000021E4 7303E9A801              	jc .error
  5365 000021E9 FF46EC                  	inc word [bp + ?did_guard_auxbuff]
  5366                                  
  5367 000021EC B8FFFF                  	mov ax, -1
  5368 000021EF A3[F601]                	mov word [load_data - LOADDATA2 + lsvFATSector + 2], ax
  5369 000021F2 A3[F401]                	mov word [load_data - LOADDATA2 + lsvFATSector + 0], ax
  5370 000021F5 800E[E701]04            	setopt [load_ldflags], ldfFATBuffered
  5371                                  
  5372 000021FA 8B16[C601]              	mov dx, word [load_data - LOADDATA2 + ldFileSize + 2]
  5373 000021FE A1[C401]                	mov ax, word [load_data - LOADDATA2 + ldFileSize]
  5374                                  
  5375 00002201 2B06[CC01]              	sub ax, word [load_data - LOADDATA2 + ldCurrentSeek]
  5376 00002205 1B16[CE01]              	sbb dx, word [load_data - LOADDATA2 + ldCurrentSeek + 2]
  5377                                  					; dx:ax = read at most this many bytes
  5378 00002209 7304                    	jnc @F
  5379                                  		; file size below current seek
  5380 0000220B 31C0                    	xor ax, ax
  5381 0000220D 31D2                    	xor dx, dx			; = read at most zero bytes
  5382                                  @@:
  5383 0000220F 85D2                    	test dx, dx
  5384 00002211 7506                    	jnz .use_count
  5385 00002213 39C8                    	cmp ax, cx			; dx:ax >= cx ?
  5386 00002215 7302                    	jae .use_count			; yes, use cx as count to read
  5387 00002217 89C1                    	mov cx, ax			; no, use (dx:)ax as count to read
  5388                                  .use_count:
  5389 00002219 85C9                    	test cx, cx			; any more to read ?
  5390 0000221B 7503E97001              	jz .success			; no, reached the end -->
  5391 00002220 894EFE                  	mov word [bp + ?length], cx
  5392                                  
  5393                                  .next_cluster:
  5394 00002223 8B36[CE01]              	mov si, word [load_data - LOADDATA2 + ldCurrentSeek + 2]
  5395 00002227 8B3E[CC01]              	mov di, word [load_data - LOADDATA2 + ldCurrentSeek]
  5396 0000222B A1[0B02]                	mov ax, word [load_data - LOADDATA2 + bsBPB + bpbBytesPerSector]
  5397 0000222E F726[E801]              	mul word [load_data - LOADDATA2 + ldClusterSize]
  5398                                  
  5399 00002232 8946F8                  	mov word [bp + ?bytes_per_cluster], ax
  5400 00002235 8956FA                  	mov word [bp + ?bytes_per_cluster + 2], dx
  5401 00002238 83E801                  	sub ax, 1
  5402 0000223B 83DA00                  	sbb dx, 0
  5403 0000223E 21D6                    	and si, dx
  5404 00002240 21C7                    	and di, ax		; how far are we into cluster
  5405                                  
  5406 00002242 897EF4                  	mov word [bp + ?how_far_in_cluster], di
  5407 00002245 8976F6                  	mov word [bp + ?how_far_in_cluster + 2], si
  5408                                  
  5409 00002248 F7DE                    	neg si
  5410 0000224A F7DF                    	neg di
  5411 0000224C 83DE00                  	sbb si, byte 0		; neg si:di
  5412                                  
  5413 0000224F 037EF8                  	add di, word [bp + ?bytes_per_cluster]
  5414 00002252 1376FA                  	adc si, word [bp + ?bytes_per_cluster + 2]
  5415                                  				; cluster size - how far we are
  5416                                  				;  = how much to read from this cluster
  5417 00002255 85F6                    	test si, si
  5418 00002257 7506                    	jnz .use_count_2
  5419 00002259 39CF                    	cmp di, cx
  5420 0000225B 7302                    	jae .use_count_2
  5421 0000225D 89F9                    	mov cx, di
  5422                                  .use_count_2:
  5423 0000225F 894EFC                  	mov word [bp + ?length_this_cluster], cx
  5424                                  
  5425                                  .next_sector:
  5426 00002262 A1[C801]                	mov ax, word [load_data - LOADDATA2 + ldCurrentCluster]
  5427 00002265 8B16[CA01]              	mov dx, word [load_data - LOADDATA2 + ldCurrentCluster + 2]
  5428 00002269 E8A7F5                  	call check_clust
  5429 0000226C 7303E92001              	jc .error
  5430 00002271 E874F4                  	call clust_to_first_sector
  5431 00002274 8B1E[0B02]              	mov bx, word [load_data - LOADDATA2 + bsBPB + bpbBytesPerSector]
  5432 00002278 8B7EF4                  	mov di, word [bp + ?how_far_in_cluster]
  5433 0000227B 8B76F6                  	mov si, word [bp + ?how_far_in_cluster + 2]
  5434 0000227E 87D6                    	xchg dx, si
  5435 00002280 97                      	xchg ax, di
  5436 00002281 F7F3                    	div bx
  5437                                  		; dx = byte offset into sector
  5438                                  		; ax = sector offset into cluster's data
  5439 00002283 01C7                    	add di, ax
  5440 00002285 83D600                  	adc si, 0
  5441 00002288 87D6                    	xchg dx, si
  5442 0000228A 97                      	xchg ax, di
  5443                                  		; dx:ax = sector in fs
  5444                                  		; si = byte offset
  5445                                  
  5446 0000228B 89F1                    	mov cx, si		; = byte offset
  5447 0000228D F7D9                    	neg cx			; - byte offset
  5448 0000228F 01D9                    	add cx, bx		; sector size - byte offset
  5449                                  				;  = length this sector
  5450 00002291 3B4EFC                  	cmp cx, word [bp + ?length_this_cluster]
  5451 00002294 7603                    	jbe @F			; sector has less than requested -->
  5452 00002296 8B4EFC                  	mov cx, word [bp + ?length_this_cluster]
  5453                                  				; fill entire remaining request
  5454                                  @@:
  5455 00002299 8B1E[0000]              	mov bx, word [auxbuff_segorsel]
  5456 0000229D 813E[0B02]0010          	cmp word [load_data - LOADDATA2 + bsBPB + bpbBytesPerSector], 4096
  5457 000022A3 7706                    	ja .invalidatefat
  5458 000022A5 81C30001                	add bx, paras(4096)	; => use upper buffer for file data
  5459                                  		; Note that the FAT12 straddling entry's second sector
  5460                                  		;  is reloaded even if the entry's first sector is still
  5461                                  		;  buffered. That means we do not have to invalidate the
  5462                                  		;  second sector here, so even with a 4 KiB sector size
  5463                                  		;  the upper buffer is free for file data use here.
  5464 000022A9 EB0A                    	jmp @F
  5465                                  .invalidatefat:
  5466                                  		; need to invalidate FAT buffer
  5467 000022AB 830E[F601]FF            	or word [load_data - LOADDATA2 + lsvFATSector + 2], -1
  5468 000022B0 830E[F401]FF            	or word [load_data - LOADDATA2 + lsvFATSector + 0], -1
  5469                                  @@:
  5470                                  
  5471 000022B5 813E[0B02]0002          	cmp word [load_data - LOADDATA2 + bsBPB + bpbBytesPerSector], 512
  5472 000022BB 7745                    	ja .nodatabuffer	; data buffer is only 512 bytes. too small -->
  5473 000022BD F606[E701]08            	testopt [load_ldflags], ldfDataBuffered
  5474 000022C2 743E                    	jz .nodatabuffer	; data buffer not used -->
  5475 000022C4 3916[DA01]              	cmp word [load_data - LOADDATA2 + ldDataSector + 2], dx
  5476 000022C8 7512                    	jne .filldatabuffer
  5477 000022CA 3906[D801]              	cmp word [load_data - LOADDATA2 + ldDataSector], ax
  5478 000022CE 750C                    	jne .filldatabuffer
  5479                                  .havedatabuffer:
  5480 000022D0 8EC3                    	mov es, bx		; es => sector buffer to read into
  5481 000022D2 06                      	push es
  5482 000022D3 1E                      	push ds
  5483 000022D4 56                      	push si
  5484 000022D5 51                      	push cx			; must match stack frame for .copydatabuffer
  5485 000022D6 8E1E[D601]              	mov ds, word [load_data - LOADDATA2 + ldDataSegment]
  5486                                  				; ds => data buffer
  5487 000022DA EB15                    	jmp .copydatabuffer
  5488                                  
  5489                                  .filldatabuffer:
  5490 000022DC 8916[DA01]              	mov word [load_data - LOADDATA2 + ldDataSector + 2], dx
  5491 000022E0 A3[D801]                	mov word [load_data - LOADDATA2 + ldDataSector], ax
  5492                                  				; update buffered data sector
  5493 000022E3 E8EBF8                  	call read_sector	; actually read data from disk
  5494 000022E6 06                      	push es
  5495 000022E7 1E                      	push ds
  5496 000022E8 56                      	push si
  5497 000022E9 51                      	push cx
  5498 000022EA 06                      	 push es
  5499 000022EB 1F                      	 pop ds			; ds => sector buffer to read from
  5500 000022EC 368E06[D601]            	mov es, word [ss:load_data - LOADDATA2 + ldDataSegment]
  5501                                  				; es => data buffer
  5502                                  .copydatabuffer:
  5503 000022F1 31FF                    	xor di, di		; es:di -> sector buffer to read into
  5504 000022F3 31F6                    	xor si, si		; ds:si -> data buffer
  5505 000022F5 368B0E[0B02]            	mov cx, word [ss:load_data - LOADDATA2 + bsBPB + bpbBytesPerSector]
  5506                                  				; cx = sector size
  5507 000022FA F3A4                    	rep movsb		; get/set buffered data
  5508 000022FC 59                      	pop cx
  5509 000022FD 5E                      	pop si
  5510 000022FE 1F                      	pop ds
  5511 000022FF 07                      	pop es
  5512 00002300 EB03                    	jmp .databufferdone
  5513                                  
  5514                                  .nodatabuffer:
  5515 00002302 E8CCF8                  	call read_sector
  5516                                  .databufferdone:
  5517 00002305 1E                      	push ds
  5518                                  
  5519 00002306 06                      	 push es
  5520                                  				; es:si -> data in sector buffer
  5521 00002307 C47EF0                  	les di, [bp + ?pointer]
  5522                                  				; es:di -> buffer
  5523 0000230A 014EEA                  	add word [bp + ?read_how_many], cx
  5524 0000230D 294EFC                  	sub word [bp + ?length_this_cluster], cx
  5525 00002310 294EFE                  	sub word [bp + ?length], cx
  5526 00002313 010E[CC01]              	add word [load_data - LOADDATA2 + ldCurrentSeek], cx
  5527 00002317 8316[CE01]00            	adc word [load_data - LOADDATA2 + ldCurrentSeek + 2], 0
  5528 0000231C 014EF4                  	add word [bp + ?how_far_in_cluster], cx
  5529 0000231F 8356F600                	adc word [bp + ?how_far_in_cluster + 2], 0
  5530 00002323 1F                      	 pop ds			; ds:si -> data in sector buffer
  5531 00002324 F3A4                    	rep movsb		; copy
  5532 00002326 897EF0                  	mov word [bp + ?pointer], di
  5533                                  				; update pointer
  5534 00002329 1F                      	pop ds
  5535                                  
  5536 0000232A 837EFC00                	cmp word [bp + ?length_this_cluster], 0
  5537 0000232E 7403E92FFF              	jne .next_sector
  5538                                  
  5539 00002333 8B7EF8                  	mov di, word [bp + ?bytes_per_cluster]
  5540 00002336 8B76FA                  	mov si, word [bp + ?bytes_per_cluster + 2]
  5541 00002339 397EF4                  	cmp word [bp + ?how_far_in_cluster], di
  5542 0000233C 7505                    	jne @F
  5543 0000233E 3976F6                  	cmp word [bp + ?how_far_in_cluster + 2], si
  5544 00002341 7408                    	je @FF
  5545                                  @@:
  5546 00002343 837EFE00                	cmp word [bp + ?length], 0
  5547 00002347 7548                    	jne .error
  5548 00002349 EB45                    	jmp .success
  5549                                  
  5550                                  @@:
  5551 0000234B A1[C801]                	mov ax, word [load_data - LOADDATA2 + ldCurrentCluster]
  5552 0000234E 8B16[CA01]              	mov dx, word [load_data - LOADDATA2 + ldCurrentCluster + 2]
  5553 00002352 E8BEF4                  	call check_clust
  5554 00002355 723A                    	jc .error
  5555 00002357 E8BBF3                  	call clust_next.dxax
  5556 0000235A 731B                    	jnc @F			; (NC) -->
  5557 0000235C B8F6FF                  	mov ax, 0FFF8h - 2
  5558 0000235F BAFF0F                  	mov dx, 0FFFh
  5559 00002362 8B3E[CC01]              	mov di, word [load_data - LOADDATA2 + ldCurrentSeek]
  5560 00002366 8B36[CE01]              	mov si, word [load_data - LOADDATA2 + ldCurrentSeek + 2]
  5561 0000236A 3B36[C601]              	cmp si, word [load_data - LOADDATA2 + ldFileSize + 2]
  5562 0000236E 7506                    	jne .set_error
  5563 00002370 3B3E[C401]              	cmp di, word [load_data - LOADDATA2 + ldFileSize]
  5564 00002374 7401                    	je .do_not_set_error	; if same then NC -->
  5565                                  .set_error:
  5566 00002376 F9                      	stc
  5567                                  .do_not_set_error:
  5568                                  @@:
  5569 00002377 9C                      	pushf
  5570 00002378 83C002                  	add ax, 2
  5571 0000237B 83D200                  	adc dx, 0
  5572 0000237E A3[C801]                	mov word [load_data - LOADDATA2 + ldCurrentCluster], ax
  5573 00002381 8916[CA01]              	mov word [load_data - LOADDATA2 + ldCurrentCluster + 2], dx
  5574 00002385 9D                      	popf			; CF
  5575 00002386 7209                    	jc .error
  5576 00002388 8B4EFE                  	mov cx, word [bp + ?length]
  5577 0000238B E303                    	jcxz .success
  5578 0000238D E993FE                  	jmp .next_cluster
  5579                                  
  5580                                  .success:
  5581 00002390 A8                      	db __TEST_IMM8		; (skip stc, NC)
  5582                                  .error:
  5583 00002391 F9                      	stc
  5584                                  
  5585 00002392 5D                      	pop bp
  5586                                  
  5587 00002393 8F06[0000]              	pop word [throwsp]
  5588 00002397 8F06[0000]              	pop word [throwret]	; restore throw destination
  5589 0000239B 8F06[0000]              	pop word [errret]
  5590                                  
  5591 0000239F 9C                      	pushf
  5592 000023A0 F646EC01                	testopt [bp + ?did_guard_auxbuff], 1
  5593 000023A4 7405                    	jz @F
  5594 000023A6 8026[0300]EF            	clropt [internalflags3], dif3_auxbuff_guarded_1
  5595                                  @@:
  5596 000023AB 8026[E701]FB            	clropt [load_ldflags], ldfFATBuffered
  5597 000023B0 9D                      	popf			; CF
  5598                                  
  5599 000023B1 8B5EEE                  	mov bx, word [bp + ?load_input_file_structure]
  5600                                  		; bx -> load_input_file structure
  5601 000023B4 E8C1FD                  	call yy_boot_update.bx
  5602                                  
  5603 000023B7 59                      	pop cx
  5604 000023B8 5F                      	pop di
  5605 000023B9 5E                      	pop si
  5606 000023BA 5A                      	pop dx
  5607 000023BB 58                      	pop ax			; pop from ?read_how_many
  5608 000023BC 8E46F2                  	mov es, word [bp + ?pointer + 2]
  5609 000023BF 89EC5D                  	lleave
  5610 000023C2 C3                      	retn
  5611                                  
  5612                                  .err_ret:
  5613 000023C3 8B26[0000]              	mov sp, word [throwsp]	; restore stack
  5614                                  				;  (needed here if returned to errret)
  5615 000023C7 EBC8                    	jmp .error
  5616                                  
  5617                                  
  5618                                  		; INP:	[load_input_file] = active file
  5619                                  		;	cx:dx = signed seek distance from current
  5620                                  		; OUT:	-
  5621                                  		; CHG:	ax, bx, cx, dx
  5622                                  		; STT:	ds = es = ss
  5623                                  		; REM:	negative seek must not seek to before SOF
  5624                                  %if _INPUT_FILE_BOOT
  5625                                  yy_boot_seek_current:
  5626 000023C9 E8BDFD                  	call yy_calculate_structure
  5627                                  
  5628                                  .bx: section_of_function yy_boot_seek_current
  5629                                  %else
  5630                                  yy_boot_seek_current.bx: section_of_function
  5631                                  %endif
  5632                                  	lframe near
  5633                                  	lvar dword, length
  5634                                  	lvar dword, length_this_cluster
  5635                                  	lvar dword, bytes_per_cluster
  5636                                  	lvar dword, how_far_in_cluster
  5637 000023CC 5589E58D66F0            	lenter
  5638                                  	lvar dword, seek_distance
  5639 000023D2 51                      	 push cx
  5640 000023D3 52                      	 push dx
  5641                                  	lvar word, load_input_file_structure
  5642 000023D4 53                      	 push bx
  5643 000023D5 31C0                    	xor ax, ax
  5644                                  	lvar word, did_guard_auxbuff
  5645 000023D7 50                      	 push ax
  5646 000023D8 56                      	push si
  5647 000023D9 57                      	push di
  5648                                  
  5649 000023DA FF36[0000]              	push word [errret]
  5650 000023DE FF36[0000]              	push word [throwret]
  5651 000023E2 FF36[0000]              	push word [throwsp]
  5652                                  
  5653 000023E6 55                      	push bp
  5654                                  
  5655 000023E7 C706[0000][2C26]        	mov word [errret], .err_ret
  5656 000023ED C706[0000][2C26]        	mov word [throwret], .err_ret
  5657 000023F3 8926[0000]              	mov word [throwsp], sp
  5658                                  
  5659                                  		; bx -> load_input_file structure
  5660 000023F7 E86FFD                  	call yy_boot_get.bx
  5661                                  
  5662 000023FA E89BFD                  	call guard_auxbuff_return
  5663 000023FD 7303E9FF01              	jc .error
  5664 00002402 FF46E8                  	inc word [bp + ?did_guard_auxbuff]
  5665                                  
  5666 00002405 B8FFFF                  	mov ax, -1
  5667 00002408 A3[F601]                	mov word [load_data - LOADDATA2 + lsvFATSector + 2], ax
  5668 0000240B A3[F401]                	mov word [load_data - LOADDATA2 + lsvFATSector + 0], ax
  5669 0000240E 800E[E701]04            	setopt [load_ldflags], ldfFATBuffered
  5670                                  
  5671 00002413 85C9                    	test cx, cx
  5672 00002415 7975                    	jns .plus
  5673                                  
  5674 00002417 8B36[CE01]              	mov si, word [load_data - LOADDATA2 + ldCurrentSeek + 2]
  5675 0000241B 8B3E[CC01]              	mov di, word [load_data - LOADDATA2 + ldCurrentSeek]
  5676 0000241F A1[0B02]                	mov ax, word [load_data - LOADDATA2 + bsBPB + bpbBytesPerSector]
  5677 00002422 F726[E801]              	mul word [load_data - LOADDATA2 + ldClusterSize]
  5678                                  
  5679 00002426 8946F4                  	mov word [bp + ?bytes_per_cluster], ax
  5680 00002429 8956F6                  	mov word [bp + ?bytes_per_cluster + 2], dx
  5681 0000242C 83E801                  	sub ax, 1
  5682 0000242F 83DA00                  	sbb dx, 0
  5683 00002432 F7D0                    	not ax
  5684 00002434 F7D2                    	not dx
  5685                                  
  5686 00002436 56                      	push si
  5687 00002437 57                      	push di
  5688                                  
  5689 00002438 21D6                    	and si, dx
  5690 0000243A 21C7                    	and di, ax		; start seek of current cluster
  5691                                  
  5692 0000243C 58                      	pop ax
  5693 0000243D 5A                      	pop dx			; current seek
  5694                                  
  5695 0000243E 0346EC                  	add ax, word [bp + ?seek_distance]
  5696 00002441 1356EE                  	adc dx, word [bp + ?seek_distance + 2]
  5697 00002444 7203E9B801              	jnc .error		; target seek
  5698                                  
  5699                                  		; if the cluster is invalid, need to reset
  5700 00002449 813E[CA01]FF0F          	cmp word [load_data - LOADDATA2 + ldCurrentCluster + 2], 0FFFh
  5701 0000244F 7207                    	jb @F
  5702 00002451 833E[C801]F8            	cmp word [load_data - LOADDATA2 + ldCurrentCluster], 0FFF8h
  5703 00002456 7308                    	jae .minus_reset
  5704                                  @@:
  5705                                  
  5706 00002458 39F2                    	cmp dx, si		; is target seek
  5707                                  				;  >= start seek of current cluster?
  5708 0000245A 7502                    	jne @F
  5709 0000245C 39F8                    	cmp ax, di
  5710                                  @@:
  5711 0000245E 7322                    	jae .minus_simple	; yes, simple -->
  5712                                  
  5713                                  .minus_reset:
  5714                                  		; reset current cluster to first, seek to 0
  5715 00002460 FF36[F201]              	push word [load_data - LOADDATA2 + lsvFirstCluster + 2]
  5716 00002464 FF36[F001]              	push word [load_data - LOADDATA2 + lsvFirstCluster]
  5717 00002468 8F06[C801]              	pop word [load_data - LOADDATA2 + ldCurrentCluster]
  5718 0000246C 8F06[CA01]              	pop word [load_data - LOADDATA2 + ldCurrentCluster + 2]
  5719 00002470 8326[CC01]00            	and word [load_data - LOADDATA2 + ldCurrentSeek], 0
  5720 00002475 8326[CE01]00            	and word [load_data - LOADDATA2 + ldCurrentSeek + 2], 0
  5721                                  
  5722                                  		; set distance
  5723 0000247A 8946EC                  	mov word [bp + ?seek_distance], ax
  5724 0000247D 8956EE                  	mov word [bp + ?seek_distance + 2], dx
  5725                                  		; use positive seek code
  5726 00002480 EB0A                    	jmp .plus
  5727                                  
  5728                                  .minus_simple:
  5729                                  		; just set seek, current cluster still valid
  5730 00002482 A3[CC01]                	mov word [load_data - LOADDATA2 + ldCurrentSeek], ax
  5731 00002485 8916[CE01]              	mov word [load_data - LOADDATA2 + ldCurrentSeek + 2], dx
  5732 00002489 E97501                  	jmp .return
  5733                                  
  5734                                  .plus:
  5735 0000248C 8B16[C601]              	mov dx, word [load_data - LOADDATA2 + ldFileSize + 2]
  5736 00002490 A1[C401]                	mov ax, word [load_data - LOADDATA2 + ldFileSize]
  5737                                  
  5738 00002493 2B06[CC01]              	sub ax, word [load_data - LOADDATA2 + ldCurrentSeek]
  5739 00002497 1B16[CE01]              	sbb dx, word [load_data - LOADDATA2 + ldCurrentSeek + 2]
  5740                                  
  5741 0000249B 720A                    	jc .eof
  5742                                  		; dx:ax = how far we can seek within file
  5743 0000249D 3B56EE                  	cmp dx, word [bp + ?seek_distance + 2]
  5744 000024A0 7503                    	jne @F
  5745 000024A2 3B46EC                  	cmp ax, word [bp + ?seek_distance]
  5746                                  @@:
  5747 000024A5 771D                    	ja .not_eof
  5748                                  .eof:
  5749 000024A7 8B46EC                  	mov ax, word [bp + ?seek_distance]
  5750 000024AA 8B56EE                  	mov dx, word [bp + ?seek_distance + 2]
  5751 000024AD 0106[CC01]              	add word [load_data - LOADDATA2 + ldCurrentSeek], ax
  5752 000024B1 1116[CE01]              	adc word [load_data - LOADDATA2 + ldCurrentSeek + 2], dx
  5753 000024B5 C706[C801]F8FF          	mov word [load_data - LOADDATA2 + ldCurrentCluster], 0FFF8h
  5754 000024BB C706[CA01]FF0F          	mov word [load_data - LOADDATA2 + ldCurrentCluster + 2], 0FFFh
  5755 000024C1 E93D01                  	jmp .return
  5756                                  
  5757                                  .not_eof:
  5758 000024C4 8B4EEC                  	mov cx, word [bp + ?seek_distance]
  5759 000024C7 8B5EEE                  	mov bx, word [bp + ?seek_distance + 2]
  5760 000024CA 85DB                    	test bx, bx
  5761 000024CC 7507                    	jnz @F
  5762 000024CE 85C9                    	test cx, cx
  5763 000024D0 7503E92C01              	jz .return
  5764                                  @@:
  5765 000024D5 894EFC                  	mov word [bp + ?length], cx
  5766 000024D8 895EFE                  	mov word [bp + ?length + 2], bx
  5767                                  
  5768                                  		; bx:cx = length
  5769                                  .next_cluster:
  5770 000024DB 8B36[CE01]              	mov si, word [load_data - LOADDATA2 + ldCurrentSeek + 2]
  5771 000024DF 8B3E[CC01]              	mov di, word [load_data - LOADDATA2 + ldCurrentSeek]
  5772 000024E3 A1[0B02]                	mov ax, word [load_data - LOADDATA2 + bsBPB + bpbBytesPerSector]
  5773 000024E6 F726[E801]              	mul word [load_data - LOADDATA2 + ldClusterSize]
  5774                                  
  5775 000024EA 8946F4                  	mov word [bp + ?bytes_per_cluster], ax
  5776 000024ED 8956F6                  	mov word [bp + ?bytes_per_cluster + 2], dx
  5777 000024F0 83E801                  	sub ax, 1
  5778 000024F3 83DA00                  	sbb dx, 0
  5779 000024F6 21D6                    	and si, dx
  5780 000024F8 21C7                    	and di, ax		; how far are we into cluster
  5781                                  
  5782 000024FA 897EF0                  	mov word [bp + ?how_far_in_cluster], di
  5783 000024FD 8976F2                  	mov word [bp + ?how_far_in_cluster + 2], si
  5784                                  
  5785 00002500 F7DE                    	neg si
  5786 00002502 F7DF                    	neg di
  5787 00002504 83DE00                  	sbb si, byte 0		; neg si:di
  5788                                  
  5789 00002507 037EF4                  	add di, word [bp + ?bytes_per_cluster]
  5790 0000250A 1376F6                  	adc si, word [bp + ?bytes_per_cluster + 2]
  5791                                  				; cluster size - how far we are
  5792                                  				;  = how much to read from this cluster
  5793 0000250D 39DE                    	cmp si, bx
  5794 0000250F 7502                    	jne @F
  5795 00002511 39CF                    	cmp di, cx
  5796                                  @@:
  5797 00002513 7304                    	jae .use_count_2
  5798 00002515 89F9                    	mov cx, di
  5799 00002517 89F3                    	mov bx, si
  5800                                  .use_count_2:
  5801                                  		; bx:cx = how far to seek in this cluster
  5802 00002519 894EF8                  	mov word [bp + ?length_this_cluster], cx
  5803 0000251C 895EFA                  	mov word [bp + ?length_this_cluster + 2], bx
  5804                                  
  5805                                  .next_sector:
  5806 0000251F A1[C801]                	mov ax, word [load_data - LOADDATA2 + ldCurrentCluster]
  5807 00002522 8B16[CA01]              	mov dx, word [load_data - LOADDATA2 + ldCurrentCluster + 2]
  5808 00002526 E8EAF2                  	call check_clust
  5809 00002529 7303E9D300              	jc .error
  5810 0000252E 8B1E[0B02]              	mov bx, word [load_data - LOADDATA2 + bsBPB + bpbBytesPerSector]
  5811 00002532 8B7EF0                  	mov di, word [bp + ?how_far_in_cluster]
  5812 00002535 8B76F2                  	mov si, word [bp + ?how_far_in_cluster + 2]
  5813                                  
  5814 00002538 87D6                    	xchg dx, si
  5815 0000253A 97                      	xchg ax, di
  5816 0000253B F7F3                    	div bx
  5817                                  		; dx = byte offset into sector
  5818                                  		; ax = sector offset into cluster's data
  5819 0000253D 87D6                    	xchg dx, si
  5820 0000253F 97                      	xchg ax, di
  5821                                  		; si = byte offset
  5822                                  
  5823 00002540 89F1                    	mov cx, si		; = byte offset
  5824 00002542 F7D9                    	neg cx			; - byte offset
  5825 00002544 01D9                    	add cx, bx		; sector size - byte offset
  5826                                  				;  = length this sector
  5827 00002546 837EFA00                	cmp word [bp + ?length_this_cluster + 2], 0
  5828 0000254A 7508                    	jne @F			; fill remaining sector size
  5829 0000254C 3B4EF8                  	cmp cx, word [bp + ?length_this_cluster]
  5830 0000254F 7603                    	jbe @F			; sector has less than requested -->
  5831 00002551 8B4EF8                  	mov cx, word [bp + ?length_this_cluster]
  5832                                  				; fill entire remaining request
  5833                                  @@:
  5834 00002554 294EF8                  	sub word [bp + ?length_this_cluster], cx
  5835 00002557 835EFA00                	sbb word [bp + ?length_this_cluster + 2], 0
  5836 0000255B 294EFC                  	sub word [bp + ?length], cx
  5837 0000255E 835EFE00                	sbb word [bp + ?length + 2], 0
  5838 00002562 010E[CC01]              	add word [load_data - LOADDATA2 + ldCurrentSeek], cx
  5839 00002566 8316[CE01]00            	adc word [load_data - LOADDATA2 + ldCurrentSeek + 2], 0
  5840 0000256B 014EF0                  	add word [bp + ?how_far_in_cluster], cx
  5841 0000256E 8356F200                	adc word [bp + ?how_far_in_cluster + 2], 0
  5842                                  
  5843 00002572 837EFA00                	cmp word [bp + ?length_this_cluster + 2], 0
  5844 00002576 75A7                    	jne .next_sector
  5845 00002578 837EF800                	cmp word [bp + ?length_this_cluster], 0
  5846 0000257C 75A1                    	jne .next_sector
  5847                                  
  5848 0000257E 8B7EF4                  	mov di, word [bp + ?bytes_per_cluster]
  5849 00002581 8B76F6                  	mov si, word [bp + ?bytes_per_cluster + 2]
  5850 00002584 397EF0                  	cmp word [bp + ?how_far_in_cluster], di
  5851 00002587 7505                    	jne @F
  5852 00002589 3976F2                  	cmp word [bp + ?how_far_in_cluster + 2], si
  5853 0000258C 740E                    	je @FF
  5854                                  @@:
  5855 0000258E 837EFE00                	cmp word [bp + ?length + 2], 0
  5856 00002592 756D                    	jne .error
  5857 00002594 837EFC00                	cmp word [bp + ?length], 0
  5858 00002598 7567                    	jne .error
  5859 0000259A EB65                    	jmp .return
  5860                                  
  5861                                  @@:
  5862 0000259C A1[C801]                	mov ax, word [load_data - LOADDATA2 + ldCurrentCluster]
  5863 0000259F 8B16[CA01]              	mov dx, word [load_data - LOADDATA2 + ldCurrentCluster + 2]
  5864 000025A3 E86DF2                  	call check_clust
  5865 000025A6 7259                    	jc .error
  5866 000025A8 E86AF1                  	call clust_next.dxax
  5867 000025AB 732F                    	jnc @F			; (NC) -->
  5868 000025AD B8F6FF                  	mov ax, 0FFF8h - 2
  5869 000025B0 BAFF0F                  	mov dx, 0FFFh
  5870 000025B3 8B3E[CC01]              	mov di, word [load_data - LOADDATA2 + ldCurrentSeek]
  5871 000025B7 8B36[CE01]              	mov si, word [load_data - LOADDATA2 + ldCurrentSeek + 2]
  5872 000025BB 3B36[C601]              	cmp si, word [load_data - LOADDATA2 + ldFileSize + 2]
  5873 000025BF 7506                    	jne .set_error
  5874 000025C1 3B3E[C401]              	cmp di, word [load_data - LOADDATA2 + ldFileSize]
  5875 000025C5 7401                    	je .do_not_set_error	; if same then NC -->
  5876                                  .set_error:
  5877 000025C7 F9                      	stc
  5878                                  .do_not_set_error:
  5879 000025C8 9C                      	pushf
  5880 000025C9 31C9                    	xor cx, cx
  5881 000025CB 31DB                    	xor bx, bx
  5882 000025CD 874EFC                  	xchg cx, word [bp + ?length]
  5883 000025D0 875EFE                  	xchg bx, word [bp + ?length + 2]
  5884 000025D3 010E[CC01]              	add word [load_data - LOADDATA2 + ldCurrentSeek], cx
  5885 000025D7 111E[CE01]              	adc word [load_data - LOADDATA2 + ldCurrentSeek + 2], bx
  5886 000025DB A8                      	db __TEST_IMM8		; (skip pushf)
  5887                                  @@:
  5888 000025DC 9C                      	pushf
  5889 000025DD 83C002                  	add ax, 2
  5890 000025E0 83D200                  	adc dx, 0
  5891 000025E3 A3[C801]                	mov word [load_data - LOADDATA2 + ldCurrentCluster], ax
  5892 000025E6 8916[CA01]              	mov word [load_data - LOADDATA2 + ldCurrentCluster + 2], dx
  5893 000025EA 9D                      	popf			; CF
  5894 000025EB 7214                    	jc .error
  5895 000025ED 8B4EFC                  	mov cx, word [bp + ?length]
  5896 000025F0 8B5EFE                  	mov bx, word [bp + ?length + 2]
  5897 000025F3 85DB                    	test bx, bx
  5898 000025F5 7403E9E1FE              	jnz .next_cluster
  5899 000025FA 85C9                    	test cx, cx
  5900 000025FC 7403E9DAFE              	jnz .next_cluster
  5901                                  .return:
  5902                                  .error:
  5903                                  
  5904 00002601 5D                      	pop bp
  5905                                  
  5906 00002602 8F06[0000]              	pop word [throwsp]
  5907 00002606 8F06[0000]              	pop word [throwret]	; restore throw destination
  5908 0000260A 8F06[0000]              	pop word [errret]
  5909                                  
  5910 0000260E 9C                      	pushf
  5911 0000260F F646E801                	testopt [bp + ?did_guard_auxbuff], 1
  5912 00002613 7405                    	jz @F
  5913 00002615 8026[0300]EF            	clropt [internalflags3], dif3_auxbuff_guarded_1
  5914                                  @@:
  5915 0000261A 8026[E701]FB            	clropt [load_ldflags], ldfFATBuffered
  5916 0000261F 9D                      	popf			; CF
  5917                                  
  5918 00002620 8B5EEA                  	mov bx, word [bp + ?load_input_file_structure]
  5919                                  		; bx -> load_input_file structure
  5920 00002623 E852FB                  	call yy_boot_update.bx
  5921                                  
  5922 00002626 5F                      	pop di
  5923 00002627 5E                      	pop si
  5924 00002628 89EC5D                  	lleave
  5925 0000262B C3                      	retn
  5926                                  
  5927                                  .err_ret:
  5928 0000262C 8B26[0000]              	mov sp, word [throwsp]	; restore stack
  5929                                  				;  (needed here if returned to errret)
  5930 00002630 EBCF                    	jmp .error
  5931                                  
  5932                                  
  5933                                  		; INP:	[load_input_file] = active file
  5934                                  		;	cx:dx = 0
  5935                                  		; OUT:	-
  5936                                  		; CHG:	ax, bx, cx, dx
  5937                                  		; STT:	ds = es = ss
  5938                                  %if _INPUT_FILE_BOOT
  5939                                  yy_boot_seek_start:
  5940 00002632 E854FB                  	call yy_calculate_structure
  5941                                  
  5942                                  		; INP:	bx -> data
  5943                                  		; CHG:	ax
  5944                                  .bx: section_of_function yy_boot_seek_start
  5945                                  %else
  5946                                  yy_boot_seek_start.bx: section_of_function
  5947                                  %endif
  5948 00002635 56                      	push si
  5949 00002636 57                      	push di
  5950                                  
  5951                                  		; bx -> load_input_file structure
  5952 00002637 E82FFB                  	call yy_boot_get.bx
  5953                                  
  5954                                  .reset:
  5955                                  		; reset current cluster to first, seek to 0
  5956 0000263A FF36[F201]              	push word [load_data - LOADDATA2 + lsvFirstCluster + 2]
  5957 0000263E FF36[F001]              	push word [load_data - LOADDATA2 + lsvFirstCluster]
  5958 00002642 8F06[C801]              	pop word [load_data - LOADDATA2 + ldCurrentCluster]
  5959 00002646 8F06[CA01]              	pop word [load_data - LOADDATA2 + ldCurrentCluster + 2]
  5960 0000264A 8326[CC01]00            	and word [load_data - LOADDATA2 + ldCurrentSeek], 0
  5961 0000264F 8326[CE01]00            	and word [load_data - LOADDATA2 + ldCurrentSeek + 2], 0
  5962                                  
  5963                                  		; bx -> load_input_file structure
  5964 00002654 E821FB                  	call yy_boot_update.bx
  5965                                  
  5966 00002657 5F                      	pop di
  5967 00002658 5E                      	pop si
  5968 00002659 C3                      	retn
  5969                                  %endif
  5970                                  
  5971                                  
  5972                                  		; INP:	bp = load_data - LOADDATA2
  5973                                  initialise_fs:
  5974                                  ; (boot.asm code starts here)
  5975                                  
  5976 0000265A 31C0                    	xor ax, ax
  5977                                  ; calculate some values that we need:
  5978                                  ; adjusted sectors per cluster (store in a word,
  5979                                  ;  and decode EDR-DOS's special value 0 meaning 256)
  5980 0000265C 8A460D                  	mov al, [bp + bsBPB + bpbSectorsPerCluster]
  5981 0000265F FEC8                    	dec al
  5982 00002661 40                      	inc ax
  5983 00002662 8946E8                  	mov [bp + ldClusterSize], ax
  5984                                  
  5985 00002665 8B46D4                  	mov ax, [bp + ldEntriesPerSector]
  5986                                  
  5987                                  ; number of sectors used for root directory (store in CX)
  5988 00002668 31D2                    	xor dx, dx
  5989 0000266A 89C3                    	mov bx, ax
  5990 0000266C 48                      	dec ax				; rounding up
  5991 0000266D 034611                  	add ax, [bp + bsBPB + bpbNumRootDirEnts]	; (0 iff FAT32)
  5992 00002670 11D2                    	adc dx, dx			; account for overflow (dx was zero)
  5993 00002672 F7F3                    	div bx				; get number of root sectors
  5994 00002674 91                      	xchg ax, cx			; cx = number of root secs
  5995                                  
  5996                                  
  5997                                  ; (iniload.asm code starts here)
  5998                                  
  5999 00002675 51                      	push cx				; number of root secs
  6000 00002676 31C0                    	xor ax, ax
  6001                                  ; first sector of root directory
  6002 00002678 8A4610                  	mov al, [bp + bsBPB + bpbNumFATs]	; ! ah = 0, hence ax = number of FATs
  6003 0000267B 8B4E16                  	mov cx, word [bp + bsBPB + bpbSectorsPerFAT]
  6004 0000267E 31FF                    	xor di, di			; di:cx = sectors per FAT
  6005                                  					;  iff FAT12, FAT16
  6006 00002680 85C9                    	test cx, cx			; is FAT32 ?
  6007 00002682 7506                    	jnz @F				; no -->
  6008 00002684 8B4E24                  	mov cx, word [bp + bsBPB + ebpbSectorsPerFATLarge]
  6009 00002687 8B7E26                  	mov di, word [bp + bsBPB + ebpbSectorsPerFATLarge + 2]	; for FAT32
  6010                                  @@:
  6011 0000268A 50                      	push ax
  6012 0000268B F7E1                    	mul cx
  6013                                  		; ax = low word SpF*nF
  6014                                  		; dx = high word
  6015 0000268D 93                      	xchg bx, ax
  6016 0000268E 87CA                    	xchg cx, dx
  6017                                  		; cx:bx = first mul
  6018 00002690 58                      	pop ax
  6019 00002691 F7E7                    	mul di
  6020                                  		; ax = high word adjust
  6021                                  		; dx = third word
  6022 00002693 85D2                    	test dx, dx
  6023 00002695 740C                    	jz @F
  6024                                  .error_badchain:
  6025                                  error_badchain: equ $
  6026 00002697 BA[0000]                	mov dx, msg.boot_badchain
  6027 0000269A B80D02                  	mov ax, 020Dh
  6028 0000269D E8(0000)                	call setrc
  6029 000026A0 E9B9DE                  	jmp bootcmd.fail
  6030                                  
  6031                                  @@:
  6032 000026A3 92                      	xchg dx, ax
  6033                                  		; dx = high word adjust
  6034 000026A4 01CA                    	add dx, cx
  6035                                  		; dx:bx = result
  6036 000026A6 93                      	xchg ax, bx
  6037                                  		; dx:ax = result
  6038 000026A7 72EE                    	jc .error_badchain
  6039                                  
  6040 000026A9 03460E                  	add ax, [bp + bsBPB + bpbReservedSectors]
  6041 000026AC 83D200                  	adc dx, byte 0
  6042 000026AF 72E6                    	jc .error_badchain
  6043                                  
  6044 000026B1 59                      	pop cx				; number of root sectors
  6045 000026B2 31FF                    	xor di, di
  6046                                  
  6047                                  ; first sector of disk data area:
  6048 000026B4 01C1                    	add cx, ax
  6049 000026B6 11D7                    	adc di, dx
  6050 000026B8 72DD                    	jc .error_badchain
  6051 000026BA 894EFC                  	mov [bp + lsvDataStart], cx
  6052 000026BD 897EFE                  	mov [bp + lsvDataStart + 2], di
  6053                                  
  6054 000026C0 8946D0                  	mov [bp + ldRootSector], ax
  6055 000026C3 8956D2                  	mov [bp + ldRootSector + 2], dx
  6056                                  
  6057                                  ; total sectors
  6058 000026C6 31D2                    	xor dx, dx
  6059 000026C8 8B4613                  	mov ax, [bp + bsBPB + bpbTotalSectors]
  6060 000026CB 85C0                    	test ax, ax
  6061 000026CD 7506                    	jnz @F
  6062 000026CF 8B5622                  	mov dx, [bp + bsBPB + bpbTotalSectorsLarge + 2]
  6063 000026D2 8B4620                  	mov ax, [bp + bsBPB + bpbTotalSectorsLarge]
  6064                                  
  6065                                  		; fall through and let it overwrite the field with the
  6066                                  		; already current contents. saves a jump.
  6067                                  @@:
  6068 000026D5 895622                  	mov [bp + bsBPB + bpbTotalSectorsLarge + 2], dx
  6069 000026D8 894620                  	mov [bp + bsBPB + bpbTotalSectorsLarge], ax
  6070                                  
  6071                                  	; dx:ax = total sectors
  6072                                  
  6073 000026DB 8B5E16                  	mov bx, [bp + bsBPB + bpbSectorsPerFAT]
  6074 000026DE C646E620                	mov byte [bp + ldFATType], 32
  6075 000026E2 85DB                    	test bx, bx
  6076 000026E4 740B                    	jz @F
  6077                                  
  6078 000026E6 31C9                    	xor cx, cx
  6079                                  
  6080 000026E8 895E24                  	mov word [bp + bsBPB + ebpbSectorsPerFATLarge], bx
  6081 000026EB 894E26                  	mov word [bp + bsBPB + ebpbSectorsPerFATLarge + 2], cx
  6082 000026EE 894E28                  	mov word [bp + bsBPB + ebpbFSFlags], cx
  6083                                  	; FSVersion, RootCluster, FSINFOSector, BackupSector, Reserved:
  6084                                  	;  uninitialised here (initialised by loaded_all later)
  6085                                  
  6086                                  @@:
  6087                                  	; dx:ax = total amount of sectors
  6088 000026F1 2B46FC                  	sub ax, word [bp + lsvDataStart]
  6089 000026F4 1B56FE                  	sbb dx, word [bp + lsvDataStart + 2]
  6090                                  
  6091                                  	; dx:ax = total amount of data sectors
  6092 000026F7 89C3                    	mov bx, ax
  6093 000026F9 92                      	xchg ax, dx
  6094 000026FA 31D2                    	xor dx, dx
  6095 000026FC F776E8                  	div word [bp + ldClusterSize]
  6096 000026FF 93                      	xchg bx, ax
  6097 00002700 F776E8                  	div word [bp + ldClusterSize]
  6098                                  	; bx:ax = quotient, dx = remainder
  6099                                  	; bx:ax = number of clusters
  6100 00002703 85DB                    	test bx, bx
  6101 00002705 741F                    	jz @FF
  6102                                  		; >= 1_0000h clusters, should be FAT32
  6103 00002707 81FBFF0F                	cmp bx, 0FFFh
  6104 0000270B 770D                    	ja .badclusters
  6105 0000270D 7505                    	jne @F
  6106 0000270F 83F8F5                  	cmp ax, 0FFF7h - 2
  6107 00002712 7706                    	ja .badclusters
  6108                                  @@:
  6109                                  		; check it is really FAT32
  6110 00002714 837E1600                	cmp word [bp + bsBPB + bpbSectorsPerFAT], 0
  6111 00002718 7447                    	je .gotfattype
  6112                                  
  6113                                  .badclusters:
  6114 0000271A BA[0000]                	mov dx, msg.boot_badclusters
  6115 0000271D B80E02                  	mov ax, 020Eh
  6116 00002720 E8(0000)                	call setrc
  6117 00002723 E936DE                  	jmp bootcmd.fail
  6118                                  
  6119                                  @@:
  6120                                  		; <= FFFFh clusters, may be FAT12 or FAT16 (or small FAT32)
  6121                                  		; check if it is small FAT32
  6122 00002726 837E1600                	cmp word [bp + bsBPB + bpbSectorsPerFAT], 0
  6123 0000272A 7435                    	je .gotfattype
  6124                                  
  6125 0000272C 83F8F5                  	cmp ax, 0FFF7h - 2		; too much for FAT16 ?
  6126 0000272F 77E9                    	ja .badclusters
  6127 00002731 C646E610                	mov byte [bp + ldFATType], 16
  6128 00002735 3DF50F                  	cmp ax, 0FF7h - 2		; is it FAT12 ?
  6129 00002738 7727                    	ja .gotfattype			; no, is FAT16 -->
  6130                                  
  6131 0000273A C646E60C                	mov byte [bp + ldFATType], 12
  6132                                  
  6133 0000273E F606[E701]02            	testopt [load_ldflags], ldfFATInvalid
  6134 00002743 751C                    	jnz .gotfattype
  6135                                  
  6136 00002745 53                      	push bx
  6137 00002746 50                      	push ax
  6138                                  ; (boot.asm code continues here)
  6139                                  
  6140                                  ; Load the entire FAT into memory. This is easily feasible for FAT12,
  6141                                  ;  as the FAT can only contain at most 4096 entries.
  6142                                  ; (The exact condition should be "at most 4087 entries", or with a
  6143                                  ;  specific FF7h semantic, "at most 4088 entries"; the more reliable
  6144                                  ;  and portable alternative would be "at most 4080 entries".)
  6145                                  ; Thus, no more than 6 KiB need to be read, even though the FAT size
  6146                                  ;  as indicated by word[sectors_per_fat] could be much higher. The
  6147                                  ;  first loop condition below is to correctly handle the latter case.
  6148                                  ; (Sector size is assumed to be a power of two between 32 and 8192
  6149                                  ;  bytes, inclusive. An 8 KiB buffer is necessary if the sector size
  6150                                  ;  is 4 or 8 KiB, because reading the FAT can or will write to 8 KiB
  6151                                  ;  of memory instead of only the relevant 6 KiB. This is always true
  6152                                  ;  if the sector size is 8 KiB, and with 4 KiB sector size it is true
  6153                                  ;  iff word[sectors_per_fat] is higher than one.)
  6154 00002747 BF0018                  		mov di, 6 << 10		; maximum size of FAT12 to load
  6155 0000274A 8B4E16                  		mov cx, [bp + bsBPB + bpbSectorsPerFAT]
  6156                                  					; maximum size of this FS's FAT
  6157 0000274D 31D2                    		xor dx, dx
  6158 0000274F 8B460E                  		mov ax, [bp + bsBPB + bpbReservedSectors]; = first FAT sector
  6159 00002752 8B5EF8                  		mov bx, [bp + lsvFATSeg]
  6160                                  @@:
  6161 00002755 E879F4                  		call read_sector	; read next FAT sector
  6162 00002758 2B7E0B                  		sub di, [bp + bsBPB + bpbBytesPerSector]
  6163                                  					; di = bytes still left to read
  6164 0000275B 7602                    		jbe @F			; if none -->
  6165                                  					; (jbe means jump if CF || ZF)
  6166 0000275D E2F6                    		loop @B			; if any FAT sector still remains -->
  6167                                  @@:					; one of the limits reached; FAT read
  6168 0000275F 58                      	pop ax
  6169 00002760 5B                      	pop bx
  6170                                  
  6171                                  .gotfattype:
  6172                                  
  6173                                  ; if bx:ax = 1, then entries 0, 1, 2 are valid
  6174 00002761 83C001                  	add ax, 1
  6175 00002764 83D300                  	adc bx, 0
  6176                                  ; max entry is x+1 (2 if x=1)
  6177                                  
  6178 00002767 8946C0                  	mov word [bp + ldMaxCluster], ax
  6179 0000276A 895EC2                  	mov word [bp + ldMaxCluster + 2], bx
  6180                                  
  6181                                  ; if bx:ax was = 1, then entries below 3 have to exist
  6182 0000276D 83C001                  	add ax, 1
  6183 00002770 83D300                  	adc bx, 0
  6184                                  ; if bx:ax was 1, bx:ax now = 3
  6185                                  
  6186 00002773 89DA                    	mov dx, bx
  6187                                  
  6188 00002775 807EE610                	cmp byte [bp + ldFATType], 16
  6189 00002779 720C                    	jb .check_fat_limit_12
  6190 0000277B 7404                    	je .check_fat_limit_16
  6191                                  .check_fat_limit_32:
  6192 0000277D 01C0                    	add ax, ax
  6193 0000277F 11D2                    	adc dx, dx
  6194                                  .check_fat_limit_16:
  6195 00002781 01C0                    	add ax, ax
  6196 00002783 11D2                    	adc dx, dx
  6197 00002785 EB0D                    	jmp @F
  6198                                  
  6199                                  .check_fat_limit_12:
  6200 00002787 89C2                    	mov dx, ax
  6201 00002789 01C0                    	add ax, ax
  6202 0000278B 01D0                    	add ax, dx		; * 3
  6203 0000278D D1E8                    	shr ax, 1		; * 3 / 2 = * 1.5
  6204 0000278F 83D000                  	adc ax, 0		; if the last nybble is needed
  6205 00002792 31D2                    	xor dx, dx
  6206                                  
  6207                                  @@:
  6208 00002794 8B5E0B                  	mov bx, word [bp + bsBPB + bpbBytesPerSector]
  6209 00002797 4B                      	dec bx
  6210 00002798 01D8                    	add ax, bx
  6211 0000279A 83D200                  	adc dx, 0
  6212 0000279D 43                      	inc bx
  6213                                  
  6214 0000279E 91                      	xchg cx, ax
  6215 0000279F 89D0                    	mov ax, dx
  6216 000027A1 31D2                    	xor dx, dx
  6217 000027A3 F7F3                    	div bx
  6218 000027A5 91                      	xchg cx, ax
  6219 000027A6 F7F3                    	div bx
  6220 000027A8 87CA                    	xchg cx, dx
  6221                                  		; cx = remainder, dx:ax = number of sectors needed
  6222                                  
  6223 000027AA 8B4E16                  	mov cx, word [bp + bsBPB + bpbSectorsPerFAT]
  6224 000027AD 31FF                    	xor di, di			; di:cx = sectors per FAT
  6225                                  					;  iff FAT12, FAT16
  6226 000027AF 85C9                    	test cx, cx			; is FAT32 ?
  6227 000027B1 7506                    	jnz @F				; no -->
  6228 000027B3 8B4E24                  	mov cx, word [bp + bsBPB + ebpbSectorsPerFATLarge]
  6229 000027B6 8B7E26                  	mov di, word [bp + bsBPB + ebpbSectorsPerFATLarge + 2]	; for FAT32
  6230                                  @@:
  6231                                  
  6232 000027B9 39D7                    	cmp di, dx
  6233 000027BB 7502                    	jne @F
  6234 000027BD 39C1                    	cmp cx, ax
  6235                                  @@:
  6236 000027BF 730C                    	jae @F
  6237                                  .badfat:
  6238 000027C1 BA[0000]                	mov dx, msg.boot_badfat
  6239 000027C4 B80F02                  	mov ax, 020Fh
  6240 000027C7 E8(0000)                	call setrc
  6241 000027CA E98FDD                  	jmp bootcmd.fail
  6242                                  
  6243                                  @@:
  6244 000027CD C3                      	retn
  6245                                  
  6246                                  
  6247                                  %if _INPUT_FILE_BOOT
  6248                                  yy_boot_clear_remember_seek:
  6249 000027CE 50                      	push ax
  6250 000027CF A1[2005]                	mov ax, word [load_input_file.active]
  6251 000027D2 3906[0000]              	cmp word [boot_remember_seek_handle], ax
  6252 000027D6 750F                    	jne .ret_pop_ax
  6253                                  .clear:
  6254 000027D8 830E[0000]FF            	or word [boot_remember_seek_handle], -1
  6255 000027DD 8326[0200]00            	and word [boot_remember_seek_offset + 2], 0
  6256 000027E2 8326[0000]00            	and word [boot_remember_seek_offset], 0
  6257                                  .ret_pop_ax:
  6258 000027E7 58                      	pop ax
  6259 000027E8 C3                      	retn
  6260                                  
  6261                                  
  6262                                  yy_boot_remember_seek:
  6263 000027E9 50                      	push ax
  6264 000027EA A1[2005]                	mov ax, word [load_input_file.active]
  6265 000027ED 3906[0000]              	cmp word [boot_remember_seek_handle], ax
  6266 000027F1 75F4                    	jne yy_boot_clear_remember_seek.ret_pop_ax
  6267                                  
  6268 000027F3 53                      	push bx
  6269 000027F4 51                      	push cx
  6270 000027F5 52                      	push dx
  6271 000027F6 8B0E[0200]              	mov cx, word [boot_remember_seek_offset + 2]
  6272 000027FA 8B16[0000]              	mov dx, word [boot_remember_seek_offset]
  6273 000027FE E8C8FB                  	call yy_boot_seek_current
  6274 00002801 5A                      	pop dx
  6275 00002802 59                      	pop cx
  6276 00002803 5B                      	pop bx
  6277 00002804 EBD2                    	jmp yy_boot_clear_remember_seek.clear
  6278                                  %endif
  6279                                  
  6280                                  %if _LINK && !_BOOTLDR_DISCARD
  6281                                  behind_code_truncated:
  6282                                  %endif
  6283                                  
  6284                                  %endif
