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