     1                                  
     2                                  %if 0
     3                                  
     4                                  lDebug "boot" commands - boot loading
     5                                  
     6                                  Copyright (C) 2008-2026 E. C. Masloch
     7                                  
     8                                  Usage of the works is permitted provided that this
     9                                  instrument is retained with the works, so that any entity
    10                                  that uses the works is notified of this instrument.
    11                                  
    12                                  DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                                  
    14                                  %endif
    15                                  
    16                                  %define SOURCEFILENAME "boot.asm"
    17                                  %ifidni __OUTPUT_FORMAT__, obj
    18                                   %include "debug.mac"
     1                              <1> [list -]
    14                              <3> [list -]
    14                              <2> [list -]
    86                              <1> [list -]
    86          ------------------  <1>  note: Disable usesection detection
    86          ------------------  <1>  note: usesection lDEBUG_DATA_ENTRY
    86          ------------------  <1>  note: usesection ASMTABLE1
    86          ------------------  <1>  note: usesection ASMTABLE2
    86          ------------------  <1>  note: usesection DATASTACKBASE
    86          ------------------  <1>  note: usesection MESSAGESEGMENT
    86          ------------------  <1>  note: usesection lDEBUG_CODE
    86          ------------------  <1>  note: usesection lDEBUG_CODE2
    86          ------------------  <1>  note: usesection INIT
    86          ------------------  <1>  note: usesection WLEMITALIGNINITEND
    86          ------------------  <1>  note: usesection DEVICESHIM
    86          ------------------  <1>  note: usesection WLEMITALIGNRELOCZERO
    68                              <2> %endif
    69                              <2> 
    70                              <2> 
    71                              <2> 	usesection lDEBUG_CODE
    71          ------------------  <2>  note: usesection lDEBUG_CODE
    72                              <2> section_of puts, trimputs, puts_ext_done, puts_ext_next
    73                              <2> section_of putsz_exthelp, code_retf
    74                              <2> section_of puts_getline_ext_done
    75                              <2> section_of puts_copyoutput_ext_done
    76                              <2> section_of guard_auxbuff, guard_re
    77                              <2> section_of handle_serial_flags_ctrl_c
    78                              <2> section_of hexword_high
    79                              <2> section_of call_int2D
    80                              <2> section_of copy_single_counted_string
    81                              <2> section_of intchk
    82                              <2> section_of IsIISPEntry?
    83                              <2> section_of dd_store
    84                              <2> section_of dohack, getsegmented, hexbyte, hexnyb, iseol?.notsemicolon
    85                              <2> section_of peekc, getc, prephack, readmem, setds2si, setds2bx, setes2dx
    86                              <2> section_of silence_get_start, silence_get_start.have_di, silence_count_zeroes
    87                              <2> section_of setrmlimit, skipcomm0, unhack
    88                              <2> section_of skipequals
    89                              <2> section_of to_errret_pop
    90                              <2> section_of cmd3.have_cx_convenience
    91                              <2> section_of verifysegm, verifysegm_or_error
    92                              <2> section_of pp16, resetmode, resetmode_and_test_d_b_bit
    93                              <2> section_of pp_fix32bitflags, proceedbreakpoint
    94                              <2> section_of putsz, hexword, skipcomma, cmd3, cmd3_not_ext, cmd3_preprocessed
    95                              <2> section_of hexdword
    96                              <2> section_of cmd3_not_inject, cmd3_injected
    97                              <2> section_of aa_not_inject, aa_injected, aa_before_getline, aa_after_getline
    98                              <2> section_of transfer_ext_cx_nearcall_from_code2
    99                              <2> section_of traceone, unexpectedinterrupt, dumpregs_no_disasm
   100                              <2> section_of aa_imm_entry, ia_restore_a_addr, ia_restore_u_addr, disasm
   101                              <2> section_of ia_restore_ds
   102                              <2> %ifn _SYMBOLIC
   103                              <2> section_of selector_to_segment
   104                              <2> %endif
   105                              <2> section_of disp_al, disp_al_hex, disp_al_nybble_hex, disp_ax_dec, disp_ax_hex
   106                              <2> section_of disp_dxax_times_cx_width_bx_size
   107                              <2> section_of disp_dxax_times_cx_width_bx_size.store
   108                              <2> section_of disp_message, disp_message_length_cx
   109                              <2> section_of ispm
   110                              <2> section_of setrc, error
   111                              <2> section_of _doscall, _doscall_return_es, _doscall_return_es_parameter_es_ds
   112                              <2> section_of intcall_ext_return_es, close_ext, doscall_extseg
   113                              <2> section_of yy_reset_buf
   114                              <2> section_of init_bootcmd
   115                              <2> 
   116                              <2> section_of InDOS, bootgetmemorysize
   117                              <2> section_of chkeol, decword, decdword
   118                              <2> section_of dec_dword_minwidth
   119                              <2> section_of getexpression.lit_isdigit?, getexpression.lit_ishexdigit?
   120                              <2> section_of getlinearaddr
   121                              <2> section_of getlinear_d_b
   122                              <2> section_of getlinear_high_limit
   123                              <2> section_of getlinear_32bit
   124                              <2> section_of getlinear_high_limit.do_not_use_test
   125                              <2> section_of getlinear_common
   126                              <2> section_of ifsep, iseol?, isseparator?, isstring?, movp
   127                              <2> section_of putc, putsline, putsline_crlf, putsz_error
   128                              <2> section_of setrmsegm
   129                              <2> section_of skipwh0, skipwhite
   130                              <2> section_of test_d_b_bit, test_high_limit, push_cxdx_or_edx
   131                              <2> section_of capitalise
   132                              <2> section_of setes2ax
   133                              <2> section_of zz_copy_strings_to_str_buffer
   134                              <2> section_of call_xms_move, zz_call_xms, zz_detect_xms
   135                              <2> section_of code2_to_code_ret_to_ext
   136                              <2> section_of yy_dos_parse_name, yy_open_file, yy_check_lfn
   137                              <2> section_of yy_common_parse_name
   138                              <2> section_of yy_common_parse_name_bx_buffer
   139                              <2> section_of retry_open_scriptspath
   140                              <2> section_of yy_boot_read.bx, yy_boot_seek_start.bx, yy_boot_seek_current.bx
   141                              <2> section_of yy_boot_parse_name, yy_boot_open_file
   142                              <2> section_of yy_boot_parse_name_bx_buffer
   143                              <2> section_of near_transfer_ext_return, scan_dir_aux, read_sector
   144                              <2> section_of yy_boot_init_dir, got_yyentry, scan_dir_entry
   145                              <2> section_of ..@yy_filename_empty, boot_parse_fn
   146                              <2> section_of count_store, count_store.maybe_0
   147                              <2> section_of loader_get_resident_address, loader_prepare_resident
   148                              <2> 
   149                              <2> 
   150                              <2>  %if _SYMBOLIC && _DUALCODE && _SYMBOLASMDUALCODE
   151                              <2> 	usesection lDEBUG_CODE2
   152                              <2>  %else
   153                              <2> 	usesection lDEBUG_CODE
   153          ------------------  <2>  note: usesection lDEBUG_CODE
   154                              <2>  %endif
   155                              <2> section_of bxcx_to_cx_paragraphs
   156                              <2> section_of zz_list_symbol.first, zz_list_symbol.subsequent
   157                              <2> section_of zz_xms_to_86mm, zz_xms_try_free, zz_xms_try_free_handle
   158                              <2> section_of zz_86mm_to_xms, zz_del_match.add_poison_entrypoint
   159                              <2> section_of zz_free_nonxms, zz_free_xms, zz_free_reset, zz_free_dos
   160                              <2> section_of zz_get_literal, zz_restore_strat, zz_save_strat
   161                              <2> section_of zz_switch_s, zz_transfer_buffer
   162                              <2> 
   163                              <2> 
   164                              <2> %if _SYMBOLIC
   165                              <2>  %if _DUALCODE && _SYMBOLICDUALCODE
   166                              <2> 	usesection lDEBUG_CODE2
   167                              <2>  %else
   168                              <2> 	usesection lDEBUG_CODE
   169                              <2>  %endif
   170                              <2> section_of shift_left_4_bxcx
   171                              <2> section_of selector_to_segment
   172                              <2> 
   173                              <2> section_of anti_normalise_pointer_with_displacement_bxcx, displaystring
   174                              <2> section_of getfarpointer.hash, getfarpointer.main, getfarpointer.str
   175                              <2> section_of move_delete_farpointer.hash, move_delete_farpointer.hash.sidi
   176                              <2> section_of move_delete_farpointer.main, move_delete_farpointer.str.sidi
   177                              <2> section_of move_insert_farpointer.hash, move_insert_farpointer.hash.sidi
   178                              <2> section_of move_insert_farpointer.main, move_insert_farpointer.main.sidi
   179                              <2> section_of move_insert_farpointer.str.sidi
   180                              <2> section_of normalise_pointer, normalise_pointer_with_displacement_bxcx
   181                              <2> section_of pointer_to_linear
   182                              <2> section_of save_slice_farpointer.hash, save_slice_farpointer.main
   183                              <2> section_of save_slice_farpointer.str
   184                              <2> section_of segment_to_selector
   185                              <2> section_of zz_insert, zz_match_symbol, zz_match_symbol.continue, zz_relocate
   186                              <2> 
   187                              <2> section_of binsearchhash, binsearchmain
   188                              <2> section_of check_second_slice
   189                              <2> section_of disp_size_hash, disp_size_main, disp_size_str
   190                              <2> section_of displayresult, getstring1, getstring2
   191                              <2> section_of increment_ss_ref_count
   192                              <2> section_of list_sym_storage_usage, str_index_to_pointer
   193                              <2> section_of zz_commit_insert, zz_compact, zz_compact_expand_check_nonxms
   194                              <2> section_of zz_compact_expand_check_xms
   195                              <2> section_of zz_delete_hash, zz_delete_main, zz_delete_main_and_its_hash
   196                              <2> section_of zz_delete_string, zz_expand, zz_expand_common
   197                              <2> section_of zz_get_symstr_length_bytes
   198                              <2> section_of zz_get_symstr_length_bytes.ssLength_in_cx
   199                              <2> section_of zz_get_symstr_length_indices
   200                              <2> section_of zz_get_symstr_length_indices.ssLength_in_cx
   201                              <2> section_of zz_hash, zz_hash.bx_init
   202                              <2> section_of zz_insert_main.linklist, zz_reloc_main, zz_reloc_str
   203                              <2> section_of zz_store_pre_str, zz_store_string, zz_store_string.hash_bx
   204                              <2> section_of zz_unlink_main_next
   205                              <2> %endif
   206                              <2> 
   207                              <2> %if _DUALCODE
   208                              <2> 	usesection lDEBUG_CODE2
   208          ------------------  <2>  note: usesection lDEBUG_CODE2
   209                              <2> %else
   210                              <2> 	usesection lDEBUG_CODE
   211                              <2> %endif
   212                              <2> section_of FloatToStr
   213                              <2> 
   214                              <2> 
   215                              <2>  %if _DUALCODE && _EXPRDUALCODE
   216                              <2> 	usesection lDEBUG_CODE2
   216          ------------------  <2>  note: usesection lDEBUG_CODE2
   217                              <2>  %else
   218                              <2> 	usesection lDEBUG_CODE
   219                              <2>  %endif
   220                              <2> 
   221                              <2> section_of getofsforbx, checkpointer, getrangeX
   222                              <2> section_of getrangeX_have_address_need_length
   223                              <2> section_of getrange, getaddr, getofsforbx_remember_bitness
   224                              <2> section_of remember_bitness, getaddr_taken
   225                              <2> section_of getstr, get_length, get_length_keyword
   226                              <2> section_of isbracketorunaryoperator?, isunaryoperator?, isoperator?
   227                              <2> section_of ..@call_operator_dispatchers
   228                              <2> section_of isseparator?, istype?, isunsignedtype?
   229                              <2> section_of handlesegment, handle3byte, handlebyte, handleword
   230                              <2> section_of handledword, handlepointer
   231                              <2> section_of uoh_abs, uoh_minus, calculate_minus_bxdx, uoh_plus
   232                              <2> section_of uoh_not_bitwise, uoh_not_boolean
   233                              <2> section_of od_minus, od_plus, od_multiply, od_divide, od_modulo, od_retn
   234                              <2> section_of od_above, od_below, od_equal, od_not, od_or, od_and, od_xor
   235                              <2> section_of od_cond, od_o, od_a, od_x, od_c, od_string_common
   236                              <2> section_of of_modulo, of_minus, of_plus, or_hhtype, of_multiply
   237                              <2> section_of set_hhtype, of_divide, of_power
   238                              <2> section_of of_compare_below_equal, of_compare_below, of_compare_not_equal
   239                              <2> section_of of_compare_equal, of_compare_above_equal, of_compare_above
   240                              <2> section_of toboolean, of_helper_compare_true, of_rightop, of_helper_compare
   241                              <2> section_of of_shift_right, of_shift_right_signed, of_shift_left
   242                              <2> section_of of_helper_getshiftdata, of_bit_mirror
   243                              <2> section_of of_or_bitwise, or_hhtype_1, of_or_boolean, of_clr_bitwise
   244                              <2> section_of of_and_bitwise, of_and_boolean, of_xor_bitwise, of_xor_boolean
   245                              <2> section_of of_helper_retbool, of_helper_getbool
   246                              <2> 
   247                              <2> section_of var_cip_setup, var_csp_setup, var_lfsr_setup, var_reverselfsr_setup
   248                              <2> section_of var_dpspsel_setup, var_seldbg_setup, var_mt_setup
   249                              <2> section_of var_ioi_setup, var_psps_setup, var_ppr_setup, var_ppi_setup
   250                              <2> section_of var_iok_setup, var_rhcount_setup
   251                              <2> section_of var_get_psp_segment, var_get_psp_selector
   252                              <2> section_of var_bootldpunit_setup, var_bootsdpunit_setup, var_bootydpunit_setup
   253                              <2> section_of var_bootldppart_setup, var_bootsdppart_setup, var_bootydppart_setup
   254                              <2> section_of var_bootunitflags_setup
   255                              <2> 
   256                              <2> section_of issymbol?, isvariable?, var_mm_setup, var_ri_setup, var_ysf_setup
   257                              <2> section_of default_variable_setup
   258                              <2> section_of var_ext_setup
   259                              <2> section_of var_ext_setup_done
   260                              <2> 
   261                              <2> section_of getstmmxdigit
   262                              <2> section_of getexpression.lit_ishexdigit?, getexpression.lit_isdigit?
   263                              <2> section_of of_cond, count_unary_operators, count_unary_operators_restrict
   264                              <2> section_of get3byte.checksignificantbits, getbyte, checksignificantbitscommon
   265                              <2> section_of getnyb, get_value_range
   266                              <2> 
   267                              <2> section_of getaddrX, getword, getdword, getexpression
   268                              <2> 
   269                              <2> section_of getrangeX.lines, getrangeX.ecx_and_0_valid
   270                              <2> section_of getrange.lines, getrange.ecx_and_0_valid, get_length.lines
   271                              <2> section_of getrangeX.lines_and_uu, getrange.lines_and_uu
   272                              <2> section_of isseparator?.except_L_or_dot, isvariable?.return_name
   273                              <2> section_of getword.checksignificantbits, getbyte.checksignificantbits
   274                              <2> 
   275                              <2> section_of seg_bx_to_sel
   276                              <2> section_of getexpression.countsignificantbits
   277                              <2> section_of ..@rr_checksignificantbits, ..@rr_operatordispatchers
   278                              <2> section_of ..@rr_operatorfunctions, ..@parsecm_getaddr
   279                              <2> section_of stack_check.internal
   280                              <2> 
   281                              <2> 
   282                              <2> 	usesection INIT
   282          ------------------  <2>  note: usesection INIT
   283                              <2> section_of init_capitalise
   284                              <2> section_of init_skipwhite, init_skipwh0
   285                              <2> section_of init_skipcomma, init_skipcomm0
   286                              <2> section_of init_skipequals
   287                              <2> 
   288                              <2> 
   289                              <2> 	usesection lDEBUG_DATA_ENTRY
   289          ------------------  <2>  note: usesection lDEBUG_DATA_ENTRY
   290                              <2> section_of entry_retn
   291                              <2> 
   292                              <2> 
   293                              <2> %if _LINK
   294                              <2>  %include "extern.mac"
     1                              <3> 
     2                              <3> ; expr.asm
     3                              <3>  extern PPLEN, PPLEN_ONLY_PREFIXES, a_addr, alloc_seg, alloc_size
     4                              <3>  extern amis_multiplex_number, asm_options, asm_startoptions
     5                              <3>  extern auxbuff_current_size, auxbuff_segorsel, behind_r_u_addr
     6                              <3>  extern bp_offset, code_seg, code_size, d_addr, dcount_addr
     7                              <3>  extern dcpm_addr, dd_default_length, dd_default_lines, dd_text_and
     8                              <3>  extern debuggerfunction, default_pp_count, default_tp_count
     9                              <3>  extern default_tt_count, device_header_address, device_mcb_paragraphs
    10                              <3>  extern dwcount_addr, dz_addr, e_addr, encodedmach87, entryseg_size
    11                              <3>  extern env_size, envseg, erc, errret
    12                              <3>  extern extdata, extdata_size, extdata_used, extseg, extseg_size
    13                              <3>  extern extseg_used, flagbits.amount, flagnames, flagvaron
    14                              <3>  extern getrange_is_uu, getrange_lines, has_mmx, hhresult
    15                              <3>  extern history.segorsel, historyseg_size, immseg, input_file_handles
    16                              <3>  extern input_file_handles.active, internalflags, internalflags2
    17                              <3>  extern internalflags3, intr8_limit, io_columns, io_columns_getline
    18                              <3>  extern io_end_buffer, io_flags, io_levels, io_rows, io_start_buffer
    19                              <3>  extern line_out, line_out_end, linkinfoaddress, load_data
    20                              <3>  extern load_input_file, load_input_file.active, load_unit_flags
    21                              <3>  extern loaddata_loadedfrom, machine, maxmachinetype, messageseg
    22                              <3>  extern messageseg_size, mmxbuff, msg.as, msg.end, msg.executing
    23                              <3>  extern msg.executing_value_range, msg.from, msg.in, msg.length
    24                              <3>  extern msg.linear, msg.lines, msg.lr, msg.nd, msg.nottaken
    25                              <3>  extern msg.nt, msg.or, msg.questionmark, msg.r, msg.stack_overflow
    26                              <3>  extern msg.stack_overflow.caller, msg.stack_overflow.cond
    27                              <3>  extern msg.stack_overflow.indirection, msg.stack_overflow.linear
    28                              <3>  extern msg.stack_overflow.parens, msg.stack_overflow.precedence
    29                              <3>  extern msg.stack_overflow.value_in, msg.t, msg.taken, msg.to
    30                              <3>  extern msg.value, msgtable_value_range, options, options2, parent
    31                              <3>  extern ppbytes, priorrc, psp22, pspdbe, pspdbg
    32                              <3>  extern qqtermcode, rc_count, rc_limit, re_count, re_limit
    33                              <3>  extern reading_access_variables, reg16names, reg8names, reg_cs
    34                              <3>  extern reg_ds, reg_efl, reg_eip, reg_esp, search_results
    35                              <3>  extern serial_columns, serial_fifo_size, serial_keep_timeout
    36                              <3>  extern serial_rows, serial_use_baseport, serial_use_dl
    37                              <3>  extern serial_use_fifo, serial_use_intnum, serial_use_irqmask
    38                              <3>  extern serial_use_params, serial_var_baseport, serial_var_dl
    39                              <3>  extern serial_var_fifo, serial_var_intnum, serial_var_irqmask
    40                              <3>  extern serial_var_params, sscounter, stack, startoptions
    41                              <3>  extern table_length_keywords, throwsp, transfer_ext_cx
    42                              <3>  extern try_amis_multiplex_number, try_debugger_amis_multiplex_number
    43                              <3>  extern types, types.addresses_minus_end, types.end, u_addr
    44                              <3>  extern usertermcode, uu_default_length, uu_default_lines, vregs
    45                              <3>  extern vregs.amount, writing_access_variables
    46                              <3>  extern flagbits, regs
    47                              <3> 
    48                              <3> ; run.asm
    49                              <3>  extern ..@aa_access_end, ..@aa_access_start, ..@dd_access_end
    50                              <3>  extern ..@dd_access_start, ..@ee_access_end, ..@ee_access_start
    51                              <3>  extern ..@ee_interactive_access_end, ..@ee_interactive_access_start
    52                              <3>  extern ..@hh_indirection_memory_access_end
    53                              <3>  extern ..@hh_indirection_memory_access_start
    54                              <3>  extern ..@readmem_fault_skip_4_near_call, ..@rr_access_end
    55                              <3>  extern ..@rr_access_start, ..@rr_variable_read_access_end
    56                              <3>  extern ..@rr_variable_read_access_start
    57                              <3>  extern ..@rr_variable_write_access_end
    58                              <3>  extern ..@rr_variable_write_access_start, ..@sss_access_end
    59                              <3>  extern ..@sss_access_start, ..@uu_access_end, ..@uu_access_start
    60                              <3>  extern ..@uu_referenced_memory_access_end
    61                              <3>  extern ..@uu_referenced_memory_access_start, ..@uu_simulate_cmps_end
    62                              <3>  extern ..@uu_simulate_cmps_start, ..@uu_simulate_scas_end
    63                              <3>  extern ..@uu_simulate_scas_start, InDOS_or_BIOS_IO, PPLEN_ONLY_STRING
    64                              <3>  extern auxbuff_behind_last_silent
    65                              <3>  extern auxbuff_start_silent, bInDbg, b_bplist.bp, b_bplist.counter
    66                              <3>  extern b_bplist.disabled_mask, b_bplist.idbuffer, b_bplist.used_mask
    67                              <3>  extern b_bplist.when, bb_deferred_message_in_lineout_behind
    68                              <3>  extern bp_display_offset, calcpointbit, cmd2_reset_re, cmd_goto
    69                              <3>  extern debug22.cleartraceflag, decbyte, dmycmd, dumpregs_extended
    70                              <3>  extern enable_rh, entry_to_code_seg, entry_to_code_segsel, eqflag
    71                              <3>  extern eqladdr, exccsip, exception_csip, exception_stack, excloc
    72                              <3>  extern g_bplist.bp, g_bplist.used_count, get_set_id_offset_length
    73                              <3>  extern getc_if_any, getcseipbyte, getint2324, getpsp
    74                              <3>  extern gg_deferred_message, gg_first_cseip_linear
    75                              <3>  extern gg_next_cseip_linear, guard_auxbuff.1_or_2, idle, in_getinput
    76                              <3>  extern int19msg, internalflags6, intr8_counter, lastcmd, msg.again
    77                              <3>  extern msg.alreadytsr, msg.area_aa_access, msg.area_dd_access
    78                              <3>  extern msg.area_ee_access, msg.area_ee_interactive_access
    79                              <3>  extern msg.area_hh_indirection_memory_access, msg.area_rr_access
    80                              <3>  extern msg.area_rr_variable_read_access
    81                              <3>  extern msg.area_rr_variable_write_access, msg.area_run_access
    82                              <3>  extern msg.area_sss_access, msg.area_uu_access
    83                              <3>  extern msg.area_uu_referenced_memory_access
    84                              <3>  extern msg.area_uu_simulate_cmps, msg.area_uu_simulate_scas
    85                              <3>  extern msg.bb_hit.1, msg.bb_hit.2.counter, msg.bb_hitpass_id.after
    86                              <3>  extern msg.bb_hitpass_id.long, msg.bb_hitpass_id.short, msg.bb_pass.1
    87                              <3>  extern msg.cant_bp_linear, msg.cant_bp_linear.address1
    88                              <3>  extern msg.cant_bp_reason, msg.cant_bp_reason0, msg.cant_bp_reason1
    89                              <3>  extern msg.cant_bp_reason2, msg.cant_bp_reason3
    90                              <3>  extern msg.cant_bp_reason3.value, msg.cant_bp_reasonu
    91                              <3>  extern msg.cant_bp_restore, msg.cant_bp_restore.value
    92                              <3>  extern msg.cant_bp_the, msg.cant_bp_type_gg
    93                              <3>  extern msg.cant_bp_type_permanent, msg.cant_bp_type_permanent.index
    94                              <3>  extern msg.cant_bp_type_proceed, msg.cant_bp_write, msg.ctrlc
    95                              <3>  extern msg.empty_message, msg.goto, msg.invalidpsp, msg.list
    96                              <3>  extern msg.list_bp.address1, msg.list_bp.first, msg.list_bp.second
    97                              <3>  extern msg.list_bp.third, msg.list_bp.value, msg.list_bp_csip_16
    98                              <3>  extern msg.list_bp_none, msg.list_bp_not_cseip, msg.notyettsr
    99                              <3>  extern msg.nowattached, msg.nowtsr1, msg.nowtsr2, msg.psphooked
   100                              <3>  extern msg.pspnotfound, msg.remember, msg.selfownedpsp, msg.silent
   101                              <3>  extern msg.warnprefix, msg.while, msg.while_not_true
   102                              <3>  extern msg.while_terminated_after, msg.while_terminated_before
   103                              <3>  extern oldcols, oldcrtp, oldcsrpos, oldmr, options3
   104                              <3>  extern options6, pp_instruction, pp_operand, progexit, progtrm
   105                              <3>  extern rc, reg_eax, reg_es, reg_gs, reg_ss
   106                              <3>  extern run_int, run_sp, run_sp_reserve, savesp, setcseipbyte
   107                              <3>  extern setint2324, setpsp, setpspdbg
   108                              <3>  extern showstring, silence_dump, spadjust, swapscreen
   109                              <3>  extern tmode0, tmode1, tmodes, tmodev, tpg_possible_breakpoint
   110                              <3>  extern tpg_proceed_bp, tt_silent_mode_number, vpage, vrows
   111                              <3>  extern while_buffer, while_buffer.length, writemem
   112                              <3> 
   113                              <3>  extern ..@getcseipbyte_fault_skip_2_near_call
   114                              <3>  extern ..@setcseipbyte_fault_skip_2_near_call
   115                              <3>  extern ..@writemem_fault_skip_4_near_call_a
   116                              <3>  extern ..@writemem_fault_skip_4_near_call_b, int0Cmsg, int0Dmsg
   117                              <3>  extern int0msg, int18msg, int1msg, int3msg, int6msg
   118                              <3>  extern int8_kbd_msg, int8msg, runint_ctrlc_msg, serial_flags
   119                              <3> 
   120                              <3> ; bb.asm
   121                              <3>  extern ..@bb_id_length, ..@bb_id_start, ..@bb_saved_linear
   122                              <3>  extern ..@bb_when_length, ..@bb_when_start, b_bplist.id
   123                              <3>  extern b_bplist.idbuffer.free
   124                              <3>  extern b_bplist.whenbuffer, b_bplist.whenbuffer.free
   125                              <3>  extern bootcmd, crlf, msg.all, msg.at
   126                              <3>  extern msg.bb_no_new, msg.bb_when, msg.boot, msg.bp, msg.bpaddress
   127                              <3>  extern msg.bpcontent, msg.bpcounter, msg.bpdisabled, msg.bpenabled
   128                              <3>  extern msg.bpnone, msg.bpnone_at, msg.bpunused, msg.counter
   129                              <3>  extern msg.existing, msg.id, msg.new, msg.notbu, msg.number
   130                              <3>  extern msg.offset, msg.when, prnquit
   131                              <3> 
   132                              <3> ; rr.asm
   133                              <3>  extern InDOS_or_BIOS_output, cmdline_buffer
   134                              <3>  extern cmdline_buffer.end, cmdline_buffer.position, disflags, ee0a
   135                              <3>  extern error_expr, flagbits_for_40, flagbits_for_80, flagsoff
   136                              <3>  extern flagsoff_style2, flagsoff_style3, flagson, flagson_style23
   137                              <3>  extern get_memref_index_bx, getline00, getline_reset_notatty
   138                              <3>  extern guard_rc, hexnyb.common, hhtype, hhvar, in_re
   139                              <3>  extern mask_4byte, masks, memrefs, memrefs.free, msg.3byte
   140                              <3>  extern msg.abort, msg.append, msg.byte, msg.count, msg.dword
   141                              <3>  extern msg.highlight, msg.internal_error_no_mmx, msg.readonly
   142                              <3>  extern msg.readonly_mem, msg.regs386, msg.regs386_off, msg.regs386_on
   143                              <3>  extern msg.replace, msg.rh, msg.rv_mode.before, msg.rv_mode_r86m
   144                              <3>  extern msg.rv_mode_v86m, msg.rvd, msg.rvd_deviceheader
   145                              <3>  extern msg.rvd_not_device, msg.rvd_size, msg.rvm, msg.rvp
   146                              <3>  extern msg.rvp_application, msg.rvp_boot, msg.rvp_device
   147                              <3>  extern msg.rvp_device_attached, msg.rvp_tsr, msg.rvv
   148                              <3>  extern msg.unexpected_auxbuff_guard, msg.unhighlight, msg.vm_auxseg
   149                              <3>  extern msg.vm_codeseg, msg.vm_dataseg, msg.vm_entryseg, msg.vm_hisseg
   150                              <3>  extern msg.vm_messageseg, msg.vp_dparent, msg.vp_dpra
   151                              <3>  extern msg.vp_dpspsegment, msg.vp_parent, msg.vp_pra
   152                              <3>  extern msg.vp_pspsegment, msg.word, operatorfunctions, psp_parent
   153                              <3>  extern psp_pra, puts_break_line_more, putsline_break_line, re_buffer
   154                              <3>  extern re_buffer.end, re_buffer.position, re_sp, regs_prior
   155                              <3>  extern regs_prior.size, retn_expr, rh_count_number
   156                              <3>  extern rh_display_with_count, shortflagbits, shortflagbits.amount
   157                              <3>  extern shortflagsoff, shortflagson, silence_dump.rh
   158                              <3>  extern silence_dump.rh.all, table_getline_prepare_ldebug
   159                              <3>  extern table_getline_prepare_ms_debug, terminate_silent_dump
   160                              <3>  extern terminate_silent_dump.if_nonnull
   161                              <3> 
   162                              <3> ; rr.asm
   163                              <3>  extern flagbits_for_shl, regs_prior.size_w
   164                              <3> 
   165                              <3> ; aa.asm
   166                              <3>  extern REP_LEN, SEGP_LEN, attach
   167                              <3>  extern ext_aa_after_getline_handler, ext_aa_before_getline_handler
   168                              <3>  extern ext_aa_inject_handler, immasm_length, immasm_rel1632_target
   169                              <3>  extern immasm_rel8_target, msg.aa_internal_error, msg.attach
   170                              <3>  extern prefixlist.after_segment, replist, segprfxtab, showmach
   171                              <3>  extern skipalpha, sm1
   172                              <3> 
   173                              <3> ; uu.asm
   174                              <3>  extern A32P_LEN, GROUP7, MN_DB, MN_LOCK, MN_LOOP
   175                              <3>  extern MN_LOOPNZ, MN_LOOPZ, MN_REP, MN_REPE, MN_REPNE
   176                              <3>  extern MN_SEG, MN_WAIT, N_LOCK, N_LTABA, N_LTABO
   177                              <3>  extern N_WTAB, O32P_AMOUNT, OPTYPES_BASE, REP_DIFF_LEN, REP_SAME_LEN
   178                              <3>  extern SFPGROUP3, SGROUP4, SPARSE_BASE, a32prfxtab, dismach
   179                              <3>  extern dmflags, has_87, immasm_far_target, immasm_imm16, locktab
   180                              <3>  extern ltaba1, ltabo1, mach_87, mnlist, mnlist_a_suffix_allowed
   181                              <3>  extern mnlist_o_suffix_allowed, mnlist_o_suffix_required
   182                              <3>  extern msg.condjump, msg.condnotjump, msg.memrefs_invalid_internal
   183                              <3>  extern msg.uninstall, msg.uu_internal_error, msg.uu_too_many_repeat
   184                              <3>  extern needsmath, needsmath_L, needsmsg, needsmsg.digit_6_ofs
   185                              <3>  extern needsmsg.digit_x_ofs, needsmsg_L, o32prfxtab, obsmach
   186                              <3>  extern obsolete, obsolete_L, opindex, opinfo, oplists
   187                              <3>  extern optypes, ppbytes.string, ppbytes.string_amount, reg_ebp
   188                              <3>  extern reg_ebx, reg_ecx, reg_edi, reg_esi, reg_fs
   189                              <3>  extern regmem, rgnam16, rgnam816, segrgnam, sibbyte
   190                              <3>  extern sqztab, tab_to, uninstall, unused, wtab1
   191                              <3> 
   192                              <3> ; uu.asm
   193                              <3>  extern reg_edx
   194                              <3> 
   195                              <3> ; uu.asm
   196                              <3>  extern MN_BSWAP, MN_O32
   197                              <3> 
   198                              <3> ; uu.asm
   199                              <3>  extern MN_A32
   200                              <3> 
   201                              <3> ; amis.asm
   202                              <3>  extern amisintr_offset, deviceshim_size, ext_amis_handler
   203                              <3> 
   204                              <3> ; boot.asm
   205                              <3>  extern boot_remember_seek_handle
   206                              <3>  extern boot_remember_seek_offset, chkeol_or_then, cmd_goto.yy_entry
   207                              <3>  extern display_y_or_ext, ext_cmdline, ext_finish.boot
   208                              <3>  extern if_exists_found_open, if_exists_not_found
   209                              <3>  extern if_exists_then_address, iseol?_or_then, loadoptiontable
   210                              <3>  extern loadoptiontable.incompatible, loadsettings
   211                              <3>  extern msdos7_message_table, msdos7_message_table.size
   212                              <3>  extern msg.boot_access_error, msg.boot_and, msg.boot_auxbuff_crossing
   213                              <3>  extern msg.boot_badchain, msg.boot_badclusters, msg.boot_badfat
   214                              <3>  extern msg.boot_bpb_load_overlap, msg.boot_bpb_too_low
   215                              <3>  extern msg.boot_cannot_set_both, msg.boot_dot_crlf
   216                              <3>  extern msg.boot_file_not_found, msg.boot_file_too_big_error
   217                              <3>  extern msg.boot_file_too_small_error, msg.boot_internal_error
   218                              <3>  extern msg.boot_invalid_filename, msg.boot_invalid_heads
   219                              <3>  extern msg.boot_invalid_sectors, msg.boot_out_of_memory_error
   220                              <3>  extern msg.boot_partition_cycle_error, msg.boot_partition_not_found
   221                              <3>  extern msg.boot_quit_fail, msg.boot_sector_not_power
   222                              <3>  extern msg.boot_sector_too_large, msg.boot_sector_too_small
   223                              <3>  extern msg.boot_segment_too_low, msg.boot_too_many_partitions_error
   224                              <3>  extern msg.bootfail, msg.bootfail_check_mismatch
   225                              <3>  extern msg.bootfail_check_mismatch.check_got
   226                              <3>  extern msg.bootfail_check_mismatch.check_offset
   227                              <3>  extern msg.bootfail_check_mismatch.check_value, msg.bootfail_code
   228                              <3>  extern msg.bootfail_read, msg.bootfail_read_errorcode
   229                              <3>  extern msg.bootfail_secsizediffer, msg.bootfail_sig
   230                              <3>  extern msg.bootfail_sig_parttable, msg.bootfail_stack_underflow
   231                              <3>  extern msg.bpb, msg.checkoffset, msg.checkvalue, msg.dir
   232                              <3>  extern msg.dirinsteadsize, msg.emptydirname, msg.entry
   233                              <3>  extern msg.guard_auxbuff_error, msg.hidden, msg.hiddenadd
   234                              <3>  extern msg.maxpara, msg.minpara, msg.protocol, msg.quit, msg.read
   235                              <3>  extern msg.sector, msg.sector_alt, msg.segment, msg.write
   236                              <3>  extern msg.yy_empty, msg.yy_filename_empty, msg.yy_no_file
   237                              <3>  extern msg.yy_requires_filename, msg.yy_too_large
   238                              <3>  extern msg.yy_too_many_handles, terminator_in_line_in.offset
   239                              <3>  extern terminator_in_line_in.value, throwret
   240                              <3>  extern yy_boot_attempt_open_pathname, yy_boot_attempt_open_stack
   241                              <3>  extern yy_is_script
   242                              <3> 
   243                              <3> ; cc.asm
   244                              <3>  extern count_var, hh.single, msg.clear, msg.clear_sequence
   245                              <3>  extern msg.range, parsecm
   246                              <3> 
   247                              <3> ; dd.asm
   248                              <3>  extern auxbuff_current_size_minus_24, charcounter
   249                              <3>  extern dstringaddr, dstringtype, firstmcb, firstumcb, intaddress
   250                              <3>  extern lastint, lastint_is_86m_and_mcb, msg.di_empty, msg.di_error
   251                              <3>  extern msg.di_freedos_reloc, msg.di_hidden, msg.di_hma, msg.di_iisp
   252                              <3>  extern msg.di_jmpfar, msg.di_jmpfarindirect, msg.di_multiplex.1
   253                              <3>  extern msg.di_multiplex.2, msg.di_multiplex.3, msg.di_nonstd_iisp
   254                              <3>  extern msg.di_system_low, msg.di_system_mcb, msg.di_system_upper
   255                              <3>  extern msg.di_testhook, msg.di_toomany, msg.di_uninst_iisp
   256                              <3>  extern msg.header, msg.header.length, msg.invmcbadr, msg.prefixes
   257                              <3>  extern msg.tableheader, msg.tableheadertop, msg.top, msg.trailer
   258                              <3>  extern msg.trailer.length, smcbmsg_unknown, smcbtypes
   259                              <3> 
   260                              <3> ; debug.asm
   261                              <3>  extern UnhookInterruptForce, UnhookInterruptForceSim, aa
   262                              <3>  extern adusetup, bb, boot_ebdaflag, boot_initcode
   263                              <3>  extern boot_new_memsizekib, boot_old_memsizekib, cc, code_start, ddd
   264                              <3>  extern device_initcode, driveno, dumpregs_extended.exit, ee
   265                              <3>  extern eld_linkcall.call_cmd3, end_of_ldebug_code, entry_int3_retf
   266                              <3>  extern errcarat, ff, get_86m_interrupt_handler_no_dos, get_columns
   267                              <3>  extern getline_close_file, getline_close_file.resetstuff, gg, hh
   268                              <3>  extern hh_depth, hh_depth_of_single_term, hhflag, ia_restore, ii
   269                              <3>  extern immasm, install_86m_interrupt_handler, int22, int2D, intr0
   270                              <3>  extern intr0C, intr0D, intr1, intr18, intr19
   271                              <3>  extern intr3, intr6, intr8, linkinfo, ll
   272                              <3>  extern ll3, ll_copy_cmdline_and_fcbs
   273                              <3>  extern ll_copy_cmdline_and_fcbs.have_cx
   274                              <3>  extern mm, msg.NULblank, msg.asmoptions_1, msg.boothelp
   275                              <3>  extern msg.build_array, msg.build_long_amount, msg.build_short_amount
   276                              <3>  extern msg.build_version_amount, msg.cannot_hook_2D.invalid
   277                              <3>  extern msg.cannot_hook_2D.nofree, msg.cannotbootquit_memsizes
   278                              <3>  extern msg.condhelp, msg.ensure_no_memory, msg.expressionhelp
   279                              <3>  extern msg.flaghelp, msg.flags_1, msg.guard_rc_error
   280                              <3>  extern msg.guard_re_error, msg.help_array, msg.help_array_amount
   281                              <3>  extern msg.help_re, msg.help_run, msg.help_source, msg.keep
   282                              <3>  extern msg.license, msg.line_out_overflow, msg.n_toolongname
   283                              <3>  extern msg.n_toolongtail, msg.nobootsupp, msg.options_array
   284                              <3>  extern msg.options_array_amount, msg.options_pages, msg.options_scan
   285                              <3>  extern msg.options_scan_amount, msg.qq_a_terminated
   286                              <3>  extern msg.qq_a_unterminated, msg.qq_device_no_c, msg.qq_device_no_d
   287                              <3>  extern msg.qq_device_none_selected, msg.qq_unterm
   288                              <3>  extern msg.rc_limit_reached, msg.re, msg.re_limit_reached
   289                              <3>  extern msg.reghelp, msg.rh_disabled, msg.rh_enabled, msg.run
   290                              <3>  extern msg.serial_cannot_hook, msg.serial_cannot_hook.new_int
   291                              <3>  extern msg.serial_cannot_hook.old_int, msg.serial_cannot_unhook
   292                              <3>  extern msg.serial_cannot_unhook.int, msg.serial_cannot_unhook.nowarn
   293                              <3>  extern msg.serial_late_unhook, msg.serial_late_unhook.int
   294                              <3>  extern msg.serial_no_keep_enter, msg.serial_no_keep_timer
   295                              <3>  extern msg.serial_request_keep, msg.source, msg.string_build
   296                              <3>  extern msg.string_options, msg.string_version
   297                              <3>  extern msg.tsr_cannot_terminate_attached, msg.varhelp, oo, ph_msg, pp
   298                              <3>  extern putrunint, putsz_exthelp, rr, run, section.DEVICESHIM.vstart
   299                              <3>  extern serial_clean_up, serial_clear_fifos, serial_eoi
   300                              <3>  extern serial_init_UART, serial_install_interrupt_handler
   301                              <3>  extern serial_interrupt_handler, serial_uninstall_interrupt_handler
   302                              <3>  extern set_irq, setscreen, sleep_delta_limit, sleep_highest_delta
   303                              <3>  extern sss, tpg_initialise_empty_auxbuff.reset
   304                              <3>  extern transfer_to_ext_puts_getline, tt, update_inttab_optional, uu
   305                              <3>  extern vv, vv_disable, vv_set, ww, yy
   306                              <3> 
   307                              <3> ; debug.asm
   308                              <3>  extern eld_linkcall
   309                              <3> 
   310                              <3> ; ee.asm
   311                              <3>  extern bufend, bufnext, fillbuf, fullbsout
   312                              <3>  extern getline_is_input_file?, line_in, linecounter, load_extension
   313                              <3>  extern msg.ext, notatty, prehak1, run2324
   314                              <3> 
   315                              <3> ; hh.asm
   316                              <3>  extern hh_div_active, hh_div_dividend, hh_div_divisor
   317                              <3>  extern msg.base, msg.group, msg.hh_div_remainder, msg.width
   318                              <3> 
   319                              <3> ; iioo.asm
   320                              <3>  extern if_exists_length, if_exists_si, if_exists_sp
   321                              <3>  extern install, msg.exists, msg.install, msg.not, msg.then
   322                              <3>  extern msg.y, resetrc, yy_or_ext_no_guard_re
   323                              <3> 
   324                              <3> ; immasm.asm
   325                              <3>  extern aa_ret, addrr, condmsg, error_mirror, index
   326                              <3>  extern msg.immasm_error_eip, presizeflags, reg32addr, segmnt
   327                              <3>  extern segrgaddr
   328                              <3> 
   329                              <3> ; msg.asm
   330                              <3>  extern ..@boot_scan_dir_return_fat16_root_entry
   331                              <3>  extern ..@boot_scan_dir_return_filenotfound
   332                              <3>  extern ..@boot_scan_dir_return_subdir_or_fat32_entry
   333                              <3>  extern alloc_size_not_reserved, asciitablenames, boot_init_foundname
   334                              <3>  extern configpath, configpath.dir_end, device_quittable_regs, dpmi32
   335                              <3>  extern execblk.cmdline, ext_command_handler, ext_finish.bp_is_set
   336                              <3>  extern ext_handle, ext_inject_handler, ext_preprocess_handler
   337                              <3>  extern ext_puts_copyoutput_handler, ext_puts_getline_handler
   338                              <3>  extern ext_puts_handler, ext_var, ext_var_amount, ext_var_format
   339                              <3>  extern ext_var_size, extcssel, extdssel, handle_scan_dir_entry
   340                              <3>  extern handle_scan_dir_not_found, history.first, history.last
   341                              <3>  extern indirect_array_errfix, init_executable_pathname
   342                              <3>  extern init_executable_pathname.end, internalflags4, internalflags5
   343                              <3>  extern internalflags7, isvariable_morebyte_nameheaders.ext
   344                              <3>  extern lastcmd_transfer_ext_address, lastcmd_transfer_ext_entry
   345                              <3>  extern line_in.end, linkcall_table, load_adr_dirbuf_segment
   346                              <3>  extern load_check_dir_attr, load_data_lowest, load_kernel_name
   347                              <3>  extern load_yy_direntry, load_yyname_input, load_yyname_next
   348                              <3>  extern near_transfer_ext_address, near_transfer_ext_entry
   349                              <3>  extern next_reserved_segment, options4, options5, options7
   350                              <3>  extern patcharea_intrtn, patcharea_intrtn.segment
   351                              <3>  extern patcharea_intrtn.size, patcharea_run, patcharea_run.segment
   352                              <3>  extern patcharea_run.size, pm_2_86m_0, promptlen, reserved_address
   353                              <3>  extern scriptspath, scriptspath.dir_end
   354                              <3>  extern sss_silent_count, sss_silent_count_used, stack_end, swch1
   355                              <3>  extern while_buffer.end
   356                              <3> 
   357                              <3> ; msg.asm
   358                              <3>  extern install_trying
   359                              <3> 
   360                              <3> ; init.asm
   361                              <3>  extern ..@init_behind, ..@init_first
   362                              <3>  extern ..@patch_no386_ds_6_DATA_ENTRY
   363                              <3>  extern ..@patch_no386_ds_code_or_entry
   364                              <3>  extern ..@patch_no386_iret_code_or_entry, behind_code_truncated
   365                              <3>  extern behind_init, behind_messagesegment_nobits
   366                              <3>  extern behind_messagesegment_nobits_truncated, debug22
   367                              <3>  extern device_header.next, devint23, devint24, entry_retf
   368                              <3>  extern execblk.fcb1, execblk.fcb2, ext_data_area, extcall_table.ret
   369                              <3>  extern extcall_table.segsel, fileext, hVdd, immasm_buffer, initcont
   370                              <3>  extern initcont.boot_entry, initcont.device, inttab, inttab.i06
   371                              <3>  extern inttab.i2D, inttab_number_variable, line_out_overflow
   372                              <3>  extern linkcall_table.code1, linkcall_table.entry
   373                              <3>  extern linkcall_table.init, oldmode, pInDOS, pSDA, regs.size
   374                              <3>  extern switchar, trim_overflow, var_addr_entries
   375                              <3>  extern var_addr_entries.amount
   376                              <3> 
   377                              <3> ; install.asm
   378                              <3>  extern installflags, msg.alreadydisabled
   379                              <3>  extern msg.alreadyenabled, msg.toggle, msg.trydisable, msg.tryenable
   380                              <3> 
   381                              <3> ; ints.asm
   382                              <3>  extern debuggeramissig, inttab_optional
   383                              <3> 
   384                              <3> ; lineio.asm
   385                              <3>  extern auxbuff_amount_silent, cmd3_set_options
   386                              <3>  extern determine_quiet_output, eldheader, getc_repeat_idle
   387                              <3>  extern getline_timer_func, handle_ctrl_c, if_exists_found_closed
   388                              <3>  extern if_exists_found_ext_open, indos_remember_seek_function
   389                              <3>  extern indos_remember_seek_handle, indos_remember_seek_offset
   390                              <3>  extern input_file_handles.to_close, msg.configkeyword
   391                              <3>  extern msg.eld_error_code, msg.eld_load_error, msg.emptykeyword
   392                              <3>  extern msg.eof, msg.executablekeyword, msg.ext_error_internal
   393                              <3>  extern msg.ext_error_invalid, msg.ext_error_io, msg.ext_error_oom
   394                              <3>  extern msg.freedos_ctrlc_workaround, msg.goto_empty
   395                              <3>  extern msg.goto_not_file, msg.goto_not_found.1, msg.goto_not_found.2
   396                              <3>  extern msg.history_internal_error, msg.more, msg.more_over
   397                              <3>  extern msg.more_over_size, msg.more_size, msg.rh_step.1
   398                              <3>  extern msg.rh_step.2, msg.scriptskeyword, msg.silent_error, msg.sof
   399                              <3>  extern msg.unexpected_noneol_rc, msg.unexpected_noneol_re
   400                              <3>  extern msg.yy_error_file_open, msg.yy_filename_missing_unquote
   401                              <3>  extern msg.yy_no_dos, qq, section.DATASTACK.vstart
   402                              <3>  extern serial_check_receive_char, serial_receive_char
   403                              <3>  extern serial_send_char, skip_rh, yy_boot
   404                              <3>  extern yy_boot_clear_remember_seek, yy_boot_close_file, yy_boot_read
   405                              <3>  extern yy_boot_remember_seek, yy_boot_seek_current
   406                              <3>  extern yy_boot_seek_start, yy_try_scriptspath
   407                              <3>  extern yy_try_scriptspath.didnotyettry
   408                              <3>  extern yy_try_scriptspath.nokeywordused
   409                              <3> 
   410                              <3> ; ll.asm
   411                              <3>  extern doserr8, ensuredebuggeeloaded, execblk, execblk.csip
   412                              <3>  extern execblk.sssp, msg.hexerror, msg.ll_unterm, msg.not_while_indos
   413                              <3>  extern msg.tsr_cannot_ll, parselw, reading
   414                              <3>  extern terminate_attached_process, ww1, ww15, zeroregs
   415                              <3> 
   416                              <3> ; mm.asm
   417                              <3>  extern has_287, has_copr, msg.c0, msg.cr, msg8088
   418                              <3>  extern msgx86, no_copr, parsecm_have_address
   419                              <3> 
   420                              <3> ; serialp.asm
   421                              <3>  extern baseport, msg.no_progress, rxfifo, rxhead
   422                              <3>  extern rxtail, serial_fcr_setting, serial_installed_intnum
   423                              <3>  extern serial_save_dl, serial_save_ier, serial_save_irq_mask
   424                              <3>  extern serial_save_irq_off, serial_save_lcr, serial_save_mcr, txfifo
   425                              <3>  extern txhead, txtail
   426                              <3> 
   427                              <3> ; ss.asm
   428                              <3>  extern msg.matches, msg.reverse, msg.seconds, msg.sleep
   429                              <3>  extern msg.ticks, sleep_repeat_idle
   430                              <3> 
   431                              <3> ; vv.asm
   432                              <3>  extern csrpos, msg.nokeep, msg.off, msg.on, msg.vv_disabled
   433                              <3>  extern msg.vv_enable_failure, xmsdrv, xmsmove
   434                              <3> 
   435                              <3> ; ww.asm
   436                              <3>  extern diskful, doserr11, doserr2, doserr3, doserr5
   437                              <3>  extern drive, drivenumber, dskerrs, not_while_indos, nowhexe
   438                              <3>  extern nownull, openerr, openerr1, writing, wwmsg1
   439                              <3>  extern wwmsg2
   440                              <3> 
   441                              <3> 
   442                              <3>  extern bCSAttr, lDEBUG_CODE_to_lDEBUG_CODE2_nearcall_helper
   443                              <3> 
   444                              <3>  extern hook2F.not_in_dos
   445                              <3> 
   446                              <3>  extern cmd4.int3, lDEBUG_CODE2_dualret_helper
   447                              <3>  extern lDEBUG_CODE2_to_lDEBUG_CODE_nearcall_helper
   448                              <3>  extern lDEBUG_CODE_to_lDEBUG_CODE2_dualcall_helper, msg.bu
   449                              <3>  extern msg.bu_relocated, msg.bu_relocated.sign
   450                              <3> 
   451                              <3>  extern nopmsupp
   452                              <3> 
   453                              <3>  extern bAddr32
   454                              <3> 
   455                              <3>  extern descriptor, descriptor.attrib, descriptor.base
   456                              <3>  extern descriptor.limit, gatewrong, msg.d.a_error, msg.d.a_error_code
   457                              <3>  extern msg.d.a_success, msg.d.a_success_sel, msg.d.b_error
   458                              <3>  extern msg.d.b_error_code, msg.d.b_success, msg.d.d_error
   459                              <3>  extern msg.d.d_error_code, msg.d.d_success, msg.d.l_error
   460                              <3>  extern msg.d.l_error_code, msg.d.l_success, msg.d.t_error
   461                              <3>  extern msg.d.t_error_code, msg.d.t_success, msg.deschelp, msg.ofs32
   462                              <3>  extern nodesc
   463                              <3> 
   464                              <3>  extern ..@patch_tsr_quit_run, areastruc_entry.qq_entry, cssel
   465                              <3>  extern ddebugareas.next, debug2F, dpmidisable, dpmientry, dpmihook
   466                              <3>  extern dpmihookamis, dpmihookcs, dpmiwatch, end_of_ldebug_code2
   467                              <3>  extern findinstalleddebugger, get_messagesegsel, handle_mode_changed
   468                              <3>  extern i23pm, msg.cannotpmquit, msg.desc, msg.dpmi_no_hook, msg.msdos
   469                              <3>  extern msg.qq_device_pm, msg.qq_still_pm, msg.qqlate_areas_error
   470                              <3>  extern msg.readonly_verifysegm, msg.readonly_verifysegm.selector
   471                              <3>  extern mydpmientry, nodosext, oldi2F, pm_reset_handlers, scratchsel
   472                              <3>  extern sr_state, switchmode, uninstall_areas.qq_entry
   473                              <3> 
   474                              <3>  extern i24pm
   475                              <3> 
   476                              <3>  extern auxbuff_switchbuffer_size, code2_seg, code2_sel, code2_size
   477                              <3>  extern code_sel, daresult, dssel, immsel
   478                              <3>  extern lDEBUG_CODE2_to_lDEBUG_CODE_dualcall_helper
   479                              <3>  extern lDEBUG_CODE_dualret_helper, messagesel, msg.desctype
   480                              <3>  extern msg.stack_overflow.desctype
   481                              <3> 
   482                              <3>  extern cmd3_mirror
   483                              <3> 
   484                              <3>  extern ..@patch_entry_seg, ..@patch_no386_ds_4, ..@patch_no386_ds_5
   485                              <3>  extern ..@patch_no386_ds_entry_pmint21_1
   486                              <3>  extern ..@patch_no386_ds_entry_pmint21_2, areas_fun, areas_sub
   487                              <3>  extern ddebugareas.prev, linkcall_table.code2
   488                              <3> 
   489                              <3>  extern areas_struc, msg.areasalreadyinstalled
   490                              <3>  extern msg.areasalreadyuninstalled, msg.areasinstalled
   491                              <3>  extern msg.areasnodebuggerfound, msg.areasnotinstalled
   492                              <3>  extern msg.areasnotinstalled.code, msg.areasnotsupported
   493                              <3>  extern msg.areasuninstalled, msg.areasuninstalled.code
   494                              <3> 
   495                              <3>  extern intcall_return_parameter_es_parameter_ds
   496                              <3>  extern lDEBUG_CODE_to_lDEBUG_CODE_dualcall_helper, pop_if, push_if
   497                              <3> 
   498                              <3>  extern isextenderavailable, msg.cannotpmload, nodosextinst
   499                              <3> 
   500                              <3>  extern install_areas, patcharea_pm_exc, patcharea_pm_exc.segment
   501                              <3>  extern patcharea_pm_exc.size
   502                              <3> 
   503                              <3>  extern pmint21
   504                              <3> 
   505                              <3>  extern debuggerexception, entry_to_code_sel, exc6msg, excCmsg
   506                              <3>  extern excDmsg, excEmsg, intrtn2_entry, pmintsave.int21
   507                              <3> 
   508                              <3>  extern convsegs, convsegs.amount_fixed, convsegs.end_fixed
   509                              <3>  extern dpmi_pm2rm, dpmi_pmsav, dpmi_rm2pm, dpmi_rmsav, endexctab
   510                              <3>  extern exc_first, exc_second, excsave, exctab, installdpmimsg
   511                              <3>  extern intrtn_entry.from_installdpmi, pmintsave, pminttab
   512                              <3>  extern pminttab.end, setrmaddr, silence_delete_one_string.internal
   513                              <3> 
   514                              <3>  extern msg.rv_mode_dpmi_16, msg.rv_mode_dpmi_32, msg.vm_code2seg
   515                              <3>  extern msg.vm_selector, msg.vp_dpspsel, msg.vp_pspsel, psp_selector
   516                              <3> 
   517                              <3>  extern ..@getcseipbyte_fault_skip_6_near_call
   518                              <3>  extern ..@hh_code1_indirection_memory_access_end
   519                              <3>  extern ..@hh_code1_indirection_memory_access_start
   520                              <3>  extern ..@readmem_fault_skip_2_near_call
   521                              <3>  extern ..@setcseipbyte_fault_skip_6_near_call
   522                              <3>  extern ..@writemem_fault_skip_2_near_call_a
   523                              <3>  extern ..@writemem_fault_skip_2_near_call_b, behind_code
   524                              <3>  extern behind_code2, convsegs.amount, ddebugareas
   525                              <3>  extern getline_extra_int22.cleartraceflag, msg.list_bp_cseip_32
   526                              <3> 
   527                              <3>  extern MN_O16
   528                              <3> 
   529                              <3>  extern MN_A16
   530                              <3> 
   531                              <3>  extern relocatedzero
   532                              <3> 
   533                              <3>  extern msg.bu_disabled
   534                              <3> 
   535                              <3>  extern reset_interrupts, set_interrupts
   536                              <3> 
   537                              <3>  extern startoptions6
   538                              <3> 
   539                              <3>  extern currentposition, msg.loader_bottom_not_allowed
   540                              <3>  extern msg.loader_too_low_load
   541                              <3> 
   542                              <3>  extern intr_loader_18, intr_loader_19, moveloader_hook_ints
   543                              <3> 
   544                              <3>  extern loader_query, loader_transfer_cmd3, loader_transfer_relocate
   545                              <3> 
   546                              <3>  extern cmd3_int_disable.set_bx_to_dx, cmd3_int_enable.set_bx_to_dx
   547                              <3>  extern ldebug_code_size, movesegrefstable, movetable
   548                              <3>  extern movetable.bottom, msg.isalready, msg.isnow, msg.loader_error
   549                              <3>  extern msg.move, msg.move_auxbuff_error, msg.move_auxdown
   550                              <3>  extern msg.move_auxup, msg.move_ebdanottop, msg.move_empty
   551                              <3>  extern msg.move_int_error, msg.move_int_panic
   552                              <3>  extern msg.move_must_be_bottom, msg.move_nottop, msg.move_oom
   553                              <3>  extern msg.move_rpl, msg.move_toolargeebda, msg.unsupportedmove
   554                              <3>  extern qq_int_unhook_sim.set_bx_to_dx
   555                              <3> 
   556                              <3>  extern moveloader.already, moveloader.bottom_to_hidden
   557                              <3>  extern moveloader.bottom_to_top, moveloader.hidden_to_bottom
   558                              <3>  extern moveloader.hidden_to_top, moveloader.top_to_bottom
   559                              <3>  extern moveloader.top_to_hidden
   560                              <3> 
   561                              <3>  extern moveloader.specificerror, moveloader_check_serial, msg.godebug
   562                              <3>  extern msg.loader_extra, msg.loader_flag, msg.loader_loadseg_low
   563                              <3>  extern msg.loader_must_be_hidden, msg.loader_sign, msg.loader_stack
   564                              <3>  extern msg.loadsupportsignature, msg.loadsupportsignature.size
   565                              <3> 
   566                              <3>  extern depack, hshrink_memory_source.offset
   567                              <3>  extern hshrink_memory_source.segment, indirect_hshrink_message_buffer
   568                              <3>  extern msg.hshrink_error, nontruncated_hshrink_message_buffer
   569                              <3> 
   570                              <3>  extern truncated_hshrink_message_buffer
   571                              <3> 
   572                              <3>  extern patch_boothelp_uncompressed
   295                              <2> %endif
   710                              <1> %endif
   711                              <1> [list -]
   714                              <1> 
   715                              <1> %include "eld.mac"
     1                              <2> %if 0
     2                              <2> 
     3                              <2> Extensions for lDebug macros
     4                              <2> 
     5                              <2> Copyright (C) 2008-2025 E. C. Masloch
     6                              <2> 
     7                              <2> Usage of the works is permitted provided that this
     8                              <2> instrument is retained with the works, so that any entity
     9                              <2> that uses the works is notified of this instrument.
    10                              <2> 
    11                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    12                              <2> 
    13                              <2> %endif
    14                              <2> 
    15                              <2> %ifndef ELD_MAC
    16                              <2> %define ELD_MAC 1
    17                              <2> 
    18                              <2> %include "lmacros3.mac"
     1                              <3> [list -]
    19                              <2> 
    20                              <2> 		; ELD executable header
    21                              <2> 	struc ELD_HEADER
    22 00000000 ????????            <2> eldhSignature:		resb 4	; "ELD1"
    23 00000004 ??????              <2> 			resb 3	; reserved
    24 00000007 ??                  <2> 			resb 1	; 26 (Ctrl-Z)
    25 00000008 ????????            <2> eldhCodeOffset:		resd 1	; position displacement from eldhSignature
    26 0000000C ????                <2> eldhCodeImageLength:	resw 1	; amount bytes, at least 32
    27 0000000E ????                <2> eldhCodeAllocLength:	resw 1	; amount bytes, added to prior. sum < 64 KiB
    28 00000010 ????????            <2> eldhDataOffset:		resd 1
    29 00000014 ????                <2> eldhDataImageLength:	resw 1	; (zero allowed)
    30 00000016 ????                <2> eldhDataAllocLength:	resw 1	; (zero allowed)
    31 00000018 ????                <2> eldhCodeEntrypoint:	resw 1	; within code section, used as displacement
    32 0000001A ????????            <2> eldhReserved:		resb 4	; reserved
    33 0000001E ????                <2> eldhExtensionSize:	resw 1	; from eldhSignature, -> past eldhx fields in use
    34                              <2> 	endstruc
    35                              <2> 	endarea ELD_HEADER, 1
    36                              <2> 
    37                              <2> 	struc ELD_HEADERX
    38 00000000 <res 20h>           <2> eldhxHeader:		resb ELD_HEADER_size
    39 00000020 ????????            <2> eldhxDescriptionOffset:	resd 1	; zero if none, from eldhxHeader. <= 128 Bytes
    40 00000024 ????????            <2> eldhxHelpOffset:	resd 1	; zero if none, from eldhxHeader
    41 00000028 ????????            <2> eldhxLibTable:		resd 1	; zero if none, from eldhxHeader
    42 0000002C ????????            <2> eldhxDateTimeOffset:	resd 1	; zero if none, from eldhxHeader
    43                              <2> 	alignb 16
    44                              <2> 	endstruc
    45                              <2> 
    46                              <2> 	struc ELD_TRAILER_HEADER
    47 00000000 ????????????????    <2> eldthSignature:		resb 8	; "ELD1TAIL"
    48 00000008 ????????            <2> eldthHeaderOffset:	resd 1	; negative displacement from eldthSignature,
    49                              <2> 				;  add this dword to the seek offset
    50 0000000C ????                <2> eldthReserved:		resw 1	; reserved, must be initialised to zero
    51 0000000E ????                <2> eldthChecksum:		resw 1	; sum of all words in trailer header = 0
    52                              <2> 	endstruc
    53                              <2> 	endarea ELD_TRAILER_HEADER, 1
    54                              <2> 
    55                              <2> 	struc ELD_LIBTABLE
    56 00000000 ????                <2> eldltFormat:		resw 1
    57                              <2> 	; 0 = uncompressed
    58                              <2> 	; 2 = heatshrink compressed
    59                              <2> 	; 3 = lzexedat -4 compressed
    60                              <2> 	; 4 = lzexedat -4 -l compressed
    61 00000002 ????                <2> eldltAmount:		resw 1
    62 00000004 ????????            <2> eldltOffset:		resd 1	; from eldhxHeader
    63                              <2> eldltCompressedLength:		; (dword, only present if format 2, 3, or 4)
    64                              <2> 	endstruc
    65                              <2> 	endarea ELD_LIBTABLE, 1
    66                              <2> 
    67                              <2> 		; ELD instance header
    68                              <2> 	struc ELD_INSTANCE
    69 00000000 ????                <2> eldiStartCode:		resw 1	; -> this structure itself (para aligned)
    70 00000002 ????                <2> eldiEndCode:		resw 1	; -> behind memory used by instance (para aligned)
    71 00000004 ????                <2> eldiStartData:		resw 1	; -> data in data entry section (para aligned), or 0
    72 00000006 ????                <2> eldiEndData:		resw 1	; -> behind data (para aligned), or 0
    73 00000008 ????????????????    <2> eldiIdentifier:		resb 8	; blank-filled text
    74 00000010 ????                <2> eldiFlags:		resw 1	; flags
    75                              <2> eldiListing_size equ 14
    76 00000012 <res Eh>            <2> eldiListing:		resb eldiListing_size
    77                              <2> 				; ASCIZ listing file name
    78                              <2> 	endstruc
    79                              <2> 		; flags for eldiFlags:
    80                              <2> eldifResident:		equ 1
    81                              <2> 
    82                              <2> 		; ELD link info header
    83                              <2> 	struc ELD_LINKINFO
    84 00000000 ????                <2> eldlSignature:		resw 1	; 0E1D1h
    85 00000002 ????????            <2> eldlReserved:		resw 2
    86 00000006 ????                <2> eldlUseLinkHash:	resw 1
    87 00000008 ????                <2> eldlDataAmount:		resw 1
    88 0000000A ????                <2> eldlDataPrefixes:	resw 1
    89 0000000C ????                <2> eldlDataEntries:	resw 1
    90 0000000E ????                <2> eldlDataAddresses:	resw 1
    91 00000010 ????                <2> eldlCodeAmount:		resw 1
    92 00000012 ????                <2> eldlCodePrefixes:	resw 1
    93 00000014 ????                <2> eldlCodeEntries:	resw 1
    94 00000016 ????                <2> eldlCodeAddresses:	resw 1
    95                              <2> 	endstruc
    96                              <2> 
    97                              <2> 	numdef ELD_CODE_VSTART, 9001h
    98                              <2> 	numdef ELD_DATA_VSTART, 8000h
    99                              <2> 	numdef ELD_RELOC_VSTART, 8000h
   100                              <2> 
   101                              <2> 	numdef ELD_RECLAIM_HINT, 0
   102                              <2> 	strdef ELD_LISTING, ""
   103                              <2> 	numdef ELD_DATETIME, 0
   104                              <2> 
   105                              <2> %if _ELD_DATETIME
   106                              <2>  %define PUT_ELDHX_DATETIME_OFFSET at eldhxDateTimeOffset, dd DATAOFFSET + datetime - datastart
   107                              <2>  %macro PUT_ELD_DATETIME 0.nolist
   108                              <2> datetime:	asciz __UTC_DATE__,'T',__UTC_TIME__,'Z'
   109                              <2> 		asciz		; for future extension
   110                              <2>  %endmacro
   111                              <2> %else
   112                              <2>  %define PUT_ELDHX_DATETIME_OFFSET
   113                              <2>  %define PUT_ELD_DATETIME
   114                              <2> %endif
   115                              <2> 
   116                              <2> %endif
   716                              <1> 
   717                              <1> %include "install.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug INSTALL command macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2023 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 	struc INSTALLFLAG
    17 00000000 ????                <2> ifKeyword:	resw 1
    18 00000002 ????                <2> ifDescription:	resw 1
    19 00000004 ????                <2> ifOptions:	resw 1
    20 00000006 ????                <2> ifValue:	resw 1
    21 00000008 ????                <2> ifTrying:	resw 1
    22 0000000A ????                <2> ifReserved:	resw 1
    23                              <2> 	endstruc
    24                              <2> 
   718                              <1> 
   719                              <1> %if _SYMBOLIC
   720                              <1> 	defaulting 0			; disable defaulting
   721                              <1> %include "symbols.mac"
   722                              <1> [list -]
   723                              <1> 		; symbolic branch defines *without* defaulting!
   724                              <1> 	numdef ZZ_INSERT_TEMP, 1
   725                              <1> 	numdef XMS_SYMBOL_TABLE, 1
   726                              <1> 	numdef BUFFER_86MM_SLICE, 0
   727                              <1> 	numdef SECOND_SLICE, 0
   728                              <1> 
   729                              <1> 	defaulting 1			; re-enable defaulting
   730                              <1> 
   731                              <1> 		; symbolic branch defines
   732                              <1> 	numdef 86MM_SYMBOL_TABLE_MAX, 256, 256
   733                              <1> %endif
   734                              <1> 
   735                              <1> 	struc SEGADR
   736 00000000 ????????            <1> saOffset:	resd 1
   737 00000004 ????                <1> saSegSel:	resw 1
   738                              <1> %if _PM
   739 00000006 ????                <1> saSegment:	resw 1
   740 00000008 ????                <1> saSelector:	resw 1
   741                              <1> %endif
   742                              <1> 	endstruc
   743                              <1> 
   744                              <1> 	%macro segmentedaddress 0.nolist
   745                              <1> 	istruc SEGADR
   746                              <1> 	iend
   747                              <1> 	%endmacro
   748                              <1> 
   749                              <1> 	struc SEGOFS16ADR
   750 00000000 ????                <1> so16aOffset:	resw 1
   751 00000002 ????                <1> so16aSegSel:	resw 1
   752                              <1> %if _PM
   753 00000004 ????                <1> so16aSegment:	resw 1
   754 00000006 ????                <1> so16aSelector:	resw 1
   755                              <1> %endif
   756                              <1> 	endstruc
   757                              <1> 
   758                              <1> 	%macro segofs16address 0-1.nolist zero
   759                              <1> 	istruc SEGOFS16ADR
   760                              <1> %ifidni %1,zero
   761                              <1> %elifidni %1,minusone
   762                              <1> at so16aOffset,		dw -1
   763                              <1> at so16aSegSel,		dw -1
   764                              <1>  %if _PM
   765                              <1> at so16aSegment,	dw -1
   766                              <1> at so16aSelector,	dw -1
   767                              <1>  %endif
   768                              <1> %else
   769                              <1>  %error Unexpected initialiser keyword
   770                              <1> %endif
   771                              <1> 	iend
   772                              <1> 	%endmacro
   773                              <1> 
   774                              <1> 	struc SEGONLYADR
   775 00000000 ????                <1> soaSegSel:	resw 1
   776                              <1> %if _PM
   777 00000002 ????                <1> soaSegment:	resw 1
   778 00000004 ????                <1> soaSelector:	resw 1
   779                              <1> %endif
   780                              <1> 	endstruc
   781                              <1> 
   782                              <1> 	%macro segonlyaddress 0.nolist
   783                              <1> 	istruc SEGONLYADR
   784                              <1> 	iend
   785                              <1> 	%endmacro
   786                              <1> 
   787                              <1> 
   788                              <1> %if _LOADER
   789                              <1> 	struc MOVETABLEENTRY
   790                              <1> mteIdentifier:		resw 1
   791                              <1> mteArrayIndex:		resw 1
   792                              <1> mteStatusMessage:	resw 1
   793                              <1> mteFromArray:
   794                              <1> mteFromBottom:		resw 1
   795                              <1> mteFromTop:		resw 1
   796                              <1> mteFromHidden:		resw 1
   797                              <1> 	endstruc
   798                              <1> %endif
   799                              <1> 
   800                              <1> %if _BOOTLDR
   801                              <1>  %include "iniload.mac"
     1                              <2> %if 0
     2                              <2> 
     3                              <2> lDebug iniload/boot interfacing structs and macros
     4                              <2> 
     5                              <2> Copyright (C) 2008-2025 E. C. Masloch
     6                              <2> 
     7                              <2> Usage of the works is permitted provided that this
     8                              <2> instrument is retained with the works, so that any entity
     9                              <2> that uses the works is notified of this instrument.
    10                              <2> 
    11                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    12                              <2> 
    13                              <2> %endif
    14                              <2> 
    15                              <2> 
    16                              <2> 	struc BS
    17 00000000 ??????              <2> bsJump:	resb 3
    18 00000003 ????????????????    <2> bsOEM:	resb 8
    19                              <2> bsBPB:
    20                              <2> 	endstruc
    21                              <2> 
    22                              <2> 	struc EBPB		;        BPB sec
    23 00000000 ????                <2> bpbBytesPerSector:	resw 1	; offset 00h 0Bh
    24 00000002 ??                  <2> bpbSectorsPerCluster:	resb 1	; offset 02h 0Dh
    25 00000003 ????                <2> bpbReservedSectors:	resw 1	; offset 03h 0Eh
    26 00000005 ??                  <2> bpbNumFATs:		resb 1	; offset 05h 10h
    27 00000006 ????                <2> bpbNumRootDirEnts:	resw 1	; offset 06h 11h -- 0 for FAT32
    28 00000008 ????                <2> bpbTotalSectors:	resw 1	; offset 08h 13h
    29 0000000A ??                  <2> bpbMediaID:		resb 1	; offset 0Ah 15h
    30 0000000B ????                <2> bpbSectorsPerFAT:	resw 1	; offset 0Bh 16h -- 0 for FAT32
    31 0000000D ????                <2> bpbCHSSectors:		resw 1	; offset 0Dh 18h
    32 0000000F ????                <2> bpbCHSHeads:		resw 1	; offset 0Fh 1Ah
    33 00000011 ????????            <2> bpbHiddenSectors:	resd 1	; offset 11h 1Ch
    34 00000015 ????????            <2> bpbTotalSectorsLarge:	resd 1	; offset 15h 20h
    35                              <2> bpbNew:				; offset 19h 24h
    36                              <2> 
    37 00000019 ????????            <2> ebpbSectorsPerFATLarge:	resd 1	; offset 19h 24h
    38 0000001D ????                <2> ebpbFSFlags:		resw 1	; offset 1Dh 28h
    39 0000001F ????                <2> ebpbFSVersion:		resw 1	; offset 1Fh 2Ah
    40 00000021 ????????            <2> ebpbRootCluster:	resd 1	; offset 21h 2Ch
    41 00000025 ????                <2> ebpbFSINFOSector:	resw 1	; offset 25h 30h
    42 00000027 ????                <2> ebpbBackupSector:	resw 1	; offset 27h 32h
    43 00000029 <res Ch>            <2> ebpbReserved:		resb 12	; offset 29h 34h
    44                              <2> ebpbNew:			; offset 35h 40h
    45                              <2> 	endstruc
    46                              <2> 
    47                              <2> 	struc BPBN		; ofs B16 S16 B32 S32
    48 00000000 ??                  <2> bpbnBootUnit:		resb 1	; 00h 19h 24h 35h 40h
    49 00000001 ??                  <2> 			resb 1	; 01h 1Ah 25h 36h 41h
    50 00000002 ??                  <2> bpbnExtBPBSignature:	resb 1	; 02h 1Bh 26h 37h 42h -- 29h for valid BPBN
    51 00000003 ????????            <2> bpbnSerialNumber:	resd 1	; 03h 1Ch 27h 38h 43h
    52 00000007 <res Bh>            <2> bpbnVolumeLabel:	resb 11	; 07h 20h 2Bh 3Ch 47h
    53 00000012 ????????????????    <2> bpbnFilesystemID:	resb 8	; 12h 2Bh 36h 47h 52h
    54                              <2> 	endstruc		; 1Ah 33h 3Eh 4Fh 5Ah
    55                              <2> 
    56                              <2> 	struc DIRENTRY
    57 00000000 ????????????????    <2> deName:		resb 8
    58 00000008 ??????              <2> deExt:		resb 3
    59 0000000B ??                  <2> deAttrib:	resb 1
    60 0000000C ??                  <2> dePlusSize:	resb 1
    61 0000000D ??????????????      <2> 		resb 7
    62 00000014 ????                <2> deClusterHigh:	resw 1
    63 00000016 ????                <2> deTime:		resw 1
    64 00000018 ????                <2> deDate:		resw 1
    65 0000001A ????                <2> deClusterLow:	resw 1
    66 0000001C ????????            <2> deSize:		resd 1
    67                              <2> 	endstruc
    68                              <2> 
    69                              <2> ATTR_READONLY	equ 1
    70                              <2> ATTR_HIDDEN	equ 2
    71                              <2> ATTR_SYSTEM	equ 4
    72                              <2> ATTR_VOLLABEL	equ 8
    73                              <2> ATTR_DIRECTORY	equ 10h
    74                              <2> ATTR_ARCHIVE	equ 20h
    75                              <2> 
    76                              <2> lsvclSignature		equ "CL"
    77                              <2> lsvclBufferLength	equ 256
    78                              <2> 
    79                              <2> 	struc LOADSTACKVARS, -10h
    80 FFFFFFF0 ????????            <2> lsvFirstCluster:	resd 1
    81 FFFFFFF4 ????????            <2> lsvFATSector:		resd 1
    82 FFFFFFF8 ????                <2> lsvFATSeg:		resw 1
    83 FFFFFFFA ????                <2> lsvLoadSeg:		resw 1
    84 FFFFFFFC ????????            <2> lsvDataStart:		resd 1
    85                              <2> 	endstruc
    86                              <2> 
    87                              <2> 	struc LOADDATA, LOADSTACKVARS - 10h
    88 FFFFFFE0 ????                <2> ldMemoryTop:	resw 1
    89 FFFFFFE2 ????                <2> ldLoadTop:	resw 1
    90 FFFFFFE4 ????                <2> ldSectorSeg:	resw 1
    91 FFFFFFE6 ??                  <2> ldFATType:	resb 1
    92                              <2> ldFlags:
    93 FFFFFFE7 ??                  <2> ldHasLBA:	resb 1
    94 FFFFFFE8 ????                <2> ldClusterSize:	resw 1
    95 FFFFFFEA ????                <2> ldParaPerSector:resw 1
    96                              <2> ldDirCluster:			; dword
    97                              <2> ldLoadingSeg:		; word
    98                              <2> ldQueryPatchValue:	; word
    99                              <2> lsvCommandLine:		; word
   100                              <2> .start:		equ $ - lsvclBufferLength
   101 FFFFFFEC ????                <2> .signature:	resw 1
   102                              <2> ldLoadUntilSeg:		; word
   103                              <2> lsvExtra:		; word
   104 FFFFFFEE ??                  <2> .partition:	resb 1	; byte
   105 FFFFFFEF ??                  <2> .flags:		resb 1	; byte
   106                              <2> 	endstruc
   107                              <2> 
   108                              <2> ldhlfPreserveLoader	equ 4
   109                              <2> 
   110                              <2> lsvefNoDataStart	equ 1
   111                              <2> lsvefPartitionNumber	equ 2
   112                              <2> lsvefPreserveLoader	equ 4
   113                              <2> 
   114                              <2> %if lsvefPreserveLoader != ldhlfPreserveLoader
   115                              <2>  %error Unexpected flag values
   116                              <2> %endif
   117                              <2> 
   118                              <2> 	struc LOADCMDLINE, LOADDATA - lsvclBufferLength
   119                              <2> ldCommandLine:
   120 FFFFFEE0 <res 100h>          <2> .start:		resb lsvclBufferLength
   121                              <2> 	endstruc
   122                              <2> 
   123                              <2> ldfHasLBA:	equ 1
   124                              <2> ldfFATInvalid:	equ 2
   125                              <2> ldfFATBuffered:	equ 4
   126                              <2> ldfDataBuffered: equ 8
   127                              <2> 
   128                              <2> 	struc LOADDATA2, LOADDATA - 10h
   129 FFFFFFD0 ????????            <2> ldRootSector:		resd 1
   130 FFFFFFD4 ????                <2> ldEntriesPerSector:	resw 1
   131                              <2> ldDataSegment:		; word
   132 FFFFFFD6 ????                <2> ldLastAvailableSector:	resw 1
   133                              <2> ldDataSector:		; dword
   134 FFFFFFD8 ????                <2> ldParasLeft:		resw 1
   135 FFFFFFDA ????                <2> ldParasDone:		resw 1
   136                              <2> 	endstruc
   137                              <2> 
   138                              <2> 	struc LOADDATA3, LOADDATA2 - 10h
   139 FFFFFFC0 ????????            <2> ldMaxCluster:		resd 1
   140 FFFFFFC4 ????????            <2> ldFileSize:		resd 1
   141 FFFFFFC8 ????????            <2> ldCurrentCluster:	resd 1
   142 FFFFFFCC ????????            <2> ldCurrentSeek:		resd 1
   143                              <2> 	endstruc
   144                              <2> 
   145                              <2> 	struc LOADERIMAGEIDENT
   146 00000000 ????????            <2> liiSignature:		resb 4		; "NLDR"
   147 00000004 ????                <2> liiVersion:		resb 2		; "00"
   148 00000006 ????                <2> liiChecksum:		resw 1		; word sum of first 8 words = 0
   149 00000008 ????                <2> liiAmountParagraphs:	resw 1
   150 0000000A ????????????        <2> liiReserved:		resw 3
   151 00000010 ????                <2> liiEntryQuerySize:	resw 1		; 0 if not supported
   152                              <2> 		; INP:	cs => NLDR image ident
   153                              <2> 		;	ip = this word field content
   154                              <2> 		;	ax = 60h
   155                              <2> 		; OUT:	ax => behind memory requested (should be >= 60h)
   156                              <2> 		; CHG:	es, ds, di, si, bx, cx, dx
   157                              <2> 		; STT:	far called, UP, EI
   158 00000012 ????                <2> liiEntryRelocate:	resw 1		; 0 if not supported
   159                              <2> 		; INP:	cs => NLDR image ident
   160                              <2> 		;	ip = this word field content
   161                              <2> 		;	ax = 60h
   162                              <2> 		; OUT:	ax => relocated NLDR segment (usually 60h)
   163                              <2> 		; CHG:	es, ds, di, si, bx, cx, dx
   164                              <2> 		; STT:	far called, UP, EI
   165 00000014 ????                <2> liiEntryDebug:		resw 1		; 0 if not supported
   166                              <2> 		; INP:	es = ds = cs = ss => relocated NLDR
   167                              <2> 		;	ip = this word field content
   168                              <2> 		;	sp = next word field content
   169                              <2> 		; STT:	running as debuggee, UP, EI
   170 00000016 ????                <2> liiStackPointer:	resw 1
   171                              <2> 	endstruc
   172                              <2> 
   173                              <2> 	struc LBAPACKET
   174 00000000 ????                <2> lpSize:		resw 1
   175 00000002 ????                <2> lpCount:	resw 1
   176 00000004 ????????            <2> lpBuffer:	resd 1
   177 00000008 ????????????????    <2> lpSector:	resq 1
   178                              <2> 	endstruc
   179                              <2> 
   180                              <2> 	struc PARTINFO
   181 00000000 ??                  <2> piBoot:		resb 1
   182 00000001 ??????              <2> piStartCHS:	resb 3
   183 00000004 ??                  <2> piType:		resb 1
   184 00000005 ??????              <2> piEndCHS:	resb 3
   185 00000008 ????????            <2> piStart:	resd 1
   186 0000000C ????????            <2> piLength:	resd 1
   187                              <2> 	endstruc
   188                              <2> 
   189                              <2> ptEmpty:		equ 0
   190                              <2> ptFAT12:		equ 1
   191                              <2> ptFAT16_16BIT_CHS:	equ 4
   192                              <2> ptExtendedCHS:		equ 5
   193                              <2> ptFAT16_CHS:		equ 6
   194                              <2> ptFAT32_CHS:		equ 0Bh
   195                              <2> ptFAT32:		equ 0Ch
   196                              <2> ptFAT16:		equ 0Eh
   197                              <2> ptExtended:		equ 0Fh
   198                              <2> ptLinux:		equ 83h
   199                              <2> ptExtendedLinux:	equ 85h
   200                              <2> 
   201                              <2> 
   202                              <2> 		; Flags of load_unit_flags
   203                              <2> lufForceCHS:		equ 1
   204                              <2> lufForceLBA:		equ 2
   205                              <2> lufForceGeometry:	equ 4
   206                              <2> luf_mask_writable equ lufForceCHS | lufForceLBA | lufForceGeometry
   802                              <1> 
   803                              <1> LOAD_INPUT_FILE_SIZE equ fromparas(paras(-LOADDATA3 + bsBPB + ebpbNew + BPBN_size))
   804                              <1> 
   805                              <1> 	struc LOADSETTINGS
   806 00000000 ????                <1> lsKernelName:	resw 1	; -> kernel file default name
   807 00000002 ????                <1> lsAddName:	resw 1	; -> additional file default name, may be empty string
   808 00000004 ????                <1> lsMinPara:	resw 1	; how much to load at least, fail if file smaller
   809 00000006 ????                <1> lsMaxPara:	resw 1	; how much to load at most (will round up to sector size)
   810 00000008 ????                <1> lsOptions:	resw 1	; option flags
   811 0000000A ????                <1> lsSegment:	resw 1	; => where to load file
   812 0000000C ????????            <1> lsEntry:	resd 1	; relative segment for CS, value for IP
   813 00000010 ????????            <1> lsBPB:		resd 1	; segment for BPB (-1 auto-BPB), offset for BPB
   814 00000014 ????                <1> lsCheckOffset:	resw 1	; offset in file segment of word to check
   815 00000016 ????                <1> lsCheckValue:	resw 1	; value to check for word, 0 if unused
   816 00000018 ????????????????    <1> lsName:		resq 1	; ASCIZ load protocol name
   817                              <1> 	endstruc
   818                              <1> 
   819                              <1> 		numdef LUF_DEFAULT_DISKETTE, 0
   820                              <1> 		numdef LUF_DEFAULT_HARDDISK, 0
   821                              <1> %endif
   822                              <1> 
   823                              <1> 
   824                              <1> %include "mzheader.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug MZ .EXE header macros
     5                              <2> 
     6                              <2> Copyright (C) 1995-2003 Paul Vojta
     7                              <2> Copyright (C) 2008-2023 E. C. Masloch
     8                              <2> 
     9                              <2> Usage of the works is permitted provided that this
    10                              <2> instrument is retained with the works, so that any entity
    11                              <2> that uses the works is notified of this instrument.
    12                              <2> 
    13                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    14                              <2> 
    15                              <2> %endif
    16                              <2> 
    17                              <2> 
    18                              <2> 	struc EXEHEADER
    19 00000000 ????                <2> exact_struc_at 00h, exeSignature:	resw 1
    20 00000002 ????                <2> exact_struc_at 02h, exeExtraBytes:	resw 1	; bytes in last page
    21 00000004 ????                <2> exact_struc_at 04h, exePages:		resw 1	; number of 512-byte pages. includes the header!
    22 00000006 ????                <2> exact_struc_at 06h, exeRelocItems:	resw 1	; number of relocation items
    23 00000008 ????                <2> exact_struc_at 08h, exeHeaderSize:	resw 1	; header size in 16-byte paragraphs
    24 0000000A ????                <2> exact_struc_at 0Ah, exeMinAlloc:	resw 1	; minimum (bss) allocation in paragraphs
    25 0000000C ????                <2> exact_struc_at 0Ch, exeMaxAlloc:	resw 1	; maximum (bss) allocation in paragraphs
    26 0000000E ????                <2> exact_struc_at 0Eh, exeInitSS:		resw 1	; init ss (is relocated)
    27 00000010 ????                <2> exact_struc_at 10h, exeInitSP:		resw 1	; init sp
    28 00000012 ????                <2> exact_struc_at 12h, exeChecksum:	resw 1
    29                              <2> exact_struc_at 14h, exeInitCSIP:
    30 00000014 ????                <2> exact_struc_at 14h, exeInitIP:		resw 1	; init ip
    31 00000016 ????                <2> exact_struc_at 16h, exeInitCS:		resw 1	; init cs (is relocated)
    32 00000018 ????                <2> exact_struc_at 18h, exeRelocTable:	resw 1	; byte offset of relocation table
    33                              <2> 		; Each relocation item is a word offset and a word segment.
    34                              <2> 		;  The segment of the item itself is relocated as well.
    35 0000001A ????                <2> exact_struc_at 1Ah, exeOverlayNum:	resw 1
    36                              <2> exact_struc_at 1Ch
    37                              <2> 	endstruc
   825                              <1> 
   826                              <1> 
   827                              <1> 	struc INPUTFILEHANDLE
   828 00000000 ????                <1> ifhHandle:	resw 1
   829 00000002 ????                <1> ifhFlags:	resw 1
   830 00000004 ????????            <1> ifhParentSeek:	resd 1
   831                              <1> 	endstruc
   832                              <1> 
   833                              <1> ifhfIsDup:		equ  100h	; before closing, seek it back
   834                              <1> 	; same value as LBA flag for boot load input files
   835                              <1> ifhfTestReserved1:	equ 1000h
   836                              <1> ifhfTestReserved2:	equ 2000h
   837                              <1> ifhfQuietInput:		equ 4000h	; do not display prompt and input
   838                              <1> ifhfQuietOutput:	equ 8000h	; do not display normal output
   839                              <1> 	; these four are valid for both input file handles and
   840                              <1> 	;  boot load input files.
   841                              <1> 
   842                              <1> 
   843                              <1> 	struc AREASTRUC
   844 00000000 <res 18h>           <1> areastrucEntry:		resb 24
   845 00000018 ????????            <1> areastrucNext:		resd 1
   846 0000001C ????????            <1> areastrucPrev:		resd 1
   847 00000020 ????                <1> areastrucSubAmount:	resw 1
   848 00000022 ????                <1> areastrucSubOffset:	resw 1
   849 00000024 ????                <1> areastrucFunAmount:	resw 1
   850 00000026 ????                <1> areastrucFunOffset:	resw 1
   851                              <1> 	endstruc
   852                              <1> 
   853                              <1> 	struc AREASTRUCSUB
   854 00000000 ????????            <1> areastrucsubLinear:	resd 1
   855 00000004 ????????            <1> areastrucsubLinearEnd:	resd 1
   856 00000008 ????                <1> areastrucsubListOffset:	resw 1
   857 0000000A ????                <1> areastrucsubListAmount:	resw 1
   858                              <1> 	endstruc
   859                              <1> 
   860                              <1> 	struc AREASTRUCFUN
   861 00000000 ????????            <1> areastrucfunLinear:	resd 1
   862 00000004 ????????            <1> areastrucfunLinearEnd:	resd 1
   863 00000008 ????                <1> areastrucfunListOffset:	resw 1
   864 0000000A ????                <1> areastrucfunListAmount:	resw 1
   865                              <1> 	endstruc
   866                              <1> 
   867                              <1> 	struc AREA
   868 00000000 ????                <1> areastart:		resw 1
   869 00000002 ????                <1> areaend:		resw 1
   870 00000004 ????                <1> areamessage:		resw 1
   871 00000006 ????                <1> 			resw 1
   872                              <1> 	endstruc
   873                              <1> 
   874                              <1> 
   875                              <1> %include "isvariab.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug isvariable? function strutures and macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2025 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 
    17                              <2> 	struc ISVARIABLESTRUC
    18 00000000 ????                <2> ivName:		resw 1		; -> name (up to 13 bytes, but actually only 11)
    19                              <2> 				;  (search for ivfNameLengthLimit for limit)
    20                              <2> 				;  (length given by ivFlags & ivfNameLengthMask)
    21                              <2> 	; The ivName pointer is only used for more-byte names. It actually
    22                              <2> 	;  contains the trailer of the name, excluding the prefix formed by
    23                              <2> 	;  the first two bytes. This suffix can be the empty string if the
    24                              <2> 	;  variable in question has a two-byte name.
    25                              <2> 	; (For one-byte names this field is unused and contains zero.)
    26 00000002 ????                <2> ivFlags:	resw 1
    27 00000004 ????                <2> ivAddress:	resw 1		; default -> variable
    28                              <2> 	; The ivAddress field is used by default_variable_setup as the base
    29                              <2> 	;  address for the variable(s). It is also used by var_ext_setup as
    30                              <2> 	;  the ELD code section offset to transfer control to. Otherwise, it
    31                              <2> 	;  is usually set to zero and unused.
    32 00000006 ????                <2> ivSetup:	resw 1		; -> set up code (in expr code section)
    33                              <2> 	; INP:	ax = array index (0-based)
    34                              <2> 	;	di = 0
    35                              <2> 	;	cl = default size of variable (1..4)
    36                              <2> 	;	ch = length of variable name
    37                              <2> 	;	bx -> ISVARIABLESTRUC structure
    38                              <2> 	; CHG:	ax, bx, cx, dx, si, di
    39                              <2> 	; OUT:	NC if valid,
    40                              <2> 	;	 bx -> var, di = 0 or di -> mask
    41                              <2> 	;	 cl = size of variable (1..4)
    42                              <2> 	;	 ch = length of variable name
    43 00000008 ??                  <2> ivArrayLast:	resb 1		; 0 if no array, FFh = 256 entries
    44                              <2> 	; The ivArrayLast field is used by the dispatcher to determine
    45                              <2> 	;  whether to support array index expressions. It is checked
    46                              <2> 	;  before decrementing the index if ivfArrayOneBased is set.
    47 00000009 ??                  <2> ivArrayBetween: resb 1		; how many bytes to skip for each index
    48                              <2> 	; The ivArrayBetween field is only used by default_variable_setup.
    49                              <2> 	endstruc
    50                              <2> 
    51                              <2> ivfNameLengthMask:	equ 15	; gives name trailer length, 0 to 11
    52                              <2> ivfNameLengthLimit:	equ 13
    53                              <2> ivfVarLengthShift:	equ 4
    54                              <2> ivfVarLengthMask:	equ 3 << ivfVarLengthShift
    55                              <2> 				; gives default variable size minus 1
    56                              <2> ivfReadOnly:		equ 80h	; variable cannot be written at all
    57                              <2> ivfArrayOneBased:	equ 100h; first array entry is 1 not 0 (ivArrayLast > 0)
    58                              <2> ivfArrayOptional:	equ 200h; array index expression is optional
    59                              <2> ivfSeparatorSpecial:	equ 400h; used for RIxxP/L/S/O
    60                              <2> 
    61                              <2> %define ISVARIABLESTRINGS db "",db ""
    62                              <2> %define IVS_ONEBYTE_NAMES ""
    63                              <2> %define IVS_MOREBYTE_NAMEHEADERS ""
    64                              <2> %assign IVS_HAVE_ONEBYTE 0
    65                              <2> %assign IVS_SINGLE_ONEBYTE 1
    66                              <2> 
    67                              <2> 		; %1 = name string
    68                              <2> 		; %2 = default variable length, 1 to 4
    69                              <2> 		; %3 = flags to set (except name length and var length)
    70                              <2> 		; %4 = ivAddress value
    71                              <2> 		; %5 = ivArrayLast, defaults to 0 (no array)
    72                              <2> 		; %6 = ivArrayBetween, defaults to 0 (immediately consecutive)
    73                              <2> 		; %7 = ivSetup, defaults to default_variable_setup
    74                              <2> 	%macro isvariablestruc 4-7.nolist 0, 0, default_variable_setup
    75                              <2> %push
    76                              <2> %strlen %$namelength %1
    77                              <2> %if %$namelength > ivfNameLengthLimit
    78                              <2>  %error Expected at most 13-byte name (or adjust isvariable? code)
    79                              <2> %endif
    80                              <2> %if IVS_ONEBYTE && %$namelength != 1
    81                              <2>  %error Expected a one-byte name
    82                              <2> %elif ! IVS_ONEBYTE && %$namelength < 2
    83                              <2>  %error Expected at least a two-byte name
    84                              <2> %endif
    85                              <2> %if IVS_ONEBYTE
    86                              <2>  %define IVS_SINGLE_ONEBYTE_NAME %1
    87                              <2>  %if IVS_HAVE_ONEBYTE
    88                              <2>   %assign IVS_SINGLE_ONEBYTE 0
    89                              <2>  %endif
    90                              <2>  %assign IVS_HAVE_ONEBYTE 1
    91                              <2>  %assign %$namelength 0
    92                              <2>  %xdefine IVS_ONEBYTE_NAMES IVS_ONEBYTE_NAMES, %1
    93                              <2>  %%name equ 0
    94                              <2> %else
    95                              <2>  %assign %$namelength %$namelength - 2
    96                              <2>  %substr %$nametrailer %1 3,-1
    97                              <2>  %substr %$nameheader %1 1,2
    98                              <2>  %xdefine IVS_MOREBYTE_NAMEHEADERS IVS_MOREBYTE_NAMEHEADERS, %$nameheader
    99                              <2>  %xdefine ISVARIABLESTRINGS ISVARIABLESTRINGS, %%name:, {db %$nametrailer}
   100                              <2> %endif
   101                              <2> 
   102                              <2> %assign %$varlength %2 - 1	; 0 means one byte, 1 means two bytes,
   103                              <2> 				;  2 means three bytes, 3 means four bytes
   104                              <2> 	istruc ISVARIABLESTRUC
   105                              <2> at ivName,		dw %%name
   106                              <2>  IV_NAME_RELOCATION
   107                              <2> at ivFlags,		dw %$$namelength | (%$$varlength << ivfVarLengthShift) | %3
   108                              <2> at ivAddress,		dw %4
   109                              <2>  IV_ADDRESS_RELOCATION
   110                              <2> at ivSetup,		dw %7
   111                              <2>  IV_SETUP_RELOCATION
   112                              <2> at ivArrayLast,		db %5
   113                              <2> at ivArrayBetween,	db %6
   114                              <2> 	iend
   115                              <2> %pop
   116                              <2> %ifndef SECTION_OF_%7
   117                              <2>  %error Unknown target section for symbol %7
   118                              <2> %elifnidni %[SECTION_OF_%7], _EXPR_SECTION
   119                              <2>  %error Wrong section for symbol %7: section_of=SECTION_OF_%7, expr=_EXPR_SECTION
   120                              <2> %endif
   121                              <2> 	%endmacro
   122                              <2> 
   123                              <2> %define IV_NAME_RELOCATION
   124                              <2> %define IV_ADDRESS_RELOCATION
   125                              <2> %define IV_SETUP_RELOCATION
   126                              <2> 
   127                              <2> 	%macro isvariablestrings 2-*.nolist
   128                              <2> %rep %0
   129                              <2>  %1
   130                              <2>  %rotate 1
   131                              <2> %endrep
   132                              <2> 	%endmacro
   876                              <1> 
   877                              <1> 
   878                              <1> %include "386.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug 386 patch macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2026 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 	numdef LINK, 0
    17                              <2> 
    18                              <2> 	numdef WPT_LABELS, 0
    19                              <2> 		; This used to be required, because CODESECTIONFIXUP used
    20                              <2> 		;  ldebug_data_entry_size, which is not yet defined during
    21                              <2> 		;  assembling of (most) lDEBUG_CODE fragments.
    22                              <2> 		; However, assembling DebugX with this option selected
    23                              <2> 		;  took more than 2 minutes, so the non-label variant
    24                              <2> 		;  is clearly to be preferred when available.
    25                              <2> 		; Now that lDEBUG_CODE has vstart=0 we can use the
    26                              <2> 		;  CODESECTIONFIXUP again and thus disable this option.
    27                              <2> 
    28                              <2> %ifn _LINK
    29                              <2> %define PATCH_NO386_TABLE ""
    30                              <2> %define PATCH_386_TABLE ""
    31                              <2> %define PATCH_NO386_TABLE2 ""
    32                              <2> %define PATCH_386_TABLE2 ""
    33                              <2> %define PATCH_NO386_TABLEENTRY ""
    34                              <2> %define PATCH_386_TABLEENTRY ""
    35                              <2> %endif
    36                              <2> 
    37                              <2> %if _ONLY386
    38                              <2> 		; Default patch macros if only running on 386+.
    39                              <2> %define _386_o32 o32
    40                              <2> %define _386_a32 a32
    41                              <2> %define _386_jmps jmp short
    42                              <2> %define _386_jmpn jmp near
    43                              <2> %define _no386_jmps comment
    44                              <2> %define _no386_jmpn comment
    45                              <2> 	%macro _386 0-1+.nolist
    46                              <2> [cpu 386]			; change CPU type
    47                              <2> 		%1		; write instruction
    48                              <2> __CPU__				; reset CPU type
    49                              <2> 	%endmacro
    50                              <2> %define _no386 comment
    51                              <2> %elif _ONLYNON386
    52                              <2> 		; Default patch macros if only running on non-386.
    53                              <2> %define _386_o32
    54                              <2> %define _386_a32
    55                              <2> %define _386_jmps comment
    56                              <2> %define _386_jmpn comment
    57                              <2> %define _no386_jmps jmp short
    58                              <2> %define _no386_jmpn jmp near
    59                              <2> %define _386 comment
    60                              <2> %define _no386
    61                              <2> %else
    62                              <2> 
    63                              <2> ; These macros are to make DEBUG's 386 support as small as
    64                              <2> ; possible. To achieve this, two patch tables are created
    65                              <2> ; in the initialisation code. One of the tables is used if
    66                              <2> ; the CPU is a 386+, the other one if it isn't. The bytes
    67                              <2> ; pointed to in the used table are over-written with NOP
    68                              <2> ; instructions. (The patched bytes are usually address or
    69                              <2> ; operand size prefixes or jumps that branch to 386/non-386
    70                              <2> ; code.)
    71                              <2> 
    72                              <2> ; There are a few special patches that require the
    73                              <2> ; initialisation code to write specific bytes other than
    74                              <2> ; NOP instructions for lower resident memory usage.
    75                              <2> ; Two are in the run: code, three in pmentry.asm.
    76                              <2> 
    77                              <2> %if _LINK
    78                              <2> 
    79                              <2> %imacro wllist 1-3.nolist
    80                              <2> %ifnempty %3
    81                              <2>  %deftok %%filenametoken %3
    82                              <2> %else
    83                              <2>  %deftok %%filenametoken __FILE__
    84                              <2> %endif
    85                              <2>  global ..@wllist_%1?%[%%l]%[%%filenametoken]
    86                              <2> ..@wllist_%1?%[%%l]%[%%filenametoken]: %2
    87                              <2> %endmacro
    88                              <2> 
    89                              <2> 	%macro patch386 2-3.nolist 1
    90                              <2> %define %%repeat
    91                              <2> %if %3 != 1
    92                              <2>  %define %%repeat r%3_
    93                              <2> %endif
    94                              <2> %ifidn _CURRENT_SECTION, lDEBUG_CODE
    95                              <2>  wllist %[%%repeat]Lpatch_%{1}386_table, %2
    96                              <2> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
    97                              <2>  wllist %[%%repeat]Lpatch_%{1}386_table2, %2
    98                              <2> %elifidn _CURRENT_SECTION, lDEBUG_DATA_ENTRY
    99                              <2>  wllist %[%%repeat]Lpatch_%{1}386_tableentry, %2
   100                              <2> %else
   101                              <2>  %error Wrong section
   102                              <2> %endif
   103                              <2> 	%endmacro
   104                              <2> 
   105                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   106                              <2> 	%macro _386_o32 0-1+.nolist
   107                              <2> _386		o32
   108                              <2> 		%1
   109                              <2> 	%endmacro
   110                              <2> 
   111                              <2> 		; Address size 32-bit prefix if 386+ CPU
   112                              <2> 	%macro _386_a32 0-1+.nolist
   113                              <2> _386		a32
   114                              <2> 		%1
   115                              <2> 	%endmacro
   116                              <2> 
   117                              <2> 		; Short jump if 386+ CPU
   118                              <2> 	%macro _386_jmps 1.nolist
   119                              <2> _386		jmp short %1
   120                              <2> 	%endmacro
   121                              <2> 
   122                              <2> 		; Near jump if 386+ CPU
   123                              <2> 	%macro _386_jmpn 1.nolist
   124                              <2> _386		jmp near %1
   125                              <2> 	%endmacro
   126                              <2> 
   127                              <2> 		; Short jump if no 386+ CPU
   128                              <2> 	%macro _no386_jmps 1.nolist
   129                              <2> _no386		jmp short %1
   130                              <2> 	%endmacro
   131                              <2> 
   132                              <2> 		; Near jump if no 386+ CPU
   133                              <2> 	%macro _no386_jmpn 1.nolist
   134                              <2> _no386		jmp near %1
   135                              <2> 	%endmacro
   136                              <2> 
   137                              <2> 		; Instruction if 386+ CPU
   138                              <2> 	%macro _386 0-1+.nolist
   139                              <2> [cpu 386]			; change CPU type
   140                              <2> %%entry:
   141                              <2> 		%1		; write instruction
   142                              <2> __CPU__				; reset CPU type
   143                              <2> %assign %%length ($ - %%entry)
   144                              <2>  patch386 no, equ %%entry, %%length
   145                              <2> 	%endmacro
   146                              <2> 
   147                              <2> 		; Instruction if no 386+ CPU
   148                              <2> 	%macro _no386 0-1+.nolist
   149                              <2> %%entry:
   150                              <2> 		%1		; write instruction
   151                              <2> %assign %%length ($ - %%entry)
   152                              <2>  patch386 , equ %%entry, %%length
   153                              <2> 	%endmacro
   154                              <2> 
   155                              <2> %else
   156                              <2> 	%macro patch386 2+.nolist
   157                              <2> %ifidn _CURRENT_SECTION, lDEBUG_CODE
   158                              <2>  %define PATCH_%{1}386_TABLE %[PATCH_%{1}386_TABLE], %2
   159                              <2> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
   160                              <2>  %define PATCH_%{1}386_TABLE2 %[PATCH_%{1}386_TABLE2], %2
   161                              <2> %elifidn _CURRENT_SECTION, lDEBUG_DATA_ENTRY
   162                              <2>  %define PATCH_%{1}386_TABLEENTRY %[PATCH_%{1}386_TABLEENTRY], %2
   163                              <2> %else
   164                              <2>  %error Wrong section
   165                              <2> %endif
   166                              <2> 	%endmacro
   167                              <2> 
   168                              <2> %if _WPT_LABELS
   169                              <2> 	; These forms provide verbose info by defining a
   170                              <2> 	; meaningful label for each patch. That fills up
   171                              <2> 	; the map file and might take longer though.
   172                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   173                              <2> 	%macro _386_o32 0-1+.nolist
   174                              <2> %%386_o32:	o32
   175                              <2> patch386 NO, %%386_o32
   176                              <2> 		%1
   177                              <2> 	%endmacro
   178                              <2> 
   179                              <2> 		; Address size 32-bit prefix if 386+ CPU
   180                              <2> 	%macro _386_a32 0-1+.nolist
   181                              <2> %%386_a32:	a32
   182                              <2> patch386 NO, %%386_a32
   183                              <2> 		%1
   184                              <2> 	%endmacro
   185                              <2> 
   186                              <2> 		; Short jump if 386+ CPU
   187                              <2> 	%macro _386_jmps 1.nolist
   188                              <2> %%386_jmps:	jmp short %1
   189                              <2> patch386 NO, %%386_jmps,%%386_jmps+1
   190                              <2> 	%endmacro
   191                              <2> 
   192                              <2> 		; Near jump if 386+ CPU
   193                              <2> 	%macro _386_jmpn 1.nolist
   194                              <2> %%386_jmpn:	jmp near %1
   195                              <2> patch386 NO, %%386_jmpn,%%386_jmpn+1,%%386_jmpn+2
   196                              <2> 	%endmacro
   197                              <2> 
   198                              <2> 		; Short jump if no 386+ CPU
   199                              <2> 	%macro _no386_jmps 1.nolist
   200                              <2> %%no386_jmps:	jmp short %1
   201                              <2> patch386 , %%no386_jmps,%%no386_jmps+1
   202                              <2> 	%endmacro
   203                              <2> 
   204                              <2> 		; Near jump if no 386+ CPU
   205                              <2> 	%macro _no386_jmpn 1.nolist
   206                              <2> %%no386_jmpn:	jmp near %1
   207                              <2> patch386 , %%no386_jmpn,%%no386_jmpn+1,%%no386_jmpn+2
   208                              <2> 	%endmacro
   209                              <2> 
   210                              <2> 		; Instruction if 386+ CPU
   211                              <2> 	%macro _386 0-1+.nolist
   212                              <2> [cpu 386]			; change CPU type
   213                              <2> %%386_instr:	%1		; write instruction
   214                              <2> __CPU__				; reset CPU type
   215                              <2> 
   216                              <2> %assign %%INSTRCOUNT 0
   217                              <2> %rep $-%%386_instr		; count size of instruction
   218                              <2>  patch386 NO, %%386_instr+%[%%INSTRCOUNT]
   219                              <2> 				; write a patch for each byte
   220                              <2>  %assign %%INSTRCOUNT %%INSTRCOUNT+1
   221                              <2> %endrep
   222                              <2> %undef %%INSTRCOUNT
   223                              <2> 	%endmacro
   224                              <2> 
   225                              <2> 		; Instruction if no 386+ CPU
   226                              <2> 	%macro _no386 0-1+.nolist
   227                              <2> %%no386_instr:	%1		; write instruction
   228                              <2> 
   229                              <2> %assign %%INSTRCOUNT 0
   230                              <2> %rep $-%%no386_instr		; count size of instruction
   231                              <2>  patch386 , %%no386_instr+%[%%INSTRCOUNT]
   232                              <2> 				; write a patch for each byte
   233                              <2>  %assign %%INSTRCOUNT %%INSTRCOUNT+1
   234                              <2> %endrep
   235                              <2> %undef %%INSTRCOUNT
   236                              <2> 	%endmacro
   237                              <2> %else	; _WPT_LABELS
   238                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   239                              <2> 	%macro _386_o32 0-1+.nolist
   240                              <2> _386		o32
   241                              <2> 		%1
   242                              <2> 	%endmacro
   243                              <2> 
   244                              <2> 		; Address size 32-bit prefix if 386+ CPU
   245                              <2> 	%macro _386_a32 0-1+.nolist
   246                              <2> _386		a32
   247                              <2> 		%1
   248                              <2> 	%endmacro
   249                              <2> 
   250                              <2> 		; Short jump if 386+ CPU
   251                              <2> 	%macro _386_jmps 1.nolist
   252                              <2> _386		jmp short %1
   253                              <2> 	%endmacro
   254                              <2> 
   255                              <2> 		; Near jump if 386+ CPU
   256                              <2> 	%macro _386_jmpn 1.nolist
   257                              <2> _386		jmp near %1
   258                              <2> 	%endmacro
   259                              <2> 
   260                              <2> 		; Short jump if no 386+ CPU
   261                              <2> 	%macro _no386_jmps 1.nolist
   262                              <2> _no386		jmp short %1
   263                              <2> 	%endmacro
   264                              <2> 
   265                              <2> 		; Near jump if no 386+ CPU
   266                              <2> 	%macro _no386_jmpn 1.nolist
   267                              <2> _no386		jmp near %1
   268                              <2> 	%endmacro
   269                              <2> 
   270                              <2> 		; Instruction if 386+ CPU
   271                              <2> 	%macro _386 0-1+.nolist
   272                              <2> %push
   273                              <2> [cpu 386]			; change CPU type
   274                              <2> %assign %$entry $ + _CURRENT_SECTION %+ FIXUP
   275                              <2> 		%1		; write instruction
   276                              <2> __CPU__				; reset CPU type
   277                              <2> 
   278                              <2> %rep ($ + _CURRENT_SECTION %+ FIXUP) - %$entry
   279                              <2> 				; count size of instruction
   280                              <2>  patch386 NO, %[%$entry]	; write a patch for each byte
   281                              <2>  %assign %$entry %$entry+1
   282                              <2> %endrep
   283                              <2> %pop
   284                              <2> 	%endmacro
   285                              <2> 
   286                              <2> 		; Instruction if no 386+ CPU
   287                              <2> 	%macro _no386 0-1+.nolist
   288                              <2> %push
   289                              <2> %assign %$entry $ + _CURRENT_SECTION %+ FIXUP
   290                              <2> 		%1		; write instruction
   291                              <2> 
   292                              <2> %rep ($ + _CURRENT_SECTION %+ FIXUP) - %$entry
   293                              <2> 				; count size of instruction
   294                              <2>  patch386 , %[%$entry]		; write a patch for each byte
   295                              <2>  %assign %$entry %$entry+1
   296                              <2> %endrep
   297                              <2> %pop
   298                              <2> 	%endmacro
   299                              <2> %endif	; _WPT_LABELS
   300                              <2> %endif	; _LINK
   301                              <2> 
   302                              <2> %endif
   303                              <2> 
   304                              <2> 		; Patch macros but for cases where the 386+
   305                              <2> 		; instructions should only be generated for
   306                              <2> 		; DEBUGX (i.e. for 32-bit DPMI addressing code).
   307                              <2> %if _PM
   308                              <2> %define _386_PM_o32	_386_o32
   309                              <2> %define _386_PM_a32	_386_a32
   310                              <2> %define _386_PM_jmps	_386_jmps
   311                              <2> %define _386_PM_jmpn	_386_jmpn
   312                              <2> %define _386_PM		_386
   313                              <2> %else
   314                              <2> %define _386_PM_o32
   315                              <2> %define _386_PM_a32
   316                              <2> %define _386_PM_jmps	comment
   317                              <2> %define _386_PM_jmpn	comment
   318                              <2> %define _386_PM		comment
   319                              <2> %endif
   320                              <2> 
   321                              <2> 
   322                              <2> %ifn _LINK
   323                              <2> %macro __writepatchtable2 0-*.nolist
   324                              <2> %if %0 & 1
   325                              <2>  %fatal Expected even number of arguments
   326                              <2> %endif
   327                              <2> %rep %0 >> 1
   328                              <2> 	%1 %2
   329                              <2> %rotate 2
   330                              <2> %endrep
   331                              <2> %endmacro
   332                              <2> 
   333                              <2> %macro __patchtable2_entry 0.nolist
   334                              <2>   ; only if this isn't the first (pseudo-)entry
   335                              <2>   %if %$lastcount != 0
   336                              <2>     %assign %$runscount %[%$runscount]+1
   337                              <2>    ; if the offset from %$previous is less than 255
   338                              <2>    %if (%$last-%$previous) < 255
   339                              <2>     %assign %$$method2tablesize %$$method2tablesize+1
   340                              <2>     ; then write a single byte (number of bytes not to patch between)
   341                              <2>     %xdefine %$$method2list %$$method2list,db,%$last-%$previous
   342                              <2>    %else
   343                              <2>     ; otherwise write a 255 ("reposition") and write the 16-bit address afterwards
   344                              <2>     %assign %$$method2tablesize %$$method2tablesize+3
   345                              <2>     %xdefine %$$method2list %$$method2list,db,255,dw,%$last
   346                              <2>     %assign %$reposcount %[%$reposcount]+1
   347                              <2>    %endif
   348                              <2>    %if %$lastcount == 1
   349                              <2>     %assign %$onecount %[%$onecount]+1
   350                              <2>    %endif
   351                              <2>    %assign %$$method2tablesize %$$method2tablesize+1
   352                              <2>    ; and write the number of bytes to be patched
   353                              <2>    %xdefine %$$method2list %$$method2list,db,%$lastcount
   354                              <2>    ; define %$previous for the next entry: it points to the next non-patched byte
   355                              <2>    %define %$previous (%[%$last]+%[%$lastcount])
   356                              <2>   %endif
   357                              <2> %endmacro
   358                              <2> 
   359                              <2> %macro writepatchtable 2-*.nolist
   360                              <2> 
   361                              <2> 	numdef %{1}_FORCE_METHOD, 0
   362                              <2> %push
   363                              <2> 		; Determine length of simple table:
   364                              <2> %assign %$method1tablesize (%0 - 2)*2
   365                              <2> 
   366                              <2> %if !_%{1}_FORCE_METHOD || _%{1}_FORCE_METHOD == 2
   367                              <2> 		; Determine length of complicated table:
   368                              <2> %assign %$method2tablesize 0
   369                              <2> %define %$method2list db,""
   370                              <2> %push
   371                              <2> %if _WPT_LABELS
   372                              <2>  %define %$previous code_start	; if list contains labels
   373                              <2> %else
   374                              <2>  %define %$previous 0
   375                              <2> %endif
   376                              <2> %define %$last %[%$previous]
   377                              <2> %assign %$lastcount 0
   378                              <2> %assign %$onecount 0
   379                              <2> %assign %$reposcount 0
   380                              <2> %assign %$bytescount %0 - 2
   381                              <2> %assign %$runscount 0
   382                              <2> %rotate 1
   383                              <2> %rep %0 - 2
   384                              <2>  %rotate 1
   385                              <2>  ;if  it continues the previous patch   and not too long   and this isn't the first
   386                              <2>  %if ((%$last+%$lastcount) == %1) && (%$lastcount < 255) && (%$lastcount != 0)
   387                              <2>   ; then do not write an entry, just increase the patch's size
   388                              <2>   %assign %$lastcount %[%$lastcount]+1
   389                              <2>  %else
   390                              <2>   ; otherwise write the last entry
   391                              <2>   __patchtable2_entry
   392                              <2>   ; define new %$last to this parameter, %$lastcount to one
   393                              <2>   %define %$last %1
   394                              <2>   %assign %$lastcount 1
   395                              <2>  %endif
   396                              <2> %endrep
   397                              <2> __patchtable2_entry
   398                              <2> 
   399                              <2> ; at the end, there's a patch with offset 0, size 0
   400                              <2> %assign %$$method2tablesize %$$method2tablesize+2
   401                              <2> %xdefine %$$method2list %$$method2list,db,0,db,0
   402                              <2> 
   403                              <2> %assign %$$onecount %$onecount
   404                              <2> %assign %$$reposcount %$reposcount
   405                              <2> %assign %$$bytescount %$bytescount
   406                              <2> %assign %$$runscount %$runscount
   407                              <2> %pop
   408                              <2> %rotate 1
   409                              <2> %endif
   410                              <2> 
   411                              <2> %if _%{1}_FORCE_METHOD == 2
   412                              <2>  %define __%{1}_method 2
   413                              <2> %elif _%{1}_FORCE_METHOD == 1
   414                              <2>  %define __%{1}_method 1
   415                              <2> %else
   416                              <2>  %if _%{1}_FORCE_METHOD
   417                              <2>   %fatal Invalid forced method selected: _%{1}_FORCE_METHOD
   418                              <2>  %endif
   419                              <2>  %if %$method1tablesize > (%$method2tablesize+20)
   420                              <2>   %define __%{1}_method 2
   421                              <2>  %else
   422                              <2>   %define __%{1}_method 1
   423                              <2>  %endif
   424                              <2> %endif
   425                              <2> 
   426                              <2> 
   427                              <2> %1:
   428                              <2> %if __%{1}_method == 2
   429                              <2> 	__writepatchtable2 %$method2list
   430                              <2> 	endarea %1
   431                              <2> %assign %$size %1_size
   432                              <2> %warning %1: %$size bytes (Method 2)
   433                              <2> %warning 1B=%$onecount repo=%$reposcount run=%$runscount byte=%$bytescount
   434                              <2> %else
   435                              <2> %rotate 1
   436                              <2> %rep %0 - 2
   437                              <2> %rotate 1
   438                              <2> 	dw %1
   439                              <2> %endrep
   440                              <2> %rotate 1
   441                              <2> 	endarea %1
   442                              <2> %assign %$size %1_size
   443                              <2> %warning %1: %$size bytes (Method 1)
   444                              <2> %1.amount equ %1_size_w
   445                              <2> %endif
   446                              <2> %pop
   447                              <2> %endmacro
   448                              <2> %endif
   879                              <1> 
   880                              <1> 
   881                              <1> %if _VDD
   882                              <1> ; standard BOPs for communication with DEBXXVDD on NT platforms
   883                              <1> %macro RegisterModule 0.nolist
   884                              <1> 	db 0C4h, 0C4h, 58h, 0
   885                              <1> 	nop
   886                              <1> %endmacro
   887                              <1> %macro UnRegisterModule 0.nolist
   888                              <1> 	db 0C4h, 0C4h, 58h, 1
   889                              <1> 	nop
   890                              <1> %endmacro
   891                              <1> %macro DispatchCall 0.nolist
   892                              <1> 	db 0C4h, 0C4h, 58h, 2
   893                              <1> 	nop
   894                              <1> %endmacro
   895                              <1> %endif
   896                              <1> 
   897                              <1> %assign CODE_INSURE_COUNT 0
   898                              <1> 
   899                              <1> 		; The entry_to_code_seg/_sel dispatcher in lDEBUG_DATA_ENTRY
   900                              <1> 		;  detects mistaken debugger breakpoints in its
   901                              <1> 		;  in-code-parameter by checking for a low-byte
   902                              <1> 		;  value equal to 0CCh (one-byte int3 opcode).
   903                              <1> 		; Therefore, we insure that all destinations jumped to
   904                              <1> 		;  via that dispatcher do not happen to be located
   905                              <1> 		;  on an offset that gives 0CCh in the low byte.
   906                              <1> 	%imacro code_insure_low_byte_not_0CCh 0.nolist
   907                              <1> %ifn _LINK
   908                              <1>  %if (($ - _CURRENT_SECTION %+ _start) & 0FFh) == 0CCh
   909                              <1> 	nop
   910                              <1>   %assign CODE_INSURE_COUNT 1 + CODE_INSURE_COUNT
   911                              <1>  %endif
   912                              <1> %endif
   913                              <1> 	%endmacro
   914                              <1> 
   915                              <1> 
   916                              <1> 		; dual code segments
   917                              <1> %if _DUALCODE && _PM
   918                              <1> 
   919                              <1> %if _DEBUG
   920                              <1> %idefine dualfunction comment
   921                              <1> %else
   922                              <1> %idefine dualfunction code_insure_low_byte_not_0CCh
   923                              <1> %endif
   924                              <1> 
   925                              <1> %idefine dualreturn call _CURRENT_SECTION %+ _dualret_helper
   926                              <1> %idefine dualdistance far
   927                              <1> 	%imacro dualcall 1.nolist
   928                              <1> %ifndef SECTION_OF_%1
   929                              <1>  %error Unknown target section for symbol %1
   930                              <1> %endif
   931                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _dualcall_helper
   932                              <1>  %if _DEBUG
   933                              <1> 	jmp strict short %%skipdata
   934                              <1>  %endif
   935                              <1> 	dw %1
   936                              <1> %%skipdata:
   937                              <1> 	%endmacro
   938                              <1> 	%imacro nearcall 1.nolist
   939                              <1> %ifndef SECTION_OF_%1
   940                              <1>  %error Unknown target section for symbol %1
   941                              <1> %endif
   942                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
   943                              <1> 	call %1
   944                              <1> %else
   945                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _nearcall_helper
   946                              <1>  %if _DEBUG
   947                              <1> 	jmp strict short %%skipdata
   948                              <1>  %endif
   949                              <1> 	dw %1
   950                              <1> %%skipdata:
   951                              <1> %endif
   952                              <1> 	%endmacro
   953                              <1> 
   954                              <1> %elif _DUALCODE && ! _PM
   955                              <1> 
   956                              <1> %idefine dualfunction comment
   957                              <1> %idefine dualreturn
   958                              <1> %idefine dualdistance far
   959                              <1> 
   960                              <1> %ifn _LINK
   961                              <1> %define PATCH_RELOCATE_FROM_lDEBUG_CODE ""
   962                              <1> %define PATCH_RELOCATE_FROM_lDEBUG_CODE2 ""
   963                              <1> 	%imacro dualcall 1.nolist
   964                              <1> %ifndef SECTION_OF_%1
   965                              <1>  %error Unknown target section for symbol %1
   966                              <1> %endif
   967                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
   968                              <1> 	push cs
   969                              <1> 	call %1
   970                              <1> %else
   971                              <1> 	call relocatedzero:%1
   972                              <1> %push
   973                              <1> %assign %$entry ($ + _CURRENT_SECTION %+ FIXUP) - 2
   974                              <1> 	relocatelist _CURRENT_SECTION, %$entry
   975                              <1> %pop
   976                              <1> %endif
   977                              <1> 	%endmacro
   978                              <1> 	%imacro relocatelist 2.nolist
   979                              <1>  %define PATCH_RELOCATE_FROM_%1 %[PATCH_RELOCATE_FROM_%1],%2
   980                              <1> 	%endmacro
   981                              <1> %else		; _LINK
   982                              <1> 	%idefine dualcall dualcall_with_filename __FILE__,
   983                              <1> 	%imacro dualcall_with_filename 2.nolist
   984                              <1> %ifndef SECTION_OF_%2
   985                              <1>  %error Unknown target section for symbol %2
   986                              <1> %endif
   987                              <1> %ifidni %[SECTION_OF_%2], _CURRENT_SECTION
   988                              <1> 	push cs
   989                              <1> 	call %2
   990                              <1> %else
   991                              <1> 	call relocatedzero:%2
   992                              <1> %ifidn _CURRENT_SECTION, lDEBUG_CODE
   993                              <1>  wllist Lrelocate_from_code, equ $ - 2, %1
   994                              <1> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
   995                              <1>  wllist Lrelocate_from_code2, equ $ - 2, %1
   996                              <1> %else
   997                              <1>  %error Wrong section
   998                              <1> %endif
   999                              <1> %endif
  1000                              <1> 	%endmacro
  1001                              <1> %endif		; _LINK
  1002                              <1>  %if _DUALCODENEARDUAL
  1003                              <1> 
  1004                              <1> %if _LINK
  1005                              <1> 	%idefine nearcall nearcall_with_filename __FILE__,
  1006                              <1> 	%imacro nearcall_with_filename 2
  1007                              <1> %ifndef SECTION_OF_%2
  1008                              <1>  %error Unknown target section for symbol %2
  1009                              <1> %endif
  1010                              <1> %ifidni %[SECTION_OF_%2], _CURRENT_SECTION
  1011                              <1> 	call %2
  1012                              <1> %else
  1013                              <1>  %push
  1014                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1015                              <1>  %xdefine %$targetsection SECTION_OF_%2
  1016                              <1>  %deftok %%filenametoken SOURCEFILENAME
  1017                              <1>   %ifndef NEARCALL_THUNK_TO_%2%[%%filenametoken]
  1018                              <1> 	hiddenusesection %$targetsection
  1019                              <1> %define NEARCALL_THUNK_TO_%2%[%%filenametoken] %%nearcall_thunk_to_%2%[%%filenametoken]
  1020                              <1> section_of %%nearcall_thunk_to_%2%[%%filenametoken]
  1021                              <1> dualfunction
  1022                              <1> %%nearcall_thunk_to_%2%[%%filenametoken]:
  1023                              <1> 	call %2
  1024                              <1> 	dualreturn
  1025                              <1> 	retf
  1026                              <1> 
  1027                              <1> 	hiddenusesection %$originalsection
  1028                              <1>   %endif
  1029                              <1>  %pop
  1030                              <1> 	dualcall_with_filename %1, NEARCALL_THUNK_TO_%2%[%%filenametoken]
  1031                              <1> %endif
  1032                              <1> 	%endmacro
  1033                              <1> %elif _LINK_COMPAT	; _LINK
  1034                              <1> 	%imacro nearcall 1
  1035                              <1> %ifndef SECTION_OF_%1
  1036                              <1>  %error Unknown target section for symbol %1
  1037                              <1> %endif
  1038                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1039                              <1> 	call %1
  1040                              <1> %else
  1041                              <1>  %push
  1042                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1043                              <1>  %xdefine %$targetsection SECTION_OF_%1
  1044                              <1>  %deftok %%filenametoken SOURCEFILENAME
  1045                              <1>   %ifndef NEARCALL_THUNK_TO_%1%[%%filenametoken]
  1046                              <1> 	hiddenusesection %$targetsection
  1047                              <1> %define NEARCALL_THUNK_TO_%1%[%%filenametoken] %%nearcall_thunk_to_%1%[%%filenametoken]
  1048                              <1> section_of %%nearcall_thunk_to_%1%[%%filenametoken]
  1049                              <1> dualfunction
  1050                              <1> %%nearcall_thunk_to_%1%[%%filenametoken]:
  1051                              <1> 	call %1
  1052                              <1> 	dualreturn
  1053                              <1> 	retf
  1054                              <1> 
  1055                              <1> 	hiddenusesection %$originalsection
  1056                              <1>   %endif
  1057                              <1>  %pop
  1058                              <1> 	dualcall NEARCALL_THUNK_TO_%1%[%%filenametoken]
  1059                              <1> %endif
  1060                              <1> 	%endmacro
  1061                              <1> %else		; _LINK, _LINK_COMPAT
  1062                              <1> 	%imacro nearcall 1
  1063                              <1> %ifndef SECTION_OF_%1
  1064                              <1>  %error Unknown target section for symbol %1
  1065                              <1> %endif
  1066                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1067                              <1> 	call %1
  1068                              <1> %else
  1069                              <1>  %push
  1070                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1071                              <1>  %xdefine %$targetsection SECTION_OF_%1
  1072                              <1>   %ifndef NEARCALL_THUNK_TO_%1
  1073                              <1> 	hiddenusesection %$targetsection
  1074                              <1> %define NEARCALL_THUNK_TO_%1 %%nearcall_thunk_to_%1
  1075                              <1> section_of %%nearcall_thunk_to_%1
  1076                              <1> dualfunction
  1077                              <1> %%nearcall_thunk_to_%1:
  1078                              <1> 	call %1
  1079                              <1> 	dualreturn
  1080                              <1> 	retf
  1081                              <1> 
  1082                              <1> 	hiddenusesection %$originalsection
  1083                              <1>   %endif
  1084                              <1>  %pop
  1085                              <1> 	dualcall NEARCALL_THUNK_TO_%1
  1086                              <1> %endif
  1087                              <1> 	%endmacro
  1088                              <1> %endif		; _LINK, _LINK_COMPAT
  1089                              <1>  %else
  1090                              <1> 	%imacro nearcall 1.nolist
  1091                              <1> %ifndef SECTION_OF_%1
  1092                              <1>  %error Unknown target section for symbol %1
  1093                              <1> %endif
  1094                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1095                              <1> 	call %1
  1096                              <1> %else
  1097                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _nearcall_helper
  1098                              <1>  %if _DEBUG
  1099                              <1> 	jmp strict short %%skipdata
  1100                              <1>  %endif
  1101                              <1> 	dw %1
  1102                              <1> %%skipdata:
  1103                              <1> %endif
  1104                              <1> 	%endmacro
  1105                              <1>  %endif
  1106                              <1> %elif ! _DUALCODE
  1107                              <1> 
  1108                              <1> %idefine dualfunction comment
  1109                              <1> %idefine dualreturn
  1110                              <1> %idefine dualdistance near
  1111                              <1> 	%imacro dualcall 1.nolist
  1112                              <1> 	call %1
  1113                              <1> 	%endmacro
  1114                              <1> 	%imacro nearcall 1.nolist
  1115                              <1> 	call %1
  1116                              <1> 	%endmacro
  1117                              <1> %assign _SYMBOLICDUALCODE 0
  1118                              <1> %assign _SYMBOLASMDUALCODE 0
  1119                              <1> 
  1120                              <1> %else
  1121                              <1>  %error Unexpected defines
  1122                              <1> %endif
  1123                              <1> 
  1124                              <1> %ifn _SYMBOLICDUALCODE
  1125                              <1>  %assign _SYMBOLASMDUALCODE 0
  1126                              <1> %endif
  1127                              <1> 
  1128                              <1>  %if _SYMBOLIC && _DUALCODE && _SYMBOLASMDUALCODE
  1129                              <1> %idefine dual2function	dualfunction
  1130                              <1> %idefine dual2return	dualreturn
  1131                              <1> %idefine dual2distance	dualdistance
  1132                              <1> %idefine dual2call	dualcall
  1133                              <1>  %else
  1134                              <1> %idefine dual2function comment
  1135                              <1> %idefine dual2return
  1136                              <1> %idefine dual2distance near
  1137                              <1> 	%imacro dual2call 1.nolist
  1138                              <1> 	call %1
  1139                              <1> 	%endmacro
  1140                              <1>  %endif
  1141                              <1> 
  1142                              <1> 
  1143                              <1> 	numdef CHECKSECTION, 0
  1144                              <1> 	numdef CHECKCALLSECTION, _CHECKSECTION
  1145                              <1> 	numdef CHECKJMPSECTION, _CHECKSECTION
  1146                              <1> 	numdef CHECKJCCSECTION, _CHECKSECTION
  1147                              <1> 
  1148                              <1> %if _CHECKCALLSECTION
  1149                              <1> 	%imacro call 1.nolist
  1150                              <1> 	%? %1
  1151                              <1> checksection %1, %?, call
  1152                              <1> 	%endmacro
  1153                              <1> %endif
  1154                              <1> %if _CHECKJMPSECTION
  1155                              <1> 	%imacro jmp 1.nolist
  1156                              <1> 	%? %1
  1157                              <1> checksection %1, %?, jmp
  1158                              <1> 	%endmacro
  1159                              <1> %endif
  1160                              <1> %if _CHECKJCCSECTION
  1161                              <1> 	%imacro je 1.nolist
  1162                              <1> 	%? %1
  1163                              <1> checksection %1, %?, jcc
  1164                              <1> 	%endmacro
  1165                              <1> 	%imacro jne 1.nolist
  1166                              <1> 	%? %1
  1167                              <1> checksection %1, %?, jcc
  1168                              <1> 	%endmacro
  1169                              <1> 	%imacro jz 1.nolist
  1170                              <1> 	%? %1
  1171                              <1> checksection %1, %?, jcc
  1172                              <1> 	%endmacro
  1173                              <1> 	%imacro jnz 1.nolist
  1174                              <1> 	%? %1
  1175                              <1> checksection %1, %?, jcc
  1176                              <1> 	%endmacro
  1177                              <1> 
  1178                              <1> 	%imacro jb 1.nolist
  1179                              <1> 	%? %1
  1180                              <1> checksection %1, %?, jcc
  1181                              <1> 	%endmacro
  1182                              <1> 	%imacro jnb 1.nolist
  1183                              <1> 	%? %1
  1184                              <1> checksection %1, %?, jcc
  1185                              <1> 	%endmacro
  1186                              <1> 	%imacro jbe 1.nolist
  1187                              <1> 	%? %1
  1188                              <1> checksection %1, %?, jcc
  1189                              <1> 	%endmacro
  1190                              <1> 	%imacro jnbe 1.nolist
  1191                              <1> 	%? %1
  1192                              <1> checksection %1, %?, jcc
  1193                              <1> 	%endmacro
  1194                              <1> 	%imacro jc 1.nolist
  1195                              <1> 	%? %1
  1196                              <1> checksection %1, %?, jcc
  1197                              <1> 	%endmacro
  1198                              <1> 	%imacro jnc 1.nolist
  1199                              <1> 	%? %1
  1200                              <1> checksection %1, %?, jcc
  1201                              <1> 	%endmacro
  1202                              <1> 	%imacro ja 1.nolist
  1203                              <1> 	%? %1
  1204                              <1> checksection %1, %?, jcc
  1205                              <1> 	%endmacro
  1206                              <1> 	%imacro jna 1.nolist
  1207                              <1> 	%? %1
  1208                              <1> checksection %1, %?, jcc
  1209                              <1> 	%endmacro
  1210                              <1> 	%imacro jae 1.nolist
  1211                              <1> 	%? %1
  1212                              <1> checksection %1, %?, jcc
  1213                              <1> 	%endmacro
  1214                              <1> 	%imacro jnae 1.nolist
  1215                              <1> 	%? %1
  1216                              <1> checksection %1, %?, jcc
  1217                              <1> 	%endmacro
  1218                              <1> 
  1219                              <1> 	%imacro jl 1.nolist
  1220                              <1> 	%? %1
  1221                              <1> checksection %1, %?, jcc
  1222                              <1> 	%endmacro
  1223                              <1> 	%imacro jnl 1.nolist
  1224                              <1> 	%? %1
  1225                              <1> checksection %1, %?, jcc
  1226                              <1> 	%endmacro
  1227                              <1> 	%imacro jle 1.nolist
  1228                              <1> 	%? %1
  1229                              <1> checksection %1, %?, jcc
  1230                              <1> 	%endmacro
  1231                              <1> 	%imacro jnle 1.nolist
  1232                              <1> 	%? %1
  1233                              <1> checksection %1, %?, jcc
  1234                              <1> 	%endmacro
  1235                              <1> 	%imacro jg 1.nolist
  1236                              <1> 	%? %1
  1237                              <1> checksection %1, %?, jcc
  1238                              <1> 	%endmacro
  1239                              <1> 	%imacro jng 1.nolist
  1240                              <1> 	%? %1
  1241                              <1> checksection %1, %?, jcc
  1242                              <1> 	%endmacro
  1243                              <1> 	%imacro jge 1.nolist
  1244                              <1> 	%? %1
  1245                              <1> checksection %1, %?, jcc
  1246                              <1> 	%endmacro
  1247                              <1> 	%imacro jnge 1.nolist
  1248                              <1> 	%? %1
  1249                              <1> checksection %1, %?, jcc
  1250                              <1> 	%endmacro
  1251                              <1> 
  1252                              <1> 	%imacro jo 1.nolist
  1253                              <1> 	%? %1
  1254                              <1> checksection %1, %?, jcc
  1255                              <1> 	%endmacro
  1256                              <1> 	%imacro jno 1.nolist
  1257                              <1> 	%? %1
  1258                              <1> checksection %1, %?, jcc
  1259                              <1> 	%endmacro
  1260                              <1> 	%imacro jp 1.nolist
  1261                              <1> 	%? %1
  1262                              <1> checksection %1, %?, jcc
  1263                              <1> 	%endmacro
  1264                              <1> 	%imacro jnp 1.nolist
  1265                              <1> 	%? %1
  1266                              <1> checksection %1, %?, jcc
  1267                              <1> 	%endmacro
  1268                              <1> 	%imacro jpe 1.nolist
  1269                              <1> 	%? %1
  1270                              <1> checksection %1, %?, jcc
  1271                              <1> 	%endmacro
  1272                              <1> 	%imacro jnpe 1.nolist
  1273                              <1> 	%? %1
  1274                              <1> checksection %1, %?, jcc
  1275                              <1> 	%endmacro
  1276                              <1> 	%imacro jpo 1.nolist
  1277                              <1> 	%? %1
  1278                              <1> checksection %1, %?, jcc
  1279                              <1> 	%endmacro
  1280                              <1> 	%imacro jnpo 1.nolist
  1281                              <1> 	%? %1
  1282                              <1> checksection %1, %?, jcc
  1283                              <1> 	%endmacro
  1284                              <1> 	%imacro js 1.nolist
  1285                              <1> 	%? %1
  1286                              <1> checksection %1, %?, jcc
  1287                              <1> 	%endmacro
  1288                              <1> 	%imacro jns 1.nolist
  1289                              <1> 	%? %1
  1290                              <1> checksection %1, %?, jcc
  1291                              <1> 	%endmacro
  1292                              <1> 
  1293                              <1> 	%imacro jcxz 1.nolist
  1294                              <1> 	%? %1
  1295                              <1> checksection %1, %?, jcc
  1296                              <1> 	%endmacro
  1297                              <1> 	%imacro jecxz 1.nolist
  1298                              <1> 	%? %1
  1299                              <1> checksection %1, %?, jcc
  1300                              <1> 	%endmacro
  1301                              <1> 	%imacro loop 1.nolist
  1302                              <1> 	%? %1
  1303                              <1> checksection %1, %?, jcc
  1304                              <1> 	%endmacro
  1305                              <1> 	%imacro loopz 1.nolist
  1306                              <1> 	%? %1
  1307                              <1> checksection %1, %?, jcc
  1308                              <1> 	%endmacro
  1309                              <1> 	%imacro loopnz 1.nolist
  1310                              <1> 	%? %1
  1311                              <1> checksection %1, %?, jcc
  1312                              <1> 	%endmacro
  1313                              <1> 	%imacro loope 1.nolist
  1314                              <1> 	%? %1
  1315                              <1> checksection %1, %?, jcc
  1316                              <1> 	%endmacro
  1317                              <1> 	%imacro loopne 1.nolist
  1318                              <1> 	%? %1
  1319                              <1> checksection %1, %?, jcc
  1320                              <1> 	%endmacro
  1321                              <1> %endif
  1322                              <1> 
  1323                              <1> 	%imacro checksection 3.nolist
  1324                              <1> %push
  1325                              <1>  %defstr %$string %1
  1326                              <1>  %substr %$shortword %$string 1, 5
  1327                              <1>  %substr %$shortsep %$string 6, 1
  1328                              <1>  %substr %$nearword %$string 1, 4
  1329                              <1>  %substr %$nearsep %$string 5, 1
  1330                              <1>  %substr %$farword %$string 1, 3
  1331                              <1>  %substr %$farsep %$string 4, 1
  1332                              <1>  %assign %$isshort 0
  1333                              <1>  %ifidni %$shortword, "short"
  1334                              <1>   %if %$shortsep == 32 || %$shortsep == 9
  1335                              <1>    %assign %$isshort 1
  1336                              <1>    %substr %$string %$string 7, -1
  1337                              <1>   %elif %$shortsep == '['
  1338                              <1>    %assign %$isshort 1
  1339                              <1>    %substr %$string %$string 6, -1
  1340                              <1>   %endif
  1341                              <1>  %endif
  1342                              <1>  %assign %$isnear 0
  1343                              <1>  %ifidni %$nearword, "near"
  1344                              <1>   %if %$nearsep == 32 || %$nearsep == 9
  1345                              <1>    %assign %$isnear 1
  1346                              <1>    %substr %$string %$string 6, -1
  1347                              <1>   %elif %$nearsep == '['
  1348                              <1>    %assign %$isnear 1
  1349                              <1>    %substr %$string %$string 5, -1
  1350                              <1>   %endif
  1351                              <1>  %endif
  1352                              <1>  %assign %$isfar 0
  1353                              <1>  %ifidni %$farword, "far"
  1354                              <1>   %if %$farsep == 32 || %$farsep == 9
  1355                              <1>    %assign %$isfar 1
  1356                              <1>    %substr %$string %$string 5, -1
  1357                              <1>   %elif %$farsep == '['
  1358                              <1>    %assign %$isfar 1
  1359                              <1>    %substr %$string %$string 4, -1
  1360                              <1>   %endif
  1361                              <1>  %endif
  1362                              <1> 
  1363                              <1>  %deftok %$token %$string
  1364                              <1> 
  1365                              <1>  %assign %$size 2
  1366                              <1>  %assign %$isreg 0
  1367                              <1>  %assign %$exit 0
  1368                              <1>  %rep 2
  1369                              <1>   %ifn %$exit
  1370                              <1>    %if %$size == 2
  1371                              <1>     %define %$regnames "ax  cx  dx  bx  sp  bp  si  di  "
  1372                              <1>    %elif %$size == 4
  1373                              <1>     %define %$regnames "eax ecx edx ebx esp ebp esi edi "
  1374                              <1>    %endif
  1375                              <1>    %assign %$index 0
  1376                              <1>    %rep 8
  1377                              <1>     %ifn %$exit
  1378                              <1>      %substr %$reg %$regnames %$index * 4 + 1, 4
  1379                              <1>      %deftok %$reg %$reg
  1380                              <1>      %ifnempty %$reg
  1381                              <1>       %ifidni %$reg, %$token
  1382                              <1>        %assign %$isreg %$size
  1383                              <1>        %assign %$exit 1
  1384                              <1>        %exitrep
  1385                              <1>       %endif
  1386                              <1>      %endif
  1387                              <1>     %endif
  1388                              <1>     %assign %$index %$index + 1
  1389                              <1>    %endrep
  1390                              <1>    %if %$exit
  1391                              <1>     %exitrep
  1392                              <1>    %endif
  1393                              <1>    %assign %$size %$size * 2
  1394                              <1>   %endif
  1395                              <1>  %endrep
  1396                              <1> 
  1397                              <1>  %assign %$ismulti 0
  1398                              <1>  %assign %$ismem 0
  1399                              <1>  %strlen %$length %$string
  1400                              <1>  %assign %$ii 0
  1401                              <1>  %rep %$length
  1402                              <1>   %substr %$point %$string %$ii + 1, 1
  1403                              <1>   %if %$point == 32 || %$point == 9
  1404                              <1>    %assign %$ismulti 1
  1405                              <1>   %endif
  1406                              <1>   %ifidn %$point, '['
  1407                              <1>    %assign %$ismem 1
  1408                              <1>   %endif
  1409                              <1>   %assign %$ii %$ii + 1
  1410                              <1>  %endrep
  1411                              <1> 
  1412                              <1>  %assign %$islocal 0
  1413                              <1>  %substr %$point %$string 1, 1
  1414                              <1>  %substr %$prefix %$string 1, 3
  1415                              <1>  %ifidn %$point, '.'
  1416                              <1>   %ifnidn %$prefix, '..@'
  1417                              <1>    %assign %$islocal 1
  1418                              <1>   %endif
  1419                              <1>  %endif
  1420                              <1> 
  1421                              <1>  %if %$isreg
  1422                              <1>   %if %$isreg == 4
  1423                              <1>    %warning 32-bit reg %3: %2 %1
  1424                              <1>   %else
  1425                              <1>    %warning 16-bit reg %3: %2 %1
  1426                              <1>   %endif
  1427                              <1>  %elif %$ismulti || %$ismem
  1428                              <1>   %warning not single %3: %2 %1
  1429                              <1>  %elif %$islocal
  1430                              <1>   %ifidni %3, call
  1431                              <1>    %warning local %3: %2 %1
  1432                              <1>   %endif
  1433                              <1>  %elifdef SECTION_OF_%[%$token]
  1434                              <1>   %ifnidni SECTION_OF_%[%$token], _CURRENT_SECTION
  1435                              <1>    %error Symbol %$token called wrongly: section_of=SECTION_OF_%[%$token], current=_CURRENT_SECTION
  1436                              <1>   %endif
  1437                              <1>  %endif
  1438                              <1> %pop
  1439                              <1> 	%endmacro
  1440                              <1> 
  1441                              <1> 
  1442                              <1> 	struc MEMREF
  1443 00000000 ????????            <1> mrLinear:		resd 1
  1444 00000004 ????????            <1> mrOffset:		resd 1
  1445 00000008 ????                <1> mrSegmentSelector:	resw 1
  1446 0000000A ????                <1> mrFlags:		resw 1
  1447 0000000C ????????            <1> mrLength:		resd 1
  1448                              <1> 	endstruc
  1449                              <1> 
  1450                              <1> 		; Currently only direct branches are allowed when
  1451                              <1> 		;  disassembling from the U command. (That is,
  1452                              <1> 		;  [disflags] & DIS_F_SHOW is clear.) All other
  1453                              <1> 		;  types of references depend on segment registers
  1454                              <1> 		;  and sometimes base and index registers, which are
  1455                              <1> 		;  not known ahead of time. They are only known for
  1456                              <1> 		;  the R command's disassembly. (DIS_F_SHOW set.)
  1457                              <1> 		; (When a mov ss or pop to ss will change ss, a
  1458                              <1> 		;  subsequent instruction using ss will not be
  1459                              <1> 		;  disassembled with the correct ss value.
  1460                              <1> 		;  This should be rare though. We may at a later
  1461                              <1> 		;  point detect this condition and not display
  1462                              <1> 		;  references with ss then.)
  1463                              <1> mrfBranchDirect:	equ    1
  1464                              <1> mrfMem:			equ    2
  1465                              <1> mrfMemSource:		equ    4
  1466                              <1> mrfMemDest:		equ    8
  1467                              <1> mrfA32:			equ   10h
  1468                              <1> mrfString:		equ   20h
  1469                              <1> mrfStringSource:	equ   40h
  1470                              <1> mrfStringDest:		equ   80h
  1471                              <1> mrfUsesSS:		equ  100h
  1472                              <1> mrfBranchIndirect:	equ  200h
  1473                              <1> 
  1474                              <1> 
  1475                              <1> %if _VXCHG && ! _VXCHGBIOS
  1476                              <1> 	struc XMSM
  1477 00000000 ????????            <1> .size_:		resd 1
  1478 00000004 ????                <1> .srchdl:	resw 1
  1479 00000006 ????????            <1> .srcadr:	resd 1
  1480 0000000A ????                <1> .dsthdl:	resw 1
  1481 0000000C ????????            <1> .dstadr:	resd 1
  1482                              <1> 	endstruc
  1483                              <1> %endif
  1484                              <1> 
  1485                              <1> 
  1486                              <1> 	; doscall is used by symbols.asm and run.asm and in
  1487                              <1> 	;  cmd3_close_handle, so define it prior
  1488                              <1> %if _PM && _NOEXTENDER
  1489                              <1> %macro doscall 0
  1490                              <1> 	nearcall _doscall
  1491                              <1> %endmacro
  1492                              <1> %else
  1493                              <1> 		; When we don't support non-extended DPMI all Int21 calls
  1494                              <1> 		; are either in Real Mode or extended (all are real Int21
  1495                              <1> 		; instructions).
  1496                              <1> %macro doscall 0
  1497                              <1> 	int 21h
  1498                              <1> %endmacro
  1499                              <1> %endif
  1500                              <1> 
  1501                              <1> 
  1502                              <1> %if _LINK
  1503                              <1> %imacro wlcalc 1-2.nolist
  1504                              <1> %deftok %%filenametoken __FILE__
  1505                              <1>  global wlcalc_%1?%[%%l]%[%%filenametoken]
  1506                              <1> wlcalc_%1?%[%%l]%[%%filenametoken]: %2
  1507                              <1> %endmacro
  1508                              <1> %endif
  1509                              <1> 
  1510                              <1> %if _BOOTLDR && _LINK
  1511                              <1> %macro lot_equate 2.nolist
  1512                              <1> LOAD_%2 equ %1
  1513                              <1> %endmacro
  1514                              <1> 
  1515                              <1> 	lot_equate    1, SET_DL_UNIT
  1516                              <1> 	lot_equate    2, SET_BL_UNIT
  1517                              <1> 	lot_equate    4, SET_SIDI_CLUSTER
  1518                              <1> 	lot_equate  10h, SET_DSSI_DPT
  1519                              <1> 	lot_equate  20h, PUSH_DPT
  1520                              <1> 	lot_equate  40h, DATASTART_HIDDEN
  1521                              <1> 	lot_equate  80h, SET_AXBX_DATASTART
  1522                              <1> 	lot_equate 100h, SET_DSBP_BPB
  1523                              <1> 	lot_equate 200h, LBA_SET_TYPE
  1524                              <1> 	lot_equate 400h, MESSAGE_TABLE
  1525                              <1> 	lot_equate 800h, SET_AXBX_ROOT_HIDDEN
  1526                              <1> 	lot_equate 1000h, CMDLINE
  1527                              <1> 	lot_equate 2000h, NO_BPB
  1528                              <1> 	lot_equate 4000h, SET_DSSI_PARTINFO
  1529                              <1> %endif
  1530                              <1> 
  1531                              <1> %if _HELP_COMPRESSED
  1532                              <1>  %assign NONCOMPRESSEDFLAG 1
  1533                              <1> %else
  1534                              <1>  %assign NONCOMPRESSEDFLAG 0
  1535                              <1> %endif
  1536                              <1> 
  1537                              <1> [list +]
  1538                              <1> 
  1539                              <1> %if _LINK
  1540                              <1>  %if _ONLY386
  1541                              <1> 	cpu 386
  1542                              <1>  %else
  1543                              <1> 	cpu 8086
  1544                              <1>  %endif
  1545                              <1> 
  1546                              <1> auxbuff_size: equ (_AUXBUFFSIZE+15) & ~15
  1547                              <1> 	endarea auxbuff, 1
  1548                              <1> 
  1549                              <1> auxbuff_max_size: equ (_AUXBUFFMAXSIZE+15) & ~15
  1550                              <1> 	endarea auxbuff_max, 1
  1551                              <1> 
  1552                              <1> %if _INIT_MAX
  1553                              <1>  auxbuff_init_size: equ (_AUXBUFFMAXSIZE+15) & ~15
  1554                              <1> %else
  1555                              <1>  auxbuff_init_size: equ (_AUXBUFFSIZE+15) & ~15
  1556                              <1> %endif
  1557                              <1> 	endarea auxbuff_init, 1
  1558                              <1> 
  1559                              <1>  %include "options.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug options and internal flags
     5                              <2> 
     6                              <2> Copyright (C) 2008-2025 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 
    17                              <2> dispregs32	equ	  1	; RX: 32-bit register display (R, T/P/G)
    18                              <2> traceints	equ	  2	; TM: trace into interrupts (T)
    19                              <2> cpdepchars	equ	  4	; allow dumping of CP-dependent characters (D, DX)
    20                              <2> fakeindos	equ	  8	; always assume InDOS flag non-zero (all)
    21                              <2> nonpagingdevice	equ	 10h	; disallow paged output with [more] prompt (all exc. P, T)
    22                              <2> 	; This option was never used anywhere:
    23                              <2> ; pagingdevice	equ	 20h	; allow paged output with [more] prompt (all exc. P, T)
    24                              <2> 				; paged output is by default on if the output device is StdOut, else off
    25                              <2> hexrn		equ	 40h	; display raw hexadecimal content of FPU registers (RN)
    26                              <2> ;novdd		equ	 80h	; don't use a registered NTVDM VDD (L, W)
    27                              <2> nondospaging	equ	100h	; paging: don't use DOS for input when waiting for a key
    28                              <2> opt1_86mnohlt	equ	200h	; (86 Mode:) HLT doesn't work, don't use it
    29                              <2> biosidles	equ	400h	; don't idle with HLT or Int2F.1680, only call BIOS Int16.00
    30                              <2> opt_usegetinput	equ	800h	; use getinput for int 21h interactive input
    31                              <2> use_si_units	equ    1000h	; in disp_*_size use SI units (kB = 1000, etc)
    32                              <2> use_jedec_units	equ    2000h	; in disp_*_size use JEDEC units (kB = 1024)
    33                              <2> enable_serial	equ    4000h	; enable serial I/O (preferred over DOS or BIOS terminal)
    34                              <2> int8_disable_serial equ	   8000h	; disable serial I/O when breaking due to intr8
    35                              <2> gg_do_not_skip_bp equ	 1_0000h	; gg: do not skip a breakpoint (bb or gg)
    36                              <2> gg_no_autorepeat equ	 2_0000h	; gg: do not auto-repeat
    37                              <2> tp_do_not_skip_bp equ	 4_0000h	; T/TP/P: do not skip a (bb) breakpoint
    38                              <2> gg_bb_hit_no_repeat equ	 8_0000h	; gg: do not auto-repeat after bb hit
    39                              <2> tp_bb_hit_no_repeat equ	10_0000h	; T/TP/P: do not auto-repeat after bb hit
    40                              <2> gg_unexpected_no_repeat equ 20_0000h	; gg: do not auto-repeat after unexpectedinterrupt
    41                              <2> tp_unexpected_no_repeat equ 40_0000h	; T/TP/P
    42                              <2> ss_no_dump:		equ 80_0000h
    43                              <2> %if _SYMBOLIC
    44                              <2> dd_no_blanks_sym:	equ 100_0000h
    45                              <2> zz_no_pm_xms:		equ 200_0000h
    46                              <2> %endif
    47                              <2> rr_disasm_no_rept:	equ 1000_0000h
    48                              <2> rr_disasm_no_show:	equ 2000_0000h
    49                              <2> opt_cmdline_quiet_input:equ 4000_0000h
    50                              <2> opt_cmdline_quiet_output:equ 8000_0000h
    51                              <2> %if _SYMBOLIC
    52                              <2> DEFAULTOPTIONS	equ zz_no_pm_xms
    53                              <2> %else
    54                              <2> DEFAULTOPTIONS	equ 0
    55                              <2> %endif
    56                              <2> 
    57                              <2> 
    58                              <2> opt2_db_header:		equ 1
    59                              <2> opt2_db_trailer:	equ 2
    60                              <2> opt2_dw_header:		equ 10h
    61                              <2> opt2_dw_trailer:	equ 20h
    62                              <2> opt2_dd_header:		equ 100h
    63                              <2> opt2_dd_trailer:	equ 200h
    64                              <2> opt2_getinput_dpmi:	equ 800h
    65                              <2> opt2_hh_compat:		equ 1000h
    66                              <2> opt2_getc_idle:		equ 2000h
    67                              <2> opt2_getc_idle_dpmi:	equ 4000h
    68                              <2> opt2_re_cancel_tpg:	equ 8000h
    69                              <2> opt2_nn_compat:		equ 1_0000h
    70                              <2> opt2_nn_capitalise:	equ 2_0000h
    71                              <2> %if _MS_0RANGE_COMPAT
    72                              <2> opt2_0range_compat:	equ 4_0000h
    73                              <2> %endif
    74                              <2> opt2_rr16_compat:	equ 8_0000h
    75                              <2> opt2_r_prompt_compat:	equ 10_0000h
    76                              <2> opt2_r_separate:	equ 20_0000h
    77                              <2> opt2_r_linebreak_always:equ 40_0000h
    78                              <2> opt2_dpminohlt:		equ 8000_0000h	; DPMI doesn't like hlt
    79                              <2> DEFAULTOPTIONS2	equ opt2_dw_header | opt2_dd_header | opt2_getc_idle_dpmi | opt2_dpminohlt
    80                              <2> 
    81                              <2> 
    82                              <2> opt3_tt_no_paging:	equ 1
    83                              <2> opt3_tp_no_paging:	equ 2
    84                              <2> opt3_pp_no_paging:	equ 4
    85                              <2> opt3_gg_no_paging:	equ 8
    86                              <2> opt3_silence_paging_set:equ 100h
    87                              <2> opt3_silence_paging_on:	equ 200h
    88                              <2> opt3_paging_rc:		equ 1000h
    89                              <2> opt3_paging_yy:		equ 2000h
    90                              <2> opt3_paging_re:		equ 4000h
    91                              <2> opt3_r_highlight_diff:	equ 10000h
    92                              <2> opt3_r_highlight_dumb:	equ 20000h
    93                              <2> opt3_r_highlight_full:	equ 40000h
    94                              <2> opt3_r_highlight_eip:	equ 80000h
    95                              <2> %if _PM
    96                              <2> opt3_ss_b_bit_set:	equ   10_0000h
    97                              <2>  %if _BREAK_INSTALLDPMI
    98                              <2> opt3_break_installdpmi:	equ   20_0000h
    99                              <2>  %endif
   100                              <2> %endif
   101                              <2> %if _DHIGHLIGHT
   102                              <2> opt3_d_highlight:	equ   80_0000h
   103                              <2> %endif
   104                              <2> %if _GETLINEHIGHLIGHT
   105                              <2> opt3_getline_highlight:	equ  100_0000h
   106                              <2> %endif
   107                              <2> opt3_no_idle_2F:	equ  200_0000h
   108                              <2> %if _DELAY_BEFORE_BP
   109                              <2> opt3_delay_before_bp:	equ  400_0000h
   110                              <2> %endif
   111                              <2> opt3_no_call_amis:	equ  800_0000h
   112                              <2> opt3_disable_autorepeat:equ 1000_0000h
   113                              <2> opt3_check_ctrlc_keyb:	equ 2000_0000h
   114                              <2> opt3_check_ctrlc_0bh:	equ 4000_0000h
   115                              <2> opt3_tsr_quit_leave_tf:	equ 8000_0000h
   116                              <2> DEFAULTOPTIONS3	equ opt3_tt_no_paging | opt3_tp_no_paging 		| opt3_pp_no_paging | opt3_gg_no_paging 		| opt3_check_ctrlc_keyb | opt3_check_ctrlc_0bh
   119                              <2> 
   120                              <2> 
   121                              <2> opt4_int_2F_hook:	equ 2
   122                              <2> opt4_int_08_hook:	equ 4
   123                              <2> opt4_int_2D_hook:	equ 8
   124                              <2> %if _CATCHINTFAULTCOND
   125                              <2> opt4_int_fault_hook:	equ 10h
   126                              <2> %endif
   127                              <2> opt4_int_serial_force:	equ 1_0000h
   128                              <2> opt4_int_2F_force:	equ 2_0000h
   129                              <2> opt4_int_08_force:	equ 4_0000h
   130                              <2> opt4_int_2D_force:	equ 8_0000h
   131                              <2> %if _CATCHINT0D
   132                              <2> opt4_int_0D_force:	equ   10_0000h
   133                              <2> %endif
   134                              <2> %if _CATCHINT0C
   135                              <2> opt4_int_0C_force:	equ   20_0000h
   136                              <2> %endif
   137                              <2> opt4_int_00_force:	equ  100_0000h
   138                              <2> opt4_int_01_force:	equ  200_0000h
   139                              <2> opt4_int_03_force:	equ  400_0000h
   140                              <2> opt4_int_06_force:	equ  800_0000h
   141                              <2> opt4_int_18_force:	equ 1000_0000h
   142                              <2> opt4_int_19_force:	equ 2000_0000h
   143                              <2> opt4_int_09_force:	equ 4000_0000h	; not used at the same time as 15h
   144                              <2> opt4_int_15_force:	equ 4000_0000h	; not used at the same time as 09h
   145                              <2> opt4_int_07_force:	equ 8000_0000h
   146                              <2> DEFAULTOPTIONS4 equ opt4_int_2F_hook
   147                              <2> 
   148                              <2> 
   149                              <2> %if _VXCHG
   150                              <2> opt6_vv_mode:		equ 1
   151                              <2> opt6_vv_keep:		equ 2
   152                              <2> opt6_vv_int16:		equ 10h
   153                              <2>  %if _VXCHG_DEFAULT_ON
   154                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq | opt6_vv_mode
   155                              <2>  %else
   156                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq
   157                              <2>  %endif
   158                              <2> %else
   159                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq
   160                              <2> %endif
   161                              <2> %if _DEBUG
   162                              <2> opt6_debug_exception_late:	equ  20h
   163                              <2> opt6_debug_exception_early:	equ  40h
   164                              <2>  %if _DEBUG_COND
   165                              <2> opt6_debug_exception:	equ  80h
   166                              <2> opt6_debug_mode:	equ 100h
   167                              <2>  %endif
   168                              <2> %endif
   169                              <2> opt6_bios_output:	equ 200h
   170                              <2> opt6_flat_binary:	equ 400h
   171                              <2> opt6_big_stack:		equ 800h
   172                              <2> opt6_40_columns:	equ 1000h
   173                              <2> opt6_40_indent_odd:	equ 2000h
   174                              <2> opt6_40_dash:		equ 4000h
   175                              <2> opt6_share_serial_irq:	equ 1_0000h
   176                              <2> opt6_serial_EOI_call:	equ 2_0000h
   177                              <2> %if _RH
   178                              <2> opt6_rh_mode:		equ 10_0000h
   179                              <2> %endif
   180                              <2> %if _DEBUG
   181                              <2> opt6_debug_putrunint_early:	equ  40_0000h
   182                              <2>  %if _DEBUG_COND
   183                              <2> opt6_debug_putrunint:		equ  80_0000h
   184                              <2>  %endif
   185                              <2> %endif
   186                              <2> opt6_bios_io:		equ 100_0000h
   187                              <2> opt6_immasm_display_uu:	equ 200_0000h
   188                              <2> opt6_immasm_debug:	equ 400_0000h
   189                              <2> opt6_immasm_flag:	equ 800_0000h
   190                              <2> opt6_immasm_nobranch:	equ 1000_0000h
   191                              <2> opt6_r_flags_style2:	equ 2000_0000h
   192                              <2> opt6_r_flags_style3:	equ 4000_0000h
   193                              <2> opt6_r_linebreak_conditional:	equ 8000_0000h
   194                              <2> 
   195                              <2> 
   196                              <2> DEFAULTOPTIONS7 equ opt7_no_tsr_ll
   197                              <2> opt7_no_free_oneshot_eld:	equ 1
   198                              <2> opt7_debug_optional_link:	equ 2
   199                              <2> opt7_quiet_install:		equ 4
   200                              <2> opt7_quick_run:			equ 8
   201                              <2> opt7_houdini:			equ 100h
   202                              <2> opt7_debug_run:			equ 200h
   203                              <2> opt7_no_ensure:			equ 1000h
   204                              <2> opt7_no_tsr_ll:			equ 2000h
   205                              <2> 
   206                              <2> 
   207                              <2> oldpacket	equ	  1	; Int25/Int26 packet method available (L, W)
   208                              <2> newpacket	equ	  2	; Int21.7305 packet method available (L, W)
   209                              <2> ntpacket	equ	  4	; VDD registered and usable (L, W)
   210                              <2> pagedcommand	equ	  8	; allows paging in puts
   211                              <2> notstdinput	equ	 10h	; DEBUG's StdIn isn't a device with StdIn bit (is file or other device)
   212                              <2> inputfile	equ	 20h	; DEBUG's StdIn is a file, notstdinput also set
   213                              <2> notstdoutput	equ	 40h	; DEBUG's StdOut isn't a device with StdOut bit (is file or other device)
   214                              <2> outputfile	equ	  80h	; DEBUG's StdOut is a file, notstdoutput also set
   215                              <2> hooked2F	equ	 100h	; Int2F hooked
   216                              <2> nohook2F	equ	 200h	; don't hook Int2F.1687 (required for Win9x, DosEmu?)
   217                              <2> unused_dif1_dpminohlt equ 400h	; DPMI doesn't like hlt
   218                              <2> protectedmode	equ	 800h	; in (DPMI) protected mode
   219                              <2> debuggeeA20	equ	1000h	; state of debuggee's A20
   220                              <2> debuggerA20	equ	2000h	; state of debugger's A20 (will be on if possible)
   221                              <2> nodosloaded	equ	4000h	; No DOS loaded currently (Boot loader mode)
   222                              <2> has386		equ	8000h	; CPU is a 386
   223                              <2> usecharcounter	equ    1_0000h	; don't reset charcounter between calls to puts
   224                              <2> runningnt	equ    2_0000h	; running in NTVDM
   225                              <2> canswitchmode	equ    4_0000h	; can switch modes (auxbuff large enough, DPMI mode switch set up)
   226                              <2> modeswitched	equ    8_0000h	; switched mode (now in the mode that we weren't entered in)
   227                              <2> promptwaiting	equ   10_0000h	; puts: any more output needs to display a prompt first
   228                              <2> switchbuffer	equ   20_0000h	; mode switch needs a buffer (auxbuff)
   229                              <2> tsrmode		equ   40_0000h	; in TSR mode; DPI and DPP not valid
   230                              <2> attachedterm	equ   80_0000h	; the attached process terminated
   231                              <2> runningdosemu	equ  100_0000h	; running in dosemu
   232                              <2> ; load_is_ldp	equ  200_0000h	; boot load: partition specified as "ldp"
   233                              <2> tt_while:	equ  400_0000h	; tt: while condition specified
   234                              <2> tt_p:		equ  800_0000h	; tt: proceed past repeated string instructions
   235                              <2> tt_silent_mode:	equ 1000_0000h	; tt: run should be silent (dump at end)
   236                              <2> tt_silence:	equ 2000_0000h	; tt: silent writing (write to auxbuff instead)
   237                              <2> tt_no_bb:	equ 4000_0000h	; tt: do not use bb breakpoints
   238                              <2> tt_no_bb_first:	equ 8000_0000h	; tt: do not use bb breakpoints at first
   239                              <2> 
   240                              <2> 
   241                              <2> dif2_gg_is_first:	equ   1
   242                              <2> dif2_gg_skip_non_cseip:	equ   2
   243                              <2> dif2_gg_skip_cseip:	equ   4
   244                              <2> dif2_gg_is_gg:		equ   8
   245                              <2> dif2_gg_first_detected:	equ  10h
   246                              <2> dif2_gg_again:		equ  20h
   247                              <2> dif2_tpg_proceed_bp_set:equ  40h
   248                              <2> dif2_tpg_keep_proceed_bp: equ 80h
   249                              <2> dif2_tpg_have_bp:	equ 100h
   250                              <2> dif2_tpg_adjusted_cseip:equ 200h
   251                              <2> dif2_tpg_do_not_adjust:	equ 400h
   252                              <2> dif2_bp_failure:	equ 800h
   253                              <2> dif2_is_pp:		equ 1000h
   254                              <2> %if _SYMBOLIC
   255                              <2> dif2_createdprocess:	equ 800_0000h	; created empty debuggee process
   256                              <2> dif2_sym_req_xms:	equ 2000h
   257                              <2> dif2_sym_req_86mm:	equ 4000h
   258                              <2> dif2_sym_req_mask equ dif2_sym_req_86mm | dif2_sym_req_xms
   259                              <2> dif2_no_pm_xms:		equ 1_0000h
   260                              <2> dif2_xms_detection_done:equ 2_0000h
   261                              <2> %endif
   262                              <2> %if _INPUT_FILE_HANDLES
   263                              <2> dif2_input_file:	equ 10_0000h
   264                              <2> dif2_closed_input_file:	equ 20_0000h
   265                              <2> %endif
   266                              <2> dif2_did_getline_file:	equ 40_0000h
   267                              <2> %if _SYMBOLIC
   268                              <2> dif2_poison:		equ 80_0000h
   269                              <2> %endif
   270                              <2> dif2_boot_loaded_kernel:equ 100_0000h
   271                              <2> %if _INPUT_FILE_BOOT
   272                              <2> dif2_input_file_boot:	equ 200_0000h
   273                              <2> dif2_closed_input_file_boot:	equ 400_0000h
   274                              <2> %endif
   275                              <2> dif2_in_silence_dump:	equ 1000_0000h
   276                              <2> dif2_int31_segment:	equ 2000_0000h
   277                              <2> dif2_nn_compat:		equ 4000_0000h
   278                              <2> dif2_nn_capitalise:	equ 8000_0000h
   279                              <2> 
   280                              <2> 
   281                              <2> dif3_load_is_ldp:	equ 1	; boot load: partition specified as "ldp"
   282                              <2> dif3_load_is_sdp:	equ 2	; boot load: partition specified as "sdp"
   283                              <2> dif3_load_is_ydp:	equ 4	; boot load: partition specified as "ydp"
   284                              <2> dif3_load_is_dp:	equ dif3_load_is_ldp 				| dif3_load_is_sdp 				| dif3_load_is_ydp
   287                              <2> dif3_load_dir_dir:	equ 8
   288                              <2> dif3_input_terminal_override:	equ 10h
   289                              <2> dif3_input_serial_override:	equ 20h
   290                              <2> dif3_if_not:		equ 40h
   291                              <2> dif3_partition_changed:	equ 80h
   292                              <2> ;
   293                              <2> dif3_input_cmdline:	equ 100h; input reading from cmdline_buffer
   294                              <2> dif3_input_cmdline_closed: equ 200h
   295                              <2> dif3_at_line_end:	equ 400h
   296                              <2> dif3_quiet_input_single:equ 800h
   297                              <2> dif3_quiet_output:	equ 1000h
   298                              <2> dif3_unquiet_error:	equ 2000h
   299                              <2> dif3_unquiet_prompt:	equ 4000h
   300                              <2> dif3_unquiet:		equ dif3_unquiet_error | dif3_unquiet_prompt
   301                              <2> dif3_return_eof:	equ 8000h
   302                              <2> dif3_highlighting:	equ 1_0000h
   303                              <2> dif3_do_not_highlight:	equ 2_0000h
   304                              <2> dif3_int10_highlight:	equ 2_0000h
   305                              <2> dif3_nosymbols_1:	equ 4_0000h
   306                              <2> dif3_nosymbols_2:	equ 8_0000h
   307                              <2> %if _PM
   308                              <2> dif3_ss_b_bit_set:	equ  10_0000h
   309                              <2> %endif
   310                              <2> dif3_gotint19:		equ  20_0000h
   311                              <2> dif3_prior_pm:		equ  40_0000h
   312                              <2> %if _DELAY_BEFORE_BP
   313                              <2> dif3_delayed		equ  80_0000h
   314                              <2> %endif
   315                              <2> dif3_input_re:		equ 100_0000h	; input reading from re_buffer
   316                              <2> dif3_input_re_closed:	equ 200_0000h
   317                              <2> dif3_accept_getrange_0:	equ 400_0000h
   318                              <2> %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
   319                              <2> dif3_in_if:		equ 800_0000h
   320                              <2> %endif
   321                              <2> dif3_auxbuff_guarded_1:	equ 1000_0000h
   322                              <2> dif3_auxbuff_guarded_2:	equ 2000_0000h
   323                              <2> dif3_auxbuff_guarded_3:	equ 4000_0000h
   324                              <2> dif3_sss_is_reverse:	equ 8000_0000h
   325                              <2> 
   326                              <2> 
   327                              <2> dif4_int_serial_hooked:	equ 1
   328                              <2> dif4_int_2F_hooked:	equ 2
   329                              <2> dif4_int_08_hooked:	equ 4
   330                              <2> dif4_int_2D_hooked:	equ 8
   331                              <2> %if _CATCHINTFAULTCOND && _CATCHINT0D
   332                              <2> dif4_int_0D_hooked:	equ 10h
   333                              <2> %endif
   334                              <2> %if _CATCHINTFAULTCOND && _CATCHINT0C
   335                              <2> dif4_int_0C_hooked:	equ 20h
   336                              <2> %endif
   337                              <2> %if _LOADER
   338                              <2> dif4_int_18_hooked:	equ 1000h
   339                              <2> dif4_int_19_hooked:	equ 2000h
   340                              <2> %endif
   341                              <2> 
   342                              <2> 
   343                              <2> %if _VXCHG
   344                              <2> dif6_vv_mode:		equ 1
   345                              <2> %endif
   346                              <2> dif6_in_hook2F:		equ 2
   347                              <2> dif6_in_amis_hook2F:	equ 4
   348                              <2> dif6_debug_mode:	equ 100h
   349                              <2> dif6_locked:		equ 200h
   350                              <2> dif6_mcp:		equ 400h
   351                              <2> %if _RH
   352                              <2> dif6_rh_mode_was:	equ  8_0000h
   353                              <2> dif6_rh_mode:		equ 10_0000h
   354                              <2> dif6_rh_mode_2:		equ 20_0000h
   355                              <2> %endif
   356                              <2> dif6_device_mode:	equ 40_0000h
   357                              <2> dif6_cpdepchars:	equ 80_0000h
   358                              <2> %if _IMMASM
   359                              <2> dif6_immasm_no_output:	equ 100_0000h
   360                              <2> dif6_immasm:		equ 200_0000h
   361                              <2> dif6_immasm_rel8:	equ 400_0000h
   362                              <2> %endif
   363                              <2> 
   364                              <2> 
   365                              <2> disasm_lowercase	equ 1
   366                              <2> disasm_commablank	equ 2
   367                              <2> disasm_nasm		equ 4
   368                              <2> disasm_lowercase_refmem:equ 8
   369                              <2> disasm_show_short:	equ 10h
   370                              <2> disasm_show_near:	equ 20h
   371                              <2> disasm_show_far:	equ 40h
   372                              <2> disasm_nec:		equ 80h
   373                              <2> disasm_40_columns:	equ 100h
   374                              <2> disasm_no_indent:	equ 200h
   375                              <2> disasm_msdebug_mnemonofs: equ 400h
   376                              <2> disasm_a16_memref:	equ 1000h
   377                              <2> disasm_a32_memref:	equ 2000h
   378                              <2> disasm_a16_string:	equ 4000h
   379                              <2> disasm_a32_string:	equ 8000h
   380                              <2> disasm_hide_modrm:	equ 10000h
   381                              <2> disasm_asize_loop_nasm:	equ 20000h
   382                              <2> disasm_modrm_always:	equ 40000h
   383                              <2> DEFAULTASMOPTIONS equ disasm_lowercase|disasm_commablank|disasm_nasm 	| disasm_a16_memref | disasm_a32_memref 	| disasm_a16_string | disasm_a32_string
   386                              <2> 
   387                              <2> 	; serial_flags values
   388                              <2> sf_init_done:	equ 1
   389                              <2> sf_ctrl_c:	equ 2
   390                              <2> sf_double_ctrl_c:	equ 4
   391                              <2> sf_built_in_fifo:	equ 8
   392                              <2> sf_use_serial:		equ 10h
  1560                              <1> %endif
    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 [4405]                  	dw bootcmd.list
   181 0000056E [0000]                  	dw msg.list
   182 00000570 [7300]                  	dw bootcmd.quit
   183 00000572 [0000]                  	dw msg.quit
   184 00000574 [6409]                  	dw boot_read
   185 00000576 [0000]                  	dw msg.read
   186 00000578 [6C09]                  	dw boot_write
   187 0000057A [0000]                  	dw msg.write
   188 0000057C [1D12]                  	dw boot_dir
   189 0000057E [0000]                  	dw msg.dir
   190 00000580 [A900]                  	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 00000047 E8(0000)                	call ispm
   200 0000004A 750C                    	jnz .rm
   201 0000004C BA[0000]                	mov dx, nopmsupp
   202 0000004F B80102                  	mov ax, 0201h
   203 00000052 E8(0000)                	call setrc
   204 00000055 E9(0000)                	jmp putsz_error
   205                                  .rm:
   206                                  %endif
   207                                  d4	call d4message
   208                                  d4	asciz "In bootcmd",13,10
   209                                  
   210 00000058 E8A5FF                  	call init_bootcmd
   211                                  
   212 0000005B E8(0000)                	call skipcomma
   213 0000005E 4E                      	dec si
   214 0000005F BB[6C05]                	mov bx, bootcmd_dispatch
   215                                  @@:
   216 00000062 8B0F                    	mov cx, [bx]
   217 00000064 8B5702                  	mov dx, [bx + 2]
   218 00000067 83C304                  	add bx, 4
   219 0000006A E370                    	jcxz .notproto
   220 0000006C E8(0000)                	call isstring?
   221 0000006F 75F1                    	jne @B
   222 00000071 FFE1                    	jmp cx
   223                                  
   224                                  
   225                                  .quit:
   226                                   %if _DOSEMU
   227 00000073 F606[0300]01            	testopt [internalflags], runningdosemu
   228 00000078 7407                    	jz .quit_not_dosemu
   229                                  
   230 0000007A 31DB                    	xor bx, bx
   231 0000007C B8FFFF                  	mov ax, -1
   232 0000007F CDE6                    	int 0E6h			; dosemu quit
   233                                  
   234                                  .quit_not_dosemu:
   235                                   %endif
   236                                  
   237                                  ; from https://stackoverflow.com/a/5240330/738287
   238 00000081 B80153                  	mov ax, 5301h
   239 00000084 31DB                    	xor bx, bx
   240 00000086 CD15                    	int 15h				; connect to APM API
   241                                  
   242 00000088 B80E53                  	mov ax, 530Eh
   243 0000008B 31DB                    	xor bx, bx
   244 0000008D B90201                  	mov cx, 0102h
   245 00000090 CD15                    	int 15h				; set APM version to 1.02
   246                                  
   247 00000092 B80753                  	mov ax, 5307h
   248 00000095 BB0100                  	mov bx, 1
   249 00000098 B90300                  	mov cx, 3
   250 0000009B CD15                    	int 15h				; shut down system
   251                                  
   252 0000009D BA[0000]                	mov dx, msg.boot_quit_fail
   253 000000A0 B80202                  	mov ax, 0202h
   254 000000A3 E8(0000)                	call setrc
   255 000000A6 E9(0000)                	jmp putsz_error
   256                                  
   257                                  
   258                                  .protocol:
   259 000000A9 E8(0000)                	call skipequals
   260 000000AC 4E                      	dec si
   261 000000AD BA[0000]                	mov dx, msg.sector
   262 000000B0 E8(0000)                	call isstring?
   263 000000B3 7423                    	je .proto_sector
   264                                  
   265 000000B5 BA[0000]                	mov dx, msg.sector_alt
   266 000000B8 E8(0000)                	call isstring?
   267 000000BB 7416                    	je .proto_sector_alt
   268                                  
   269 000000BD BB[0000]                	mov bx, loadsettings
   270                                  .proto_settings_next:
   271 000000C0 8D5718                  	lea dx, [bx + lsName]
   272 000000C3 E8(0000)                	call isstring?
   273 000000C6 7421                    	je .proto_settings
   274 000000C8 83C320                  	add bx, LOADSETTINGS_size
   275 000000CB 833F00                  	cmp word [bx], 0
   276 000000CE 75F0                    	jne .proto_settings_next
   277                                  
   278 000000D0 E9(0000)                	jmp error
   279                                  
   280                                  .proto_sector_alt:
   281 000000D3 C606[3C05]01            	mov byte [load_sector_alt], 1
   282                                  .proto_sector:
   283 000000D8 E8(0000)                	call skipcomma
   284 000000DB A8                      	db __TEST_IMM8
   285                                  .notproto:
   286 000000DC AC                      	lodsb
   287 000000DD E85C06                  	call parseloadunit_default_sdp
   288 000000E0 E96203                  	jmp .load
   289                                  
   290                                  
   291                                  .errordec:
   292 000000E3 4E                      	dec si
   293                                  .error:
   294 000000E4 A8                      	db __TEST_IMM8		; skip pop
   295                                  .errorpop:
   296 000000E5 5E                      	pop si
   297 000000E6 E9(0000)                	jmp error
   298                                  
   299                                  
   300                                  .proto_settings:
   301 000000E9 56                      	push si
   302 000000EA 89DE                    	mov si, bx
   303 000000EC BF[6002]                	mov di, load_current_settings
   304 000000EF B90C00                  	mov cx, lsName >> 1
   305 000000F2 F3A5                    	rep movsw
   306                                  %if lsName & 1
   307                                  	movsb
   308                                  %endif
   309 000000F4 FF75E8                  	push word [load_kernelname_default - (load_current_settings + lsName) + di]
   310 000000F7 8F85D402                	pop word [load_kernelname_input - (load_current_settings + lsName) + di]
   311 000000FB FF75EA                  	push word [load_addname_default - (load_current_settings + lsName) + di]
   312 000000FE 8F85D802                	pop word [load_addname_input - (load_current_settings + lsName) + di]
   313                                  
   314 00000102 5E                      	pop si
   315                                  
   316                                  d4	call d4message
   317                                  d4	asciz "In bootcmd.proto_settings",13,10
   318                                  
   319                                  .proto_next:
   320 00000103 E8(0000)                	call skipcomma
   321 00000106 4E                      	dec si
   322 00000107 BA[0000]                	mov dx, msg.segment
   323 0000010A E8(0000)                	call isstring?
   324 0000010D 747C                    	je .proto_segment
   325 0000010F BA[0000]                	mov dx, msg.entry
   326 00000112 E8(0000)                	call isstring?
   327 00000115 7503E99200              	je .proto_entry
   328 0000011A BA[0000]                	mov dx, msg.bpb
   329 0000011D E8(0000)                	call isstring?
   330 00000120 7503E9A800              	je .proto_bpb
   331 00000125 BA[0000]                	mov dx, msg.minpara
   332 00000128 E8(0000)                	call isstring?
   333 0000012B 7503E9BE00              	je .proto_minpara
   334 00000130 BA[0000]                	mov dx, msg.maxpara
   335 00000133 E8(0000)                	call isstring?
   336 00000136 7503E9C300              	je .proto_maxpara
   337 0000013B BA[0000]                	mov dx, msg.checkoffset
   338 0000013E E8(0000)                	call isstring?
   339 00000141 7503E9C800              	je .proto_checkoffset
   340 00000146 BA[0000]                	mov dx, msg.checkvalue
   341 00000149 E8(0000)                	call isstring?
   342 0000014C 7503E9D800              	je .proto_checkvalue
   343                                  
   344 00000151 BB[0000]                	mov bx, loadoptiontable
   345                                  .proto_lot_next:
   346 00000154 8B0F                    	mov cx, [bx]		; flag
   347 00000156 8B5702                  	mov dx, [bx + 2]	; -> ASCIZ message
   348 00000159 85C9                    	test cx, cx
   349 0000015B 7503E9D900              	jz .proto_done
   350 00000160 E8(0000)                	call isstring?
   351 00000163 7405                    	je .proto_lot
   352 00000165 83C304                  	add bx, 4
   353 00000168 EBEA                    	jmp .proto_lot_next
   354                                  
   355                                  .proto_lot:
   356 0000016A E8(0000)                	call skipequals
   357 0000016D 89CA                    	mov dx, cx
   358 0000016F F7D2                    	not dx
   359 00000171 2116[6802]              	and word [load_options], dx
   360 00000175 E8(0000)[0000]          	nearcall getexpression
   361 0000017A E8(0000)[0000]          	nearcall toboolean
   362 0000017F 85D2                    	test dx, dx
   363 00000181 7404                    	jz @F
   364 00000183 090E[6802]              	or word [load_options], cx
   365                                  @@:
   366 00000187 4E                      	dec si
   367 00000188 E978FF                  	jmp .proto_next
   368                                  
   369                                  .proto_segment:
   370 0000018B E8(0000)                	call skipequals
   371 0000018E E8(0000)[0000]          	nearcall getword	; dx = word
   372 00000193 83FA50                  	cmp dx, 50h
   373 00000196 7208                    	jb @F
   374 00000198 8916[6A02]              	mov word [load_loadseg], dx
   375 0000019C 4E                      	dec si
   376 0000019D E963FF                  	jmp .proto_next
   377                                  
   378                                  @@:
   379 000001A0 BA[0000]                	mov dx, msg.boot_segment_too_low
   380 000001A3 B81002                  	mov ax, 0210h
   381 000001A6 E8(0000)                	call setrc
   382 000001A9 E98103                  	jmp .fail
   383                                  
   384                                  
   385                                  .proto_entry:
   386 000001AC E8(0000)                	call skipequals
   387 000001AF 31DB                    	xor bx, bx
   388 000001B1 E8(0000)[0000]          	nearcall getaddr	; bx:(e)dx = addr
   389 000001B6 66F7C20000FFFF          _386_PM	test edx, 0_FFFF_0000h
   390 000001BD 0F8523FF                _386_PM	jnz .error
   391 000001C1 8916[6C02]              	mov word [load_entrypoint], dx
   392 000001C5 891E[6E02]              	mov word [load_entrypoint + 2], bx
   393 000001C9 4E                      	dec si
   394 000001CA E936FF                  	jmp .proto_next
   395                                  
   396                                  .proto_bpb:
   397 000001CD E8(0000)                	call skipequals
   398 000001D0 31DB                    	xor bx, bx
   399 000001D2 E8(0000)[0000]          	nearcall getaddr	; bx:(e)dx = addr
   400 000001D7 66F7C20000FFFF          _386_PM	test edx, 0_FFFF_0000h
   401 000001DE 0F8502FF                _386_PM	jnz .error
   402 000001E2 8916[7002]              	mov word [load_bpb], dx
   403 000001E6 891E[7202]              	mov word [load_bpb + 2], bx
   404 000001EA 4E                      	dec si
   405 000001EB E915FF                  	jmp .proto_next
   406                                  
   407                                  .proto_minpara:
   408 000001EE E8(0000)                	call skipequals
   409 000001F1 E8(0000)[0000]          	nearcall getword	; dx = word
   410 000001F6 8916[6402]              	mov word [load_minpara], dx
   411 000001FA 4E                      	dec si
   412 000001FB E905FF                  	jmp .proto_next
   413                                  
   414                                  .proto_maxpara:
   415 000001FE E8(0000)                	call skipequals
   416 00000201 E8(0000)[0000]          	nearcall getword	; dx = word
   417 00000206 8916[6602]              	mov word [load_maxpara], dx
   418 0000020A 4E                      	dec si
   419 0000020B E9F5FE                  	jmp .proto_next
   420                                  
   421                                  .proto_checkoffset:
   422 0000020E E8(0000)                	call skipequals
   423 00000211 E8(0000)[0000]          	nearcall getword	; dx = word
   424 00000216 89D0                    	mov ax, dx
   425 00000218 241F                    	and al, 31
   426 0000021A 3C1F                    	cmp al, 31
   427 0000021C 7503E9C3FE              	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 00000221 8916[7402]              	mov word [load_check_offset], dx
   435 00000225 4E                      	dec si
   436 00000226 E9DAFE                  	jmp .proto_next
   437                                  
   438                                  .proto_checkvalue:
   439 00000229 E8(0000)                	call skipequals
   440 0000022C E8(0000)[0000]          	nearcall getword	; dx = word
   441 00000231 8916[7602]              	mov word [load_check_value], dx
   442 00000235 4E                      	dec si
   443 00000236 E9CAFE                  	jmp .proto_next
   444                                  
   445                                  .proto_done:
   446 00000239 BB[0000]                	mov bx, loadoptiontable.incompatible
   447                                  @@:
   448 0000023C 8B0F                    	mov cx, [bx]
   449 0000023E 0B4F02                  	or cx, [bx + 2]
   450 00000241 746B                    	jz .proto_compatible
   451 00000243 8B16[6802]              	mov dx, word [load_options]
   452 00000247 21CA                    	and dx, cx
   453 00000249 39CA                    	cmp dx, cx
   454 0000024B 7405                    	je .proto_incompatible
   455 0000024D 83C304                  	add bx, 4
   456 00000250 EBEA                    	jmp @B
   457                                  
   458                                  .proto_incompatible:
   459 00000252 16                      	 push ss
   460 00000253 07                      	 pop es
   461 00000254 B80302                  	mov ax, 0203h
   462 00000257 E8(0000)                	call setrc
   463 0000025A BA[0000]                	mov dx, msg.bootfail
   464 0000025D E8(0000)                	call putsz_error
   465 00000260 BA[0000]                	mov dx, msg.boot_cannot_set_both
   466 00000263 E8(0000)                	call putsz_error
   467 00000266 8B07                    	 mov ax, word [bx]
   468 00000268 E82200                  	 call .proto_incompatible_get_label
   469 0000026B E8(0000)                	 call putsz_error
   470 0000026E BA[0000]                	mov dx, msg.boot_and
   471 00000271 E8(0000)                	call putsz_error
   472 00000274 8B4702                  	 mov ax, word [bx + 2]
   473 00000277 E81300                  	 call .proto_incompatible_get_label
   474 0000027A E8(0000)                	 call putsz_error
   475 0000027D BA[0000]                	mov dx, msg.boot_dot_crlf
   476                                  .putsz_errret:
   477 00000280 B80402                  	mov ax, 0204h
   478 00000283 E8(0000)                	call setrc
   479 00000286 E8(0000)                	call putsz_error
   480 00000289 FF26[0000]              	jmp near word [errret]
   481                                  
   482                                  .proto_incompatible_get_label:
   483 0000028D 53                      	push bx
   484 0000028E BB[0000]                	mov bx, loadoptiontable
   485                                  @@:
   486 00000291 8B0F                    	mov cx, [bx]
   487 00000293 E30E                    	jcxz .proto_internal_error
   488 00000295 39C8                    	cmp ax, cx
   489 00000297 8B5702                  	mov dx, word [bx + 2]
   490 0000029A 7405                    	je @F
   491 0000029C 83C304                  	add bx, 4
   492 0000029F EBF0                    	jmp @B
   493                                  
   494                                  @@:
   495 000002A1 5B                      	pop bx
   496 000002A2 C3                      	retn
   497                                  
   498                                  .proto_internal_error:
   499 000002A3 BA[0000]                	mov dx, msg.boot_internal_error
   500 000002A6 B80502                  	mov ax, 0205h
   501 000002A9 E8(0000)                	call setrc
   502 000002AC EBD2                    	jmp .putsz_errret
   503                                  
   504                                  
   505                                  .proto_compatible:
   506 000002AE AC                      	lodsb
   507 000002AF E88A04                  	call parseloadunit_default_sdp
   508 000002B2 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 000002B7 BB[4C05]                	mov bx, load_kernelname_input
   512 000002BA E83900                  	call .pathname_parse_super
   513                                  
   514 000002BD 56                      	push si
   515 000002BE 50                      	push ax
   516 000002BF E8(0000)                	call skipwh0
   517 000002C2 E8(0000)                	call iseol?
   518 000002C5 58                      	pop ax
   519 000002C6 5E                      	pop si
   520 000002C7 747C                    	je .fn_done
   521                                  
   522 000002C9 BB[5005]                	mov bx, load_addname_input
   523                                  
   524 000002CC E8(0000)                	call skipwh0
   525 000002CF 3C2F                    	cmp al, '/'
   526 000002D1 7404                    	je @F
   527 000002D3 3C5C                    	cmp al, '\'
   528 000002D5 751A                    	jne .proto_not_double_slash
   529                                  @@:
   530 000002D7 803C2F                  	cmp byte [si], '/'
   531 000002DA 7405                    	je @F
   532 000002DC 803C5C                  	cmp byte [si], '\'
   533 000002DF 7510                    	jne .proto_not_double_slash
   534                                  @@:
   535 000002E1 4E                      	dec si
   536 000002E2 8937                    	mov word [bx], si
   537 000002E4 C7042F2F                	mov word [si], "//"
   538 000002E8 46                      	inc si
   539 000002E9 46                      	inc si
   540 000002EA AC                      	lodsb
   541 000002EB C644FF00                	mov byte [si - 1], 0
   542 000002EF EB54                    	jmp .fn_done
   543                                  
   544                                  .proto_not_double_slash:
   545 000002F1 E80200                  	call .pathname_parse_super
   546 000002F4 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 000002F6 E8(0000)                	call skipwh0
   557 000002F9 3C2F                    	cmp al, '/'
   558 000002FB 7404                    	je @F
   559 000002FD 3C5C                    	cmp al, '\'
   560 000002FF 7506                    	jne @FF
   561                                  @@:
   562 00000301 4E                      	dec si
   563 00000302 8937                    	mov word [bx], si
   564 00000304 46                      	inc si
   565 00000305 EB13                    	jmp .pathname_check
   566                                  
   567                                  @@:
   568 00000307 4E                      	dec si
   569 00000308 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 0000030A E87007                  	call boot_parse_fn
   576 0000030D 7303                    	jnc @F
   577 0000030F 7401                    	je @F			; CY ZR (have slash, si already -> next)
   578 00000311 46                      	inc si			; increment si -> past separator
   579                                  @@:
   580                                  		; al = separator char
   581                                  		; si -> next char after that (if any)
   582 00000312 3C2F                    	cmp al, '/'		; path separator?
   583 00000314 7404                    	je .pathname_check
   584 00000316 3C5C                    	cmp al, '\'
   585 00000318 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 0000031A C644FF2F                	mov byte [si - 1], '/'	; normalise path separator
   590 0000031E AC                      	lodsb
   591 0000031F 3C20                    	cmp al, 32		; space ?
   592 00000321 740E                    	je .pathname_gotfirst
   593 00000323 3C09                    	cmp al, 9
   594 00000325 740A                    	je .pathname_gotfirst	; yes, allow for second name -->
   595 00000327 4E                      	dec si
   596 00000328 E8(0000)                	call iseol?		; EOL ?
   597 0000032B 75DD                    	jne .pathname_next	; no, next pathname element -->
   598 0000032D C60400                  	mov byte [si], 0	; terminate after trailing path sep
   599 00000330 C3                      	retn
   600                                  
   601                                  .pathname_gotfirst:
   602                                  .pathname_none:
   603 00000331 B000                    	mov al, 0
   604 00000333 4E                      	dec si
   605 00000334 8604                    	xchg al, byte [si]	; terminate after filename
   606 00000336 84C0                    	test al, al
   607 00000338 7407                    	jz @F
   608 0000033A 8936[0000]              	mov word [terminator_in_line_in.offset], si
   609 0000033E A2[0000]                	mov byte [terminator_in_line_in.value], al
   610                                  @@:
   611 00000341 46                      	inc si
   612 00000342 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 00000343 B00D                    	mov al, 13
   623                                  .fn_done:
   624                                  d4	call d4message
   625                                  d4	asciz "In bootcmd.fn_done",13,10
   626                                  
   627 00000345 8326[3205]00            	and word [load_cmdline], 0
   628                                  
   629 0000034A E8(0000)                	call skipwh0
   630 0000034D E8(0000)                	call iseol?.notsemicolon
   631 00000350 7450                    	je @F
   632                                  
   633 00000352 F606[6902]10            	testopt [load_options], LOAD_CMDLINE
   634 00000357 7509                    	jnz .cmdline
   635 00000359 3C3B                    	cmp al, ';'
   636 0000035B 7403E9(0000)            	jne error
   637 00000360 EB40                    	jmp @F
   638                                  .cmdline:
   639                                  
   640 00000362 B400                    	mov ah, 0
   641 00000364 8826[3E05]              	mov byte [load_cmdline_first], ah
   642 00000368 3C22                    	cmp al, '"'
   643 0000036A 7404                    	je .cmdline_quote
   644 0000036C 3C27                    	cmp al, "'"
   645 0000036E 7504                    	jne .cmdline_no_quote
   646                                  .cmdline_quote:
   647 00000370 88C4                    	mov ah, al
   648 00000372 EB0B                    	jmp .cmdline_loop_1
   649                                  .cmdline_no_quote:
   650 00000374 4E                      	dec si
   651 00000375 8936[3205]              	mov word [load_cmdline], si
   652 00000379 46                      	inc si
   653 0000037A A2[3E05]                	mov byte [load_cmdline_first], al
   654 0000037D EB05                    	jmp .cmdline_loop_2
   655                                  
   656                                  .cmdline_loop_1:
   657 0000037F 8936[3205]              	mov word [load_cmdline], si
   658                                  .cmdline_loop:
   659 00000383 AC                      	lodsb
   660                                  .cmdline_loop_2:
   661 00000384 E8(0000)                	call iseol?.notsemicolon
   662 00000387 740E                    	je .cmdline_eol
   663 00000389 38E0                    	cmp al, ah
   664 0000038B 75F6                    	jne .cmdline_loop
   665                                  .cmdline_quote_eol:
   666 0000038D C644FF00                	mov byte [si - 1], 0
   667 00000391 AC                      	lodsb
   668 00000392 E8(0000)                	call chkeol
   669 00000395 EB0B                    	jmp @F
   670                                  
   671                                  .cmdline_eol:
   672 00000397 84E4                    	test ah, ah
   673 00000399 7403E9(0000)            	jnz error
   674 0000039E C644FF00                	mov byte [si - 1], 0
   675                                  
   676                                  @@:
   677 000003A2 F606[0000]07            	testopt [internalflags3], dif3_load_is_dp
   678 000003A7 7527                    	jnz .load_kernel_from_ldp
   679                                  
   680 000003A9 8A1E[3805]              	mov bl, [load_partition]
   681 000003AD 803E[4002]80            	cmp byte [load_unit], 80h
   682 000003B2 7228                    	jb .p_f_is_diskette
   683 000003B4 84DB                    	test bl, bl		; partition specified ?
   684 000003B6 7503E929FD              	jz .error		; no, error -->
   685                                  
   686 000003BB E8F015                  	call query_geometry
   687                                  
   688 000003BE B9[820B]                	mov cx, load_freedos_from_partition
   689 000003C1 E83C14                  	call scan_partitions
   690 000003C4 BA[0000]                	mov dx, msg.boot_partition_not_found
   691 000003C7 B81102                  	mov ax, 0211h
   692 000003CA E8(0000)                	call setrc
   693 000003CD E95D01                  	jmp .fail
   694                                  
   695                                  
   696                                  .load_kernel_from_ldp:
   697 000003D0 E8DB15                  	call query_geometry
   698 000003D3 A1[2805]                	mov ax, word [load_partition_sector]
   699 000003D6 8B16[2A05]              	mov dx, word [load_partition_sector + 2]
   700 000003DA EB0E                    	jmp @F
   701                                  
   702                                  
   703                                  .p_f_is_diskette:
   704 000003DC 84DB                    	test bl, bl		; partition specified ?
   705 000003DE 7403E901FD              	jnz .error		; yes, error -->
   706                                  
   707 000003E3 E8C815                  	call query_geometry
   708                                  
   709 000003E6 31C0                    	xor ax, ax
   710 000003E8 31D2                    	xor dx, dx
   711                                  @@:
   712 000003EA 8B1E[0000]              	mov bx, word [auxbuff_segorsel]	; bx => auxbuff
   713 000003EE 52                      	 push dx
   714 000003EF 50                      	 push ax
   715 000003F0 E88717                  	call read_ae_512_bytes
   716                                  
   717 000003F3 26813EFE0155AA          	cmp word [es:510], 0AA55h
   718 000003FA 7403E93D1C              	jne boot_sigmismatch
   719 000003FF 58                      	 pop ax
   720 00000400 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 00000401 06                      	push es
   733 00000402 F606[6902]40            	testopt [load_options], LOAD_SET_DSSI_PARTINFO
   734 00000407 7438                    	jz @F
   735                                  
   736 00000409 50                      	push ax
   737                                  %if _LOADER
   738                                  	mov es, bx
   739                                  	xor di, di
   740                                  	cmp bx, 60h
   741                                  	ja .loader
   742                                  %endif
   743 0000040A 31FF                    	xor di, di
   744 0000040C 8EC7                    	mov es, di
   745 0000040E BF0006                  	mov di, 600h
   746                                  .loader:
   747 00000411 B8CD19                  	mov ax, 19CDh
   748 00000414 AB                      	stosw				; fake boot sector loader
   749 00000415 B9FE00                  	mov cx, 508 / 2
   750 00000418 31C0                    	xor ax, ax
   751 0000041A F3AB                    	rep stosw			; initialise pseudo MBR
   752 0000041C B855AA                  	mov ax, 0AA55h
   753 0000041F AB                      	stosw				; fake boot sector signature
   754 00000420 58                      	pop ax
   755                                  
   756 00000421 8D75BE                  	lea si, [di - 2 - 64]		; -> first partition table entry
   757                                  
   758 00000424 26894408                	mov word [es:si + 8], ax
   759 00000428 2689540A                	mov word [es:si + 8 + 2], dx	; store in partition table entry
   760 0000042C 26C60480                	mov byte [es:si + piBoot], 80h	; fake primary active
   761 00000430 26C64404FF              	mov byte [es:si + piType], 0FFh	; fake a type
   762 00000435 26FE440C                	inc byte [es:si + piLength]	; fake a size
   763                                  
   764 00000439 8C06[3605]              	mov word [load_partition_entry + 2], es
   765 0000043D 8936[3405]              	mov word [load_partition_entry], si
   766                                  @@:
   767 00000441 07                      	pop es
   768                                  
   769 00000442 E9B607                  	jmp load_freedos_common
   770                                  
   771                                  
   772                                  .load:
   773 00000445 7403E99AFC              	jnz bootcmd.error
   774                                  
   775 0000044A F606[0000]07            	testopt [internalflags3], dif3_load_is_dp
   776 0000044F 751C                    	jnz .load_sector_from_ldp
   777                                  
   778 00000451 803E[3805]00            	cmp byte [load_partition], 0
   779 00000456 7421                    	je .load_boot
   780                                  
   781 00000458 E85315                  	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 0000045B B9[0F0B]                	mov cx, load_from_partition
   792 0000045E E89F13                  	call scan_partitions
   793 00000461 BA[0000]                	mov dx, msg.boot_partition_not_found
   794 00000464 B81202                  	mov ax, 0212h
   795 00000467 E8(0000)                	call setrc
   796 0000046A 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 0000046D E83E15                  	call query_geometry
   816 00000470 A1[2805]                	mov ax, word [load_partition_sector]
   817 00000473 8B16[2A05]              	mov dx, word [load_partition_sector + 2]
   818 00000477 EB07                    	jmp @F
   819                                  
   820                                  .load_boot:
   821 00000479 E83215                  	call query_geometry
   822                                  
   823 0000047C 31C0                    	xor ax, ax
   824 0000047E 31D2                    	xor dx, dx
   825                                  @@:
   826                                  
   827                                  %if _LOADER
   828                                  	cmp byte [currentposition], 0
   829                                  	je ..@loader_bottom_not_allowed
   830                                  %endif
   831                                  
   832 00000480 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 00000483 52                      	 push dx
   837 00000484 50                      	 push ax
   838 00000485 E8F216                  	call read_ae_512_bytes
   839                                  d4	call d4message
   840                                  d4	asciz "In bootcmd.load_boot (after call to read_sector)",13,10
   841 00000488 31D2                    	xor dx, dx
   842 0000048A 8EC2                    	mov es, dx
   843                                  
   844 0000048C A0[4002]                	mov al, byte [load_unit]	; al = boot unit
   845 0000048F BB007C                  	mov bx, 7C00h
   846                                  
   847 00000492 26813EFE7D55AA          	cmp word [es:7C00h + 510], 0AA55h
   848 00000499 7403E99E1B              	jne boot_sigmismatch
   849                                  
   850 0000049E 26833F00                	cmp word [es:bx], 0
   851 000004A2 7503E9A11B              	je boot_codemismatch
   852                                  
   853 000004A7 50                      	push ax
   854 000004A8 B9FF00                  	mov cx, 510 / 2
   855 000004AB BF0006                  	mov di, 600h			; MBR location
   856 000004AE 31C0                    	xor ax, ax
   857 000004B0 F3AB                    	rep stosw			; initialise (sector and all entries)
   858 000004B2 B855AA                  	mov ax, 0AA55h
   859 000004B5 AB                      	stosw				; initialise boot sector signature
   860 000004B6 26C7060006CD19          	mov word [es:600h], 019CDh	; initialise boot sector code
   861 000004BD BFBE07                  	mov di, 600h + 510 - 4*16	; -> first partition table entry
   862 000004C0 58                      	pop ax
   863 000004C1 268F4508                	 pop word [es:di + piStart]
   864 000004C5 268F450A                	 pop word [es:di + piStart + 2]	; = boot sector LBA
   865 000004C9 26C60580                	mov byte [es:di + 0], 80h	; "bootable" flag set
   866 000004CD 26C64504FF              	mov byte [es:di + 4], 0FFh	; dummy value for FS type (nonzero)
   867 000004D2 26C6450C01              	mov byte [es:di + 12], 1	; dummy value for length (nonzero)
   868                                  
   869                                  load_partition_common: equ $
   870 000004D7 8126[0000]FFF8          	and word [reg_efl], ~(400h|200h|100h)	; UP, DI, TF=0
   871 000004DD 893E[0000]              	mov word [reg_esi], di
   872 000004E1 893E[0000]              	mov word [reg_ebp], di
   873 000004E5 890E[0000]              	mov word [reg_ds], cx		; ds:si -> 0:600h + offset to first entry
   874 000004E9 A2[0000]                	mov byte [reg_edx], al		; dl = boot unit
   875 000004EC 891E[0000]              	mov word [reg_eip], bx
   876 000004F0 890E[0200]              	mov word [reg_eip + 2], cx
   877 000004F4 890E[0000]              	mov word [reg_cs], cx		; cs:eip = 0:7C00h
   878 000004F8 803E[3C05]00            	 cmp byte [load_sector_alt], 0
   879 000004FD 740A                    	 je @F
   880 000004FF 890E[0000]              	 mov word [reg_eip], cx
   881 00000503 C706[0000]C007          	 mov word [reg_cs], 7C0h	; cs:eip = 07C0h:0
   882                                  @@:
   883 00000509 891E[0000]              	mov word [reg_esp], bx
   884 0000050D 890E[0200]              	mov word [reg_esp + 2], cx
   885 00000511 890E[0000]              	mov word [reg_ss], cx		; ss:esp = 0:7C00h
   886 00000515 800E[0300]01            	setopt [internalflags2], dif2_boot_loaded_kernel
   887 0000051A C3                      	retn
   888                                  
   889                                  
   890                                  .fail_read:
   891 0000051B 16                      	 push ss
   892 0000051C 07                      	 pop es
   893 0000051D BF[0000]                	mov di, msg.bootfail_read_errorcode
   894 00000520 88E0                    	mov al, ah
   895 00000522 B404                    	mov ah, 04h
   896 00000524 E8(0000)                	call setrc
   897 00000527 E8(0000)                	call hexbyte
   898 0000052A BA[0000]                	mov dx, msg.bootfail_read
   899                                  
   900                                  .fail:
   901 0000052D 16                      	 push ss
   902 0000052E 07                      	 pop es
   903 0000052F 52                      	push dx
   904 00000530 BA[0000]                	mov dx, msg.bootfail
   905 00000533 E8(0000)                	call putsz_error
   906 00000536 5A                      	pop dx
   907 00000537 E8(0000)                	call putsz_error
   908 0000053A B8FF02                  	mov ax, 02FFh
   909 0000053D E8(0000)                	call setrc
   910 00000540 FF26[0000]              	jmp near word [errret]
   911                                  
   912                                  
   913                                  bootcmd.list:
   914 00000544 E8(0000)                	call skipcomma
   915                                  
   916 00000547 E8F201                  	call parseloadunit_default_sdp
   917 0000054A 7403E995FB              	jnz bootcmd.error
   918                                  
   919 0000054F E85C14                  	call query_geometry
   920                                  
   921 00000552 F606[0000]07            	testopt [internalflags3], dif3_load_is_dp
   922 00000557 752B                    	jnz .list_ldp
   923                                  
   924 00000559 803E[3805]00            	cmp byte [load_partition], 0
   925 0000055E 741E                    	je .listall
   926                                  
   927 00000560 C606[3A05]00            	mov byte [load_found_partition], 0
   928 00000565 B9[BD05]                	mov cx, list_single_partition
   929 00000568 E89512                  	call scan_partitions
   930 0000056B 803E[3A05]00            	cmp byte [load_found_partition], 0
   931 00000570 750B                    	jne @F
   932 00000572 BA[0000]                	mov dx, msg.boot_partition_not_found
   933 00000575 B81302                  	mov ax, 0213h
   934 00000578 E8(0000)                	call setrc
   935 0000057B EBB0                    	jmp bootcmd.fail
   936                                  @@:
   937 0000057D C3                      	retn
   938                                  
   939                                  .listall:
   940 0000057E B9[CB05]                	mov cx, list_any_partition
   941 00000581 E97C12                  	jmp scan_partitions
   942                                  
   943                                  .list_ldp:
   944 00000584 C606[3A05]00            	mov byte [load_found_partition], 0
   945 00000589 B9[A205]                	mov cx, list_partition_if_ldp
   946 0000058C E87112                  	call scan_partitions
   947 0000058F 803E[3A05]00            	cmp byte [load_found_partition], 0
   948 00000594 750B                    	jne @F
   949 00000596 BA[0000]                	mov dx, msg.boot_partition_not_found
   950 00000599 B81402                  	mov ax, 0214h
   951 0000059C E8(0000)                	call setrc
   952 0000059F EB8C                    	jmp bootcmd.fail
   953                                  @@:
   954 000005A1 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 000005A2 8B43F8                  	mov ax, word [bp + di - 8]
   962 000005A5 8B53FA                  	mov dx, word [bp + di - 6]	; root
   963 000005A8 26034408                	add ax, word [es:si + 8]
   964 000005AC 2613540A                	adc dx, word [es:si + 8 + 2]	; add partition offset
   965 000005B0 3906[2805]              	cmp word [load_partition_sector], ax
   966 000005B4 7506                    	jne @F
   967 000005B6 3916[2A05]              	cmp word [load_partition_sector + 2], dx
   968 000005BA 740B                    	je list_single_partition.gotit
   969                                  @@:
   970 000005BC C3                      	retn
   971                                  
   972                                  list_single_partition:
   973                                  d4	call d4message
   974                                  d4	asciz "In list_single_partition",13,10
   975                                  
   976 000005BD A0[3905]                	mov al, byte [load_current_partition]
   977 000005C0 3A06[3805]              	cmp al, byte [load_partition]
   978 000005C4 7401                    	je .gotit
   979 000005C6 C3                      	retn
   980                                  
   981                                  .gotit:
   982 000005C7 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 000005CB 06                      	 push es
   993 000005CC 51                      	 push cx
   994 000005CD 56                      	 push si
   995 000005CE 57                      	 push di
   996                                  
   997 000005CF BF[0000]                	mov di, line_out	; reset di
   998 000005D2 B075                    	mov al, "u"
   999 000005D4 AA                      	stosb
  1000 000005D5 A0[4002]                	mov al, byte [load_unit]
  1001 000005D8 E8(0000)                	call hexbyte
  1002 000005DB 84C0                    	test al, al
  1003 000005DD B02E                    	mov al, '.'
  1004 000005DF AA                      	stosb
  1005 000005E0 7806                    	js @F
  1006 000005E2 B020                    	mov al, 32
  1007 000005E4 AA                      	stosb
  1008 000005E5 AA                      	stosb
  1009 000005E6 EB0D                    	jmp @FF
  1010                                  
  1011                                  @@:
  1012 000005E8 A0[3905]                	mov al, byte [load_current_partition]
  1013 000005EB E8(0000)                	call decbyte
  1014 000005EE 3C0A                    	cmp al, 10
  1015 000005F0 B020                    	mov al, 32
  1016 000005F2 7301                    	jae @F
  1017 000005F4 AA                      	stosb
  1018                                  @@:
  1019 000005F5 AA                      	stosb
  1020                                  
  1021 000005F6 A0[4002]                	mov al, byte [load_unit]
  1022 000005F9 50                      	push ax
  1023 000005FA BB6664                  	mov bx, "fd"
  1024 000005FD 3C80                    	cmp al, 80h
  1025 000005FF 7202                    	jb @F
  1026 00000601 B368                    	mov bl, "h"
  1027                                  @@:
  1028 00000603 247F                    	and al, ~80h
  1029 00000605 0461                    	add al, 'a'
  1030 00000607 3C7A                    	cmp al, 'z'
  1031 00000609 760A                    	jbe @F
  1032 0000060B 58                      	pop ax
  1033 0000060C B020                    	mov al, 32
  1034 0000060E B90500                  	mov cx, 3 + 2
  1035 00000611 F3AA                    	rep stosb
  1036 00000613 EB1C                    	jmp .beyondZ
  1037                                  
  1038                                  @@:
  1039 00000615 93                      	xchg ax, bx
  1040 00000616 AB                      	stosw
  1041 00000617 93                      	xchg ax, bx
  1042 00000618 AA                      	stosb
  1043 00000619 58                      	pop ax
  1044 0000061A 84C0                    	test al, al
  1045 0000061C 7806                    	js @F
  1046 0000061E B020                    	mov al, 32
  1047 00000620 AA                      	stosb
  1048 00000621 AA                      	stosb
  1049 00000622 EB0D                    	jmp @FF
  1050                                  
  1051                                  @@:
  1052 00000624 A0[3905]                	mov al, byte [load_current_partition]
  1053 00000627 E8(0000)                	call decbyte
  1054 0000062A 3C0A                    	cmp al, 10
  1055 0000062C B020                    	mov al, 32
  1056 0000062E 7301                    	jae @F
  1057 00000630 AA                      	stosb
  1058                                  @@:
  1059                                  .beyondZ:
  1060 00000631 AA                      	stosb
  1061                                  
  1062 00000632 8A4404                  	mov al, byte [si + 4]
  1063 00000635 E8(0000)                	call hexbyte
  1064                                  
  1065 00000638 B020                    	mov al, 32
  1066 0000063A AA                      	stosb
  1067                                  
  1068 0000063B 89F9                    	mov cx, di		; (preserve di in line_out)
  1069 0000063D 5F                      	 pop di			; get di of scan_partitions
  1070 0000063E 57                      	 push di
  1071 0000063F 8B43F8                  	mov ax, word [bp + di - 8]
  1072 00000642 8B53FA                  	mov dx, word [bp + di - 6]	; root
  1073 00000645 89CF                    	mov di, cx		; (preserve di in line_out)
  1074 00000647 034408                  	add ax, word [si + 8]
  1075 0000064A 13540A                  	adc dx, word [si + 8 + 2]	; add partition offset
  1076 0000064D 92                      	xchg ax, dx
  1077 0000064E E8(0000)                	call hexword
  1078 00000651 92                      	xchg ax, dx
  1079 00000652 E8(0000)                	call hexword
  1080                                  
  1081 00000655 50                      	 push ax
  1082 00000656 B82028                  	mov ax, " ("
  1083 00000659 AB                      	stosw
  1084 0000065A 58                      	 pop ax
  1085 0000065B 51                      	  push cx
  1086 0000065C 53                      	  push bx
  1087 0000065D 8B0E[0B02]              	mov cx, [load_sectorsize]
  1088 00000661 BB0800                  	mov bx, 4+4
  1089 00000664 E8(0000)                	call disp_dxax_times_cx_width_bx_size.store
  1090 00000667 50                      	 push ax
  1091 00000668 B82920                  	mov ax, ") "
  1092 0000066B AB                      	stosw
  1093 0000066C 58                      	 pop ax
  1094                                  
  1095 0000066D 52                      	push dx
  1096 0000066E 50                      	push ax
  1097                                  
  1098 0000066F 8B440C                  	mov ax, word [si + 12]
  1099 00000672 8B540E                  	mov dx, word [si + 12 + 2]
  1100 00000675 92                      	xchg ax, dx
  1101 00000676 E8(0000)                	call hexword
  1102 00000679 92                      	xchg ax, dx
  1103 0000067A E8(0000)                	call hexword
  1104                                  
  1105 0000067D 50                      	 push ax
  1106 0000067E B82028                  	mov ax, " ("
  1107 00000681 AB                      	stosw
  1108 00000682 58                      	 pop ax
  1109 00000683 E8(0000)                	call disp_dxax_times_cx_width_bx_size.store
  1110 00000686 B029                    	mov al, ")"
  1111 00000688 AA                      	stosb
  1112                                  
  1113 00000689 58                      	pop ax
  1114 0000068A 5A                      	pop dx
  1115                                  
  1116 0000068B 5B                      	  pop bx
  1117 0000068C 59                      	  pop cx
  1118                                  
  1119 0000068D 807C0483                	cmp byte [si + piType], ptLinux
  1120 00000691 753D                    	jne .notlinux
  1121                                  
  1122 00000693 8B1E[0000]              	mov bx, word [auxbuff_segorsel]	; bx => auxbuff
  1123 00000697 E8CF14                  	call read_ae_1536_bytes
  1124                                  
  1125 0000069A 26813E380453EF          	cmp word [es:1024 + 56], 0xEF53	; s_magic == EXT2_SUPER_MAGIC ?
  1126 000006A1 7510                    	jne .nolabel_j
  1127                                  
  1128 000006A3 26833E4E0400            	cmp word [es:1024 + 76 + 2], 0
  1129 000006A9 7508                    	jne .nolabel_j
  1130 000006AB 26833E4C0401            	cmp word [es:1024 + 76], 1	; s_rev_level == EXT2_DYNAMIC_REV ?
  1131 000006B1 7402                    	je @F
  1132                                  .nolabel_j:
  1133 000006B3 EB7D                    	jmp .nolabel
  1134                                  @@:
  1135                                  
  1136 000006B5 06                      	push es
  1137 000006B6 1F                      	pop ds
  1138 000006B7 BE7804                  	mov si, 1024 + 120
  1139 000006BA B91000                  	mov cx, 16
  1140 000006BD 16                      	push ss
  1141 000006BE 07                      	pop es
  1142                                  
  1143 000006BF B020                    	mov al, 32
  1144 000006C1 AA                      	stosb
  1145                                  @@:
  1146 000006C2 AC                      	lodsb
  1147 000006C3 84C0                    	test al, al
  1148 000006C5 7403                    	jz @F
  1149 000006C7 AA                      	stosb
  1150 000006C8 E2F8                    	loop @B
  1151                                  @@:
  1152                                  
  1153 000006CA 16                      	push ss
  1154 000006CB 1F                      	pop ds
  1155                                  
  1156 000006CC 59                      	pop cx
  1157 000006CD 5E                      	pop si
  1158 000006CE 56                      	push si				; get si of scan_partitions
  1159 000006CF 51                      	push cx
  1160                                  
  1161                                  .notlinux:
  1162 000006D0 8A5C04                  	mov bl, byte [si + piType]
  1163 000006D3 80FB01                  	cmp bl, ptFAT12
  1164 000006D6 7419                    	je .isfat
  1165 000006D8 80FB04                  	cmp bl, ptFAT16_16BIT_CHS
  1166 000006DB 7414                    	je .isfat
  1167 000006DD 80FB06                  	cmp bl, ptFAT16_CHS
  1168 000006E0 740F                    	je .isfat
  1169 000006E2 80FB0B                  	cmp bl, ptFAT32_CHS
  1170 000006E5 740A                    	je .isfat
  1171 000006E7 80FB0C                  	cmp bl, ptFAT32
  1172 000006EA 7405                    	je .isfat
  1173 000006EC 80FB0E                  	cmp bl, ptFAT16
  1174 000006EF 7541                    	jne .notfat
  1175                                  .isfat:
  1176                                  
  1177 000006F1 8B1E[0000]              	mov bx, word [auxbuff_segorsel]	; bx => auxbuff
  1178 000006F5 E88214                  	call read_ae_512_bytes
  1179                                  
  1180 000006F8 26813EFE0155AA          	cmp word [es:510], 0AA55h
  1181 000006FF 7531                    	jne .nolabel
  1182 00000701 26833E0B0000            	cmp word [es:bsBPB + bpbBytesPerSector], 0
  1183 00000707 7429                    	je .nolabel
  1184 00000709 BE2B00                  	mov si, bsBPB + bpbNew + bpbnVolumeLabel
  1185 0000070C 26833E160000            	cmp word [es:bsBPB + bpbSectorsPerFAT], 0
  1186 00000712 7503                    	jne @F
  1187 00000714 BE4700                  	mov si, bsBPB + ebpbNew + bpbnVolumeLabel
  1188                                  @@:
  1189 00000717 26807CFB29              	cmp byte [es:si - bpbnVolumeLabel + bpbnExtBPBSignature], 29h
  1190 0000071C 7514                    	jne .nolabel
  1191 0000071E B90B00                  	mov cx, 11
  1192                                  
  1193 00000721 06                      	push es
  1194 00000722 1F                      	pop ds
  1195 00000723 16                      	push ss
  1196 00000724 07                      	pop es
  1197                                  
  1198 00000725 B020                    	mov al, 32
  1199 00000727 AA                      	stosb
  1200                                  @@:
  1201 00000728 AC                      	lodsb
  1202 00000729 84C0                    	test al, al
  1203 0000072B 7403                    	jz @F
  1204 0000072D AA                      	stosb
  1205 0000072E E2F8                    	loop @B
  1206                                  @@:
  1207                                  
  1208 00000730 16                      	push ss
  1209 00000731 1F                      	pop ds
  1210                                  .notfat:
  1211                                  .nolabel:
  1212 00000732 16                      	push ss
  1213 00000733 07                      	pop es
  1214 00000734 E8(0000)                	call putsline_crlf
  1215                                  
  1216 00000737 5F                      	 pop di
  1217 00000738 5E                      	 pop si
  1218 00000739 59                      	 pop cx
  1219 0000073A 07                      	 pop es
  1220 0000073B 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 0000073C F8                      	clc
  1240                                  .cf:
  1241 0000073D E82C00                  	call parseloadunit
  1242 00000740 7329                    	jnc @F
  1243                                  
  1244 00000742 8A16[3D05]              	mov dl, byte [load_sdp_unit]
  1245 00000746 8816[4002]              	mov byte [load_unit], dl
  1246 0000074A FF36[2E05]              	 push word [load_sdp_sector + 2]
  1247 0000074E FF36[2C05]              	 push word [load_sdp_sector]
  1248 00000752 8F06[2805]              	 pop word [load_partition_sector]
  1249 00000756 8F06[2A05]              	 pop word [load_partition_sector + 2]
  1250 0000075A C606[3805]FF            	mov byte [load_partition], -1
  1251 0000075F 800E[0000]02            	or byte [internalflags3], dif3_load_is_sdp
  1252                                  
  1253 00000764 E8(0000)                	call skipwh0
  1254 00000767 E8(0000)                	call iseol?
  1255 0000076A F8                      	clc
  1256                                  @@:
  1257 0000076B 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 0000076C 5589E550                	lenter
  1285                                  	lvar word,	bit0_no_set_sdp
  1286 00000770 9C                      	 pushf
  1287 00000771 31DB                    	xor bx, bx
  1288                                  	lvar word,	dif3_set
  1289 00000773 53                      	 push bx
  1290                                  	lvar dword,	load_partition_sector
  1291 00000774 FF36[2E05]              	 push word [load_sdp_sector + 2]
  1292 00000778 FF36[2C05]              	 push word [load_sdp_sector]
  1293                                  
  1294 0000077C 89F7                    	mov di, si
  1295 0000077E 8026[0000]F8            	clropt [internalflags3], dif3_load_is_dp
  1296 00000783 E8(0000)                	call capitalise
  1297 00000786 3C48                    	cmp al, 'H'
  1298 00000788 7503E9F100              	je .load_hd
  1299 0000078D 3C46                    	cmp al, 'F'
  1300 0000078F 7503E9E700              	je .load_fd
  1301 00000794 B401                    	mov ah, dif3_load_is_ldp
  1302 00000796 3C4C                    	cmp al, 'L'
  1303 00000798 7419                    	je .load_ld_sd
  1304 0000079A B402                    	mov ah, dif3_load_is_sdp
  1305 0000079C 3C53                    	cmp al, 'S'
  1306 0000079E 7413                    	je .load_ld_sd
  1307                                  %if _INPUT_FILE_BOOT
  1308 000007A0 B404                    	mov ah, dif3_load_is_ydp
  1309 000007A2 3C59                    	cmp al, 'Y'
  1310 000007A4 740D                    	je .load_ld_sd
  1311                                  %endif
  1312 000007A6 3C55                    	cmp al, 'U'
  1313 000007A8 747C                    	je .load_u
  1314                                  .retc:
  1315 000007AA 89FE                    	mov si, di
  1316 000007AC 4E                      	dec si
  1317 000007AD AC                      	lodsb
  1318 000007AE F9                      	stc
  1319                                  .ret:
  1320 000007AF 89EC5D                  	lleave code
  1321 000007B2 C3                      	lret
  1322                                  
  1323                                  .load_ld_sd:
  1324 000007B3 AC                      	lodsb
  1325 000007B4 E8(0000)                	call capitalise
  1326 000007B7 3C44                    	cmp al, 'D'
  1327 000007B9 75EF                    	jne .retc
  1328                                  
  1329                                  d4	call d4message
  1330                                  d4	asciz "In parseloadunit.load_ld_sd",13,10
  1331                                  
  1332 000007BB 8A16[3D05]              	mov dl, byte [load_sdp_unit]
  1333 000007BF 80FC02                  	cmp ah, dif3_load_is_sdp
  1334 000007C2 741D                    	je @F
  1335 000007C4 8A16[A001]              	mov dl, byte [loaddata_loadedfrom - LOADDATA 			+ bsBPB + ebpbNew + bpbnBootUnit]
  1337                                  %if _INPUT_FILE_BOOT
  1338 000007C8 80FC01                  	cmp ah, dif3_load_is_ldp
  1339 000007CB 7414                    	je @F
  1340 000007CD F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  1341 000007D2 74D6                    	jz .retc
  1342                                  
  1343 000007D4 93                      	xchg ax, bx
  1344 000007D5 B8A000                  	mov ax, LOAD_INPUT_FILE_SIZE
  1345 000007D8 F726[2005]              	mul word [load_input_file.active]
  1346                                  
  1347                                  ;	test dx, dx
  1348                                  ;	jnz .error
  1349                                  
  1350 000007DC 93                      	xchg ax, bx
  1351 000007DD 8A97[2003]              	mov dl, byte [load_input_file + bx - LOADDATA3 			+ bsBPB + ebpbNew + bpbnBootUnit]
  1353                                  %endif
  1354                                  @@:
  1355 000007E1 AC                      	lodsb
  1356 000007E2 E8(0000)                	call capitalise
  1357 000007E5 3C50                    	cmp al, 'P'
  1358 000007E7 7403E9AF00              	jne .got_unit
  1359                                  
  1360                                  d4	call d4message
  1361                                  d4	asciz "In parseloadunit.load_ld_sd with ldp",13,10
  1362                                  
  1363 000007EC 8856FE                  	mov byte [bp + ?unit], dl
  1364 000007EF C646FFFF                	mov byte [bp + ?partition], -1
  1365 000007F3 0866FA                  	or byte [bp + ?dif3_set], ah
  1366                                  
  1367 000007F6 80FC02                  	cmp ah, dif3_load_is_sdp
  1368 000007F9 741D                    	je @F
  1369                                  %if _INPUT_FILE_BOOT
  1370 000007FB 80FC01                  	cmp ah, dif3_load_is_ldp
  1371 000007FE 740A                    	je .is_ldp
  1372 00000800 FFB7[FE02]              	push word [load_input_file + bx - LOADDATA3 			+ bsBPB + bpbHiddenSectors + 2]
  1374 00000804 FFB7[FC02]              	push word [load_input_file + bx - LOADDATA3 			+ bsBPB + bpbHiddenSectors]
  1376 00000808 EB08                    	jmp .is_ldp_ydp
  1377                                  
  1378                                  %endif
  1379                                  .is_ldp:
  1380 0000080A FF36[7E01]              	push word [load_ldp_sector + 2]
  1381 0000080E FF36[7C01]              	push word [load_ldp_sector]
  1382                                  .is_ldp_ydp:
  1383 00000812 8F46F6                  	pop word [bp + ?load_partition_sector]
  1384 00000815 8F46F8                  	pop word [bp + ?load_partition_sector + 2]
  1385                                  @@:
  1386                                  
  1387 00000818 E8(0000)                	call skipwhite
  1388 0000081B E8(0000)                	call iseol?
  1389 0000081E 7403E90701              	jne .fn
  1390 00000823 E90001                  	jmp .ret_nc
  1391                                  
  1392                                  .load_u:
  1393 00000826 AC                      	lodsb
  1394 00000827 E8(0000)                	call capitalise
  1395                                  
  1396 0000082A 3C28                    	cmp al, '('
  1397 0000082C 7419                    	je @F
  1398 0000082E 3C30                    	cmp al, '0'
  1399 00000830 7303E975FF              	jb .retc
  1400 00000835 3C39                    	cmp al, '9'
  1401 00000837 760E                    	jbe @F
  1402 00000839 3C41                    	cmp al, 'A'
  1403 0000083B 7303E96AFF              	jb .retc
  1404 00000840 3C46                    	cmp al, 'F'
  1405 00000842 7603E963FF              	ja .retc
  1406                                  @@:
  1407                                  
  1408 00000847 3C28                    	cmp al, '('
  1409 00000849 7513                    	jne .u_not_expr
  1410 0000084B AC                      	lodsb
  1411 0000084C E8(0000)[0000]          	nearcall getexpression
  1412 00000851 E8(0000)                	call skipwh0
  1413 00000854 3C29                    	cmp al, ')'
  1414 00000856 AC                      	lodsb
  1415 00000857 7403E987F8              	jne bootcmd.errordec
  1416 0000085C EB03                    	jmp .u_check_dot
  1417                                  
  1418                                  .u_not_expr:
  1419 0000085E E8F210                  	call boot_get_hexadecimal_literal
  1420                                  .u_check_dot:
  1421 00000861 3C2E                    	cmp al, '.'
  1422 00000863 7403E97CF8              	jne bootcmd.error
  1423 00000868 AC                      	lodsb
  1424 00000869 85DB                    	test bx, bx
  1425 0000086B 7403E974F8              	jnz bootcmd.error
  1426 00000870 81FA0001                	cmp dx, 256
  1427 00000874 7203E96BF8              	jae bootcmd.error
  1428 00000879 EB20                    	jmp .got_unit
  1429                                  
  1430                                  .load_fd:
  1431 0000087B B200                    	mov dl, 0
  1432                                  
  1433                                  d4	call d4message
  1434                                  d4	asciz "In parseloadunit.load_fd",13,10
  1435                                  
  1436 0000087D A9                      	db __TEST_IMM16		; skip mov
  1437                                  .load_hd:
  1438 0000087E B280                    	mov dl, 80h
  1439                                  d4	call d4message
  1440                                  d4	asciz "In parseloadunit.load_fd or .load_hd",13,10
  1441                                  
  1442 00000880 AC                      	lodsb
  1443 00000881 E8(0000)                	call capitalise
  1444 00000884 3C44                    	cmp al, 'D'
  1445 00000886 7403E91FFF              	jne .retc
  1446 0000088B AC                      	lodsb
  1447 0000088C E8(0000)                	call capitalise
  1448 0000088F 2C41                    	sub al, 'A'
  1449 00000891 3C19                    	cmp al, 'Z' - 'A'
  1450 00000893 7603E912FF              	ja .retc
  1451 00000898 08C2                    	or dl, al			; hdX: 80h + number, fdX: 0 + number
  1452 0000089A AC                      	lodsb
  1453                                  
  1454                                  .got_unit:
  1455 0000089B 89D1                    	mov cx, dx
  1456 0000089D 884EFE                  	mov byte [bp + ?unit], cl
  1457 000008A0 C646FF00                	mov byte [bp + ?partition], 0
  1458 000008A4 3C2F                    	cmp al, '/'			; slash ?
  1459 000008A6 7414                    	je .fn_j
  1460 000008A8 3C5C                    	cmp al, '\'
  1461 000008AA 7410                    	je .fn_j			; got a filename -->
  1462 000008AC 3C20                    	cmp al, 32			; or blank ?
  1463 000008AE 7404                    	je @F
  1464 000008B0 3C09                    	cmp al, 9
  1465 000008B2 750A                    	jne .checkeol			; check for EOL -- but no filename
  1466                                  		;  (hdd1name is invalid -- must be hdd1/name or hdd1 name)
  1467                                  @@:					; was blank
  1468 000008B4 E8(0000)                	call skipwh0			; skip blanks
  1469 000008B7 E8(0000)                	call iseol?			; EOL ?
  1470 000008BA 7402                    	je .checkeol
  1471                                  .fn_j:
  1472 000008BC EB6C                    	jmp .fn				; no, is filename -->
  1473                                  					; will jump after this
  1474                                  .checkeol:
  1475 000008BE E8(0000)                	call iseol?			; EOL ?
  1476 000008C1 7463                    	je .ret_nc			; yes, no filename -->
  1477                                  
  1478 000008C3 3C28                    	cmp al, '('
  1479 000008C5 740E                    	je @F
  1480 000008C7 3C30                    	cmp al, '0'
  1481 000008C9 7303E9DCFE              	jb .retc
  1482 000008CE 3C39                    	cmp al, '9'
  1483 000008D0 7603E9D5FE              	ja .retc
  1484                                  @@:
  1485                                  
  1486                                  d4	call d4message
  1487                                  d4	asciz "In parseloadunit (after no EOL found)",13,10
  1488 000008D5 51                      	push cx
  1489 000008D6 3C28                    	cmp al, '('
  1490 000008D8 751B                    	jne .not_expr
  1491 000008DA AC                      	lodsb				; skip opening paren
  1492                                  
  1493                                  d4	call d4message
  1494                                  d4	asciz "In parseloadunit (before call to getexpression)",13,10
  1495                                  
  1496 000008DB E8(0000)[0000]          	nearcall getexpression
  1497                                  
  1498                                  d4	call d4message
  1499                                  d4	asciz "In parseloadunit (after call to getexpression)",13,10
  1500 000008E0 E8(0000)                	call skipwh0
  1501 000008E3 3C29                    	cmp al, ')'
  1502 000008E5 AC                      	lodsb
  1503 000008E6 7509                    	jne .errordec
  1504 000008E8 89D1                    	mov cx, dx
  1505 000008EA 09D9                    	or cx, bx
  1506 000008EC 750A                    	jnz .got_expr
  1507 000008EE 5A                      	pop dx
  1508 000008EF EBAA                    	jmp .got_unit
  1509                                  
  1510                                  .errordec:
  1511 000008F1 4E                      	dec si
  1512                                  .error:
  1513 000008F2 E9EFF7                  	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 000008F5 E85310                  	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 000008F8 59                      	pop cx			; cl = load unit
  1523 000008F9 80F980                  	cmp cl, 80h
  1524 000008FC 7303E9E3F7              	jb bootcmd.error		; diskettes aren't partitioned
  1525 00000901 85DB                    	test bx, bx
  1526 00000903 7403E9DCF7              	jnz bootcmd.error
  1527 00000908 81FAFF00                	cmp dx, 255
  1528 0000090C 7603E9D3F7              	ja bootcmd.error
  1529 00000911 85D2                    	test dx, dx
  1530 00000913 7503E9CCF7              	jz bootcmd.error
  1531 00000918 E8(0000)                	call skipwh0
  1532 0000091B 8856FF                  	mov byte [bp + ?partition], dl
  1533 0000091E 884EFE                  	mov byte [bp + ?unit], cl
  1534 00000921 E8(0000)                	call iseol?
  1535 00000924 7504                    	jne .fn
  1536                                  .ret_nc:
  1537 00000926 31DB                    	xor bx, bx		; NC, ZR
  1538 00000928 EB06                    	jmp @F
  1539                                  
  1540                                  .fn:
  1541 0000092A E8(0000)                	call skipwh0
  1542 0000092D 83CB01                  	or bx, 1		; NC, NZ
  1543                                  @@:
  1544 00000930 9C                      	pushf
  1545 00000931 8B5EFE                  	mov bx, word [bp + ?unit_low_partition_high]
  1546 00000934 881E[4002]              	mov byte [load_unit], bl
  1547 00000938 883E[3805]              	mov byte [load_partition], bh
  1548 0000093C 8A5EFA                  	mov bl, byte [bp + ?dif3_set]
  1549 0000093F 081E[0000]              	or byte [internalflags3], bl
  1550 00000943 F646FC01                	test byte [bp + ?bit0_no_set_sdp], 1
  1551 00000947 750E                    	jnz @F
  1552 00000949 FF76F8                  	 push word [bp + ?load_partition_sector + 2]
  1553 0000094C FF76F6                  	 push word [bp + ?load_partition_sector]
  1554 0000094F 8F06[2C05]              	 pop word [load_sdp_sector]
  1555 00000953 8F06[2E05]              	 pop word [load_sdp_sector + 2]
  1556                                  @@:
  1557 00000957 9D                      	popf			; ZF, CF
  1558 00000958 8F06[2805]              	 pop word [load_partition_sector]
  1559 0000095C 8F06[2A05]              	 pop word [load_partition_sector + 2]
  1560                                  				; pop from ?load_partition_sector
  1561 00000960 E94CFE                  	jmp .ret
  1562                                  
  1563                                  	lleave ctx
  1564                                  
  1565                                  
  1566 00000963 00                      	align 4, db 0
  1567                                  
  1568                                  boot_read:
  1569 00000964 C706[6805][8C1B]        	mov word [load_readwrite_function], read_sector
  1570 0000096A EB06                    	jmp boot_readwrite
  1571                                  
  1572                                  boot_write:
  1573 0000096C C706[6805][8B1B]        	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 00000972 E8(0000)                	call skipequals
  1581 00000975 E8C4FD                  	call parseloadunit_default_sdp
  1582 00000978 7503E9FD00              	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 0000097D E8(0000)[0000]          	nearcall getword
  1597                                  		; (variable is a word)
  1598 00000982 8916[6405]              	mov word [load_readwrite_buffer], dx
  1599                                  %endif
  1600                                  
  1601 00000986 31DB                    	xor bx, bx
  1602 00000988 53                      	push bx			; hidden specified flag (0)
  1603 00000989 53                      	push bx
  1604 0000098A 53                      	push bx			; hidden number
  1605 0000098B E8(0000)                	call skipwh0
  1606 0000098E E8(0000)                	call iseol?
  1607 00000991 750F                    	jne @F
  1608                                  
  1609                                  d4	call d4message
  1610                                  d4	asciz "In boot_readwrite no sector given no count given",13,10
  1611                                  
  1612 00000993 8326[6005]00            	and word [load_readwrite_sector], 0
  1613 00000998 8326[6205]00            	and word [load_readwrite_sector + 2], 0
  1614 0000099D BA0100                  	mov dx, 1
  1615 000009A0 EB50                    	jmp @FF
  1616                                  
  1617                                  @@:
  1618 000009A2 BA[0000]                	mov dx, msg.hidden
  1619 000009A5 4E                      	dec si
  1620 000009A6 E8(0000)                	call isstring?
  1621 000009A9 7516                    	jne .nothidden
  1622                                  
  1623 000009AB 83C406                  	add sp, 6		; discard hidden number and specified flag
  1624 000009AE BA0100                  	mov dx, 1
  1625                                  
  1626                                  .hiddencommon:
  1627 000009B1 52                      	push dx			; hidden specified flag (1 or 2)
  1628                                  
  1629 000009B2 E8(0000)                	call skipequals
  1630                                  
  1631 000009B5 E8(0000)[0000]          	nearcall getdword
  1632 000009BA 53                      	push bx
  1633 000009BB 52                      	push dx			; hidden number
  1634 000009BC E8(0000)                	call skipwh0
  1635                                  
  1636 000009BF EB11                    	jmp .hiddendone
  1637                                  .nothidden:
  1638 000009C1 BA[0000]                	mov dx, msg.hiddenadd
  1639 000009C4 E8(0000)                	call isstring?
  1640 000009C7 7508                    	jne .nothiddenadd
  1641                                  
  1642 000009C9 83C406                  	add sp, 6		; discard hidden number and specified flag
  1643 000009CC BA0200                  	mov dx, 2
  1644 000009CF EBE0                    	jmp .hiddencommon
  1645                                  
  1646                                  .nothiddenadd:
  1647 000009D1 AC                      	lodsb
  1648                                  .hiddendone:
  1649 000009D2 E8(0000)[0000]          	nearcall getexpression	; bx:dx = value
  1650                                  
  1651 000009D7 8916[6005]              	mov word [load_readwrite_sector], dx
  1652 000009DB 891E[6205]              	mov word [load_readwrite_sector + 2], bx
  1653                                  
  1654 000009DF E8(0000)                	call skipwh0
  1655 000009E2 BA0100                  	mov dx, 1
  1656 000009E5 E8(0000)                	call iseol?
  1657 000009E8 7408                    	je @F
  1658 000009EA E8(0000)[0000]          	nearcall getword
  1659 000009EF E8(0000)                	call chkeol
  1660                                  @@:
  1661 000009F2 8916[6605]              	mov word [load_readwrite_count], dx
  1662                                  
  1663 000009F6 E8B50F                  	call query_geometry
  1664                                  
  1665 000009F9 F606[0000]07            	testopt [internalflags3], dif3_load_is_dp
  1666 000009FE 753C                    	jnz .ldp
  1667                                  
  1668 00000A00 803E[3805]00            	cmp byte [load_partition], 0
  1669 00000A05 7447                    	je .whole_unit
  1670                                  
  1671 00000A07 C606[3A05]00            	mov byte [load_found_partition], 0
  1672 00000A0C B9[1E0A]                	mov cx, .single_partition
  1673 00000A0F E8EE0D                  	call scan_partitions
  1674                                  ;	cmp byte [load_found_partition], 0
  1675                                  ;	jne @F
  1676 00000A12 BA[0000]                	mov dx, msg.boot_partition_not_found
  1677 00000A15 B81502                  	mov ax, 0215h
  1678 00000A18 E8(0000)                	call setrc
  1679 00000A1B E90FFB                  	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 00000A1E A0[3905]                	mov al, byte [load_current_partition]
  1698 00000A21 3A06[3805]              	cmp al, byte [load_partition]
  1699 00000A25 7401                    	je .gotit
  1700 00000A27 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 00000A28 8B43F8                  	mov ax, [bp + di - 8]
  1709 00000A2B 8B53FA                  	mov dx, [bp + di - 6]		; base (current table position)
  1710                                  
  1711 00000A2E 26034408                	add ax, [es:si + 8]
  1712 00000A32 2613540A                	adc dx, [es:si + 8 + 2]		; add offset to logical partition
  1713                                  
  1714 00000A36 89EC                    	mov sp, bp
  1715 00000A38 5D                      	pop bp				; restore bp (scan_partitions)
  1716 00000A39 5B                      	pop bx				; discard ret address (scan_partitions)
  1717 00000A3A EB07                    	jmp .gotbase_dxax
  1718                                  
  1719                                  
  1720                                  .ldp:
  1721 00000A3C A1[2805]                	mov ax, word [load_partition_sector]
  1722 00000A3F 8B16[2A05]              	mov dx, word [load_partition_sector + 2]
  1723                                  
  1724                                  .gotbase_dxax:
  1725 00000A43 89461C                  	mov word [bp + bsBPB + bpbHiddenSectors + 0], ax
  1726 00000A46 89561E                  	mov word [bp + bsBPB + bpbHiddenSectors + 2], dx
  1727 00000A49 800E[0000]80            	setopt [internalflags3], dif3_partition_changed
  1728                                  
  1729                                  .whole_unit:
  1730 00000A4E 5A                      	pop dx
  1731 00000A4F 5B                      	pop bx				; hidden number (or zero)
  1732 00000A50 59                      	pop cx				; hidden specified flag
  1733 00000A51 E30F                    	jcxz @FF			; if not specified -->
  1734 00000A53 49                      	dec cx				; hidden flag is 1 ?
  1735 00000A54 7406                    	jz @F				; yes, replacce -->
  1736 00000A56 03561C                  	add dx, word [bp + bsBPB + bpbHiddenSectors + 0]
  1737 00000A59 135E1E                  	adc bx, word [bp + bsBPB + bpbHiddenSectors + 2]
  1738                                  					; add to hidden (HIDDENADD=)
  1739                                  
  1740                                  @@:
  1741 00000A5C 89561C                  	mov word [bp + bsBPB + bpbHiddenSectors + 0], dx
  1742 00000A5F 895E1E                  	mov word [bp + bsBPB + bpbHiddenSectors + 2], bx
  1743                                  					; overwrite hidden number with this
  1744                                  @@:
  1745                                  
  1746 00000A62 A1[6005]                	mov ax, word [load_readwrite_sector]
  1747 00000A65 8B16[6205]              	mov dx, word [load_readwrite_sector + 2]
  1748 00000A69 8B0E[6605]              	mov cx, word [load_readwrite_count]
  1749 00000A6D 8B1E[6405]              	mov bx, word [load_readwrite_buffer]
  1750                                  
  1751 00000A71 E306                    	jcxz @FF
  1752                                  @@:
  1753 00000A73 FF16[6805]              	call near word [load_readwrite_function]
  1754 00000A77 E2FA                    	loop @B
  1755                                  @@:
  1756 00000A79 C3                      	retn
  1757                                  
  1758                                  .error:
  1759 00000A7A 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 00000A7D B020                    	mov al, 32
  1779 00000A7F BF[4005]                	mov di, load_kernel_name
  1780 00000A82 B90B00                  	mov cx, 11
  1781 00000A85 F3AA                    	rep stosb		; initialise to empty
  1782                                  
  1783 00000A87 BF[4005]                	mov di, load_kernel_name
  1784 00000A8A B90900                  	mov cx, 9
  1785 00000A8D AC                      	lodsb
  1786 00000A8E 3C2E                    	cmp al, '.'
  1787 00000A90 7514                    	jne @F
  1788 00000A92 AC                      	lodsb
  1789 00000A93 E86500                  	call .separator_or_slash
  1790 00000A96 751D                    	jne .invalid
  1791 00000A98 3C2F                    	cmp al, '/'
  1792 00000A9A 7407                    	je .dotret		; --> ZR
  1793 00000A9C 3C5C                    	cmp al, '\'
  1794 00000A9E 7403                    	je .dotret		; --> ZR
  1795 00000AA0 8D74FF                  	lea si, [si - 1]	; NZ, -> at separator (first text after dot)
  1796                                  .dotret:
  1797 00000AA3 F9                      	stc			; CY return
  1798 00000AA4 C3                      	retn
  1799                                  
  1800                                  
  1801                                  .loop_name:
  1802 00000AA5 AC                      	lodsb
  1803                                  @@:
  1804 00000AA6 E8(0000)                	call capitalise
  1805 00000AA9 E84F00                  	call .separator_or_slash
  1806 00000AAC 7435                    	je .loop_name_done
  1807 00000AAE 3C2E                    	cmp al, '.'
  1808 00000AB0 740F                    	je .loop_name_ext
  1809 00000AB2 AA                      	stosb
  1810 00000AB3 E2F0                    	loop .loop_name
  1811                                  .invalid:
  1812 00000AB5 BA[0000]                	mov dx, msg.boot_invalid_filename
  1813 00000AB8 B81602                  	mov ax, 0216h
  1814 00000ABB E8(0000)                	call setrc
  1815 00000ABE E96CFA                  	jmp bootcmd.fail
  1816                                  
  1817                                  .loop_name_ext:
  1818 00000AC1 83F909                  	cmp cx, 9
  1819 00000AC4 74EF                    	je .invalid
  1820 00000AC6 B90400                  	mov cx, 4
  1821 00000AC9 BF[4805]                	mov di, load_kernel_name + 8
  1822                                  .loop_ext:
  1823 00000ACC AC                      	lodsb
  1824 00000ACD E8(0000)                	call capitalise
  1825 00000AD0 E82800                  	call .separator_or_slash
  1826 00000AD3 7409                    	je .loop_ext_done
  1827 00000AD5 3C2E                    	cmp al, '.'
  1828 00000AD7 74DC                    	je .invalid
  1829 00000AD9 AA                      	stosb
  1830 00000ADA E2F0                    	loop .loop_ext
  1831 00000ADC EBD7                    	jmp .invalid
  1832                                  
  1833                                  .loop_ext_done:
  1834 00000ADE 83F904                  	cmp cx, 4
  1835 00000AE1 74D2                    	je .invalid
  1836                                  .loop_name_done:
  1837 00000AE3 83F909                  	cmp cx, 9
  1838 00000AE6 74CD                    	je .invalid
  1839 00000AE8 C606[4B05]00            	mov byte [load_kernel_name + 11], 0
  1840 00000AED 803E[4005]E5            	cmp byte [load_kernel_name], 0E5h
  1841 00000AF2 7505                    	jne @F
  1842 00000AF4 C606[4005]05            	mov byte [load_kernel_name], 05h
  1843                                  @@:
  1844 00000AF9 F8                      	clc			; NC return
  1845 00000AFA C3                      	retn
  1846                                  
  1847                                  .separator_or_slash:
  1848 00000AFB E8(0000)                	call iseol?
  1849 00000AFE 740E                    	je @F
  1850 00000B00 3C20                    	cmp al, 32
  1851 00000B02 740A                    	je @F
  1852 00000B04 3C09                    	cmp al, 9
  1853 00000B06 7406                    	je @F
  1854 00000B08 3C2F                    	cmp al, '/'
  1855 00000B0A 7402                    	je @F
  1856 00000B0C 3C5C                    	cmp al, '\'
  1857                                  @@:
  1858 00000B0E 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 00000B0F A0[3905]                	mov al, byte [load_current_partition]
  1873 00000B12 3A06[3805]              	cmp al, byte [load_partition]
  1874 00000B16 7401                    	je .gotit
  1875 00000B18 C3                      	retn
  1876                                  
  1877                                  .gotit:
  1878                                  d4	call d4message
  1879                                  d4	asciz "In load_from_partition.gotit",13,10
  1880                                  
  1881 00000B19 8B43F8                  	mov ax, [bp + di - 8]
  1882 00000B1C 8B53FA                  	mov dx, [bp + di - 6]		; base (current table position)
  1883                                  
  1884 00000B1F 52                      	push dx
  1885 00000B20 50                      	push ax
  1886 00000B21 06                      	push es
  1887 00000B22 BB6000                  	mov bx, 60h
  1888 00000B25 E85210                  	call read_ae_512_bytes		; load partition table to 0:600h
  1889 00000B28 07                      	pop es
  1890 00000B29 58                      	pop ax
  1891 00000B2A 5A                      	pop dx
  1892                                  
  1893 00000B2B 26034408                	add ax, [es:si + 8]
  1894 00000B2F 2613540A                	adc dx, [es:si + 8 + 2]		; add offset to logical partition
  1895                                  
  1896 00000B33 26894408                	mov word [es:si + 8], ax
  1897 00000B37 2689540A                	mov word [es:si + 8 + 2], dx	; store in partition table entry
  1898                                  
  1899 00000B3B 31C9                    	xor cx, cx
  1900 00000B3D 8EC1                    	mov es, cx			; es = 0
  1901                                  %if _LINK_COMPAT
  1902 00000B3F 8DB4BE07                	lea si, [si + 600h + (510 - 64)]
  1903 00000B43 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 00000B47 26894408                	mov word [es:si + 8], ax
  1909 00000B4B 2689540A                	mov word [es:si + 8 + 2], dx	; store in partition table entry
  1910                                  
  1911                                  					; dx:ax = absolute sector number
  1912 00000B4F BBC007                  	mov bx, 7C0h			; bx:0 = 7C0h:0 -> boot sector area
  1913 00000B52 E82510                  	call read_ae_512_bytes		; load partition boot sector to 0:7C00h
  1914                                  
  1915 00000B55 89EC                    	mov sp, bp
  1916 00000B57 5D                      	pop bp				; restore bp (scan_partitions)
  1917 00000B58 58                      	pop ax				; discard ret address (scan_partitions)
  1918                                  
  1919 00000B59 26813EFE0155AA          	cmp word [es:510], 0AA55h
  1920 00000B60 7403E9D714              	jne boot_sigmismatch
  1921                                  
  1922 00000B65 31C9                    	xor cx, cx
  1923 00000B67 26390E0000              	cmp word [es:0], cx
  1924 00000B6C 7503E9D714              	je boot_codemismatch
  1925                                  
  1926 00000B71 8EC1                    	mov es, cx			; cx = 0, es = 0
  1927 00000B73 89F7                    	mov di, si			; di -> partition table entry (seg 0)
  1928 00000B75 26800D80                	or byte [es:di + 0], 80h	; set bootable flag
  1929 00000B79 A0[4002]                	mov al, byte [load_unit]	; al = unit
  1930 00000B7C BB007C                  	mov bx, 7C00h			; bx = 7C00h
  1931 00000B7F E955F9                  	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 00000B82 A0[3905]                	mov al, byte [load_current_partition]
  1946 00000B85 3A06[3805]              	cmp al, byte [load_partition]
  1947 00000B89 7401                    	je .gotit
  1948 00000B8B C3                      	retn
  1949                                  
  1950                                  .gotit:
  1951                                  d4	call d4message
  1952                                  d4	asciz "In load_freedos_from_partition.gotit",13,10
  1953                                  
  1954 00000B8C 8B43F8                  	mov ax, [bp + di - 8]
  1955 00000B8F 8B53FA                  	mov dx, [bp + di - 6]		; base (current table position)
  1956                                  
  1957 00000B92 26034408                	add ax, [es:si + 8]
  1958 00000B96 2613540A                	adc dx, [es:si + 8 + 2]		; add offset to logical partition
  1959                                  
  1960 00000B9A 26894408                	mov word [es:si + 8], ax
  1961 00000B9E 2689540A                	mov word [es:si + 8 + 2], dx	; store in partition table entry
  1962 00000BA2 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 00000BA6 F606[6902]40            	testopt [load_options], LOAD_SET_DSSI_PARTINFO
  1975 00000BAB 7431                    	jz @F
  1976                                  
  1977 00000BAD 52                      	push dx
  1978 00000BAE 50                      	push ax
  1979                                  
  1980 00000BAF 8B43F8                  	mov ax, [bp + di - 8]
  1981 00000BB2 8B53FA                  	mov dx, [bp + di - 6]		; base (current table position)
  1982                                  
  1983 00000BB5 52                      	push dx
  1984 00000BB6 50                      	push ax
  1985 00000BB7 06                      	push es
  1986                                  %if _LOADER
  1987                                  	mov bx, [loader_lowest_free]
  1988                                  	push bx
  1989                                  %else
  1990 00000BB8 BB6000                  	mov bx, 60h
  1991                                  %endif
  1992 00000BBB E8BC0F                  	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 00000BBE 07                      	pop es
  1998 00000BBF 58                      	pop ax
  1999 00000BC0 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 00000BC1 31C9                    	xor cx, cx
  2014 00000BC3 8EC1                    	mov es, cx			; es = 0
  2015                                  %if _LINK_COMPAT
  2016 00000BC5 8DBCBE07                	lea di, [si + 600h + (510 - 64)]
  2017 00000BC9 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 00000BCD B90800                  	mov cx, 16 / 2
  2024 00000BD0 06                      	 push es
  2025 00000BD1 57                      	 push di
  2026 00000BD2 F3A5                    	rep movsw
  2027 00000BD4 8F06[3405]              	 pop word [load_partition_entry]
  2028 00000BD8 8F06[3605]              	 pop word [load_partition_entry + 2]
  2029                                  
  2030 00000BDC 58                      	pop ax
  2031 00000BDD 5A                      	pop dx
  2032                                  @@:
  2033                                  
  2034                                  
  2035 00000BDE 89EC                    	mov sp, bp
  2036 00000BE0 5D                      	pop bp				; restore bp (scan_partitions)
  2037 00000BE1 5B                      	pop bx				; discard ret address (scan_partitions)
  2038                                  
  2039                                  					; dx:ax = absolute sector number
  2040 00000BE2 8B1E[0000]              	mov bx, word [auxbuff_segorsel]	; bx => auxbuff
  2041 00000BE6 50                      	push ax
  2042 00000BE7 52                      	push dx
  2043 00000BE8 E88F0F                  	call read_ae_512_bytes		; load partition boot sector
  2044                                  
  2045 00000BEB 26813EFE0155AA          	cmp word [es:510], 0AA55h
  2046 00000BF2 7403E94514              	jne boot_sigmismatch
  2047                                  
  2048 00000BF7 31C9                    	xor cx, cx
  2049                                  ;	cmp word [es:0], cx
  2050                                  ;	je boot_codemismatch
  2051                                  
  2052 00000BF9 5A                      	pop dx
  2053 00000BFA 58                      	pop ax
  2054                                  
  2055                                  		; dx:ax = boot sector
  2056                                  		; byte [load_unit] = unit
  2057                                  		; es:0-> read sector
  2058                                  load_freedos_common:
  2059 00000BFB 26A31C00                	mov word [es:bsBPB + bpbHiddenSectors], ax
  2060 00000BFF 2689161E00              	mov word [es:bsBPB + bpbHiddenSectors + 2], dx
  2061                                  
  2062 00000C04 8B5E0B                  	mov bx, [bp + bsBPB + bpbBytesPerSector]
  2063 00000C07 263B1E0B00              	cmp bx, [es:bsBPB + bpbBytesPerSector]
  2064 00000C0C 7403E93F14              	jne boot_secsizemismatch
  2065                                  
  2066                                  		; preserve some variables from our pseudo BPB
  2067 00000C11 31C0                    	xor ax, ax
  2068 00000C13 FF7618                  	push word [bp + bsBPB + bpbCHSSectors]
  2069 00000C16 268F061800              	pop word [es:bsBPB + bpbCHSSectors]
  2070 00000C1B FF761A                  	push word [bp + bsBPB + bpbCHSHeads]
  2071 00000C1E 268F061A00              	pop word [es:bsBPB + bpbCHSHeads]	; preserve geometry
  2072                                  
  2073 00000C23 8B5EEA                  	mov bx, word [bp + ldParaPerSector]
  2074 00000C26 D1EB                    	shr bx, 1
  2075 00000C28 895ED4                  	mov word [bp + ldEntriesPerSector], bx
  2076                                  
  2077 00000C2B 2639061600              	cmp word [es:bsBPB + bpbSectorsPerFAT], ax
  2078 00000C30 8A5E40                  	mov bl, byte [bp + bsBPB + ebpbNew + bpbnBootUnit]
  2079 00000C33 7407                    	je .is_fat32
  2080 00000C35 26881E2400              	mov byte [es:bsBPB + bpbNew + bpbnBootUnit], bl
  2081 00000C3A EB05                    	jmp short .was_fat1612
  2082                                  .is_fat32:
  2083 00000C3C 26881E4000              	mov byte [es:bsBPB + ebpbNew + bpbnBootUnit], bl
  2084                                  .was_fat1612:
  2085                                  
  2086 00000C41 06                      	 push es
  2087 00000C42 1E                      	 push ds
  2088 00000C43 06                      	push es
  2089 00000C44 1F                      	pop ds
  2090 00000C45 31F6                    	xor si, si				; -> BPB from boot partition
  2091 00000C47 16                      	push ss
  2092 00000C48 07                      	pop es
  2093 00000C49 BF[0002]                	mov di, load_data - LOADDATA2		; -> our copy of a BPB
  2094 00000C4C B95A00                  	mov cx, (bsBPB + ebpbNew + BPBN_size)
  2095 00000C4F F3A4                    	rep movsb				; get the BPB
  2096                                  
  2097 00000C51 1F                      	 pop ds
  2098 00000C52 800E[0000]80            	setopt [internalflags3], dif3_partition_changed
  2099                                  
  2100 00000C57 394616                  	cmp word [bp + bsBPB + bpbSectorsPerFAT], ax
  2101 00000C5A 740B                    	je @F					; is FAT32 -->
  2102 00000C5C BE[2402]                	mov si, load_data - LOADDATA2 + bsBPB + bpbNew
  2103 00000C5F BF[4002]                	mov di, load_data - LOADDATA2 + bsBPB + ebpbNew
  2104 00000C62 B91A00                  	mov cx, BPBN_size
  2105 00000C65 F3A4                    	rep movsb				; clone the FAT16 / FAT12 BPBN
  2106                                  						; to where the FAT32 BPBN lives
  2107                                  @@:
  2108 00000C67 07                      	 pop es
  2109                                  
  2110 00000C68 E8(0000)                	call bootgetmemorysize
  2111 00000C6B 8956E0                  	mov word [bp + ldMemoryTop], dx
  2112 00000C6E 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 00000C72 7303                    	jnc @F
  2117                                  .outofmem:
  2118 00000C74 E9B80E                  	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 00000C77 81EA0002                	sub dx, 8192 >> 4
  2132 00000C7B 72F7                    	jc .outofmem
  2133 00000C7D 8956F8                  	mov word [bp + lsvFATSeg], dx
  2134 00000C80 B8FFFF                  	mov ax, -1
  2135 00000C83 8946F4                  	mov word [bp + lsvFATSector], ax
  2136 00000C86 8946F6                  	mov word [bp + lsvFATSector + 2], ax
  2137                                  
  2138 00000C89 A1[6A02]                	mov ax, word [load_loadseg]
  2139 00000C8C 8946FA                  	mov word [bp + lsvLoadSeg], ax
  2140                                  %if _LOADER
  2141                                  	cmp ax, [loader_lowest_free]
  2142                                  	jb ..@loader_too_low_load
  2143                                  %endif
  2144 00000C8F 31DB                    	xor bx, bx
  2145 00000C91 B98000                  	mov cx, ((256 + 15) & ~15) >> 1
  2146 00000C94 F606[6902]20            	testopt [load_options], LOAD_NO_BPB
  2147 00000C99 7506                    	jnz @F
  2148 00000C9B BB0002                  	mov bx, 512
  2149 00000C9E B98001                  	mov cx, ((512 + 256 + 15) & ~15) >> 1
  2150                                  @@:
  2151 00000CA1 F606[6902]10            	testopt [load_options], LOAD_CMDLINE
  2152 00000CA6 7404                    	jz @F
  2153 00000CA8 81C18000                	add cx, (256) >> 1
  2154                                  @@:
  2155                                  
  2156 00000CAC 833E[7202]FF            	cmp word [load_bpb + 2], -1
  2157 00000CB1 7475                    	je .auto_bpb
  2158                                  
  2159 00000CB3 A1[7002]                	mov ax, [load_bpb]
  2160 00000CB6 D1E8                    	shr ax, 1
  2161 00000CB8 D1E8                    	shr ax, 1
  2162 00000CBA D1E8                    	shr ax, 1
  2163 00000CBC D1E8                    	shr ax, 1		; round down: start of BPB
  2164 00000CBE 0306[7202]              	add ax, [load_bpb + 2]	; start of BPB
  2165 00000CC2 83E810                  	sub ax, (256) >> 4	; start of stack area
  2166 00000CC5 720A                    	jc @F
  2167 00000CC7 F606[6902]10            	testopt [load_options], LOAD_CMDLINE
  2168 00000CCC 7403                    	jz @F
  2169 00000CCE 83E810                  	sub ax, (256) >> 4
  2170                                  @@:
  2171 00000CD1 50                      	push ax
  2172 00000CD2 7235                    	jc .bpb_too_low
  2173                                  
  2174 00000CD4 3B46FA                  	cmp ax, word [bp + lsvLoadSeg]
  2175 00000CD7 773B                    	ja .loads_below_bpb
  2176                                  
  2177                                  %if _LOADER
  2178                                  	cmp ax, [loader_lowest_free]
  2179                                  %else
  2180 00000CD9 83F860                  	cmp ax, 60h
  2181                                  %endif
  2182 00000CDC 722B                    	jb .bpb_too_low
  2183                                  
  2184 00000CDE A1[7002]                	mov ax, [load_bpb]
  2185 00000CE1 01D8                    	add ax, bx
  2186 00000CE3 83C00F                  	add ax, 15
  2187 00000CE6 D1E8                    	shr ax, 1
  2188 00000CE8 D1E8                    	shr ax, 1
  2189 00000CEA D1E8                    	shr ax, 1
  2190 00000CEC D1E8                    	shr ax, 1
  2191 00000CEE 0306[7202]              	add ax, [load_bpb + 2]	; end of BPB / pseudo-boot-sector
  2192                                  
  2193 00000CF2 3B46FA                  	cmp ax, word [bp + lsvLoadSeg]
  2194 00000CF5 761F                    	jbe .loads_above_bpb
  2195                                  
  2196 00000CF7 BA[0000]                	mov dx, msg.boot_bpb_load_overlap
  2197 00000CFA B81702                  	mov ax, 0217h
  2198 00000CFD E8(0000)                	call setrc
  2199                                  .fail:
  2200 00000D00 B81802                  	mov ax, 0218h
  2201 00000D03 E8(0000)                	call setrc
  2202 00000D06 E924F8                  	jmp bootcmd.fail
  2203                                  
  2204                                  .bpb_too_low:
  2205 00000D09 BA[0000]                	mov dx, msg.boot_bpb_too_low
  2206 00000D0C B81902                  	mov ax, 0219h
  2207 00000D0F E8(0000)                	call setrc
  2208 00000D12 EBEC                    	jmp .fail
  2209                                  
  2210                                  
  2211                                  
  2212                                  .loads_below_bpb:
  2213 00000D14 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 00000D16 FF36[7202]              	push word [load_bpb + 2]
  2217 00000D1A 8F06[2605]              	pop word [load_bpb_dest + 2]
  2218 00000D1E FF36[7002]              	push word [load_bpb]
  2219 00000D22 8F06[2405]              	pop word [load_bpb_dest]
  2220 00000D26 EB50                    	jmp .got_bpb_set_load_top
  2221                                  
  2222                                  
  2223                                  		; auto-BPB: allocate BPB at top and load below that
  2224                                  .auto_bpb:
  2225 00000D28 83EA10                  	sub dx, (256 + 15) >> 4
  2226 00000D2B 7303E944FF              	jc .outofmem
  2227 00000D30 F606[6902]10            	testopt [load_options], LOAD_CMDLINE
  2228 00000D35 7408                    	jz @F
  2229 00000D37 83EA10                  	sub dx, (256) >> 4
  2230 00000D3A 7303E935FF              	jc .outofmem
  2231                                  @@:
  2232 00000D3F 85DB                    	test bx, bx
  2233 00000D41 7408                    	jz @F
  2234 00000D43 83EA20                  	sub dx, 512 >> 4
  2235 00000D46 7303E929FF              	jc .outofmem
  2236                                  @@:
  2237                                  
  2238 00000D4B 52                      	push dx
  2239 00000D4C 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 00000D4E BB00FF                  	mov bx, (- 256)
  2247 00000D51 F606[6902]10            	testopt [load_options], LOAD_CMDLINE
  2248 00000D56 7404                    	jz @F
  2249 00000D58 81EB0001                	sub bx, (256)
  2250                                  @@:
  2251 00000D5C 031E[7002]              	add bx, word [load_bpb]
  2252 00000D60 51                      	push cx
  2253 00000D61 B104                    	mov cl, 4
  2254 00000D63 D3EB                    	shr bx, cl
  2255 00000D65 59                      	pop cx
  2256 00000D66 29D8                    	sub ax, bx
  2257                                  	; sub ax, (-256 + 7C00h) / 16
  2258 00000D68 7303E907FF              	jc .outofmem
  2259                                  	; mov word [load_bpb_dest], 7C00h
  2260 00000D6D FF36[7002]              	push word [load_bpb]
  2261 00000D71 8F06[2405]              	pop word [load_bpb_dest]
  2262 00000D75 A3[2605]                	mov word [load_bpb_dest + 2], ax
  2263                                  .got_bpb_set_load_top:
  2264 00000D78 8956E2                  	mov word [bp + ldLoadTop], dx
  2265                                  
  2266                                  .got_bpb:		; cx = how many words are used for stack/lsv/BPB
  2267 00000D7B 58                      	pop ax		; -> stack area
  2268 00000D7C 06                      	push es
  2269 00000D7D 8EC0                    	mov es, ax
  2270 00000D7F 31FF                    	xor di, di
  2271 00000D81 31C0                    	xor ax, ax
  2272 00000D83 F3AB                    	rep stosw
  2273 00000D85 07                      	pop es
  2274                                  
  2275 00000D86 E88C18                  	call initialise_fs
  2276                                  
  2277 00000D89 C606[3B05]00            	mov byte [load_check_dir_attr], 0
  2278 00000D8E 8B36[4C05]              	mov si, word [load_kernelname_input]
  2279 00000D92 803C2F                  	cmp byte [si], '/'
  2280 00000D95 7501                    	jne @F
  2281 00000D97 46                      	inc si
  2282                                  @@:
  2283                                  .dotcomponent:
  2284 00000D98 803C00                  	cmp byte [si], 0
  2285 00000D9B 7504                    	jne @F
  2286 00000D9D 8B36[6002]              	mov si, word [load_kernelname_default]
  2287                                  @@:
  2288 00000DA1 16                      	 push ss
  2289 00000DA2 07                      	 pop es
  2290 00000DA3 E8D7FC                  	call boot_parse_fn	; get next pathname
  2291 00000DA6 72F0                    	jc .dotcomponent
  2292 00000DA8 3C2F                    	cmp al, '/'
  2293 00000DAA 7509                    	jne @F
  2294 00000DAC C606[3B05]10            	mov byte [load_check_dir_attr], ATTR_DIRECTORY
  2295 00000DB1 8936[4E05]              	mov word [load_kernelname_next], si
  2296                                  @@:
  2297                                  
  2298 00000DB5 BFFFFF                  	mov di, -1
  2299 00000DB8 89FE                    	mov si, di
  2300 00000DBA 897EF4                  	mov [bp + lsvFATSector], di
  2301 00000DBD 8976F6                  	mov [bp + lsvFATSector + 2], si
  2302                                  
  2303 00000DC0 31C0                    	xor ax, ax
  2304 00000DC2 31D2                    	xor dx, dx
  2305                                  
  2306                                  scan_dir_kernelname_loop:
  2307 00000DC4 8946EC                  	mov word [bp + ldDirCluster], ax
  2308 00000DC7 8956EE                  	mov word [bp + ldDirCluster + 2], dx
  2309                                  
  2310 00000DCA 31DB                    	xor bx, bx
  2311 00000DCC 8EC3                    	mov es, bx
  2312 00000DCE BB0005                  	mov bx, 500h
  2313 00000DD1 E8E507                  	call scan_dir_aux_for_file
  2314                                  
  2315 00000DD4 803E[3B05]10            	cmp byte [load_check_dir_attr], ATTR_DIRECTORY
  2316 00000DD9 753E                    	jne got_kernelentry
  2317                                  
  2318 00000DDB 56                      	push si
  2319 00000DDC 57                      	push di
  2320 00000DDD C606[3B05]00            	mov byte [load_check_dir_attr], 0
  2321 00000DE2 8B36[4E05]              	mov si, word [load_kernelname_next]
  2322                                  .dotcomponent_next:
  2323 00000DE6 803C00                  	cmp byte [si], 0
  2324 00000DE9 7504                    	jne @F
  2325 00000DEB 8B36[6002]              	mov si, word [load_kernelname_default]
  2326                                  @@:
  2327 00000DEF 06                      	push es
  2328 00000DF0 16                      	 push ss
  2329 00000DF1 07                      	 pop es
  2330 00000DF2 E888FC                  	call boot_parse_fn	; get next pathname
  2331 00000DF5 07                      	pop es
  2332 00000DF6 72EE                    	jc .dotcomponent_next
  2333 00000DF8 3C2F                    	cmp al, '/'
  2334 00000DFA 7509                    	jne @F
  2335 00000DFC C606[3B05]10            	mov byte [load_check_dir_attr], ATTR_DIRECTORY
  2336 00000E01 8936[4E05]              	mov word [load_kernelname_next], si
  2337                                  @@:
  2338 00000E05 5F                      	pop di
  2339 00000E06 5E                      	pop si
  2340                                  
  2341 00000E07 31D2                    	xor dx, dx
  2342 00000E09 268B471A                	mov ax, [es:bx + deClusterLow]
  2343                                  				; = first cluster (not FAT32)
  2344 00000E0D 807EE620                	cmp byte [bp + ldFATType], 32
  2345 00000E11 7504                    	jne @F
  2346 00000E13 268B5714                	mov dx, [es:bx + deClusterHigh]
  2347                                  				; dx:ax = first cluster (FAT32)
  2348                                  @@:
  2349                                  
  2350 00000E17 EBAB                    	jmp scan_dir_kernelname_loop
  2351                                  
  2352                                  
  2353                                  got_kernelentry:
  2354 00000E19 56                      	push si
  2355 00000E1A 57                      	push di
  2356                                  
  2357 00000E1B C606[3B05]00            	mov byte [load_check_dir_attr], 0
  2358 00000E20 8B36[5005]              	mov si, word [load_addname_input]
  2359 00000E24 803C2F                  	cmp byte [si], '/'
  2360 00000E27 7511                    	jne @F
  2361 00000E29 46                      	inc si
  2362 00000E2A 803C2F                  	cmp byte [si], '/'
  2363 00000E2D 7503E9A800              	je got_no_addentry.no_dxax_on_stack
  2364                                  
  2365 00000E32 31C0                    	xor ax, ax
  2366 00000E34 8946EC                  	mov word [bp + ldDirCluster], ax
  2367 00000E37 8946EE                  	mov word [bp + ldDirCluster + 2], ax
  2368                                  				; search from root directory
  2369                                  @@:
  2370                                  .dotcomponent_next:
  2371 00000E3A 803C00                  	cmp byte [si], 0
  2372 00000E3D 750C                    	jne @F
  2373 00000E3F 8B36[6202]              	mov si, word [load_addname_default]
  2374 00000E43 803C00                  	cmp byte [si], 0
  2375 00000E46 7503E98F00              	je got_no_addentry.no_dxax_on_stack
  2376                                  @@:
  2377 00000E4B 16                      	 push ss
  2378 00000E4C 07                      	 pop es
  2379 00000E4D E82DFC                  	call boot_parse_fn	; get next pathname
  2380 00000E50 72E8                    	jc .dotcomponent_next
  2381 00000E52 3C2F                    	cmp al, '/'
  2382 00000E54 7509                    	jne @F
  2383 00000E56 C606[3B05]10            	mov byte [load_check_dir_attr], ATTR_DIRECTORY
  2384 00000E5B 8936[5205]              	mov word [load_addname_next], si
  2385                                  @@:
  2386 00000E5F 5F                      	pop di
  2387 00000E60 5E                      	pop si
  2388 00000E61 EB06                    	jmp @F
  2389                                  
  2390                                  
  2391                                  scan_dir_addname_loop:
  2392 00000E63 8946EC                  	mov word [bp + ldDirCluster], ax
  2393 00000E66 8956EE                  	mov word [bp + ldDirCluster + 2], dx
  2394                                  
  2395                                  @@:
  2396 00000E69 31DB                    	xor bx, bx
  2397 00000E6B 8EC3                    	mov es, bx
  2398 00000E6D BB2005                  	mov bx, 520h	;  0:bx -> space for second directory entry
  2399 00000E70 E84607                  	call scan_dir_aux_for_file
  2400                                  
  2401 00000E73 803E[3B05]10            	cmp byte [load_check_dir_attr], ATTR_DIRECTORY
  2402 00000E78 756E                    	jne got_addentry
  2403                                  
  2404 00000E7A 56                      	push si
  2405 00000E7B 57                      	push di
  2406 00000E7C 52                      	push dx
  2407 00000E7D 50                      	push ax
  2408 00000E7E C606[3B05]00            	mov byte [load_check_dir_attr], 0
  2409 00000E83 8B36[5205]              	mov si, word [load_addname_next]
  2410                                  .dotcomponent_next:
  2411 00000E87 803C00                  	cmp byte [si], 0
  2412 00000E8A 7509                    	jne @F
  2413 00000E8C 8B36[6202]              	mov si, word [load_addname_default]
  2414 00000E90 803C00                  	cmp byte [si], 0
  2415 00000E93 7443                    	je got_no_addentry
  2416                                  @@:
  2417 00000E95 06                      	push es
  2418 00000E96 16                      	 push ss
  2419 00000E97 07                      	 pop es
  2420 00000E98 E8E2FB                  	call boot_parse_fn	; get next pathname
  2421 00000E9B 07                      	pop es
  2422 00000E9C 72E9                    	jc .dotcomponent_next
  2423 00000E9E 3C2F                    	cmp al, '/'
  2424 00000EA0 7509                    	jne @F
  2425 00000EA2 C606[3B05]10            	mov byte [load_check_dir_attr], ATTR_DIRECTORY
  2426 00000EA7 8936[5205]              	mov word [load_addname_next], si
  2427                                  @@:
  2428 00000EAB 58                      	pop ax
  2429 00000EAC 5A                      	pop dx
  2430 00000EAD 5F                      	pop di
  2431 00000EAE 5E                      	pop si
  2432                                  
  2433 00000EAF 31D2                    	xor dx, dx
  2434 00000EB1 268B471A                	mov ax, [es:bx + deClusterLow]
  2435                                  				; = first cluster (not FAT32)
  2436 00000EB5 807EE620                	cmp byte [bp + ldFATType], 32
  2437 00000EB9 7504                    	jne @F
  2438 00000EBB 268B5714                	mov dx, [es:bx + deClusterHigh]
  2439                                  				; dx:ax = first cluster (FAT32)
  2440                                  @@:
  2441                                  
  2442 00000EBF 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 00000EC1 B90400                  	mov cx, 4
  2454                                  @@:
  2455 00000EC4 D0EA                    	shr dl, 1
  2456 00000EC6 D1D8                    	rcr ax, 1
  2457 00000EC8 D1DB                    	rcr bx, 1
  2458 00000ECA E2F8                    	loop @B			; cx = 0
  2459                                  
  2460 00000ECC 08D0                    	or al, dl
  2461 00000ECE 89DA                    	mov dx, bx		; size in paragraphs
  2462 00000ED0 85C0                    	test ax, ax		; > 0FFFFh ?
  2463 00000ED2 7403                    	jz @F			; no, take actual size -->
  2464 00000ED4 BAFFFF                  	mov dx, 0FFFFh		; clamp to 0FFFFh
  2465                                  @@:
  2466 00000ED7 C3                      	retn
  2467                                  
  2468                                  
  2469                                  got_no_addentry:
  2470 00000ED8 58                      	pop ax
  2471 00000ED9 5A                      	pop dx
  2472                                  .no_dxax_on_stack:
  2473                                  ;	push ax
  2474 00000EDA B91000                  	mov cx, 16
  2475 00000EDD 31C0                    	xor ax, ax
  2476 00000EDF 8EC0                    	mov es, ax
  2477 00000EE1 BF2005                  	mov di, 520h	; es:di -> space for second directory entry
  2478 00000EE4 F3AB                    	rep stosw	; store zeros
  2479                                  ;	pop ax
  2480                                  
  2481 00000EE6 5F                      	pop di
  2482 00000EE7 5E                      	pop si
  2483                                  
  2484                                  got_addentry:
  2485 00000EE8 31C0                    	xor ax, ax
  2486 00000EEA 8EC0                    	mov es, ax
  2487                                  
  2488                                  
  2489                                  ; (boot32.asm code starts here)
  2490                                  
  2491 00000EEC 8B46E2                  	mov ax, word [bp + ldLoadTop]
  2492 00000EEF 2B46EA                  	sub ax, word [bp + ldParaPerSector]
  2493 00000EF2 7303E97DFD              	jc load_freedos_common.outofmem
  2494 00000EF7 8946D6                  	mov [bp + ldLastAvailableSector], ax
  2495                                  
  2496 00000EFA 268B1E1C05              		mov bx, [es:500h + deSize]
  2497 00000EFF 26A11E05                		mov ax, [es:500h + deSize + 2] ; ax:bx = file size
  2498 00000F03 268A160C05              		mov dl, [es:500h + 12]	; dl = FAT+ size bits
  2499 00000F08 88D6                    		mov dh, dl
  2500 00000F0A 81E207E0                		and dx, 0E007h		; obtain bits 7-5 and 2-0
  2501 00000F0E D0EE                    		shr dh, 1
  2502 00000F10 D0EE                    		shr dh, 1
  2503 00000F12 08F2                    		or dl, dh		; dl:ax:bx = file size
  2504 00000F14 52                      		push dx
  2505 00000F15 50                      		push ax
  2506 00000F16 53                      		push bx
  2507                                  
  2508 00000F17 E8A7FF                  		call helper_shift_down_and_clamp
  2509                                  					; round down to next paragraph boundary
  2510 00000F1A 3916[6402]              		cmp word [load_minpara], dx
  2511                                  					; compare size (rounded down) to minpara
  2512 00000F1E 7603E9A200              		ja error_filetoosmall	; too small -->
  2513                                  
  2514 00000F23 5B                      		pop bx
  2515 00000F24 58                      		pop ax
  2516 00000F25 5A                      		pop dx
  2517 00000F26 8B4E0B                  		mov cx, [bp + bsBPB + bpbBytesPerSector]
  2518 00000F29 49                      		dec cx			; BpS - 1
  2519 00000F2A 01CB                    		add bx, cx
  2520 00000F2C 83D000                  		adc ax, 0
  2521 00000F2F 80D200                  		adc dl, 0		; round up to next sector
  2522 00000F32 F7D1                    		not cx			; ~ (BpS - 1)
  2523 00000F34 21CB                    		and bx, cx		; mask to limit to rounded-up sector
  2524 00000F36 E888FF                  		call helper_shift_down_and_clamp
  2525                                  
  2526                                  			; dx = size in paragraphs, rounded up to sector
  2527 00000F39 A1[6602]                		mov ax, word [load_maxpara]
  2528 00000F3C 39C2                    		cmp dx, ax		; actual size below maximum ?
  2529 00000F3E 7602                    		jbe @F			; yes, use actual size -->
  2530 00000F40 89C2                    		mov dx, ax		; use maximum size (or 0)
  2531                                  @@:
  2532 00000F42 8956D8                  		mov word [bp + ldParasLeft], dx
  2533 00000F45 894EDA                  		mov word [bp + ldParasDone], cx
  2534                                  					; = 0
  2535                                  
  2536                                  ; get starting cluster of file
  2537 00000F48 31D2                    		xor dx, dx
  2538 00000F4A 26A11A05                		mov ax, [es:500h + deClusterLow]
  2539                                  					; = first cluster (not FAT32)
  2540                                  
  2541 00000F4E 807EE620                		cmp byte [bp + ldFATType], 32
  2542 00000F52 7505                    		jne @F
  2543 00000F54 268B161405              		mov dx, [es:500h + deClusterHigh]
  2544                                  					; dx:ax = first cluster (FAT32)
  2545                                  @@:
  2546                                  
  2547 00000F59 8946F0                  		mov word [bp + lsvFirstCluster], ax
  2548 00000F5C 8956F2                  		mov word [bp + lsvFirstCluster + 2], dx
  2549                                  
  2550 00000F5F E86C08                  		call check_clust
  2551 00000F62 7303E9EB16              		jc error_badchain
  2552                                  
  2553                                  next_load_cluster:
  2554 00000F67 E83907                  		call clust_to_first_sector
  2555                                  			; dx:ax = first sector of cluster
  2556                                  			; cx:bx = cluster value
  2557 00000F6A 51                      		push cx
  2558 00000F6B 53                      		push bx			; preserve cluster number for later
  2559                                  
  2560 00000F6C 8B4EE8                  		mov cx, [bp + ldClusterSize]
  2561                                  
  2562 00000F6F 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 00000F72 3B5ED6                  		cmp bx, [bp + ldLastAvailableSector]
  2567 00000F75 7613                    		jbe @F
  2568 00000F77 833E[6602]00            		cmp word [load_maxpara], 0
  2569 00000F7C 743D                    		je @FF			; if to allow partial load -->
  2570 00000F7E BA[0000]                		mov dx, msg.boot_file_too_big_error
  2571 00000F81 B81A02                  		mov ax, 021Ah
  2572 00000F84 E8(0000)                		call setrc
  2573 00000F87 E9A3F5                  		jmp bootcmd.fail
  2574                                  
  2575                                  @@:
  2576 00000F8A 06                      		push es		; (must preserve ADR_FATBUF reference)
  2577 00000F8B E8FE0B                  		call read_sector
  2578 00000F8E 07                      		pop es
  2579 00000F8F 895EFA                  		mov [bp + lsvLoadSeg], bx	; => after last read data
  2580                                  
  2581 00000F92 50                      		push ax
  2582 00000F93 8B46EA                  		mov ax, [bp + ldParaPerSector]
  2583 00000F96 0146DA                  		add word [bp + ldParasDone], ax
  2584 00000F99 833E[6602]00            		cmp word [load_maxpara], 0
  2585 00000F9E 7407                    		je .donotuseleft
  2586 00000FA0 2946D8                  		sub word [bp + ldParasLeft], ax
  2587 00000FA3 58                      		pop ax
  2588 00000FA4 7615                    		jbe @F		; read enough -->
  2589 00000FA6 A8                      		db __TEST_IMM8	; (skip pop)
  2590                                  .donotuseleft:
  2591 00000FA7 58                      		pop ax
  2592                                  
  2593 00000FA8 E2C8                    		loop @BB
  2594 00000FAA 5B                      		pop bx
  2595 00000FAB 59                      		pop cx
  2596                                  
  2597 00000FAC E81D07                  		call clust_next
  2598 00000FAF 73B6                    		jnc next_load_cluster
  2599 00000FB1 40                      		inc ax
  2600 00000FB2 40                      		inc ax
  2601 00000FB3 A808                    		test al, 8	; set in 0FFF_FFF8h--0FFF_FFFFh,
  2602                                  				;  clear in 0, 1, and 0FFF_FFF7h
  2603 00000FB5 7503E99816              		jz error_badchain
  2604 00000FBA A9                      		db __TEST_IMM16
  2605                                  @@:
  2606 00000FBB 5B                      		pop bx
  2607 00000FBC 59                      		pop cx
  2608                                  
  2609 00000FBD A1[6402]                		mov ax, word [load_minpara]
  2610 00000FC0 3B46DA                  		cmp ax, word [bp + ldParasDone]
  2611 00000FC3 760C                    		jbe @F
  2612                                  error_filetoosmall:
  2613 00000FC5 BA[0000]                		mov dx, msg.boot_file_too_small_error
  2614 00000FC8 B81B02                  		mov ax, 021Bh
  2615 00000FCB E8(0000)                		call setrc
  2616 00000FCE E95CF5                  		jmp bootcmd.fail
  2617                                  @@:
  2618                                  
  2619                                  
  2620 00000FD1 8E06[6A02]              	mov es, word [load_loadseg]
  2621 00000FD5 8B3E[7402]              	mov di, word [load_check_offset]
  2622 00000FD9 A1[7602]                	mov ax, word [load_check_value]
  2623 00000FDC 85C0                    	test ax, ax
  2624 00000FDE 7406                    	jz @F
  2625 00000FE0 AF                      	scasw
  2626 00000FE1 7403E90402              	jne .error_check_mismatch
  2627                                  @@:
  2628                                  
  2629                                  ; turn off floppy motor
  2630 00000FE6 BAF203                  		mov dx,3F2h
  2631 00000FE9 B000                    		mov al,0
  2632 00000FEB EE                      		out dx,al
  2633                                  
  2634                                  ; Set-up registers for and jump to loaded file
  2635                                  
  2636 00000FEC 8A5640                  		mov dl, [bp + bsBPB + ebpbNew + bpbnBootUnit]
  2637                                  ;		testopt [load_options], LOAD_SET_DL_UNIT
  2638                                  ;		jz @F
  2639                                  	; (always set dl)
  2640 00000FEF 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 00000FF3 8816[0000]              		mov byte [reg_ebx], dl
  2647                                  @@:
  2648                                  
  2649 00000FF7 8A6E15                  		mov ch, byte [bp + bsBPB + bpbMediaID]
  2650 00000FFA 882E[0100]              		mov byte [reg_ecx + 1], ch
  2651                                  
  2652 00000FFE F606[6802]40            		testopt [load_options], LOAD_DATASTART_HIDDEN
  2653 00001003 740C                    		jz @F
  2654 00001005 8B5E1C                  		mov bx, [bp + bsBPB + bpbHiddenSectors]
  2655 00001008 8B461E                  		mov ax, [bp + bsBPB + bpbHiddenSectors + 2]
  2656 0000100B 015EFC                  		add word [bp + lsvDataStart], bx
  2657 0000100E 1146FE                  		adc word [bp + lsvDataStart + 2], ax
  2658                                  @@:
  2659                                  
  2660 00001011 F606[6802]80            		testopt [load_options], LOAD_SET_AXBX_DATASTART
  2661 00001016 740D                    		jz @F
  2662 00001018 8B5EFC                  		mov bx, word [bp + lsvDataStart]
  2663 0000101B 8B46FE                  		mov ax, word [bp + lsvDataStart + 2]
  2664 0000101E 891E[0000]              		mov word [reg_ebx], bx
  2665 00001022 A3[0000]                		mov word [reg_eax], ax
  2666                                  @@:
  2667                                  
  2668 00001025 F606[6902]08            		testopt [load_options], LOAD_SET_AXBX_ROOT_HIDDEN
  2669 0000102A 7413                    		jz @F
  2670 0000102C 8B5ED0                  		mov bx, word [bp + ldRootSector]
  2671 0000102F 8B46D2                  		mov ax, word [bp + ldRootSector + 2]
  2672 00001032 035E1C                  		add bx, word [bp + bsBPB + bpbHiddenSectors]
  2673 00001035 13461E                  		adc ax, word [bp + bsBPB + bpbHiddenSectors + 2]
  2674 00001038 891E[0000]              		mov word [reg_ebx], bx
  2675 0000103C A3[0000]                		mov word [reg_eax], ax
  2676                                  @@:
  2677                                  
  2678 0000103F F606[6802]04            		testopt [load_options], LOAD_SET_SIDI_CLUSTER
  2679 00001044 740D                    		jz @F
  2680 00001046 8B56F2                  		mov dx, word [bp + lsvFirstCluster + 2]
  2681 00001049 8B46F0                  		mov ax, word [bp + lsvFirstCluster]
  2682 0000104C 8916[0000]              		mov word [reg_esi], dx
  2683 00001050 A3[0000]                		mov word [reg_edi], ax
  2684                                  @@:
  2685                                  
  2686                                  ; (boot.asm code ends here)
  2687                                  
  2688                                  
  2689 00001053 C43E[2405]              	les di, [load_bpb_dest]
  2690 00001057 57                      	push di
  2691 00001058 83EF10                  	sub di, -LOADSTACKVARS
  2692 0000105B BE[F001]                	mov si, load_data - LOADDATA2 + LOADSTACKVARS
  2693 0000105E B91000                  	mov cx, -LOADSTACKVARS
  2694 00001061 F606[6902]20            	testopt [load_options], LOAD_NO_BPB
  2695 00001066 7568                    	jnz .no_bpb_movsb
  2696 00001068 B93400                  	mov cx, -LOADSTACKVARS + bsBPB + bpbNew
  2697 0000106B F3A4                    	rep movsb		; move common BPB part
  2698                                  
  2699 0000106D 394E16                  	cmp word [bp + bsBPB + bpbSectorsPerFAT], cx
  2700 00001070 B93600                  	mov cx, ebpbNew - bpbNew + BPBN_size	; move FAT32 EBPB part + BPBN
  2701 00001073 7406                    	je @F
  2702 00001075 83C61C                  	add si, ebpbNew - bpbNew; -> BPBN
  2703 00001078 B91A00                  	mov cx, BPBN_size	; move only BPBN
  2704                                  @@:
  2705 0000107B F3A4                    	rep movsb
  2706                                  
  2707 0000107D 89F8                    	mov ax, di
  2708 0000107F 5F                      	pop di
  2709 00001080 29F8                    	sub ax, di
  2710 00001082 48                      	dec ax
  2711 00001083 48                      	dec ax
  2712 00001084 86C4                    	xchg al, ah
  2713 00001086 B0EB                    	mov al, 0EBh
  2714 00001088 268905                  	mov word [es:di], ax
  2715 0000108B 26C6450290              	mov byte [es:di + 2], 90h
  2716                                  
  2717 00001090 F606[6902]02            		testopt [load_options], LOAD_LBA_SET_TYPE
  2718 00001095 7416                    		jz @F
  2719 00001097 F646E701                	test byte [bp + ldFlags], ldfHasLBA
  2720 0000109B 7410                    	jz @F
  2721                                  
  2722 0000109D 26C645020E              	mov byte [es:di + 2], 0Eh	; (LBA-enabled) FAT16 FS partition type
  2723 000010A2 807EE620                	cmp byte [bp + ldFATType], 32
  2724 000010A6 7205                    	jb @F
  2725 000010A8 26C645020C              	mov byte [es:di + 2], 0Ch	; (LBA-enabled) FAT32 FS partition type
  2726                                  @@:
  2727                                  
  2728 000010AD 26C785FE0155AA          	mov word [es:di + 510], 0AA55h
  2729 000010B4 1E                      	 push ds
  2730 000010B5 31C9                    	xor cx, cx
  2731 000010B7 8ED9                    	mov ds, cx
  2732 000010B9 BE0005                  	mov si, 500h
  2733 000010BC 57                      	 push di
  2734 000010BD 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 000010C1 B10B                    	mov cl, 11
  2739 000010C3 F3A4                    	rep movsb	; put kernel filename into the pseudo boot sector
  2740 000010C5 47                      	inc di
  2741 000010C6 BE2005                  	mov si, 520h
  2742 000010C9 B10B                    	mov cl, 11
  2743 000010CB F3A4                    	rep movsb	; put additional filename (if any), cx = 0
  2744 000010CD 5F                      	 pop di
  2745 000010CE 1F                      	 pop ds
  2746                                  
  2747                                  			; cx = 0
  2748 000010CF A8                      	db __TEST_IMM8	; (skip pop)
  2749                                  .no_bpb_movsb:
  2750 000010D0 58                      	pop ax		; discard word on stack
  2751 000010D1 F3A4                    	rep movsb
  2752                                  
  2753 000010D3 8126[0000]FFF8          	and word [reg_efl], ~(400h|200h|100h)	; UP, DI, TF=0
  2754                                  
  2755 000010D9 890E[0200]              	mov word [reg_eip + 2], cx
  2756 000010DD FF36[6C02]              	push word [load_entrypoint]
  2757 000010E1 8F06[0000]              	pop word [reg_eip]
  2758 000010E5 A1[6E02]                	mov ax, word [load_entrypoint + 2]
  2759 000010E8 0306[6A02]              	add ax, word [load_loadseg]
  2760 000010EC A3[0000]                	mov word [reg_cs], ax
  2761                                  
  2762 000010EF A1[2605]                	mov ax, word [load_bpb_dest + 2]
  2763 000010F2 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 000010F5 A3[0000]                	mov word [reg_ds], ax
  2768                                  @@:
  2769 000010F8 8B1E[2405]              	mov bx, word [load_bpb_dest]
  2770 000010FC 890E[0200]              	mov word [reg_ebp + 2], cx
  2771 00001100 891E[0000]              	mov word [reg_ebp], bx
  2772 00001104 89D8                    	mov ax, bx
  2773 00001106 83EB10                  	sub bx, -LOADSTACKVARS	; (subtracts --10h)
  2774 00001109 890E[0200]              	mov word [reg_esp + 2], cx
  2775 0000110D 891E[0000]              	mov word [reg_esp], bx
  2776                                  
  2777 00001111 F606[6902]20            	testopt [load_options], LOAD_NO_BPB
  2778 00001116 751B                    	jnz @F
  2779                                  
  2780 00001118 F606[6902]04            		testopt [load_options], LOAD_MESSAGE_TABLE
  2781 0000111D 7414                    		jz @F
  2782 0000111F B96000                  	mov cx, (bsBPB + ebpbNew + BPBN_size + 2 + 15) & ~15
  2783 00001122 01C8                    	add ax, cx
  2784 00001124 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 00001129 BE[0000]                	mov si, msdos7_message_table
  2793 0000112C 01CF                    	add di, cx
  2794 0000112E B9[0000]                	mov cx, msdos7_message_table.size
  2795 00001131 F3A4                    	rep movsb
  2796                                  @@:
  2797                                  
  2798 00001133 F606[6902]10            	testopt [load_options], LOAD_CMDLINE
  2799 00001138 7450                    	jz .no_cmdline
  2800                                  
  2801 0000113A 8B36[3205]              	mov si, word [load_cmdline]
  2802 0000113E 85F6                    	test si, si
  2803 00001140 7508                    	jnz @F
  2804 00001142 C606[3E05]00            	mov byte [load_cmdline_first], 0
  2805 00001147 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 0000114A B98000                  	mov cx, lsvclBufferLength / 2
  2812 0000114D 812E[0000]0401          	sub word [reg_esp], - lsvCommandLine.start + LOADSTACKVARS
  2813                                  		; hazard: if sp is too low, this underflows!
  2814 00001153 7303E9B900              	jc .error_stack_underflow
  2815 00001158 8E06[0000]              	mov es, [reg_ss]
  2816 0000115C 8B3E[0000]              	mov di, [reg_esp]	; es:di -> stack area for the pointers
  2817 00001160 81FF0001                	cmp di, 256
  2818 00001164 7303E9A800              	jb .error_stack_underflow
  2819 00001169 57                      	push di
  2820 0000116A A0[3E05]                	mov al, byte [load_cmdline_first]
  2821 0000116D 84C0                    	test al, al		; have another first byte ?
  2822 0000116F 7404                    	jz @F			; no -->
  2823 00001171 AA                      	stosb			; store it
  2824 00001172 46                      	inc si			; skip source
  2825 00001173 A4                      	movsb			; make it even (1st word done)
  2826 00001174 49                      	dec cx			; one word less
  2827                                  @@:
  2828 00001175 F3A5                    	rep movsw
  2829 00001177 26884DFF                	mov byte [es:di - 1], cl; truncate command line if too long
  2830 0000117B B8434C                  	mov ax, lsvclSignature
  2831 0000117E AB                      	stosw			; write lsvCommandLine.signature
  2832 0000117F 31C0                    	xor ax, ax
  2833 00001181 AB                      	stosw			; write lsvExtra
  2834 00001182 5F                      	pop di
  2835 00001183 B90001                  	mov cx, lsvclBufferLength
  2836 00001186 F2AE                    	repne scasb		; search terminator
  2837 00001188 F3AA                    	rep stosb		; zero buffer behind terminator
  2838                                  .no_cmdline:
  2839                                  
  2840 0000118A 31C0                    		xor ax, ax
  2841 0000118C 8EC0                    		mov es, ax
  2842 0000118E BF7800                  		mov di, 1Eh * 4
  2843 00001191 268B5502                		mov dx, word [es:di + 2]
  2844 00001195 268B1D                  		mov bx, word [es:di]
  2845                                  
  2846 00001198 F606[6802]10            		testopt [load_options], LOAD_SET_DSSI_DPT
  2847 0000119D 7408                    		jz @F
  2848 0000119F 8916[0000]              		mov word [reg_ds], dx
  2849 000011A3 891E[0000]              		mov word [reg_esi], bx
  2850                                  @@:
  2851 000011A7 F606[6802]20            		testopt [load_options], LOAD_PUSH_DPT
  2852 000011AC 7419                    		jz @F
  2853                                  
  2854 000011AE 06                      		 push es
  2855 000011AF 57                      		 push di
  2856 000011B0 832E[0000]08            		sub word [reg_esp], 4 * 2	; push four words
  2857 000011B5 8E06[0000]              		mov es, [reg_ss]
  2858 000011B9 8B3E[0000]              		mov di, [reg_esp]	; es:di -> stack area for the pointers
  2859 000011BD 58                      		 pop ax		; di (1Eh * 4)
  2860 000011BE AB                      		stosw
  2861 000011BF 58                      		 pop ax		; es (0)
  2862 000011C0 AB                      		stosw
  2863 000011C1 89D8                    		mov ax, bx
  2864 000011C3 AB                      		stosw		; si (Int1E offset)
  2865 000011C4 89D0                    		mov ax, dx
  2866 000011C6 AB                      		stosw		; ds (Int1E segment)
  2867                                  @@:
  2868                                  
  2869 000011C7 F606[6902]40            	testopt [load_options], LOAD_SET_DSSI_PARTINFO
  2870 000011CC 7416                    	jz @F
  2871 000011CE A1[3605]                	mov ax, word [load_partition_entry + 2]
  2872 000011D1 A3[0000]                	mov word [reg_ds], ax
  2873 000011D4 A1[3405]                	mov ax, word [load_partition_entry]
  2874 000011D7 A3[0000]                	mov word [reg_esi], ax
  2875 000011DA F606[6902]20            	testopt [load_options], LOAD_NO_BPB
  2876 000011DF 7403                    	jz @F
  2877 000011E1 A3[0000]                	mov word [reg_ebp], ax
  2878                                  @@:
  2879 000011E4 800E[0300]01            	setopt [internalflags2], dif2_boot_loaded_kernel
  2880 000011E9 C3                      	retn
  2881                                  
  2882                                  
  2883                                  .error_check_mismatch:
  2884 000011EA 4F                      	dec di
  2885 000011EB 4F                      	dec di			; = offset into file
  2886 000011EC 26FF35                  	push word [es:di]	; = value we got in file
  2887 000011EF 57                      	push di			; = offset
  2888 000011F0 16                      	 push ss
  2889 000011F1 07                      	 pop es			; set STT
  2890 000011F2 BF[0000]                	mov di, msg.bootfail_check_mismatch.check_value
  2891 000011F5 E8(0000)                	call hexword		; write expected value
  2892 000011F8 58                      	pop ax
  2893 000011F9 BF[0000]                	mov di, msg.bootfail_check_mismatch.check_offset
  2894 000011FC E8(0000)                	call hexword		; write offset
  2895 000011FF 58                      	pop ax
  2896 00001200 BF[0000]                	mov di, msg.bootfail_check_mismatch.check_got
  2897 00001203 E8(0000)                	call hexword		; write what we got in file
  2898                                  
  2899 00001206 BA[0000]                	mov dx, msg.bootfail_check_mismatch
  2900 00001209 B81C02                  	mov ax, 021Ch
  2901 0000120C E8(0000)                	call setrc
  2902 0000120F EB09                    	jmp @F			; fail with error message
  2903                                  
  2904                                  .error_stack_underflow:
  2905 00001211 BA[0000]                	mov dx, msg.bootfail_stack_underflow
  2906 00001214 B81D02                  	mov ax, 021Dh
  2907 00001217 E8(0000)                	call setrc
  2908                                  @@:
  2909 0000121A E910F3                  	jmp bootcmd.fail
  2910                                  
  2911                                  
  2912                                  boot_dir:
  2913 0000121D 8026[0000]F7            	clropt [internalflags3], dif3_load_dir_dir
  2914 00001222 E8(0000)                	call skipwhite
  2915 00001225 4E                      	dec si
  2916 00001226 BA[0000]                	mov dx, msg.dir
  2917 00001229 E8(0000)                	call isstring?
  2918 0000122C 7505                    	jne @F
  2919 0000122E 800E[0000]08            	setopt [internalflags3], dif3_load_dir_dir
  2920                                  @@:
  2921 00001233 C706[4C05][0000]        	mov word [load_kernelname_input], msg.emptydirname
  2922 00001239 AC                      	lodsb
  2923 0000123A E8(0000)                	call yy_common_parse_name
  2924 0000123D E8(0000)                	call chkeol
  2925 00001240 89DE                    	mov si, bx
  2926 00001242 AC                      	lodsb
  2927 00001243 E8F6F4                  	call parseloadunit_default_sdp
  2928 00001246 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 00001248 BB[4C05]                	mov bx, load_kernelname_input
  2932 0000124B E8A8F0                  	call bootcmd.pathname_parse_super
  2933                                  
  2934                                  .fn_done_eol:
  2935 0000124E F606[0000]07            	testopt [internalflags3], dif3_load_is_dp
  2936 00001253 7527                    	jnz .boot_dir_from_ldp
  2937                                  
  2938 00001255 8A1E[3805]              	mov bl, [load_partition]
  2939 00001259 803E[4002]80            	cmp byte [load_unit], 80h
  2940 0000125E 7228                    	jb .boot_dir_is_diskette
  2941 00001260 84DB                    	test bl, bl		; partition specified ?
  2942 00001262 7503E97DEE              	jz bootcmd.error	; no, error -->
  2943                                  
  2944 00001267 E84407                  	call query_geometry
  2945                                  
  2946 0000126A B9[AF12]                	mov cx, boot_dir_from_partition
  2947 0000126D E89005                  	call scan_partitions
  2948 00001270 BA[0000]                	mov dx, msg.boot_partition_not_found
  2949 00001273 B81102                  	mov ax, 0211h
  2950 00001276 E8(0000)                	call setrc
  2951 00001279 E9B1F2                  	jmp bootcmd.fail
  2952                                  
  2953                                  
  2954                                  .boot_dir_from_ldp:
  2955 0000127C E82F07                  	call query_geometry
  2956 0000127F A1[2805]                	mov ax, word [load_partition_sector]
  2957 00001282 8B16[2A05]              	mov dx, word [load_partition_sector + 2]
  2958 00001286 EB0E                    	jmp @F
  2959                                  
  2960                                  
  2961                                  .boot_dir_is_diskette:
  2962 00001288 84DB                    	test bl, bl		; partition specified ?
  2963 0000128A 7403E955EE              	jnz bootcmd.error	; yes, error -->
  2964                                  
  2965 0000128F E81C07                  	call query_geometry
  2966                                  
  2967 00001292 31C0                    	xor ax, ax
  2968 00001294 31D2                    	xor dx, dx
  2969                                  @@:
  2970 00001296 8B1E[0000]              	mov bx, word [auxbuff_segorsel]	; bx => auxbuff
  2971 0000129A 52                      	 push dx
  2972 0000129B 50                      	 push ax
  2973 0000129C E8DB08                  	call read_ae_512_bytes
  2974                                  
  2975 0000129F 26813EFE0155AA          	cmp word [es:510], 0AA55h
  2976 000012A6 7403E9910D              	jne boot_sigmismatch
  2977 000012AB 58                      	 pop ax
  2978 000012AC 5A                      	 pop dx
  2979                                  
  2980 000012AD 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 000012AF A0[3905]                	mov al, byte [load_current_partition]
  2995 000012B2 3A06[3805]              	cmp al, byte [load_partition]
  2996 000012B6 7401                    	je .gotit
  2997 000012B8 C3                      	retn
  2998                                  
  2999                                  .gotit:
  3000                                  d4	call d4message
  3001                                  d4	asciz "In boot_dir_from_partition.gotit",13,10
  3002                                  
  3003 000012B9 8B43F8                  	mov ax, [bp + di - 8]
  3004 000012BC 8B53FA                  	mov dx, [bp + di - 6]		; base (current table position)
  3005                                  
  3006 000012BF 26034408                	add ax, [es:si + 8]
  3007 000012C3 2613540A                	adc dx, [es:si + 8 + 2]		; add offset to logical partition
  3008                                  
  3009 000012C7 26894408                	mov word [es:si + 8], ax
  3010 000012CB 2689540A                	mov word [es:si + 8 + 2], dx	; store in partition table entry
  3011 000012CF 26800C80                	or byte [es:si + 0], 80h	; set bootable flag
  3012                                  
  3013 000012D3 89EC                    	mov sp, bp
  3014 000012D5 5D                      	pop bp				; restore bp (scan_partitions)
  3015 000012D6 5B                      	pop bx				; discard ret address (scan_partitions)
  3016                                  
  3017                                  					; dx:ax = absolute sector number
  3018 000012D7 8B1E[0000]              	mov bx, word [auxbuff_segorsel]	; bx => auxbuff
  3019 000012DB 50                      	push ax
  3020 000012DC 52                      	push dx
  3021 000012DD E89A08                  	call read_ae_512_bytes		; load partition boot sector
  3022                                  
  3023 000012E0 26813EFE0155AA          	cmp word [es:510], 0AA55h
  3024 000012E7 7403E9500D              	jne boot_sigmismatch
  3025                                  
  3026 000012EC 31C9                    	xor cx, cx
  3027                                  ;	cmp word [es:0], cx
  3028                                  ;	je boot_codemismatch
  3029                                  
  3030 000012EE 5A                      	pop dx
  3031 000012EF 58                      	pop ax
  3032                                  
  3033                                  		; dx:ax = boot sector
  3034                                  		; byte [load_unit] = unit
  3035                                  		; es:0-> read sector
  3036                                  boot_dir_common:
  3037 000012F0 26A31C00                	mov word [es:bsBPB + bpbHiddenSectors], ax
  3038 000012F4 2689161E00              	mov word [es:bsBPB + bpbHiddenSectors + 2], dx
  3039                                  
  3040 000012F9 8B5E0B                  	mov bx, [bp + bsBPB + bpbBytesPerSector]
  3041 000012FC 263B1E0B00              	cmp bx, [es:bsBPB + bpbBytesPerSector]
  3042 00001301 7403E94A0D              	jne boot_secsizemismatch
  3043                                  
  3044                                  		; preserve some variables from our pseudo BPB
  3045 00001306 31C0                    	xor ax, ax
  3046 00001308 FF7618                  	push word [bp + bsBPB + bpbCHSSectors]
  3047 0000130B 268F061800              	pop word [es:bsBPB + bpbCHSSectors]
  3048 00001310 FF761A                  	push word [bp + bsBPB + bpbCHSHeads]
  3049 00001313 268F061A00              	pop word [es:bsBPB + bpbCHSHeads]	; preserve geometry
  3050                                  
  3051 00001318 8B5EEA                  	mov bx, word [bp + ldParaPerSector]
  3052 0000131B D1EB                    	shr bx, 1
  3053 0000131D 895ED4                  	mov word [bp + ldEntriesPerSector], bx
  3054                                  
  3055 00001320 2639061600              	cmp word [es:bsBPB + bpbSectorsPerFAT], ax
  3056 00001325 8A5E40                  	mov bl, byte [bp + bsBPB + ebpbNew + bpbnBootUnit]
  3057 00001328 7407                    	je .is_fat32
  3058 0000132A 26881E2400              	mov byte [es:bsBPB + bpbNew + bpbnBootUnit], bl
  3059 0000132F EB05                    	jmp short .was_fat1612
  3060                                  .is_fat32:
  3061 00001331 26881E4000              	mov byte [es:bsBPB + ebpbNew + bpbnBootUnit], bl
  3062                                  .was_fat1612:
  3063                                  
  3064 00001336 06                      	 push es
  3065 00001337 1E                      	 push ds
  3066 00001338 06                      	push es
  3067 00001339 1F                      	pop ds
  3068 0000133A 31F6                    	xor si, si				; -> BPB from boot partition
  3069 0000133C 16                      	push ss
  3070 0000133D 07                      	pop es
  3071 0000133E BF[0002]                	mov di, load_data - LOADDATA2		; -> our copy of a BPB
  3072 00001341 B95A00                  	mov cx, (bsBPB + ebpbNew + BPBN_size)
  3073 00001344 F3A4                    	rep movsb				; get the BPB
  3074                                  
  3075 00001346 1F                      	 pop ds
  3076 00001347 800E[0000]80            	setopt [internalflags3], dif3_partition_changed
  3077                                  
  3078 0000134C 394616                  	cmp word [bp + bsBPB + bpbSectorsPerFAT], ax
  3079 0000134F 740B                    	je @F					; is FAT32 -->
  3080 00001351 BE[2402]                	mov si, load_data - LOADDATA2 + bsBPB + bpbNew
  3081 00001354 BF[4002]                	mov di, load_data - LOADDATA2 + bsBPB + ebpbNew
  3082 00001357 B91A00                  	mov cx, BPBN_size
  3083 0000135A F3A4                    	rep movsb				; clone the FAT16 / FAT12 BPBN
  3084                                  						; to where the FAT32 BPBN lives
  3085                                  @@:
  3086 0000135C 07                      	 pop es
  3087                                  
  3088 0000135D FF36[0000]              	push word [auxbuff_segorsel]
  3089 00001361 8F46F8                  	pop word [bp + lsvFATSeg]
  3090 00001364 804EE702                	or byte [bp + ldFlags], ldfFATInvalid
  3091 00001368 B8FFFF                  	mov ax, -1
  3092 0000136B 8946F4                  	mov word [bp + lsvFATSector], ax
  3093 0000136E 8946F6                  	mov word [bp + lsvFATSector + 2], ax
  3094                                  
  3095 00001371 E8A112                  	call initialise_fs
  3096                                  
  3097 00001374 C706[8605][8A15]        	mov word [handle_scan_dir_entry], scan_dir_entry
  3098                                  
  3099 0000137A C606[3B05]00            	mov byte [load_check_dir_attr], 0
  3100 0000137F 8B36[4C05]              	mov si, word [load_kernelname_input]
  3101 00001383 803C2F                  	cmp byte [si], '/'
  3102 00001386 7501                    	jne @F
  3103 00001388 46                      	inc si
  3104                                  @@:
  3105                                  .dotcomponent:
  3106 00001389 803C00                  	cmp byte [si], 0
  3107 0000138C 7503E99F00              	je .root
  3108 00001391 16                      	 push ss
  3109 00001392 07                      	 pop es
  3110 00001393 E8E7F6                  	call boot_parse_fn	; get next pathname
  3111 00001396 72F1                    	jc .dotcomponent
  3112 00001398 3C2F                    	cmp al, '/'
  3113 0000139A 7509                    	jne @F
  3114 0000139C C606[3B05]10            	mov byte [load_check_dir_attr], ATTR_DIRECTORY
  3115 000013A1 8936[4E05]              	mov word [load_kernelname_next], si
  3116                                  @@:
  3117 000013A5 84C0                    	test al, al
  3118 000013A7 7506                    	jnz @F
  3119 000013A9 C706[8605][8715]        	mov word [handle_scan_dir_entry], scan_dir_entry_dir_or_file
  3120                                  @@:
  3121                                  
  3122 000013AF BFFFFF                  	mov di, -1
  3123 000013B2 89FE                    	mov si, di
  3124 000013B4 897EF4                  	mov [bp + lsvFATSector], di
  3125 000013B7 8976F6                  	mov [bp + lsvFATSector + 2], si
  3126                                  
  3127 000013BA 31C0                    	xor ax, ax
  3128 000013BC 31D2                    	xor dx, dx
  3129                                  
  3130 000013BE 83EC20                  	sub sp, 32
  3131                                  
  3132                                  .scan_dir_dirname_loop:
  3133 000013C1 8946EC                  	mov word [bp + ldDirCluster], ax
  3134 000013C4 8956EE                  	mov word [bp + ldDirCluster + 2], dx
  3135                                  
  3136 000013C7 16                      	push ss
  3137 000013C8 07                      	pop es
  3138 000013C9 89E3                    	mov bx, sp
  3139 000013CB E8F101                  	call scan_dir_aux_with_error
  3140                                  
  3141 000013CE 803E[3B05]10            	cmp byte [load_check_dir_attr], ATTR_DIRECTORY
  3142 000013D3 7544                    	jne .got_direntry
  3143                                  
  3144 000013D5 56                      	push si
  3145 000013D6 57                      	push di
  3146 000013D7 C606[3B05]00            	mov byte [load_check_dir_attr], 0
  3147 000013DC 8B36[4E05]              	mov si, word [load_kernelname_next]
  3148                                  .dotcomponent2_next:
  3149 000013E0 803C00                  	cmp byte [si], 0
  3150 000013E3 7451                    	je .sub
  3151                                  
  3152 000013E5 06                      	push es
  3153 000013E6 16                      	 push ss
  3154 000013E7 07                      	 pop es
  3155 000013E8 E892F6                  	call boot_parse_fn	; get next pathname
  3156 000013EB 07                      	pop es
  3157 000013EC 72F2                    	jc .dotcomponent2_next
  3158 000013EE 3C2F                    	cmp al, '/'
  3159 000013F0 7509                    	jne @F
  3160 000013F2 C606[3B05]10            	mov byte [load_check_dir_attr], ATTR_DIRECTORY
  3161 000013F7 8936[4E05]              	mov word [load_kernelname_next], si
  3162                                  @@:
  3163 000013FB 84C0                    	test al, al
  3164 000013FD 7506                    	jnz @F
  3165 000013FF C706[8605][8715]        	mov word [handle_scan_dir_entry], scan_dir_entry_dir_or_file
  3166                                  @@:
  3167                                  
  3168 00001405 5F                      	pop di
  3169 00001406 5E                      	pop si
  3170                                  
  3171 00001407 31D2                    	xor dx, dx
  3172 00001409 268B471A                	mov ax, [es:bx + deClusterLow]
  3173                                  				; = first cluster (not FAT32)
  3174 0000140D 807EE620                	cmp byte [bp + ldFATType], 32
  3175 00001411 7504                    	jne @F
  3176 00001413 268B5714                	mov dx, [es:bx + deClusterHigh]
  3177                                  				; dx:ax = first cluster (FAT32)
  3178                                  @@:
  3179                                  
  3180 00001417 EBA8                    	jmp .scan_dir_dirname_loop
  3181                                  
  3182                                  
  3183                                  .got_direntry:
  3184 00001419 F606[0000]08            	testopt [internalflags3], dif3_load_dir_dir
  3185 0000141E 7507                    	jnz @F
  3186 00001420 26F6470B10              	test byte [es:bx + deAttrib], ATTR_DIRECTORY
  3187 00001425 7511                    	jnz @FF
  3188                                  @@:
  3189 00001427 89DF                    	mov di, bx
  3190 00001429 E83400                  	call list_dir_entry
  3191 0000142C 83C420                  	add sp, 32
  3192 0000142F C3                      	retn
  3193                                  
  3194                                  .root:
  3195 00001430 31C0                    	xor ax, ax
  3196 00001432 31D2                    	xor dx, dx
  3197 00001434 EB15                    	jmp .scan
  3198                                  
  3199                                  .sub:
  3200 00001436 5F                      	pop di
  3201 00001437 5E                      	pop si
  3202                                  
  3203                                  @@:
  3204 00001438 83C420                  	add sp, 32
  3205                                  
  3206 0000143B 31D2                    	xor dx, dx
  3207 0000143D 268B471A                	mov ax, [es:bx + deClusterLow]
  3208                                  				; = first cluster (not FAT32)
  3209 00001441 807EE620                	cmp byte [bp + ldFATType], 32
  3210 00001445 7504                    	jne @F
  3211 00001447 268B5714                	mov dx, [es:bx + deClusterHigh]
  3212                                  				; dx:ax = first cluster (FAT32)
  3213                                  @@:
  3214                                  .scan:
  3215 0000144B 8946EC                  	mov word [bp + ldDirCluster], ax
  3216 0000144E 8956EE                  	mov word [bp + ldDirCluster + 2], dx
  3217                                  
  3218 00001451 C706[8605][6014]        	mov word [handle_scan_dir_entry], list_dir_entry
  3219 00001457 C706[8805][0000]        	mov word [handle_scan_dir_not_found], dmycmd
  3220                                  
  3221 0000145D E96501                  	jmp scan_dir_aux
  3222                                  
  3223                                  
  3224                                  list_dir_entry:
  3225 00001460 26803D00                	cmp byte [es:di], 0
  3226 00001464 7503E91D01              	je .ret			; (NC, ZR)
  3227 00001469 26803DE5                	cmp byte [es:di], 0E5h
  3228 0000146D 7504                    	jne @F
  3229 0000146F 80CB01                  	or bl, 1		; (NC, NZ)
  3230 00001472 C3                      	retn
  3231                                  
  3232                                  @@:
  3233 00001473 268A5D0B                	mov bl, byte [es:di + deAttrib]
  3234 00001477 F6C308                  	test bl, ATTR_VOLLABEL
  3235 0000147A 7403E90401              	jnz .ret_NC_NZ		; skip volume labels (and LFNs) --> (NZ)
  3236                                  
  3237 0000147F 26803D2E                	cmp byte [es:di], '.'	; dot or dotdot entry ?
  3238 00001483 7503E9FB00              	je .ret_NC_NZ		; yes, skip -->
  3239                                  
  3240 00001488 50                      	push ax
  3241 00001489 53                      	push bx
  3242 0000148A 51                      	push cx
  3243 0000148B 52                      	push dx
  3244 0000148C 56                      	push si
  3245 0000148D 57                      	push di
  3246 0000148E 06                      	push es
  3247 0000148F 1E                      	push ds
  3248 00001490 06                      	 push es
  3249 00001491 1F                      	 pop ds
  3250 00001492 89FE                    	mov si, di
  3251                                  
  3252 00001494 16                      	 push ss
  3253 00001495 07                      	 pop es
  3254 00001496 BF[0000]                	mov di, line_out
  3255 00001499 B90800                  	mov cx, 8
  3256 0000149C F3A4                    	rep movsb
  3257 0000149E B82020                  	mov ax, 2020h
  3258 000014A1 AA                      	stosb
  3259 000014A2 B103                    	mov cl, 3
  3260 000014A4 F3A4                    	rep movsb
  3261 000014A6 AB                      	stosw
  3262                                  
  3263 000014A7 1F                      	pop ds
  3264 000014A8 B02D                    	mov al, '-'
  3265 000014AA F6C320                  	test bl, ATTR_ARCHIVE
  3266 000014AD 7402                    	jz @F
  3267 000014AF B041                    	mov al, 'A'
  3268                                  @@:
  3269 000014B1 AA                      	stosb
  3270 000014B2 B02D                    	mov al, '-'
  3271 000014B4 F6C302                  	test bl, ATTR_HIDDEN
  3272 000014B7 7402                    	jz @F
  3273 000014B9 B048                    	mov al, 'H'
  3274                                  @@:
  3275 000014BB AA                      	stosb
  3276 000014BC B02D                    	mov al, '-'
  3277 000014BE F6C301                  	test bl, ATTR_READONLY
  3278 000014C1 7402                    	jz @F
  3279 000014C3 B052                    	mov al, 'R'
  3280                                  @@:
  3281 000014C5 AA                      	stosb
  3282 000014C6 B02D                    	mov al, '-'
  3283 000014C8 F6C304                  	test bl, ATTR_SYSTEM
  3284 000014CB 7402                    	jz @F
  3285 000014CD B053                    	mov al, 'S'
  3286                                  @@:
  3287 000014CF AA                      	stosb
  3288 000014D0 B82020                  	mov ax, 2020h
  3289 000014D3 AB                      	stosw
  3290                                  
  3291 000014D4 F6C310                  	test bl, ATTR_DIRECTORY
  3292 000014D7 7408                    	jz @F
  3293 000014D9 BE[0000]                	mov si, msg.dirinsteadsize
  3294 000014DC E8(0000)                	call copy_single_counted_string
  3295 000014DF EB2D                    	jmp @FF
  3296                                  
  3297                                  @@:
  3298 000014E1 07                      	 pop es
  3299 000014E2 5E                      	 pop si
  3300 000014E3 56                      	 push si
  3301 000014E4 06                      	 push es
  3302 000014E5 268A440C                	mov al, byte [es:si + dePlusSize]
  3303 000014E9 88C4                    	mov ah, al
  3304 000014EB 2507E0                  	and ax, 0E007h
  3305 000014EE 88E2                    	mov dl, ah
  3306 000014F0 B400                    	mov ah, 0
  3307 000014F2 B600                    	mov dh, 0
  3308 000014F4 D1EA                    	shr dx, 1
  3309 000014F6 D1EA                    	shr dx, 1
  3310 000014F8 09D0                    	or ax, dx
  3311 000014FA 50                      	 push ax
  3312 000014FB 268B541E                	mov dx, word [es:si + deSize + 2]
  3313 000014FF 268B441C                	mov ax, word [es:si + deSize]
  3314 00001503 5E                      	 pop si
  3315 00001504 16                      	 push ss
  3316 00001505 07                      	 pop es
  3317 00001506 31C9                    	xor cx, cx
  3318 00001508 BB0800                  	mov bx, 4+4
  3319 0000150B E8(0000)                	call disp_dxax_times_cx_width_bx_size.store
  3320                                  
  3321                                  @@:
  3322 0000150E B82020                  	mov ax, 2020h
  3323 00001511 AB                      	stosw
  3324 00001512 07                      	 pop es
  3325 00001513 5E                      	 pop si
  3326 00001514 56                      	 push si
  3327 00001515 06                      	 push es
  3328 00001516 268B5C18                	mov bx, word [es:si + deDate]
  3329 0000151A 268B7416                	mov si, word [es:si + deTime]
  3330 0000151E 16                      	 push ss
  3331 0000151F 07                      	 pop es
  3332 00001520 89D8                    	mov ax, bx
  3333 00001522 B90900                  	mov cx, 9
  3334 00001525 D3E8                    	shr ax, cl
  3335 00001527 05BC07                  	add ax, 1980
  3336 0000152A 31D2                    	xor dx, dx
  3337 0000152C B104                    	mov cl, 4
  3338 0000152E E8(0000)                	call dec_dword_minwidth
  3339 00001531 B02D                    	mov al, '-'
  3340 00001533 AA                      	stosb
  3341 00001534 89D8                    	mov ax, bx
  3342 00001536 B105                    	mov cl, 5
  3343 00001538 D3E8                    	shr ax, cl
  3344 0000153A 83E00F                  	and ax, 15
  3345 0000153D B102                    	mov cl, 2
  3346 0000153F E8(0000)                	call dec_dword_minwidth
  3347 00001542 B02D                    	mov al, '-'
  3348 00001544 AA                      	stosb
  3349 00001545 89D8                    	mov ax, bx
  3350 00001547 83E01F                  	and ax, 31
  3351 0000154A E8(0000)                	call dec_dword_minwidth
  3352 0000154D B020                    	mov al, 32
  3353 0000154F AA                      	stosb
  3354 00001550 89F0                    	mov ax, si
  3355 00001552 B10B                    	mov cl, 11
  3356 00001554 D3E8                    	shr ax, cl
  3357 00001556 B102                    	mov cl, 2
  3358 00001558 E8(0000)                	call dec_dword_minwidth
  3359 0000155B B03A                    	mov al, ':'
  3360 0000155D AA                      	stosb
  3361 0000155E 89F0                    	mov ax, si
  3362 00001560 B105                    	mov cl, 5
  3363 00001562 D3E8                    	shr ax, cl
  3364 00001564 83E03F                  	and ax, 63
  3365 00001567 B102                    	mov cl, 2
  3366 00001569 E8(0000)                	call dec_dword_minwidth
  3367 0000156C B03A                    	mov al, ':'
  3368 0000156E AA                      	stosb
  3369 0000156F 89F0                    	mov ax, si
  3370 00001571 83E01F                  	and ax, 31
  3371 00001574 D1E0                    	shl ax, 1
  3372 00001576 E8(0000)                	call dec_dword_minwidth
  3373                                  
  3374 00001579 E8(0000)                	call putsline_crlf
  3375                                  
  3376 0000157C 07                      	pop es
  3377 0000157D 5F                      	pop di
  3378 0000157E 5E                      	pop si
  3379 0000157F 5A                      	pop dx
  3380 00001580 59                      	pop cx
  3381 00001581 5B                      	pop bx
  3382 00001582 58                      	pop ax
  3383                                  
  3384                                  .ret_NC_NZ:
  3385 00001583 80CB01                  	or bl, 1		; (NC, NZ)
  3386                                  .ret:
  3387 00001586 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 00001587 B701                    	mov bh, 1
  3406 00001589 A9                      	db __TEST_IMM16		; (skip mov)
  3407                                  
  3408                                  scan_dir_entry:
  3409 0000158A B700                    	mov bh, 0
  3410 0000158C 26803D00                	cmp byte [es:di], 0
  3411 00001590 F9                      	stc
  3412 00001591 7425                    	je .ret
  3413 00001593 268A5D0B                	mov bl, byte [es:di + deAttrib]
  3414 00001597 F6C308                  	test bl, ATTR_VOLLABEL
  3415 0000159A 751B                    	jnz @F			; skip volume labels (and LFNs) --> (NZ)
  3416 0000159C 84FF                    	test bh, bh
  3417 0000159E 7509                    	jnz .no_check_dir
  3418 000015A0 80E310                  	and bl, ATTR_DIRECTORY	; isolate directory bit
  3419 000015A3 3A1E[3B05]              	cmp bl, byte [load_check_dir_attr]	; is it what we're searching?
  3420 000015A7 750E                    	jne @F			; no -->
  3421                                  .no_check_dir:
  3422 000015A9 56                      	push si
  3423 000015AA 57                      	push di
  3424 000015AB 51                      	push cx
  3425 000015AC BE[4005]                	mov si, load_kernel_name	; ds:si-> name to match
  3426 000015AF B90B00                  	mov cx, 11		; length of padded 8.3 FAT filename
  3427 000015B2 F3A6                    	repe cmpsb		; check entry
  3428 000015B4 59                      	pop cx
  3429 000015B5 5F                      	pop di
  3430 000015B6 5E                      	pop si
  3431                                  @@:
  3432 000015B7 F8                      	clc
  3433                                  .ret:
  3434 000015B8 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 000015B9 C706[8605][8A15]        	mov word [handle_scan_dir_entry], scan_dir_entry
  3447                                  
  3448                                  scan_dir_aux_with_error:
  3449 000015BF C706[8805][1D16]        	mov word [handle_scan_dir_not_found], error_filenotfound
  3450                                  
  3451                                  scan_dir_aux: section_of_function
  3452 000015C5 FF36[0000]              	push word [auxbuff_segorsel]
  3453 000015C9 8F06[5805]              	pop word [load_adr_dirbuf_segment]
  3454                                  
  3455                                  scan_dir:
  3456 000015CD 8B46EC                  	mov ax, word [bp + ldDirCluster]
  3457 000015D0 8B56EE                  	mov dx, word [bp + ldDirCluster + 2]
  3458                                  
  3459 000015D3 85C0                    	test ax, ax
  3460 000015D5 7572                    	jnz fat32_scan_root.dir_clust_dxax
  3461 000015D7 85D2                    	test dx, dx
  3462 000015D9 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 000015DB 807EE610                	cmp byte [bp + ldFATType], 16
  3468 000015DF 7762                    	ja fat32_scan_root
  3469                                  
  3470 000015E1 56                      	push si
  3471 000015E2 57                      	push di
  3472 000015E3 06                      	push es
  3473 000015E4 53                      	push bx
  3474                                  
  3475 000015E5 8B7611                  	mov si, word [bp + bsBPB + bpbNumRootDirEnts]
  3476                                  
  3477                                  
  3478                                  ; (boot.asm code starts here)
  3479                                  
  3480                                  fat16_scan_root:
  3481 000015E8 85F6                    	test si, si
  3482 000015EA 7424                    	jz handle_filenotfound_fat16
  3483                                  
  3484 000015EC 8B46D0                  	mov ax, [bp + ldRootSector]
  3485 000015EF 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 000015F2 8B1E[5805]              	mov bx, [load_adr_dirbuf_segment]
  3492 000015F6 E89305                  	call read_sector
  3493                                  
  3494 000015F9 8B4ED4                  	mov cx, [bp + ldEntriesPerSector] ; entries per sector as loop counter
  3495 000015FC 31FF                    	xor di, di		; es:di-> first entry in this sector
  3496                                  fat16_next_ent:
  3497 000015FE FF16[8605]              	call near word [handle_scan_dir_entry]
  3498                                  ..@boot_scan_dir_return_fat16_root_entry:
  3499 00001602 720C                    	jc handle_filenotfound_fat16
  3500 00001604 8D7D20                  	lea di, [di + DIRENTRY_size]	; bytes/dirent
  3501 00001607 7423                    	je fat16_found_it	; found entry -->
  3502                                  
  3503 00001609 4E                      	dec si			; count down entire root's entries
  3504 0000160A E0F2                    	loopnz fat16_next_ent	; count down sector's entries (jumps iff si >0 && cx >0)
  3505 0000160C 85F6                    	test si, si		; work around qemu bug
  3506 0000160E 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 00001610 5B                      	pop bx
  3533 00001611 07                      	pop es
  3534 00001612 5F                      	pop di
  3535 00001613 5E                      	pop si
  3536                                  
  3537 00001614 A9                      	db __TEST_IMM16		; (skip pop and pop)
  3538                                  handle_filenotfound_fat32:
  3539 00001615 5B                      	pop bx
  3540 00001616 07                      	pop es
  3541                                  
  3542                                  handle_filenotfound:
  3543 00001617 FF16[8805]              	call near word [handle_scan_dir_not_found]
  3544                                  ..@boot_scan_dir_return_filenotfound:
  3545 0000161B F9                      	stc
  3546 0000161C C3                      	retn
  3547                                  
  3548                                  error_filenotfound:
  3549                                  %if _INPUT_FILE_BOOT
  3550 0000161D E87809                  	call yy_boot_file_not_found
  3551                                  %endif
  3552 00001620 BA[0000]                	mov dx, msg.boot_file_not_found
  3553 00001623 B81E02                  	mov ax, 021Eh
  3554 00001626 E8(0000)                	call setrc
  3555 00001629 E901EF                  	jmp bootcmd.fail
  3556                                  
  3557                                  fat16_found_it:
  3558 0000162C 5B                      	  pop bx
  3559 0000162D 58                      	  pop ax
  3560 0000162E B92000                  	mov cx, 32
  3561 00001631 29CF                    	sub di, cx
  3562 00001633 1E                      	push ds
  3563 00001634 06                      	 push es
  3564 00001635 1F                      	 pop ds
  3565 00001636 89FE                    	mov si, di		; ds:si -> entry in directory buffer
  3566 00001638 89DF                    	mov di, bx
  3567 0000163A 8EC0                    	mov es, ax		; es:di -> destination for entry
  3568 0000163C F3A4                    	rep movsb
  3569 0000163E 1F                      	pop ds
  3570 0000163F 5F                      	  pop di
  3571 00001640 5E                      	  pop si
  3572 00001641 F8                      	clc
  3573 00001642 C3                      	retn
  3574                                  
  3575                                  
  3576                                  ; (boot32.asm code starts here)
  3577                                  
  3578                                  fat32_scan_root:
  3579 00001643 8B462C                  	mov ax, [bp + bsBPB + ebpbRootCluster]
  3580 00001646 8B562E                  	mov dx, [bp + bsBPB + ebpbRootCluster + 2]
  3581                                  
  3582                                  .dir_clust_dxax:
  3583 00001649 06                      	push es
  3584 0000164A 53                      	push bx
  3585                                  
  3586 0000164B E88001                  	call check_clust
  3587 0000164E 72C5                    	jc handle_filenotfound_fat32
  3588                                  
  3589                                  fat32_next_root_clust:
  3590 00001650 E85000                  	call clust_to_first_sector
  3591 00001653 51                      	push cx
  3592 00001654 53                      	push bx
  3593 00001655 8B4EE8                  	mov cx, [bp + ldClusterSize]
  3594                                  fat32_next_root_sect:
  3595 00001658 51                      	push cx
  3596 00001659 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 0000165C 8B1E[5805]              	mov bx, [load_adr_dirbuf_segment]
  3601 00001660 E82905                  	call read_sector
  3602                                  
  3603 00001663 57                      	push di
  3604 00001664 31FF                    	xor di, di		; es:di-> first entry in this sector
  3605                                  fat32_next_ent:
  3606 00001666 FF16[8605]              	call near word [handle_scan_dir_entry]
  3607                                  ..@boot_scan_dir_return_subdir_or_fat32_entry:
  3608 0000166A 7214                    	jc handle_filenotfound_fat32_pop
  3609 0000166C 8D7D20                  	lea di, [di + DIRENTRY_size]	; bytes/dirent
  3610 0000166F 7415                    	je fat32_found_it	; found entry -->
  3611                                  
  3612 00001671 E2F3                    	loop fat32_next_ent	; count down sector's entries (jumps iff cx >0)
  3613 00001673 5F                      	pop di
  3614 00001674 59                      	pop cx
  3615 00001675 E2E1                    	loop fat32_next_root_sect
  3616 00001677 5B                      	pop bx
  3617 00001678 59                      	pop cx
  3618 00001679 E85000                  	call clust_next
  3619 0000167C 73D2                    	jnc fat32_next_root_clust
  3620 0000167E EB04                    	jmp @F
  3621                                  
  3622                                  handle_filenotfound_fat32_pop:
  3623 00001680 5F                      	pop di
  3624 00001681 59                      	pop cx
  3625 00001682 5B                      	pop bx
  3626 00001683 59                      	pop cx
  3627                                  @@:
  3628 00001684 EB8F                    	jmp handle_filenotfound_fat32
  3629                                  
  3630                                  
  3631                                  fat32_found_it:
  3632 00001686 5A                      	pop dx			; value for di
  3633 00001687 83C406                  	add sp, 6		; discard sector-in-cluster counter and cluster
  3634 0000168A 5B                      	  pop bx
  3635 0000168B 58                      	  pop ax
  3636 0000168C B92000                  	mov cx, 32
  3637 0000168F 29CF                    	sub di, cx
  3638 00001691 1E                      	push ds
  3639 00001692 06                      	 push es
  3640 00001693 1F                      	 pop ds
  3641 00001694 56                      	push si
  3642 00001695 89FE                    	mov si, di		; ds:si -> entry in directory buffer
  3643 00001697 89DF                    	mov di, bx
  3644 00001699 8EC0                    	mov es, ax		; es:di -> destination for entry
  3645 0000169B F3A4                    	rep movsb
  3646 0000169D 5E                      	pop si
  3647 0000169E 1F                      	pop ds
  3648 0000169F 89D7                    	  mov di, dx		; restore si:di = loaded FAT sector
  3649 000016A1 F8                      	clc
  3650 000016A2 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 000016A3 52                      	push dx
  3661 000016A4 50                      	push ax
  3662 000016A5 52                      	 push dx
  3663 000016A6 F726[E801]              	mul word [load_data - LOADDATA2 + ldClusterSize]
  3664 000016AA 93                      	xchg bx, ax
  3665 000016AB 87CA                    	xchg cx, dx
  3666 000016AD 58                      	 pop ax
  3667 000016AE F726[E801]              	mul word [load_data - LOADDATA2 + ldClusterSize]
  3668 000016B2 85D2                    	test dx, dx
  3669 000016B4 7513                    	jnz .error_badchain
  3670 000016B6 92                      	xchg dx, ax
  3671 000016B7 01CA                    	add dx, cx
  3672 000016B9 720E                    	jc .error_badchain
  3673 000016BB 93                      	xchg ax, bx
  3674                                  
  3675 000016BC 0306[FC01]              	add ax, [load_data - LOADDATA2 + lsvDataStart]
  3676 000016C0 1316[FE01]              	adc dx, [load_data - LOADDATA2 + lsvDataStart + 2]
  3677 000016C4 7203                    	jc .error_badchain
  3678                                  				; dx:ax = first sector in cluster
  3679 000016C6 5B                      	pop bx
  3680 000016C7 59                      	pop cx			; cx:bx = cluster
  3681 000016C8 C3                      	retn
  3682                                  
  3683                                  .error_badchain:
  3684 000016C9 E9860F                  	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 000016CC 89D8                    	mov ax, bx
  3696 000016CE 89CA                    	mov dx, cx
  3697                                  .dxax:
  3698 000016D0 83C002                  	add ax, 2
  3699 000016D3 83D200                  	adc dx, 0
  3700                                  
  3701 000016D6 06                      	push es
  3702 000016D7 803E[E601]10            	cmp byte [load_data - LOADDATA2 + ldFATType], 16
  3703 000016DC 7503                    	jne @F
  3704 000016DE E98800                  	jmp strict near .fat16
  3705                                  @@:
  3706 000016E1 7603                    	jna @F
  3707 000016E3 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 000016E6 89C2                    		mov dx, ax
  3715 000016E8 D1E0                    		shl ax, 1		; = 2n (up to 13 bits set)
  3716 000016EA 01D0                    		add ax, dx		; = 2n+n = 3n (up to 14 bits set)
  3717 000016EC D1E8                    		shr ax, 1		; ax = byte offset into FAT (0..6129)
  3718                                  					; CF = whether to use high 12 bits
  3719 000016EE 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 000016F0 8E06[F801]              		mov es, [load_data - LOADDATA2 + lsvFATSeg]
  3724 000016F4 89C3                    		mov bx, ax		; -> 16-bit word in FAT to load
  3725                                  
  3726 000016F6 F606[E701]02            	test byte [load_ldflags], ldfFATInvalid
  3727 000016FB 7459                    	jz .fat12_have_fat	; already have it -->
  3728 000016FD 51                      	push cx
  3729 000016FE 31D2                    	xor dx, dx
  3730 00001700 F736[0B02]              	div word [load_data - LOADDATA2 + bsBPB + bpbBytesPerSector]
  3731                                  				; dx = remainder, byte offset
  3732                                  				; ax = sector to read
  3733 00001704 52                      	push dx
  3734 00001705 31D2                    	xor dx, dx
  3735 00001707 8B1E[F801]              	mov bx, [load_data - LOADDATA2 + lsvFATSeg]
  3736                                  
  3737 0000170B F606[E701]04            	testopt [load_ldflags], ldfFATBuffered
  3738 00001710 742A                    	jz .12_notbuffered
  3739 00001712 8B36[F601]              	mov si, word [load_data - LOADDATA2 + lsvFATSector + 2]
  3740 00001716 8B3E[F401]              	mov di, word [load_data - LOADDATA2 + lsvFATSector + 0]
  3741                                  	; jmp .12_compare
  3742                                  .12_compare:
  3743 0000171A 39F2                    	cmp dx, si
  3744 0000171C 7513                    	jne @F		; read sector
  3745 0000171E 39F8                    	cmp ax, di
  3746 00001720 750F                    	jne @F		; read sector
  3747                                  		; sector is already buffered
  3748 00001722 8EC3                    	mov es, bx		; => FAT buffer
  3749 00001724 F9                      	stc
  3750 00001725 1306[0E02]              	adc ax, [load_data - LOADDATA2 + bsBPB + bpbReservedSectors]
  3751 00001729 11D2                    	adc dx, dx		; prepare for reading straddling entry sector
  3752 0000172B 031E[EA01]              	add bx, word [load_sectorsizepara]
  3753                                  				; prepare for straddling sector
  3754 0000172F EB14                    	jmp @FF
  3755                                  @@:
  3756 00001731 89D6                    	mov si, dx
  3757 00001733 89C7                    	mov di, ax
  3758 00001735 8916[F601]              	mov word [load_data - LOADDATA2 + lsvFATSector + 2], dx
  3759 00001739 A3[F401]                	mov word [load_data - LOADDATA2 + lsvFATSector + 0], ax
  3760                                  
  3761                                  .12_notbuffered:
  3762 0000173C 0306[0E02]              	add ax, [load_data - LOADDATA2 + bsBPB + bpbReservedSectors]
  3763 00001740 11D2                    	adc dx, dx
  3764 00001742 E84704                  	call read_sector
  3765                                  @@:
  3766 00001745 59                      	pop cx
  3767 00001746 41                      	inc cx
  3768 00001747 3B0E[0B02]              	cmp cx, word [load_data - LOADDATA2 + bsBPB + bpbBytesPerSector]
  3769 0000174B 7505                    	jne .fat12_have_fat_cx_dec
  3770 0000174D 06                      	push es
  3771 0000174E E83B04                  	call read_sector	; read second sector for straddling entry
  3772 00001751 07                      	pop es
  3773                                  
  3774                                  .fat12_have_fat_cx_dec:
  3775 00001752 49                      	dec cx
  3776 00001753 89CB                    	mov bx, cx
  3777 00001755 59                      	pop cx
  3778                                  
  3779                                  .fat12_have_fat:
  3780                                  
  3781                                  ; get 16 bits from FAT
  3782 00001756 268B07                  		mov ax, [es:bx]
  3783                                  
  3784 00001759 80E104                  		and cl, 4	; = 4 iff CY after shift, else 0
  3785 0000175C D3E8                    		shr ax, cl	; shift down iff odd entry, else unchanged
  3786 0000175E 25FF0F                  		and ax, 0FFFh	; insure it's only 12 bits
  3787 00001761 31D2                    		xor dx, dx
  3788 00001763 EB68                    	jmp short .gotvalue
  3789                                  
  3790                                  .fat32:
  3791                                  		; * 4 = byte offset into FAT (0--4000_0000h)
  3792 00001765 01C0                    	add ax, ax
  3793 00001767 11D2                    	adc dx, dx
  3794                                  .fat16:
  3795                                  		; * 2 = byte offset into FAT (0--2_0000h)
  3796 00001769 01C0                    	add ax, ax
  3797 0000176B 11D2                    	adc dx, dx
  3798                                  
  3799 0000176D 50                      	 push ax
  3800 0000176E 92                      	xchg ax, dx
  3801 0000176F 31D2                    	xor dx, dx		; dx:ax = high word
  3802 00001771 F736[0B02]              	div word [load_data - LOADDATA2 + bsBPB + bpbBytesPerSector]
  3803 00001775 89C3                    	mov bx, ax
  3804 00001777 58                      	 pop ax			; dx = remainder, ax = low word
  3805 00001778 F736[0B02]              	div word [load_data - LOADDATA2 + bsBPB + bpbBytesPerSector]
  3806 0000177C 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 0000177E F606[E701]04            	testopt [load_ldflags], ldfFATBuffered
  3810 00001783 740A                    	jz .1632_notbuffered
  3811 00001785 8B36[F601]              	mov si, word [load_data - LOADDATA2 + lsvFATSector + 2]
  3812 00001789 8B3E[F401]              	mov di, word [load_data - LOADDATA2 + lsvFATSector + 0]
  3813 0000178D EB07                    	jmp .1632_compare
  3814                                  
  3815                                  .1632_notbuffered:
  3816 0000178F F606[E701]02            	test byte [load_ldflags], ldfFATInvalid
  3817 00001794 7513                    	jnz .read_no_store	; always read -->
  3818                                  
  3819                                  .1632_compare:
  3820 00001796 39F2                    	cmp dx, si
  3821 00001798 7504                    	jne @F		; read sector
  3822 0000179A 39F8                    	cmp ax, di
  3823 0000179C 741B                    	je @FF		; sector is already buffered
  3824                                  @@:
  3825 0000179E 89D6                    	mov si, dx
  3826 000017A0 89C7                    	mov di, ax
  3827 000017A2 8916[F601]              	mov word [load_data - LOADDATA2 + lsvFATSector + 2], dx
  3828 000017A6 A3[F401]                	mov word [load_data - LOADDATA2 + lsvFATSector + 0], ax
  3829                                  
  3830                                  .read_no_store:
  3831 000017A9 53                      	push bx
  3832 000017AA 0306[0E02]              	add ax, [load_data - LOADDATA2 + bsBPB + bpbReservedSectors]
  3833 000017AE 83D200                  	adc dx, 0
  3834 000017B1 8B1E[F801]              	mov bx, [load_data - LOADDATA2 + lsvFATSeg]
  3835 000017B5 E8D403                  	call read_sector
  3836 000017B8 5B                      	pop bx
  3837                                  @@:
  3838 000017B9 8E06[F801]              	mov es, [load_data - LOADDATA2 + lsvFATSeg]
  3839 000017BD 31D2                    	xor dx, dx
  3840 000017BF 268B07                  	mov ax, [es:bx]
  3841                                  
  3842 000017C2 803E[E601]10            	cmp byte [load_data - LOADDATA2 + ldFATType], 16
  3843 000017C7 7404                    	je @F
  3844 000017C9 268B5702                	mov dx, [es:bx + 2]
  3845                                  @@:
  3846                                  .gotvalue:
  3847 000017CD 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 000017CE 80E60F                  	and dh, 0Fh
  3854 000017D1 83E802                  	sub ax, 2
  3855 000017D4 83DA00                  	sbb dx, 0
  3856                                  
  3857 000017D7 803E[E601]10            	cmp byte [load_data - LOADDATA2 + ldFATType], 16
  3858 000017DC 7707                    	ja .fat32
  3859 000017DE 740B                    	je .fat16
  3860                                  
  3861                                  .fat12:
  3862 000017E0 3DF50F                  	cmp ax, 0FF7h - 2
  3863 000017E3 EB09                    	jmp short .common
  3864                                  
  3865                                  .fat32:
  3866 000017E5 81FAFF0F                	cmp dx, 0FFFh
  3867 000017E9 7203                    	jb @F		; CY here means valid ...-
  3868                                  
  3869                                  .fat16:
  3870 000017EB 83F8F5                  	cmp ax, 0FFF7h - 2
  3871                                  @@:			;  -... or if NC first, CY here also
  3872                                  .common:
  3873 000017EE F5                      	cmc		; NC if valid
  3874 000017EF 720E                    	jc .ret
  3875 000017F1 3B16[C201]              	cmp dx, word [load_data - LOADDATA2 + ldMaxCluster + 2]
  3876 000017F5 7504                    	jne @F
  3877 000017F7 3B06[C001]              	cmp ax, word [load_data - LOADDATA2 + ldMaxCluster]
  3878                                  @@:
  3879 000017FB 7701                    	ja .ret_CY
  3880 000017FD A8                      	db __TEST_IMM8	; (skip stc, NC)
  3881                                  .ret_CY:
  3882 000017FE F9                      	stc
  3883                                  .ret:
  3884 000017FF 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 00001800 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 00001805 55                  <1> 	push bp
    91                              <1> %ifidn _BASE, ss:bx
    92                              <1> 	mov bx, sp
    93                              <1> %elifidn _BASE, bp
    94 00001806 89E5                <1> 	mov bp, sp
    95                              <1> %endif
    96 00001808 31FF                <1> 	xor di, di
    97 0000180A 57                  <1> 	push di		; [_BASE+di-2]
    98 0000180B 57                  <1> 	push di		; [_BASE+di-4]
    99 0000180C 57                  <1> 	push di		; [_BASE+di-6]
   100 0000180D 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 0000180E 803E[4002]80        <1> sptrel	cmp byte [ %[_SCANPTAB_PREFIX]load_unit], 80h
   107                              <1> sptinternal -3
   108 00001813 7325                <1> 	jae @F
   109                              <1> 
   110 00001815 57                  <1> 	push di
   111 00001816 51                  <1> 	push cx
   112                              <1> %if _PARTITION_TABLE_IN_CS
   113                              <1> 	 push cs
   114                              <1> %else
   115 00001817 16                  <1> 	 push ss
   116                              <1> %endif
   117 00001818 07                  <1> 	 pop es
   118 00001819 BF[0001]            <1> sptrel	mov di, %[_SCANPTAB_PREFIX]partition_table
   119                              <1> sptinternal
   120 0000181C 31C0                <1> 	xor ax, ax
   121 0000181E B92000              <1> 	mov cx, (4 * 16) >> 1
   122 00001821 F3AB                <1> 	rep stosw			; initialise fake partition table
   123 00001823 59                  <1> 	pop cx
   124 00001824 5F                  <1> 	pop di
   125 00001825 BE[0001]            <1> sptrel	mov si, %[_SCANPTAB_PREFIX]partition_table
   126                              <1> sptinternal
   127                              <1> 					; -> fake PARTINFO
   128 00001828 26C60480            <1> 	mov byte [es:si + piBoot], 80h	; fake primary active
   129 0000182C 26C64404FF          <1> 	mov byte [es:si + piType], 0FFh	; fake a type
   130 00001831 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 00001836 FFD1                <1> 	call cx
   133                              <1> 
   134 00001838 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 0000183A 31C0                <1> 	xor ax, ax
   145 0000183C 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 0000183E 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 00001841 BE[0001]            <1> sptrel	mov si, %[_SCANPTAB_PREFIX]partition_table
   152                              <1> sptinternal
   153 00001844 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 00001848 FE06[3905]          <1> sptrel	inc byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   292                              <1> sptinternal
   293 0000184C 26807C0400          <1> 	cmp byte [es:si + piType], 0
   294 00001851 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 00001853 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 00001855 83C610              <1> 	add si, 16
   323 00001858 81FE[4001]          <1> sptrel	cmp si, strict word %[_SCANPTAB_PREFIX]partition_table.end
   324                              <1> sptinternal
   325 0000185C 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 0000185E BE[0001]            <1> sptrel	mov si, %[_SCANPTAB_PREFIX]partition_table
   442                              <1> sptinternal
   443                              <1> .loop:
   444 00001861 FF06[3005]          <1> sptrel	inc word [ %[_SCANPTAB_PREFIX]load_partition_cycle]
   445                              <1> sptinternal
   446 00001865 7503E9A500          <1> 	jz .got_partition_cycle
   447                              <1> 
   448 0000186A 268A4404            <1> 	mov al, [es:si + piType]
   449                              <1> 
   450                              <1> %ifidn _BASE, bp
   451 0000186E 31DB                <1> 	xor bx, bx
   452                              <1> %endif
   453 00001870 84C0                <1> 	test al, al
   454 00001872 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 00001874 3C0F                <1> 	cmp al, 0Fh		; extended partition (LBA aware) ?
   518 00001876 742C                <1> 	je .push		; yes -->
   519 00001878 247F                <1> 	and al, ~80h		; extended partition Linux (85h) ?
   520 0000187A 3C05                <1> 	cmp al, 05h		;  or extended partition DOS (05h) ?
   521 0000187C 7426                <1> 	je .push		; yes -->
   522                              <1> .notextended:
   523                              <1> 
   524                              <1> %ifidn _BASE, bp
   525 0000187E 395BFE              <1> 	cmp word [_BASE+di-2], bx
   526 00001881 7505                <1> 	jne .logical
   527 00001883 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 00001886 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 00001888 FE06[3905]          <1> sptrel	inc byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   548                              <1> sptinternal
   549 0000188C 7503E98400          <1> 	jz .error_too_many_partitions
   550 00001891 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 00001893 83C610              <1> 	add si, 16		; -> next partition table entry
   557 00001896 81FE[4001]          <1> sptrel	cmp si, strict word %[_SCANPTAB_PREFIX]partition_table.end
   558                              <1> sptinternal			; was last?
   559 0000189A 72C5                <1> 	jb .loop		; no, loop -->
   560 0000189C 85FF                <1> 	test di, di		; still some on stack?
   561 0000189E 7546                <1> 	jnz .pop		; yes, pop
   562                              <1> .end:
   563                              <1> %ifidn _BASE, bp
   564 000018A0 89EC                <1> 	mov sp, bp		; restore sp
   565 000018A2 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 000018A3 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 000018A4 56                  <1> 	push si
   617                              <1> .push_check_empty_next:
   618 000018A5 83C610              <1> 	add si, 16		; -> next
   619 000018A8 81FE[4001]          <1> sptrel	cmp si, strict word %[_SCANPTAB_PREFIX]partition_table.end
   620                              <1> sptinternal			; at end?
   621 000018AC 734A                <1> 	jae .replace		; yes, no other partitions found, replace -->
   622 000018AE 26807C0400          <1> 	cmp byte [es:si + piType], 0	; is this a partition?
   623 000018B3 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 000018B5 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 000018B6 56                  <1> 	push si			; stored at word [_BASE+di-10]
   657 000018B7 83EF0A              <1> 	sub di, 10
   658 000018BA FF7308              <1> 	push word [_BASE+di+10-2]
   659 000018BD FF7306              <1> 	push word [_BASE+di+10-4]	; copy root
   660                              <1> %ifn _MODE
   661 000018C0 268B4408            <1> 	mov ax, word [es:si + piStart]
   662 000018C4 268B540A            <1> 	mov dx, word [es:si + piStart + 2]	; get extended partition offset
   663                              <1> %endif
   664 000018C8 0343FC              <1> 	add ax, word [_BASE+di-4]
   665 000018CB 1353FE              <1> 	adc dx, word [_BASE+di-2]	; add in root to get absolute sector number
   666                              <1> 
   667 000018CE 52                  <1> 	push dx
   668 000018CF 50                  <1> 	push ax			; new base
   669                              <1> 
   670                              <1> .replace_common:
   671                              <1> %ifidn _BASE, bp
   672 000018D0 395BFE              <1> 	cmp word [_BASE+di-2], bx	; have a (nonzero) root?
   673 000018D3 750B                <1> 	jne .have_root
   674 000018D5 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 000018D8 7506                <1> 	jne .have_root		; yes -->
   681                              <1> 
   682 000018DA 8953FE              <1> 	mov word [_BASE+di-2], dx
   683 000018DD 8943FC              <1> 	mov word [_BASE+di-4], ax	; set root
   684                              <1> .have_root:
   685                              <1> 
   686 000018E0 E83800              <1> 	call %[_SCANPTAB_PREFIX]read_partition_table.first
   687 000018E3 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 000018E6 83C70A              <1> 	add di, 10
   700 000018E9 83C408              <1> 	add sp, 8
   701 000018EC 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 000018ED 8B43F8              <1> 	mov ax, word [_BASE+di-8]
   715 000018F0 8B53FA              <1> 	mov dx, word [_BASE+di-6]
   716 000018F3 E82500              <1> 	call %[_SCANPTAB_PREFIX]read_partition_table.reload
   717 000018F6 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 000018F8 5E                  <1> 	pop si				; (discard)
   728                              <1> .replace_no_pop:
   729 000018F9 268B4408            <1> 	mov ax, word [es:si + piStart]
   730 000018FD 268B540A            <1> 	mov dx, word [es:si + piStart + 2]	; get extended partition offset
   731 00001901 0343FC              <1> 	add ax, word [_BASE+di - 4]
   732 00001904 1353FE              <1> 	adc dx, word [_BASE+di - 2]	; add in root
   733 00001907 8943F8              <1> 	mov word [_BASE+di - 8], ax
   734 0000190A 8953FA              <1> 	mov word [_BASE+di - 6], dx	; set base
   735                              <1> 
   736 0000190D EBC1                <1> 	jmp .replace_common
   737                              <1> 
   738                              <1> 
   739                              <1> %if _BOOTCMD_FAIL_ERROR
   740                              <1> .got_partition_cycle:
   741 0000190F BA[0000]            <1> sptrel	mov dx, msg.boot_partition_cycle_error
   742                              <1> sptinternal
   743 00001912 E918EC              <1> 	jmp bootcmd.fail
   744                              <1> 
   745                              <1> .error_too_many_partitions:
   746 00001915 BA[0000]            <1> sptrel	mov dx, msg.boot_too_many_partitions_error
   747                              <1> sptinternal
   748 00001918 E912EC              <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 0000191B 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 0000191C 8B1E[0000]          <1> 	mov bx, word [auxbuff_segorsel]	; bx => auxbuff
   937                              <1> %else
   938                              <1> 	mov bx, word [bp + ldSectorSeg]
   939                              <1> %endif
   940 00001920 E85702              <1> 	call %[_SCANPTAB_PREFIX]read_ae_512_bytes
   941 00001923 5B                  <1> 	pop bx
   942 00001924 26813EFE0155AA      <1> 	cmp word [es:510], 0AA55h
   943 0000192B 7518                <1> 	jne .signature_fail
   944 0000192D 1E                  <1> 	 push ds
   945 0000192E 57                  <1> 	 push di
   946 0000192F 56                  <1> 	 push si
   947 00001930 51                  <1> 	 push cx
   948 00001931 06                  <1> 	push es
   949 00001932 1F                  <1> 	pop ds
   950 00001933 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 00001936 16                  <1> 	push ss
   955                              <1> %endif
   956 00001937 07                  <1> 	pop es
   957 00001938 BF[0001]            <1> sptrel	mov di, %[_SCANPTAB_PREFIX]partition_table
   958                              <1> sptinternal				; es:di -> cs:%[_SCANPTAB_PREFIX]partition_table
   959 0000193B B92000              <1> 	mov cx, 4*16 / 2
   960 0000193E F3A5                <1> 	rep movsw
   961 00001940 59                  <1> 	 pop cx
   962 00001941 5E                  <1> 	 pop si
   963 00001942 5F                  <1> 	 pop di
   964 00001943 1F                  <1> 	 pop ds
   965 00001944 C3                  <1> 	retn
   966                              <1> 
   967                              <1> 
   968                              <1> %if _BOOTCMD_FAIL_ERROR
   969                              <1> .signature_fail:
   970 00001945 BA[0000]            <1> sptrel	mov dx, msg.bootfail_sig_parttable
   971                              <1> sptinternal
   972 00001948 E9E2EB              <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 0000194B BA0A00                  	mov dx, 10		; set base: decimal
  3905                                  %if 1
  3906 0000194E 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 00001951 EB06                    	jmp @F
  3918                                  
  3919                                  
  3920                                  boot_get_hexadecimal_literal:
  3921 00001953 BA1000                  	mov dx, 16		; set base: hexadecimal
  3922                                  %if 1
  3923 00001956 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 00001959 B400                    	mov ah, 0
  3937 0000195B 31DB                    	xor bx, bx
  3938 0000195D 89D7                    	mov di, dx		; di = base
  3939                                  
  3940 0000195F E8(0000)[0000]          	nearcall getexpression.lit_isdigit?	; first character must be a digit
  3941 00001964 7245                    	jc .err2
  3942 00001966 31D2                    	xor dx, dx		; initialize value
  3943                                  .lit_loopdigit:
  3944 00001968 3C5F                    	cmp al, '_'
  3945 0000196A 7434                    	je .lit_skip
  3946 0000196C E8(0000)[0000]          	nearcall getexpression.lit_isdigit?	; was last character ?
  3947 00001971 7230                    	jc .lit_end		; yes -->
  3948 00001973 E8(0000)                	call capitalise
  3949 00001976 2C30                    	sub al, '0'
  3950 00001978 3C09                    	cmp al, 9		; was decimal digit ?
  3951 0000197A 7602                    	jbe .lit_decimaldigit	; yes -->
  3952 0000197C 2C07                    	sub al, 'A'-('9'+1)	; else adjust for hexadecimal digit
  3953                                  .lit_decimaldigit:
  3954 0000197E 50                      	push ax
  3955 0000197F 89D0                    	mov ax, dx
  3956 00001981 53                      	push bx
  3957 00001982 F7E7                    	mul di			; multiply low word with base
  3958 00001984 89D3                    	mov bx, dx
  3959 00001986 89C2                    	mov dx, ax
  3960 00001988 58                      	pop ax
  3961 00001989 52                      	push dx
  3962 0000198A F7E7                    	mul di			; multiply high word with base
  3963 0000198C 85D2                    	test dx, dx
  3964 0000198E 5A                      	pop dx
  3965 0000198F 751A                    	jnz .err2		; overflow -->
  3966 00001991 01C3                    	add bx, ax		; add them
  3967 00001993 58                      	pop ax
  3968 00001994 7215                    	jc .err2		; overflow -->
  3969 00001996 00C2                    	add dl, al		; add in the new digit
  3970 00001998 80D600                  	adc dh, 0
  3971 0000199B 83D300                  	adc bx, byte 0
  3972 0000199E 720B                    	jc .err2		; overflow -->
  3973                                  
  3974                                  .lit_skip:
  3975 000019A0 AC                      	lodsb
  3976 000019A1 EBC5                    	jmp short .lit_loopdigit
  3977                                  
  3978                                  .lit_end:
  3979 000019A3 E8(0000)[0000]          	nearcall isseparator?	; after the number, there must be a separator
  3980 000019A8 7501                    	jne .err2		; none here -->
  3981 000019AA C3                      	retn
  3982                                  
  3983                                  .err2:
  3984 000019AB E9(0000)                	jmp error
  3985                                  
  3986                                  
  3987                                  query_geometry:
  3988 000019AE E8(0000)                	call guard_auxbuff
  3989 000019B1 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 000019B5 B408                    	mov ah, 08h
  3996 000019B7 31C9                    	xor cx, cx		; initialise cl to 0
  3997 000019B9 890E[1A02]              	mov [load_heads], cx
  3998 000019BD 890E[1802]              	mov [load_sectors], cx
  3999 000019C1 31DB                    	xor bx, bx
  4000 000019C3 88D3                    	mov bl, dl
  4001 000019C5 F687[0000]04            	testopt [load_unit_flags + bx], lufForceGeometry
  4002 000019CA 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 000019CC F9                      	stc			; initialise to CY
  4009 000019CD E84901                  	call .int13_retry	; query drive geometry
  4010 000019D0 720C                    	jc .try_bootsector	; apparently failed -->
  4011 000019D2 88F2                    	mov dl, dh
  4012 000019D4 B600                    	mov dh, 0		; dx = maximum head number
  4013 000019D6 42                      	inc dx			; dx = number of heads (H is 0-based)
  4014 000019D7 89C8                    	mov ax, cx		; ax & 3Fh = maximum sector number
  4015 000019D9 83E03F                  	and ax, 3Fh		; get sectors (number of sectors, S is 1-based)
  4016 000019DC 7523                    	jnz .got_sectors_heads	; valid (S is 1-based), use these -->
  4017                                  				; zero = invalid
  4018                                  .try_bootsector:
  4019 000019DE 8E06[0000]              	mov es, word [auxbuff_segorsel]	; es => auxbuff
  4020 000019E2 31DB                    	xor bx, bx			; es:bx -> auxbuff
  4021 000019E4 B80102                  	mov ax, 0201h			; read sector, 1 sector
  4022 000019E7 B90100                  	mov cx, 1			; sector 1 (1-based!), cylinder 0 (0-based)
  4023 000019EA B600                    	mov dh, 0			; head 0 (0-based)
  4024 000019EC 8A16[4002]              	mov dl, [load_unit]
  4025 000019F0 F9                      	stc
  4026 000019F1 E82501                  	call .int13_retry
  4027 000019F4 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 000019F9 268B4718                	mov ax, word [es:bx + bsBPB + bpbCHSSectors]
  4033 000019FD 268B571A                	mov dx, word [es:bx + bsBPB + bpbCHSHeads]
  4034                                  
  4035                                  .got_sectors_heads:
  4036 00001A01 A3[1802]                	mov word [load_sectors], ax
  4037 00001A04 8916[1A02]              	mov word [load_heads], dx
  4038                                  
  4039 00001A08 85C0                    	test ax, ax
  4040 00001A0A 7503E94601              	jz .invalid_sectors
  4041 00001A0F 83F83F                  	cmp ax, 63
  4042 00001A12 7603E93E01              	ja .invalid_sectors
  4043 00001A17 85D2                    	test dx, dx
  4044 00001A19 7503E93E01              	jz .invalid_heads
  4045 00001A1E 81FA0001                	cmp dx, 100h
  4046 00001A22 7603E93501              	ja .invalid_heads
  4047                                  
  4048 00001A27 8E06[0000]              	mov es, word [auxbuff_segorsel]	; es => auxbuff
  4049 00001A2B 31DB                    	xor bx, bx			; es:bx -> auxbuff
  4050 00001A2D 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 00001A2F 89DF                    	mov di, bx
  4061 00001A31 B90110                  	mov cx, (8192 + 2) >> 1
  4062                                  					; es:bx -> auxbuff, es:di = same
  4063 00001A34 F3AB                    	rep stosw			; fill buffer, di -> behind (auxbuff+8192+2)
  4064 00001A36 B80102                  	mov ax, 0201h			; read sector, 1 sector
  4065 00001A39 41                      	inc cx				; sector 1 (1-based!), cylinder 0 (0-based)
  4066 00001A3A B600                    	mov dh, 0			; head 0 (0-based)
  4067 00001A3C 8A16[4002]              	mov dl, [load_unit]
  4068 00001A40 F9                      	stc
  4069 00001A41 E8D500                  	call .int13_retry
  4070 00001A44 7303E9ED00              	jc .access_error
  4071                                  
  4072 00001A49 FD                      	std				; _AMD_ERRATUM_109_WORKAROUND does not apply
  4073 00001A4A 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 00001A4B B90110                  	mov cx, (8192 + 2) >> 1
  4078 00001A4E 31C0                    	xor ax, ax
  4079 00001A50 F3AF                    	repe scasw
  4080 00001A52 83C704                  	add di, 4			; di -> first differing byte (from top)
  4081 00001A55 FC                      	cld
  4082 00001A56 57                      	push di
  4083                                  
  4084 00001A57 89DF                    	mov di, bx
  4085 00001A59 B90110                  	mov cx, (8192 + 2) >> 1
  4086 00001A5C 48                      	dec ax				; = FFFFh
  4087 00001A5D F3AB                    	rep stosw
  4088                                  
  4089 00001A5F B80102                  	mov ax, 0201h
  4090 00001A62 41                      	inc cx
  4091 00001A63 B600                    	mov dh, 0
  4092 00001A65 8A16[4002]              	mov dl, [load_unit]
  4093 00001A69 F9                      	stc
  4094 00001A6A E8AC00                  	call .int13_retry
  4095 00001A6D 7303E9C400              	jc .access_error
  4096                                  
  4097 00001A72 FD                      	std				; _AMD_ERRATUM_109_WORKAROUND does not apply
  4098 00001A73 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 00001A74 5A                      	pop dx
  4103 00001A75 B8FFFF                  	mov ax, -1
  4104 00001A78 B90110                  	mov cx, (8192 + 2) >> 1
  4105 00001A7B F3AF                    	repe scasw
  4106                                  %if 0
  4107                                  AAAB
  4108                                     ^
  4109                                  	sca B, match
  4110                                    ^
  4111                                  	sca B, mismatch
  4112                                   ^
  4113                                  	stop
  4114                                  %endif
  4115 00001A7D 83C704                  	add di, 4			; di -> first differing byte (from top)
  4116 00001A80 FC                      	cld
  4117                                  
  4118                                  %if 0
  4119                                  0000000000000
  4120                                  AAAAAAAA00000
  4121                                  	^
  4122                                  FFFFFFFFFFFFF
  4123                                  AAAAAAAA00FFF
  4124                                  	  ^
  4125                                  %endif
  4126 00001A81 39FA                    	cmp dx, di			; choose the higher one
  4127 00001A83 7302                    	jae @F
  4128 00001A85 89FA                    	mov dx, di
  4129                                  @@:
  4130 00001A87 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 00001A89 81FA0220                	cmp dx, 8192 + 2
  4137 00001A8D 7203E9AE00              	jae .sector_too_large
  4138 00001A92 B82000                  	mov ax, 32
  4139 00001A95 39C2                    	cmp dx, ax
  4140 00001A97 7303E9AB00              	jb .sector_too_small
  4141                                  @@:
  4142 00001A9C 39C2                    	cmp dx, ax
  4143 00001A9E 740C                    	je .got_match
  4144 00001AA0 3D0020                  	cmp ax, 8192
  4145 00001AA3 7203E9A600              	jae .sector_not_power
  4146 00001AA8 D1E0                    	shl ax, 1
  4147 00001AAA EBF0                    	jmp @B
  4148                                  
  4149                                  .got_match:
  4150 00001AAC A3[0B02]                	mov word [load_sectorsize], ax
  4151 00001AAF B104                    	mov cl, 4
  4152 00001AB1 D3E8                    	shr ax, cl
  4153 00001AB3 A3[EA01]                	mov word [load_sectorsizepara], ax
  4154                                  
  4155 00001AB6 C606[E701]00            	mov byte [load_ldflags], 0
  4156 00001ABB 8A16[4002]              	mov dl, [load_unit]
  4157 00001ABF 31DB                    	xor bx, bx
  4158 00001AC1 88D3                    	mov bl, dl
  4159 00001AC3 F687[0000]01            	testopt [load_unit_flags + bx], lufForceCHS
  4160 00001AC8 752B                    	jnz .no_lba
  4161 00001ACA F687[0000]02            	testopt [load_unit_flags + bx], lufForceLBA
  4162 00001ACF 7520                    	jnz .yes_lba
  4163                                  
  4164 00001AD1 1E                      	push ds
  4165 00001AD2 BB4000                  	mov bx, 40h	; bx = 40h
  4166 00001AD5 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 00001AD7 B80041                  	mov ax, 4100h
  4171 00001ADA BBAA55                  	mov bx, 55AAh
  4172 00001ADD 31C9                    	xor cx, cx
  4173 00001ADF 30F6                    	xor dh, dh
  4174 00001AE1 F9                      	stc
  4175 00001AE2 CD13                    	int 13h		; 13.41.bx=55AA extensions installation check
  4176 00001AE4 1F                      	pop ds
  4177 00001AE5 720E                    	jc .no_lba
  4178 00001AE7 81FB55AA                	cmp bx, 0AA55h
  4179 00001AEB 7508                    	jne .no_lba
  4180 00001AED D0E9                    	shr cl, 1	; support bitmap bit 0
  4181 00001AEF 7304                    	jnc .no_lba
  4182                                  
  4183                                  .yes_lba:
  4184                                  %if ldfHasLBA != 1
  4185                                   %error Assuming ldfHasLBA is 1
  4186                                  %endif
  4187 00001AF1 FE06[E701]              	inc byte [load_ldflags]
  4188                                  .no_lba:
  4189                                  
  4190 00001AF5 A1[0000]                	mov ax, word [auxbuff_segorsel]	; ax => auxbuff
  4191 00001AF8 89C2                    	mov dx, ax
  4192 00001AFA 81C2FF01                	add dx, (8192 - 16) >> 4
  4193 00001AFE 89C3                    	mov bx, ax
  4194 00001B00 89D1                    	mov cx, dx
  4195 00001B02 81E300F0                	and bx, 0F000h
  4196 00001B06 81E100F0                	and cx, 0F000h
  4197 00001B0A 39D9                    	cmp cx, bx
  4198 00001B0C 7504                    	jne @F
  4199 00001B0E A3[E401]                	mov word [load_sectorseg], ax
  4200 00001B11 C3                      	retn
  4201                                  
  4202                                  @@:
  4203 00001B12 BA[0000]                	mov dx, msg.boot_auxbuff_crossing
  4204 00001B15 B020                    	mov al, 20h
  4205 00001B17 EB48                    	jmp .error_common_j
  4206                                  
  4207                                  
  4208                                  .int13_retry:
  4209 00001B19 9C                      	pushf
  4210 00001B1A 50                      	push ax
  4211 00001B1B CD13                    	int 13h		; first try
  4212 00001B1D 730B                    	jnc @F		; NC, success on first attempt -->
  4213                                  
  4214                                  ; reset drive
  4215 00001B1F 31C0                    	xor ax, ax
  4216 00001B21 CD13                    	int 13h
  4217 00001B23 7205                    	jc @F		; CY, reset failed, error in ah -->
  4218                                  
  4219                                  ; try read again
  4220 00001B25 58                      	pop ax		; restore function number
  4221 00001B26 9D                      	popf		; CF
  4222 00001B27 CD13                    	int 13h		; retry, CF error status, ah error number
  4223 00001B29 C3                      	retn
  4224                                  
  4225                                  @@:			; NC or CY, stack has function number
  4226 00001B2A 44                      	inc sp
  4227 00001B2B 44                      	inc sp
  4228 00001B2C 44                      	inc sp
  4229 00001B2D 44                      	inc sp		; discard two words on stack, preserve CF
  4230 00001B2E C3                      	retn
  4231                                  
  4232                                  
  4233                                  .out_of_memory_error:
  4234 00001B2F BA[0000]                	mov dx, msg.boot_out_of_memory_error
  4235 00001B32 B021                    	mov al, 21h
  4236 00001B34 EB2B                    	jmp .error_common_j
  4237                                  .access_error:
  4238                                  %if _INPUT_FILE_BOOT
  4239 00001B36 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 00001B39 BA[0000]                	mov dx, msg.boot_access_error
  4244 00001B3C B022                    	mov al, 22h
  4245 00001B3E EB21                    	jmp .error_common_j
  4246                                  .sector_too_large:
  4247 00001B40 BA[0000]                	mov dx, msg.boot_sector_too_large
  4248 00001B43 B023                    	mov al, 23h
  4249 00001B45 EB1A                    	jmp .error_common_j
  4250                                  .sector_too_small:
  4251 00001B47 BA[0000]                	mov dx, msg.boot_sector_too_small
  4252 00001B4A B024                    	mov al, 24h
  4253 00001B4C EB13                    	jmp .error_common_j
  4254                                  .sector_not_power:
  4255 00001B4E BA[0000]                	mov dx, msg.boot_sector_not_power
  4256 00001B51 B025                    	mov al, 25h
  4257 00001B53 EB0C                    	jmp .error_common_j
  4258                                  .invalid_sectors:
  4259 00001B55 BA[0000]                	mov dx, msg.boot_invalid_sectors
  4260 00001B58 B026                    	mov al, 26h
  4261 00001B5A EB05                    	jmp .error_common_j
  4262                                  .invalid_heads:
  4263 00001B5C BA[0000]                	mov dx, msg.boot_invalid_heads
  4264 00001B5F B027                    	mov al, 27h
  4265                                  .error_common_j:
  4266 00001B61 B402                    	mov ah, 02h
  4267 00001B63 E8(0000)                	call setrc
  4268 00001B66 E9C4E9                  	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 00001B69 51                      	push cx
  4280 00001B6A 53                      	push bx
  4281 00001B6B B90006                  	mov cx, 1536
  4282                                  .loop:
  4283 00001B6E E81B00                  	call read_sector
  4284 00001B71 2B0E[0B02]              	sub cx, word [load_data - LOADDATA2 + bsBPB + bpbBytesPerSector]
  4285 00001B75 77F7                    	ja .loop
  4286 00001B77 07                      	pop es
  4287 00001B78 59                      	pop cx
  4288 00001B79 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 00001B7A 51                      	push cx
  4299 00001B7B 53                      	push bx
  4300 00001B7C B90002                  	mov cx, 512
  4301                                  .loop:
  4302 00001B7F E80A00                  	call read_sector
  4303 00001B82 2B0E[0B02]              	sub cx, word [load_data - LOADDATA2 + bsBPB + bpbBytesPerSector]
  4304 00001B86 77F7                    	ja .loop
  4305 00001B88 07                      	pop es
  4306 00001B89 59                      	pop cx
  4307 00001B8A 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 00001B8B 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 00001B8C F9                      	stc
  4337                                  
  4338                                  read_sector_CY_or_write_sector_NC:
  4339                                  	lframe near
  4340 00001B8D 5589E5                  	lenter
  4341                                  	lvar word, is_read_bit0
  4342 00001B90 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 00001B91 52                      	push dx
  4350 00001B92 51                      	push cx
  4351 00001B93 50                      	push ax
  4352 00001B94 56                      	push si
  4353                                  
  4354 00001B95 8EC3                    	mov es, bx
  4355                                  
  4356                                  ; DX:AX==LBA sector number
  4357                                  ; add partition start (= number of hidden sectors)
  4358 00001B97 0306[1C02]              		add ax,[load_data - LOADDATA2 + bsBPB + bpbHiddenSectors + 0]
  4359 00001B9B 1316[1E02]              		adc dx,[load_data - LOADDATA2 + bsBPB + bpbHiddenSectors + 2]
  4360                                  
  4361 00001B9F 19F6                    	sbb si, si	; -1 if was CY, 0 else
  4362 00001BA1 F7DE                    	neg si		; 1 if was CY, 0 else
  4363 00001BA3 31C9                    	xor cx, cx
  4364 00001BA5 51                      	push cx
  4365 00001BA6 56                      	push si		; bit 32 = 1 if operating in 33-bit space
  4366 00001BA7 52                      	push dx
  4367 00001BA8 50                      	push ax		; qword sector number (lpSector)
  4368 00001BA9 53                      	push bx
  4369 00001BAA 51                      	push cx		; bx:0 -> buffer (lpBuffer)
  4370 00001BAB 41                      	inc cx
  4371 00001BAC 51                      	push cx		; word number of sectors to read (lpCount)
  4372 00001BAD B110                    	mov cl, 10h
  4373 00001BAF 51                      	push cx		; word size of disk address packet (lpSize)
  4374 00001BB0 89E6                    	mov si, sp	; ds:si -> disk address packet (on stack)
  4375                                  
  4376 00001BB2 F606[E701]01            	test byte [load_data - LOADDATA2 + ldFlags], ldfHasLBA
  4377 00001BB7 7503E9BA00              	jz .no_lba
  4378                                  
  4379                                  d5	call d5message
  4380                                  d5	asciz "In read_sector.lba",13,10
  4381                                  
  4382 00001BBC 8A16[4002]              	mov dl, byte [load_unit]
  4383 00001BC0 E89001                  	call .set_ah_function_42_or_43
  4384 00001BC3 CD13                    	int 13h		; 13.42 extensions read
  4385 00001BC5 7203E9A600              	jnc .lba_done
  4386                                  
  4387 00001BCA 31C0                    	xor ax, ax
  4388 00001BCC CD13                    	int 13h
  4389 00001BCE 7303E948E9              	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 00001BD3 C6440201                	mov byte [si + lpCount], 1
  4395                                  
  4396 00001BD7 E87901                  	call .set_ah_function_42_or_43
  4397 00001BDA CD13                    	int 13h
  4398 00001BDC 7203E98F00              	jnc .lba_done
  4399                                  
  4400 00001BE1 80FC09                  	cmp ah, 9	; data boundary error?
  4401 00001BE4 7403E932E9              	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 00001BE9 F646FE01                	test byte [bp + ?is_read_bit0], 1
  4409 00001BED 7544                    	jnz .lba_sectorseg_read
  4410                                  
  4411                                  .lba_sectorseg_write:
  4412 00001BEF 06                      	push es
  4413                                  
  4414 00001BF0 1E                      	push ds
  4415 00001BF1 56                      	push si
  4416 00001BF2 57                      	push di
  4417 00001BF3 8B0E[0B02]              	mov cx, word [load_sectorsize]
  4418 00001BF7 8E06[E401]              	mov es, word [load_sectorseg]	; => sectorseg
  4419                                  	; lds si, [si + lpBuffer + 0]
  4420 00001BFB 8E5C06                  	mov ds, word [si + lpBuffer + 2]; => user buffer
  4421 00001BFE 31F6                    	xor si, si
  4422 00001C00 31FF                    	xor di, di
  4423 00001C02 F3A4                    	rep movsb			; copy data into sectorseg
  4424 00001C04 5F                      	pop di
  4425 00001C05 5E                      	pop si
  4426 00001C06 1F                      	pop ds
  4427                                  
  4428 00001C07 8E06[E401]              	 mov es, word [load_sectorseg]
  4429 00001C0B 8C4406                  	 mov word [si + lpBuffer + 2], es
  4430                                  					; => sectorseg
  4431                                  	; and word [si + lpBuffer + 0], byte 0
  4432                                  
  4433 00001C0E C6440201                	mov byte [si + lpCount], 1
  4434 00001C12 B80043                  	mov ax, 4300h
  4435 00001C15 CD13                    	int 13h
  4436 00001C17 7317                    	jnc @F
  4437                                  
  4438 00001C19 31C0                    	xor ax, ax
  4439 00001C1B CD13                    	int 13h
  4440 00001C1D 7303E9F9E8              	jc .lba_error
  4441                                  
  4442 00001C22 C6440201                	mov byte [si + lpCount], 1
  4443 00001C26 B80043                  	mov ax, 4300h
  4444 00001C29 CD13                    	int 13h
  4445 00001C2B 7303E9EBE8              	jc .lba_error
  4446                                  @@:
  4447                                  
  4448 00001C30 07                      	pop es
  4449 00001C31 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 00001C33 06                      	push es				; => user buffer
  4456 00001C34 8E06[E401]              	 mov es, word [load_sectorseg]
  4457 00001C38 8C4406                  	 mov word [si + lpBuffer + 2], es
  4458                                  	; and word [si + lpBuffer + 0], byte 0
  4459                                  
  4460 00001C3B C6440201                	mov byte [si + lpCount], 1
  4461 00001C3F E81101                  	call .set_ah_function_42_or_43
  4462 00001C42 CD13                    	int 13h
  4463 00001C44 7317                    	jnc .lba_sectorseg_done
  4464                                  
  4465 00001C46 31C0                    	xor ax, ax
  4466 00001C48 CD13                    	int 13h
  4467 00001C4A 7303E9CCE8              	jc .lba_error
  4468                                  
  4469 00001C4F C6440201                	mov byte [si + lpCount], 1
  4470 00001C53 E8FD00                  	call .set_ah_function_42_or_43
  4471 00001C56 CD13                    	int 13h
  4472 00001C58 7303E9BEE8              	jc .lba_error
  4473                                  .lba_sectorseg_done:
  4474                                  
  4475 00001C5D 31F6                    	xor si, si
  4476 00001C5F 07                      	pop es
  4477                                  	; pop cx
  4478 00001C60 57                      	 push di
  4479                                  	; mov di, cx
  4480 00001C61 31FF                    	xor di, di
  4481 00001C63 8B0E[0B02]              	mov cx, word [load_sectorsize]
  4482 00001C67 8E1E[E401]              	mov ds, word [load_sectorseg]
  4483 00001C6B F3A4                    	rep movsb
  4484 00001C6D 5F                      	 pop di
  4485                                  
  4486 00001C6E 16                      	push ss
  4487 00001C6F 1F                      	pop ds
  4488                                  .lba_done:
  4489 00001C70 83C410                  	add sp, 10h
  4490 00001C73 E9CB00                  	jmp .done
  4491                                  
  4492                                  .lba_error: equ .err
  4493                                  
  4494                                  .no_lba:
  4495 00001C76 83C408                  	add sp, 8
  4496 00001C79 58                      	pop ax
  4497 00001C7A 5A                      	pop dx
  4498 00001C7B 5E                      	pop si
  4499 00001C7C 59                      	pop cx
  4500 00001C7D 85F6                    	test si, si
  4501 00001C7F 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 00001C81 89C1                    			mov cx,ax
  4508 00001C83 89D0                    			mov ax,dx
  4509 00001C85 31D2                    			xor dx,dx
  4510 00001C87 F736[1802]              			div word [load_sectors]
  4511 00001C8B 91                      			xchg cx,ax
  4512 00001C8C F736[1802]              			div word [load_sectors]
  4513 00001C90 87CA                    			xchg cx,dx
  4514                                  
  4515                                  ; DX:AX=quotient, CX=remainder=sector (S) - 1
  4516                                  ; divide quotient by number of heads
  4517 00001C92 89C3                    			mov bx, ax
  4518 00001C94 92                      			xchg ax, dx
  4519 00001C95 31D2                    			xor dx, dx
  4520 00001C97 F736[1A02]              			div word [load_heads]
  4521 00001C9B 93                      			xchg bx, ax
  4522 00001C9C 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 00001CA0 88D6                    			mov dh, dl	; dh = head
  4527 00001CA2 41                      			inc cx		; cl5:0 = sector
  4528 00001CA3 86E8                    			xchg ch, al	; ch = cylinder 7:0, al = 0
  4529 00001CA5 D1E8                    			shr ax, 1
  4530 00001CA7 D1E8                    			shr ax, 1	; al7:6 = cylinder 9:8
  4531                                  	; bx has bits set iff it's > 0, indicating a cylinder >= 65536.
  4532 00001CA9 08FB                    			 or bl, bh	; collect set bits from bh
  4533 00001CAB 08C1                    			or cl, al	; cl7:6 = cylinder 9:8
  4534                                  	; ah has bits set iff it was >= 4, indicating a cylinder >= 1024.
  4535 00001CAD 08E3                    			 or bl, ah	; collect set bits from ah
  4536 00001CAF 8A16[4002]              			mov dl, [load_unit]
  4537                                  					; dl = drive
  4538                                  .err_4_NZ:
  4539 00001CB3 B404                    			mov ah, 04h	; error number: sector not found
  4540 00001CB5 7403E961E8              			 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 00001CBA BE1100                  			mov si, 16 + 1
  4546                                  .loop_chs_retry_repeat:
  4547 00001CBD E89F00                  			call .set_ax_function_0201_or_0301
  4548 00001CC0 CD13                    			int 13h		; read one sector
  4549 00001CC2 7349                    			jnc .done_j
  4550 00001CC4 50                      			push ax
  4551 00001CC5 31C0                    			xor ax, ax
  4552 00001CC7 CD13                    			int 13h		; reset disk
  4553 00001CC9 58                      			pop ax
  4554 00001CCA 4E                      			dec si		; another attempt ?
  4555 00001CCB 75F0                    			jnz .loop_chs_retry_repeat	; yes -->
  4556                                  
  4557 00001CCD 80FC09                  	cmp ah, 9	; data boundary error?
  4558 00001CD0 7403E946E8              	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 00001CD5 F646FE01                	test byte [bp + ?is_read_bit0], 1
  4566 00001CD9 7534                    	jnz .chs_sectorseg_read
  4567                                  
  4568                                  .chs_sectorseg_write:
  4569 00001CDB 06                      	push es
  4570                                  
  4571 00001CDC 1E                      	push ds
  4572 00001CDD 57                      	push di
  4573 00001CDE 51                      	push cx
  4574 00001CDF 8B0E[0B02]              	mov cx, word [load_sectorsize]
  4575 00001CE3 06                      	push es
  4576 00001CE4 8E06[E401]              	mov es, word [load_sectorseg]	; => sectorseg
  4577 00001CE8 1F                      	pop ds				; => user buffer
  4578 00001CE9 31F6                    	xor si, si
  4579 00001CEB 31FF                    	xor di, di
  4580 00001CED F3A4                    	rep movsb			; copy data into sectorseg
  4581 00001CEF 59                      	pop cx
  4582 00001CF0 5F                      	pop di
  4583 00001CF1 1F                      	pop ds
  4584                                  
  4585 00001CF2 B80103                  	mov ax, 0301h
  4586 00001CF5 CD13                    	int 13h
  4587 00001CF7 7313                    	jnc @F
  4588                                  
  4589 00001CF9 31C0                    	xor ax, ax
  4590 00001CFB CD13                    	int 13h
  4591 00001CFD 7303E919E8              	jc .err
  4592                                  
  4593 00001D02 B80103                  	mov ax, 0301h
  4594 00001D05 CD13                    	int 13h
  4595 00001D07 7303E90FE8              	jc .err
  4596                                  @@:
  4597 00001D0C 07                      	pop es
  4598                                  .done_j:
  4599 00001D0D EB32                    	jmp .done
  4600                                  
  4601                                  
  4602                                  .chs_sectorseg_read:
  4603                                  
  4604 00001D0F 06                      	push es		; user buffer
  4605 00001D10 8E06[E401]              	 mov es, word [load_sectorseg]
  4606                                  
  4607 00001D14 E84800                  	call .set_ax_function_0201_or_0301
  4608 00001D17 CD13                    	int 13h
  4609 00001D19 7313                    	jnc .chs_sectorseg_done
  4610                                  
  4611 00001D1B 31C0                    	xor ax, ax
  4612 00001D1D CD13                    	int 13h
  4613 00001D1F 7303E9F7E7              	jc .err
  4614                                  
  4615 00001D24 E83800                  	call .set_ax_function_0201_or_0301
  4616 00001D27 CD13                    	int 13h
  4617 00001D29 7303E9EDE7              	jc .err
  4618                                  .chs_sectorseg_done:
  4619                                  
  4620 00001D2E 31F6                    	xor si, si
  4621 00001D30 07                      	pop es
  4622 00001D31 57                      	 push di
  4623 00001D32 31FF                    	xor di, di
  4624 00001D34 8B0E[0B02]              	mov cx, word [load_sectorsize]
  4625 00001D38 8E1E[E401]              	mov ds, word [load_sectorseg]
  4626 00001D3C F3A4                    	rep movsb
  4627 00001D3E 5F                      	 pop di
  4628                                  
  4629 00001D3F 16                      	push ss
  4630 00001D40 1F                      	pop ds
  4631                                  .done:
  4632                                  ; increment segment
  4633 00001D41 8CC3                    	mov bx, es
  4634 00001D43 031E[EA01]              	add bx, word [load_sectorsizepara]
  4635                                  
  4636 00001D47 5E                      	pop si
  4637 00001D48 58                      	pop ax
  4638 00001D49 59                      	pop cx
  4639 00001D4A 5A                      	pop dx
  4640                                  ; increment LBA sector number
  4641 00001D4B 40                      	inc ax
  4642 00001D4C 7501                    	jne @F
  4643 00001D4E 42                      	inc dx
  4644                                  @@:
  4645 00001D4F 89EC5D                  	lleave code
  4646 00001D52 C3                      	retn
  4647                                  
  4648                                  .set_ah_function_42_or_43:
  4649 00001D53 B442                    	mov ah, 42h
  4650 00001D55 F646FE01                	test byte [bp + ?is_read_bit0], 1
  4651 00001D59 7503                    	jnz @F
  4652 00001D5B B80043                  	mov ax, 4300h
  4653                                  @@:
  4654 00001D5E C3                      	retn
  4655                                  
  4656                                  .set_ax_function_0201_or_0301:
  4657 00001D5F B001                    	mov al, 1
  4658                                  .set_ah_function_02_or_03:
  4659 00001D61 B402                    	mov ah, 02h
  4660 00001D63 F646FE01                	test byte [bp + ?is_read_bit0], 1
  4661 00001D67 7502                    	jnz @F
  4662 00001D69 B403                    	mov ah, 03h
  4663                                  @@:
  4664 00001D6B C3                      	retn
  4665                                  
  4666                                  	lleave ctx
  4667                                  
  4668                                  
  4669                                  %if _INPUT_FILE_BOOT || _EXTENSIONS
  4670                                  yy_boot_error:
  4671 00001D6C 52                      	push dx
  4672 00001D6D BA[0000]                	mov dx, msg.bootfail
  4673 00001D70 E8(0000)                	call putsz_error
  4674 00001D73 5A                      	pop dx
  4675 00001D74 EB03                    	jmp @F
  4676                                  
  4677                                  yy_boot_disp_error_1:
  4678 00001D76 B80002                  	mov ax, 0200h
  4679                                  @@:
  4680 00001D79 E8(0000)                	call setrc
  4681 00001D7C E8(0000)                	call display_y_or_ext
  4682 00001D7F E8(0000)                	call putsz_error
  4683 00001D82 FF26[0000]              	jmp near word [errret]
  4684                                  
  4685                                  yy_boot_parse_name: section_of_function
  4686 00001D86 8D5CFF                  	lea bx, [si - 1]	; -> start of name
  4687                                  yy_boot_parse_name_bx_buffer: section_of_function
  4688 00001D89 E874E2                  	call init_bootcmd
  4689 00001D8C E9(0000)                	jmp yy_common_parse_name_bx_buffer
  4690                                  
  4691                                  yy_boot:
  4692                                  %if _EXTENSIONS
  4693                                   %if _INPUT_FILE_BOOT
  4694 00001D8F D006[0000]              	rol byte [yy_is_script], 1
  4695 00001D93 7203E9DF00              	jnc ext_boot
  4696                                   %endif
  4697                                  %endif
  4698                                  
  4699                                  %if _INPUT_FILE_BOOT
  4700                                  yy_script_boot:
  4701 00001D98 E8EBFF                  	call yy_boot_parse_name
  4702                                  
  4703 00001D9B F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  4704 00001DA0 740C                    	jz @F
  4705 00001DA2 833E[2005]03            	cmp word [load_input_file.active], _INPUT_FILE_BOOT - 1
  4706 00001DA7 7205                    	jb @F
  4707                                  
  4708 00001DA9 BA[0000]                	mov dx, msg.yy_too_many_handles
  4709 00001DAC EBC8                    	jmp yy_boot_disp_error_1
  4710                                  @@:
  4711                                  
  4712 00001DAE 803F3A                  	cmp byte [bx], ':'
  4713 00001DB1 752D                    	jne .not_yy_goto_subfunction
  4714                                  
  4715 00001DB3 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  4716 00001DB8 7421                    	jz @F
  4717                                  
  4718 00001DBA 8B3E[0000]              	mov di, word [terminator_in_line_in.offset]
  4719 00001DBE A0[0000]                	mov al, byte [terminator_in_line_in.value]
  4720 00001DC1 8805                    	mov byte [di], al
  4721                                  
  4722 00001DC3 43                      	inc bx
  4723 00001DC4 89DE                    	mov si, bx
  4724 00001DC6 E8(0000)                	call skipwhite
  4725 00001DC9 4E                      	dec si
  4726 00001DCA 8936[2205]              	mov word [load_input_file.goto_offset], si
  4727                                  
  4728 00001DCE E87303                  	call yy_calculate_structure
  4729 00001DD1 E85003                  	call yy_boot_get.bx
  4730 00001DD4 800E[0000]80            	setopt [internalflags3], dif3_partition_changed
  4731 00001DD9 EB44                    	jmp .finish
  4732                                  
  4733                                  @@:
  4734 00001DDB BA[0000]                	mov dx, msg.yy_no_file
  4735 00001DDE EB96                    	jmp yy_boot_disp_error_1
  4736                                  
  4737                                  .not_yy_goto_subfunction:
  4738 00001DE0 8326[2205]00            	and word [load_input_file.goto_offset], 0
  4739 00001DE5 E8(0000)                	call skipcomm0
  4740 00001DE8 8936[0000]              	mov word [if_exists_then_address], si
  4741 00001DEC E8(0000)                	call iseol?_or_then
  4742 00001DEF 742B                    	je .not_yy_goto
  4743                                  
  4744 00001DF1 3C3A                    	cmp al, ':'
  4745 00001DF3 7403E9(0000)            	jne error
  4746                                  
  4747 00001DF8 E8(0000)                	call skipwhite
  4748 00001DFB 4E                      	dec si
  4749 00001DFC 8936[2205]              	mov word [load_input_file.goto_offset], si
  4750                                  
  4751                                  @@:
  4752 00001E00 AC                      	lodsb
  4753 00001E01 3C20                    	cmp al, 32
  4754 00001E03 740D                    	je @F
  4755 00001E05 3C09                    	cmp al, 9
  4756 00001E07 7409                    	je @F
  4757 00001E09 3C2C                    	cmp al, ','
  4758 00001E0B 7405                    	je @F
  4759 00001E0D E8(0000)                	call iseol?
  4760 00001E10 75EE                    	jne @B
  4761                                  @@:
  4762 00001E12 E8(0000)                	call skipcomm0
  4763 00001E15 8936[0000]              	mov word [if_exists_then_address], si
  4764 00001E19 E8(0000)                	call chkeol_or_then
  4765                                  
  4766                                  .not_yy_goto:
  4767 00001E1C E87700                  	call yy_boot_open_file
  4768                                  
  4769                                  .finish:
  4770 00001E1F 31ED                    	xor bp, bp
  4771 00001E21 31DB                    	xor bx, bx
  4772 00001E23 BE[C001]                	mov si, load_data_lowest
  4773 00001E26 B95000                  	mov cx, (LOAD_INPUT_FILE_SIZE + 1) >> 1
  4774                                  
  4775 00001E29 BF[A002]                	mov di, load_input_file
  4776 00001E2C F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  4777 00001E31 7415                    	jz @F
  4778 00001E33 8B1E[2005]              	mov bx, word [load_input_file.active]
  4779 00001E37 43                      	inc bx
  4780 00001E38 B8A000                  	mov ax, LOAD_INPUT_FILE_SIZE
  4781 00001E3B F7E3                    	mul bx
  4782                                  	; test dx, dx
  4783                                  	; jnz error
  4784 00001E3D 01C7                    	add di, ax
  4785 00001E3F 8B5586                  	mov dx, word [di - LOAD_INPUT_FILE_SIZE - LOADDATA3 + ldFATType]
  4786 00001E42 81E200F0                	and dx, ifhfTestReserved1 | ifhfTestReserved2 		| ifhfQuietInput | ifhfQuietOutput
  4788 00001E46 09D5                    	or bp, dx
  4789                                  
  4790                                  @@:
  4791                                  
  4792 00001E48 092E[E601]              	or word [load_data - LOADDATA2 + ldFATType], bp
  4793 00001E4C 16                      	push ss
  4794 00001E4D 07                      	pop es
  4795 00001E4E 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 00001E50 8026[0300]EF            	clropt [internalflags3], dif3_auxbuff_guarded_1
  4801 00001E55 E8(0000)                	call yy_reset_buf
  4802                                  
  4803 00001E58 891E[2005]              	mov word [load_input_file.active], bx
  4804 00001E5C 800E[0300]02            	setopt [internalflags2], dif2_input_file_boot
  4805                                  
  4806 00001E61 8B36[2205]              	mov si, word [load_input_file.goto_offset]
  4807 00001E65 85F6                    	test si, si
  4808 00001E67 7403E9(0000)            	jnz cmd_goto.yy_entry
  4809                                  
  4810 00001E6C F606[0300]08            	testopt [internalflags3], dif3_in_if
  4811 00001E71 7403E9(0000)            	jnz if_exists_found_open
  4812 00001E76 C3                      	retn
  4813                                  %endif
  4814                                  
  4815                                  
  4816                                  %if _EXTENSIONS
  4817                                  ext_boot:
  4818 00001E77 E80CFF                  	call yy_boot_parse_name
  4819 00001E7A 8D54FF                  	lea dx, [si - 1]
  4820 00001E7D 8916[0000]              	mov word [ext_cmdline], dx
  4821 00001E81 E8(0000)                	call skipcomm0
  4822 00001E84 8936[0000]              	mov word [if_exists_then_address], si
  4823 00001E88 E80B00                  	call yy_boot_open_file
  4824 00001E8B BB[C001]                	mov bx, load_data_lowest ; make yy_boot_get and yy_boot_update no-ops
  4825 00001E8E 8026[0300]EF            	clropt [internalflags3], dif3_auxbuff_guarded_1
  4826 00001E93 E9(0000)                	jmp ext_finish.boot
  4827                                  %endif
  4828                                  
  4829                                  
  4830                                  yy_boot_open_file: section_of_function
  4831                                  %if _CONFIG
  4832 00001E96 8926[0000]              	mov word [yy_boot_attempt_open_stack], sp
  4833 00001E9A 891E[0000]              	mov word [yy_boot_attempt_open_pathname], bx
  4834                                  %endif
  4835 00001E9E E81D01                  	call yy_boot_init_dir
  4836 00001EA1 C606[3B05]00            	mov byte [load_check_dir_attr], 0
  4837 00001EA6 8B36[5405]              	mov si, word [load_yyname_input]
  4838 00001EAA 803C2F                  	cmp byte [si], '/'
  4839 00001EAD 7501                    	jne @F
  4840 00001EAF 46                      	inc si
  4841                                  @@:
  4842                                  .dotcomponent:
  4843 00001EB0 803C00                  	cmp byte [si], 0
  4844 00001EB3 7509                    	jne @F
  4845                                  ..@yy_filename_empty: section_of_function
  4846 00001EB5 BA[0000]                	mov dx, msg.yy_filename_empty
  4847 00001EB8 B80A02                  	mov ax, 020Ah
  4848 00001EBB E9AEFE                  	jmp yy_boot_error
  4849                                  @@:
  4850 00001EBE 16                      	 push ss
  4851 00001EBF 07                      	 pop es
  4852 00001EC0 E8BAEB                  	call boot_parse_fn	; get next pathname
  4853 00001EC3 72EB                    	jc .dotcomponent
  4854 00001EC5 3C2F                    	cmp al, '/'
  4855 00001EC7 7509                    	jne @F
  4856 00001EC9 C606[3B05]10            	mov byte [load_check_dir_attr], ATTR_DIRECTORY
  4857 00001ECE 8936[5605]              	mov word [load_yyname_next], si
  4858                                  @@:
  4859                                  
  4860 00001ED2 BFFFFF                  	mov di, -1
  4861 00001ED5 89FE                    	mov si, di
  4862 00001ED7 897EF4                  	mov [bp + lsvFATSector], di
  4863 00001EDA 8976F6                  	mov [bp + lsvFATSector + 2], si
  4864                                  
  4865 00001EDD 31C0                    	xor ax, ax
  4866 00001EDF 31D2                    	xor dx, dx
  4867                                  
  4868                                  scan_dir_yyname_loop:
  4869 00001EE1 8946EC                  	mov word [bp + ldDirCluster], ax
  4870 00001EE4 8956EE                  	mov word [bp + ldDirCluster + 2], dx
  4871                                  
  4872 00001EE7 16                      	push ss
  4873 00001EE8 07                      	pop es
  4874 00001EE9 BB[8002]                	mov bx, load_yy_direntry
  4875                                  
  4876 00001EEC E8CAF6                  	call scan_dir_aux_for_file
  4877                                  
  4878 00001EEF 803E[3B05]10            	cmp byte [load_check_dir_attr], ATTR_DIRECTORY
  4879 00001EF4 753C                    	jne got_yyentry
  4880                                  
  4881 00001EF6 56                      	push si
  4882 00001EF7 57                      	push di
  4883 00001EF8 C606[3B05]00            	mov byte [load_check_dir_attr], 0
  4884 00001EFD 8B36[5605]              	mov si, word [load_yyname_next]
  4885                                  .dotcomponent_next:
  4886 00001F01 803C00                  	cmp byte [si], 0
  4887 00001F04 7502                    	jne @F
  4888 00001F06 EBAD                    	jmp ..@yy_filename_empty
  4889                                  @@:
  4890 00001F08 06                      	push es
  4891 00001F09 16                      	 push ss
  4892 00001F0A 07                      	 pop es
  4893 00001F0B E86FEB                  	call boot_parse_fn	; get next pathname
  4894 00001F0E 07                      	pop es
  4895 00001F0F 72F0                    	jc .dotcomponent_next
  4896 00001F11 3C2F                    	cmp al, '/'
  4897 00001F13 7509                    	jne @F
  4898 00001F15 C606[3B05]10            	mov byte [load_check_dir_attr], ATTR_DIRECTORY
  4899 00001F1A 8936[5605]              	mov word [load_yyname_next], si
  4900                                  @@:
  4901 00001F1E 5F                      	pop di
  4902 00001F1F 5E                      	pop si
  4903                                  
  4904 00001F20 31D2                    	xor dx, dx
  4905 00001F22 268B471A                	mov ax, [es:bx + deClusterLow]
  4906                                  				; = first cluster (not FAT32)
  4907 00001F26 807EE620                	cmp byte [bp + ldFATType], 32
  4908 00001F2A 7504                    	jne @F
  4909 00001F2C 268B5714                	mov dx, [es:bx + deClusterHigh]
  4910                                  				; dx:ax = first cluster (FAT32)
  4911                                  @@:
  4912                                  
  4913 00001F30 EBAF                    	jmp scan_dir_yyname_loop
  4914                                  
  4915                                  
  4916                                  got_yyentry: section_of_function
  4917                                  
  4918                                  
  4919                                  ; (boot32.asm code starts here)
  4920                                  
  4921 00001F32 8B1E[9C02]              		mov bx, [load_yy_direntry + deSize]
  4922 00001F36 A1[9E02]                		mov ax, [load_yy_direntry + deSize + 2]
  4923                                  					 ; ax:bx = file size
  4924 00001F39 8A16[8C02]              		mov dl, [load_yy_direntry + 12]
  4925                                  					; dl = FAT+ size bits
  4926 00001F3D 88D6                    		mov dh, dl
  4927 00001F3F 81E207E0                		and dx, 0E007h		; obtain bits 7-5 and 2-0
  4928 00001F43 7409                    		jz @F
  4929 00001F45 BA[0000]                	mov dx, msg.yy_too_large
  4930 00001F48 B80B02                  	mov ax, 020Bh
  4931 00001F4B E91EFE                  	jmp yy_boot_error
  4932                                  @@:
  4933 00001F4E 895EC4                  	mov word [bp + ldFileSize], bx
  4934 00001F51 8946C6                  	mov word [bp + ldFileSize + 2], ax
  4935                                  
  4936 00001F54 09D8                    	or ax, bx
  4937 00001F56 750C                    	jnz @F
  4938                                  
  4939 00001F58 E83D00                  	call yy_boot_file_not_found
  4940 00001F5B BA[0000]                	mov dx, msg.yy_empty
  4941 00001F5E B80C02                  	mov ax, 020Ch
  4942 00001F61 E908FE                  	jmp yy_boot_error
  4943                                  @@:
  4944                                  
  4945                                  ; get starting cluster of file
  4946 00001F64 31D2                    		xor dx, dx
  4947 00001F66 A1[9A02]                		mov ax, [load_yy_direntry + deClusterLow]
  4948                                  					; = first cluster (not FAT32)
  4949                                  
  4950 00001F69 807EE620                		cmp byte [bp + ldFATType], 32
  4951 00001F6D 7504                    		jne @F
  4952 00001F6F 8B16[9402]              		mov dx, [load_yy_direntry + deClusterHigh]
  4953                                  					; dx:ax = first cluster (FAT32)
  4954                                  @@:
  4955                                  
  4956 00001F73 80E60F                  	and dh, 0Fh
  4957 00001F76 8946F0                  		mov word [bp + lsvFirstCluster], ax
  4958 00001F79 8956F2                  		mov word [bp + lsvFirstCluster + 2], dx
  4959                                  
  4960 00001F7C 8946C8                  	mov word [bp + ldCurrentCluster], ax
  4961 00001F7F 8956CA                  	mov word [bp + ldCurrentCluster + 2], dx
  4962 00001F82 31DB                    	xor bx, bx
  4963 00001F84 895ECC                  	mov word [bp + ldCurrentSeek], bx
  4964 00001F87 895ECE                  	mov word [bp + ldCurrentSeek + 2], bx
  4965 00001F8A E841F8                  		call check_clust
  4966 00001F8D 7303E9C006              		jc error_badchain
  4967                                  
  4968 00001F92 800E[0000]80            	setopt [internalflags3], dif3_partition_changed
  4969                                  
  4970 00001F97 C3                      	retn
  4971                                  
  4972                                  
  4973                                  yy_boot_file_not_found:
  4974                                  %if _CONFIG
  4975 00001F98 8B3E[0000]              	mov di, word [yy_boot_attempt_open_pathname]
  4976 00001F9C 85FF                    	test di, di
  4977 00001F9E 7413                    	jz @F
  4978 00001FA0 16                      	push ss
  4979 00001FA1 07                      	pop es
  4980 00001FA2 E8(0000)                	call retry_open_scriptspath
  4981 00001FA5 750C                    	jnz @F
  4982 00001FA7 8B26[0000]              	mov sp, word [yy_boot_attempt_open_stack]
  4983 00001FAB 8026[0300]EF            	clropt [internalflags3], dif3_auxbuff_guarded_1
  4984 00001FB0 E9E3FE                  	jmp yy_boot_open_file
  4985                                  %endif
  4986                                  @@:
  4987                                  .if:
  4988 00001FB3 F606[0300]08            	testopt [internalflags3], dif3_in_if
  4989 00001FB8 7403E9(0000)            	jnz if_exists_not_found
  4990 00001FBD C3                      	retn
  4991                                  
  4992                                  
  4993                                  yy_boot_init_dir: section_of_function
  4994 00001FBE 31C0                    	xor ax, ax
  4995 00001FC0 89461C                  	mov [bp + bsBPB + bpbHiddenSectors + 0], ax
  4996 00001FC3 89461E                  	mov [bp + bsBPB + bpbHiddenSectors + 2], ax
  4997 00001FC6 F9                      	stc
  4998 00001FC7 89DE                    	mov si, bx
  4999 00001FC9 AC                      	lodsb
  5000 00001FCA E870E7                  	call parseloadunit_default_sdp.cf
  5001 00001FCD 7506                    	jnz .have_filename
  5002                                  
  5003 00001FCF BA[0000]                	mov dx, msg.yy_requires_filename
  5004 00001FD2 E9A1FD                  	jmp yy_boot_disp_error_1
  5005                                  
  5006                                  .have_filename:
  5007 00001FD5 BB[5405]                	mov bx, load_yyname_input
  5008 00001FD8 E81BE3                  	call bootcmd.pathname_parse_super
  5009                                  
  5010 00001FDB F606[0000]07            	testopt [internalflags3], dif3_load_is_dp
  5011 00001FE0 754E                    	jnz .load_yy_from_ldp
  5012                                  
  5013 00001FE2 8A1E[3805]              	mov bl, [load_partition]
  5014 00001FE6 803E[4002]80            	cmp byte [load_unit], 80h
  5015 00001FEB 721F                    	jb .p_f_is_diskette
  5016 00001FED 84DB                    	test bl, bl		; partition specified ?
  5017 00001FEF 7503E9(0000)            	jz error		; no, error -->
  5018                                  
  5019 00001FF4 E8B7F9                  	call query_geometry
  5020                                  
  5021 00001FF7 B9[5820]                	mov cx, load_yy_from_partition
  5022 00001FFA E803F8                  	call scan_partitions
  5023 00001FFD E898FF                  	call yy_boot_file_not_found
  5024 00002000 BA[0000]                	mov dx, msg.boot_partition_not_found
  5025 00002003 B80602                  	mov ax, 0206h
  5026 00002006 E8(0000)                	call setrc
  5027 00002009 E921E5                  	jmp bootcmd.fail
  5028                                  
  5029                                  
  5030                                  .p_f_is_diskette:
  5031 0000200C 84DB                    	test bl, bl		; partition specified ?
  5032 0000200E 7403E9(0000)            	jnz error		; yes, error -->
  5033                                  
  5034 00002013 E898F9                  	call query_geometry
  5035                                  
  5036 00002016 31C0                    	xor ax, ax
  5037 00002018 31D2                    	xor dx, dx
  5038                                  @@:
  5039 0000201A 8B1E[0000]              	mov bx, word [auxbuff_segorsel]	; bx => auxbuff
  5040 0000201E 52                      	 push dx
  5041 0000201F 50                      	 push ax
  5042 00002020 E857FB                  	call read_ae_512_bytes
  5043                                  
  5044 00002023 26813EFE0155AA          	cmp word [es:510], 0AA55h
  5045 0000202A 7510                    	jne boot_sigmismatch
  5046 0000202C 58                      	 pop ax
  5047 0000202D 5A                      	 pop dx
  5048                                  
  5049 0000202E EB62                    	jmp load_yy_common
  5050                                  
  5051                                  
  5052                                  .load_yy_from_ldp:
  5053 00002030 E87BF9                  	call query_geometry
  5054 00002033 A1[2805]                	mov ax, word [load_partition_sector]
  5055 00002036 8B16[2A05]              	mov dx, word [load_partition_sector + 2]
  5056 0000203A EBDE                    	jmp @B
  5057                                  %endif
  5058                                  
  5059                                  
  5060                                  boot_sigmismatch:
  5061 0000203C BA[0000]                	mov dx, msg.bootfail_sig
  5062 0000203F B80702                  	mov ax, 0207h
  5063                                  @@:
  5064 00002042 E8(0000)                	call setrc
  5065 00002045 E9E5E4                  	jmp bootcmd.fail
  5066                                  
  5067                                  boot_codemismatch:
  5068 00002048 BA[0000]                	mov dx, msg.bootfail_code
  5069 0000204B B80802                  	mov ax, 0208h
  5070 0000204E EBF2                    	jmp @B
  5071                                  
  5072                                  boot_secsizemismatch:
  5073 00002050 BA[0000]                	mov dx, msg.bootfail_secsizediffer
  5074 00002053 B80902                  	mov ax, 0209h
  5075 00002056 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 00002058 A0[3905]                	mov al, byte [load_current_partition]
  5091 0000205B 3A06[3805]              	cmp al, byte [load_partition]
  5092 0000205F 7401                    	je .gotit
  5093 00002061 C3                      	retn
  5094                                  
  5095                                  .gotit:
  5096                                  d4	call d4message
  5097                                  d4	asciz "In load_yy_from_partition.gotit",13,10
  5098                                  
  5099 00002062 8B43F8                  	mov ax, [bp + di - 8]
  5100 00002065 8B53FA                  	mov dx, [bp + di - 6]		; base (current table position)
  5101                                  
  5102 00002068 26034408                	add ax, [es:si + 8]
  5103 0000206C 2613540A                	adc dx, [es:si + 8 + 2]		; add offset to logical partition
  5104                                  
  5105 00002070 26894408                	mov word [es:si + 8], ax
  5106 00002074 2689540A                	mov word [es:si + 8 + 2], dx	; store in partition table entry
  5107                                  
  5108 00002078 89EC                    	mov sp, bp
  5109 0000207A 5D                      	pop bp				; restore bp (scan_partitions)
  5110 0000207B 5B                      	pop bx				; discard ret address (scan_partitions)
  5111                                  
  5112                                  					; dx:ax = absolute sector number
  5113 0000207C 8B1E[0000]              	mov bx, word [auxbuff_segorsel]	; bx => auxbuff
  5114 00002080 50                      	push ax
  5115 00002081 52                      	push dx
  5116 00002082 E8F5FA                  	call read_ae_512_bytes		; load partition boot sector
  5117                                  
  5118 00002085 26813EFE0155AA          	cmp word [es:510], 0AA55h
  5119 0000208C 75AE                    	jne boot_sigmismatch
  5120                                  
  5121 0000208E 31C9                    	xor cx, cx
  5122                                  ;	cmp word [es:0], cx
  5123                                  ;	je boot_codemismatch
  5124                                  
  5125 00002090 5A                      	pop dx
  5126 00002091 58                      	pop ax
  5127                                  
  5128                                  		; dx:ax = boot sector
  5129                                  		; byte [load_unit] = unit
  5130                                  		; es:0-> read sector
  5131                                  load_yy_common:
  5132 00002092 26A31C00                	mov word [es:bsBPB + bpbHiddenSectors], ax
  5133 00002096 2689161E00              	mov word [es:bsBPB + bpbHiddenSectors + 2], dx
  5134                                  
  5135 0000209B 8B5E0B                  	mov bx, [bp + bsBPB + bpbBytesPerSector]
  5136 0000209E 263B1E0B00              	cmp bx, [es:bsBPB + bpbBytesPerSector]
  5137 000020A3 75AB                    	jne boot_secsizemismatch
  5138                                  
  5139                                  		; preserve some variables from our pseudo BPB
  5140 000020A5 31C0                    	xor ax, ax
  5141 000020A7 FF7618                  	push word [bp + bsBPB + bpbCHSSectors]
  5142 000020AA 268F061800              	pop word [es:bsBPB + bpbCHSSectors]
  5143 000020AF FF761A                  	push word [bp + bsBPB + bpbCHSHeads]
  5144 000020B2 268F061A00              	pop word [es:bsBPB + bpbCHSHeads]	; preserve geometry
  5145                                  
  5146 000020B7 8B5EEA                  	mov bx, word [bp + ldParaPerSector]
  5147 000020BA D1EB                    	shr bx, 1
  5148 000020BC 895ED4                  	mov word [bp + ldEntriesPerSector], bx
  5149                                  
  5150 000020BF 2639061600              	cmp word [es:bsBPB + bpbSectorsPerFAT], ax
  5151 000020C4 8A5E40                  	mov bl, byte [bp + bsBPB + ebpbNew + bpbnBootUnit]
  5152 000020C7 7407                    	je .is_fat32
  5153 000020C9 26881E2400              	mov byte [es:bsBPB + bpbNew + bpbnBootUnit], bl
  5154 000020CE EB05                    	jmp short .was_fat1612
  5155                                  .is_fat32:
  5156 000020D0 26881E4000              	mov byte [es:bsBPB + ebpbNew + bpbnBootUnit], bl
  5157                                  .was_fat1612:
  5158                                  
  5159 000020D5 06                      	 push es
  5160 000020D6 1E                      	 push ds
  5161 000020D7 06                      	push es
  5162 000020D8 1F                      	pop ds
  5163 000020D9 31F6                    	xor si, si				; -> BPB from boot partition
  5164 000020DB 16                      	push ss
  5165 000020DC 07                      	pop es
  5166 000020DD BF[0002]                	mov di, load_data - LOADDATA2		; -> our copy of a BPB
  5167 000020E0 B95A00                  	mov cx, (bsBPB + ebpbNew + BPBN_size)
  5168 000020E3 F3A4                    	rep movsb				; get the BPB
  5169                                  
  5170 000020E5 1F                      	 pop ds
  5171                                  
  5172 000020E6 394616                  	cmp word [bp + bsBPB + bpbSectorsPerFAT], ax
  5173 000020E9 740B                    	je @F					; is FAT32 -->
  5174 000020EB BE[2402]                	mov si, load_data - LOADDATA2 + bsBPB + bpbNew
  5175 000020EE BF[4002]                	mov di, load_data - LOADDATA2 + bsBPB + ebpbNew
  5176 000020F1 B91A00                  	mov cx, BPBN_size
  5177 000020F4 F3A4                    	rep movsb				; clone the FAT16 / FAT12 BPBN
  5178                                  						; to where the FAT32 BPBN lives
  5179                                  @@:
  5180 000020F6 07                      	 pop es
  5181                                  
  5182                                  .outofmem: equ query_geometry.out_of_memory_error
  5183                                  
  5184 000020F7 FF36[0000]              	push word [auxbuff_segorsel]
  5185 000020FB 8F46F8                  	pop word [bp + lsvFATSeg]
  5186 000020FE 804EE702                	or byte [bp + ldFlags], ldfFATInvalid
  5187 00002102 B8FFFF                  	mov ax, -1
  5188 00002105 8946F4                  	mov word [bp + lsvFATSector], ax
  5189 00002108 8946F6                  	mov word [bp + lsvFATSector + 2], ax
  5190                                  
  5191 0000210B E80705                  	call initialise_fs
  5192 0000210E 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 0000210F A1[2005]                	mov ax, word [load_input_file.active]
  5201 00002112 48                      	dec ax
  5202 00002113 790B                    	jns .next
  5203 00002115 8026[0300]FD            	clropt [internalflags2], dif2_input_file_boot
  5204 0000211A 800E[0300]04            	setopt [internalflags2], dif2_closed_input_file_boot
  5205 0000211F C3                      	retn
  5206                                  .next:
  5207 00002120 A3[2005]                	mov word [load_input_file.active], ax
  5208 00002123 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 00002124 16                      	push ss
  5217 00002125 07                      	pop es
  5218                                  
  5219                                  %if _INPUT_FILE_BOOT
  5220 00002126 51                      	push cx
  5221 00002127 BF[C001]                	mov di, load_data_lowest
  5222 0000212A B95000                  	mov cx, (LOAD_INPUT_FILE_SIZE + 1) >> 1
  5223 0000212D 89DE                    	mov si, bx
  5224 0000212F F3A5                    	rep movsw
  5225 00002131 59                      	pop cx
  5226                                  %endif
  5227 00002132 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 00002133 9C                      	pushf
  5236                                  
  5237 00002134 16                      	push ss
  5238 00002135 07                      	pop es
  5239                                  
  5240                                  %if _INPUT_FILE_BOOT
  5241 00002136 51                      	push cx
  5242 00002137 BE[C001]                	mov si, load_data_lowest
  5243 0000213A B90800                  	mov cx, LOADDATA3_size >> 1
  5244 0000213D 89DF                    	mov di, bx
  5245 0000213F F3A5                    	rep movsw
  5246 00002141 59                      	pop cx
  5247                                  %endif
  5248 00002142 9D                      	popf			; ZF, CF
  5249 00002143 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 00002144 52                      	push dx
  5258 00002145 B8A000                  	mov ax, LOAD_INPUT_FILE_SIZE
  5259 00002148 F726[2005]              	mul word [load_input_file.active]
  5260                                  
  5261                                  ;	test dx, dx
  5262                                  ;	jnz .error
  5263 0000214C 5A                      	pop dx
  5264                                  
  5265 0000214D 93                      	xchg bx, ax
  5266 0000214E 81C3[A002]              	add bx, load_input_file
  5267 00002152 C3                      	retn
  5268                                  %endif
  5269                                  
  5270                                  
  5271                                  guard_auxbuff_return:
  5272 00002153 F606[0300]70            	testopt [internalflags3], dif3_auxbuff_guarded_1 		| dif3_auxbuff_guarded_2 		| dif3_auxbuff_guarded_3
  5275 00002158 7506                    	jnz @F
  5276 0000215A 800E[0300]10            	setopt [internalflags3], dif3_auxbuff_guarded_1
  5277                                  					; (NC)
  5278 0000215F C3                      	retn
  5279                                  
  5280                                  @@:
  5281 00002160 BA[0000]                	mov dx, msg.guard_auxbuff_error
  5282 00002163 E8(0000)                	call putsz
  5283 00002166 F9                      	stc				; (CY)
  5284 00002167 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 00002168 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 0000216B 5589E58D66F4            	lenter
  5309                                  	lvar dword, pointer
  5310 00002171 06                      	 push es
  5311 00002172 52                      	 push dx
  5312                                  	lvar word, load_input_file_structure
  5313 00002173 53                      	 push bx
  5314 00002174 31C0                    	xor ax, ax
  5315                                  	lvar word, did_guard_auxbuff
  5316 00002176 50                      	 push ax
  5317                                  	lvar word, read_how_many
  5318 00002177 50                      	 push ax
  5319 00002178 52                      	push dx
  5320 00002179 56                      	push si
  5321 0000217A 57                      	push di
  5322 0000217B 51                      	push cx
  5323                                  
  5324 0000217C FF36[0000]              	push word [errret]
  5325 00002180 FF36[0000]              	push word [throwret]
  5326 00002184 FF36[0000]              	push word [throwsp]
  5327                                  
  5328 00002188 55                      	push bp
  5329                                  
  5330 00002189 C706[0000][7E23]        	mov word [errret], .err_ret
  5331 0000218F C706[0000][7E23]        	mov word [throwret], .err_ret
  5332 00002195 8926[0000]              	mov word [throwsp], sp
  5333                                  
  5334                                  		; bx -> load_input_file structure
  5335 00002199 E888FF                  	call yy_boot_get.bx
  5336                                  
  5337 0000219C E8B4FF                  	call guard_auxbuff_return
  5338 0000219F 7303E9A801              	jc .error
  5339 000021A4 FF46EC                  	inc word [bp + ?did_guard_auxbuff]
  5340                                  
  5341 000021A7 B8FFFF                  	mov ax, -1
  5342 000021AA A3[F601]                	mov word [load_data - LOADDATA2 + lsvFATSector + 2], ax
  5343 000021AD A3[F401]                	mov word [load_data - LOADDATA2 + lsvFATSector + 0], ax
  5344 000021B0 800E[E701]04            	setopt [load_ldflags], ldfFATBuffered
  5345                                  
  5346 000021B5 8B16[C601]              	mov dx, word [load_data - LOADDATA2 + ldFileSize + 2]
  5347 000021B9 A1[C401]                	mov ax, word [load_data - LOADDATA2 + ldFileSize]
  5348                                  
  5349 000021BC 2B06[CC01]              	sub ax, word [load_data - LOADDATA2 + ldCurrentSeek]
  5350 000021C0 1B16[CE01]              	sbb dx, word [load_data - LOADDATA2 + ldCurrentSeek + 2]
  5351                                  					; dx:ax = read at most this many bytes
  5352 000021C4 7304                    	jnc @F
  5353                                  		; file size below current seek
  5354 000021C6 31C0                    	xor ax, ax
  5355 000021C8 31D2                    	xor dx, dx			; = read at most zero bytes
  5356                                  @@:
  5357 000021CA 85D2                    	test dx, dx
  5358 000021CC 7506                    	jnz .use_count
  5359 000021CE 39C8                    	cmp ax, cx			; dx:ax >= cx ?
  5360 000021D0 7302                    	jae .use_count			; yes, use cx as count to read
  5361 000021D2 89C1                    	mov cx, ax			; no, use (dx:)ax as count to read
  5362                                  .use_count:
  5363 000021D4 85C9                    	test cx, cx			; any more to read ?
  5364 000021D6 7503E97001              	jz .success			; no, reached the end -->
  5365 000021DB 894EFE                  	mov word [bp + ?length], cx
  5366                                  
  5367                                  .next_cluster:
  5368 000021DE 8B36[CE01]              	mov si, word [load_data - LOADDATA2 + ldCurrentSeek + 2]
  5369 000021E2 8B3E[CC01]              	mov di, word [load_data - LOADDATA2 + ldCurrentSeek]
  5370 000021E6 A1[0B02]                	mov ax, word [load_data - LOADDATA2 + bsBPB + bpbBytesPerSector]
  5371 000021E9 F726[E801]              	mul word [load_data - LOADDATA2 + ldClusterSize]
  5372                                  
  5373 000021ED 8946F8                  	mov word [bp + ?bytes_per_cluster], ax
  5374 000021F0 8956FA                  	mov word [bp + ?bytes_per_cluster + 2], dx
  5375 000021F3 83E801                  	sub ax, 1
  5376 000021F6 83DA00                  	sbb dx, 0
  5377 000021F9 21D6                    	and si, dx
  5378 000021FB 21C7                    	and di, ax		; how far are we into cluster
  5379                                  
  5380 000021FD 897EF4                  	mov word [bp + ?how_far_in_cluster], di
  5381 00002200 8976F6                  	mov word [bp + ?how_far_in_cluster + 2], si
  5382                                  
  5383 00002203 F7DE                    	neg si
  5384 00002205 F7DF                    	neg di
  5385 00002207 83DE00                  	sbb si, byte 0		; neg si:di
  5386                                  
  5387 0000220A 037EF8                  	add di, word [bp + ?bytes_per_cluster]
  5388 0000220D 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 00002210 85F6                    	test si, si
  5392 00002212 7506                    	jnz .use_count_2
  5393 00002214 39CF                    	cmp di, cx
  5394 00002216 7302                    	jae .use_count_2
  5395 00002218 89F9                    	mov cx, di
  5396                                  .use_count_2:
  5397 0000221A 894EFC                  	mov word [bp + ?length_this_cluster], cx
  5398                                  
  5399                                  .next_sector:
  5400 0000221D A1[C801]                	mov ax, word [load_data - LOADDATA2 + ldCurrentCluster]
  5401 00002220 8B16[CA01]              	mov dx, word [load_data - LOADDATA2 + ldCurrentCluster + 2]
  5402 00002224 E8A7F5                  	call check_clust
  5403 00002227 7303E92001              	jc .error
  5404 0000222C E874F4                  	call clust_to_first_sector
  5405 0000222F 8B1E[0B02]              	mov bx, word [load_data - LOADDATA2 + bsBPB + bpbBytesPerSector]
  5406 00002233 8B7EF4                  	mov di, word [bp + ?how_far_in_cluster]
  5407 00002236 8B76F6                  	mov si, word [bp + ?how_far_in_cluster + 2]
  5408 00002239 87D6                    	xchg dx, si
  5409 0000223B 97                      	xchg ax, di
  5410 0000223C F7F3                    	div bx
  5411                                  		; dx = byte offset into sector
  5412                                  		; ax = sector offset into cluster's data
  5413 0000223E 01C7                    	add di, ax
  5414 00002240 83D600                  	adc si, 0
  5415 00002243 87D6                    	xchg dx, si
  5416 00002245 97                      	xchg ax, di
  5417                                  		; dx:ax = sector in fs
  5418                                  		; si = byte offset
  5419                                  
  5420 00002246 89F1                    	mov cx, si		; = byte offset
  5421 00002248 F7D9                    	neg cx			; - byte offset
  5422 0000224A 01D9                    	add cx, bx		; sector size - byte offset
  5423                                  				;  = length this sector
  5424 0000224C 3B4EFC                  	cmp cx, word [bp + ?length_this_cluster]
  5425 0000224F 7603                    	jbe @F			; sector has less than requested -->
  5426 00002251 8B4EFC                  	mov cx, word [bp + ?length_this_cluster]
  5427                                  				; fill entire remaining request
  5428                                  @@:
  5429 00002254 8B1E[0000]              	mov bx, word [auxbuff_segorsel]
  5430 00002258 813E[0B02]0010          	cmp word [load_data - LOADDATA2 + bsBPB + bpbBytesPerSector], 4096
  5431 0000225E 7706                    	ja .invalidatefat
  5432 00002260 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 00002264 EB0A                    	jmp @F
  5439                                  .invalidatefat:
  5440                                  		; need to invalidate FAT buffer
  5441 00002266 830E[F601]FF            	or word [load_data - LOADDATA2 + lsvFATSector + 2], -1
  5442 0000226B 830E[F401]FF            	or word [load_data - LOADDATA2 + lsvFATSector + 0], -1
  5443                                  @@:
  5444                                  
  5445 00002270 813E[0B02]0002          	cmp word [load_data - LOADDATA2 + bsBPB + bpbBytesPerSector], 512
  5446 00002276 7745                    	ja .nodatabuffer	; data buffer is only 512 bytes. too small -->
  5447 00002278 F606[E701]08            	testopt [load_ldflags], ldfDataBuffered
  5448 0000227D 743E                    	jz .nodatabuffer	; data buffer not used -->
  5449 0000227F 3916[DA01]              	cmp word [load_data - LOADDATA2 + ldDataSector + 2], dx
  5450 00002283 7512                    	jne .filldatabuffer
  5451 00002285 3906[D801]              	cmp word [load_data - LOADDATA2 + ldDataSector], ax
  5452 00002289 750C                    	jne .filldatabuffer
  5453                                  .havedatabuffer:
  5454 0000228B 8EC3                    	mov es, bx		; es => sector buffer to read into
  5455 0000228D 06                      	push es
  5456 0000228E 1E                      	push ds
  5457 0000228F 56                      	push si
  5458 00002290 51                      	push cx			; must match stack frame for .copydatabuffer
  5459 00002291 8E1E[D601]              	mov ds, word [load_data - LOADDATA2 + ldDataSegment]
  5460                                  				; ds => data buffer
  5461 00002295 EB15                    	jmp .copydatabuffer
  5462                                  
  5463                                  .filldatabuffer:
  5464 00002297 8916[DA01]              	mov word [load_data - LOADDATA2 + ldDataSector + 2], dx
  5465 0000229B A3[D801]                	mov word [load_data - LOADDATA2 + ldDataSector], ax
  5466                                  				; update buffered data sector
  5467 0000229E E8EBF8                  	call read_sector	; actually read data from disk
  5468 000022A1 06                      	push es
  5469 000022A2 1E                      	push ds
  5470 000022A3 56                      	push si
  5471 000022A4 51                      	push cx
  5472 000022A5 06                      	 push es
  5473 000022A6 1F                      	 pop ds			; ds => sector buffer to read from
  5474 000022A7 368E06[D601]            	mov es, word [ss:load_data - LOADDATA2 + ldDataSegment]
  5475                                  				; es => data buffer
  5476                                  .copydatabuffer:
  5477 000022AC 31FF                    	xor di, di		; es:di -> sector buffer to read into
  5478 000022AE 31F6                    	xor si, si		; ds:si -> data buffer
  5479 000022B0 368B0E[0B02]            	mov cx, word [ss:load_data - LOADDATA2 + bsBPB + bpbBytesPerSector]
  5480                                  				; cx = sector size
  5481 000022B5 F3A4                    	rep movsb		; get/set buffered data
  5482 000022B7 59                      	pop cx
  5483 000022B8 5E                      	pop si
  5484 000022B9 1F                      	pop ds
  5485 000022BA 07                      	pop es
  5486 000022BB EB03                    	jmp .databufferdone
  5487                                  
  5488                                  .nodatabuffer:
  5489 000022BD E8CCF8                  	call read_sector
  5490                                  .databufferdone:
  5491 000022C0 1E                      	push ds
  5492                                  
  5493 000022C1 06                      	 push es
  5494                                  				; es:si -> data in sector buffer
  5495 000022C2 C47EF0                  	les di, [bp + ?pointer]
  5496                                  				; es:di -> buffer
  5497 000022C5 014EEA                  	add word [bp + ?read_how_many], cx
  5498 000022C8 294EFC                  	sub word [bp + ?length_this_cluster], cx
  5499 000022CB 294EFE                  	sub word [bp + ?length], cx
  5500 000022CE 010E[CC01]              	add word [load_data - LOADDATA2 + ldCurrentSeek], cx
  5501 000022D2 8316[CE01]00            	adc word [load_data - LOADDATA2 + ldCurrentSeek + 2], 0
  5502 000022D7 014EF4                  	add word [bp + ?how_far_in_cluster], cx
  5503 000022DA 8356F600                	adc word [bp + ?how_far_in_cluster + 2], 0
  5504 000022DE 1F                      	 pop ds			; ds:si -> data in sector buffer
  5505 000022DF F3A4                    	rep movsb		; copy
  5506 000022E1 897EF0                  	mov word [bp + ?pointer], di
  5507                                  				; update pointer
  5508 000022E4 1F                      	pop ds
  5509                                  
  5510 000022E5 837EFC00                	cmp word [bp + ?length_this_cluster], 0
  5511 000022E9 7403E92FFF              	jne .next_sector
  5512                                  
  5513 000022EE 8B7EF8                  	mov di, word [bp + ?bytes_per_cluster]
  5514 000022F1 8B76FA                  	mov si, word [bp + ?bytes_per_cluster + 2]
  5515 000022F4 397EF4                  	cmp word [bp + ?how_far_in_cluster], di
  5516 000022F7 7505                    	jne @F
  5517 000022F9 3976F6                  	cmp word [bp + ?how_far_in_cluster + 2], si
  5518 000022FC 7408                    	je @FF
  5519                                  @@:
  5520 000022FE 837EFE00                	cmp word [bp + ?length], 0
  5521 00002302 7548                    	jne .error
  5522 00002304 EB45                    	jmp .success
  5523                                  
  5524                                  @@:
  5525 00002306 A1[C801]                	mov ax, word [load_data - LOADDATA2 + ldCurrentCluster]
  5526 00002309 8B16[CA01]              	mov dx, word [load_data - LOADDATA2 + ldCurrentCluster + 2]
  5527 0000230D E8BEF4                  	call check_clust
  5528 00002310 723A                    	jc .error
  5529 00002312 E8BBF3                  	call clust_next.dxax
  5530 00002315 731B                    	jnc @F			; (NC) -->
  5531 00002317 B8F6FF                  	mov ax, 0FFF8h - 2
  5532 0000231A BAFF0F                  	mov dx, 0FFFh
  5533 0000231D 8B3E[CC01]              	mov di, word [load_data - LOADDATA2 + ldCurrentSeek]
  5534 00002321 8B36[CE01]              	mov si, word [load_data - LOADDATA2 + ldCurrentSeek + 2]
  5535 00002325 3B36[C601]              	cmp si, word [load_data - LOADDATA2 + ldFileSize + 2]
  5536 00002329 7506                    	jne .set_error
  5537 0000232B 3B3E[C401]              	cmp di, word [load_data - LOADDATA2 + ldFileSize]
  5538 0000232F 7401                    	je .do_not_set_error	; if same then NC -->
  5539                                  .set_error:
  5540 00002331 F9                      	stc
  5541                                  .do_not_set_error:
  5542                                  @@:
  5543 00002332 9C                      	pushf
  5544 00002333 83C002                  	add ax, 2
  5545 00002336 83D200                  	adc dx, 0
  5546 00002339 A3[C801]                	mov word [load_data - LOADDATA2 + ldCurrentCluster], ax
  5547 0000233C 8916[CA01]              	mov word [load_data - LOADDATA2 + ldCurrentCluster + 2], dx
  5548 00002340 9D                      	popf			; CF
  5549 00002341 7209                    	jc .error
  5550 00002343 8B4EFE                  	mov cx, word [bp + ?length]
  5551 00002346 E303                    	jcxz .success
  5552 00002348 E993FE                  	jmp .next_cluster
  5553                                  
  5554                                  .success:
  5555 0000234B A8                      	db __TEST_IMM8		; (skip stc, NC)
  5556                                  .error:
  5557 0000234C F9                      	stc
  5558                                  
  5559 0000234D 5D                      	pop bp
  5560                                  
  5561 0000234E 8F06[0000]              	pop word [throwsp]
  5562 00002352 8F06[0000]              	pop word [throwret]	; restore throw destination
  5563 00002356 8F06[0000]              	pop word [errret]
  5564                                  
  5565 0000235A 9C                      	pushf
  5566 0000235B F646EC01                	testopt [bp + ?did_guard_auxbuff], 1
  5567 0000235F 7405                    	jz @F
  5568 00002361 8026[0300]EF            	clropt [internalflags3], dif3_auxbuff_guarded_1
  5569                                  @@:
  5570 00002366 8026[E701]FB            	clropt [load_ldflags], ldfFATBuffered
  5571 0000236B 9D                      	popf			; CF
  5572                                  
  5573 0000236C 8B5EEE                  	mov bx, word [bp + ?load_input_file_structure]
  5574                                  		; bx -> load_input_file structure
  5575 0000236F E8C1FD                  	call yy_boot_update.bx
  5576                                  
  5577 00002372 59                      	pop cx
  5578 00002373 5F                      	pop di
  5579 00002374 5E                      	pop si
  5580 00002375 5A                      	pop dx
  5581 00002376 58                      	pop ax			; pop from ?read_how_many
  5582 00002377 8E46F2                  	mov es, word [bp + ?pointer + 2]
  5583 0000237A 89EC5D                  	lleave
  5584 0000237D C3                      	retn
  5585                                  
  5586                                  .err_ret:
  5587 0000237E 8B26[0000]              	mov sp, word [throwsp]	; restore stack
  5588                                  				;  (needed here if returned to errret)
  5589 00002382 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 00002384 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 00002387 5589E58D66F0            	lenter
  5612                                  	lvar dword, seek_distance
  5613 0000238D 51                      	 push cx
  5614 0000238E 52                      	 push dx
  5615                                  	lvar word, load_input_file_structure
  5616 0000238F 53                      	 push bx
  5617 00002390 31C0                    	xor ax, ax
  5618                                  	lvar word, did_guard_auxbuff
  5619 00002392 50                      	 push ax
  5620 00002393 56                      	push si
  5621 00002394 57                      	push di
  5622                                  
  5623 00002395 FF36[0000]              	push word [errret]
  5624 00002399 FF36[0000]              	push word [throwret]
  5625 0000239D FF36[0000]              	push word [throwsp]
  5626                                  
  5627 000023A1 55                      	push bp
  5628                                  
  5629 000023A2 C706[0000][E725]        	mov word [errret], .err_ret
  5630 000023A8 C706[0000][E725]        	mov word [throwret], .err_ret
  5631 000023AE 8926[0000]              	mov word [throwsp], sp
  5632                                  
  5633                                  		; bx -> load_input_file structure
  5634 000023B2 E86FFD                  	call yy_boot_get.bx
  5635                                  
  5636 000023B5 E89BFD                  	call guard_auxbuff_return
  5637 000023B8 7303E9FF01              	jc .error
  5638 000023BD FF46E8                  	inc word [bp + ?did_guard_auxbuff]
  5639                                  
  5640 000023C0 B8FFFF                  	mov ax, -1
  5641 000023C3 A3[F601]                	mov word [load_data - LOADDATA2 + lsvFATSector + 2], ax
  5642 000023C6 A3[F401]                	mov word [load_data - LOADDATA2 + lsvFATSector + 0], ax
  5643 000023C9 800E[E701]04            	setopt [load_ldflags], ldfFATBuffered
  5644                                  
  5645 000023CE 85C9                    	test cx, cx
  5646 000023D0 7975                    	jns .plus
  5647                                  
  5648 000023D2 8B36[CE01]              	mov si, word [load_data - LOADDATA2 + ldCurrentSeek + 2]
  5649 000023D6 8B3E[CC01]              	mov di, word [load_data - LOADDATA2 + ldCurrentSeek]
  5650 000023DA A1[0B02]                	mov ax, word [load_data - LOADDATA2 + bsBPB + bpbBytesPerSector]
  5651 000023DD F726[E801]              	mul word [load_data - LOADDATA2 + ldClusterSize]
  5652                                  
  5653 000023E1 8946F4                  	mov word [bp + ?bytes_per_cluster], ax
  5654 000023E4 8956F6                  	mov word [bp + ?bytes_per_cluster + 2], dx
  5655 000023E7 83E801                  	sub ax, 1
  5656 000023EA 83DA00                  	sbb dx, 0
  5657 000023ED F7D0                    	not ax
  5658 000023EF F7D2                    	not dx
  5659                                  
  5660 000023F1 56                      	push si
  5661 000023F2 57                      	push di
  5662                                  
  5663 000023F3 21D6                    	and si, dx
  5664 000023F5 21C7                    	and di, ax		; start seek of current cluster
  5665                                  
  5666 000023F7 58                      	pop ax
  5667 000023F8 5A                      	pop dx			; current seek
  5668                                  
  5669 000023F9 0346EC                  	add ax, word [bp + ?seek_distance]
  5670 000023FC 1356EE                  	adc dx, word [bp + ?seek_distance + 2]
  5671 000023FF 7203E9B801              	jnc .error		; target seek
  5672                                  
  5673                                  		; if the cluster is invalid, need to reset
  5674 00002404 813E[CA01]FF0F          	cmp word [load_data - LOADDATA2 + ldCurrentCluster + 2], 0FFFh
  5675 0000240A 7207                    	jb @F
  5676 0000240C 833E[C801]F8            	cmp word [load_data - LOADDATA2 + ldCurrentCluster], 0FFF8h
  5677 00002411 7308                    	jae .minus_reset
  5678                                  @@:
  5679                                  
  5680 00002413 39F2                    	cmp dx, si		; is target seek
  5681                                  				;  >= start seek of current cluster?
  5682 00002415 7502                    	jne @F
  5683 00002417 39F8                    	cmp ax, di
  5684                                  @@:
  5685 00002419 7322                    	jae .minus_simple	; yes, simple -->
  5686                                  
  5687                                  .minus_reset:
  5688                                  		; reset current cluster to first, seek to 0
  5689 0000241B FF36[F201]              	push word [load_data - LOADDATA2 + lsvFirstCluster + 2]
  5690 0000241F FF36[F001]              	push word [load_data - LOADDATA2 + lsvFirstCluster]
  5691 00002423 8F06[C801]              	pop word [load_data - LOADDATA2 + ldCurrentCluster]
  5692 00002427 8F06[CA01]              	pop word [load_data - LOADDATA2 + ldCurrentCluster + 2]
  5693 0000242B 8326[CC01]00            	and word [load_data - LOADDATA2 + ldCurrentSeek], 0
  5694 00002430 8326[CE01]00            	and word [load_data - LOADDATA2 + ldCurrentSeek + 2], 0
  5695                                  
  5696                                  		; set distance
  5697 00002435 8946EC                  	mov word [bp + ?seek_distance], ax
  5698 00002438 8956EE                  	mov word [bp + ?seek_distance + 2], dx
  5699                                  		; use positive seek code
  5700 0000243B EB0A                    	jmp .plus
  5701                                  
  5702                                  .minus_simple:
  5703                                  		; just set seek, current cluster still valid
  5704 0000243D A3[CC01]                	mov word [load_data - LOADDATA2 + ldCurrentSeek], ax
  5705 00002440 8916[CE01]              	mov word [load_data - LOADDATA2 + ldCurrentSeek + 2], dx
  5706 00002444 E97501                  	jmp .return
  5707                                  
  5708                                  .plus:
  5709 00002447 8B16[C601]              	mov dx, word [load_data - LOADDATA2 + ldFileSize + 2]
  5710 0000244B A1[C401]                	mov ax, word [load_data - LOADDATA2 + ldFileSize]
  5711                                  
  5712 0000244E 2B06[CC01]              	sub ax, word [load_data - LOADDATA2 + ldCurrentSeek]
  5713 00002452 1B16[CE01]              	sbb dx, word [load_data - LOADDATA2 + ldCurrentSeek + 2]
  5714                                  
  5715 00002456 720A                    	jc .eof
  5716                                  		; dx:ax = how far we can seek within file
  5717 00002458 3B56EE                  	cmp dx, word [bp + ?seek_distance + 2]
  5718 0000245B 7503                    	jne @F
  5719 0000245D 3B46EC                  	cmp ax, word [bp + ?seek_distance]
  5720                                  @@:
  5721 00002460 771D                    	ja .not_eof
  5722                                  .eof:
  5723 00002462 8B46EC                  	mov ax, word [bp + ?seek_distance]
  5724 00002465 8B56EE                  	mov dx, word [bp + ?seek_distance + 2]
  5725 00002468 0106[CC01]              	add word [load_data - LOADDATA2 + ldCurrentSeek], ax
  5726 0000246C 1116[CE01]              	adc word [load_data - LOADDATA2 + ldCurrentSeek + 2], dx
  5727 00002470 C706[C801]F8FF          	mov word [load_data - LOADDATA2 + ldCurrentCluster], 0FFF8h
  5728 00002476 C706[CA01]FF0F          	mov word [load_data - LOADDATA2 + ldCurrentCluster + 2], 0FFFh
  5729 0000247C E93D01                  	jmp .return
  5730                                  
  5731                                  .not_eof:
  5732 0000247F 8B4EEC                  	mov cx, word [bp + ?seek_distance]
  5733 00002482 8B5EEE                  	mov bx, word [bp + ?seek_distance + 2]
  5734 00002485 85DB                    	test bx, bx
  5735 00002487 7507                    	jnz @F
  5736 00002489 85C9                    	test cx, cx
  5737 0000248B 7503E92C01              	jz .return
  5738                                  @@:
  5739 00002490 894EFC                  	mov word [bp + ?length], cx
  5740 00002493 895EFE                  	mov word [bp + ?length + 2], bx
  5741                                  
  5742                                  		; bx:cx = length
  5743                                  .next_cluster:
  5744 00002496 8B36[CE01]              	mov si, word [load_data - LOADDATA2 + ldCurrentSeek + 2]
  5745 0000249A 8B3E[CC01]              	mov di, word [load_data - LOADDATA2 + ldCurrentSeek]
  5746 0000249E A1[0B02]                	mov ax, word [load_data - LOADDATA2 + bsBPB + bpbBytesPerSector]
  5747 000024A1 F726[E801]              	mul word [load_data - LOADDATA2 + ldClusterSize]
  5748                                  
  5749 000024A5 8946F4                  	mov word [bp + ?bytes_per_cluster], ax
  5750 000024A8 8956F6                  	mov word [bp + ?bytes_per_cluster + 2], dx
  5751 000024AB 83E801                  	sub ax, 1
  5752 000024AE 83DA00                  	sbb dx, 0
  5753 000024B1 21D6                    	and si, dx
  5754 000024B3 21C7                    	and di, ax		; how far are we into cluster
  5755                                  
  5756 000024B5 897EF0                  	mov word [bp + ?how_far_in_cluster], di
  5757 000024B8 8976F2                  	mov word [bp + ?how_far_in_cluster + 2], si
  5758                                  
  5759 000024BB F7DE                    	neg si
  5760 000024BD F7DF                    	neg di
  5761 000024BF 83DE00                  	sbb si, byte 0		; neg si:di
  5762                                  
  5763 000024C2 037EF4                  	add di, word [bp + ?bytes_per_cluster]
  5764 000024C5 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 000024C8 39DE                    	cmp si, bx
  5768 000024CA 7502                    	jne @F
  5769 000024CC 39CF                    	cmp di, cx
  5770                                  @@:
  5771 000024CE 7304                    	jae .use_count_2
  5772 000024D0 89F9                    	mov cx, di
  5773 000024D2 89F3                    	mov bx, si
  5774                                  .use_count_2:
  5775                                  		; bx:cx = how far to seek in this cluster
  5776 000024D4 894EF8                  	mov word [bp + ?length_this_cluster], cx
  5777 000024D7 895EFA                  	mov word [bp + ?length_this_cluster + 2], bx
  5778                                  
  5779                                  .next_sector:
  5780 000024DA A1[C801]                	mov ax, word [load_data - LOADDATA2 + ldCurrentCluster]
  5781 000024DD 8B16[CA01]              	mov dx, word [load_data - LOADDATA2 + ldCurrentCluster + 2]
  5782 000024E1 E8EAF2                  	call check_clust
  5783 000024E4 7303E9D300              	jc .error
  5784 000024E9 8B1E[0B02]              	mov bx, word [load_data - LOADDATA2 + bsBPB + bpbBytesPerSector]
  5785 000024ED 8B7EF0                  	mov di, word [bp + ?how_far_in_cluster]
  5786 000024F0 8B76F2                  	mov si, word [bp + ?how_far_in_cluster + 2]
  5787                                  
  5788 000024F3 87D6                    	xchg dx, si
  5789 000024F5 97                      	xchg ax, di
  5790 000024F6 F7F3                    	div bx
  5791                                  		; dx = byte offset into sector
  5792                                  		; ax = sector offset into cluster's data
  5793 000024F8 87D6                    	xchg dx, si
  5794 000024FA 97                      	xchg ax, di
  5795                                  		; si = byte offset
  5796                                  
  5797 000024FB 89F1                    	mov cx, si		; = byte offset
  5798 000024FD F7D9                    	neg cx			; - byte offset
  5799 000024FF 01D9                    	add cx, bx		; sector size - byte offset
  5800                                  				;  = length this sector
  5801 00002501 837EFA00                	cmp word [bp + ?length_this_cluster + 2], 0
  5802 00002505 7508                    	jne @F			; fill remaining sector size
  5803 00002507 3B4EF8                  	cmp cx, word [bp + ?length_this_cluster]
  5804 0000250A 7603                    	jbe @F			; sector has less than requested -->
  5805 0000250C 8B4EF8                  	mov cx, word [bp + ?length_this_cluster]
  5806                                  				; fill entire remaining request
  5807                                  @@:
  5808 0000250F 294EF8                  	sub word [bp + ?length_this_cluster], cx
  5809 00002512 835EFA00                	sbb word [bp + ?length_this_cluster + 2], 0
  5810 00002516 294EFC                  	sub word [bp + ?length], cx
  5811 00002519 835EFE00                	sbb word [bp + ?length + 2], 0
  5812 0000251D 010E[CC01]              	add word [load_data - LOADDATA2 + ldCurrentSeek], cx
  5813 00002521 8316[CE01]00            	adc word [load_data - LOADDATA2 + ldCurrentSeek + 2], 0
  5814 00002526 014EF0                  	add word [bp + ?how_far_in_cluster], cx
  5815 00002529 8356F200                	adc word [bp + ?how_far_in_cluster + 2], 0
  5816                                  
  5817 0000252D 837EFA00                	cmp word [bp + ?length_this_cluster + 2], 0
  5818 00002531 75A7                    	jne .next_sector
  5819 00002533 837EF800                	cmp word [bp + ?length_this_cluster], 0
  5820 00002537 75A1                    	jne .next_sector
  5821                                  
  5822 00002539 8B7EF4                  	mov di, word [bp + ?bytes_per_cluster]
  5823 0000253C 8B76F6                  	mov si, word [bp + ?bytes_per_cluster + 2]
  5824 0000253F 397EF0                  	cmp word [bp + ?how_far_in_cluster], di
  5825 00002542 7505                    	jne @F
  5826 00002544 3976F2                  	cmp word [bp + ?how_far_in_cluster + 2], si
  5827 00002547 740E                    	je @FF
  5828                                  @@:
  5829 00002549 837EFE00                	cmp word [bp + ?length + 2], 0
  5830 0000254D 756D                    	jne .error
  5831 0000254F 837EFC00                	cmp word [bp + ?length], 0
  5832 00002553 7567                    	jne .error
  5833 00002555 EB65                    	jmp .return
  5834                                  
  5835                                  @@:
  5836 00002557 A1[C801]                	mov ax, word [load_data - LOADDATA2 + ldCurrentCluster]
  5837 0000255A 8B16[CA01]              	mov dx, word [load_data - LOADDATA2 + ldCurrentCluster + 2]
  5838 0000255E E86DF2                  	call check_clust
  5839 00002561 7259                    	jc .error
  5840 00002563 E86AF1                  	call clust_next.dxax
  5841 00002566 732F                    	jnc @F			; (NC) -->
  5842 00002568 B8F6FF                  	mov ax, 0FFF8h - 2
  5843 0000256B BAFF0F                  	mov dx, 0FFFh
  5844 0000256E 8B3E[CC01]              	mov di, word [load_data - LOADDATA2 + ldCurrentSeek]
  5845 00002572 8B36[CE01]              	mov si, word [load_data - LOADDATA2 + ldCurrentSeek + 2]
  5846 00002576 3B36[C601]              	cmp si, word [load_data - LOADDATA2 + ldFileSize + 2]
  5847 0000257A 7506                    	jne .set_error
  5848 0000257C 3B3E[C401]              	cmp di, word [load_data - LOADDATA2 + ldFileSize]
  5849 00002580 7401                    	je .do_not_set_error	; if same then NC -->
  5850                                  .set_error:
  5851 00002582 F9                      	stc
  5852                                  .do_not_set_error:
  5853 00002583 9C                      	pushf
  5854 00002584 31C9                    	xor cx, cx
  5855 00002586 31DB                    	xor bx, bx
  5856 00002588 874EFC                  	xchg cx, word [bp + ?length]
  5857 0000258B 875EFE                  	xchg bx, word [bp + ?length + 2]
  5858 0000258E 010E[CC01]              	add word [load_data - LOADDATA2 + ldCurrentSeek], cx
  5859 00002592 111E[CE01]              	adc word [load_data - LOADDATA2 + ldCurrentSeek + 2], bx
  5860 00002596 A8                      	db __TEST_IMM8		; (skip pushf)
  5861                                  @@:
  5862 00002597 9C                      	pushf
  5863 00002598 83C002                  	add ax, 2
  5864 0000259B 83D200                  	adc dx, 0
  5865 0000259E A3[C801]                	mov word [load_data - LOADDATA2 + ldCurrentCluster], ax
  5866 000025A1 8916[CA01]              	mov word [load_data - LOADDATA2 + ldCurrentCluster + 2], dx
  5867 000025A5 9D                      	popf			; CF
  5868 000025A6 7214                    	jc .error
  5869 000025A8 8B4EFC                  	mov cx, word [bp + ?length]
  5870 000025AB 8B5EFE                  	mov bx, word [bp + ?length + 2]
  5871 000025AE 85DB                    	test bx, bx
  5872 000025B0 7403E9E1FE              	jnz .next_cluster
  5873 000025B5 85C9                    	test cx, cx
  5874 000025B7 7403E9DAFE              	jnz .next_cluster
  5875                                  .return:
  5876                                  .error:
  5877                                  
  5878 000025BC 5D                      	pop bp
  5879                                  
  5880 000025BD 8F06[0000]              	pop word [throwsp]
  5881 000025C1 8F06[0000]              	pop word [throwret]	; restore throw destination
  5882 000025C5 8F06[0000]              	pop word [errret]
  5883                                  
  5884 000025C9 9C                      	pushf
  5885 000025CA F646E801                	testopt [bp + ?did_guard_auxbuff], 1
  5886 000025CE 7405                    	jz @F
  5887 000025D0 8026[0300]EF            	clropt [internalflags3], dif3_auxbuff_guarded_1
  5888                                  @@:
  5889 000025D5 8026[E701]FB            	clropt [load_ldflags], ldfFATBuffered
  5890 000025DA 9D                      	popf			; CF
  5891                                  
  5892 000025DB 8B5EEA                  	mov bx, word [bp + ?load_input_file_structure]
  5893                                  		; bx -> load_input_file structure
  5894 000025DE E852FB                  	call yy_boot_update.bx
  5895                                  
  5896 000025E1 5F                      	pop di
  5897 000025E2 5E                      	pop si
  5898 000025E3 89EC5D                  	lleave
  5899 000025E6 C3                      	retn
  5900                                  
  5901                                  .err_ret:
  5902 000025E7 8B26[0000]              	mov sp, word [throwsp]	; restore stack
  5903                                  				;  (needed here if returned to errret)
  5904 000025EB 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 000025ED 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 000025F0 56                      	push si
  5923 000025F1 57                      	push di
  5924                                  
  5925                                  		; bx -> load_input_file structure
  5926 000025F2 E82FFB                  	call yy_boot_get.bx
  5927                                  
  5928                                  .reset:
  5929                                  		; reset current cluster to first, seek to 0
  5930 000025F5 FF36[F201]              	push word [load_data - LOADDATA2 + lsvFirstCluster + 2]
  5931 000025F9 FF36[F001]              	push word [load_data - LOADDATA2 + lsvFirstCluster]
  5932 000025FD 8F06[C801]              	pop word [load_data - LOADDATA2 + ldCurrentCluster]
  5933 00002601 8F06[CA01]              	pop word [load_data - LOADDATA2 + ldCurrentCluster + 2]
  5934 00002605 8326[CC01]00            	and word [load_data - LOADDATA2 + ldCurrentSeek], 0
  5935 0000260A 8326[CE01]00            	and word [load_data - LOADDATA2 + ldCurrentSeek + 2], 0
  5936                                  
  5937                                  		; bx -> load_input_file structure
  5938 0000260F E821FB                  	call yy_boot_update.bx
  5939                                  
  5940 00002612 5F                      	pop di
  5941 00002613 5E                      	pop si
  5942 00002614 C3                      	retn
  5943                                  %endif
  5944                                  
  5945                                  
  5946                                  		; INP:	bp = load_data - LOADDATA2
  5947                                  initialise_fs:
  5948                                  ; (boot.asm code starts here)
  5949                                  
  5950 00002615 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 00002617 8A460D                  	mov al, [bp + bsBPB + bpbSectorsPerCluster]
  5955 0000261A FEC8                    	dec al
  5956 0000261C 40                      	inc ax
  5957 0000261D 8946E8                  	mov [bp + ldClusterSize], ax
  5958                                  
  5959 00002620 8B46D4                  	mov ax, [bp + ldEntriesPerSector]
  5960                                  
  5961                                  ; number of sectors used for root directory (store in CX)
  5962 00002623 31D2                    	xor dx, dx
  5963 00002625 89C3                    	mov bx, ax
  5964 00002627 48                      	dec ax				; rounding up
  5965 00002628 034611                  	add ax, [bp + bsBPB + bpbNumRootDirEnts]	; (0 iff FAT32)
  5966 0000262B 11D2                    	adc dx, dx			; account for overflow (dx was zero)
  5967 0000262D F7F3                    	div bx				; get number of root sectors
  5968 0000262F 91                      	xchg ax, cx			; cx = number of root secs
  5969                                  
  5970                                  
  5971                                  ; (iniload.asm code starts here)
  5972                                  
  5973 00002630 51                      	push cx				; number of root secs
  5974 00002631 31C0                    	xor ax, ax
  5975                                  ; first sector of root directory
  5976 00002633 8A4610                  	mov al, [bp + bsBPB + bpbNumFATs]	; ! ah = 0, hence ax = number of FATs
  5977 00002636 8B4E16                  	mov cx, word [bp + bsBPB + bpbSectorsPerFAT]
  5978 00002639 31FF                    	xor di, di			; di:cx = sectors per FAT
  5979                                  					;  iff FAT12, FAT16
  5980 0000263B 85C9                    	test cx, cx			; is FAT32 ?
  5981 0000263D 7506                    	jnz @F				; no -->
  5982 0000263F 8B4E24                  	mov cx, word [bp + bsBPB + ebpbSectorsPerFATLarge]
  5983 00002642 8B7E26                  	mov di, word [bp + bsBPB + ebpbSectorsPerFATLarge + 2]	; for FAT32
  5984                                  @@:
  5985 00002645 50                      	push ax
  5986 00002646 F7E1                    	mul cx
  5987                                  		; ax = low word SpF*nF
  5988                                  		; dx = high word
  5989 00002648 93                      	xchg bx, ax
  5990 00002649 87CA                    	xchg cx, dx
  5991                                  		; cx:bx = first mul
  5992 0000264B 58                      	pop ax
  5993 0000264C F7E7                    	mul di
  5994                                  		; ax = high word adjust
  5995                                  		; dx = third word
  5996 0000264E 85D2                    	test dx, dx
  5997 00002650 740C                    	jz @F
  5998                                  .error_badchain:
  5999                                  error_badchain: equ $
  6000 00002652 BA[0000]                	mov dx, msg.boot_badchain
  6001 00002655 B80D02                  	mov ax, 020Dh
  6002 00002658 E8(0000)                	call setrc
  6003 0000265B E9CFDE                  	jmp bootcmd.fail
  6004                                  
  6005                                  @@:
  6006 0000265E 92                      	xchg dx, ax
  6007                                  		; dx = high word adjust
  6008 0000265F 01CA                    	add dx, cx
  6009                                  		; dx:bx = result
  6010 00002661 93                      	xchg ax, bx
  6011                                  		; dx:ax = result
  6012 00002662 72EE                    	jc .error_badchain
  6013                                  
  6014 00002664 03460E                  	add ax, [bp + bsBPB + bpbReservedSectors]
  6015 00002667 83D200                  	adc dx, byte 0
  6016 0000266A 72E6                    	jc .error_badchain
  6017                                  
  6018 0000266C 59                      	pop cx				; number of root sectors
  6019 0000266D 31FF                    	xor di, di
  6020                                  
  6021                                  ; first sector of disk data area:
  6022 0000266F 01C1                    	add cx, ax
  6023 00002671 11D7                    	adc di, dx
  6024 00002673 72DD                    	jc .error_badchain
  6025 00002675 894EFC                  	mov [bp + lsvDataStart], cx
  6026 00002678 897EFE                  	mov [bp + lsvDataStart + 2], di
  6027                                  
  6028 0000267B 8946D0                  	mov [bp + ldRootSector], ax
  6029 0000267E 8956D2                  	mov [bp + ldRootSector + 2], dx
  6030                                  
  6031                                  ; total sectors
  6032 00002681 31D2                    	xor dx, dx
  6033 00002683 8B4613                  	mov ax, [bp + bsBPB + bpbTotalSectors]
  6034 00002686 85C0                    	test ax, ax
  6035 00002688 7506                    	jnz @F
  6036 0000268A 8B5622                  	mov dx, [bp + bsBPB + bpbTotalSectorsLarge + 2]
  6037 0000268D 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 00002690 895622                  	mov [bp + bsBPB + bpbTotalSectorsLarge + 2], dx
  6043 00002693 894620                  	mov [bp + bsBPB + bpbTotalSectorsLarge], ax
  6044                                  
  6045                                  	; dx:ax = total sectors
  6046                                  
  6047 00002696 8B5E16                  	mov bx, [bp + bsBPB + bpbSectorsPerFAT]
  6048 00002699 C646E620                	mov byte [bp + ldFATType], 32
  6049 0000269D 85DB                    	test bx, bx
  6050 0000269F 740B                    	jz @F
  6051                                  
  6052 000026A1 31C9                    	xor cx, cx
  6053                                  
  6054 000026A3 895E24                  	mov word [bp + bsBPB + ebpbSectorsPerFATLarge], bx
  6055 000026A6 894E26                  	mov word [bp + bsBPB + ebpbSectorsPerFATLarge + 2], cx
  6056 000026A9 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 000026AC 2B46FC                  	sub ax, word [bp + lsvDataStart]
  6063 000026AF 1B56FE                  	sbb dx, word [bp + lsvDataStart + 2]
  6064                                  
  6065                                  	; dx:ax = total amount of data sectors
  6066 000026B2 89C3                    	mov bx, ax
  6067 000026B4 92                      	xchg ax, dx
  6068 000026B5 31D2                    	xor dx, dx
  6069 000026B7 F776E8                  	div word [bp + ldClusterSize]
  6070 000026BA 93                      	xchg bx, ax
  6071 000026BB F776E8                  	div word [bp + ldClusterSize]
  6072                                  	; bx:ax = quotient, dx = remainder
  6073                                  	; bx:ax = number of clusters
  6074 000026BE 85DB                    	test bx, bx
  6075 000026C0 741F                    	jz @FF
  6076                                  		; >= 1_0000h clusters, should be FAT32
  6077 000026C2 81FBFF0F                	cmp bx, 0FFFh
  6078 000026C6 770D                    	ja .badclusters
  6079 000026C8 7505                    	jne @F
  6080 000026CA 83F8F5                  	cmp ax, 0FFF7h - 2
  6081 000026CD 7706                    	ja .badclusters
  6082                                  @@:
  6083                                  		; check it is really FAT32
  6084 000026CF 837E1600                	cmp word [bp + bsBPB + bpbSectorsPerFAT], 0
  6085 000026D3 7447                    	je .gotfattype
  6086                                  
  6087                                  .badclusters:
  6088 000026D5 BA[0000]                	mov dx, msg.boot_badclusters
  6089 000026D8 B80E02                  	mov ax, 020Eh
  6090 000026DB E8(0000)                	call setrc
  6091 000026DE E94CDE                  	jmp bootcmd.fail
  6092                                  
  6093                                  @@:
  6094                                  		; <= FFFFh clusters, may be FAT12 or FAT16 (or small FAT32)
  6095                                  		; check if it is small FAT32
  6096 000026E1 837E1600                	cmp word [bp + bsBPB + bpbSectorsPerFAT], 0
  6097 000026E5 7435                    	je .gotfattype
  6098                                  
  6099 000026E7 83F8F5                  	cmp ax, 0FFF7h - 2		; too much for FAT16 ?
  6100 000026EA 77E9                    	ja .badclusters
  6101 000026EC C646E610                	mov byte [bp + ldFATType], 16
  6102 000026F0 3DF50F                  	cmp ax, 0FF7h - 2		; is it FAT12 ?
  6103 000026F3 7727                    	ja .gotfattype			; no, is FAT16 -->
  6104                                  
  6105 000026F5 C646E60C                	mov byte [bp + ldFATType], 12
  6106                                  
  6107 000026F9 F606[E701]02            	testopt [load_ldflags], ldfFATInvalid
  6108 000026FE 751C                    	jnz .gotfattype
  6109                                  
  6110 00002700 53                      	push bx
  6111 00002701 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 00002702 BF0018                  		mov di, 6 << 10		; maximum size of FAT12 to load
  6129 00002705 8B4E16                  		mov cx, [bp + bsBPB + bpbSectorsPerFAT]
  6130                                  					; maximum size of this FS's FAT
  6131 00002708 31D2                    		xor dx, dx
  6132 0000270A 8B460E                  		mov ax, [bp + bsBPB + bpbReservedSectors]; = first FAT sector
  6133 0000270D 8B5EF8                  		mov bx, [bp + lsvFATSeg]
  6134                                  @@:
  6135 00002710 E879F4                  		call read_sector	; read next FAT sector
  6136 00002713 2B7E0B                  		sub di, [bp + bsBPB + bpbBytesPerSector]
  6137                                  					; di = bytes still left to read
  6138 00002716 7602                    		jbe @F			; if none -->
  6139                                  					; (jbe means jump if CF || ZF)
  6140 00002718 E2F6                    		loop @B			; if any FAT sector still remains -->
  6141                                  @@:					; one of the limits reached; FAT read
  6142 0000271A 58                      	pop ax
  6143 0000271B 5B                      	pop bx
  6144                                  
  6145                                  .gotfattype:
  6146                                  
  6147                                  ; if bx:ax = 1, then entries 0, 1, 2 are valid
  6148 0000271C 83C001                  	add ax, 1
  6149 0000271F 83D300                  	adc bx, 0
  6150                                  ; max entry is x+1 (2 if x=1)
  6151                                  
  6152 00002722 8946C0                  	mov word [bp + ldMaxCluster], ax
  6153 00002725 895EC2                  	mov word [bp + ldMaxCluster + 2], bx
  6154                                  
  6155                                  ; if bx:ax was = 1, then entries below 3 have to exist
  6156 00002728 83C001                  	add ax, 1
  6157 0000272B 83D300                  	adc bx, 0
  6158                                  ; if bx:ax was 1, bx:ax now = 3
  6159                                  
  6160 0000272E 89DA                    	mov dx, bx
  6161                                  
  6162 00002730 807EE610                	cmp byte [bp + ldFATType], 16
  6163 00002734 720C                    	jb .check_fat_limit_12
  6164 00002736 7404                    	je .check_fat_limit_16
  6165                                  .check_fat_limit_32:
  6166 00002738 01C0                    	add ax, ax
  6167 0000273A 11D2                    	adc dx, dx
  6168                                  .check_fat_limit_16:
  6169 0000273C 01C0                    	add ax, ax
  6170 0000273E 11D2                    	adc dx, dx
  6171 00002740 EB0D                    	jmp @F
  6172                                  
  6173                                  .check_fat_limit_12:
  6174 00002742 89C2                    	mov dx, ax
  6175 00002744 01C0                    	add ax, ax
  6176 00002746 01D0                    	add ax, dx		; * 3
  6177 00002748 D1E8                    	shr ax, 1		; * 3 / 2 = * 1.5
  6178 0000274A 83D000                  	adc ax, 0		; if the last nybble is needed
  6179 0000274D 31D2                    	xor dx, dx
  6180                                  
  6181                                  @@:
  6182 0000274F 8B5E0B                  	mov bx, word [bp + bsBPB + bpbBytesPerSector]
  6183 00002752 4B                      	dec bx
  6184 00002753 01D8                    	add ax, bx
  6185 00002755 83D200                  	adc dx, 0
  6186 00002758 43                      	inc bx
  6187                                  
  6188 00002759 91                      	xchg cx, ax
  6189 0000275A 89D0                    	mov ax, dx
  6190 0000275C 31D2                    	xor dx, dx
  6191 0000275E F7F3                    	div bx
  6192 00002760 91                      	xchg cx, ax
  6193 00002761 F7F3                    	div bx
  6194 00002763 87CA                    	xchg cx, dx
  6195                                  		; cx = remainder, dx:ax = number of sectors needed
  6196                                  
  6197 00002765 8B4E16                  	mov cx, word [bp + bsBPB + bpbSectorsPerFAT]
  6198 00002768 31FF                    	xor di, di			; di:cx = sectors per FAT
  6199                                  					;  iff FAT12, FAT16
  6200 0000276A 85C9                    	test cx, cx			; is FAT32 ?
  6201 0000276C 7506                    	jnz @F				; no -->
  6202 0000276E 8B4E24                  	mov cx, word [bp + bsBPB + ebpbSectorsPerFATLarge]
  6203 00002771 8B7E26                  	mov di, word [bp + bsBPB + ebpbSectorsPerFATLarge + 2]	; for FAT32
  6204                                  @@:
  6205                                  
  6206 00002774 39D7                    	cmp di, dx
  6207 00002776 7502                    	jne @F
  6208 00002778 39C1                    	cmp cx, ax
  6209                                  @@:
  6210 0000277A 730C                    	jae @F
  6211                                  .badfat:
  6212 0000277C BA[0000]                	mov dx, msg.boot_badfat
  6213 0000277F B80F02                  	mov ax, 020Fh
  6214 00002782 E8(0000)                	call setrc
  6215 00002785 E9A5DD                  	jmp bootcmd.fail
  6216                                  
  6217                                  @@:
  6218 00002788 C3                      	retn
  6219                                  
  6220                                  
  6221                                  %if _INPUT_FILE_BOOT
  6222                                  yy_boot_clear_remember_seek:
  6223 00002789 50                      	push ax
  6224 0000278A A1[2005]                	mov ax, word [load_input_file.active]
  6225 0000278D 3906[0000]              	cmp word [boot_remember_seek_handle], ax
  6226 00002791 750F                    	jne .ret_pop_ax
  6227                                  .clear:
  6228 00002793 830E[0000]FF            	or word [boot_remember_seek_handle], -1
  6229 00002798 8326[0200]00            	and word [boot_remember_seek_offset + 2], 0
  6230 0000279D 8326[0000]00            	and word [boot_remember_seek_offset], 0
  6231                                  .ret_pop_ax:
  6232 000027A2 58                      	pop ax
  6233 000027A3 C3                      	retn
  6234                                  
  6235                                  
  6236                                  yy_boot_remember_seek:
  6237 000027A4 50                      	push ax
  6238 000027A5 A1[2005]                	mov ax, word [load_input_file.active]
  6239 000027A8 3906[0000]              	cmp word [boot_remember_seek_handle], ax
  6240 000027AC 75F4                    	jne yy_boot_clear_remember_seek.ret_pop_ax
  6241                                  
  6242 000027AE 53                      	push bx
  6243 000027AF 51                      	push cx
  6244 000027B0 52                      	push dx
  6245 000027B1 8B0E[0200]              	mov cx, word [boot_remember_seek_offset + 2]
  6246 000027B5 8B16[0000]              	mov dx, word [boot_remember_seek_offset]
  6247 000027B9 E8C8FB                  	call yy_boot_seek_current
  6248 000027BC 5A                      	pop dx
  6249 000027BD 59                      	pop cx
  6250 000027BE 5B                      	pop bx
  6251 000027BF 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
