     1                                  
     2                                  %if 0
     3                                  
     4                                  lDebug line input and output
     5                                  
     6                                  Copyright (C) 1995-2003 Paul Vojta
     7                                  Copyright (C) 2008-2026 E. C. Masloch
     8                                  
     9                                  Usage of the works is permitted provided that this
    10                                  instrument is retained with the works, so that any entity
    11                                  that uses the works is notified of this instrument.
    12                                  
    13                                  DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    14                                  
    15                                  %endif
    16                                  
    17                                  %define SOURCEFILENAME "lineio.asm"
    18                                  %ifidni __OUTPUT_FORMAT__, obj
    19                                   %include "debug.mac"
     1                              <1> [list -]
    14                              <3> [list -]
    14                              <2> [list -]
    86                              <1> [list -]
    86          ------------------  <1>  note: Disable usesection detection
    86          ------------------  <1>  note: usesection lDEBUG_DATA_ENTRY
    86          ------------------  <1>  note: usesection ASMTABLE1
    86          ------------------  <1>  note: usesection ASMTABLE2
    86          ------------------  <1>  note: usesection DATASTACKBASE
    86          ------------------  <1>  note: usesection MESSAGESEGMENT
    86          ------------------  <1>  note: usesection lDEBUG_CODE
    86          ------------------  <1>  note: usesection lDEBUG_CODE2
    86          ------------------  <1>  note: usesection INIT
    86          ------------------  <1>  note: usesection WLEMITALIGNINITEND
    86          ------------------  <1>  note: usesection DEVICESHIM
    86          ------------------  <1>  note: usesection WLEMITALIGNRELOCZERO
    68                              <2> %endif
    69                              <2> 
    70                              <2> 
    71                              <2> 	usesection lDEBUG_CODE
    71          ------------------  <2>  note: usesection lDEBUG_CODE
    72                              <2> section_of puts, trimputs, puts_ext_done, puts_ext_next
    73                              <2> section_of putsz_exthelp, code_retf
    74                              <2> section_of puts_getline_ext_done
    75                              <2> section_of puts_copyoutput_ext_done
    76                              <2> section_of guard_auxbuff, guard_re
    77                              <2> section_of handle_serial_flags_ctrl_c
    78                              <2> section_of hexword_high
    79                              <2> section_of call_int2D
    80                              <2> section_of copy_single_counted_string
    81                              <2> section_of intchk
    82                              <2> section_of IsIISPEntry?
    83                              <2> section_of dd_store
    84                              <2> section_of dohack, getsegmented, hexbyte, hexnyb, iseol?.notsemicolon
    85                              <2> section_of peekc, getc, prephack, readmem, setds2si, setds2bx, setes2dx
    86                              <2> section_of silence_get_start, silence_get_start.have_di, silence_count_zeroes
    87                              <2> section_of setrmlimit, skipcomm0, unhack
    88                              <2> section_of skipequals
    89                              <2> section_of to_errret_pop
    90                              <2> section_of cmd3.have_cx_convenience
    91                              <2> section_of verifysegm, verifysegm_or_error
    92                              <2> section_of pp16, resetmode, resetmode_and_test_d_b_bit
    93                              <2> section_of pp_fix32bitflags, proceedbreakpoint
    94                              <2> section_of putsz, hexword, skipcomma, cmd3, cmd3_not_ext, cmd3_preprocessed
    95                              <2> section_of hexdword
    96                              <2> section_of cmd3_not_inject, cmd3_injected
    97                              <2> section_of aa_not_inject, aa_injected, aa_before_getline, aa_after_getline
    98                              <2> section_of transfer_ext_cx_nearcall_from_code2
    99                              <2> section_of traceone, unexpectedinterrupt, dumpregs_no_disasm
   100                              <2> section_of aa_imm_entry, ia_restore_a_addr, ia_restore_u_addr, disasm
   101                              <2> section_of ia_restore_ds
   102                              <2> %ifn _SYMBOLIC
   103                              <2> section_of selector_to_segment
   104                              <2> %endif
   105                              <2> section_of disp_al, disp_al_hex, disp_al_nybble_hex, disp_ax_dec, disp_ax_hex
   106                              <2> section_of disp_dxax_times_cx_width_bx_size
   107                              <2> section_of disp_dxax_times_cx_width_bx_size.store
   108                              <2> section_of disp_message, disp_message_length_cx
   109                              <2> section_of ispm
   110                              <2> section_of setrc, error
   111                              <2> section_of _doscall, _doscall_return_es, _doscall_return_es_parameter_es_ds
   112                              <2> section_of intcall_ext_return_es, close_ext, doscall_extseg
   113                              <2> section_of yy_reset_buf
   114                              <2> section_of init_bootcmd
   115                              <2> 
   116                              <2> section_of InDOS, bootgetmemorysize
   117                              <2> section_of chkeol, decword, decdword
   118                              <2> section_of dec_dword_minwidth
   119                              <2> section_of getexpression.lit_isdigit?, getexpression.lit_ishexdigit?
   120                              <2> section_of getlinearaddr
   121                              <2> section_of getlinear_d_b
   122                              <2> section_of getlinear_high_limit
   123                              <2> section_of getlinear_32bit
   124                              <2> section_of getlinear_high_limit.do_not_use_test
   125                              <2> section_of getlinear_common
   126                              <2> section_of ifsep, iseol?, isseparator?, isstring?, movp
   127                              <2> section_of putc, putsline, putsline_crlf, putsz_error
   128                              <2> section_of setrmsegm
   129                              <2> section_of skipwh0, skipwhite
   130                              <2> section_of test_d_b_bit, test_high_limit, push_cxdx_or_edx
   131                              <2> section_of capitalise
   132                              <2> section_of setes2ax
   133                              <2> section_of zz_copy_strings_to_str_buffer
   134                              <2> section_of call_xms_move, zz_call_xms, zz_detect_xms
   135                              <2> section_of code2_to_code_ret_to_ext
   136                              <2> section_of yy_dos_parse_name, yy_open_file, yy_check_lfn
   137                              <2> section_of yy_common_parse_name
   138                              <2> section_of yy_common_parse_name_bx_buffer
   139                              <2> section_of retry_open_scriptspath
   140                              <2> section_of yy_boot_read.bx, yy_boot_seek_start.bx, yy_boot_seek_current.bx
   141                              <2> section_of yy_boot_parse_name, yy_boot_open_file
   142                              <2> section_of yy_boot_parse_name_bx_buffer
   143                              <2> section_of near_transfer_ext_return, scan_dir_aux, read_sector
   144                              <2> section_of yy_boot_init_dir, got_yyentry, scan_dir_entry
   145                              <2> section_of ..@yy_filename_empty, boot_parse_fn
   146                              <2> section_of count_store, count_store.maybe_0
   147                              <2> section_of loader_get_resident_address, loader_prepare_resident
   148                              <2> 
   149                              <2> 
   150                              <2>  %if _SYMBOLIC && _DUALCODE && _SYMBOLASMDUALCODE
   151                              <2> 	usesection lDEBUG_CODE2
   152                              <2>  %else
   153                              <2> 	usesection lDEBUG_CODE
   153          ------------------  <2>  note: usesection lDEBUG_CODE
   154                              <2>  %endif
   155                              <2> section_of bxcx_to_cx_paragraphs
   156                              <2> section_of zz_list_symbol.first, zz_list_symbol.subsequent
   157                              <2> section_of zz_xms_to_86mm, zz_xms_try_free, zz_xms_try_free_handle
   158                              <2> section_of zz_86mm_to_xms, zz_del_match.add_poison_entrypoint
   159                              <2> section_of zz_free_nonxms, zz_free_xms, zz_free_reset, zz_free_dos
   160                              <2> section_of zz_get_literal, zz_restore_strat, zz_save_strat
   161                              <2> section_of zz_switch_s, zz_transfer_buffer
   162                              <2> 
   163                              <2> 
   164                              <2> %if _SYMBOLIC
   165                              <2>  %if _DUALCODE && _SYMBOLICDUALCODE
   166                              <2> 	usesection lDEBUG_CODE2
   167                              <2>  %else
   168                              <2> 	usesection lDEBUG_CODE
   169                              <2>  %endif
   170                              <2> section_of shift_left_4_bxcx
   171                              <2> section_of selector_to_segment
   172                              <2> 
   173                              <2> section_of anti_normalise_pointer_with_displacement_bxcx, displaystring
   174                              <2> section_of getfarpointer.hash, getfarpointer.main, getfarpointer.str
   175                              <2> section_of move_delete_farpointer.hash, move_delete_farpointer.hash.sidi
   176                              <2> section_of move_delete_farpointer.main, move_delete_farpointer.str.sidi
   177                              <2> section_of move_insert_farpointer.hash, move_insert_farpointer.hash.sidi
   178                              <2> section_of move_insert_farpointer.main, move_insert_farpointer.main.sidi
   179                              <2> section_of move_insert_farpointer.str.sidi
   180                              <2> section_of normalise_pointer, normalise_pointer_with_displacement_bxcx
   181                              <2> section_of pointer_to_linear
   182                              <2> section_of save_slice_farpointer.hash, save_slice_farpointer.main
   183                              <2> section_of save_slice_farpointer.str
   184                              <2> section_of segment_to_selector
   185                              <2> section_of zz_insert, zz_match_symbol, zz_match_symbol.continue, zz_relocate
   186                              <2> 
   187                              <2> section_of binsearchhash, binsearchmain
   188                              <2> section_of check_second_slice
   189                              <2> section_of disp_size_hash, disp_size_main, disp_size_str
   190                              <2> section_of displayresult, getstring1, getstring2
   191                              <2> section_of increment_ss_ref_count
   192                              <2> section_of list_sym_storage_usage, str_index_to_pointer
   193                              <2> section_of zz_commit_insert, zz_compact, zz_compact_expand_check_nonxms
   194                              <2> section_of zz_compact_expand_check_xms
   195                              <2> section_of zz_delete_hash, zz_delete_main, zz_delete_main_and_its_hash
   196                              <2> section_of zz_delete_string, zz_expand, zz_expand_common
   197                              <2> section_of zz_get_symstr_length_bytes
   198                              <2> section_of zz_get_symstr_length_bytes.ssLength_in_cx
   199                              <2> section_of zz_get_symstr_length_indices
   200                              <2> section_of zz_get_symstr_length_indices.ssLength_in_cx
   201                              <2> section_of zz_hash, zz_hash.bx_init
   202                              <2> section_of zz_insert_main.linklist, zz_reloc_main, zz_reloc_str
   203                              <2> section_of zz_store_pre_str, zz_store_string, zz_store_string.hash_bx
   204                              <2> section_of zz_unlink_main_next
   205                              <2> %endif
   206                              <2> 
   207                              <2> %if _DUALCODE
   208                              <2> 	usesection lDEBUG_CODE2
   208          ------------------  <2>  note: usesection lDEBUG_CODE2
   209                              <2> %else
   210                              <2> 	usesection lDEBUG_CODE
   211                              <2> %endif
   212                              <2> section_of FloatToStr
   213                              <2> 
   214                              <2> 
   215                              <2>  %if _DUALCODE && _EXPRDUALCODE
   216                              <2> 	usesection lDEBUG_CODE2
   216          ------------------  <2>  note: usesection lDEBUG_CODE2
   217                              <2>  %else
   218                              <2> 	usesection lDEBUG_CODE
   219                              <2>  %endif
   220                              <2> 
   221                              <2> section_of getofsforbx, checkpointer, getrangeX
   222                              <2> section_of getrangeX_have_address_need_length
   223                              <2> section_of getrange, getaddr, getofsforbx_remember_bitness
   224                              <2> section_of remember_bitness, getaddr_taken
   225                              <2> section_of getstr, get_length, get_length_keyword
   226                              <2> section_of isbracketorunaryoperator?, isunaryoperator?, isoperator?
   227                              <2> section_of ..@call_operator_dispatchers
   228                              <2> section_of isseparator?, istype?, isunsignedtype?
   229                              <2> section_of handlesegment, handle3byte, handlebyte, handleword
   230                              <2> section_of handledword, handlepointer
   231                              <2> section_of uoh_abs, uoh_minus, calculate_minus_bxdx, uoh_plus
   232                              <2> section_of uoh_not_bitwise, uoh_not_boolean
   233                              <2> section_of od_minus, od_plus, od_multiply, od_divide, od_modulo, od_retn
   234                              <2> section_of od_above, od_below, od_equal, od_not, od_or, od_and, od_xor
   235                              <2> section_of od_cond, od_o, od_a, od_x, od_c, od_string_common
   236                              <2> section_of of_modulo, of_minus, of_plus, or_hhtype, of_multiply
   237                              <2> section_of set_hhtype, of_divide, of_power
   238                              <2> section_of of_compare_below_equal, of_compare_below, of_compare_not_equal
   239                              <2> section_of of_compare_equal, of_compare_above_equal, of_compare_above
   240                              <2> section_of toboolean, of_helper_compare_true, of_rightop, of_helper_compare
   241                              <2> section_of of_shift_right, of_shift_right_signed, of_shift_left
   242                              <2> section_of of_helper_getshiftdata, of_bit_mirror
   243                              <2> section_of of_or_bitwise, or_hhtype_1, of_or_boolean, of_clr_bitwise
   244                              <2> section_of of_and_bitwise, of_and_boolean, of_xor_bitwise, of_xor_boolean
   245                              <2> section_of of_helper_retbool, of_helper_getbool
   246                              <2> 
   247                              <2> section_of var_cip_setup, var_csp_setup, var_lfsr_setup, var_reverselfsr_setup
   248                              <2> section_of var_dpspsel_setup, var_seldbg_setup, var_mt_setup
   249                              <2> section_of var_ioi_setup, var_psps_setup, var_ppr_setup, var_ppi_setup
   250                              <2> section_of var_iok_setup, var_rhcount_setup
   251                              <2> section_of var_get_psp_segment, var_get_psp_selector
   252                              <2> section_of var_bootldpunit_setup, var_bootsdpunit_setup, var_bootydpunit_setup
   253                              <2> section_of var_bootldppart_setup, var_bootsdppart_setup, var_bootydppart_setup
   254                              <2> section_of var_bootunitflags_setup
   255                              <2> 
   256                              <2> section_of issymbol?, isvariable?, var_mm_setup, var_ri_setup, var_ysf_setup
   257                              <2> section_of default_variable_setup
   258                              <2> section_of var_ext_setup
   259                              <2> section_of var_ext_setup_done
   260                              <2> 
   261                              <2> section_of getstmmxdigit
   262                              <2> section_of getexpression.lit_ishexdigit?, getexpression.lit_isdigit?
   263                              <2> section_of of_cond, count_unary_operators, count_unary_operators_restrict
   264                              <2> section_of get3byte.checksignificantbits, getbyte, checksignificantbitscommon
   265                              <2> section_of getnyb, get_value_range
   266                              <2> 
   267                              <2> section_of getaddrX, getword, getdword, getexpression
   268                              <2> 
   269                              <2> section_of getrangeX.lines, getrangeX.ecx_and_0_valid
   270                              <2> section_of getrange.lines, getrange.ecx_and_0_valid, get_length.lines
   271                              <2> section_of getrangeX.lines_and_uu, getrange.lines_and_uu
   272                              <2> section_of isseparator?.except_L_or_dot, isvariable?.return_name
   273                              <2> section_of getword.checksignificantbits, getbyte.checksignificantbits
   274                              <2> 
   275                              <2> section_of seg_bx_to_sel
   276                              <2> section_of getexpression.countsignificantbits
   277                              <2> section_of ..@rr_checksignificantbits, ..@rr_operatordispatchers
   278                              <2> section_of ..@rr_operatorfunctions, ..@parsecm_getaddr
   279                              <2> section_of stack_check.internal
   280                              <2> 
   281                              <2> 
   282                              <2> 	usesection INIT
   282          ------------------  <2>  note: usesection INIT
   283                              <2> section_of init_capitalise
   284                              <2> section_of init_skipwhite, init_skipwh0
   285                              <2> section_of init_skipcomma, init_skipcomm0
   286                              <2> section_of init_skipequals
   287                              <2> 
   288                              <2> 
   289                              <2> 	usesection lDEBUG_DATA_ENTRY
   289          ------------------  <2>  note: usesection lDEBUG_DATA_ENTRY
   290                              <2> section_of entry_retn
   291                              <2> 
   292                              <2> 
   293                              <2> %if _LINK
   294                              <2>  %include "extern.mac"
     1                              <3> 
     2                              <3> ; expr.asm
     3                              <3>  extern PPLEN, PPLEN_ONLY_PREFIXES, a_addr, alloc_seg, alloc_size
     4                              <3>  extern amis_multiplex_number, asm_options, asm_startoptions
     5                              <3>  extern auxbuff_current_size, auxbuff_segorsel, behind_r_u_addr
     6                              <3>  extern bp_offset, code_seg, code_size, d_addr, dcount_addr
     7                              <3>  extern dcpm_addr, dd_default_length, dd_default_lines, dd_text_and
     8                              <3>  extern debuggerfunction, default_pp_count, default_tp_count
     9                              <3>  extern default_tt_count, device_header_address, device_mcb_paragraphs
    10                              <3>  extern dwcount_addr, dz_addr, e_addr, encodedmach87, entryseg_size
    11                              <3>  extern env_size, envseg, erc, errret
    12                              <3>  extern extdata, extdata_size, extdata_used, extseg, extseg_size
    13                              <3>  extern extseg_used, flagbits.amount, flagnames, flagvaron
    14                              <3>  extern getrange_is_uu, getrange_lines, has_mmx, hhresult
    15                              <3>  extern history.segorsel, historyseg_size, immseg, input_file_handles
    16                              <3>  extern input_file_handles.active, internalflags, internalflags2
    17                              <3>  extern internalflags3, intr8_limit, io_columns, io_columns_getline
    18                              <3>  extern io_end_buffer, io_flags, io_levels, io_rows, io_start_buffer
    19                              <3>  extern line_out, line_out_end, linkinfoaddress, load_data
    20                              <3>  extern load_input_file, load_input_file.active, load_unit_flags
    21                              <3>  extern loaddata_loadedfrom, machine, maxmachinetype, messageseg
    22                              <3>  extern messageseg_size, mmxbuff, msg.as, msg.end, msg.executing
    23                              <3>  extern msg.executing_value_range, msg.from, msg.in, msg.length
    24                              <3>  extern msg.linear, msg.lines, msg.lr, msg.nd, msg.nottaken
    25                              <3>  extern msg.nt, msg.or, msg.questionmark, msg.r, msg.stack_overflow
    26                              <3>  extern msg.stack_overflow.caller, msg.stack_overflow.cond
    27                              <3>  extern msg.stack_overflow.indirection, msg.stack_overflow.linear
    28                              <3>  extern msg.stack_overflow.parens, msg.stack_overflow.precedence
    29                              <3>  extern msg.stack_overflow.value_in, msg.t, msg.taken, msg.to
    30                              <3>  extern msg.value, msgtable_value_range, options, options2, parent
    31                              <3>  extern ppbytes, priorrc, psp22, pspdbe, pspdbg
    32                              <3>  extern qqtermcode, rc_count, rc_limit, re_count, re_limit
    33                              <3>  extern reading_access_variables, reg16names, reg8names, reg_cs
    34                              <3>  extern reg_ds, reg_efl, reg_eip, reg_esp, search_results
    35                              <3>  extern serial_columns, serial_fifo_size, serial_keep_timeout
    36                              <3>  extern serial_rows, serial_use_baseport, serial_use_dl
    37                              <3>  extern serial_use_fifo, serial_use_intnum, serial_use_irqmask
    38                              <3>  extern serial_use_params, serial_var_baseport, serial_var_dl
    39                              <3>  extern serial_var_fifo, serial_var_intnum, serial_var_irqmask
    40                              <3>  extern serial_var_params, sscounter, stack, startoptions
    41                              <3>  extern table_length_keywords, throwsp, transfer_ext_cx
    42                              <3>  extern try_amis_multiplex_number, try_debugger_amis_multiplex_number
    43                              <3>  extern types, types.addresses_minus_end, types.end, u_addr
    44                              <3>  extern usertermcode, uu_default_length, uu_default_lines, vregs
    45                              <3>  extern vregs.amount, writing_access_variables
    46                              <3>  extern flagbits, regs
    47                              <3> 
    48                              <3> ; run.asm
    49                              <3>  extern ..@aa_access_end, ..@aa_access_start, ..@dd_access_end
    50                              <3>  extern ..@dd_access_start, ..@ee_access_end, ..@ee_access_start
    51                              <3>  extern ..@ee_interactive_access_end, ..@ee_interactive_access_start
    52                              <3>  extern ..@hh_indirection_memory_access_end
    53                              <3>  extern ..@hh_indirection_memory_access_start
    54                              <3>  extern ..@readmem_fault_skip_4_near_call, ..@rr_access_end
    55                              <3>  extern ..@rr_access_start, ..@rr_variable_read_access_end
    56                              <3>  extern ..@rr_variable_read_access_start
    57                              <3>  extern ..@rr_variable_write_access_end
    58                              <3>  extern ..@rr_variable_write_access_start, ..@sss_access_end
    59                              <3>  extern ..@sss_access_start, ..@uu_access_end, ..@uu_access_start
    60                              <3>  extern ..@uu_referenced_memory_access_end
    61                              <3>  extern ..@uu_referenced_memory_access_start, ..@uu_simulate_cmps_end
    62                              <3>  extern ..@uu_simulate_cmps_start, ..@uu_simulate_scas_end
    63                              <3>  extern ..@uu_simulate_scas_start, InDOS_or_BIOS_IO, PPLEN_ONLY_STRING
    64                              <3>  extern auxbuff_behind_last_silent
    65                              <3>  extern auxbuff_start_silent, bInDbg, b_bplist.bp, b_bplist.counter
    66                              <3>  extern b_bplist.disabled_mask, b_bplist.idbuffer, b_bplist.used_mask
    67                              <3>  extern b_bplist.when, bb_deferred_message_in_lineout_behind
    68                              <3>  extern bp_display_offset, calcpointbit, cmd2_reset_re, cmd_goto
    69                              <3>  extern debug22.cleartraceflag, decbyte, dmycmd, dumpregs_extended
    70                              <3>  extern enable_rh, entry_to_code_seg, entry_to_code_segsel, eqflag
    71                              <3>  extern eqladdr, exccsip, exception_csip, exception_stack, excloc
    72                              <3>  extern g_bplist.bp, g_bplist.used_count, get_set_id_offset_length
    73                              <3>  extern getc_if_any, getcseipbyte, getint2324, getpsp
    74                              <3>  extern gg_deferred_message, gg_first_cseip_linear
    75                              <3>  extern gg_next_cseip_linear, guard_auxbuff.1_or_2, idle, in_getinput
    76                              <3>  extern int19msg, internalflags6, intr8_counter, lastcmd, msg.again
    77                              <3>  extern msg.alreadytsr, msg.area_aa_access, msg.area_dd_access
    78                              <3>  extern msg.area_ee_access, msg.area_ee_interactive_access
    79                              <3>  extern msg.area_hh_indirection_memory_access, msg.area_rr_access
    80                              <3>  extern msg.area_rr_variable_read_access
    81                              <3>  extern msg.area_rr_variable_write_access, msg.area_run_access
    82                              <3>  extern msg.area_sss_access, msg.area_uu_access
    83                              <3>  extern msg.area_uu_referenced_memory_access
    84                              <3>  extern msg.area_uu_simulate_cmps, msg.area_uu_simulate_scas
    85                              <3>  extern msg.bb_hit.1, msg.bb_hit.2.counter, msg.bb_hitpass_id.after
    86                              <3>  extern msg.bb_hitpass_id.long, msg.bb_hitpass_id.short, msg.bb_pass.1
    87                              <3>  extern msg.cant_bp_linear, msg.cant_bp_linear.address1
    88                              <3>  extern msg.cant_bp_reason, msg.cant_bp_reason0, msg.cant_bp_reason1
    89                              <3>  extern msg.cant_bp_reason2, msg.cant_bp_reason3
    90                              <3>  extern msg.cant_bp_reason3.value, msg.cant_bp_reasonu
    91                              <3>  extern msg.cant_bp_restore, msg.cant_bp_restore.value
    92                              <3>  extern msg.cant_bp_the, msg.cant_bp_type_gg
    93                              <3>  extern msg.cant_bp_type_permanent, msg.cant_bp_type_permanent.index
    94                              <3>  extern msg.cant_bp_type_proceed, msg.cant_bp_write, msg.ctrlc
    95                              <3>  extern msg.empty_message, msg.goto, msg.invalidpsp, msg.list
    96                              <3>  extern msg.list_bp.address1, msg.list_bp.first, msg.list_bp.second
    97                              <3>  extern msg.list_bp.third, msg.list_bp.value, msg.list_bp_csip_16
    98                              <3>  extern msg.list_bp_none, msg.list_bp_not_cseip, msg.notyettsr
    99                              <3>  extern msg.nowattached, msg.nowtsr1, msg.nowtsr2, msg.psphooked
   100                              <3>  extern msg.pspnotfound, msg.remember, msg.selfownedpsp, msg.silent
   101                              <3>  extern msg.warnprefix, msg.while, msg.while_not_true
   102                              <3>  extern msg.while_terminated_after, msg.while_terminated_before
   103                              <3>  extern oldcols, oldcrtp, oldcsrpos, oldmr, options3
   104                              <3>  extern options6, pp_instruction, pp_operand, progexit, progtrm
   105                              <3>  extern rc, reg_eax, reg_es, reg_gs, reg_ss
   106                              <3>  extern run_int, run_sp, run_sp_reserve, savesp, setcseipbyte
   107                              <3>  extern setint2324, setpsp, setpspdbg
   108                              <3>  extern showstring, silence_dump, spadjust, swapscreen
   109                              <3>  extern tmode0, tmode1, tmodes, tmodev, tpg_possible_breakpoint
   110                              <3>  extern tpg_proceed_bp, tt_silent_mode_number, vpage, vrows
   111                              <3>  extern while_buffer, while_buffer.length, writemem
   112                              <3> 
   113                              <3>  extern ..@getcseipbyte_fault_skip_2_near_call
   114                              <3>  extern ..@setcseipbyte_fault_skip_2_near_call
   115                              <3>  extern ..@writemem_fault_skip_4_near_call_a
   116                              <3>  extern ..@writemem_fault_skip_4_near_call_b, int0Cmsg, int0Dmsg
   117                              <3>  extern int0msg, int18msg, int1msg, int3msg, int6msg
   118                              <3>  extern int8_kbd_msg, int8msg, runint_ctrlc_msg, serial_flags
   119                              <3> 
   120                              <3> ; bb.asm
   121                              <3>  extern ..@bb_id_length, ..@bb_id_start, ..@bb_saved_linear
   122                              <3>  extern ..@bb_when_length, ..@bb_when_start, b_bplist.id
   123                              <3>  extern b_bplist.idbuffer.free
   124                              <3>  extern b_bplist.whenbuffer, b_bplist.whenbuffer.free
   125                              <3>  extern bootcmd, crlf, msg.all, msg.at
   126                              <3>  extern msg.bb_no_new, msg.bb_when, msg.boot, msg.bp, msg.bpaddress
   127                              <3>  extern msg.bpcontent, msg.bpcounter, msg.bpdisabled, msg.bpenabled
   128                              <3>  extern msg.bpnone, msg.bpnone_at, msg.bpunused, msg.counter
   129                              <3>  extern msg.existing, msg.id, msg.new, msg.notbu, msg.number
   130                              <3>  extern msg.offset, msg.when, prnquit
   131                              <3> 
   132                              <3> ; rr.asm
   133                              <3>  extern InDOS_or_BIOS_output, cmdline_buffer
   134                              <3>  extern cmdline_buffer.end, cmdline_buffer.position, disflags, ee0a
   135                              <3>  extern error_expr, flagbits_for_40, flagbits_for_80, flagsoff
   136                              <3>  extern flagsoff_style2, flagsoff_style3, flagson, flagson_style23
   137                              <3>  extern get_memref_index_bx, getline00, getline_reset_notatty
   138                              <3>  extern guard_rc, hexnyb.common, hhtype, hhvar, in_re
   139                              <3>  extern mask_4byte, masks, memrefs, memrefs.free, msg.3byte
   140                              <3>  extern msg.abort, msg.append, msg.byte, msg.count, msg.dword
   141                              <3>  extern msg.highlight, msg.internal_error_no_mmx, msg.readonly
   142                              <3>  extern msg.readonly_mem, msg.regs386, msg.regs386_off, msg.regs386_on
   143                              <3>  extern msg.replace, msg.rh, msg.rv_mode.before, msg.rv_mode_r86m
   144                              <3>  extern msg.rv_mode_v86m, msg.rvd, msg.rvd_deviceheader
   145                              <3>  extern msg.rvd_not_device, msg.rvd_size, msg.rvm, msg.rvp
   146                              <3>  extern msg.rvp_application, msg.rvp_boot, msg.rvp_device
   147                              <3>  extern msg.rvp_device_attached, msg.rvp_tsr, msg.rvv
   148                              <3>  extern msg.unexpected_auxbuff_guard, msg.unhighlight, msg.vm_auxseg
   149                              <3>  extern msg.vm_codeseg, msg.vm_dataseg, msg.vm_entryseg, msg.vm_hisseg
   150                              <3>  extern msg.vm_messageseg, msg.vp_dparent, msg.vp_dpra
   151                              <3>  extern msg.vp_dpspsegment, msg.vp_parent, msg.vp_pra
   152                              <3>  extern msg.vp_pspsegment, msg.word, operatorfunctions, psp_parent
   153                              <3>  extern psp_pra, puts_break_line_more, putsline_break_line, re_buffer
   154                              <3>  extern re_buffer.end, re_buffer.position, re_sp, regs_prior
   155                              <3>  extern regs_prior.size, retn_expr, rh_count_number
   156                              <3>  extern rh_display_with_count, shortflagbits, shortflagbits.amount
   157                              <3>  extern shortflagsoff, shortflagson, silence_dump.rh
   158                              <3>  extern silence_dump.rh.all, table_getline_prepare_ldebug
   159                              <3>  extern table_getline_prepare_ms_debug, terminate_silent_dump
   160                              <3>  extern terminate_silent_dump.if_nonnull
   161                              <3> 
   162                              <3> ; rr.asm
   163                              <3>  extern flagbits_for_shl, regs_prior.size_w
   164                              <3> 
   165                              <3> ; aa.asm
   166                              <3>  extern REP_LEN, SEGP_LEN, attach
   167                              <3>  extern ext_aa_after_getline_handler, ext_aa_before_getline_handler
   168                              <3>  extern ext_aa_inject_handler, immasm_length, immasm_rel1632_target
   169                              <3>  extern immasm_rel8_target, msg.aa_internal_error, msg.attach
   170                              <3>  extern prefixlist.after_segment, replist, segprfxtab, showmach
   171                              <3>  extern skipalpha, sm1
   172                              <3> 
   173                              <3> ; uu.asm
   174                              <3>  extern A32P_LEN, GROUP7, MN_DB, MN_LOCK, MN_LOOP
   175                              <3>  extern MN_LOOPNZ, MN_LOOPZ, MN_REP, MN_REPE, MN_REPNE
   176                              <3>  extern MN_SEG, MN_WAIT, N_LOCK, N_LTABA, N_LTABO
   177                              <3>  extern N_WTAB, O32P_AMOUNT, OPTYPES_BASE, REP_DIFF_LEN, REP_SAME_LEN
   178                              <3>  extern SFPGROUP3, SGROUP4, SPARSE_BASE, a32prfxtab, dismach
   179                              <3>  extern dmflags, has_87, immasm_far_target, immasm_imm16, locktab
   180                              <3>  extern ltaba1, ltabo1, mach_87, mnlist, mnlist_a_suffix_allowed
   181                              <3>  extern mnlist_o_suffix_allowed, mnlist_o_suffix_required
   182                              <3>  extern msg.condjump, msg.condnotjump, msg.memrefs_invalid_internal
   183                              <3>  extern msg.uninstall, msg.uu_internal_error, msg.uu_too_many_repeat
   184                              <3>  extern needsmath, needsmath_L, needsmsg, needsmsg.digit_6_ofs
   185                              <3>  extern needsmsg.digit_x_ofs, needsmsg_L, o32prfxtab, obsmach
   186                              <3>  extern obsolete, obsolete_L, opindex, opinfo, oplists
   187                              <3>  extern optypes, ppbytes.string, ppbytes.string_amount, reg_ebp
   188                              <3>  extern reg_ebx, reg_ecx, reg_edi, reg_esi, reg_fs
   189                              <3>  extern regmem, rgnam16, rgnam816, segrgnam, sibbyte
   190                              <3>  extern sqztab, tab_to, uninstall, unused, wtab1
   191                              <3> 
   192                              <3> ; uu.asm
   193                              <3>  extern reg_edx
   194                              <3> 
   195                              <3> ; uu.asm
   196                              <3>  extern MN_BSWAP, MN_O32
   197                              <3> 
   198                              <3> ; uu.asm
   199                              <3>  extern MN_A32
   200                              <3> 
   201                              <3> ; amis.asm
   202                              <3>  extern amisintr_offset, deviceshim_size, ext_amis_handler
   203                              <3> 
   204                              <3> ; boot.asm
   205                              <3>  extern boot_remember_seek_handle
   206                              <3>  extern boot_remember_seek_offset, chkeol_or_then, cmd_goto.yy_entry
   207                              <3>  extern display_y_or_ext, ext_cmdline, ext_finish.boot
   208                              <3>  extern if_exists_found_open, if_exists_not_found
   209                              <3>  extern if_exists_then_address, iseol?_or_then, loadoptiontable
   210                              <3>  extern loadoptiontable.incompatible, loadsettings
   211                              <3>  extern msdos7_message_table, msdos7_message_table.size
   212                              <3>  extern msg.boot_access_error, msg.boot_and, msg.boot_auxbuff_crossing
   213                              <3>  extern msg.boot_badchain, msg.boot_badclusters, msg.boot_badfat
   214                              <3>  extern msg.boot_bpb_load_overlap, msg.boot_bpb_too_low
   215                              <3>  extern msg.boot_cannot_set_both, msg.boot_dot_crlf
   216                              <3>  extern msg.boot_file_not_found, msg.boot_file_too_big_error
   217                              <3>  extern msg.boot_file_too_small_error, msg.boot_internal_error
   218                              <3>  extern msg.boot_invalid_filename, msg.boot_invalid_heads
   219                              <3>  extern msg.boot_invalid_sectors, msg.boot_out_of_memory_error
   220                              <3>  extern msg.boot_partition_cycle_error, msg.boot_partition_not_found
   221                              <3>  extern msg.boot_quit_fail, msg.boot_sector_not_power
   222                              <3>  extern msg.boot_sector_too_large, msg.boot_sector_too_small
   223                              <3>  extern msg.boot_segment_too_low, msg.boot_too_many_partitions_error
   224                              <3>  extern msg.bootfail, msg.bootfail_check_mismatch
   225                              <3>  extern msg.bootfail_check_mismatch.check_got
   226                              <3>  extern msg.bootfail_check_mismatch.check_offset
   227                              <3>  extern msg.bootfail_check_mismatch.check_value, msg.bootfail_code
   228                              <3>  extern msg.bootfail_read, msg.bootfail_read_errorcode
   229                              <3>  extern msg.bootfail_secsizediffer, msg.bootfail_sig
   230                              <3>  extern msg.bootfail_sig_parttable, msg.bootfail_stack_underflow
   231                              <3>  extern msg.bpb, msg.checkoffset, msg.checkvalue, msg.dir
   232                              <3>  extern msg.dirinsteadsize, msg.emptydirname, msg.entry
   233                              <3>  extern msg.guard_auxbuff_error, msg.hidden, msg.hiddenadd
   234                              <3>  extern msg.maxpara, msg.minpara, msg.protocol, msg.quit, msg.read
   235                              <3>  extern msg.sector, msg.sector_alt, msg.segment, msg.write
   236                              <3>  extern msg.yy_empty, msg.yy_filename_empty, msg.yy_no_file
   237                              <3>  extern msg.yy_requires_filename, msg.yy_too_large
   238                              <3>  extern msg.yy_too_many_handles, terminator_in_line_in.offset
   239                              <3>  extern terminator_in_line_in.value, throwret
   240                              <3>  extern yy_boot_attempt_open_pathname, yy_boot_attempt_open_stack
   241                              <3>  extern yy_is_script
   242                              <3> 
   243                              <3> ; cc.asm
   244                              <3>  extern count_var, hh.single, msg.clear, msg.clear_sequence
   245                              <3>  extern msg.range, parsecm
   246                              <3> 
   247                              <3> ; dd.asm
   248                              <3>  extern auxbuff_current_size_minus_24, charcounter
   249                              <3>  extern dstringaddr, dstringtype, firstmcb, firstumcb, intaddress
   250                              <3>  extern lastint, lastint_is_86m_and_mcb, msg.di_empty, msg.di_error
   251                              <3>  extern msg.di_freedos_reloc, msg.di_hidden, msg.di_hma, msg.di_iisp
   252                              <3>  extern msg.di_jmpfar, msg.di_jmpfarindirect, msg.di_multiplex.1
   253                              <3>  extern msg.di_multiplex.2, msg.di_multiplex.3, msg.di_nonstd_iisp
   254                              <3>  extern msg.di_system_low, msg.di_system_mcb, msg.di_system_upper
   255                              <3>  extern msg.di_testhook, msg.di_toomany, msg.di_uninst_iisp
   256                              <3>  extern msg.header, msg.header.length, msg.invmcbadr, msg.prefixes
   257                              <3>  extern msg.tableheader, msg.tableheadertop, msg.top, msg.trailer
   258                              <3>  extern msg.trailer.length, smcbmsg_unknown, smcbtypes
   259                              <3> 
   260                              <3> ; debug.asm
   261                              <3>  extern UnhookInterruptForce, UnhookInterruptForceSim, aa
   262                              <3>  extern adusetup, bb, boot_ebdaflag, boot_initcode
   263                              <3>  extern boot_new_memsizekib, boot_old_memsizekib, cc, code_start, ddd
   264                              <3>  extern device_initcode, driveno, dumpregs_extended.exit, ee
   265                              <3>  extern eld_linkcall.call_cmd3, end_of_ldebug_code, entry_int3_retf
   266                              <3>  extern errcarat, ff, get_86m_interrupt_handler_no_dos, get_columns
   267                              <3>  extern getline_close_file, getline_close_file.resetstuff, gg, hh
   268                              <3>  extern hh_depth, hh_depth_of_single_term, hhflag, ia_restore, ii
   269                              <3>  extern immasm, install_86m_interrupt_handler, int22, int2D, intr0
   270                              <3>  extern intr0C, intr0D, intr1, intr18, intr19
   271                              <3>  extern intr3, intr6, intr8, linkinfo, ll
   272                              <3>  extern ll3, ll_copy_cmdline_and_fcbs
   273                              <3>  extern ll_copy_cmdline_and_fcbs.have_cx
   274                              <3>  extern mm, msg.NULblank, msg.asmoptions_1, msg.boothelp
   275                              <3>  extern msg.build_array, msg.build_long_amount, msg.build_short_amount
   276                              <3>  extern msg.build_version_amount, msg.cannot_hook_2D.invalid
   277                              <3>  extern msg.cannot_hook_2D.nofree, msg.cannotbootquit_memsizes
   278                              <3>  extern msg.condhelp, msg.ensure_no_memory, msg.expressionhelp
   279                              <3>  extern msg.flaghelp, msg.flags_1, msg.guard_rc_error
   280                              <3>  extern msg.guard_re_error, msg.help_array, msg.help_array_amount
   281                              <3>  extern msg.help_re, msg.help_run, msg.help_source, msg.keep
   282                              <3>  extern msg.license, msg.line_out_overflow, msg.n_toolongname
   283                              <3>  extern msg.n_toolongtail, msg.nobootsupp, msg.options_array
   284                              <3>  extern msg.options_array_amount, msg.options_pages, msg.options_scan
   285                              <3>  extern msg.options_scan_amount, msg.qq_a_terminated
   286                              <3>  extern msg.qq_a_unterminated, msg.qq_device_no_c, msg.qq_device_no_d
   287                              <3>  extern msg.qq_device_none_selected, msg.qq_unterm
   288                              <3>  extern msg.rc_limit_reached, msg.re, msg.re_limit_reached
   289                              <3>  extern msg.reghelp, msg.rh_disabled, msg.rh_enabled, msg.run
   290                              <3>  extern msg.serial_cannot_hook, msg.serial_cannot_hook.new_int
   291                              <3>  extern msg.serial_cannot_hook.old_int, msg.serial_cannot_unhook
   292                              <3>  extern msg.serial_cannot_unhook.int, msg.serial_cannot_unhook.nowarn
   293                              <3>  extern msg.serial_late_unhook, msg.serial_late_unhook.int
   294                              <3>  extern msg.serial_no_keep_enter, msg.serial_no_keep_timer
   295                              <3>  extern msg.serial_request_keep, msg.source, msg.string_build
   296                              <3>  extern msg.string_options, msg.string_version
   297                              <3>  extern msg.tsr_cannot_terminate_attached, msg.varhelp, oo, ph_msg, pp
   298                              <3>  extern putrunint, putsz_exthelp, rr, run, section.DEVICESHIM.vstart
   299                              <3>  extern serial_clean_up, serial_clear_fifos, serial_eoi
   300                              <3>  extern serial_init_UART, serial_install_interrupt_handler
   301                              <3>  extern serial_interrupt_handler, serial_uninstall_interrupt_handler
   302                              <3>  extern set_irq, setscreen, sleep_delta_limit, sleep_highest_delta
   303                              <3>  extern sss, tpg_initialise_empty_auxbuff.reset
   304                              <3>  extern transfer_to_ext_puts_getline, tt, update_inttab_optional, uu
   305                              <3>  extern vv, vv_disable, vv_set, ww, yy
   306                              <3> 
   307                              <3> ; debug.asm
   308                              <3>  extern eld_linkcall
   309                              <3> 
   310                              <3> ; ee.asm
   311                              <3>  extern bufend, bufnext, fillbuf, fullbsout
   312                              <3>  extern getline_is_input_file?, line_in, linecounter, load_extension
   313                              <3>  extern msg.ext, notatty, prehak1, run2324
   314                              <3> 
   315                              <3> ; hh.asm
   316                              <3>  extern hh_div_active, hh_div_dividend, hh_div_divisor
   317                              <3>  extern msg.base, msg.group, msg.hh_div_remainder, msg.width
   318                              <3> 
   319                              <3> ; iioo.asm
   320                              <3>  extern if_exists_length, if_exists_si, if_exists_sp
   321                              <3>  extern install, msg.exists, msg.install, msg.not, msg.then
   322                              <3>  extern msg.y, resetrc, yy_or_ext_no_guard_re
   323                              <3> 
   324                              <3> ; immasm.asm
   325                              <3>  extern aa_ret, addrr, condmsg, error_mirror, index
   326                              <3>  extern msg.immasm_error_eip, presizeflags, reg32addr, segmnt
   327                              <3>  extern segrgaddr
   328                              <3> 
   329                              <3> ; msg.asm
   330                              <3>  extern ..@boot_scan_dir_return_fat16_root_entry
   331                              <3>  extern ..@boot_scan_dir_return_filenotfound
   332                              <3>  extern ..@boot_scan_dir_return_subdir_or_fat32_entry
   333                              <3>  extern alloc_size_not_reserved, asciitablenames, boot_init_foundname
   334                              <3>  extern configpath, configpath.dir_end, device_quittable_regs, dpmi32
   335                              <3>  extern execblk.cmdline, ext_command_handler, ext_finish.bp_is_set
   336                              <3>  extern ext_handle, ext_inject_handler, ext_preprocess_handler
   337                              <3>  extern ext_puts_copyoutput_handler, ext_puts_getline_handler
   338                              <3>  extern ext_puts_handler, ext_var, ext_var_amount, ext_var_format
   339                              <3>  extern ext_var_size, extcssel, extdssel, handle_scan_dir_entry
   340                              <3>  extern handle_scan_dir_not_found, history.first, history.last
   341                              <3>  extern indirect_array_errfix, init_executable_pathname
   342                              <3>  extern init_executable_pathname.end, internalflags4, internalflags5
   343                              <3>  extern internalflags7, isvariable_morebyte_nameheaders.ext
   344                              <3>  extern lastcmd_transfer_ext_address, lastcmd_transfer_ext_entry
   345                              <3>  extern line_in.end, linkcall_table, load_adr_dirbuf_segment
   346                              <3>  extern load_check_dir_attr, load_data_lowest, load_kernel_name
   347                              <3>  extern load_yy_direntry, load_yyname_input, load_yyname_next
   348                              <3>  extern near_transfer_ext_address, near_transfer_ext_entry
   349                              <3>  extern next_reserved_segment, options4, options5, options7
   350                              <3>  extern patcharea_intrtn, patcharea_intrtn.segment
   351                              <3>  extern patcharea_intrtn.size, patcharea_run, patcharea_run.segment
   352                              <3>  extern patcharea_run.size, pm_2_86m_0, promptlen, reserved_address
   353                              <3>  extern scriptspath, scriptspath.dir_end
   354                              <3>  extern sss_silent_count, sss_silent_count_used, stack_end, swch1
   355                              <3>  extern while_buffer.end
   356                              <3> 
   357                              <3> ; msg.asm
   358                              <3>  extern install_trying
   359                              <3> 
   360                              <3> ; init.asm
   361                              <3>  extern ..@init_behind, ..@init_first
   362                              <3>  extern ..@patch_no386_ds_6_DATA_ENTRY
   363                              <3>  extern ..@patch_no386_ds_code_or_entry
   364                              <3>  extern ..@patch_no386_iret_code_or_entry, behind_code_truncated
   365                              <3>  extern behind_init, behind_messagesegment_nobits
   366                              <3>  extern behind_messagesegment_nobits_truncated, debug22
   367                              <3>  extern device_header.next, devint23, devint24, entry_retf
   368                              <3>  extern execblk.fcb1, execblk.fcb2, ext_data_area, extcall_table.ret
   369                              <3>  extern extcall_table.segsel, fileext, hVdd, immasm_buffer, initcont
   370                              <3>  extern initcont.boot_entry, initcont.device, inttab, inttab.i06
   371                              <3>  extern inttab.i2D, inttab_number_variable, line_out_overflow
   372                              <3>  extern linkcall_table.code1, linkcall_table.entry
   373                              <3>  extern linkcall_table.init, oldmode, pInDOS, pSDA, regs.size
   374                              <3>  extern switchar, trim_overflow, var_addr_entries
   375                              <3>  extern var_addr_entries.amount
   376                              <3> 
   377                              <3> ; install.asm
   378                              <3>  extern installflags, msg.alreadydisabled
   379                              <3>  extern msg.alreadyenabled, msg.toggle, msg.trydisable, msg.tryenable
   380                              <3> 
   381                              <3> ; ints.asm
   382                              <3>  extern debuggeramissig, inttab_optional
   383                              <3> 
   384                              <3> ; lineio.asm
   385                              <3>  extern auxbuff_amount_silent, cmd3_set_options
   386                              <3>  extern determine_quiet_output, eldheader, getc_repeat_idle
   387                              <3>  extern getline_timer_func, handle_ctrl_c, if_exists_found_closed
   388                              <3>  extern if_exists_found_ext_open, indos_remember_seek_function
   389                              <3>  extern indos_remember_seek_handle, indos_remember_seek_offset
   390                              <3>  extern input_file_handles.to_close, msg.configkeyword
   391                              <3>  extern msg.eld_error_code, msg.eld_load_error, msg.emptykeyword
   392                              <3>  extern msg.eof, msg.executablekeyword, msg.ext_error_internal
   393                              <3>  extern msg.ext_error_invalid, msg.ext_error_io, msg.ext_error_oom
   394                              <3>  extern msg.freedos_ctrlc_workaround, msg.goto_empty
   395                              <3>  extern msg.goto_not_file, msg.goto_not_found.1, msg.goto_not_found.2
   396                              <3>  extern msg.history_internal_error, msg.more, msg.more_over
   397                              <3>  extern msg.more_over_size, msg.more_size, msg.rh_step.1
   398                              <3>  extern msg.rh_step.2, msg.scriptskeyword, msg.silent_error, msg.sof
   399                              <3>  extern msg.unexpected_noneol_rc, msg.unexpected_noneol_re
   400                              <3>  extern msg.yy_error_file_open, msg.yy_filename_missing_unquote
   401                              <3>  extern msg.yy_no_dos, qq, section.DATASTACK.vstart
   402                              <3>  extern serial_check_receive_char, serial_receive_char
   403                              <3>  extern serial_send_char, skip_rh, yy_boot
   404                              <3>  extern yy_boot_clear_remember_seek, yy_boot_close_file, yy_boot_read
   405                              <3>  extern yy_boot_remember_seek, yy_boot_seek_current
   406                              <3>  extern yy_boot_seek_start, yy_try_scriptspath
   407                              <3>  extern yy_try_scriptspath.didnotyettry
   408                              <3>  extern yy_try_scriptspath.nokeywordused
   409                              <3> 
   410                              <3> ; ll.asm
   411                              <3>  extern doserr8, ensuredebuggeeloaded, execblk, execblk.csip
   412                              <3>  extern execblk.sssp, msg.hexerror, msg.ll_unterm, msg.not_while_indos
   413                              <3>  extern msg.tsr_cannot_ll, parselw, reading
   414                              <3>  extern terminate_attached_process, ww1, ww15, zeroregs
   415                              <3> 
   416                              <3> ; mm.asm
   417                              <3>  extern has_287, has_copr, msg.c0, msg.cr, msg8088
   418                              <3>  extern msgx86, no_copr, parsecm_have_address
   419                              <3> 
   420                              <3> ; serialp.asm
   421                              <3>  extern baseport, msg.no_progress, rxfifo, rxhead
   422                              <3>  extern rxtail, serial_fcr_setting, serial_installed_intnum
   423                              <3>  extern serial_save_dl, serial_save_ier, serial_save_irq_mask
   424                              <3>  extern serial_save_irq_off, serial_save_lcr, serial_save_mcr, txfifo
   425                              <3>  extern txhead, txtail
   426                              <3> 
   427                              <3> ; ss.asm
   428                              <3>  extern msg.matches, msg.reverse, msg.seconds, msg.sleep
   429                              <3>  extern msg.ticks, sleep_repeat_idle
   430                              <3> 
   431                              <3> ; vv.asm
   432                              <3>  extern csrpos, msg.nokeep, msg.off, msg.on, msg.vv_disabled
   433                              <3>  extern msg.vv_enable_failure, xmsdrv, xmsmove
   434                              <3> 
   435                              <3> ; ww.asm
   436                              <3>  extern diskful, doserr11, doserr2, doserr3, doserr5
   437                              <3>  extern drive, drivenumber, dskerrs, not_while_indos, nowhexe
   438                              <3>  extern nownull, openerr, openerr1, writing, wwmsg1
   439                              <3>  extern wwmsg2
   440                              <3> 
   441                              <3> 
   442                              <3>  extern bCSAttr, lDEBUG_CODE_to_lDEBUG_CODE2_nearcall_helper
   443                              <3> 
   444                              <3>  extern hook2F.not_in_dos
   445                              <3> 
   446                              <3>  extern cmd4.int3, lDEBUG_CODE2_dualret_helper
   447                              <3>  extern lDEBUG_CODE2_to_lDEBUG_CODE_nearcall_helper
   448                              <3>  extern lDEBUG_CODE_to_lDEBUG_CODE2_dualcall_helper, msg.bu
   449                              <3>  extern msg.bu_relocated, msg.bu_relocated.sign
   450                              <3> 
   451                              <3>  extern nopmsupp
   452                              <3> 
   453                              <3>  extern bAddr32
   454                              <3> 
   455                              <3>  extern descriptor, descriptor.attrib, descriptor.base
   456                              <3>  extern descriptor.limit, gatewrong, msg.d.a_error, msg.d.a_error_code
   457                              <3>  extern msg.d.a_success, msg.d.a_success_sel, msg.d.b_error
   458                              <3>  extern msg.d.b_error_code, msg.d.b_success, msg.d.d_error
   459                              <3>  extern msg.d.d_error_code, msg.d.d_success, msg.d.l_error
   460                              <3>  extern msg.d.l_error_code, msg.d.l_success, msg.d.t_error
   461                              <3>  extern msg.d.t_error_code, msg.d.t_success, msg.deschelp, msg.ofs32
   462                              <3>  extern nodesc
   463                              <3> 
   464                              <3>  extern ..@patch_tsr_quit_run, areastruc_entry.qq_entry, cssel
   465                              <3>  extern ddebugareas.next, debug2F, dpmidisable, dpmientry, dpmihook
   466                              <3>  extern dpmihookamis, dpmihookcs, dpmiwatch, end_of_ldebug_code2
   467                              <3>  extern findinstalleddebugger, get_messagesegsel, handle_mode_changed
   468                              <3>  extern i23pm, msg.cannotpmquit, msg.desc, msg.dpmi_no_hook, msg.msdos
   469                              <3>  extern msg.qq_device_pm, msg.qq_still_pm, msg.qqlate_areas_error
   470                              <3>  extern msg.readonly_verifysegm, msg.readonly_verifysegm.selector
   471                              <3>  extern mydpmientry, nodosext, oldi2F, pm_reset_handlers, scratchsel
   472                              <3>  extern sr_state, switchmode, uninstall_areas.qq_entry
   473                              <3> 
   474                              <3>  extern i24pm
   475                              <3> 
   476                              <3>  extern auxbuff_switchbuffer_size, code2_seg, code2_sel, code2_size
   477                              <3>  extern code_sel, daresult, dssel, immsel
   478                              <3>  extern lDEBUG_CODE2_to_lDEBUG_CODE_dualcall_helper
   479                              <3>  extern lDEBUG_CODE_dualret_helper, messagesel, msg.desctype
   480                              <3>  extern msg.stack_overflow.desctype
   481                              <3> 
   482                              <3>  extern cmd3_mirror
   483                              <3> 
   484                              <3>  extern ..@patch_entry_seg, ..@patch_no386_ds_4, ..@patch_no386_ds_5
   485                              <3>  extern ..@patch_no386_ds_entry_pmint21_1
   486                              <3>  extern ..@patch_no386_ds_entry_pmint21_2, areas_fun, areas_sub
   487                              <3>  extern ddebugareas.prev, linkcall_table.code2
   488                              <3> 
   489                              <3>  extern areas_struc, msg.areasalreadyinstalled
   490                              <3>  extern msg.areasalreadyuninstalled, msg.areasinstalled
   491                              <3>  extern msg.areasnodebuggerfound, msg.areasnotinstalled
   492                              <3>  extern msg.areasnotinstalled.code, msg.areasnotsupported
   493                              <3>  extern msg.areasuninstalled, msg.areasuninstalled.code
   494                              <3> 
   495                              <3>  extern intcall_return_parameter_es_parameter_ds
   496                              <3>  extern lDEBUG_CODE_to_lDEBUG_CODE_dualcall_helper, pop_if, push_if
   497                              <3> 
   498                              <3>  extern isextenderavailable, msg.cannotpmload, nodosextinst
   499                              <3> 
   500                              <3>  extern install_areas, patcharea_pm_exc, patcharea_pm_exc.segment
   501                              <3>  extern patcharea_pm_exc.size
   502                              <3> 
   503                              <3>  extern pmint21
   504                              <3> 
   505                              <3>  extern debuggerexception, entry_to_code_sel, exc6msg, excCmsg
   506                              <3>  extern excDmsg, excEmsg, intrtn2_entry, pmintsave.int21
   507                              <3> 
   508                              <3>  extern convsegs, convsegs.amount_fixed, convsegs.end_fixed
   509                              <3>  extern dpmi_pm2rm, dpmi_pmsav, dpmi_rm2pm, dpmi_rmsav, endexctab
   510                              <3>  extern exc_first, exc_second, excsave, exctab, installdpmimsg
   511                              <3>  extern intrtn_entry.from_installdpmi, pmintsave, pminttab
   512                              <3>  extern pminttab.end, setrmaddr, silence_delete_one_string.internal
   513                              <3> 
   514                              <3>  extern msg.rv_mode_dpmi_16, msg.rv_mode_dpmi_32, msg.vm_code2seg
   515                              <3>  extern msg.vm_selector, msg.vp_dpspsel, msg.vp_pspsel, psp_selector
   516                              <3> 
   517                              <3>  extern ..@getcseipbyte_fault_skip_6_near_call
   518                              <3>  extern ..@hh_code1_indirection_memory_access_end
   519                              <3>  extern ..@hh_code1_indirection_memory_access_start
   520                              <3>  extern ..@readmem_fault_skip_2_near_call
   521                              <3>  extern ..@setcseipbyte_fault_skip_6_near_call
   522                              <3>  extern ..@writemem_fault_skip_2_near_call_a
   523                              <3>  extern ..@writemem_fault_skip_2_near_call_b, behind_code
   524                              <3>  extern behind_code2, convsegs.amount, ddebugareas
   525                              <3>  extern getline_extra_int22.cleartraceflag, msg.list_bp_cseip_32
   526                              <3> 
   527                              <3>  extern MN_O16
   528                              <3> 
   529                              <3>  extern MN_A16
   530                              <3> 
   531                              <3>  extern relocatedzero
   532                              <3> 
   533                              <3>  extern msg.bu_disabled
   534                              <3> 
   535                              <3>  extern reset_interrupts, set_interrupts
   536                              <3> 
   537                              <3>  extern startoptions6
   538                              <3> 
   539                              <3>  extern currentposition, msg.loader_bottom_not_allowed
   540                              <3>  extern msg.loader_too_low_load
   541                              <3> 
   542                              <3>  extern intr_loader_18, intr_loader_19, moveloader_hook_ints
   543                              <3> 
   544                              <3>  extern loader_query, loader_transfer_cmd3, loader_transfer_relocate
   545                              <3> 
   546                              <3>  extern cmd3_int_disable.set_bx_to_dx, cmd3_int_enable.set_bx_to_dx
   547                              <3>  extern ldebug_code_size, movesegrefstable, movetable
   548                              <3>  extern movetable.bottom, msg.isalready, msg.isnow, msg.loader_error
   549                              <3>  extern msg.move, msg.move_auxbuff_error, msg.move_auxdown
   550                              <3>  extern msg.move_auxup, msg.move_ebdanottop, msg.move_empty
   551                              <3>  extern msg.move_int_error, msg.move_int_panic
   552                              <3>  extern msg.move_must_be_bottom, msg.move_nottop, msg.move_oom
   553                              <3>  extern msg.move_rpl, msg.move_toolargeebda, msg.unsupportedmove
   554                              <3>  extern qq_int_unhook_sim.set_bx_to_dx
   555                              <3> 
   556                              <3>  extern moveloader.already, moveloader.bottom_to_hidden
   557                              <3>  extern moveloader.bottom_to_top, moveloader.hidden_to_bottom
   558                              <3>  extern moveloader.hidden_to_top, moveloader.top_to_bottom
   559                              <3>  extern moveloader.top_to_hidden
   560                              <3> 
   561                              <3>  extern moveloader.specificerror, moveloader_check_serial, msg.godebug
   562                              <3>  extern msg.loader_extra, msg.loader_flag, msg.loader_loadseg_low
   563                              <3>  extern msg.loader_must_be_hidden, msg.loader_sign, msg.loader_stack
   564                              <3>  extern msg.loadsupportsignature, msg.loadsupportsignature.size
   565                              <3> 
   566                              <3>  extern depack, hshrink_memory_source.offset
   567                              <3>  extern hshrink_memory_source.segment, indirect_hshrink_message_buffer
   568                              <3>  extern msg.hshrink_error, nontruncated_hshrink_message_buffer
   569                              <3> 
   570                              <3>  extern truncated_hshrink_message_buffer
   571                              <3> 
   572                              <3>  extern patch_boothelp_uncompressed
   573                              <3> 
   574                              <3>  extern msg.copybpb
   295                              <2> %endif
   710                              <1> %endif
   711                              <1> [list -]
   714                              <1> 
   715                              <1> %include "eld.mac"
     1                              <2> %if 0
     2                              <2> 
     3                              <2> Extensions for lDebug macros
     4                              <2> 
     5                              <2> Copyright (C) 2008-2025 E. C. Masloch
     6                              <2> 
     7                              <2> Usage of the works is permitted provided that this
     8                              <2> instrument is retained with the works, so that any entity
     9                              <2> that uses the works is notified of this instrument.
    10                              <2> 
    11                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    12                              <2> 
    13                              <2> %endif
    14                              <2> 
    15                              <2> %ifndef ELD_MAC
    16                              <2> %define ELD_MAC 1
    17                              <2> 
    18                              <2> %include "lmacros3.mac"
     1                              <3> [list -]
    19                              <2> 
    20                              <2> 		; ELD executable header
    21                              <2> 	struc ELD_HEADER
    22 00000000 ????????            <2> eldhSignature:		resb 4	; "ELD1"
    23 00000004 ??????              <2> 			resb 3	; reserved
    24 00000007 ??                  <2> 			resb 1	; 26 (Ctrl-Z)
    25 00000008 ????????            <2> eldhCodeOffset:		resd 1	; position displacement from eldhSignature
    26 0000000C ????                <2> eldhCodeImageLength:	resw 1	; amount bytes, at least 32
    27 0000000E ????                <2> eldhCodeAllocLength:	resw 1	; amount bytes, added to prior. sum < 64 KiB
    28 00000010 ????????            <2> eldhDataOffset:		resd 1
    29 00000014 ????                <2> eldhDataImageLength:	resw 1	; (zero allowed)
    30 00000016 ????                <2> eldhDataAllocLength:	resw 1	; (zero allowed)
    31 00000018 ????                <2> eldhCodeEntrypoint:	resw 1	; within code section, used as displacement
    32 0000001A ????????            <2> eldhReserved:		resb 4	; reserved
    33 0000001E ????                <2> eldhExtensionSize:	resw 1	; from eldhSignature, -> past eldhx fields in use
    34                              <2> 	endstruc
    35                              <2> 	endarea ELD_HEADER, 1
    36                              <2> 
    37                              <2> 	struc ELD_HEADERX
    38 00000000 <res 20h>           <2> eldhxHeader:		resb ELD_HEADER_size
    39 00000020 ????????            <2> eldhxDescriptionOffset:	resd 1	; zero if none, from eldhxHeader. <= 128 Bytes
    40 00000024 ????????            <2> eldhxHelpOffset:	resd 1	; zero if none, from eldhxHeader
    41 00000028 ????????            <2> eldhxLibTable:		resd 1	; zero if none, from eldhxHeader
    42 0000002C ????????            <2> eldhxDateTimeOffset:	resd 1	; zero if none, from eldhxHeader
    43                              <2> 	alignb 16
    44                              <2> 	endstruc
    45                              <2> 
    46                              <2> 	struc ELD_TRAILER_HEADER
    47 00000000 ????????????????    <2> eldthSignature:		resb 8	; "ELD1TAIL"
    48 00000008 ????????            <2> eldthHeaderOffset:	resd 1	; negative displacement from eldthSignature,
    49                              <2> 				;  add this dword to the seek offset
    50 0000000C ????                <2> eldthReserved:		resw 1	; reserved, must be initialised to zero
    51 0000000E ????                <2> eldthChecksum:		resw 1	; sum of all words in trailer header = 0
    52                              <2> 	endstruc
    53                              <2> 	endarea ELD_TRAILER_HEADER, 1
    54                              <2> 
    55                              <2> 	struc ELD_LIBTABLE
    56 00000000 ????                <2> eldltFormat:		resw 1
    57                              <2> 	; 0 = uncompressed
    58                              <2> 	; 2 = heatshrink compressed
    59                              <2> 	; 3 = lzexedat -4 compressed
    60                              <2> 	; 4 = lzexedat -4 -l compressed
    61 00000002 ????                <2> eldltAmount:		resw 1
    62 00000004 ????????            <2> eldltOffset:		resd 1	; from eldhxHeader
    63                              <2> eldltCompressedLength:		; (dword, only present if format 2, 3, or 4)
    64                              <2> 	endstruc
    65                              <2> 	endarea ELD_LIBTABLE, 1
    66                              <2> 
    67                              <2> 		; ELD instance header
    68                              <2> 	struc ELD_INSTANCE
    69 00000000 ????                <2> eldiStartCode:		resw 1	; -> this structure itself (para aligned)
    70 00000002 ????                <2> eldiEndCode:		resw 1	; -> behind memory used by instance (para aligned)
    71 00000004 ????                <2> eldiStartData:		resw 1	; -> data in data entry section (para aligned), or 0
    72 00000006 ????                <2> eldiEndData:		resw 1	; -> behind data (para aligned), or 0
    73 00000008 ????????????????    <2> eldiIdentifier:		resb 8	; blank-filled text
    74 00000010 ????                <2> eldiFlags:		resw 1	; flags
    75                              <2> eldiListing_size equ 14
    76 00000012 <res Eh>            <2> eldiListing:		resb eldiListing_size
    77                              <2> 				; ASCIZ listing file name
    78                              <2> 	endstruc
    79                              <2> 		; flags for eldiFlags:
    80                              <2> eldifResident:		equ 1
    81                              <2> 
    82                              <2> 		; ELD link info header
    83                              <2> 	struc ELD_LINKINFO
    84 00000000 ????                <2> eldlSignature:		resw 1	; 0E1D1h
    85 00000002 ????????            <2> eldlReserved:		resw 2
    86 00000006 ????                <2> eldlUseLinkHash:	resw 1
    87 00000008 ????                <2> eldlDataAmount:		resw 1
    88 0000000A ????                <2> eldlDataPrefixes:	resw 1
    89 0000000C ????                <2> eldlDataEntries:	resw 1
    90 0000000E ????                <2> eldlDataAddresses:	resw 1
    91 00000010 ????                <2> eldlCodeAmount:		resw 1
    92 00000012 ????                <2> eldlCodePrefixes:	resw 1
    93 00000014 ????                <2> eldlCodeEntries:	resw 1
    94 00000016 ????                <2> eldlCodeAddresses:	resw 1
    95                              <2> 	endstruc
    96                              <2> 
    97                              <2> 	numdef ELD_CODE_VSTART, 9001h
    98                              <2> 	numdef ELD_DATA_VSTART, 8000h
    99                              <2> 	numdef ELD_RELOC_VSTART, 8000h
   100                              <2> 
   101                              <2> 	numdef ELD_RECLAIM_HINT, 0
   102                              <2> 	strdef ELD_LISTING, ""
   103                              <2> 	numdef ELD_DATETIME, 0
   104                              <2> 
   105                              <2> %if _ELD_DATETIME
   106                              <2>  %define PUT_ELDHX_DATETIME_OFFSET at eldhxDateTimeOffset, dd DATAOFFSET + datetime - datastart
   107                              <2>  %macro PUT_ELD_DATETIME 0.nolist
   108                              <2> datetime:	asciz __UTC_DATE__,'T',__UTC_TIME__,'Z'
   109                              <2> 		asciz		; for future extension
   110                              <2>  %endmacro
   111                              <2> %else
   112                              <2>  %define PUT_ELDHX_DATETIME_OFFSET
   113                              <2>  %define PUT_ELD_DATETIME
   114                              <2> %endif
   115                              <2> 
   116                              <2> %endif
   716                              <1> 
   717                              <1> %include "install.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug INSTALL command macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2023 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 	struc INSTALLFLAG
    17 00000000 ????                <2> ifKeyword:	resw 1
    18 00000002 ????                <2> ifDescription:	resw 1
    19 00000004 ????                <2> ifOptions:	resw 1
    20 00000006 ????                <2> ifValue:	resw 1
    21 00000008 ????                <2> ifTrying:	resw 1
    22 0000000A ????                <2> ifReserved:	resw 1
    23                              <2> 	endstruc
    24                              <2> 
   718                              <1> 
   719                              <1> %if _SYMBOLIC
   720                              <1> 	defaulting 0			; disable defaulting
   721                              <1> %include "symbols.mac"
   722                              <1> [list -]
   723                              <1> 		; symbolic branch defines *without* defaulting!
   724                              <1> 	numdef ZZ_INSERT_TEMP, 1
   725                              <1> 	numdef XMS_SYMBOL_TABLE, 1
   726                              <1> 	numdef BUFFER_86MM_SLICE, 0
   727                              <1> 	numdef SECOND_SLICE, 0
   728                              <1> 
   729                              <1> 	defaulting 1			; re-enable defaulting
   730                              <1> 
   731                              <1> 		; symbolic branch defines
   732                              <1> 	numdef 86MM_SYMBOL_TABLE_MAX, 256, 256
   733                              <1> %endif
   734                              <1> 
   735                              <1> 	struc SEGADR
   736 00000000 ????????            <1> saOffset:	resd 1
   737 00000004 ????                <1> saSegSel:	resw 1
   738                              <1> %if _PM
   739 00000006 ????                <1> saSegment:	resw 1
   740 00000008 ????                <1> saSelector:	resw 1
   741                              <1> %endif
   742                              <1> 	endstruc
   743                              <1> 
   744                              <1> 	%macro segmentedaddress 0.nolist
   745                              <1> 	istruc SEGADR
   746                              <1> 	iend
   747                              <1> 	%endmacro
   748                              <1> 
   749                              <1> 	struc SEGOFS16ADR
   750 00000000 ????                <1> so16aOffset:	resw 1
   751 00000002 ????                <1> so16aSegSel:	resw 1
   752                              <1> %if _PM
   753 00000004 ????                <1> so16aSegment:	resw 1
   754 00000006 ????                <1> so16aSelector:	resw 1
   755                              <1> %endif
   756                              <1> 	endstruc
   757                              <1> 
   758                              <1> 	%macro segofs16address 0-1.nolist zero
   759                              <1> 	istruc SEGOFS16ADR
   760                              <1> %ifidni %1,zero
   761                              <1> %elifidni %1,minusone
   762                              <1> at so16aOffset,		dw -1
   763                              <1> at so16aSegSel,		dw -1
   764                              <1>  %if _PM
   765                              <1> at so16aSegment,	dw -1
   766                              <1> at so16aSelector,	dw -1
   767                              <1>  %endif
   768                              <1> %else
   769                              <1>  %error Unexpected initialiser keyword
   770                              <1> %endif
   771                              <1> 	iend
   772                              <1> 	%endmacro
   773                              <1> 
   774                              <1> 	struc SEGONLYADR
   775 00000000 ????                <1> soaSegSel:	resw 1
   776                              <1> %if _PM
   777 00000002 ????                <1> soaSegment:	resw 1
   778 00000004 ????                <1> soaSelector:	resw 1
   779                              <1> %endif
   780                              <1> 	endstruc
   781                              <1> 
   782                              <1> 	%macro segonlyaddress 0.nolist
   783                              <1> 	istruc SEGONLYADR
   784                              <1> 	iend
   785                              <1> 	%endmacro
   786                              <1> 
   787                              <1> 
   788                              <1> %if _LOADER
   789                              <1> 	struc MOVETABLEENTRY
   790                              <1> mteIdentifier:		resw 1
   791                              <1> mteArrayIndex:		resw 1
   792                              <1> mteStatusMessage:	resw 1
   793                              <1> mteFromArray:
   794                              <1> mteFromBottom:		resw 1
   795                              <1> mteFromTop:		resw 1
   796                              <1> mteFromHidden:		resw 1
   797                              <1> 	endstruc
   798                              <1> %endif
   799                              <1> 
   800                              <1> %if _BOOTLDR
   801                              <1>  %include "iniload.mac"
     1                              <2> %if 0
     2                              <2> 
     3                              <2> lDebug iniload/boot interfacing structs and macros
     4                              <2> 
     5                              <2> Copyright (C) 2008-2025 E. C. Masloch
     6                              <2> 
     7                              <2> Usage of the works is permitted provided that this
     8                              <2> instrument is retained with the works, so that any entity
     9                              <2> that uses the works is notified of this instrument.
    10                              <2> 
    11                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    12                              <2> 
    13                              <2> %endif
    14                              <2> 
    15                              <2> 
    16                              <2> 	struc BS
    17 00000000 ??????              <2> bsJump:	resb 3
    18 00000003 ????????????????    <2> bsOEM:	resb 8
    19                              <2> bsBPB:
    20                              <2> 	endstruc
    21                              <2> 
    22                              <2> 	struc EBPB		;        BPB sec
    23 00000000 ????                <2> bpbBytesPerSector:	resw 1	; offset 00h 0Bh
    24 00000002 ??                  <2> bpbSectorsPerCluster:	resb 1	; offset 02h 0Dh
    25 00000003 ????                <2> bpbReservedSectors:	resw 1	; offset 03h 0Eh
    26 00000005 ??                  <2> bpbNumFATs:		resb 1	; offset 05h 10h
    27 00000006 ????                <2> bpbNumRootDirEnts:	resw 1	; offset 06h 11h -- 0 for FAT32
    28 00000008 ????                <2> bpbTotalSectors:	resw 1	; offset 08h 13h
    29 0000000A ??                  <2> bpbMediaID:		resb 1	; offset 0Ah 15h
    30 0000000B ????                <2> bpbSectorsPerFAT:	resw 1	; offset 0Bh 16h -- 0 for FAT32
    31 0000000D ????                <2> bpbCHSSectors:		resw 1	; offset 0Dh 18h
    32 0000000F ????                <2> bpbCHSHeads:		resw 1	; offset 0Fh 1Ah
    33 00000011 ????????            <2> bpbHiddenSectors:	resd 1	; offset 11h 1Ch
    34 00000015 ????????            <2> bpbTotalSectorsLarge:	resd 1	; offset 15h 20h
    35                              <2> bpbNew:				; offset 19h 24h
    36                              <2> 
    37 00000019 ????????            <2> ebpbSectorsPerFATLarge:	resd 1	; offset 19h 24h
    38 0000001D ????                <2> ebpbFSFlags:		resw 1	; offset 1Dh 28h
    39 0000001F ????                <2> ebpbFSVersion:		resw 1	; offset 1Fh 2Ah
    40 00000021 ????????            <2> ebpbRootCluster:	resd 1	; offset 21h 2Ch
    41 00000025 ????                <2> ebpbFSINFOSector:	resw 1	; offset 25h 30h
    42 00000027 ????                <2> ebpbBackupSector:	resw 1	; offset 27h 32h
    43 00000029 <res Ch>            <2> ebpbReserved:		resb 12	; offset 29h 34h
    44                              <2> ebpbNew:			; offset 35h 40h
    45                              <2> 	endstruc
    46                              <2> 
    47                              <2> 	struc BPBN		; ofs B16 S16 B32 S32
    48 00000000 ??                  <2> bpbnBootUnit:		resb 1	; 00h 19h 24h 35h 40h
    49 00000001 ??                  <2> 			resb 1	; 01h 1Ah 25h 36h 41h
    50 00000002 ??                  <2> bpbnExtBPBSignature:	resb 1	; 02h 1Bh 26h 37h 42h -- 29h for valid BPBN
    51 00000003 ????????            <2> bpbnSerialNumber:	resd 1	; 03h 1Ch 27h 38h 43h
    52 00000007 <res Bh>            <2> bpbnVolumeLabel:	resb 11	; 07h 20h 2Bh 3Ch 47h
    53 00000012 ????????????????    <2> bpbnFilesystemID:	resb 8	; 12h 2Bh 36h 47h 52h
    54                              <2> 	endstruc		; 1Ah 33h 3Eh 4Fh 5Ah
    55                              <2> 
    56                              <2> 	struc DIRENTRY
    57 00000000 ????????????????    <2> deName:		resb 8
    58 00000008 ??????              <2> deExt:		resb 3
    59 0000000B ??                  <2> deAttrib:	resb 1
    60 0000000C ??                  <2> dePlusSize:	resb 1
    61 0000000D ??????????????      <2> 		resb 7
    62 00000014 ????                <2> deClusterHigh:	resw 1
    63 00000016 ????                <2> deTime:		resw 1
    64 00000018 ????                <2> deDate:		resw 1
    65 0000001A ????                <2> deClusterLow:	resw 1
    66 0000001C ????????            <2> deSize:		resd 1
    67                              <2> 	endstruc
    68                              <2> 
    69                              <2> ATTR_READONLY	equ 1
    70                              <2> ATTR_HIDDEN	equ 2
    71                              <2> ATTR_SYSTEM	equ 4
    72                              <2> ATTR_VOLLABEL	equ 8
    73                              <2> ATTR_DIRECTORY	equ 10h
    74                              <2> ATTR_ARCHIVE	equ 20h
    75                              <2> 
    76                              <2> lsvclSignature		equ "CL"
    77                              <2> lsvclBufferLength	equ 256
    78                              <2> 
    79                              <2> 	struc LOADSTACKVARS, -10h
    80 FFFFFFF0 ????????            <2> lsvFirstCluster:	resd 1
    81 FFFFFFF4 ????????            <2> lsvFATSector:		resd 1
    82 FFFFFFF8 ????                <2> lsvFATSeg:		resw 1
    83 FFFFFFFA ????                <2> lsvLoadSeg:		resw 1
    84 FFFFFFFC ????????            <2> lsvDataStart:		resd 1
    85                              <2> 	endstruc
    86                              <2> 
    87                              <2> 	struc LOADDATA, LOADSTACKVARS - 10h
    88 FFFFFFE0 ????                <2> ldMemoryTop:	resw 1
    89 FFFFFFE2 ????                <2> ldLoadTop:	resw 1
    90 FFFFFFE4 ????                <2> ldSectorSeg:	resw 1
    91 FFFFFFE6 ??                  <2> ldFATType:	resb 1
    92                              <2> ldFlags:
    93 FFFFFFE7 ??                  <2> ldHasLBA:	resb 1
    94 FFFFFFE8 ????                <2> ldClusterSize:	resw 1
    95 FFFFFFEA ????                <2> ldParaPerSector:resw 1
    96                              <2> ldDirCluster:			; dword
    97                              <2> ldLoadingSeg:		; word
    98                              <2> ldQueryPatchValue:	; word
    99                              <2> lsvCommandLine:		; word
   100                              <2> .start:		equ $ - lsvclBufferLength
   101 FFFFFFEC ????                <2> .signature:	resw 1
   102                              <2> ldLoadUntilSeg:		; word
   103                              <2> lsvExtra:		; word
   104 FFFFFFEE ??                  <2> .partition:	resb 1	; byte
   105 FFFFFFEF ??                  <2> .flags:		resb 1	; byte
   106                              <2> 	endstruc
   107                              <2> 
   108                              <2> ldhlfPreserveLoader	equ 4
   109                              <2> 
   110                              <2> lsvefNoDataStart	equ 1
   111                              <2> lsvefPartitionNumber	equ 2
   112                              <2> lsvefPreserveLoader	equ 4
   113                              <2> 
   114                              <2> %if lsvefPreserveLoader != ldhlfPreserveLoader
   115                              <2>  %error Unexpected flag values
   116                              <2> %endif
   117                              <2> 
   118                              <2> 	struc LOADCMDLINE, LOADDATA - lsvclBufferLength
   119                              <2> ldCommandLine:
   120 FFFFFEE0 <res 100h>          <2> .start:		resb lsvclBufferLength
   121                              <2> 	endstruc
   122                              <2> 
   123                              <2> ldfHasLBA:	equ 1
   124                              <2> ldfFATInvalid:	equ 2
   125                              <2> ldfFATBuffered:	equ 4
   126                              <2> ldfDataBuffered: equ 8
   127                              <2> 
   128                              <2> 	struc LOADDATA2, LOADDATA - 10h
   129 FFFFFFD0 ????????            <2> ldRootSector:		resd 1
   130 FFFFFFD4 ????                <2> ldEntriesPerSector:	resw 1
   131                              <2> ldDataSegment:		; word
   132 FFFFFFD6 ????                <2> ldLastAvailableSector:	resw 1
   133                              <2> ldDataSector:		; dword
   134 FFFFFFD8 ????                <2> ldParasLeft:		resw 1
   135 FFFFFFDA ????                <2> ldParasDone:		resw 1
   136                              <2> 	endstruc
   137                              <2> 
   138                              <2> 	struc LOADDATA3, LOADDATA2 - 10h
   139 FFFFFFC0 ????????            <2> ldMaxCluster:		resd 1
   140 FFFFFFC4 ????????            <2> ldFileSize:		resd 1
   141 FFFFFFC8 ????????            <2> ldCurrentCluster:	resd 1
   142 FFFFFFCC ????????            <2> ldCurrentSeek:		resd 1
   143                              <2> 	endstruc
   144                              <2> 
   145                              <2> 	struc LOADERIMAGEIDENT
   146 00000000 ????????            <2> liiSignature:		resb 4		; "NLDR"
   147 00000004 ????                <2> liiVersion:		resb 2		; "00"
   148 00000006 ????                <2> liiChecksum:		resw 1		; word sum of first 8 words = 0
   149 00000008 ????                <2> liiAmountParagraphs:	resw 1
   150 0000000A ????????????        <2> liiReserved:		resw 3
   151 00000010 ????                <2> liiEntryQuerySize:	resw 1		; 0 if not supported
   152                              <2> 		; INP:	cs => NLDR image ident
   153                              <2> 		;	ip = this word field content
   154                              <2> 		;	ax = 60h
   155                              <2> 		; OUT:	ax => behind memory requested (should be >= 60h)
   156                              <2> 		; CHG:	es, ds, di, si, bx, cx, dx
   157                              <2> 		; STT:	far called, UP, EI
   158 00000012 ????                <2> liiEntryRelocate:	resw 1		; 0 if not supported
   159                              <2> 		; INP:	cs => NLDR image ident
   160                              <2> 		;	ip = this word field content
   161                              <2> 		;	ax = 60h
   162                              <2> 		; OUT:	ax => relocated NLDR segment (usually 60h)
   163                              <2> 		; CHG:	es, ds, di, si, bx, cx, dx
   164                              <2> 		; STT:	far called, UP, EI
   165 00000014 ????                <2> liiEntryDebug:		resw 1		; 0 if not supported
   166                              <2> 		; INP:	es = ds = cs = ss => relocated NLDR
   167                              <2> 		;	ip = this word field content
   168                              <2> 		;	sp = next word field content
   169                              <2> 		; STT:	running as debuggee, UP, EI
   170 00000016 ????                <2> liiStackPointer:	resw 1
   171                              <2> 	endstruc
   172                              <2> 
   173                              <2> 	struc LBAPACKET
   174 00000000 ????                <2> lpSize:		resw 1
   175 00000002 ????                <2> lpCount:	resw 1
   176 00000004 ????????            <2> lpBuffer:	resd 1
   177 00000008 ????????????????    <2> lpSector:	resq 1
   178                              <2> 	endstruc
   179                              <2> 
   180                              <2> 	struc PARTINFO
   181 00000000 ??                  <2> piBoot:		resb 1
   182 00000001 ??????              <2> piStartCHS:	resb 3
   183 00000004 ??                  <2> piType:		resb 1
   184 00000005 ??????              <2> piEndCHS:	resb 3
   185 00000008 ????????            <2> piStart:	resd 1
   186 0000000C ????????            <2> piLength:	resd 1
   187                              <2> 	endstruc
   188                              <2> 
   189                              <2> ptEmpty:		equ 0
   190                              <2> ptFAT12:		equ 1
   191                              <2> ptFAT16_16BIT_CHS:	equ 4
   192                              <2> ptExtendedCHS:		equ 5
   193                              <2> ptFAT16_CHS:		equ 6
   194                              <2> ptFAT32_CHS:		equ 0Bh
   195                              <2> ptFAT32:		equ 0Ch
   196                              <2> ptFAT16:		equ 0Eh
   197                              <2> ptExtended:		equ 0Fh
   198                              <2> ptLinux:		equ 83h
   199                              <2> ptExtendedLinux:	equ 85h
   200                              <2> 
   201                              <2> 
   202                              <2> 		; Flags of load_unit_flags
   203                              <2> lufForceCHS:		equ 1
   204                              <2> lufForceLBA:		equ 2
   205                              <2> lufForceGeometry:	equ 4
   206                              <2> luf_mask_writable equ lufForceCHS | lufForceLBA | lufForceGeometry
   802                              <1> 
   803                              <1> LOAD_INPUT_FILE_SIZE equ fromparas(paras(-LOADDATA3 + bsBPB + ebpbNew + BPBN_size))
   804                              <1> 
   805                              <1> 	struc LOADSETTINGS
   806 00000000 ????                <1> lsKernelName:	resw 1	; -> kernel file default name
   807 00000002 ????                <1> lsAddName:	resw 1	; -> additional file default name, may be empty string
   808 00000004 ????                <1> lsMinPara:	resw 1	; how much to load at least, fail if file smaller
   809 00000006 ????                <1> lsMaxPara:	resw 1	; how much to load at most (will round up to sector size)
   810 00000008 ????                <1> lsOptions:	resw 1	; option flags
   811 0000000A ????                <1> lsSegment:	resw 1	; => where to load file
   812 0000000C ????????            <1> lsEntry:	resd 1	; relative segment for CS, value for IP
   813 00000010 ????????            <1> lsBPB:		resd 1	; segment for BPB (-1 auto-BPB), offset for BPB
   814 00000014 ????????            <1> lsCopyBPB:	resd 1	; if not all-zeroes, copy BPB to far pointer
   815 00000018 ????                <1> lsCheckOffset:	resw 1	; offset in file segment of word to check
   816 0000001A ????                <1> lsCheckValue:	resw 1	; value to check for word, 0 if unused
   817 0000001C ????????????????    <1> lsName:		resq 1	; ASCIZ load protocol name
   818                              <1> 	endstruc
   819                              <1> 
   820                              <1> 		numdef LUF_DEFAULT_DISKETTE, 0
   821                              <1> 		numdef LUF_DEFAULT_HARDDISK, 0
   822                              <1> %endif
   823                              <1> 
   824                              <1> 
   825                              <1> %include "mzheader.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug MZ .EXE header macros
     5                              <2> 
     6                              <2> Copyright (C) 1995-2003 Paul Vojta
     7                              <2> Copyright (C) 2008-2023 E. C. Masloch
     8                              <2> 
     9                              <2> Usage of the works is permitted provided that this
    10                              <2> instrument is retained with the works, so that any entity
    11                              <2> that uses the works is notified of this instrument.
    12                              <2> 
    13                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    14                              <2> 
    15                              <2> %endif
    16                              <2> 
    17                              <2> 
    18                              <2> 	struc EXEHEADER
    19 00000000 ????                <2> exact_struc_at 00h, exeSignature:	resw 1
    20 00000002 ????                <2> exact_struc_at 02h, exeExtraBytes:	resw 1	; bytes in last page
    21 00000004 ????                <2> exact_struc_at 04h, exePages:		resw 1	; number of 512-byte pages. includes the header!
    22 00000006 ????                <2> exact_struc_at 06h, exeRelocItems:	resw 1	; number of relocation items
    23 00000008 ????                <2> exact_struc_at 08h, exeHeaderSize:	resw 1	; header size in 16-byte paragraphs
    24 0000000A ????                <2> exact_struc_at 0Ah, exeMinAlloc:	resw 1	; minimum (bss) allocation in paragraphs
    25 0000000C ????                <2> exact_struc_at 0Ch, exeMaxAlloc:	resw 1	; maximum (bss) allocation in paragraphs
    26 0000000E ????                <2> exact_struc_at 0Eh, exeInitSS:		resw 1	; init ss (is relocated)
    27 00000010 ????                <2> exact_struc_at 10h, exeInitSP:		resw 1	; init sp
    28 00000012 ????                <2> exact_struc_at 12h, exeChecksum:	resw 1
    29                              <2> exact_struc_at 14h, exeInitCSIP:
    30 00000014 ????                <2> exact_struc_at 14h, exeInitIP:		resw 1	; init ip
    31 00000016 ????                <2> exact_struc_at 16h, exeInitCS:		resw 1	; init cs (is relocated)
    32 00000018 ????                <2> exact_struc_at 18h, exeRelocTable:	resw 1	; byte offset of relocation table
    33                              <2> 		; Each relocation item is a word offset and a word segment.
    34                              <2> 		;  The segment of the item itself is relocated as well.
    35 0000001A ????                <2> exact_struc_at 1Ah, exeOverlayNum:	resw 1
    36                              <2> exact_struc_at 1Ch
    37                              <2> 	endstruc
   826                              <1> 
   827                              <1> 
   828                              <1> 	struc INPUTFILEHANDLE
   829 00000000 ????                <1> ifhHandle:	resw 1
   830 00000002 ????                <1> ifhFlags:	resw 1
   831 00000004 ????????            <1> ifhParentSeek:	resd 1
   832                              <1> 	endstruc
   833                              <1> 
   834                              <1> ifhfIsDup:		equ  100h	; before closing, seek it back
   835                              <1> 	; same value as LBA flag for boot load input files
   836                              <1> ifhfTestReserved1:	equ 1000h
   837                              <1> ifhfTestReserved2:	equ 2000h
   838                              <1> ifhfQuietInput:		equ 4000h	; do not display prompt and input
   839                              <1> ifhfQuietOutput:	equ 8000h	; do not display normal output
   840                              <1> 	; these four are valid for both input file handles and
   841                              <1> 	;  boot load input files.
   842                              <1> 
   843                              <1> 
   844                              <1> 	struc AREASTRUC
   845 00000000 <res 18h>           <1> areastrucEntry:		resb 24
   846 00000018 ????????            <1> areastrucNext:		resd 1
   847 0000001C ????????            <1> areastrucPrev:		resd 1
   848 00000020 ????                <1> areastrucSubAmount:	resw 1
   849 00000022 ????                <1> areastrucSubOffset:	resw 1
   850 00000024 ????                <1> areastrucFunAmount:	resw 1
   851 00000026 ????                <1> areastrucFunOffset:	resw 1
   852                              <1> 	endstruc
   853                              <1> 
   854                              <1> 	struc AREASTRUCSUB
   855 00000000 ????????            <1> areastrucsubLinear:	resd 1
   856 00000004 ????????            <1> areastrucsubLinearEnd:	resd 1
   857 00000008 ????                <1> areastrucsubListOffset:	resw 1
   858 0000000A ????                <1> areastrucsubListAmount:	resw 1
   859                              <1> 	endstruc
   860                              <1> 
   861                              <1> 	struc AREASTRUCFUN
   862 00000000 ????????            <1> areastrucfunLinear:	resd 1
   863 00000004 ????????            <1> areastrucfunLinearEnd:	resd 1
   864 00000008 ????                <1> areastrucfunListOffset:	resw 1
   865 0000000A ????                <1> areastrucfunListAmount:	resw 1
   866                              <1> 	endstruc
   867                              <1> 
   868                              <1> 	struc AREA
   869 00000000 ????                <1> areastart:		resw 1
   870 00000002 ????                <1> areaend:		resw 1
   871 00000004 ????                <1> areamessage:		resw 1
   872 00000006 ????                <1> 			resw 1
   873                              <1> 	endstruc
   874                              <1> 
   875                              <1> 
   876                              <1> %include "isvariab.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug isvariable? function strutures and macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2025 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 
    17                              <2> 	struc ISVARIABLESTRUC
    18 00000000 ????                <2> ivName:		resw 1		; -> name (up to 13 bytes, but actually only 11)
    19                              <2> 				;  (search for ivfNameLengthLimit for limit)
    20                              <2> 				;  (length given by ivFlags & ivfNameLengthMask)
    21                              <2> 	; The ivName pointer is only used for more-byte names. It actually
    22                              <2> 	;  contains the trailer of the name, excluding the prefix formed by
    23                              <2> 	;  the first two bytes. This suffix can be the empty string if the
    24                              <2> 	;  variable in question has a two-byte name.
    25                              <2> 	; (For one-byte names this field is unused and contains zero.)
    26 00000002 ????                <2> ivFlags:	resw 1
    27 00000004 ????                <2> ivAddress:	resw 1		; default -> variable
    28                              <2> 	; The ivAddress field is used by default_variable_setup as the base
    29                              <2> 	;  address for the variable(s). It is also used by var_ext_setup as
    30                              <2> 	;  the ELD code section offset to transfer control to. Otherwise, it
    31                              <2> 	;  is usually set to zero and unused.
    32 00000006 ????                <2> ivSetup:	resw 1		; -> set up code (in expr code section)
    33                              <2> 	; INP:	ax = array index (0-based)
    34                              <2> 	;	di = 0
    35                              <2> 	;	cl = default size of variable (1..4)
    36                              <2> 	;	ch = length of variable name
    37                              <2> 	;	bx -> ISVARIABLESTRUC structure
    38                              <2> 	; CHG:	ax, bx, cx, dx, si, di
    39                              <2> 	; OUT:	NC if valid,
    40                              <2> 	;	 bx -> var, di = 0 or di -> mask
    41                              <2> 	;	 cl = size of variable (1..4)
    42                              <2> 	;	 ch = length of variable name
    43 00000008 ??                  <2> ivArrayLast:	resb 1		; 0 if no array, FFh = 256 entries
    44                              <2> 	; The ivArrayLast field is used by the dispatcher to determine
    45                              <2> 	;  whether to support array index expressions. It is checked
    46                              <2> 	;  before decrementing the index if ivfArrayOneBased is set.
    47 00000009 ??                  <2> ivArrayBetween: resb 1		; how many bytes to skip for each index
    48                              <2> 	; The ivArrayBetween field is only used by default_variable_setup.
    49                              <2> 	endstruc
    50                              <2> 
    51                              <2> ivfNameLengthMask:	equ 15	; gives name trailer length, 0 to 11
    52                              <2> ivfNameLengthLimit:	equ 13
    53                              <2> ivfVarLengthShift:	equ 4
    54                              <2> ivfVarLengthMask:	equ 3 << ivfVarLengthShift
    55                              <2> 				; gives default variable size minus 1
    56                              <2> ivfReadOnly:		equ 80h	; variable cannot be written at all
    57                              <2> ivfArrayOneBased:	equ 100h; first array entry is 1 not 0 (ivArrayLast > 0)
    58                              <2> ivfArrayOptional:	equ 200h; array index expression is optional
    59                              <2> ivfSeparatorSpecial:	equ 400h; used for RIxxP/L/S/O
    60                              <2> 
    61                              <2> %define ISVARIABLESTRINGS db "",db ""
    62                              <2> %define IVS_ONEBYTE_NAMES ""
    63                              <2> %define IVS_MOREBYTE_NAMEHEADERS ""
    64                              <2> %assign IVS_HAVE_ONEBYTE 0
    65                              <2> %assign IVS_SINGLE_ONEBYTE 1
    66                              <2> 
    67                              <2> 		; %1 = name string
    68                              <2> 		; %2 = default variable length, 1 to 4
    69                              <2> 		; %3 = flags to set (except name length and var length)
    70                              <2> 		; %4 = ivAddress value
    71                              <2> 		; %5 = ivArrayLast, defaults to 0 (no array)
    72                              <2> 		; %6 = ivArrayBetween, defaults to 0 (immediately consecutive)
    73                              <2> 		; %7 = ivSetup, defaults to default_variable_setup
    74                              <2> 	%macro isvariablestruc 4-7.nolist 0, 0, default_variable_setup
    75                              <2> %push
    76                              <2> %strlen %$namelength %1
    77                              <2> %if %$namelength > ivfNameLengthLimit
    78                              <2>  %error Expected at most 13-byte name (or adjust isvariable? code)
    79                              <2> %endif
    80                              <2> %if IVS_ONEBYTE && %$namelength != 1
    81                              <2>  %error Expected a one-byte name
    82                              <2> %elif ! IVS_ONEBYTE && %$namelength < 2
    83                              <2>  %error Expected at least a two-byte name
    84                              <2> %endif
    85                              <2> %if IVS_ONEBYTE
    86                              <2>  %define IVS_SINGLE_ONEBYTE_NAME %1
    87                              <2>  %if IVS_HAVE_ONEBYTE
    88                              <2>   %assign IVS_SINGLE_ONEBYTE 0
    89                              <2>  %endif
    90                              <2>  %assign IVS_HAVE_ONEBYTE 1
    91                              <2>  %assign %$namelength 0
    92                              <2>  %xdefine IVS_ONEBYTE_NAMES IVS_ONEBYTE_NAMES, %1
    93                              <2>  %%name equ 0
    94                              <2> %else
    95                              <2>  %assign %$namelength %$namelength - 2
    96                              <2>  %substr %$nametrailer %1 3,-1
    97                              <2>  %substr %$nameheader %1 1,2
    98                              <2>  %xdefine IVS_MOREBYTE_NAMEHEADERS IVS_MOREBYTE_NAMEHEADERS, %$nameheader
    99                              <2>  %xdefine ISVARIABLESTRINGS ISVARIABLESTRINGS, %%name:, {db %$nametrailer}
   100                              <2> %endif
   101                              <2> 
   102                              <2> %assign %$varlength %2 - 1	; 0 means one byte, 1 means two bytes,
   103                              <2> 				;  2 means three bytes, 3 means four bytes
   104                              <2> 	istruc ISVARIABLESTRUC
   105                              <2> at ivName,		dw %%name
   106                              <2>  IV_NAME_RELOCATION
   107                              <2> at ivFlags,		dw %$$namelength | (%$$varlength << ivfVarLengthShift) | %3
   108                              <2> at ivAddress,		dw %4
   109                              <2>  IV_ADDRESS_RELOCATION
   110                              <2> at ivSetup,		dw %7
   111                              <2>  IV_SETUP_RELOCATION
   112                              <2> at ivArrayLast,		db %5
   113                              <2> at ivArrayBetween,	db %6
   114                              <2> 	iend
   115                              <2> %pop
   116                              <2> %ifndef SECTION_OF_%7
   117                              <2>  %error Unknown target section for symbol %7
   118                              <2> %elifnidni %[SECTION_OF_%7], _EXPR_SECTION
   119                              <2>  %error Wrong section for symbol %7: section_of=SECTION_OF_%7, expr=_EXPR_SECTION
   120                              <2> %endif
   121                              <2> 	%endmacro
   122                              <2> 
   123                              <2> %define IV_NAME_RELOCATION
   124                              <2> %define IV_ADDRESS_RELOCATION
   125                              <2> %define IV_SETUP_RELOCATION
   126                              <2> 
   127                              <2> 	%macro isvariablestrings 2-*.nolist
   128                              <2> %rep %0
   129                              <2>  %1
   130                              <2>  %rotate 1
   131                              <2> %endrep
   132                              <2> 	%endmacro
   877                              <1> 
   878                              <1> 
   879                              <1> %include "386.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug 386 patch macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2026 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 	numdef LINK, 0
    17                              <2> 
    18                              <2> 	numdef WPT_LABELS, 0
    19                              <2> 		; This used to be required, because CODESECTIONFIXUP used
    20                              <2> 		;  ldebug_data_entry_size, which is not yet defined during
    21                              <2> 		;  assembling of (most) lDEBUG_CODE fragments.
    22                              <2> 		; However, assembling DebugX with this option selected
    23                              <2> 		;  took more than 2 minutes, so the non-label variant
    24                              <2> 		;  is clearly to be preferred when available.
    25                              <2> 		; Now that lDEBUG_CODE has vstart=0 we can use the
    26                              <2> 		;  CODESECTIONFIXUP again and thus disable this option.
    27                              <2> 
    28                              <2> %ifn _LINK
    29                              <2> %define PATCH_NO386_TABLE ""
    30                              <2> %define PATCH_386_TABLE ""
    31                              <2> %define PATCH_NO386_TABLE2 ""
    32                              <2> %define PATCH_386_TABLE2 ""
    33                              <2> %define PATCH_NO386_TABLEENTRY ""
    34                              <2> %define PATCH_386_TABLEENTRY ""
    35                              <2> %endif
    36                              <2> 
    37                              <2> %if _ONLY386
    38                              <2> 		; Default patch macros if only running on 386+.
    39                              <2> %define _386_o32 o32
    40                              <2> %define _386_a32 a32
    41                              <2> %define _386_jmps jmp short
    42                              <2> %define _386_jmpn jmp near
    43                              <2> %define _no386_jmps comment
    44                              <2> %define _no386_jmpn comment
    45                              <2> 	%macro _386 0-1+.nolist
    46                              <2> [cpu 386]			; change CPU type
    47                              <2> 		%1		; write instruction
    48                              <2> __CPU__				; reset CPU type
    49                              <2> 	%endmacro
    50                              <2> %define _no386 comment
    51                              <2> %elif _ONLYNON386
    52                              <2> 		; Default patch macros if only running on non-386.
    53                              <2> %define _386_o32
    54                              <2> %define _386_a32
    55                              <2> %define _386_jmps comment
    56                              <2> %define _386_jmpn comment
    57                              <2> %define _no386_jmps jmp short
    58                              <2> %define _no386_jmpn jmp near
    59                              <2> %define _386 comment
    60                              <2> %define _no386
    61                              <2> %else
    62                              <2> 
    63                              <2> ; These macros are to make DEBUG's 386 support as small as
    64                              <2> ; possible. To achieve this, two patch tables are created
    65                              <2> ; in the initialisation code. One of the tables is used if
    66                              <2> ; the CPU is a 386+, the other one if it isn't. The bytes
    67                              <2> ; pointed to in the used table are over-written with NOP
    68                              <2> ; instructions. (The patched bytes are usually address or
    69                              <2> ; operand size prefixes or jumps that branch to 386/non-386
    70                              <2> ; code.)
    71                              <2> 
    72                              <2> ; There are a few special patches that require the
    73                              <2> ; initialisation code to write specific bytes other than
    74                              <2> ; NOP instructions for lower resident memory usage.
    75                              <2> ; Two are in the run: code, three in pmentry.asm.
    76                              <2> 
    77                              <2> %if _LINK
    78                              <2> 
    79                              <2> %imacro wllist 1-3.nolist
    80                              <2> %ifnempty %3
    81                              <2>  %deftok %%filenametoken %3
    82                              <2> %else
    83                              <2>  %deftok %%filenametoken __FILE__
    84                              <2> %endif
    85                              <2>  global ..@wllist_%1?%[%%l]%[%%filenametoken]
    86                              <2> ..@wllist_%1?%[%%l]%[%%filenametoken]: %2
    87                              <2> %endmacro
    88                              <2> 
    89                              <2> 	%macro patch386 2-3.nolist 1
    90                              <2> %define %%repeat
    91                              <2> %if %3 != 1
    92                              <2>  %define %%repeat r%3_
    93                              <2> %endif
    94                              <2> %ifidn _CURRENT_SECTION, lDEBUG_CODE
    95                              <2>  wllist %[%%repeat]Lpatch_%{1}386_table, %2
    96                              <2> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
    97                              <2>  wllist %[%%repeat]Lpatch_%{1}386_table2, %2
    98                              <2> %elifidn _CURRENT_SECTION, lDEBUG_DATA_ENTRY
    99                              <2>  wllist %[%%repeat]Lpatch_%{1}386_tableentry, %2
   100                              <2> %else
   101                              <2>  %error Wrong section
   102                              <2> %endif
   103                              <2> 	%endmacro
   104                              <2> 
   105                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   106                              <2> 	%macro _386_o32 0-1+.nolist
   107                              <2> _386		o32
   108                              <2> 		%1
   109                              <2> 	%endmacro
   110                              <2> 
   111                              <2> 		; Address size 32-bit prefix if 386+ CPU
   112                              <2> 	%macro _386_a32 0-1+.nolist
   113                              <2> _386		a32
   114                              <2> 		%1
   115                              <2> 	%endmacro
   116                              <2> 
   117                              <2> 		; Short jump if 386+ CPU
   118                              <2> 	%macro _386_jmps 1.nolist
   119                              <2> _386		jmp short %1
   120                              <2> 	%endmacro
   121                              <2> 
   122                              <2> 		; Near jump if 386+ CPU
   123                              <2> 	%macro _386_jmpn 1.nolist
   124                              <2> _386		jmp near %1
   125                              <2> 	%endmacro
   126                              <2> 
   127                              <2> 		; Short jump if no 386+ CPU
   128                              <2> 	%macro _no386_jmps 1.nolist
   129                              <2> _no386		jmp short %1
   130                              <2> 	%endmacro
   131                              <2> 
   132                              <2> 		; Near jump if no 386+ CPU
   133                              <2> 	%macro _no386_jmpn 1.nolist
   134                              <2> _no386		jmp near %1
   135                              <2> 	%endmacro
   136                              <2> 
   137                              <2> 		; Instruction if 386+ CPU
   138                              <2> 	%macro _386 0-1+.nolist
   139                              <2> [cpu 386]			; change CPU type
   140                              <2> %%entry:
   141                              <2> 		%1		; write instruction
   142                              <2> __CPU__				; reset CPU type
   143                              <2> %assign %%length ($ - %%entry)
   144                              <2>  patch386 no, equ %%entry, %%length
   145                              <2> 	%endmacro
   146                              <2> 
   147                              <2> 		; Instruction if no 386+ CPU
   148                              <2> 	%macro _no386 0-1+.nolist
   149                              <2> %%entry:
   150                              <2> 		%1		; write instruction
   151                              <2> %assign %%length ($ - %%entry)
   152                              <2>  patch386 , equ %%entry, %%length
   153                              <2> 	%endmacro
   154                              <2> 
   155                              <2> %else
   156                              <2> 	%macro patch386 2+.nolist
   157                              <2> %ifidn _CURRENT_SECTION, lDEBUG_CODE
   158                              <2>  %define PATCH_%{1}386_TABLE %[PATCH_%{1}386_TABLE], %2
   159                              <2> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
   160                              <2>  %define PATCH_%{1}386_TABLE2 %[PATCH_%{1}386_TABLE2], %2
   161                              <2> %elifidn _CURRENT_SECTION, lDEBUG_DATA_ENTRY
   162                              <2>  %define PATCH_%{1}386_TABLEENTRY %[PATCH_%{1}386_TABLEENTRY], %2
   163                              <2> %else
   164                              <2>  %error Wrong section
   165                              <2> %endif
   166                              <2> 	%endmacro
   167                              <2> 
   168                              <2> %if _WPT_LABELS
   169                              <2> 	; These forms provide verbose info by defining a
   170                              <2> 	; meaningful label for each patch. That fills up
   171                              <2> 	; the map file and might take longer though.
   172                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   173                              <2> 	%macro _386_o32 0-1+.nolist
   174                              <2> %%386_o32:	o32
   175                              <2> patch386 NO, %%386_o32
   176                              <2> 		%1
   177                              <2> 	%endmacro
   178                              <2> 
   179                              <2> 		; Address size 32-bit prefix if 386+ CPU
   180                              <2> 	%macro _386_a32 0-1+.nolist
   181                              <2> %%386_a32:	a32
   182                              <2> patch386 NO, %%386_a32
   183                              <2> 		%1
   184                              <2> 	%endmacro
   185                              <2> 
   186                              <2> 		; Short jump if 386+ CPU
   187                              <2> 	%macro _386_jmps 1.nolist
   188                              <2> %%386_jmps:	jmp short %1
   189                              <2> patch386 NO, %%386_jmps,%%386_jmps+1
   190                              <2> 	%endmacro
   191                              <2> 
   192                              <2> 		; Near jump if 386+ CPU
   193                              <2> 	%macro _386_jmpn 1.nolist
   194                              <2> %%386_jmpn:	jmp near %1
   195                              <2> patch386 NO, %%386_jmpn,%%386_jmpn+1,%%386_jmpn+2
   196                              <2> 	%endmacro
   197                              <2> 
   198                              <2> 		; Short jump if no 386+ CPU
   199                              <2> 	%macro _no386_jmps 1.nolist
   200                              <2> %%no386_jmps:	jmp short %1
   201                              <2> patch386 , %%no386_jmps,%%no386_jmps+1
   202                              <2> 	%endmacro
   203                              <2> 
   204                              <2> 		; Near jump if no 386+ CPU
   205                              <2> 	%macro _no386_jmpn 1.nolist
   206                              <2> %%no386_jmpn:	jmp near %1
   207                              <2> patch386 , %%no386_jmpn,%%no386_jmpn+1,%%no386_jmpn+2
   208                              <2> 	%endmacro
   209                              <2> 
   210                              <2> 		; Instruction if 386+ CPU
   211                              <2> 	%macro _386 0-1+.nolist
   212                              <2> [cpu 386]			; change CPU type
   213                              <2> %%386_instr:	%1		; write instruction
   214                              <2> __CPU__				; reset CPU type
   215                              <2> 
   216                              <2> %assign %%INSTRCOUNT 0
   217                              <2> %rep $-%%386_instr		; count size of instruction
   218                              <2>  patch386 NO, %%386_instr+%[%%INSTRCOUNT]
   219                              <2> 				; write a patch for each byte
   220                              <2>  %assign %%INSTRCOUNT %%INSTRCOUNT+1
   221                              <2> %endrep
   222                              <2> %undef %%INSTRCOUNT
   223                              <2> 	%endmacro
   224                              <2> 
   225                              <2> 		; Instruction if no 386+ CPU
   226                              <2> 	%macro _no386 0-1+.nolist
   227                              <2> %%no386_instr:	%1		; write instruction
   228                              <2> 
   229                              <2> %assign %%INSTRCOUNT 0
   230                              <2> %rep $-%%no386_instr		; count size of instruction
   231                              <2>  patch386 , %%no386_instr+%[%%INSTRCOUNT]
   232                              <2> 				; write a patch for each byte
   233                              <2>  %assign %%INSTRCOUNT %%INSTRCOUNT+1
   234                              <2> %endrep
   235                              <2> %undef %%INSTRCOUNT
   236                              <2> 	%endmacro
   237                              <2> %else	; _WPT_LABELS
   238                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   239                              <2> 	%macro _386_o32 0-1+.nolist
   240                              <2> _386		o32
   241                              <2> 		%1
   242                              <2> 	%endmacro
   243                              <2> 
   244                              <2> 		; Address size 32-bit prefix if 386+ CPU
   245                              <2> 	%macro _386_a32 0-1+.nolist
   246                              <2> _386		a32
   247                              <2> 		%1
   248                              <2> 	%endmacro
   249                              <2> 
   250                              <2> 		; Short jump if 386+ CPU
   251                              <2> 	%macro _386_jmps 1.nolist
   252                              <2> _386		jmp short %1
   253                              <2> 	%endmacro
   254                              <2> 
   255                              <2> 		; Near jump if 386+ CPU
   256                              <2> 	%macro _386_jmpn 1.nolist
   257                              <2> _386		jmp near %1
   258                              <2> 	%endmacro
   259                              <2> 
   260                              <2> 		; Short jump if no 386+ CPU
   261                              <2> 	%macro _no386_jmps 1.nolist
   262                              <2> _no386		jmp short %1
   263                              <2> 	%endmacro
   264                              <2> 
   265                              <2> 		; Near jump if no 386+ CPU
   266                              <2> 	%macro _no386_jmpn 1.nolist
   267                              <2> _no386		jmp near %1
   268                              <2> 	%endmacro
   269                              <2> 
   270                              <2> 		; Instruction if 386+ CPU
   271                              <2> 	%macro _386 0-1+.nolist
   272                              <2> %push
   273                              <2> [cpu 386]			; change CPU type
   274                              <2> %assign %$entry $ + _CURRENT_SECTION %+ FIXUP
   275                              <2> 		%1		; write instruction
   276                              <2> __CPU__				; reset CPU type
   277                              <2> 
   278                              <2> %rep ($ + _CURRENT_SECTION %+ FIXUP) - %$entry
   279                              <2> 				; count size of instruction
   280                              <2>  patch386 NO, %[%$entry]	; write a patch for each byte
   281                              <2>  %assign %$entry %$entry+1
   282                              <2> %endrep
   283                              <2> %pop
   284                              <2> 	%endmacro
   285                              <2> 
   286                              <2> 		; Instruction if no 386+ CPU
   287                              <2> 	%macro _no386 0-1+.nolist
   288                              <2> %push
   289                              <2> %assign %$entry $ + _CURRENT_SECTION %+ FIXUP
   290                              <2> 		%1		; write instruction
   291                              <2> 
   292                              <2> %rep ($ + _CURRENT_SECTION %+ FIXUP) - %$entry
   293                              <2> 				; count size of instruction
   294                              <2>  patch386 , %[%$entry]		; write a patch for each byte
   295                              <2>  %assign %$entry %$entry+1
   296                              <2> %endrep
   297                              <2> %pop
   298                              <2> 	%endmacro
   299                              <2> %endif	; _WPT_LABELS
   300                              <2> %endif	; _LINK
   301                              <2> 
   302                              <2> %endif
   303                              <2> 
   304                              <2> 		; Patch macros but for cases where the 386+
   305                              <2> 		; instructions should only be generated for
   306                              <2> 		; DEBUGX (i.e. for 32-bit DPMI addressing code).
   307                              <2> %if _PM
   308                              <2> %define _386_PM_o32	_386_o32
   309                              <2> %define _386_PM_a32	_386_a32
   310                              <2> %define _386_PM_jmps	_386_jmps
   311                              <2> %define _386_PM_jmpn	_386_jmpn
   312                              <2> %define _386_PM		_386
   313                              <2> %else
   314                              <2> %define _386_PM_o32
   315                              <2> %define _386_PM_a32
   316                              <2> %define _386_PM_jmps	comment
   317                              <2> %define _386_PM_jmpn	comment
   318                              <2> %define _386_PM		comment
   319                              <2> %endif
   320                              <2> 
   321                              <2> 
   322                              <2> %ifn _LINK
   323                              <2> %macro __writepatchtable2 0-*.nolist
   324                              <2> %if %0 & 1
   325                              <2>  %fatal Expected even number of arguments
   326                              <2> %endif
   327                              <2> %rep %0 >> 1
   328                              <2> 	%1 %2
   329                              <2> %rotate 2
   330                              <2> %endrep
   331                              <2> %endmacro
   332                              <2> 
   333                              <2> %macro __patchtable2_entry 0.nolist
   334                              <2>   ; only if this isn't the first (pseudo-)entry
   335                              <2>   %if %$lastcount != 0
   336                              <2>     %assign %$runscount %[%$runscount]+1
   337                              <2>    ; if the offset from %$previous is less than 255
   338                              <2>    %if (%$last-%$previous) < 255
   339                              <2>     %assign %$$method2tablesize %$$method2tablesize+1
   340                              <2>     ; then write a single byte (number of bytes not to patch between)
   341                              <2>     %xdefine %$$method2list %$$method2list,db,%$last-%$previous
   342                              <2>    %else
   343                              <2>     ; otherwise write a 255 ("reposition") and write the 16-bit address afterwards
   344                              <2>     %assign %$$method2tablesize %$$method2tablesize+3
   345                              <2>     %xdefine %$$method2list %$$method2list,db,255,dw,%$last
   346                              <2>     %assign %$reposcount %[%$reposcount]+1
   347                              <2>    %endif
   348                              <2>    %if %$lastcount == 1
   349                              <2>     %assign %$onecount %[%$onecount]+1
   350                              <2>    %endif
   351                              <2>    %assign %$$method2tablesize %$$method2tablesize+1
   352                              <2>    ; and write the number of bytes to be patched
   353                              <2>    %xdefine %$$method2list %$$method2list,db,%$lastcount
   354                              <2>    ; define %$previous for the next entry: it points to the next non-patched byte
   355                              <2>    %define %$previous (%[%$last]+%[%$lastcount])
   356                              <2>   %endif
   357                              <2> %endmacro
   358                              <2> 
   359                              <2> %macro writepatchtable 2-*.nolist
   360                              <2> 
   361                              <2> 	numdef %{1}_FORCE_METHOD, 0
   362                              <2> %push
   363                              <2> 		; Determine length of simple table:
   364                              <2> %assign %$method1tablesize (%0 - 2)*2
   365                              <2> 
   366                              <2> %if !_%{1}_FORCE_METHOD || _%{1}_FORCE_METHOD == 2
   367                              <2> 		; Determine length of complicated table:
   368                              <2> %assign %$method2tablesize 0
   369                              <2> %define %$method2list db,""
   370                              <2> %push
   371                              <2> %if _WPT_LABELS
   372                              <2>  %define %$previous code_start	; if list contains labels
   373                              <2> %else
   374                              <2>  %define %$previous 0
   375                              <2> %endif
   376                              <2> %define %$last %[%$previous]
   377                              <2> %assign %$lastcount 0
   378                              <2> %assign %$onecount 0
   379                              <2> %assign %$reposcount 0
   380                              <2> %assign %$bytescount %0 - 2
   381                              <2> %assign %$runscount 0
   382                              <2> %rotate 1
   383                              <2> %rep %0 - 2
   384                              <2>  %rotate 1
   385                              <2>  ;if  it continues the previous patch   and not too long   and this isn't the first
   386                              <2>  %if ((%$last+%$lastcount) == %1) && (%$lastcount < 255) && (%$lastcount != 0)
   387                              <2>   ; then do not write an entry, just increase the patch's size
   388                              <2>   %assign %$lastcount %[%$lastcount]+1
   389                              <2>  %else
   390                              <2>   ; otherwise write the last entry
   391                              <2>   __patchtable2_entry
   392                              <2>   ; define new %$last to this parameter, %$lastcount to one
   393                              <2>   %define %$last %1
   394                              <2>   %assign %$lastcount 1
   395                              <2>  %endif
   396                              <2> %endrep
   397                              <2> __patchtable2_entry
   398                              <2> 
   399                              <2> ; at the end, there's a patch with offset 0, size 0
   400                              <2> %assign %$$method2tablesize %$$method2tablesize+2
   401                              <2> %xdefine %$$method2list %$$method2list,db,0,db,0
   402                              <2> 
   403                              <2> %assign %$$onecount %$onecount
   404                              <2> %assign %$$reposcount %$reposcount
   405                              <2> %assign %$$bytescount %$bytescount
   406                              <2> %assign %$$runscount %$runscount
   407                              <2> %pop
   408                              <2> %rotate 1
   409                              <2> %endif
   410                              <2> 
   411                              <2> %if _%{1}_FORCE_METHOD == 2
   412                              <2>  %define __%{1}_method 2
   413                              <2> %elif _%{1}_FORCE_METHOD == 1
   414                              <2>  %define __%{1}_method 1
   415                              <2> %else
   416                              <2>  %if _%{1}_FORCE_METHOD
   417                              <2>   %fatal Invalid forced method selected: _%{1}_FORCE_METHOD
   418                              <2>  %endif
   419                              <2>  %if %$method1tablesize > (%$method2tablesize+20)
   420                              <2>   %define __%{1}_method 2
   421                              <2>  %else
   422                              <2>   %define __%{1}_method 1
   423                              <2>  %endif
   424                              <2> %endif
   425                              <2> 
   426                              <2> 
   427                              <2> %1:
   428                              <2> %if __%{1}_method == 2
   429                              <2> 	__writepatchtable2 %$method2list
   430                              <2> 	endarea %1
   431                              <2> %assign %$size %1_size
   432                              <2> %warning %1: %$size bytes (Method 2)
   433                              <2> %warning 1B=%$onecount repo=%$reposcount run=%$runscount byte=%$bytescount
   434                              <2> %else
   435                              <2> %rotate 1
   436                              <2> %rep %0 - 2
   437                              <2> %rotate 1
   438                              <2> 	dw %1
   439                              <2> %endrep
   440                              <2> %rotate 1
   441                              <2> 	endarea %1
   442                              <2> %assign %$size %1_size
   443                              <2> %warning %1: %$size bytes (Method 1)
   444                              <2> %1.amount equ %1_size_w
   445                              <2> %endif
   446                              <2> %pop
   447                              <2> %endmacro
   448                              <2> %endif
   880                              <1> 
   881                              <1> 
   882                              <1> %if _VDD
   883                              <1> ; standard BOPs for communication with DEBXXVDD on NT platforms
   884                              <1> %macro RegisterModule 0.nolist
   885                              <1> 	db 0C4h, 0C4h, 58h, 0
   886                              <1> 	nop
   887                              <1> %endmacro
   888                              <1> %macro UnRegisterModule 0.nolist
   889                              <1> 	db 0C4h, 0C4h, 58h, 1
   890                              <1> 	nop
   891                              <1> %endmacro
   892                              <1> %macro DispatchCall 0.nolist
   893                              <1> 	db 0C4h, 0C4h, 58h, 2
   894                              <1> 	nop
   895                              <1> %endmacro
   896                              <1> %endif
   897                              <1> 
   898                              <1> %assign CODE_INSURE_COUNT 0
   899                              <1> 
   900                              <1> 		; The entry_to_code_seg/_sel dispatcher in lDEBUG_DATA_ENTRY
   901                              <1> 		;  detects mistaken debugger breakpoints in its
   902                              <1> 		;  in-code-parameter by checking for a low-byte
   903                              <1> 		;  value equal to 0CCh (one-byte int3 opcode).
   904                              <1> 		; Therefore, we insure that all destinations jumped to
   905                              <1> 		;  via that dispatcher do not happen to be located
   906                              <1> 		;  on an offset that gives 0CCh in the low byte.
   907                              <1> 	%imacro code_insure_low_byte_not_0CCh 0.nolist
   908                              <1> %ifn _LINK
   909                              <1>  %if (($ - _CURRENT_SECTION %+ _start) & 0FFh) == 0CCh
   910                              <1> 	nop
   911                              <1>   %assign CODE_INSURE_COUNT 1 + CODE_INSURE_COUNT
   912                              <1>  %endif
   913                              <1> %endif
   914                              <1> 	%endmacro
   915                              <1> 
   916                              <1> 
   917                              <1> 		; dual code segments
   918                              <1> %if _DUALCODE && _PM
   919                              <1> 
   920                              <1> %if _DEBUG
   921                              <1> %idefine dualfunction comment
   922                              <1> %else
   923                              <1> %idefine dualfunction code_insure_low_byte_not_0CCh
   924                              <1> %endif
   925                              <1> 
   926                              <1> %idefine dualreturn call _CURRENT_SECTION %+ _dualret_helper
   927                              <1> %idefine dualdistance far
   928                              <1> 	%imacro dualcall 1.nolist
   929                              <1> %ifndef SECTION_OF_%1
   930                              <1>  %error Unknown target section for symbol %1
   931                              <1> %endif
   932                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _dualcall_helper
   933                              <1>  %if _DEBUG
   934                              <1> 	jmp strict short %%skipdata
   935                              <1>  %endif
   936                              <1> 	dw %1
   937                              <1> %%skipdata:
   938                              <1> 	%endmacro
   939                              <1> 	%imacro nearcall 1.nolist
   940                              <1> %ifndef SECTION_OF_%1
   941                              <1>  %error Unknown target section for symbol %1
   942                              <1> %endif
   943                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
   944                              <1> 	call %1
   945                              <1> %else
   946                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _nearcall_helper
   947                              <1>  %if _DEBUG
   948                              <1> 	jmp strict short %%skipdata
   949                              <1>  %endif
   950                              <1> 	dw %1
   951                              <1> %%skipdata:
   952                              <1> %endif
   953                              <1> 	%endmacro
   954                              <1> 
   955                              <1> %elif _DUALCODE && ! _PM
   956                              <1> 
   957                              <1> %idefine dualfunction comment
   958                              <1> %idefine dualreturn
   959                              <1> %idefine dualdistance far
   960                              <1> 
   961                              <1> %ifn _LINK
   962                              <1> %define PATCH_RELOCATE_FROM_lDEBUG_CODE ""
   963                              <1> %define PATCH_RELOCATE_FROM_lDEBUG_CODE2 ""
   964                              <1> 	%imacro dualcall 1.nolist
   965                              <1> %ifndef SECTION_OF_%1
   966                              <1>  %error Unknown target section for symbol %1
   967                              <1> %endif
   968                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
   969                              <1> 	push cs
   970                              <1> 	call %1
   971                              <1> %else
   972                              <1> 	call relocatedzero:%1
   973                              <1> %push
   974                              <1> %assign %$entry ($ + _CURRENT_SECTION %+ FIXUP) - 2
   975                              <1> 	relocatelist _CURRENT_SECTION, %$entry
   976                              <1> %pop
   977                              <1> %endif
   978                              <1> 	%endmacro
   979                              <1> 	%imacro relocatelist 2.nolist
   980                              <1>  %define PATCH_RELOCATE_FROM_%1 %[PATCH_RELOCATE_FROM_%1],%2
   981                              <1> 	%endmacro
   982                              <1> %else		; _LINK
   983                              <1> 	%idefine dualcall dualcall_with_filename __FILE__,
   984                              <1> 	%imacro dualcall_with_filename 2.nolist
   985                              <1> %ifndef SECTION_OF_%2
   986                              <1>  %error Unknown target section for symbol %2
   987                              <1> %endif
   988                              <1> %ifidni %[SECTION_OF_%2], _CURRENT_SECTION
   989                              <1> 	push cs
   990                              <1> 	call %2
   991                              <1> %else
   992                              <1> 	call relocatedzero:%2
   993                              <1> %ifidn _CURRENT_SECTION, lDEBUG_CODE
   994                              <1>  wllist Lrelocate_from_code, equ $ - 2, %1
   995                              <1> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
   996                              <1>  wllist Lrelocate_from_code2, equ $ - 2, %1
   997                              <1> %else
   998                              <1>  %error Wrong section
   999                              <1> %endif
  1000                              <1> %endif
  1001                              <1> 	%endmacro
  1002                              <1> %endif		; _LINK
  1003                              <1>  %if _DUALCODENEARDUAL
  1004                              <1> 
  1005                              <1> %if _LINK
  1006                              <1> 	%idefine nearcall nearcall_with_filename __FILE__,
  1007                              <1> 	%imacro nearcall_with_filename 2
  1008                              <1> %ifndef SECTION_OF_%2
  1009                              <1>  %error Unknown target section for symbol %2
  1010                              <1> %endif
  1011                              <1> %ifidni %[SECTION_OF_%2], _CURRENT_SECTION
  1012                              <1> 	call %2
  1013                              <1> %else
  1014                              <1>  %push
  1015                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1016                              <1>  %xdefine %$targetsection SECTION_OF_%2
  1017                              <1>  %deftok %%filenametoken SOURCEFILENAME
  1018                              <1>   %ifndef NEARCALL_THUNK_TO_%2%[%%filenametoken]
  1019                              <1> 	hiddenusesection %$targetsection
  1020                              <1> %define NEARCALL_THUNK_TO_%2%[%%filenametoken] %%nearcall_thunk_to_%2%[%%filenametoken]
  1021                              <1> section_of %%nearcall_thunk_to_%2%[%%filenametoken]
  1022                              <1> dualfunction
  1023                              <1> %%nearcall_thunk_to_%2%[%%filenametoken]:
  1024                              <1> 	call %2
  1025                              <1> 	dualreturn
  1026                              <1> 	retf
  1027                              <1> 
  1028                              <1> 	hiddenusesection %$originalsection
  1029                              <1>   %endif
  1030                              <1>  %pop
  1031                              <1> 	dualcall_with_filename %1, NEARCALL_THUNK_TO_%2%[%%filenametoken]
  1032                              <1> %endif
  1033                              <1> 	%endmacro
  1034                              <1> %elif _LINK_COMPAT	; _LINK
  1035                              <1> 	%imacro nearcall 1
  1036                              <1> %ifndef SECTION_OF_%1
  1037                              <1>  %error Unknown target section for symbol %1
  1038                              <1> %endif
  1039                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1040                              <1> 	call %1
  1041                              <1> %else
  1042                              <1>  %push
  1043                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1044                              <1>  %xdefine %$targetsection SECTION_OF_%1
  1045                              <1>  %deftok %%filenametoken SOURCEFILENAME
  1046                              <1>   %ifndef NEARCALL_THUNK_TO_%1%[%%filenametoken]
  1047                              <1> 	hiddenusesection %$targetsection
  1048                              <1> %define NEARCALL_THUNK_TO_%1%[%%filenametoken] %%nearcall_thunk_to_%1%[%%filenametoken]
  1049                              <1> section_of %%nearcall_thunk_to_%1%[%%filenametoken]
  1050                              <1> dualfunction
  1051                              <1> %%nearcall_thunk_to_%1%[%%filenametoken]:
  1052                              <1> 	call %1
  1053                              <1> 	dualreturn
  1054                              <1> 	retf
  1055                              <1> 
  1056                              <1> 	hiddenusesection %$originalsection
  1057                              <1>   %endif
  1058                              <1>  %pop
  1059                              <1> 	dualcall NEARCALL_THUNK_TO_%1%[%%filenametoken]
  1060                              <1> %endif
  1061                              <1> 	%endmacro
  1062                              <1> %else		; _LINK, _LINK_COMPAT
  1063                              <1> 	%imacro nearcall 1
  1064                              <1> %ifndef SECTION_OF_%1
  1065                              <1>  %error Unknown target section for symbol %1
  1066                              <1> %endif
  1067                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1068                              <1> 	call %1
  1069                              <1> %else
  1070                              <1>  %push
  1071                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1072                              <1>  %xdefine %$targetsection SECTION_OF_%1
  1073                              <1>   %ifndef NEARCALL_THUNK_TO_%1
  1074                              <1> 	hiddenusesection %$targetsection
  1075                              <1> %define NEARCALL_THUNK_TO_%1 %%nearcall_thunk_to_%1
  1076                              <1> section_of %%nearcall_thunk_to_%1
  1077                              <1> dualfunction
  1078                              <1> %%nearcall_thunk_to_%1:
  1079                              <1> 	call %1
  1080                              <1> 	dualreturn
  1081                              <1> 	retf
  1082                              <1> 
  1083                              <1> 	hiddenusesection %$originalsection
  1084                              <1>   %endif
  1085                              <1>  %pop
  1086                              <1> 	dualcall NEARCALL_THUNK_TO_%1
  1087                              <1> %endif
  1088                              <1> 	%endmacro
  1089                              <1> %endif		; _LINK, _LINK_COMPAT
  1090                              <1>  %else
  1091                              <1> 	%imacro nearcall 1.nolist
  1092                              <1> %ifndef SECTION_OF_%1
  1093                              <1>  %error Unknown target section for symbol %1
  1094                              <1> %endif
  1095                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1096                              <1> 	call %1
  1097                              <1> %else
  1098                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _nearcall_helper
  1099                              <1>  %if _DEBUG
  1100                              <1> 	jmp strict short %%skipdata
  1101                              <1>  %endif
  1102                              <1> 	dw %1
  1103                              <1> %%skipdata:
  1104                              <1> %endif
  1105                              <1> 	%endmacro
  1106                              <1>  %endif
  1107                              <1> %elif ! _DUALCODE
  1108                              <1> 
  1109                              <1> %idefine dualfunction comment
  1110                              <1> %idefine dualreturn
  1111                              <1> %idefine dualdistance near
  1112                              <1> 	%imacro dualcall 1.nolist
  1113                              <1> 	call %1
  1114                              <1> 	%endmacro
  1115                              <1> 	%imacro nearcall 1.nolist
  1116                              <1> 	call %1
  1117                              <1> 	%endmacro
  1118                              <1> %assign _SYMBOLICDUALCODE 0
  1119                              <1> %assign _SYMBOLASMDUALCODE 0
  1120                              <1> 
  1121                              <1> %else
  1122                              <1>  %error Unexpected defines
  1123                              <1> %endif
  1124                              <1> 
  1125                              <1> %ifn _SYMBOLICDUALCODE
  1126                              <1>  %assign _SYMBOLASMDUALCODE 0
  1127                              <1> %endif
  1128                              <1> 
  1129                              <1>  %if _SYMBOLIC && _DUALCODE && _SYMBOLASMDUALCODE
  1130                              <1> %idefine dual2function	dualfunction
  1131                              <1> %idefine dual2return	dualreturn
  1132                              <1> %idefine dual2distance	dualdistance
  1133                              <1> %idefine dual2call	dualcall
  1134                              <1>  %else
  1135                              <1> %idefine dual2function comment
  1136                              <1> %idefine dual2return
  1137                              <1> %idefine dual2distance near
  1138                              <1> 	%imacro dual2call 1.nolist
  1139                              <1> 	call %1
  1140                              <1> 	%endmacro
  1141                              <1>  %endif
  1142                              <1> 
  1143                              <1> 
  1144                              <1> 	numdef CHECKSECTION, 0
  1145                              <1> 	numdef CHECKCALLSECTION, _CHECKSECTION
  1146                              <1> 	numdef CHECKJMPSECTION, _CHECKSECTION
  1147                              <1> 	numdef CHECKJCCSECTION, _CHECKSECTION
  1148                              <1> 
  1149                              <1> %if _CHECKCALLSECTION
  1150                              <1> 	%imacro call 1.nolist
  1151                              <1> 	%? %1
  1152                              <1> checksection %1, %?, call
  1153                              <1> 	%endmacro
  1154                              <1> %endif
  1155                              <1> %if _CHECKJMPSECTION
  1156                              <1> 	%imacro jmp 1.nolist
  1157                              <1> 	%? %1
  1158                              <1> checksection %1, %?, jmp
  1159                              <1> 	%endmacro
  1160                              <1> %endif
  1161                              <1> %if _CHECKJCCSECTION
  1162                              <1> 	%imacro je 1.nolist
  1163                              <1> 	%? %1
  1164                              <1> checksection %1, %?, jcc
  1165                              <1> 	%endmacro
  1166                              <1> 	%imacro jne 1.nolist
  1167                              <1> 	%? %1
  1168                              <1> checksection %1, %?, jcc
  1169                              <1> 	%endmacro
  1170                              <1> 	%imacro jz 1.nolist
  1171                              <1> 	%? %1
  1172                              <1> checksection %1, %?, jcc
  1173                              <1> 	%endmacro
  1174                              <1> 	%imacro jnz 1.nolist
  1175                              <1> 	%? %1
  1176                              <1> checksection %1, %?, jcc
  1177                              <1> 	%endmacro
  1178                              <1> 
  1179                              <1> 	%imacro jb 1.nolist
  1180                              <1> 	%? %1
  1181                              <1> checksection %1, %?, jcc
  1182                              <1> 	%endmacro
  1183                              <1> 	%imacro jnb 1.nolist
  1184                              <1> 	%? %1
  1185                              <1> checksection %1, %?, jcc
  1186                              <1> 	%endmacro
  1187                              <1> 	%imacro jbe 1.nolist
  1188                              <1> 	%? %1
  1189                              <1> checksection %1, %?, jcc
  1190                              <1> 	%endmacro
  1191                              <1> 	%imacro jnbe 1.nolist
  1192                              <1> 	%? %1
  1193                              <1> checksection %1, %?, jcc
  1194                              <1> 	%endmacro
  1195                              <1> 	%imacro jc 1.nolist
  1196                              <1> 	%? %1
  1197                              <1> checksection %1, %?, jcc
  1198                              <1> 	%endmacro
  1199                              <1> 	%imacro jnc 1.nolist
  1200                              <1> 	%? %1
  1201                              <1> checksection %1, %?, jcc
  1202                              <1> 	%endmacro
  1203                              <1> 	%imacro ja 1.nolist
  1204                              <1> 	%? %1
  1205                              <1> checksection %1, %?, jcc
  1206                              <1> 	%endmacro
  1207                              <1> 	%imacro jna 1.nolist
  1208                              <1> 	%? %1
  1209                              <1> checksection %1, %?, jcc
  1210                              <1> 	%endmacro
  1211                              <1> 	%imacro jae 1.nolist
  1212                              <1> 	%? %1
  1213                              <1> checksection %1, %?, jcc
  1214                              <1> 	%endmacro
  1215                              <1> 	%imacro jnae 1.nolist
  1216                              <1> 	%? %1
  1217                              <1> checksection %1, %?, jcc
  1218                              <1> 	%endmacro
  1219                              <1> 
  1220                              <1> 	%imacro jl 1.nolist
  1221                              <1> 	%? %1
  1222                              <1> checksection %1, %?, jcc
  1223                              <1> 	%endmacro
  1224                              <1> 	%imacro jnl 1.nolist
  1225                              <1> 	%? %1
  1226                              <1> checksection %1, %?, jcc
  1227                              <1> 	%endmacro
  1228                              <1> 	%imacro jle 1.nolist
  1229                              <1> 	%? %1
  1230                              <1> checksection %1, %?, jcc
  1231                              <1> 	%endmacro
  1232                              <1> 	%imacro jnle 1.nolist
  1233                              <1> 	%? %1
  1234                              <1> checksection %1, %?, jcc
  1235                              <1> 	%endmacro
  1236                              <1> 	%imacro jg 1.nolist
  1237                              <1> 	%? %1
  1238                              <1> checksection %1, %?, jcc
  1239                              <1> 	%endmacro
  1240                              <1> 	%imacro jng 1.nolist
  1241                              <1> 	%? %1
  1242                              <1> checksection %1, %?, jcc
  1243                              <1> 	%endmacro
  1244                              <1> 	%imacro jge 1.nolist
  1245                              <1> 	%? %1
  1246                              <1> checksection %1, %?, jcc
  1247                              <1> 	%endmacro
  1248                              <1> 	%imacro jnge 1.nolist
  1249                              <1> 	%? %1
  1250                              <1> checksection %1, %?, jcc
  1251                              <1> 	%endmacro
  1252                              <1> 
  1253                              <1> 	%imacro jo 1.nolist
  1254                              <1> 	%? %1
  1255                              <1> checksection %1, %?, jcc
  1256                              <1> 	%endmacro
  1257                              <1> 	%imacro jno 1.nolist
  1258                              <1> 	%? %1
  1259                              <1> checksection %1, %?, jcc
  1260                              <1> 	%endmacro
  1261                              <1> 	%imacro jp 1.nolist
  1262                              <1> 	%? %1
  1263                              <1> checksection %1, %?, jcc
  1264                              <1> 	%endmacro
  1265                              <1> 	%imacro jnp 1.nolist
  1266                              <1> 	%? %1
  1267                              <1> checksection %1, %?, jcc
  1268                              <1> 	%endmacro
  1269                              <1> 	%imacro jpe 1.nolist
  1270                              <1> 	%? %1
  1271                              <1> checksection %1, %?, jcc
  1272                              <1> 	%endmacro
  1273                              <1> 	%imacro jnpe 1.nolist
  1274                              <1> 	%? %1
  1275                              <1> checksection %1, %?, jcc
  1276                              <1> 	%endmacro
  1277                              <1> 	%imacro jpo 1.nolist
  1278                              <1> 	%? %1
  1279                              <1> checksection %1, %?, jcc
  1280                              <1> 	%endmacro
  1281                              <1> 	%imacro jnpo 1.nolist
  1282                              <1> 	%? %1
  1283                              <1> checksection %1, %?, jcc
  1284                              <1> 	%endmacro
  1285                              <1> 	%imacro js 1.nolist
  1286                              <1> 	%? %1
  1287                              <1> checksection %1, %?, jcc
  1288                              <1> 	%endmacro
  1289                              <1> 	%imacro jns 1.nolist
  1290                              <1> 	%? %1
  1291                              <1> checksection %1, %?, jcc
  1292                              <1> 	%endmacro
  1293                              <1> 
  1294                              <1> 	%imacro jcxz 1.nolist
  1295                              <1> 	%? %1
  1296                              <1> checksection %1, %?, jcc
  1297                              <1> 	%endmacro
  1298                              <1> 	%imacro jecxz 1.nolist
  1299                              <1> 	%? %1
  1300                              <1> checksection %1, %?, jcc
  1301                              <1> 	%endmacro
  1302                              <1> 	%imacro loop 1.nolist
  1303                              <1> 	%? %1
  1304                              <1> checksection %1, %?, jcc
  1305                              <1> 	%endmacro
  1306                              <1> 	%imacro loopz 1.nolist
  1307                              <1> 	%? %1
  1308                              <1> checksection %1, %?, jcc
  1309                              <1> 	%endmacro
  1310                              <1> 	%imacro loopnz 1.nolist
  1311                              <1> 	%? %1
  1312                              <1> checksection %1, %?, jcc
  1313                              <1> 	%endmacro
  1314                              <1> 	%imacro loope 1.nolist
  1315                              <1> 	%? %1
  1316                              <1> checksection %1, %?, jcc
  1317                              <1> 	%endmacro
  1318                              <1> 	%imacro loopne 1.nolist
  1319                              <1> 	%? %1
  1320                              <1> checksection %1, %?, jcc
  1321                              <1> 	%endmacro
  1322                              <1> %endif
  1323                              <1> 
  1324                              <1> 	%imacro checksection 3.nolist
  1325                              <1> %push
  1326                              <1>  %defstr %$string %1
  1327                              <1>  %substr %$shortword %$string 1, 5
  1328                              <1>  %substr %$shortsep %$string 6, 1
  1329                              <1>  %substr %$nearword %$string 1, 4
  1330                              <1>  %substr %$nearsep %$string 5, 1
  1331                              <1>  %substr %$farword %$string 1, 3
  1332                              <1>  %substr %$farsep %$string 4, 1
  1333                              <1>  %assign %$isshort 0
  1334                              <1>  %ifidni %$shortword, "short"
  1335                              <1>   %if %$shortsep == 32 || %$shortsep == 9
  1336                              <1>    %assign %$isshort 1
  1337                              <1>    %substr %$string %$string 7, -1
  1338                              <1>   %elif %$shortsep == '['
  1339                              <1>    %assign %$isshort 1
  1340                              <1>    %substr %$string %$string 6, -1
  1341                              <1>   %endif
  1342                              <1>  %endif
  1343                              <1>  %assign %$isnear 0
  1344                              <1>  %ifidni %$nearword, "near"
  1345                              <1>   %if %$nearsep == 32 || %$nearsep == 9
  1346                              <1>    %assign %$isnear 1
  1347                              <1>    %substr %$string %$string 6, -1
  1348                              <1>   %elif %$nearsep == '['
  1349                              <1>    %assign %$isnear 1
  1350                              <1>    %substr %$string %$string 5, -1
  1351                              <1>   %endif
  1352                              <1>  %endif
  1353                              <1>  %assign %$isfar 0
  1354                              <1>  %ifidni %$farword, "far"
  1355                              <1>   %if %$farsep == 32 || %$farsep == 9
  1356                              <1>    %assign %$isfar 1
  1357                              <1>    %substr %$string %$string 5, -1
  1358                              <1>   %elif %$farsep == '['
  1359                              <1>    %assign %$isfar 1
  1360                              <1>    %substr %$string %$string 4, -1
  1361                              <1>   %endif
  1362                              <1>  %endif
  1363                              <1> 
  1364                              <1>  %deftok %$token %$string
  1365                              <1> 
  1366                              <1>  %assign %$size 2
  1367                              <1>  %assign %$isreg 0
  1368                              <1>  %assign %$exit 0
  1369                              <1>  %rep 2
  1370                              <1>   %ifn %$exit
  1371                              <1>    %if %$size == 2
  1372                              <1>     %define %$regnames "ax  cx  dx  bx  sp  bp  si  di  "
  1373                              <1>    %elif %$size == 4
  1374                              <1>     %define %$regnames "eax ecx edx ebx esp ebp esi edi "
  1375                              <1>    %endif
  1376                              <1>    %assign %$index 0
  1377                              <1>    %rep 8
  1378                              <1>     %ifn %$exit
  1379                              <1>      %substr %$reg %$regnames %$index * 4 + 1, 4
  1380                              <1>      %deftok %$reg %$reg
  1381                              <1>      %ifnempty %$reg
  1382                              <1>       %ifidni %$reg, %$token
  1383                              <1>        %assign %$isreg %$size
  1384                              <1>        %assign %$exit 1
  1385                              <1>        %exitrep
  1386                              <1>       %endif
  1387                              <1>      %endif
  1388                              <1>     %endif
  1389                              <1>     %assign %$index %$index + 1
  1390                              <1>    %endrep
  1391                              <1>    %if %$exit
  1392                              <1>     %exitrep
  1393                              <1>    %endif
  1394                              <1>    %assign %$size %$size * 2
  1395                              <1>   %endif
  1396                              <1>  %endrep
  1397                              <1> 
  1398                              <1>  %assign %$ismulti 0
  1399                              <1>  %assign %$ismem 0
  1400                              <1>  %strlen %$length %$string
  1401                              <1>  %assign %$ii 0
  1402                              <1>  %rep %$length
  1403                              <1>   %substr %$point %$string %$ii + 1, 1
  1404                              <1>   %if %$point == 32 || %$point == 9
  1405                              <1>    %assign %$ismulti 1
  1406                              <1>   %endif
  1407                              <1>   %ifidn %$point, '['
  1408                              <1>    %assign %$ismem 1
  1409                              <1>   %endif
  1410                              <1>   %assign %$ii %$ii + 1
  1411                              <1>  %endrep
  1412                              <1> 
  1413                              <1>  %assign %$islocal 0
  1414                              <1>  %substr %$point %$string 1, 1
  1415                              <1>  %substr %$prefix %$string 1, 3
  1416                              <1>  %ifidn %$point, '.'
  1417                              <1>   %ifnidn %$prefix, '..@'
  1418                              <1>    %assign %$islocal 1
  1419                              <1>   %endif
  1420                              <1>  %endif
  1421                              <1> 
  1422                              <1>  %if %$isreg
  1423                              <1>   %if %$isreg == 4
  1424                              <1>    %warning 32-bit reg %3: %2 %1
  1425                              <1>   %else
  1426                              <1>    %warning 16-bit reg %3: %2 %1
  1427                              <1>   %endif
  1428                              <1>  %elif %$ismulti || %$ismem
  1429                              <1>   %warning not single %3: %2 %1
  1430                              <1>  %elif %$islocal
  1431                              <1>   %ifidni %3, call
  1432                              <1>    %warning local %3: %2 %1
  1433                              <1>   %endif
  1434                              <1>  %elifdef SECTION_OF_%[%$token]
  1435                              <1>   %ifnidni SECTION_OF_%[%$token], _CURRENT_SECTION
  1436                              <1>    %error Symbol %$token called wrongly: section_of=SECTION_OF_%[%$token], current=_CURRENT_SECTION
  1437                              <1>   %endif
  1438                              <1>  %endif
  1439                              <1> %pop
  1440                              <1> 	%endmacro
  1441                              <1> 
  1442                              <1> 
  1443                              <1> 	struc MEMREF
  1444 00000000 ????????            <1> mrLinear:		resd 1
  1445 00000004 ????????            <1> mrOffset:		resd 1
  1446 00000008 ????                <1> mrSegmentSelector:	resw 1
  1447 0000000A ????                <1> mrFlags:		resw 1
  1448 0000000C ????????            <1> mrLength:		resd 1
  1449                              <1> 	endstruc
  1450                              <1> 
  1451                              <1> 		; Currently only direct branches are allowed when
  1452                              <1> 		;  disassembling from the U command. (That is,
  1453                              <1> 		;  [disflags] & DIS_F_SHOW is clear.) All other
  1454                              <1> 		;  types of references depend on segment registers
  1455                              <1> 		;  and sometimes base and index registers, which are
  1456                              <1> 		;  not known ahead of time. They are only known for
  1457                              <1> 		;  the R command's disassembly. (DIS_F_SHOW set.)
  1458                              <1> 		; (When a mov ss or pop to ss will change ss, a
  1459                              <1> 		;  subsequent instruction using ss will not be
  1460                              <1> 		;  disassembled with the correct ss value.
  1461                              <1> 		;  This should be rare though. We may at a later
  1462                              <1> 		;  point detect this condition and not display
  1463                              <1> 		;  references with ss then.)
  1464                              <1> mrfBranchDirect:	equ    1
  1465                              <1> mrfMem:			equ    2
  1466                              <1> mrfMemSource:		equ    4
  1467                              <1> mrfMemDest:		equ    8
  1468                              <1> mrfA32:			equ   10h
  1469                              <1> mrfString:		equ   20h
  1470                              <1> mrfStringSource:	equ   40h
  1471                              <1> mrfStringDest:		equ   80h
  1472                              <1> mrfUsesSS:		equ  100h
  1473                              <1> mrfBranchIndirect:	equ  200h
  1474                              <1> 
  1475                              <1> 
  1476                              <1> %if _VXCHG && ! _VXCHGBIOS
  1477                              <1> 	struc XMSM
  1478 00000000 ????????            <1> .size_:		resd 1
  1479 00000004 ????                <1> .srchdl:	resw 1
  1480 00000006 ????????            <1> .srcadr:	resd 1
  1481 0000000A ????                <1> .dsthdl:	resw 1
  1482 0000000C ????????            <1> .dstadr:	resd 1
  1483                              <1> 	endstruc
  1484                              <1> %endif
  1485                              <1> 
  1486                              <1> 
  1487                              <1> 	; doscall is used by symbols.asm and run.asm and in
  1488                              <1> 	;  cmd3_close_handle, so define it prior
  1489                              <1> %if _PM && _NOEXTENDER
  1490                              <1> %macro doscall 0
  1491                              <1> 	nearcall _doscall
  1492                              <1> %endmacro
  1493                              <1> %else
  1494                              <1> 		; When we don't support non-extended DPMI all Int21 calls
  1495                              <1> 		; are either in Real Mode or extended (all are real Int21
  1496                              <1> 		; instructions).
  1497                              <1> %macro doscall 0
  1498                              <1> 	int 21h
  1499                              <1> %endmacro
  1500                              <1> %endif
  1501                              <1> 
  1502                              <1> 
  1503                              <1> %if _LINK
  1504                              <1> %imacro wlcalc 1-2.nolist
  1505                              <1> %deftok %%filenametoken __FILE__
  1506                              <1>  global wlcalc_%1?%[%%l]%[%%filenametoken]
  1507                              <1> wlcalc_%1?%[%%l]%[%%filenametoken]: %2
  1508                              <1> %endmacro
  1509                              <1> %endif
  1510                              <1> 
  1511                              <1> %if _BOOTLDR && _LINK
  1512                              <1> %macro lot_equate 2.nolist
  1513                              <1> LOAD_%2 equ %1
  1514                              <1> %endmacro
  1515                              <1> 
  1516                              <1> 	lot_equate    1, SET_DL_UNIT
  1517                              <1> 	lot_equate    2, SET_BL_UNIT
  1518                              <1> 	lot_equate    4, SET_SIDI_CLUSTER
  1519                              <1> 	lot_equate  10h, SET_DSSI_DPT
  1520                              <1> 	lot_equate  20h, PUSH_DPT
  1521                              <1> 	lot_equate  40h, DATASTART_HIDDEN
  1522                              <1> 	lot_equate  80h, SET_AXBX_DATASTART
  1523                              <1> 	lot_equate 100h, SET_DSBP_BPB
  1524                              <1> 	lot_equate 200h, LBA_SET_TYPE
  1525                              <1> 	lot_equate 400h, MESSAGE_TABLE
  1526                              <1> 	lot_equate 800h, SET_AXBX_ROOT_HIDDEN
  1527                              <1> 	lot_equate 1000h, CMDLINE
  1528                              <1> 	lot_equate 2000h, NO_BPB
  1529                              <1> 	lot_equate 4000h, SET_DSSI_PARTINFO
  1530                              <1> %endif
  1531                              <1> 
  1532                              <1> %if _HELP_COMPRESSED
  1533                              <1>  %assign NONCOMPRESSEDFLAG 1
  1534                              <1> %else
  1535                              <1>  %assign NONCOMPRESSEDFLAG 0
  1536                              <1> %endif
  1537                              <1> 
  1538                              <1> [list +]
  1539                              <1> 
  1540                              <1> %if _LINK
  1541                              <1>  %if _ONLY386
  1542                              <1> 	cpu 386
  1543                              <1>  %else
  1544                              <1> 	cpu 8086
  1545                              <1>  %endif
  1546                              <1> 
  1547                              <1> auxbuff_size: equ (_AUXBUFFSIZE+15) & ~15
  1548                              <1> 	endarea auxbuff, 1
  1549                              <1> 
  1550                              <1> auxbuff_max_size: equ (_AUXBUFFMAXSIZE+15) & ~15
  1551                              <1> 	endarea auxbuff_max, 1
  1552                              <1> 
  1553                              <1> %if _INIT_MAX
  1554                              <1>  auxbuff_init_size: equ (_AUXBUFFMAXSIZE+15) & ~15
  1555                              <1> %else
  1556                              <1>  auxbuff_init_size: equ (_AUXBUFFSIZE+15) & ~15
  1557                              <1> %endif
  1558                              <1> 	endarea auxbuff_init, 1
  1559                              <1> 
  1560                              <1>  %include "options.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug options and internal flags
     5                              <2> 
     6                              <2> Copyright (C) 2008-2025 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 
    17                              <2> dispregs32	equ	  1	; RX: 32-bit register display (R, T/P/G)
    18                              <2> traceints	equ	  2	; TM: trace into interrupts (T)
    19                              <2> cpdepchars	equ	  4	; allow dumping of CP-dependent characters (D, DX)
    20                              <2> fakeindos	equ	  8	; always assume InDOS flag non-zero (all)
    21                              <2> nonpagingdevice	equ	 10h	; disallow paged output with [more] prompt (all exc. P, T)
    22                              <2> 	; This option was never used anywhere:
    23                              <2> ; pagingdevice	equ	 20h	; allow paged output with [more] prompt (all exc. P, T)
    24                              <2> 				; paged output is by default on if the output device is StdOut, else off
    25                              <2> hexrn		equ	 40h	; display raw hexadecimal content of FPU registers (RN)
    26                              <2> ;novdd		equ	 80h	; don't use a registered NTVDM VDD (L, W)
    27                              <2> nondospaging	equ	100h	; paging: don't use DOS for input when waiting for a key
    28                              <2> opt1_86mnohlt	equ	200h	; (86 Mode:) HLT doesn't work, don't use it
    29                              <2> biosidles	equ	400h	; don't idle with HLT or Int2F.1680, only call BIOS Int16.00
    30                              <2> opt_usegetinput	equ	800h	; use getinput for int 21h interactive input
    31                              <2> use_si_units	equ    1000h	; in disp_*_size use SI units (kB = 1000, etc)
    32                              <2> use_jedec_units	equ    2000h	; in disp_*_size use JEDEC units (kB = 1024)
    33                              <2> enable_serial	equ    4000h	; enable serial I/O (preferred over DOS or BIOS terminal)
    34                              <2> int8_disable_serial equ	   8000h	; disable serial I/O when breaking due to intr8
    35                              <2> gg_do_not_skip_bp equ	 1_0000h	; gg: do not skip a breakpoint (bb or gg)
    36                              <2> gg_no_autorepeat equ	 2_0000h	; gg: do not auto-repeat
    37                              <2> tp_do_not_skip_bp equ	 4_0000h	; T/TP/P: do not skip a (bb) breakpoint
    38                              <2> gg_bb_hit_no_repeat equ	 8_0000h	; gg: do not auto-repeat after bb hit
    39                              <2> tp_bb_hit_no_repeat equ	10_0000h	; T/TP/P: do not auto-repeat after bb hit
    40                              <2> gg_unexpected_no_repeat equ 20_0000h	; gg: do not auto-repeat after unexpectedinterrupt
    41                              <2> tp_unexpected_no_repeat equ 40_0000h	; T/TP/P
    42                              <2> ss_no_dump:		equ 80_0000h
    43                              <2> %if _SYMBOLIC
    44                              <2> dd_no_blanks_sym:	equ 100_0000h
    45                              <2> zz_no_pm_xms:		equ 200_0000h
    46                              <2> %endif
    47                              <2> rr_disasm_no_rept:	equ 1000_0000h
    48                              <2> rr_disasm_no_show:	equ 2000_0000h
    49                              <2> opt_cmdline_quiet_input:equ 4000_0000h
    50                              <2> opt_cmdline_quiet_output:equ 8000_0000h
    51                              <2> %if _SYMBOLIC
    52                              <2> DEFAULTOPTIONS	equ zz_no_pm_xms
    53                              <2> %else
    54                              <2> DEFAULTOPTIONS	equ 0
    55                              <2> %endif
    56                              <2> 
    57                              <2> 
    58                              <2> opt2_db_header:		equ 1
    59                              <2> opt2_db_trailer:	equ 2
    60                              <2> opt2_dw_header:		equ 10h
    61                              <2> opt2_dw_trailer:	equ 20h
    62                              <2> opt2_dd_header:		equ 100h
    63                              <2> opt2_dd_trailer:	equ 200h
    64                              <2> opt2_getinput_dpmi:	equ 800h
    65                              <2> opt2_hh_compat:		equ 1000h
    66                              <2> opt2_getc_idle:		equ 2000h
    67                              <2> opt2_getc_idle_dpmi:	equ 4000h
    68                              <2> opt2_re_cancel_tpg:	equ 8000h
    69                              <2> opt2_nn_compat:		equ 1_0000h
    70                              <2> opt2_nn_capitalise:	equ 2_0000h
    71                              <2> %if _MS_0RANGE_COMPAT
    72                              <2> opt2_0range_compat:	equ 4_0000h
    73                              <2> %endif
    74                              <2> opt2_rr16_compat:	equ 8_0000h
    75                              <2> opt2_r_prompt_compat:	equ 10_0000h
    76                              <2> opt2_r_separate:	equ 20_0000h
    77                              <2> opt2_r_linebreak_always:equ 40_0000h
    78                              <2> opt2_dpminohlt:		equ 8000_0000h	; DPMI doesn't like hlt
    79                              <2> DEFAULTOPTIONS2	equ opt2_dw_header | opt2_dd_header | opt2_getc_idle_dpmi | opt2_dpminohlt
    80                              <2> 
    81                              <2> 
    82                              <2> opt3_tt_no_paging:	equ 1
    83                              <2> opt3_tp_no_paging:	equ 2
    84                              <2> opt3_pp_no_paging:	equ 4
    85                              <2> opt3_gg_no_paging:	equ 8
    86                              <2> opt3_silence_paging_set:equ 100h
    87                              <2> opt3_silence_paging_on:	equ 200h
    88                              <2> opt3_paging_rc:		equ 1000h
    89                              <2> opt3_paging_yy:		equ 2000h
    90                              <2> opt3_paging_re:		equ 4000h
    91                              <2> opt3_r_highlight_diff:	equ 10000h
    92                              <2> opt3_r_highlight_dumb:	equ 20000h
    93                              <2> opt3_r_highlight_full:	equ 40000h
    94                              <2> opt3_r_highlight_eip:	equ 80000h
    95                              <2> %if _PM
    96                              <2> opt3_ss_b_bit_set:	equ   10_0000h
    97                              <2>  %if _BREAK_INSTALLDPMI
    98                              <2> opt3_break_installdpmi:	equ   20_0000h
    99                              <2>  %endif
   100                              <2> %endif
   101                              <2> %if _DHIGHLIGHT
   102                              <2> opt3_d_highlight:	equ   80_0000h
   103                              <2> %endif
   104                              <2> %if _GETLINEHIGHLIGHT
   105                              <2> opt3_getline_highlight:	equ  100_0000h
   106                              <2> %endif
   107                              <2> opt3_no_idle_2F:	equ  200_0000h
   108                              <2> %if _DELAY_BEFORE_BP
   109                              <2> opt3_delay_before_bp:	equ  400_0000h
   110                              <2> %endif
   111                              <2> opt3_no_call_amis:	equ  800_0000h
   112                              <2> opt3_disable_autorepeat:equ 1000_0000h
   113                              <2> opt3_check_ctrlc_keyb:	equ 2000_0000h
   114                              <2> opt3_check_ctrlc_0bh:	equ 4000_0000h
   115                              <2> opt3_tsr_quit_leave_tf:	equ 8000_0000h
   116                              <2> DEFAULTOPTIONS3	equ opt3_tt_no_paging | opt3_tp_no_paging 		| opt3_pp_no_paging | opt3_gg_no_paging 		| opt3_check_ctrlc_keyb | opt3_check_ctrlc_0bh
   119                              <2> 
   120                              <2> 
   121                              <2> opt4_int_2F_hook:	equ 2
   122                              <2> opt4_int_08_hook:	equ 4
   123                              <2> opt4_int_2D_hook:	equ 8
   124                              <2> %if _CATCHINTFAULTCOND
   125                              <2> opt4_int_fault_hook:	equ 10h
   126                              <2> %endif
   127                              <2> opt4_int_serial_force:	equ 1_0000h
   128                              <2> opt4_int_2F_force:	equ 2_0000h
   129                              <2> opt4_int_08_force:	equ 4_0000h
   130                              <2> opt4_int_2D_force:	equ 8_0000h
   131                              <2> %if _CATCHINT0D
   132                              <2> opt4_int_0D_force:	equ   10_0000h
   133                              <2> %endif
   134                              <2> %if _CATCHINT0C
   135                              <2> opt4_int_0C_force:	equ   20_0000h
   136                              <2> %endif
   137                              <2> opt4_int_00_force:	equ  100_0000h
   138                              <2> opt4_int_01_force:	equ  200_0000h
   139                              <2> opt4_int_03_force:	equ  400_0000h
   140                              <2> opt4_int_06_force:	equ  800_0000h
   141                              <2> opt4_int_18_force:	equ 1000_0000h
   142                              <2> opt4_int_19_force:	equ 2000_0000h
   143                              <2> opt4_int_09_force:	equ 4000_0000h	; not used at the same time as 15h
   144                              <2> opt4_int_15_force:	equ 4000_0000h	; not used at the same time as 09h
   145                              <2> opt4_int_07_force:	equ 8000_0000h
   146                              <2> DEFAULTOPTIONS4 equ opt4_int_2F_hook
   147                              <2> 
   148                              <2> 
   149                              <2> %if _VXCHG
   150                              <2> opt6_vv_mode:		equ 1
   151                              <2> opt6_vv_keep:		equ 2
   152                              <2> opt6_vv_int16:		equ 10h
   153                              <2>  %if _VXCHG_DEFAULT_ON
   154                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq | opt6_vv_mode
   155                              <2>  %else
   156                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq
   157                              <2>  %endif
   158                              <2> %else
   159                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq
   160                              <2> %endif
   161                              <2> %if _DEBUG
   162                              <2> opt6_debug_exception_late:	equ  20h
   163                              <2> opt6_debug_exception_early:	equ  40h
   164                              <2>  %if _DEBUG_COND
   165                              <2> opt6_debug_exception:	equ  80h
   166                              <2> opt6_debug_mode:	equ 100h
   167                              <2>  %endif
   168                              <2> %endif
   169                              <2> opt6_bios_output:	equ 200h
   170                              <2> opt6_flat_binary:	equ 400h
   171                              <2> opt6_big_stack:		equ 800h
   172                              <2> opt6_40_columns:	equ 1000h
   173                              <2> opt6_40_indent_odd:	equ 2000h
   174                              <2> opt6_40_dash:		equ 4000h
   175                              <2> opt6_share_serial_irq:	equ 1_0000h
   176                              <2> opt6_serial_EOI_call:	equ 2_0000h
   177                              <2> %if _RH
   178                              <2> opt6_rh_mode:		equ 10_0000h
   179                              <2> %endif
   180                              <2> %if _DEBUG
   181                              <2> opt6_debug_putrunint_early:	equ  40_0000h
   182                              <2>  %if _DEBUG_COND
   183                              <2> opt6_debug_putrunint:		equ  80_0000h
   184                              <2>  %endif
   185                              <2> %endif
   186                              <2> opt6_bios_io:		equ 100_0000h
   187                              <2> opt6_immasm_display_uu:	equ 200_0000h
   188                              <2> opt6_immasm_debug:	equ 400_0000h
   189                              <2> opt6_immasm_flag:	equ 800_0000h
   190                              <2> opt6_immasm_nobranch:	equ 1000_0000h
   191                              <2> opt6_r_flags_style2:	equ 2000_0000h
   192                              <2> opt6_r_flags_style3:	equ 4000_0000h
   193                              <2> opt6_r_linebreak_conditional:	equ 8000_0000h
   194                              <2> 
   195                              <2> 
   196                              <2> DEFAULTOPTIONS7 equ opt7_no_tsr_ll
   197                              <2> opt7_no_free_oneshot_eld:	equ 1
   198                              <2> opt7_debug_optional_link:	equ 2
   199                              <2> opt7_quiet_install:		equ 4
   200                              <2> opt7_quick_run:			equ 8
   201                              <2> opt7_houdini:			equ 100h
   202                              <2> opt7_debug_run:			equ 200h
   203                              <2> opt7_no_ensure:			equ 1000h
   204                              <2> opt7_no_tsr_ll:			equ 2000h
   205                              <2> 
   206                              <2> 
   207                              <2> oldpacket	equ	  1	; Int25/Int26 packet method available (L, W)
   208                              <2> newpacket	equ	  2	; Int21.7305 packet method available (L, W)
   209                              <2> ntpacket	equ	  4	; VDD registered and usable (L, W)
   210                              <2> pagedcommand	equ	  8	; allows paging in puts
   211                              <2> notstdinput	equ	 10h	; DEBUG's StdIn isn't a device with StdIn bit (is file or other device)
   212                              <2> inputfile	equ	 20h	; DEBUG's StdIn is a file, notstdinput also set
   213                              <2> notstdoutput	equ	 40h	; DEBUG's StdOut isn't a device with StdOut bit (is file or other device)
   214                              <2> outputfile	equ	  80h	; DEBUG's StdOut is a file, notstdoutput also set
   215                              <2> hooked2F	equ	 100h	; Int2F hooked
   216                              <2> nohook2F	equ	 200h	; don't hook Int2F.1687 (required for Win9x, DosEmu?)
   217                              <2> unused_dif1_dpminohlt equ 400h	; DPMI doesn't like hlt
   218                              <2> protectedmode	equ	 800h	; in (DPMI) protected mode
   219                              <2> debuggeeA20	equ	1000h	; state of debuggee's A20
   220                              <2> debuggerA20	equ	2000h	; state of debugger's A20 (will be on if possible)
   221                              <2> nodosloaded	equ	4000h	; No DOS loaded currently (Boot loader mode)
   222                              <2> has386		equ	8000h	; CPU is a 386
   223                              <2> usecharcounter	equ    1_0000h	; don't reset charcounter between calls to puts
   224                              <2> runningnt	equ    2_0000h	; running in NTVDM
   225                              <2> canswitchmode	equ    4_0000h	; can switch modes (auxbuff large enough, DPMI mode switch set up)
   226                              <2> modeswitched	equ    8_0000h	; switched mode (now in the mode that we weren't entered in)
   227                              <2> promptwaiting	equ   10_0000h	; puts: any more output needs to display a prompt first
   228                              <2> switchbuffer	equ   20_0000h	; mode switch needs a buffer (auxbuff)
   229                              <2> tsrmode		equ   40_0000h	; in TSR mode; DPI and DPP not valid
   230                              <2> attachedterm	equ   80_0000h	; the attached process terminated
   231                              <2> runningdosemu	equ  100_0000h	; running in dosemu
   232                              <2> ; load_is_ldp	equ  200_0000h	; boot load: partition specified as "ldp"
   233                              <2> tt_while:	equ  400_0000h	; tt: while condition specified
   234                              <2> tt_p:		equ  800_0000h	; tt: proceed past repeated string instructions
   235                              <2> tt_silent_mode:	equ 1000_0000h	; tt: run should be silent (dump at end)
   236                              <2> tt_silence:	equ 2000_0000h	; tt: silent writing (write to auxbuff instead)
   237                              <2> tt_no_bb:	equ 4000_0000h	; tt: do not use bb breakpoints
   238                              <2> tt_no_bb_first:	equ 8000_0000h	; tt: do not use bb breakpoints at first
   239                              <2> 
   240                              <2> 
   241                              <2> dif2_gg_is_first:	equ   1
   242                              <2> dif2_gg_skip_non_cseip:	equ   2
   243                              <2> dif2_gg_skip_cseip:	equ   4
   244                              <2> dif2_gg_is_gg:		equ   8
   245                              <2> dif2_gg_first_detected:	equ  10h
   246                              <2> dif2_gg_again:		equ  20h
   247                              <2> dif2_tpg_proceed_bp_set:equ  40h
   248                              <2> dif2_tpg_keep_proceed_bp: equ 80h
   249                              <2> dif2_tpg_have_bp:	equ 100h
   250                              <2> dif2_tpg_adjusted_cseip:equ 200h
   251                              <2> dif2_tpg_do_not_adjust:	equ 400h
   252                              <2> dif2_bp_failure:	equ 800h
   253                              <2> dif2_is_pp:		equ 1000h
   254                              <2> %if _SYMBOLIC
   255                              <2> dif2_createdprocess:	equ 800_0000h	; created empty debuggee process
   256                              <2> dif2_sym_req_xms:	equ 2000h
   257                              <2> dif2_sym_req_86mm:	equ 4000h
   258                              <2> dif2_sym_req_mask equ dif2_sym_req_86mm | dif2_sym_req_xms
   259                              <2> dif2_no_pm_xms:		equ 1_0000h
   260                              <2> dif2_xms_detection_done:equ 2_0000h
   261                              <2> %endif
   262                              <2> %if _INPUT_FILE_HANDLES
   263                              <2> dif2_input_file:	equ 10_0000h
   264                              <2> dif2_closed_input_file:	equ 20_0000h
   265                              <2> %endif
   266                              <2> dif2_did_getline_file:	equ 40_0000h
   267                              <2> %if _SYMBOLIC
   268                              <2> dif2_poison:		equ 80_0000h
   269                              <2> %endif
   270                              <2> dif2_boot_loaded_kernel:equ 100_0000h
   271                              <2> %if _INPUT_FILE_BOOT
   272                              <2> dif2_input_file_boot:	equ 200_0000h
   273                              <2> dif2_closed_input_file_boot:	equ 400_0000h
   274                              <2> %endif
   275                              <2> dif2_in_silence_dump:	equ 1000_0000h
   276                              <2> dif2_int31_segment:	equ 2000_0000h
   277                              <2> dif2_nn_compat:		equ 4000_0000h
   278                              <2> dif2_nn_capitalise:	equ 8000_0000h
   279                              <2> 
   280                              <2> 
   281                              <2> dif3_load_is_ldp:	equ 1	; boot load: partition specified as "ldp"
   282                              <2> dif3_load_is_sdp:	equ 2	; boot load: partition specified as "sdp"
   283                              <2> dif3_load_is_ydp:	equ 4	; boot load: partition specified as "ydp"
   284                              <2> dif3_load_is_dp:	equ dif3_load_is_ldp 				| dif3_load_is_sdp 				| dif3_load_is_ydp
   287                              <2> dif3_load_dir_dir:	equ 8
   288                              <2> dif3_input_terminal_override:	equ 10h
   289                              <2> dif3_input_serial_override:	equ 20h
   290                              <2> dif3_if_not:		equ 40h
   291                              <2> dif3_partition_changed:	equ 80h
   292                              <2> ;
   293                              <2> dif3_input_cmdline:	equ 100h; input reading from cmdline_buffer
   294                              <2> dif3_input_cmdline_closed: equ 200h
   295                              <2> dif3_at_line_end:	equ 400h
   296                              <2> dif3_quiet_input_single:equ 800h
   297                              <2> dif3_quiet_output:	equ 1000h
   298                              <2> dif3_unquiet_error:	equ 2000h
   299                              <2> dif3_unquiet_prompt:	equ 4000h
   300                              <2> dif3_unquiet:		equ dif3_unquiet_error | dif3_unquiet_prompt
   301                              <2> dif3_return_eof:	equ 8000h
   302                              <2> dif3_highlighting:	equ 1_0000h
   303                              <2> dif3_do_not_highlight:	equ 2_0000h
   304                              <2> dif3_int10_highlight:	equ 2_0000h
   305                              <2> dif3_nosymbols_1:	equ 4_0000h
   306                              <2> dif3_nosymbols_2:	equ 8_0000h
   307                              <2> %if _PM
   308                              <2> dif3_ss_b_bit_set:	equ  10_0000h
   309                              <2> %endif
   310                              <2> dif3_gotint19:		equ  20_0000h
   311                              <2> dif3_prior_pm:		equ  40_0000h
   312                              <2> %if _DELAY_BEFORE_BP
   313                              <2> dif3_delayed		equ  80_0000h
   314                              <2> %endif
   315                              <2> dif3_input_re:		equ 100_0000h	; input reading from re_buffer
   316                              <2> dif3_input_re_closed:	equ 200_0000h
   317                              <2> dif3_accept_getrange_0:	equ 400_0000h
   318                              <2> %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
   319                              <2> dif3_in_if:		equ 800_0000h
   320                              <2> %endif
   321                              <2> dif3_auxbuff_guarded_1:	equ 1000_0000h
   322                              <2> dif3_auxbuff_guarded_2:	equ 2000_0000h
   323                              <2> dif3_auxbuff_guarded_3:	equ 4000_0000h
   324                              <2> dif3_sss_is_reverse:	equ 8000_0000h
   325                              <2> 
   326                              <2> 
   327                              <2> dif4_int_serial_hooked:	equ 1
   328                              <2> dif4_int_2F_hooked:	equ 2
   329                              <2> dif4_int_08_hooked:	equ 4
   330                              <2> dif4_int_2D_hooked:	equ 8
   331                              <2> %if _CATCHINTFAULTCOND && _CATCHINT0D
   332                              <2> dif4_int_0D_hooked:	equ 10h
   333                              <2> %endif
   334                              <2> %if _CATCHINTFAULTCOND && _CATCHINT0C
   335                              <2> dif4_int_0C_hooked:	equ 20h
   336                              <2> %endif
   337                              <2> %if _LOADER
   338                              <2> dif4_int_18_hooked:	equ 1000h
   339                              <2> dif4_int_19_hooked:	equ 2000h
   340                              <2> %endif
   341                              <2> 
   342                              <2> 
   343                              <2> %if _VXCHG
   344                              <2> dif6_vv_mode:		equ 1
   345                              <2> %endif
   346                              <2> dif6_in_hook2F:		equ 2
   347                              <2> dif6_in_amis_hook2F:	equ 4
   348                              <2> dif6_debug_mode:	equ 100h
   349                              <2> dif6_locked:		equ 200h
   350                              <2> dif6_mcp:		equ 400h
   351                              <2> %if _RH
   352                              <2> dif6_rh_mode_was:	equ  8_0000h
   353                              <2> dif6_rh_mode:		equ 10_0000h
   354                              <2> dif6_rh_mode_2:		equ 20_0000h
   355                              <2> %endif
   356                              <2> dif6_device_mode:	equ 40_0000h
   357                              <2> dif6_cpdepchars:	equ 80_0000h
   358                              <2> %if _IMMASM
   359                              <2> dif6_immasm_no_output:	equ 100_0000h
   360                              <2> dif6_immasm:		equ 200_0000h
   361                              <2> dif6_immasm_rel8:	equ 400_0000h
   362                              <2> %endif
   363                              <2> 
   364                              <2> 
   365                              <2> disasm_lowercase	equ 1
   366                              <2> disasm_commablank	equ 2
   367                              <2> disasm_nasm		equ 4
   368                              <2> disasm_lowercase_refmem:equ 8
   369                              <2> disasm_show_short:	equ 10h
   370                              <2> disasm_show_near:	equ 20h
   371                              <2> disasm_show_far:	equ 40h
   372                              <2> disasm_nec:		equ 80h
   373                              <2> disasm_40_columns:	equ 100h
   374                              <2> disasm_no_indent:	equ 200h
   375                              <2> disasm_msdebug_mnemonofs: equ 400h
   376                              <2> disasm_a16_memref:	equ 1000h
   377                              <2> disasm_a32_memref:	equ 2000h
   378                              <2> disasm_a16_string:	equ 4000h
   379                              <2> disasm_a32_string:	equ 8000h
   380                              <2> disasm_hide_modrm:	equ 10000h
   381                              <2> disasm_asize_loop_nasm:	equ 20000h
   382                              <2> disasm_modrm_always:	equ 40000h
   383                              <2> DEFAULTASMOPTIONS equ disasm_lowercase|disasm_commablank|disasm_nasm 	| disasm_a16_memref | disasm_a32_memref 	| disasm_a16_string | disasm_a32_string
   386                              <2> 
   387                              <2> 	; serial_flags values
   388                              <2> sf_init_done:	equ 1
   389                              <2> sf_ctrl_c:	equ 2
   390                              <2> sf_double_ctrl_c:	equ 4
   391                              <2> sf_built_in_fifo:	equ 8
   392                              <2> sf_use_serial:		equ 10h
  1561                              <1> %endif
    20                                  %endif
    21                                  
    22                                  
    23                                  	usesection lDEBUG_CODE
    23          ------------------       note: usesection lDEBUG_CODE
    24                                  
    25                                  %define PREFIX
    26                                  %include "isstring.asm"
     1                              <1> 
     2                              <1> %if 0
     3                              <1> 
     4                              <1> lDebug string keyword comparison
     5                              <1> 
     6                              <1> Copyright (C) 1995-2003 Paul Vojta
     7                              <1> Copyright (C) 2008-2023 E. C. Masloch
     8                              <1> 
     9                              <1> Usage of the works is permitted provided that this
    10                              <1> instrument is retained with the works, so that any entity
    11                              <1> that uses the works is notified of this instrument.
    12                              <1> 
    13                              <1> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    14                              <1> 
    15                              <1> %endif
    16                              <1> 
    17                              <1> 
    18                              <1> 		; Check for given string (cap-insensitive)
    19                              <1> 		;
    20                              <1> 		; INP:	ds:si -> input string to check (either cap),
    21                              <1> 		;	 terminated by CR (13), NUL, semicolon, space,
    22                              <1> 		;	 tab, dot, comma, equals, colon, [, ], (, or )
    23                              <1> 		;	es:dx -> ASCIZ string to check (all-caps)
    24                              <1> 		; OUT:	Iff string matches,
    25                              <1> 		;	 ZR, NC
    26                              <1> 		;	 si -> at separator that terminates the keyword
    27                              <1> 		;	else,
    28                              <1> 		;	 NZ, CY
    29                              <1> 		;	 si = input si
    30                              <1> 		; STT:	ds = es = ss
    31                              <1> 		; CHG:	dx, al
    32                              <1> %[PREFIX]isstring?:
    33 00000000 56                  <1> 	push si
    34 00000001 87D7                <1> 	xchg dx, di
    35                              <1> .loop:
    36 00000003 AC                  <1> 	lodsb
    37 00000004 E84800              <1> 	call %[PREFIX]capitalise
    38 00000007 AE                  <1> 	scasb
    39 00000008 7506                <1> 	jne .mismatch
    40 0000000A 84C0                <1> 	test al, al		; NC
    41 0000000C 75F5                <1> 	jne .loop
    42                              <1> 				; ZR
    43 0000000E EB39                <1> 	jmp .matched_zr_nc
    44                              <1> 
    45                              <1> .mismatch:
    46 00000010 E85800              <1> 	call %[PREFIX]iseol?
    47 00000013 742D                <1> 	je .checkend
    48 00000015 3C20                <1> 	cmp al, 32
    49 00000017 7429                <1> 	je .checkend
    50 00000019 3C09                <1> 	cmp al, 9
    51 0000001B 7425                <1> 	je .checkend
    52 0000001D 3C2E                <1> 	cmp al, '.'
    53 0000001F 7421                <1> 	je .checkend
    54 00000021 3C2C                <1> 	cmp al, ','
    55 00000023 741D                <1> 	je .checkend
    56 00000025 3C3D                <1> 	cmp al, '='
    57 00000027 7419                <1> 	je .checkend
    58 00000029 3C3A                <1> 	cmp al, ':'
    59 0000002B 7415                <1> 	je .checkend
    60 0000002D 3C5B                <1> 	cmp al, '['
    61 0000002F 7411                <1> 	je .checkend
    62 00000031 3C5D                <1> 	cmp al, ']'
    63 00000033 740D                <1> 	je .checkend
    64 00000035 3C28                <1> 	cmp al, '('
    65 00000037 7409                <1> 	je .checkend
    66 00000039 3C29                <1> 	cmp al, ')'
    67 0000003B 7405                <1> 	je .checkend
    68                              <1> %ifidni PREFIX, init_
    69                              <1>  %if ELD
    70                              <1> 	cmp al, byte [ss:relocateddata]
    71                              <1> linkdatarelocation swch1
    72                              <1>  %else
    73                              <1> 	cmp al, byte [ss:swch1]
    74                              <1>  %endif
    75                              <1> 	je .checkend
    76                              <1> %endif
    77                              <1> .ret_nz:	; NZ
    78 0000003D 5E                  <1> 	pop si
    79 0000003E F9                  <1> 	stc			; CY
    80                              <1> .ret:
    81 0000003F 87D7                <1> 	xchg dx, di
    82 00000041 C3                  <1> 	retn
    83                              <1> 
    84                              <1> .checkend:
    85 00000042 26807DFF00          <1> 	cmp byte [es:di - 1], 0
    86 00000047 75F4                <1> 	jne .ret_nz
    87                              <1> 				; ZR, NC
    88                              <1> .matched_zr_nc:	; ZR, NC
    89 00000049 5F                  <1> 	pop di			; (discard)
    90 0000004A 8D74FF              <1> 	lea si, [si - 1]	; -> separator (preserve ZR)
    91 0000004D EBF0                <1> 	jmp .ret
    92                              <1> 
    93                              <1> 
    94                              <1> %[PREFIX]capitalise: section_of_function
    95 0000004F 3C61                <1> 	cmp al, 'a'
    96 00000051 7206                <1> 	jb .ret
    97 00000053 3C7A                <1> 	cmp al, 'z'
    98 00000055 7702                <1> 	ja .ret
    99 00000057 24DF                <1> 	and al, TOUPPER
   100                              <1> .ret:
   101 00000059 C3                  <1> 	retn
   102                              <1> 
   103                              <1> %ifempty PREFIX
   104                              <1> iseol?_or_then:
   105                              <1>  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
   106 0000005A F606[0300]08        <1> 	testopt [internalflags3], dif3_in_if
   107 0000005F 740A                <1> 	jz iseol?
   108 00000061 BA[0000]            <1> 	mov dx, msg.then
   109 00000064 4E                  <1> 	dec si
   110 00000065 E898FF              <1> 	call isstring?
   111 00000068 740B                <1> 	je iseol?.ret
   112 0000006A AC                  <1> 	lodsb
   113                              <1>  %endif
   114                              <1> %endif
   115                              <1> 
   116                              <1> %[PREFIX]iseol?:
   117 0000006B 3C3B                <1> 	cmp al, ';'
   118 0000006D 7406                <1> 	je .ret
   119                              <1> .notsemicolon:
   120 0000006F 3C0D                <1> 	cmp al, 13		; this *IS* iseol?
   121 00000071 7402                <1> 	je .ret
   122 00000073 3C00                <1> 	cmp al, 0
   123                              <1> .ret:
   124 00000075 C3                  <1> 	retn
   125                              <1> 
   126                              <1> 
   127                              <1> 		; Skip blanks, then an optional comma, and then more blanks
   128                              <1> 		;
   129                              <1> 		; INP:	ds:si -> first character
   130                              <1> 		; OUT:	al = first non-blank character behind
   131                              <1> 		;	ds:si -> character behind the first non-blank behind
   132                              <1> 		;	NC
   133                              <1> 		; STK:	3 word
   134                              <1> %[PREFIX]skipcomma: section_of_function
   135 00000076 AC                  <1> 	lodsb
   136                              <1> 
   137                              <1> 		; Same as above but we already have the first character in al
   138                              <1> %[PREFIX]skipcomm0: section_of_function
   139 00000077 E82C00              <1> 	call %[PREFIX]skipwh0
   140 0000007A 3C2C                <1> 	cmp al, ','
   141 0000007C 7510                <1> 	jne .return		; if no comma
   142 0000007E 56                  <1> 	push si
   143 0000007F E82300              <1> 	call %[PREFIX]skipwhite
   144 00000082 E8E6FF              <1> 	call %[PREFIX]iseol?
   145 00000085 7504                <1> 	jne .noteol		; if not end of line
   146 00000087 5E                  <1> 	pop si
   147 00000088 B02C                <1> 	mov al, ','
   148 0000008A C3                  <1> 	retn
   149                              <1> .noteol:
   150 0000008B 83C402              <1> 	add sp, byte 2		; pop si into nowhere
   151                              <1> .return:
   152 0000008E C3                  <1> 	retn
   153                              <1> 
   154                              <1> 
   155                              <1> 		; Skip blanks, then an optional equals sign, then more blanks
   156                              <1> %[PREFIX]skipequals: section_of_function
   157 0000008F AC                  <1> 	lodsb
   158                              <1> %[PREFIX]skipequ0:
   159 00000090 E81300              <1> 	call %[PREFIX]skipwh0
   160 00000093 3C3D                <1> 	cmp al, '='
   161 00000095 7503                <1> 	jne .return
   162 00000097 E80B00              <1> 	call %[PREFIX]skipwhite
   163                              <1> .return:
   164 0000009A C3                  <1> 	retn
   165                              <1> 
   166                              <1> 
   167                              <1> 		; Skip alphabetic characters, and then white space
   168                              <1> 		;
   169                              <1> 		; INP:	ds:si-> first character
   170                              <1> 		; OUT:	al = first non-blank character behind alphabetic characters
   171                              <1> 		;	ds:si-> character behind the first non-blank behind alpha.
   172                              <1> 		;	NC
   173                              <1> %[PREFIX]skipalpha:
   174                              <1> .:
   175 0000009B AC                  <1> 	lodsb
   176 0000009C 24DF                <1> 	and al, TOUPPER
   177 0000009E 2C41                <1> 	sub al, 'A'
   178 000000A0 3C19                <1> 	cmp al, 'Z'-'A'
   179 000000A2 76F7                <1> 	jbe .
   180 000000A4 4E                  <1> 	dec si
   181                              <1> 
   182                              <1> 		; Skip blanks and tabs
   183                              <1> 		;
   184                              <1> 		; INP:	ds:si-> first character
   185                              <1> 		; OUT:	al = first non-blank character
   186                              <1> 		;	ds:si-> character behind the first non-blank
   187                              <1> 		;	NC
   188                              <1> 		; CHG:	-
   189                              <1> 		; STK:	1 word
   190                              <1> %[PREFIX]skipwhite: section_of_function
   191 000000A5 AC                  <1> 	lodsb
   192                              <1> 
   193                              <1> 		; Same as above, but first character in al
   194                              <1> 		;
   195                              <1> 		; INP:	al = first character
   196                              <1> 		;	ds:si-> next character
   197                              <1> 		; OUT:	al = first non-blank character
   198                              <1> 		;	ds:si-> character behind the first non-blank
   199                              <1> 		;	NC
   200                              <1> 		; CHG:	-
   201                              <1> 		; STK:	1 word
   202                              <1> %[PREFIX]skipwh0: section_of_function
   203 000000A6 3C20                <1> 	cmp al, 32
   204 000000A8 74FB                <1> 	je %[PREFIX]skipwhite
   205 000000AA 3C09                <1> 	cmp al, 9
   206 000000AC 74F7                <1> 	je %[PREFIX]skipwhite
   207 000000AE F8                  <1> 	clc
   208 000000AF C3                  <1> 	retn
    27                                  
    28                                  
    29                                  		; REM:	call skipcomma/skipcomm0 before this!
    30                                  chkeol_or_then:
    31                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
    32 000000B0 E8A7FF                  	call iseol?_or_then
    33 000000B3 74C0                    	je iseol?.ret		; if EOL -->
    34 000000B5 EB08                    	jmp @F
    35                                  %endif
    36                                  
    37                                  		; Check for end of line
    38                                  		;
    39                                  		; INP:	al = first character
    40                                  		;	ds:si-> next character
    41                                  		; OUT:	ZR
    42                                  		;	al = 13 or al = ';' or al = 0
    43                                  		;	(does not return if anything on line beside blanks)
    44                                  chkeol: section_of_function
    45 000000B7 E8ECFF                  	call skipwh0
    46 000000BA E8AEFF                  	call iseol?
    47 000000BD 74B6                    	je iseol?.ret		; if EOL -->
    48                                  
    49                                  @@:
    50 000000BF B80001                  	mov ax, 0100h
    51 000000C2 E8(0000)                	call setrc
    52                                  errorj8:
    53 000000C5 E9(0000)                	jmp error
    54                                  
    55                                  
    56                                  		; SHOWSTRING - Print ASCIZ string.
    57                                  showstring.next:
    58 000000C8 AA                      	stosb
    59                                  showstring:
    60 000000C9 AC                      	lodsb
    61 000000CA 84C0                    	test al, al
    62 000000CC 75FA                    	jnz .next
    63 000000CE C3                      	retn
    64                                  
    65                                  
    66                                  		; Dump byte as decimal number string
    67                                  		;
    68                                  		; INP:	al = byte
    69                                  		;	di-> where to store
    70                                  		; OUT:	-
    71                                  		; CHG:	di-> behind variable-length string
    72                                  decbyte:
    73 000000CF 50                      	push ax
    74 000000D0 51                      	push cx
    75 000000D1 B96400                  	mov cx, 100
    76 000000D4 E80B00                  	call .div
    77 000000D7 B10A                    	mov cl, 10
    78 000000D9 E80600                  	call .div
    79 000000DC 0430                    	add al, '0'
    80 000000DE AA                      	stosb
    81 000000DF 59                      	pop cx
    82 000000E0 58                      	pop ax
    83 000000E1 C3                      	retn
    84                                  
    85                                  .div:
    86 000000E2 30E4                    	xor ah, ah
    87 000000E4 F6F1                    	div cl
    88 000000E6 08C5                    	or ch, al
    89 000000E8 7403                    	jz .leadingzero
    90 000000EA 0430                    	add al, '0'
    91 000000EC AA                      	stosb
    92                                  .leadingzero:
    93 000000ED 86C4                    	xchg al, ah
    94 000000EF C3                      	retn
    95                                  
    96                                  
    97                                  decword: section_of_function
    98 000000F0 52                      	push dx
    99 000000F1 31D2                    	xor dx, dx
   100 000000F3 E80200                  	call decdword
   101 000000F6 5A                      	pop dx
   102 000000F7 C3                      	retn
   103                                  
   104                                  
   105                                  decdword: section_of_function
   106 000000F8 51                      	push cx
   107 000000F9 31C9                    	xor cx, cx
   108 000000FB E80200                  	call dec_dword_minwidth
   109 000000FE 59                      	pop cx
   110 000000FF C3                      	retn
   111                                  
   112                                  
   113                                  		; Dump dword as decimal number string
   114                                  		;
   115                                  		; INP:	dx:ax = dword
   116                                  		;	cx = minimum width (<= 1 for none, must be < 10)
   117                                  		;	es:di -> where to store
   118                                  		; OUT:	es:di -> behind variable-length string
   119                                  		; CHG:	-
   120                                  		; STT:	UP
   121                                  dec_dword_minwidth: section_of_function
   122                                  	lframe near
   123                                  	lequ 10,	bufferlen
   124                                  	lvar ?bufferlen,buffer
   125 00000100 5589E58D66F6            	lenter
   126                                  	lvar dword,	dividend
   127 00000106 52                      	 push dx
   128 00000107 50                      	 push ax
   129 00000108 49                      	dec cx
   130                                  	lvar word,	minwidth
   131 00000109 51                      	 push cx
   132 0000010A 41                      	inc cx
   133                                  
   134 0000010B 50                      	push ax
   135 0000010C 53                      	push bx
   136 0000010D 51                      	push cx
   137 0000010E 52                      	push dx
   138 0000010F 56                      	push si
   139 00000110 57                      	push di
   140 00000111 06                      	push es
   141                                  
   142 00000112 16                      	 push ss
   143 00000113 07                      	 pop es
   144                                  
   145 00000114 8D7EFF                  	lea di, [bp + ?buffer + ?bufferlen - 1]
   146 00000117 89FB                    	mov bx, di
   147 00000119 FD                      	std			; _AMD_ERRATUM_109_WORKAROUND does not apply
   148                                  
   149                                  		; dword [bp + ?dividend] = number to display
   150 0000011A B90A00                  	mov cx, 10		; divisor
   151                                  .loop_write:
   152                                  
   153 0000011D 31D2                    	xor dx, dx
   154 0000011F 57                      	push di
   155 00000120 BF0400                  	mov di, 4
   156                                  .loop_divide:
   157 00000123 8B43F0                  	mov ax, [bp + ?dividend - 2 + di]
   158 00000126 F7F1                    	div cx
   159 00000128 8943F0                  	mov word [bp + ?dividend - 2 + di], ax
   160 0000012B 4F                      	dec di
   161 0000012C 4F                      	dec di
   162 0000012D 75F4                    	jnz .loop_divide
   163                                  				; dx = last remainder
   164 0000012F 5F                      	pop di
   165 00000130 92                      	xchg ax, dx		; ax = remainder (next digit)
   166                                  				; dword [bp + ?dividend] = result of div
   167 00000131 0430                    	add al, '0'
   168 00000133 AA                      	stosb
   169 00000134 FF4EF0                  	dec word [bp + ?minwidth]
   170 00000137 79E4                    	jns .loop_write
   171                                  
   172 00000139 837EF400                	cmp word [bp + ?dividend + 2], 0
   173 0000013D 75DE                    	jnz .loop_write
   174 0000013F 837EF200                	cmp word [bp + ?dividend], 0
   175                                  				; any more ?
   176 00000143 75D8                    	jnz .loop_write		; loop -->
   177                                  
   178 00000145 FC                      	cld
   179                                  
   180 00000146 29FB                    	sub bx, di
   181 00000148 89D9                    	mov cx, bx
   182 0000014A 89FE                    	mov si, di
   183 0000014C 46                      	inc si
   184                                  
   185 0000014D 07                      	pop es
   186 0000014E 5F                      	pop di
   187                                  
   188                                  @@:
   189 0000014F 36A4                    	ss movsb		; do not replace by rep ss movsb, because
   190                                  				;  some 8086 don't like two-prefix opcodes
   191 00000151 E2FC                    	loop @B
   192                                  
   193 00000153 5E                      	pop si
   194 00000154 5A                      	pop dx
   195 00000155 59                      	pop cx
   196 00000156 5B                      	pop bx
   197 00000157 58                      	pop ax
   198                                  
   199 00000158 89EC5D                  	lleave
   200 0000015B C3                      	retn
   201                                  
   202                                  
   203                                  		; dump high word of eax - assumes 386
   204                                  hexword_high: section_of_function
   205                                  [cpu 386]
   206 0000015C 66C1C010                	rol eax, 16
   207 00000160 E80800                  	call hexword
   208 00000163 66C1C010                	rol eax, 16
   209                                  __CPU__
   210 00000167 C3                      	retn
   211                                  
   212                                  
   213                                  		; hexdword - dump dword (in eax) to hex ASCII - assumes 386
   214                                  		; HEXWORD - Print hex word (in AX).
   215                                  		; HEXBYTE - Print hex byte (in AL).
   216                                  		; HEXNYB - Print hex digit.
   217                                  		; Uses	none.
   218                                  hexdword: section_of_function
   219 00000168 E8F1FF                  	call hexword_high
   220                                  hexword: section_of_function
   221 0000016B 86C4                    	xchg al, ah
   222 0000016D E80200                  	call hexbyte
   223 00000170 86C4                    	xchg al, ah
   224                                  
   225                                  hexbyte: section_of_function
   226 00000172 51                      	push cx
   227 00000173 B104                    	mov cl, 4
   228 00000175 D2C0                    	rol al, cl
   229 00000177 E80300                  	call hexnyb
   230 0000017A D2C0                    	rol al, cl
   231 0000017C 59                      	pop cx
   232                                  
   233                                  hexnyb: section_of_function
   234 0000017D 50                      	push ax
   235 0000017E 240F                    	and al, 0Fh
   236                                  .common:
   237                                  		; These three instructions change to ASCII hex.
   238                                  		;  Refer to https://codegolf.stackexchange.com/questions/193793/little-endian-number-to-string-conversion/193842#193842
   239 00000180 3C0A                    	cmp al, 10	; set CF according to digit <= 9
   240 00000182 1C69                    	sbb al, 69h	; read CF, set CF and conditionally set AF
   241 00000184 2F                      	das		; magic, which happens to work
   242 00000185 AA                      	stosb
   243 00000186 58                      	pop ax
   244 00000187 C3                      	retn
   245                                  
   246                                  		; TAB_TO - Space fill line_out until reaching the
   247                                  		;  column indicated by AX. (Display a new line if
   248                                  		;  necessary.) At least two blanks are stored.
   249                                  		;
   250                                  		; INP:	es:di -> behind text to display
   251                                  		;	es:line_out -> text to display
   252                                  		;	es:ax -> destination to tab to,
   253                                  		;	 if ax >= di + 2 then just put blanks,
   254                                  		;	 else pass content so far to trimputs
   255                                  		;	 and fill line_out with blanks afterwards
   256                                  		; OUT:	es:di -> tabbed to buffer in line_out
   257                                  		; CHG:	ax, bx, cx, dx
   258                                  tab_to:
   259 00000188 50                      	push ax
   260 00000189 48                      	dec ax			; make sure at least two blanks
   261 0000018A 39F8                    	cmp ax, di
   262 0000018C 7706                    	ja .sameline		; if there's room on this line -->
   263                                  		; below-or-equal: go to next line.
   264                                  		; That is, if we are at the indicated column
   265                                  		;  (actually column - 1 due to dec) then make
   266                                  		;  a new line. This covers the case of needing
   267                                  		;  zero blanks (or one due to dec) as needing
   268                                  		;  a new line, but one or more (two or more) go
   269                                  		;  to the same line as prior content.
   270 0000018E E80B00                  	call trimputs
   271 00000191 BF[0000]                	mov di, line_out
   272                                  .sameline:
   273 00000194 59                      	pop cx
   274 00000195 29F9                    	sub cx, di
   275 00000197 B020                    	mov al, 32
   276 00000199 F3AA                    	rep stosb		; space fill to the right end
   277                                  puts.retn:
   278 0000019B C3                      	retn
   279                                  
   280                                  		; Trim excess blanks, append linebreak and display line_out.
   281                                  		;
   282                                  		; INP:	es:di -> behind last character to display, or blank
   283                                  		;	es:line_out -> text to display
   284                                  		; OUT:	es:di -> behind displayed text (CR LF inserted)
   285                                  		; CHG:	ax, bx, cx, dx
   286                                  		;
   287                                  		; Note:	May overflow if line_out only contains blanks. The byte at
   288                                  		;	trim_overflow is used to avoid overflows.
   289                                  trimputs: section_of_function
   290 0000019C 4F                      	dec di
   291 0000019D 26803D20                	cmp byte [es:di], 32
   292 000001A1 74F9                    	je trimputs
   293 000001A3 47                      	inc di
   294                                  
   295                                  		; Append linebreak and display line_out
   296                                  		;
   297                                  		; INP:	es:di -> behind last character to display
   298                                  		;	es:line_out -> text to display
   299                                  		; OUT:	es:di -> behind displayed text (CR LF inserted)
   300                                  		; STT:	all segment registers same
   301                                  		; CHG:	ax, bx, cx, dx
   302                                  putsline_crlf: section_of_function
   303 000001A4 B80D0A                  	mov ax, 10<<8| 13
   304 000001A7 AB                      	stosw
   305                                  
   306                                  		; Display line_out
   307                                  		;
   308                                  		; INP:	es:di -> behind last character to display
   309                                  		;	es:line_out -> first character to display
   310                                  		; STT:	all segment registers same
   311                                  		; CHG:	ax, bx, cx, dx
   312                                  putsline: section_of_function
   313 000001A8 89F9                    	mov cx, di
   314 000001AA BA[0000]                	mov dx, line_out
   315 000001AD 29D1                    	sub cx, dx
   316                                  
   317                                  		; Display message
   318                                  		;
   319                                  		; INP:	es:dx -> message to display
   320                                  		;	cx = length of message
   321                                  		; STT:	ds = ss = debugger data selector
   322                                  		; CHG:	ax, bx, cx, dx
   323                                  puts: section_of_function
   324                                  ;d4	call d4message
   325                                  ;d4	asciz "In puts first",13,10
   326                                  
   327                                  %if _EXTENSIONS
   328 000001AF 91                      	xchg ax, cx
   329 000001B0 8B0E[0000]              	mov cx, word [ext_puts_handler]
   330 000001B4 E308                    	jcxz @F
   331                                  check_section_of puts_ext_next
   332                                  puts_ext_next: equ $
   333 000001B6 E9EA19                  	jmp transfer_ext_cx_NC
   334                                  
   335                                  check_section_of puts_ext_done
   336                                  puts_ext_done: equ $
   337 000001B9 59                      	pop cx
   338 000001BA 59                      	pop cx
   339 000001BB 59                      	pop cx				; discard return addresses
   340 000001BC 72DD                    	jc .retn
   341                                  
   342                                  @@:
   343 000001BE 91                      	xchg ax, cx
   344                                  %endif
   345                                  
   346                                  %if _IMMASM
   347 000001BF F606[0300]01            	testopt [internalflags6], dif6_immasm_no_output
   348 000001C4 75D5                    	jnz .retn
   349                                  %endif
   350                                  %if _RH
   351 000001C6 D006[0000]              	rol byte [skip_rh], 1
   352 000001CA 7218                    	jc .no_rh
   353                                  %endif
   354                                  %if !_LOADER
   355 000001CC F606[0300]20            	testopt [internalflags], tt_silence
   356 000001D1 7403E95003              	jnz puts_silence
   357                                  %endif
   358                                  %if _RH
   359 000001D6 F606[0200]30            	testopt [internalflags6], dif6_rh_mode | dif6_rh_mode_2
   360 000001DB 7407                    	jz @F
   361 000001DD 52                      	push dx
   362 000001DE 51                      	push cx
   363 000001DF E84403                  	call puts_silence		; also copy to auxbuff
   364 000001E2 59                      	pop cx
   365 000001E3 5A                      	pop dx
   366                                  @@:
   367                                  %endif
   368                                  .no_rh:
   369                                  
   370 000001E4 F606[0100]60            	testopt [internalflags3], dif3_unquiet
   371 000001E9 7507                    	jnz @F
   372 000001EB F606[0100]10            	testopt [internalflags3], dif3_quiet_output
   373 000001F0 75A9                    	jnz .retn
   374                                  @@:
   375                                  
   376                                  
   377                                  %if _EXTENSIONS
   378                                  		; Only output actually to be displayed reaches this
   379                                  		;  hook. However, [more] prompts do not go here.
   380                                  		;  They are inserted later.
   381 000001F2 91                      	xchg ax, cx
   382 000001F3 8B0E[0000]              	mov cx, word [ext_puts_copyoutput_handler]
   383 000001F7 E308                    	jcxz @F
   384 000001F9 E9A719                  	jmp transfer_ext_cx_NC
   385                                  
   386                                  check_section_of puts_copyoutput_ext_done
   387                                  puts_copyoutput_ext_done: equ $
   388 000001FC 59                      	pop cx
   389 000001FD 59                      	pop cx
   390 000001FE 59                      	pop cx				; discard return addresses
   391 000001FF 729A                    	jc .retn
   392                                  
   393                                  @@:
   394 00000201 91                      	xchg ax, cx
   395                                  %endif
   396                                  
   397                                  
   398                                  		; The following code contains most of the paging support.
   399                                  		; Based on the number of LF characters in the string it
   400                                  		; displays only parts of the string, then interrupts it by
   401                                  		; the "[more]" prompt which waits for any key before
   402                                  		; proceeding. This is ensured to work proper in InDOS mode.
   403                                  		;
   404                                  		; Paging is deactivated if the command's output mustn't be
   405                                  		; paged (clears pagedcommand, which is set by cmd3). It is
   406                                  		; also not used when we output to a file.
   407 00000202 F606[0000]10            	testopt [options], nonpagingdevice
   408 00000207 7403E93901              	jnz .display			; deactivated by user -->
   409 0000020C F606[0100]10            	testopt [options3], opt3_paging_rc
   410 00000211 750A                    	jnz @F				; don't disable for RC
   411                                  		; RC simply does not disable paging here.
   412                                  		;  But it can still be disabled in other
   413                                  		;  ways as we do not force it enabled for RC.
   414 00000213 F606[0100]01            	testopt [internalflags3], dif3_input_cmdline
   415 00000218 7403E92801              	jnz .display
   416                                  @@:
   417                                  
   418 0000021D F606[0100]40            	testopt [options3], opt3_paging_re
   419 00000222 750C                    	jnz @F				; enable for RE
   420 00000224 F606[0300]01            	testopt [internalflags3], dif3_input_re
   421                                  					; is RE ?
   422 00000229 7403E91701              	jnz .display			; yes, don't do paging -->
   423 0000022E EB07                    	jmp @FF
   424                                  
   425                                  @@:
   426 00000230 F606[0300]01            	testopt [internalflags3], dif3_input_re
   427                                  					; is RE ?
   428 00000235 7555                    	jnz .dontcheckredirection	; yes, do paging -->
   429                                  @@:
   430                                  
   431 00000237 F606[0100]20            	testopt [options3], opt3_paging_yy
   432 0000023C 740E                    	jz @F
   433 0000023E F606[0000]10            	testopt [serial_flags], sf_use_serial
   434                                  					; I/O done using serial port ?
   435 00000243 7547                    	jnz .dontcheckredirection	; yes, is paged -->
   436 00000245 E8(0000)                	call InDOS_or_BIOS_IO		; InDOS mode ?
   437 00000248 7542                    	jnz .dontcheckredirection	; yes, then we display with Int10 anyway -->
   438 0000024A EB2F                    	jmp @FF				; re-use later @@
   439                                  
   440                                  @@:
   441                                  %if _INPUT_FILE_BOOT
   442 0000024C F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
   443 00000251 7403E9EF00              	jnz .display
   444                                  %endif
   445 00000256 E8(0000)                	call InDOS_or_BIOS_IO		; InDOS mode ?
   446 00000259 7531                    	jnz .dontcheckredirection	; yes, then we display with Int10 anyway -->
   447                                  %if _INPUT_FILE_HANDLES
   448 0000025B F606[0200]10            	testopt [internalflags2], dif2_input_file
   449 00000260 7403E9E000              	jnz .display
   450                                  %endif
   451 00000265 F606[0000]10            	testopt [serial_flags], sf_use_serial
   452                                  					; I/O done using serial port ?
   453 0000026A 7520                    	jnz .dontcheckredirection	; yes, is paged -->
   454 0000026C E8(0000)                	call InDOS_or_BIOS_output
   455 0000026F 750A                    	jnz @F
   456 00000271 F606[0000]80            	testopt [internalflags], outputfile
   457 00000276 7403E9CA00              	jnz .display			; output redirected to file. never page -->
   458                                  @@:		; targeted by two branches
   459 0000027B F606[0100]01            	testopt [options], nondospaging
   460 00000280 750A                    	jnz .dontcheckredirection
   461 00000282 F606[0000]20            	testopt [internalflags], inputfile
   462 00000287 7403E9B900              	jnz .display			; input redirected from a file. never page -->
   463                                  .dontcheckredirection:
   464 0000028C 57                      	push di
   465 0000028D 51                      	push cx				; used as variable: remaining (not yet displayed) line length
   466 0000028E 89D7                    	mov di, dx			; es:di-> string, cx = length
   467                                  .looplf:
   468 00000290 85C9                    	test cx, cx
   469 00000292 7503E9AC00              	jz .display_pop			; end of string (or ended in LF) -->
   470                                  		; Important: We only ever jump back to .looplf when cx
   471                                  		; zero means it's okay to ignore the waiting prompt as
   472                                  		; flagged below. This is (A) at the start of a string,
   473                                  		; where cx is the whole string's length, (B) after
   474                                  		; determining that prompting is not yet necessary, in
   475                                  		; which case the flag was checked earlier already, (C)
   476                                  		; after the flag has been set and a substring was already
   477                                  		; displayed (so cx is again the whole substring's length)
   478                                  		; or (D) just after the prompt was displayed, in which
   479                                  		; case the flag cannot be set.
   480                                  		; In case A and C, when the (sub)string is empty (ie. cx
   481                                  		; is zero) it's crucial to ignore the waiting prompt as
   482                                  		; this is the exact behaviour we want: If nothing is
   483                                  		; displayed anymore before the getline code prompts
   484                                  		; anyway, do not display our prompt.
   485 00000297 F606[0200]10            	testopt [internalflags], promptwaiting	; do we have a prompt to display ?
   486 0000029C 7550                    	jnz .promptnow			; yes, display it before the string -->
   487                                  
   488 0000029E 31C0                    	xor ax, ax
   489 000002A0 F606[0000]10            	testopt [serial_flags], sf_use_serial
   490                                  					; serial ?
   491 000002A5 7409                    	jz @F				; no -->
   492 000002A7 0A06[0000]              	or al, byte [serial_rows]	; ax = number of rows if serial
   493 000002AB 7419                    	jz .display_pop_ZR		; if zero, do not page -->
   494 000002AD 48                      	dec ax				; was 1 ? (adjust to rows minus one)
   495 000002AE 7516                    	jnz @FF				; no, use as rows minus one --> (NZ)
   496                                  					; ax = 0 if it was 1
   497                                  @@:
   498 000002B0 0A06[0000]              	or al, [io_rows]
   499 000002B4 7410                    	jz .display_pop_ZR
   500 000002B6 48                      	dec ax				; was 1 ? (adjust to rows minus one)
   501 000002B7 750D                    	jnz @F				; no, use as rows minus one --> (NZ)
   502                                  					; yes, automatic (use BDA)
   503 000002B9 06                      	push es
   504 000002BA B84000                  	mov ax, 40h			; 0040h is a bimodal segment/selector
   505 000002BD 8EC0                    	mov es, ax
   506 000002BF 26A08400                	mov al, byte [ es:84h ]		; rows on screen
   507 000002C3 07                      	pop es
   508 000002C4 85C0                    	test ax, ax
   509                                  @@:
   510                                  .display_pop_ZR:
   511 000002C6 747B                    	jz .display_pop
   512                                  
   513 000002C8 3806[0000]              	cmp byte [ linecounter ], al
   514 000002CC 7268                    	jb .notyet			; not yet reached -->
   515 000002CE F606[0000]08            	testopt [internalflags], pagedcommand	; active ?
   516 000002D3 7506                    	jnz .prompt			; yes, prompt -->
   517 000002D5 FE0E[0000]              	dec byte [ linecounter ]	; keep count, but don't prompt til next LF
   518 000002D9 EB5B                    	jmp short .notyet
   519                                  
   520                                  .prompt:
   521 000002DB 58                      	 pop ax				; ax = length of string, cx = length of string remaining
   522 000002DC 29C8                    	sub ax, cx			; ax = length of string til LF
   523 000002DE 91                      	xchg ax, cx			; cx = til LF incl., ax = behind LF
   524 000002DF 50                      	 push ax			; new count
   525                                  				; cx = length til LF
   526                                  				; es:dx-> start of part til LF
   527 000002E0 E86200                  	call .display			; display part of message which fits on screen
   528 000002E3 59                      	 pop cx
   529 000002E4 51                      	 push cx			; update cx from variable
   530 000002E5 89FA                    	mov dx, di			; dx-> start of next part
   531 000002E7 800E[0200]10            	setopt [internalflags], promptwaiting	; mark as prompting necessary
   532 000002EC EBA2                    	jmp short .looplf		; now check whether anything follows at all
   533                                  		; This is the magic to suppress unnecessary prompts as
   534                                  		; were displayed previously. Now, we'll set this flag
   535                                  		; which effectively displays the prompt before (!) any
   536                                  		; other output is done. Previously, the prompt would be
   537                                  		; displayed right here. The only case where behaviour
   538                                  		; changed is when no more output occurs until the flag
   539                                  		; is reset elsewhere - ie. if getline prompts anyway.
   540                                  
   541                                  .promptnow:
   542 000002EE 52                      	push dx
   543 000002EF 51                      	push cx
   544 000002F0 C606[0000]00            	mov byte [ linecounter ], 0	; prompting, so reset the line counter
   545 000002F5 8026[0200]EF            	clropt [internalflags], promptwaiting
   546 000002FA 06                      	push es
   547 000002FB 16                      	 push ss
   548 000002FC 07                      	 pop es
   549 000002FD BA[0000]                	mov dx, msg.more		; es:dx -> message
   550 00000300 B9[0000]                	mov cx, msg.more_size
   551 00000303 E83F00                  	call .display			; print string (avoiding a recursion)
   552 00000306 07                      	pop es
   553                                  
   554 00000307 800E[0000]10            	setopt [internalflags3], dif3_input_terminal_override
   555                                  				; This option is a hack for the sole use of
   556                                  				; demo scripts that only want the user to press
   557                                  				; a key for paging.
   558 0000030C F606[0100]01            	testopt [options], nondospaging
   559 00000311 7405                    	jz .getc
   560 00000313 E88C04                  	call getc.raw			; get a character from BIOS
   561 00000316 EB03                    	jmp short .dispover
   562                                  .getc:
   563 00000318 E86E04                  	call getc			; get a character
   564                                  .dispover:
   565 0000031B 8026[0000]EF            	clropt [internalflags3], dif3_input_terminal_override
   566 00000320 3C03                    	cmp al, 3			; is it Ctrl+C ?
   567 00000322 7443                    	je .ctrlc			; yes, handle that -->
   568 00000324 E8(0000)                	call handle_serial_flags_ctrl_c
   569 00000327 06                      	push es
   570 00000328 16                      	 push ss
   571 00000329 07                      	 pop es
   572 0000032A BA[0000]                	mov dx, msg.more_over		; es:dx -> message
   573 0000032D B9[0000]                	mov cx, msg.more_over_size
   574 00000330 E81200                  	call .display			; overwrite the prompt (avoiding a recursion)
   575 00000333 07                      	pop es
   576 00000334 59                      	pop cx
   577 00000335 5A                      	pop dx
   578                                  
   579                                  .notyet:
   580 00000336 B00A                    	mov al, 10
   581 00000338 F2AE                    	repne scasb			; search LF
   582 0000033A 7507                    	jne .display_pop		; none -->
   583                                  
   584 0000033C FE06[0000]              	inc byte [ linecounter ]	; record how many LFs will be displayed
   585 00000340 E94DFF                  	jmp .looplf			; search for next LF -->
   586                                  
   587                                  .display_pop:
   588 00000343 59                      	pop cx
   589 00000344 5F                      	pop di
   590                                  .display:
   591                                  		; Non-paged output code follows.
   592                                  ;d4	call d4message
   593                                  ;d4	asciz "In puts.display first",13,10
   594                                  
   595 00000345 F606[0000]10            	testopt [serial_flags], sf_use_serial
   596 0000034A 7528                    	jnz .notdos
   597 0000034C E8(0000)                	call InDOS_or_BIOS_output
   598 0000034F 7523                    	jnz .notdos
   599                                  					; es:dx -> message
   600 00000351 BB0100                  	mov bx, 1			; standard output
   601 00000354 B440                    	mov ah, 40h			; write to file
   602 00000356 E30E                    	jcxz @F
   603                                  %if _PM
   604                                  d5	push di
   605 00000358 06                      	 push es			; point ds of _doscall* to msg segment
   606                                  d5	call d4message
   607                                  d5	asciz 13,10,"In puts.display, es="
   608                                  d5	 push es
   609                                  d5	call d4disp_stack_hex
   610                                  d5	call d4message
   611                                  d5	asciz "h",13,10
   612 00000359 E8(0000)EB02[0000]      	dualcall selector_to_segment	; make sure we give it as a segment
   613                                  		; This assumes that non-access-slice pointers into the
   614                                  		;  symbol tables (SYMSTR particularly) can be converted
   615                                  		;  into 86M segmented addresses, ie that the selector
   616                                  		;  points into 86M-accessible memory.
   617                                  d5	call d4message
   618                                  d5	asciz "In puts.display, on stack ="
   619                                  d5	pop di
   620                                  d5	push di
   621                                  d5	 push di
   622                                  d5	call d4disp_stack_hex
   623                                  d5	call d4message
   624                                  d5	asciz "h",13,10
   625 00000360 E8(0000)                	dual2call _doscall_return_es_parameter_es_ds
   626 00000363 83C402                  	 add sp, 2			; discard es returned from call
   627                                  d5	pop di
   628                                  %else
   629                                  	push ds
   630                                  	 push es
   631                                  	 pop ds				; ds:dx -> message
   632                                  	int 21h				; simply call into DOS
   633                                  	pop ds
   634                                  %endif
   635                                  @@:
   636 00000366 C3                      	retn
   637                                  
   638                                  .ctrlc:
   639                                  %if !_LOADER
   640 00000367 F606[0300]10            	testopt [internalflags2], dif2_in_silence_dump
   641 0000036C 7403                    	jz @F
   642 0000036E E80003                  	call reset_silent_mode
   643                                  @@:
   644                                  %endif
   645 00000371 E9(0000)                	jmp handle_ctrl_c		; abort currently running command -->
   646                                  		; If handled by DOS, Ctrl+C causes our process to be terminated.
   647                                  		; Because we are self-owned, we re-enter our code at debug22 then.
   648                                  		; debug22 only does some re-initialization of registers before
   649                                  		; entering cmd3. Therefore, instead of aborting we can directly jump
   650                                  		; to cmd3 here. This has the additional benefit of not requiring DOS
   651                                  		; at all, so that no workarounds for InDOS mode and boot loader
   652                                  		; operation are necessary.
   653                                  
   654                                  		; No command should fail spectacularly when being aborted this way,
   655                                  		; because in fact every command calling puts can already be aborted by
   656                                  		; DOS's Ctrl+C checking if DOS is used. This check is really only an
   657                                  		; _additional_ way the commands can be aborted.
   658                                  
   659                                  		; Note that a more complete way to support command abortion would be
   660                                  		; to hook Int1B, and to keep a flag of whether Ctrl+C or Ctrl+Break
   661                                  		; were requested, and to additionally check before or after every I/O
   662                                  		; operation whether Ctrl+C was pressed using non-destructive reads.
   663                                  		; In short, exactly what DOS does.
   664                                  
   665                                  .notdos:
   666 00000374 55                      	push bp
   667                                  		; Some int 10h functions can corrupt bp, eg
   668                                  		;  06h and 0Eh. Insure to preserve it here.
   669 00000375 56                      	push si
   670 00000376 F606[0200]01            	testopt [internalflags], usecharcounter
   671 0000037B 7505                    	jnz .dontresetcharcounter
   672 0000037D C606[0000]01            	mov byte [ charcounter ], 1
   673                                  		; This assumes we always start at the beginning of a line.
   674                                  		; Therefore any call to puts must display at the beginning
   675                                  		; of a line or tab parsing will not work. Only calls to puts
   676                                  		; not containing tab characters may display partial lines.
   677                                  		; (Calls to puts with partial lines and tab characters have
   678                                  		; to set the flag usecharcounter in internalflags.)
   679                                  .dontresetcharcounter:
   680 00000382 E35F                    	jcxz .return
   681 00000384 89D6                    	mov si, dx
   682                                  .loop:
   683 00000386 26AC                    	es lodsb
   684 00000388 3C09                    	cmp al, 9
   685 0000038A 750B                    	jne .nottab			; is no tab -->
   686 0000038C A0[0000]                	mov al, byte [ charcounter ]
   687 0000038F 2407                    	and al, 7			; at 8 character boundary ?
   688 00000391 B020                    	mov al, 32			; (always replaced by blank)
   689 00000393 7402                    	jz .nottab			; yes, don't use hack -->
   690 00000395 41                      	inc cx
   691 00000396 4E                      	dec si				; find tab again next lodsb
   692                                  .nottab:
   693 00000397 3C0D                    	cmp al, 13			; (exact match for CR)
   694 00000399 7505                    	jne .notcr
   695                                  .cr:
   696 0000039B C606[0000]00            	mov byte [ charcounter ], 0	; increased to one before displaying
   697                                  .notcr:
   698                                  %if 0				; currently we never receive BS here
   699                                  	cmp al, 8
   700                                  	jne .notbs
   701                                  	mov bh, byte [vpage]
   702                                  	mov bl, al			; save number of characters per column
   703                                  	push cx
   704                                  	mov ah, 03h
   705                                  	int 10h				; get cursor position dx
   706                                  	pop cx
   707                                  	dec byte [ charcounter ]	; assume not at start of line
   708                                  	mov al, 8			; changed by Int10
   709                                  	or dl, dl
   710                                  	jnz .dontcount			; not first column, so display normal -->
   711                                  	mov byte [ charcounter ], 1	; assume at start of screen
   712                                  	or dh, dh
   713                                  	jz .next			; at start of screen, don't display -->
   714                                  	dec dh				; previous line
   715                                  	mov dl, bl
   716                                  	mov byte [ charcounter ], dl	; really at end of line (one-based counter)
   717                                  	dec dl				; last column
   718                                  	mov ah, 02h
   719                                  	int 10h				; set new cursor position
   720                                  	jmp short .next
   721                                  .notbs:
   722                                  %endif
   723 000003A0 3C0A                    	cmp al, 10
   724 000003A2 7406                    	je .dontcount_lf		; must not count line feeds!
   725 000003A4 FE06[0000]              	inc byte [ charcounter ]
   726                                  %if _REGSHIGHLIGHT || _GETLINEHIGHLIGHT || _DHIGHLIGHT
   727 000003A8 EB05                    	jmp @F
   728                                  .dontcount_lf:
   729 000003AA 8026[0200]FD            	clropt [internalflags3], dif3_int10_highlight
   730                                  @@:
   731                                  %else
   732                                  .dontcount_lf:
   733                                  %endif
   734 000003AF F606[0000]10            	testopt [serial_flags], sf_use_serial
   735 000003B4 7405                    	jz @F
   736                                  
   737 000003B6 E8(0000)                	call serial_send_char
   738                                  
   739 000003B9 EB26                    	jmp .next
   740                                  @@:
   741                                  
   742                                  %if _REGSHIGHLIGHT || _GETLINEHIGHLIGHT || _DHIGHLIGHT || _CLEAR
   743 000003BB 3C1B                    	cmp al, 27
   744 000003BD 7427                    	je .try_highlight
   745                                  
   746                                  .nohighlight:
   747                                  %endif
   748 000003BF 8A3E[0000]              	mov bh, byte [vpage]		; use the current video page
   749                                  
   750                                  %if _REGSHIGHLIGHT || _GETLINEHIGHLIGHT || _DHIGHLIGHT
   751 000003C3 F606[0200]02            	testopt [internalflags3], dif3_int10_highlight
   752 000003C8 7411                    	jz @F
   753                                  
   754                                  		; Fix: do not write a musical note for CR.
   755                                  		;  This was caused by resetting the flag
   756                                  		;  dif3_int10_highlight only for LF.
   757                                  		; Also do not write BEL symbol.
   758                                  		; Hardening: Do not write attributes for
   759                                  		;  any nonprintable codepoint.
   760 000003CA 3C20                    	cmp al, 32
   761 000003CC 720D                    	jb @F
   762 000003CE B409                    	mov ah, 09h
   763 000003D0 8A1E[0000]              	mov bl, byte [.attribute]
   764 000003D4 51                      	push cx
   765 000003D5 B90100                  	mov cx, 1
   766 000003D8 CD10                    	int 10h
   767 000003DA 59                      	pop cx
   768                                  @@:
   769                                  %endif
   770                                  
   771 000003DB B307                    	mov bl, 7
   772 000003DD B40E                    	mov ah, 0Eh
   773 000003DF CD10                    	int 10h
   774                                  .next:
   775 000003E1 E2A3                    	loop .loop
   776                                  .return:
   777 000003E3 5E                      	pop si
   778 000003E4 5D                      	pop bp
   779 000003E5 C3                      	retn
   780                                  
   781                                  
   782                                  %if _REGSHIGHLIGHT || _GETLINEHIGHLIGHT || _DHIGHLIGHT || _CLEAR
   783                                  .try_highlight:
   784 000003E6 F606[0200]02            	testopt [options3], opt3_r_highlight_dumb
   785 000003EB 75D2                    	jnz .nohighlight
   786 000003ED 83F902                  	cmp cx, 2
   787 000003F0 76CD                    	jbe .nohighlight
   788 000003F2 26803C5B                	cmp byte [es:si], '['
   789 000003F6 75C7                    	jne .nohighlight
   790                                   %if _REGSHIGHLIGHT || _GETLINEHIGHLIGHT || _DHIGHLIGHT
   791 000003F8 26807C016D              	cmp byte [es:si + 1], 'm'
   792 000003FD 742F                    	je .highlight_reset
   793                                   %endif
   794 000003FF 83F903                  	cmp cx, 3
   795 00000402 74BB                    	je .nohighlight
   796                                   %if _CLEAR
   797 00000404 26807C0132              	cmp byte [es:si + 1], '2'
   798 00000409 7507                    	jne @F
   799 0000040B 26807C024A              	cmp byte [es:si + 2], 'J'
   800 00000410 7458                    	je .clear
   801                                  @@:
   802                                   %endif
   803                                   %if _REGSHIGHLIGHT || _GETLINEHIGHLIGHT || _DHIGHLIGHT
   804 00000412 26807C0137              	cmp byte [es:si + 1], '7'
   805 00000417 75A6                    	jne .nohighlight
   806 00000419 26807C026D              	cmp byte [es:si + 2], 'm'
   807 0000041E 759F                    	jne .nohighlight
   808                                  .highlight_set:
   809 00000420 E87D00                  	call check_dumb_mode
   810 00000423 749A                    	jz .nohighlight
   811                                  		; This test fails if we are at the very left of
   812                                  		;  the screen or in dosemu -dumb mode. So don't
   813                                  		;  use highlighting at the beginning of a line!
   814 00000425 800E[0200]02            	setopt [internalflags3], dif3_int10_highlight
   815 0000042A 49                      	dec cx
   816 0000042B 46                      	inc si
   817 0000042C EB05                    	jmp @F
   818                                  
   819                                  .highlight_reset:
   820 0000042E E86F00                  	call check_dumb_mode
   821 00000431 748C                    	jz .nohighlight
   822                                  		; Refer to above comment.
   823                                  @@:
   824 00000433 800E[0200]02            	setopt [internalflags3], dif3_int10_highlight
   825 00000438 E81800                  	call .getattrib
   826 0000043B 88E0                    	mov al, ah
   827 0000043D 257788                  	and ax, 8877h
   828 00000440 D0C0                    	rol al, 1
   829 00000442 D0C0                    	rol al, 1
   830 00000444 D0C0                    	rol al, 1
   831 00000446 D0C0                    	rol al, 1
   832 00000448 08E0                    	or al, ah
   833 0000044A A2[0000]                	mov byte [.attribute], al
   834                                   %endif
   835                                  
   836                                  .dec_2:
   837 0000044D 49                      	dec cx
   838 0000044E 49                      	dec cx
   839 0000044F 46                      	inc si
   840 00000450 46                      	inc si
   841 00000451 EB8E                    	jmp .next
   842                                  
   843                                  .getattrib:
   844 00000453 FECA                    	dec dl
   845 00000455 B402                    	mov ah, 02h
   846 00000457 8A3E[0000]              	mov bh, byte [vpage]
   847 0000045B CD10                    	int 10h			; set cursor position
   848 0000045D B408                    	mov ah, 08h
   849 0000045F CD10                    	int 10h			; read attribute to ah
   850 00000461 50                      	push ax
   851 00000462 FEC2                    	inc dl
   852 00000464 B402                    	mov ah, 02h
   853 00000466 CD10                    	int 10h			; set cursor position
   854 00000468 58                      	pop ax
   855 00000469 C3                      	retn
   856                                  
   857                                   %if _REGSHIGHLIGHT || _GETLINEHIGHLIGHT || _DHIGHLIGHT
   858                                  	usesection lDEBUG_DATA_ENTRY
   858          ------------------       note: usesection lDEBUG_DATA_ENTRY
   859                                  %if _LINK_COMPAT
   860                                  	align 2, db 0
   861                                  %endif
   862                                  
   863 00000000 00                      .attribute:	db 0
   864                                  	usesection lDEBUG_CODE
   864          ------------------       note: usesection lDEBUG_CODE
   865                                   %endif
   866                                  
   867                                   %if _CLEAR
   868                                  .clear:
   869 0000046A E83300                  	call check_dumb_mode
   870 0000046D 7503E94DFF              	jz .nohighlight
   871                                  
   872 00000472 E8DEFF                  	call .getattrib
   873 00000475 93                      	xchg bx, ax		; bh = attrib
   874                                  
   875 00000476 06                      	push es
   876 00000477 B84000                  	mov ax, 40h		; bi-modal seg/sel
   877 0000047A 8EC0                    	mov es, ax
   878 0000047C 51                      	push cx
   879                                  
   880                                  		; copied from RxANSI
   881 0000047D 31C9                    	xor	cx, cx
   882 0000047F 268A164A00              	mov	dl, [es:4Ah]		; number of rows
   883 00000484 FECA                    	dec	dl
   884 00000486 268A368400              	mov	dh, [es:84h]		; number of columns
   885 0000048B B80006                  	mov	ax, 0600h
   886 0000048E CD10                    	int	10h			; Clear screen (bh = attrib)
   887 00000490 31D2                    	xor	dx, dx			; Reset cursor to 0/0
   888 00000492 8A3E[0000]              	mov bh, byte [vpage]
   889 00000496 B402                    	mov ah, 02h
   890 00000498 CD10                    	int 10h				; Set cursor
   891                                  
   892 0000049A 59                      	pop cx
   893 0000049B 07                      	pop es
   894                                  
   895 0000049C 49                      	dec cx
   896 0000049D 46                      	inc si
   897 0000049E EBAD                    	jmp .dec_2
   898                                   %endif
   899                                  
   900                                  		; INP:	byte [vpage]
   901                                  		; CHG:	bx, dx
   902                                  		; OUT:	ZR iff dumb mode
   903                                  		; STT:	ds = ss
   904                                  check_dumb_mode:
   905 000004A0 50                      	push ax
   906 000004A1 51                      	push cx
   907 000004A2 B403                    	mov ah, 3
   908 000004A4 8A3E[0000]              	mov bh, byte [vpage]
   909 000004A8 31D2                    	xor dx, dx		; pre-initialise to zero
   910 000004AA CD10                    	int 10h			; dl = column, dh = row
   911 000004AC 84D2                    	test dl, dl
   912 000004AE 7416                    	jz .ret
   913 000004B0 F606[0300]01            	testopt [internalflags], runningdosemu
   914 000004B5 740D                    	jz .ret_NZ
   915 000004B7 B85500                  	mov ax, 55h		; function DOS_HELPER_GET_TERM_TYPE
   916 000004BA CDE6                    	int 0E6h		; CHG: ax, bx, cx
   917 000004BC 80E401                  	and ah, 1		; ax & 100h = dumb mode
   918 000004BF 80F401                  	xor ah, 1		; NZ if not dumb mode
   919 000004C2 EB02                    	jmp .ret
   920                                  .ret_NZ:
   921 000004C4 85E4                    	test sp, sp		; (NZ)
   922                                  .ret:
   923 000004C6 59                      	pop cx
   924 000004C7 58                      	pop ax
   925 000004C8 C3                      	retn
   926                                  %endif
   927                                  
   928                                  
   929                                  %if _40COLUMNS
   930                                  		; Display line_out, with IOCLINE linebreaks
   931                                  		;
   932                                  		; INP:	es:di -> behind last character to display
   933                                  		;	es:line_out -> first character to display
   934                                  		;	ax = last fragment length
   935                                  		; OUT:	ax = last fragment length
   936                                  		; STT:	ds = ss = debugger data selector
   937                                  		; CHG:	ax, bx, cx, dx
   938                                  putsline_break_line:
   939 000004C9 89F9                    	mov cx, di
   940 000004CB BA[0000]                	mov dx, line_out
   941 000004CE 29D1                    	sub cx, dx
   942                                  
   943                                  		; Display message, with IOCLINE linebreaks
   944                                  		;
   945                                  		; INP:	es:dx -> message to display
   946                                  		;	cx = length of message
   947                                  		;	ax = last fragment length
   948                                  		; OUT:	ax = last fragment length
   949                                  		; STT:	ds = ss = debugger data selector
   950                                  		; CHG:	ax, bx, cx, dx
   951                                  puts_break_line:
   952 000004D0 01C8                    	add ax, cx				; how much in this line if fits
   953 000004D2 8B1E[0000]              	mov bx, word [io_columns_getline]	; = how many columns to fill
   954 000004D6 85DB                    	test bx, bx				; disabled ?
   955 000004D8 7415                    	jz .no_split				; yes, use normal handler -->
   956 000004DA 39D8                    	cmp ax, bx				; total <= columns ?
   957 000004DC 7611                    	jbe .no_input_split			; yes, back to normal code -->
   958 000004DE 56                      	push si
   959 000004DF 89CE                    	mov si, cx				; si = length input
   960 000004E1 29C8                    	sub ax, cx				; restore last fragment length
   961 000004E3 89D9                    	mov cx, bx
   962 000004E5 29C1                    	sub cx, ax				; = how much fits in first line
   963 000004E7 29CE                    	sub si, cx				; = how much left, cannot carry
   964                                  
   965                                  		; INP:	si = how much left for subsequent iterations
   966                                  		;	es:dx -> data to display
   967                                  		;	bx = columns to fill
   968                                  		;	cx = length for this iteration
   969                                  		; OUT:	cx = length of last write (0 if empty, no linebreak)
   970                                  		; CHG:	si, dx
   971 000004E9 E81500                  	call puts_partial_write
   972 000004EC 91                      	xchg ax, cx				; ax = last fragment length
   973 000004ED 5E                      	pop si
   974 000004EE C3                      	retn
   975                                  
   976                                  .no_split:
   977                                  .no_input_split:
   978 000004EF 50                      	push ax
   979 000004F0 E8BCFC                  	call puts
   980 000004F3 58                      	pop ax
   981                                  puts_break_line_more.retn:
   982 000004F4 C3                      	retn
   983                                  
   984                                  
   985                                  		; Display a linebreak if last fragment length is zero
   986                                  		;  and there is more to display. This function is only
   987                                  		;  to be called if there is more output to display!
   988                                  		;
   989                                  		; INP:	ax = last fragment length (no action if nonzero)
   990                                  		; OUT:	line break displayed if ax was zero
   991                                  		; CHG:	dx
   992                                  puts_break_line_more:
   993 000004F5 85C0                    	test ax, ax
   994 000004F7 75FB                    	jnz .retn
   995 000004F9 BA[0000]                	mov dx, crlf
   996 000004FC E92602                  	jmp putsz
   997                                  
   998                                  
   999                                  puts_partial_write.loop:
  1000 000004FF 89D9                    	mov cx, bx
  1001                                  
  1002                                  		; INP:	si = how much left for subsequent iterations
  1003                                  		;	es:dx -> data to display
  1004                                  		;	bx = columns to fill
  1005                                  		;	cx = length for this iteration
  1006                                  		; OUT:	cx = length of last write (0 if empty, no linebreak)
  1007                                  		; CHG:	si, dx
  1008                                  puts_partial_write:
  1009 00000501 53                      	push bx
  1010 00000502 51                      	push cx
  1011 00000503 52                      	push dx
  1012 00000504 E8A8FC                  	call puts				; display partial
  1013 00000507 85F6                    	test si, si				; more to go ?
  1014 00000509 7406                    	jz @F					; no -->
  1015 0000050B BA[0000]                	mov dx, crlf
  1016 0000050E E81402                  	call putsz				; put linebreak
  1017                                  @@:
  1018 00000511 5A                      	pop dx
  1019 00000512 59                      	pop cx
  1020 00000513 5B                      	pop bx
  1021 00000514 01CA                    	add dx, cx				; advance pointer
  1022 00000516 29DE                    	sub si, bx				; subtract from counter
  1023 00000518 73E5                    	jnc .loop				; still above zero, loop -->
  1024 0000051A 01DE                    	add si, bx				; restore prior si value
  1025 0000051C 89F1                    	mov cx, si
  1026 0000051E 53                      	push bx
  1027 0000051F 51                      	push cx
  1028 00000520 E88CFC                  	call puts				; display last part (possibly empty)
  1029 00000523 59                      	pop cx					; return cx
  1030 00000524 5B                      	pop bx
  1031 00000525 C3                      	retn
  1032                                  %else
  1033                                  putsline_break_line: equ putsline
  1034                                  puts_break_line: equ puts
  1035                                  puts_break_line_more: equ dmycmd
  1036                                  %endif
  1037                                  
  1038                                  
  1039                                  %if !_LOADER
  1040                                  		; INP:	es:dx -> message to display
  1041                                  		;	cx = length of message
  1042                                  		; STT:	ds = ss = debugger data selector
  1043                                  		; CHG:	ax, bx, cx, dx
  1044                                  puts_silence:
  1045 00000526 56                      	push si
  1046 00000527 57                      	push di
  1047                                  
  1048                                  .try_again:
  1049 00000528 89D6                    	mov si, dx			; es:si -> message
  1050 0000052A 8B3E[0000]              	mov di, word [auxbuff_behind_last_silent]
  1051                                  					; (auxbuff):di -> next buffer (if it fits)
  1052                                  %if _AUXBUFFSIZE == _AUXBUFFMAXSIZE
  1053                                  	mov ax, _AUXBUFFSIZE - 1
  1054                                  %else
  1055 0000052E A1[0000]                	mov ax, word [auxbuff_current_size]
  1056 00000531 48                      	dec ax
  1057                                  %endif
  1058 00000532 29F8                    	sub ax, di			; number of bytes left free
  1059                                  					;  (+ 1 byte terminator)
  1060 00000534 7204                    	jc .delete
  1061 00000536 39C8                    	cmp ax, cx			; fits ?
  1062 00000538 730B                    	jae .simple			; yes -->
  1063                                  
  1064                                  .delete:
  1065 0000053A 06                      	push es
  1066 0000053B 8E06[0000]              	mov es, word [auxbuff_segorsel]
  1067 0000053F E81600                  	call silence_delete_one_string
  1068 00000542 07                      	pop es
  1069 00000543 EBE3                    	jmp .try_again
  1070                                  
  1071                                  .simple:
  1072 00000545 1E                      	push ds
  1073 00000546 06                      	push es
  1074 00000547 06                      	 push es
  1075 00000548 8E06[0000]              	 mov es, word [auxbuff_segorsel]
  1076                                  					; es:di -> next buffer
  1077 0000054C 1F                      	 pop ds				; ds:si -> message
  1078 0000054D F3A4                    	rep movsb			; copy over
  1079 0000054F 07                      	pop es
  1080 00000550 1F                      	pop ds
  1081 00000551 893E[0000]              	mov word [auxbuff_behind_last_silent], di
  1082                                  					; update pointer
  1083 00000555 5F                      	pop di
  1084 00000556 5E                      	pop si
  1085 00000557 C3                      	retn
  1086                                  
  1087                                  
  1088                                  		; INP:	es => auxbuff
  1089                                  		;	ds = ss
  1090                                  		;	[auxbuff_behind_last_silent] -> behind last silent
  1091                                  		; OUT:	[auxbuff_behind_last_silent] updated
  1092                                  		;	auxbuff updated (deleted one of the dump strings,
  1093                                  		;	 moved forwards in the buffer the remainder)
  1094                                  		;	if error, aborts command by jumping to cmd3
  1095                                  		; CHG:	ax, di, si
  1096                                  silence_delete_one_string:
  1097 00000558 E81F00                  	call .internal			; call internal implementation
  1098 0000055B 735D                    	jnc .retn			; no error ? -->
  1099                                  .error:					; else: error, abort command
  1100 0000055D 16                      	push ss
  1101 0000055E 1F                      	pop ds
  1102 0000055F 16                      	push ss
  1103 00000560 07                      	pop es
  1104 00000561 8026[0300]DF            	clropt [internalflags], tt_silence
  1105                                  %if _RH
  1106 00000566 C606[0000]FF            	mov byte [skip_rh], 0FFh
  1107                                  %endif
  1108 0000056B BA[0000]                	mov dx, msg.silent_error
  1109 0000056E E8B401                  	call putsz
  1110 00000571 B83501                  	mov ax, 0135h
  1111 00000574 E8(0000)                	call setrc
  1112 00000577 E9(0000)                	jmp cmd3
  1113                                  
  1114                                  
  1115                                  		; INP:	as for silence_delete_one_string
  1116                                  		; OUT:	as for silence_delete_one_string, but:
  1117                                  		;	 CY if error (no more space)
  1118                                  		;	 NC if success
  1119                                  		; CHG:	ax, di, si
  1120                                  		; STT:	ds = ss
  1121                                  .internal:
  1122 0000057A 51                      	push cx
  1123 0000057B 8B0E[0000]              	mov cx, [auxbuff_behind_last_silent]
  1124                                  					; -> next buffer position
  1125                                  %if _PM
  1126 0000057F 8B3E[0000]              	mov di, word [auxbuff_switchbuffer_size]
  1127 00000583 29F9                    	sub cx, di
  1128                                  %else
  1129                                  	xor di, di
  1130                                  %endif
  1131 00000585 B000                    	mov al, 0
  1132 00000587 3C01                    	cmp al, 1			; initialise to NZ (if cx is zero)
  1133 00000589 F2AE                    	repne scasb
  1134 0000058B F9                      	stc
  1135 0000058C 752C                    	jne .retn			; error, no NUL found in data (CY)
  1136                                  		; es:di -> behind first NUL
  1137                                  
  1138 0000058E 89FE                    	mov si, di			; es:si -> next message
  1139                                  %if _RH
  1140 00000590 89F8                    	mov ax, di
  1141                                  %endif
  1142                                  %if _PM
  1143 00000592 8B3E[0000]              	mov di, word [auxbuff_switchbuffer_size]
  1144                                   %if _RH
  1145 00000596 29F8                    	sub ax, di			; -> next minus -> first, length of first
  1146                                   %endif
  1147                                  %else
  1148                                  	xor di, di
  1149                                  %endif
  1150                                  %if _RH
  1151 00000598 2906[0000]              	sub word [auxbuff_start_silent], ax
  1152                                   %if _PM
  1153 0000059C 7206                    	jb .reset_start
  1154 0000059E 393E[0000]              	cmp word [auxbuff_start_silent], di
  1155                                   %endif
  1156 000005A2 7304                    	jae @F
  1157                                  .reset_start:
  1158 000005A4 893E[0000]              	mov word [auxbuff_start_silent], di
  1159                                  @@:
  1160                                  %endif
  1161 000005A8 8B0E[0000]              	mov cx, word [auxbuff_behind_last_silent]
  1162 000005AC 06                      	push es
  1163 000005AD 1F                      	pop ds				; ds:si -> next message
  1164 000005AE 29F1                    	sub cx, si			; remaining buffer
  1165 000005B0 F3A4                    	rep movsb			; move to start of silent buffer
  1166 000005B2 16                      	push ss
  1167 000005B3 1F                      	pop ds
  1168 000005B4 893E[0000]              	mov word [auxbuff_behind_last_silent], di
  1169 000005B8 59                      	pop cx
  1170 000005B9 F8                      	clc				; (NC)
  1171                                  .retn:
  1172 000005BA C3                      	retn
  1173                                  
  1174                                  
  1175                                  		; After having used puts_silence, this dumps all data
  1176                                  		;  remaining in the silent buffer in auxbuff.
  1177                                  		; If word [tt_silent_mode_number] is set, only that many
  1178                                  		;  data strings (zero-terminated) are dumped, from the end
  1179                                  		;  of the buffer.
  1180                                  		;
  1181                                  		; CHG:	ax, bx, cx, dx, si, di, es
  1182                                  		; STT:	ds = ss = debugger data selector
  1183                                  		;	sets es to ss
  1184                                  silence_dump:
  1185 000005BB F606[0300]10            	testopt [internalflags], tt_silent_mode	; is in use ?
  1186 000005C0 7501                    	jnz @F			; yes -->
  1187 000005C2 C3                      	retn			; no. simple
  1188                                  
  1189                                  @@:
  1190                                  %if _RH
  1191 000005C3 C606[0000]00            	mov byte [rh_display_with_count], 0
  1192                                  .rh.all:
  1193 000005C8 B8FFFF                  	mov ax, -1
  1194                                  .rh:
  1195 000005CB A3[0000]                	mov word [auxbuff_amount_silent], ax
  1196                                  %endif
  1197 000005CE 8026[0300]DF            	clropt [internalflags], tt_silence
  1198 000005D3 800E[0300]10            	setopt [internalflags2], dif2_in_silence_dump
  1199                                  
  1200 000005D8 F606[0100]01            	testopt [options3], opt3_silence_paging_set
  1201 000005DD 7413                    	jz @F
  1202 000005DF F606[0100]02            	testopt [options3], opt3_silence_paging_on
  1203 000005E4 7407                    	jz .turn_paging_off
  1204                                  
  1205                                  .turn_paging_on:
  1206 000005E6 800E[0000]08            	setopt [internalflags], pagedcommand
  1207 000005EB EB05                    	jmp @F
  1208                                  
  1209                                  .turn_paging_off:
  1210 000005ED 8026[0000]F7            	clropt [internalflags], pagedcommand
  1211                                  @@:
  1212                                  
  1213 000005F2 E8BA00                  	call silence_get_start
  1214 000005F5 741E                    	jz .no_number_given
  1215                                  
  1216 000005F7 8B16[0000]              	mov dx, word [tt_silent_mode_number]
  1217 000005FB 85D2                    	test dx, dx
  1218 000005FD 7416                    	jz .no_number_given
  1219                                  
  1220 000005FF E8BC00                  	call silence_count_zeroes
  1221                                  
  1222                                  %if _RH
  1223 00000602 8B3E[0000]              	mov di, word [auxbuff_start_silent]
  1224                                  				; reset to -> silent buffered data
  1225                                  %endif
  1226 00000606 29D3                    	sub bx, dx		; number of dumps - requested number
  1227                                  				;  = excess number of dumps
  1228 00000608 760B                    	jbe .no_number_given
  1229                                  
  1230 0000060A 89D9                    	mov cx, bx		; use excess number as loop counter
  1231                                  @@:
  1232                                  %if _RH
  1233 0000060C 51                      	push cx
  1234 0000060D B9FFFF                  	mov cx, -1
  1235                                  	; mov al, 0
  1236 00000610 F2AE                    	repne scasb
  1237 00000612 59                      	pop cx
  1238                                  %else
  1239                                  	call silence_delete_one_string
  1240                                  				; delete one string
  1241                                  %endif
  1242 00000613 E2F7                    	loop @B			; loop for however many to delete -->
  1243                                  
  1244                                  .no_number_given:
  1245                                  %if _RH
  1246 00000615 E86400                  	call .rh_display_count
  1247                                  %endif
  1248                                  
  1249                                  %ifn _RH
  1250                                   %if _PM
  1251                                  	mov di, word [auxbuff_switchbuffer_size]
  1252                                   %else
  1253                                  	xor di, di
  1254                                   %endif
  1255                                  %endif
  1256                                  				; es:di -> silent buffer
  1257                                  .loop_line:
  1258 00000618 8E06[0000]              	mov es, word [auxbuff_segorsel]
  1259 0000061C 8B0E[0000]              	mov cx, word [auxbuff_behind_last_silent]
  1260 00000620 29F9                    	sub cx, di		; any more data ?
  1261 00000622 744B                    	jz .return		; no, return -->
  1262 00000624 B000                    	mov al, 0
  1263 00000626 49                      	dec cx			; (in case of branching for next conditional)
  1264 00000627 AE                      	scasb			; starts with a NUL byte ?
  1265 00000628 7404                    	je @F			; yes, skipped -->
  1266 0000062A 41                      	inc cx			; (restore cx to original value)
  1267 0000062B 4F                      	dec di			; no, decrement
  1268                                  %if _RH
  1269 0000062C EB05                    	jmp @FF
  1270                                  @@:
  1271 0000062E E303                    	jcxz @F			; anything follows the NUL ?
  1272 00000630 E84900                  	call .rh_display_count
  1273                                  %endif
  1274                                  @@:
  1275 00000633 89FE                    	mov si, di		; es:si -> start of string
  1276                                  
  1277 00000635 81F90001                	cmp cx, 256		; cx > 256 ?
  1278 00000639 7603                    	jbe @F			; no -->
  1279 0000063B B90001                  	mov cx, 256		; limit to 256 bytes per string
  1280                                  				; (line_out is 264 bytes)
  1281                                  @@:
  1282 0000063E E32F                    	jcxz .return		; (if single byte that was NUL remaining -->)
  1283 00000640 89CB                    	mov bx, cx		; search string length
  1284 00000642 B000                    	mov al, 0
  1285 00000644 F2AE                    	repne scasb		; scan for NUL bytes
  1286 00000646 7505                    	jne @F			; (if none found: cx = 0)
  1287                                  				; (if any found: cx = remaining length)
  1288 00000648 41                      	inc cx			; cx = remaining length + 1 (do not output NUL)
  1289                                  %if _RH
  1290 00000649 FF0E[0000]              	dec word [auxbuff_amount_silent]
  1291                                  %endif
  1292                                  @@:
  1293 0000064D 29CB                    	sub bx, cx		; search length - remaining = found length
  1294 0000064F 89D9                    	mov cx, bx		; how much to show
  1295 00000651 06                      	 push es
  1296 00000652 1F                      	 pop ds			; ds => auxbuff (ds:si -> start of string)
  1297 00000653 16                      	 push ss
  1298 00000654 07                      	 pop es			; es => line_out
  1299 00000655 BF[0000]                	mov di, line_out	; es:di -> line_out
  1300 00000658 51                      	 push cx
  1301 00000659 F3A4                    	rep movsb		; copy over to line_out
  1302 0000065B 59                      	 pop cx			; cx = message length
  1303                                  
  1304 0000065C 16                      	push ss
  1305 0000065D 1F                      	pop ds			; reset seg regs to ss
  1306 0000065E BA[0000]                	mov dx, line_out	; dx -> message, cx = length
  1307 00000661 56                      	push si
  1308 00000662 E87FFB                  	call puts.no_rh		; print out
  1309 00000665 5F                      	pop di			; -> next silent message
  1310                                  %if _RH
  1311 00000666 833E[0000]00            	cmp word [auxbuff_amount_silent], 0
  1312 0000066B 7402                    	je .return
  1313                                  %endif
  1314 0000066D EBA9                    	jmp .loop_line
  1315                                  
  1316                                  .return:
  1317 0000066F 16                      	push ss
  1318 00000670 07                      	pop es
  1319                                  
  1320                                  reset_silent_mode: equ $
  1321 00000671 8026[0300]CF            	clropt [internalflags], tt_silent_mode | tt_silence
  1322 00000676 8026[0300]EF            	clropt [internalflags2], dif2_in_silence_dump
  1323 0000067B C3                      	retn
  1324                                  
  1325                                  
  1326                                  %if _RH
  1327                                  .rh_display_count:
  1328 0000067C D006[0000]              	rol byte [rh_display_with_count], 1
  1329 00000680 57                      	push di
  1330 00000681 51                      	push cx
  1331 00000682 06                      	push es
  1332 00000683 7326                    	jnc @F
  1333 00000685 A1[0000]                	mov ax, word [rh_count_number]
  1334 00000688 83F8FF                  	cmp ax, -1
  1335 0000068B 741E                    	je @F
  1336 0000068D FF0E[0000]              	dec word [rh_count_number]
  1337 00000691 16                      	 push ss
  1338 00000692 07                      	 pop es
  1339 00000693 BF[0000]                	mov di, line_out
  1340 00000696 BE[0000]                	mov si, msg.rh_step.1
  1341 00000699 E8(0000)                	call copy_single_counted_string
  1342 0000069C E8CCFA                  	call hexword
  1343 0000069F BE[0000]                	mov si, msg.rh_step.2
  1344 000006A2 E8(0000)                	call copy_single_counted_string
  1345 000006A5 E848FA                  	call decword
  1346 000006A8 E8F9FA                  	call putsline_crlf
  1347                                  @@:
  1348 000006AB 07                      	pop es
  1349 000006AC 59                      	pop cx
  1350 000006AD 5F                      	pop di
  1351 000006AE C3                      	retn
  1352                                  %endif
  1353                                  
  1354                                  
  1355                                  		; STT:	ss = ds
  1356                                  		; OUT:	es => auxbuff
  1357                                  		;	es:di -> start of silent data
  1358                                  		;	cx = length of silent data
  1359                                  		;	ZR if cx == 0
  1360                                  silence_get_start: section_of_function
  1361                                  %if _RH
  1362 000006AF 8B3E[0000]              	mov di, word [auxbuff_start_silent]
  1363                                  %elif _PM
  1364                                  	mov di, word [auxbuff_switchbuffer_size]
  1365                                  %else
  1366                                  	xor di, di
  1367                                  %endif
  1368                                  
  1369                                  		; INP:	auxbuff:di -> start of data
  1370                                  .have_di: section_of_function silence_get_start
  1371 000006B3 8E06[0000]              	mov es, word [auxbuff_segorsel]
  1372 000006B7 8B0E[0000]              	mov cx, word [auxbuff_behind_last_silent]
  1373 000006BB 29F9                    	sub cx, di
  1374 000006BD C3                      	retn
  1375                                  
  1376                                  
  1377                                  		; STT:	ss = ds
  1378                                  		; OUT:	es => auxbuff
  1379                                  		;	bx = number of zeroes in silent data
  1380                                  		;	cx = 0
  1381                                  		; CHG:	ax, di
  1382                                  silence_count_zeroes: section_of_function
  1383 000006BE 31DB                    	xor bx, bx		; counter of zeros
  1384                                  @@:
  1385 000006C0 43                      	inc bx			; count zeros (NZ)
  1386 000006C1 B000                    	mov al, 0
  1387                                  	; jcxz @F		; no more data -->
  1388                                  		; If cx == 0 then the inc bx left bx <> 0 so NZ.
  1389                                  		;  Therefore the repne scasb will run zero iterations
  1390                                  		;  and leave NZ, causing the next conditional jump to
  1391                                  		;  not branch back into the loop.
  1392 000006C3 F2AE                    	repne scasb		; another zero ?
  1393 000006C5 74F9                    	je @B			; yes, count and search for next -->
  1394                                  				; no, done
  1395                                  @@:
  1396 000006C7 4B                      	dec bx			; drop bias
  1397 000006C8 C3                      	retn
  1398                                  %endif
  1399                                  
  1400                                  
  1401                                  %if _MESSAGESEGMENT && _PM
  1402                                  get_messagesegsel:
  1403 000006C9 368E1E[0000]             	mov ds, word [ss:messagesel]
  1404 000006CE E8(0000)                 	call ispm
  1405 000006D1 7405                     	jz .ret_pm
  1406                                  .86m:
  1407 000006D3 368E1E[0000]             	mov ds, word [ss:messageseg]
  1408                                  .ret_pm:
  1409 000006D8 C3                       	retn
  1410                                  %endif
  1411                                  
  1412                                  
  1413                                  		; INP:	message segment:(dx & ~1) -> message
  1414                                  		;	(dx & 1) if message is uncompressed (ASCIZ),
  1415                                  		;	 however the low bit must be masked off
  1416                                  		;	else the message is compressed
  1417                                  		; CHG:	dx low bit
  1418                                  		; OUT:	message displayed
  1419                                  		; REM:	The protocol implies that all messages passed
  1420                                  		;	 to this function must start on a word boundary.
  1421                                  putsz_exthelp: section_of_function
  1422                                  %if _HELP_COMPRESSED
  1423 000006D9 F6C201                  	test dl, 1
  1424 000006DC 7538                    	jnz .uncompressed
  1425                                  
  1426                                  .compressed:
  1427 000006DE 1E                      	push ds
  1428 000006DF 50                      	push ax
  1429 000006E0 53                      	push bx
  1430 000006E1 51                      	push cx
  1431 000006E2 52                      	push dx
  1432 000006E3 06                      	push es
  1433 000006E4 57                      	push di
  1434 000006E5 56                      	push si
  1435                                  
  1436                                  %if _TEST_HELP_FILE
  1437                                  	mov word [ss:hshrink_get_file_byte], hshrink_memory_read
  1438                                  					; insure correct source
  1439                                  %endif
  1440 000006E6 87F2                    	xchg si, dx			; si -> message compressed length
  1441                                  %if _MESSAGESEGMENT
  1442                                   %if _PM
  1443 000006E8 E8DEFF                  	call get_messagesegsel		; ds => message segment
  1444                                   %else
  1445                                   	mov ds, word [ss:messageseg]	; ds => message segment
  1446                                   %endif
  1447 000006EB AD                      	lodsw				; = length
  1448                                  %else
  1449                                  	ss lodsw			; = length
  1450                                  %endif
  1451 000006EC 91                      	xchg cx, ax			; = length
  1452 000006ED 368936[0000]            	mov word [ss:hshrink_memory_source.offset], si
  1453                                  					; save offset of data
  1454 000006F2 1E                      	push ds
  1455 000006F3 07                      	pop es				; => message segment
  1456                                  %if _BOOTLDR_DISCARD_HELP
  1457 000006F4 368B3E[0000]            	mov di, [ss:indirect_hshrink_message_buffer]
  1458 000006F9 8DB50A0B                	lea si, [di + hshrink_message_buffer_size]
  1459                                  %else
  1460                                  	mov di, nontruncated_hshrink_message_buffer	; es:di -> destination
  1461                                  	mov si, nontruncated_hshrink_message_buffer + hshrink_message_buffer_size
  1462                                  					; si -> behind destination end
  1463                                  %endif
  1464 000006FD 06                      	push es
  1465 000006FE 57                      	push di
  1466 000006FF E8(0000)                	call depack			; try depacking
  1467                                  		; ds reset before calling puts
  1468 00000702 5A                      	pop dx				; display our decompressed string
  1469 00000703 07                      	pop es
  1470 00000704 730D                    	jnc @F				; skip next part if not error -->
  1471 00000706 16                      	push ss
  1472 00000707 07                      	pop es
  1473 00000708 16                      	push ss
  1474 00000709 1F                      	pop ds
  1475 0000070A B82B01                  	mov ax, 012Bh
  1476 0000070D E8(0000)                	call setrc
  1477 00000710 BA[0000]                	mov dx, msg.hshrink_error	; if error
  1478                                  @@:
  1479 00000713 5E                      	pop si
  1480 00000714 EB18                    	jmp putsz.saved
  1481                                  
  1482                                  .uncompressed:
  1483 00000716 80E2FE                  	and dl, ~1
  1484                                  		; fall through to putsz_messagesegsel
  1485                                  
  1486                                  %endif
  1487                                  
  1488                                  putsz_messagesegsel:
  1489 00000719 1E                      	push ds
  1490                                  %if _MESSAGESEGMENT
  1491                                   %if _PM
  1492 0000071A E8ACFF                  	call get_messagesegsel
  1493                                   %else
  1494                                   	mov ds, word [ss:messageseg]
  1495                                   %endif
  1496                                  %else
  1497                                  	push ss
  1498                                  	pop ds
  1499                                  %endif
  1500 0000071D EB07                     	jmp @F
  1501                                  
  1502                                  
  1503                                  putsz_error: section_of_function
  1504 0000071F 36800E[0100]20          	setopt [ss:internalflags3], dif3_unquiet_error
  1505                                  
  1506                                  		; Display ASCIZ message
  1507                                  		;
  1508                                  		; INP:	ds:dx -> ASCIZ message to display
  1509                                  		; CHG:	-
  1510                                  		; STT:	ds, es don't care
  1511                                  putsz: section_of_function
  1512 00000725 1E                      	push ds
  1513                                  @@:
  1514 00000726 50                      	push ax
  1515 00000727 53                      	push bx
  1516 00000728 51                      	push cx
  1517 00000729 52                      	push dx
  1518 0000072A 06                      	push es
  1519 0000072B 1E                      	 push ds
  1520 0000072C 07                      	 pop es
  1521 0000072D 57                      	push di
  1522                                  .saved:
  1523 0000072E 89D7                    	mov di, dx			; es:di-> string
  1524 00000730 30C0                    	xor al, al
  1525 00000732 B9FFFF                  	mov cx, -1
  1526 00000735 F2AE                    	repne scasb			; search zero
  1527 00000737 F7D1                    	not cx
  1528 00000739 49                      	dec cx				; cx = length of message
  1529 0000073A 5F                      	pop di
  1530 0000073B 16                      	 push ss
  1531 0000073C 1F                      	 pop ds				; ds = ss
  1532 0000073D E86FFA                  	call puts
  1533 00000740 07                      	pop es
  1534 00000741 5A                      	pop dx
  1535 00000742 59                      	pop cx
  1536 00000743 5B                      	pop bx
  1537 00000744 58                      	pop ax
  1538 00000745 1F                      	pop ds
  1539 00000746 C3                      	retn
  1540                                  
  1541                                  		; Display character
  1542                                  		;
  1543                                  		; INP:	al = character to display
  1544                                  		; CHG:	-
  1545                                  		; STT:	ds, es don't care
  1546                                  %if _LINK
  1547                                  disp_al: section_of_function
  1548                                  %endif
  1549                                  check_section_of disp_al
  1550                                  putc: section_of_function
  1551 00000747 53                      	push bx
  1552 00000748 51                      	push cx
  1553 00000749 52                      	push dx
  1554 0000074A 06                      	push es
  1555 0000074B 1E                      	push ds
  1556 0000074C 16                      	 push ss
  1557 0000074D 07                      	 pop es				; es:dx -> message
  1558 0000074E 16                      	 push ss
  1559 0000074F 1F                      	 pop ds				; ds = ss
  1560 00000750 50                      	push ax
  1561 00000751 B90100                  	mov cx, 1			; one character
  1562 00000754 89E2                    	mov dx, sp			; ds:dx-> ax on stack
  1563 00000756 E856FA                  	call puts
  1564 00000759 58                      	pop ax
  1565 0000075A 1F                      	pop ds
  1566 0000075B 07                      	pop es
  1567 0000075C 5A                      	pop dx
  1568 0000075D 59                      	pop cx
  1569 0000075E 5B                      	pop bx
  1570 0000075F C3                      	retn
  1571                                  
  1572                                  
  1573                                  		; OUT:	ax = 0 if no input available
  1574                                  		;	ax = 0FFFFh if DOS stdin input available
  1575                                  		;	ah = scancode, al = ASCII if int 16h input available
  1576                                  		;	ax = al = ASCII if serial input available
  1577                                  		; REM:	This is always a nondestructive read.
  1578                                  peekc: section_of_function
  1579 00000760 F606[0000]10            	testopt [serial_flags], sf_use_serial
  1580 00000765 750C                    	jnz .serial
  1581 00000767 E8(0000)                	call InDOS_or_BIOS_IO
  1582 0000076A 740E                    	jz .dos
  1583                                  .bios:
  1584 0000076C B401                    	mov ah, 01h
  1585 0000076E CD16                    	int 16h			; key available ?
  1586                                  @@:
  1587 00000770 7413                    	jz .return_ax_0
  1588 00000772 C3                      	retn
  1589                                  
  1590                                  .serial:
  1591 00000773 E8(0000)                	call serial_check_receive_char
  1592                                  				; do serial getc (check rx buffer)
  1593 00000776 B400                    	mov ah, 0
  1594 00000778 EBF6                    	jmp @B
  1595                                  
  1596                                  .dos:
  1597 0000077A B40B                    	mov ah, 0Bh
  1598                                  	doscall
  1491 0000077C E8(0000)            <1>  nearcall _doscall
  1599 0000077F B4FF                    	mov ah, -1
  1600 00000781 84C0                    	test al, al
  1601 00000783 EBEB                    	jmp @B
  1602                                  
  1603                                  .return_ax_0:
  1604 00000785 B80000                  	mov ax, 0
  1605                                  .return:
  1606 00000788 C3                      	retn
  1607                                  
  1608                                  
  1609                                  		; Get character/key
  1610                                  		;
  1611                                  		; OUT:	al = character (if zero, look for ah)
  1612                                  		;	ah = scan code or zero
  1613                                  		; CHG:	ax
  1614                                  		; STT:	ds = ss = debugger segment/selector
  1615                                  		;
  1616                                  		; Idles system when in InDOS mode. When not in InDOS mode, Int21.08
  1617                                  		; is used which is assumed to idle the system itself.
  1618                                  getc: section_of_function
  1619 00000789 57                      	push di
  1620 0000078A BF[9409]                	mov di, getc_if_any
  1621                                  
  1622 0000078D F606[0000]20            	testopt [internalflags3], dif3_input_serial_override
  1623 00000792 750C                    	jnz @F
  1624 00000794 F606[0000]10            	testopt [serial_flags], sf_use_serial
  1625 00000799 7505                    	jnz @F
  1626 0000079B E8(0000)                	call InDOS_or_BIOS_IO
  1627 0000079E 7450                    	jz getc_dos_pop_di
  1628                                  @@:
  1629 000007A0 EB04                    	jmp @F
  1630                                  
  1631                                  .raw:
  1632 000007A2 57                      	push di
  1633 000007A3 BF[FE09]                	mov di, getc_if_any.raw
  1634                                  .loop:
  1635                                  @@:
  1636 000007A6 FF16[0000]              	call near word [getline_timer_func]
  1637 000007AA F606[0000]20            	testopt [internalflags3], dif3_input_serial_override
  1638 000007AF 7523                    	jnz @F
  1639 000007B1 F606[0300]01            	testopt [internalflags3], dif3_input_re
  1640 000007B6 751C                    	jnz @F
  1641                                  %if _INPUT_FILE_BOOT
  1642 000007B8 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  1643 000007BD 7515                    	jnz @F
  1644                                  %endif
  1645 000007BF F606[0100]01            	testopt [internalflags3], dif3_input_cmdline
  1646 000007C4 750E                    	jnz @F
  1647 000007C6 F606[0000]10            	testopt [serial_flags], sf_use_serial
  1648 000007CB 7507                    	jnz @F
  1649 000007CD F606[0100]04            	testopt [options], biosidles
  1650                                  				; idling disabled?
  1651 000007D2 7516                    	jnz .rawkey		; yes, just request a key -->
  1652                                  
  1653                                  @@:
  1654 000007D4 FFD7                    	call di			; got a key ?
  1655 000007D6 7516                    	jnz .return		; yes -->
  1656                                  .idle:				; common idling for BIOS keyboard and serial
  1657 000007D8 E8(0000)                	call handle_serial_flags_ctrl_c
  1658                                  %if _SLEEP_NEW
  1659 000007DB 57                      	push di
  1660 000007DC 8B3E[0000]              	mov di, word [getc_repeat_idle]
  1661 000007E0 47                      	inc di
  1662                                  @@:
  1663 000007E1 E89302                  	call idle
  1664 000007E4 4F                      	dec di
  1665 000007E5 75FA                    	jnz @B
  1666 000007E7 5F                      	pop di
  1667                                  %else
  1668                                  	call idle
  1669                                  %endif
  1670 000007E8 EBBC                    	jmp .loop		; check again -->
  1671                                  
  1672                                  .rawkey:
  1673 000007EA 31C0                    	xor ax, ax
  1674 000007EC CD16                    	int 16h			; get the key and scancode
  1675                                  .return:
  1676 000007EE 5F                      	pop di
  1677 000007EF C3                      	retn
  1678                                  
  1679                                  
  1680                                  getc_dos_pop_di:
  1681 000007F0 5F                      	pop di
  1682                                  getc_dos:
  1683                                  %if _PM
  1684 000007F1 E8(0000)                	call ispm
  1685 000007F4 7507                    	jnz @F			; if 86 Mode -->
  1686 000007F6 F606[0100]40            	testopt [options2], opt2_getc_idle_dpmi
  1687 000007FB 7507                    	jnz @FF
  1688                                  @@:
  1689                                  %endif
  1690 000007FD F606[0100]20            	testopt [options2], opt2_getc_idle
  1691 00000802 7410                    	jz getc_dos_internal
  1692                                  @@:
  1693                                  .with_idle:
  1694 00000804 E88D01                  	call getc_if_any
  1695 00000807 7403E9BF00              	jnz .return
  1696 0000080C E8(0000)                	call handle_serial_flags_ctrl_c
  1697 0000080F E86502                  	call idle
  1698 00000812 EBF0                    	jmp .with_idle
  1699                                  
  1700                                  .return equ getc_dos_internal_get_extended.return
  1701                                  
  1702                                  
  1703                                  getc_dos_internal:
  1704                                  		; DOS character devices handle one-byte characters. Therefore
  1705                                  		; non-ASCII keys cannot be returned with scancode in the high
  1706                                  		; byte of the same call. A non-ASCII key will be split into
  1707                                  		; two characters by CON: one NUL byte followed by the scancode.
  1708 00000814 F606[0000]10            	testopt [internalflags3], dif3_input_terminal_override
  1709 00000819 7403E99400              	jnz .terminal
  1710                                  %if !_LOADER
  1711 0000081E F606[0300]01            	testopt [internalflags3], dif3_input_re
  1712 00000823 741B                    	jz @F
  1713 00000825 56                      	push si
  1714 00000826 8B36[0000]              	mov si, word [re_buffer.position]
  1715 0000082A 31C0                    	xor ax, ax
  1716 0000082C AC                      	lodsb
  1717 0000082D 84C0                    	test al, al
  1718 0000082F 8936[0000]              	mov word [re_buffer.position], si
  1719 00000833 5E                      	pop si
  1720 00000834 7403E99200              	jnz .return
  1721 00000839 FF0E[0000]              	dec word [re_buffer.position]
  1722 0000083D E98B00                  	jmp .return
  1723                                  %endif
  1724                                  
  1725                                  .return equ getc_dos_internal_get_extended.return
  1726                                  
  1727                                  
  1728                                  @@:
  1729                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  1730                                  %if _INPUT_FILE_BOOT
  1731 00000840 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  1732 00000845 750E                    	jnz .file
  1733                                  %endif
  1734                                  %if _INPUT_FILE_HANDLES
  1735 00000847 E8(0000)                	call InDOS_or_BIOS_IO
  1736 0000084A 7546                    	jnz .file_not
  1737 0000084C F606[0200]10            	testopt [internalflags2], dif2_input_file
  1738 00000851 7502                    	jnz .file
  1739                                  %endif
  1740 00000853 EB3D                    	jmp .file_not
  1741                                  
  1742                                  .file:
  1743 00000855 52                      	push dx
  1744 00000856 51                      	push cx
  1745 00000857 53                      	push bx
  1746 00000858 57                      	push di
  1747 00000859 31C0                    	xor ax, ax		; initialise ah to zero
  1748 0000085B 50                      	push ax
  1749 0000085C 89E2                    	mov dx, sp		; ds:dx -> al byte on stack
  1750 0000085E B90100                  	mov cx, 1
  1751                                  %if _INPUT_FILE_BOOT
  1752                                   %if _INPUT_FILE_HANDLES
  1753 00000861 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  1754 00000866 7408                    	jz @F
  1755                                   %endif
  1756 00000868 E8(0000)                	call yy_boot_remember_seek
  1757 0000086B E8(0000)                	call yy_boot_read
  1758                                   %if _INPUT_FILE_HANDLES
  1759 0000086E EB0B                    	jmp @FF
  1760                                  @@:
  1761                                   %endif
  1762                                  %endif
  1763                                  %if _INPUT_FILE_HANDLES
  1764 00000870 B43F                    	mov ah, 3Fh
  1765 00000872 E81001                  	call yy_get_handle
  1766 00000875 E86D14                  	call yy_remember_seek
  1767                                  	doscall			; (depends on ds = ss)
  1491 00000878 E8(0000)            <1>  nearcall _doscall
  1768                                  %endif
  1769                                  @@:
  1770 0000087B 7204                    	jc @F
  1771 0000087D 85C0                    	test ax, ax
  1772 0000087F 750B                    	jnz .file_got
  1773                                  
  1774                                  @@:
  1775 00000881 E85100                  	call yy_close_file
  1776 00000884 58                      	pop ax
  1777 00000885 5F                      	pop di
  1778 00000886 5B                      	pop bx
  1779 00000887 59                      	pop cx
  1780 00000888 5A                      	pop dx
  1781 00000889 E9FDFE                  	jmp getc
  1782                                  
  1783                                  
  1784                                  .file_got:
  1785 0000088C 58                      	pop ax			; ah = 0, al = character read
  1786 0000088D 5F                      	pop di
  1787 0000088E 5B                      	pop bx
  1788 0000088F 59                      	pop cx
  1789 00000890 5A                      	pop dx
  1790 00000891 C3                      	retn
  1791                                  
  1792                                  .file_not:
  1793                                  %endif
  1794 00000892 F606[0100]01            	testopt [internalflags3], dif3_input_cmdline
  1795 00000897 7419                    	jz @F
  1796 00000899 56                      	push si
  1797 0000089A 8B36[0000]              	mov si, word [cmdline_buffer.position]
  1798 0000089E 31C0                    	xor ax, ax
  1799 000008A0 AC                      	lodsb
  1800 000008A1 84C0                    	test al, al
  1801 000008A3 8936[0000]              	mov word [cmdline_buffer.position], si
  1802 000008A7 5E                      	pop si
  1803 000008A8 7521                    	jnz .return
  1804 000008AA 8026[0100]FE            	clropt [internalflags3], dif3_input_cmdline
  1805 000008AF E9D7FE                  	jmp getc
  1806                                  
  1807                                  @@:
  1808                                  .terminal:
  1809 000008B2 B408                    	mov ah, 8
  1810                                  	doscall			; wait for a key
  1491 000008B4 E8(0000)            <1>  nearcall _doscall
  1811                                  
  1812                                  getc_dos_internal_get_extended:
  1813                                  		; FreeDOS kernel 2036 returns with ax=4C00h upon Control C.
  1814                                  		; This is due to setting ax internally to terminate the
  1815                                  		;  process, paired with the termination service just
  1816                                  		;  returning for self-owned processes. This was eventually
  1817                                  		;  fixed in https://sourceforge.net/p/freedos/svn/1469/
  1818                                  		; This is a work around to restart our command line then.
  1819                                  		; Usually ah stays 08h when this call returns.
  1820                                  		;  (06h if calling from getc_if_any to here.)
  1821 000008B7 80FC4C                  	cmp ah, 4Ch
  1822 000008BA 7410                    	je .freedos_ctrlc_workaround
  1823 000008BC B400                    	mov ah, 0		; assume it is ASCII
  1824 000008BE 84C0                    	test al, al
  1825 000008C0 7509                    	jne .return		; ASCII, return with ah zero -->
  1826 000008C2 B408                    	mov ah, 8
  1827                                  	doscall			; scancode of non-ASCII key to al
  1491 000008C4 E8(0000)            <1>  nearcall _doscall
  1828 000008C7 86C4                    	xchg al, ah		; to ah
  1829 000008C9 B000                    	mov al, 0		; return zero for non-ASCII key
  1830                                  .return:
  1831 000008CB C3                      	retn
  1832                                  
  1833                                  .freedos_ctrlc_workaround:
  1834 000008CC BA[0000]                	mov dx, msg.freedos_ctrlc_workaround
  1835 000008CF E853FE                  	call putsz
  1836 000008D2 E992FA                  	jmp puts.ctrlc		; use common handler
  1837                                  
  1838                                  
  1839                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT || 1
  1840                                  		; INP:	[input_file_handles], dif2_input_file
  1841                                  		; OUT:	most recent file closed, flag cleared if no longer file
  1842                                  		; CHG:	di, bx, ax
  1843                                  yy_close_file:
  1844                                  %if !_LOADER
  1845 000008D5 F606[0300]01            	testopt [internalflags3], dif3_input_re
  1846 000008DA 740B                    	jz @F
  1847 000008DC 8026[0300]FE            	clropt [internalflags3], dif3_input_re
  1848 000008E1 800E[0300]02            	setopt [internalflags3], dif3_input_re_closed
  1849 000008E6 C3                      	retn
  1850                                  
  1851                                  @@:
  1852                                  %endif
  1853                                  %if _INPUT_FILE_BOOT
  1854 000008E7 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  1855 000008EC 7406                    	jz @F
  1856 000008EE E8(0000)                	call yy_boot_clear_remember_seek
  1857 000008F1 E9(0000)                	jmp yy_boot_close_file
  1858                                  
  1859                                  @@:
  1860                                  %endif
  1861                                  %if _INPUT_FILE_HANDLES
  1862 000008F4 F606[0200]10            	testopt [internalflags2], dif2_input_file
  1863 000008F9 7455                    	jz .notfile
  1864 000008FB 8B3E[0000]              	mov di, word [input_file_handles.active]
  1865 000008FF 57                      	push di
  1866 00000900 D1E7                    	shl di, 1
  1867 00000902 D1E7                    	shl di, 1
  1868 00000904 D1E7                    	shl di, 1
  1869                                   %if INPUTFILEHANDLE_size != 8
  1870                                    %error Unexpected structure size
  1871                                   %endif
  1872 00000906 8B9D[0000]              	mov bx, word [input_file_handles + di + ifhHandle]
  1873 0000090A E8BC13                  	call yy_clear_remember_seek
  1874                                  
  1875 0000090D F685[0300]01            	testopt [input_file_handles + di + ifhFlags], ifhfIsDup
  1876 00000912 7416                    	jz @F
  1877                                  
  1878 00000914 51                      	push cx
  1879 00000915 52                      	push dx
  1880                                  
  1881 00000916 8B9D[F8FF]              	mov bx, word [input_file_handles + di - INPUTFILEHANDLE_size + ifhHandle]
  1882 0000091A 8B95[0400]              	mov dx, word [input_file_handles + di + ifhParentSeek]
  1883 0000091E 8B8D[0600]              	mov cx, word [input_file_handles + di + ifhParentSeek + 2]
  1884 00000922 B80042                  	mov ax, 4200h		; seek from start
  1885 00000925 E82B13                  	call handle_seek_or_remember
  1886                                  
  1887 00000928 5A                      	pop dx
  1888 00000929 59                      	pop cx
  1889                                  
  1890                                  @@:
  1891                                  
  1892 0000092A E8(0000)                	call InDOS
  1893 0000092D 7406                    	jz .closefile
  1894                                  
  1895 0000092F FF06[0000]              	inc word [input_file_handles.to_close]
  1896 00000933 EB06                    	jmp @F
  1897                                  
  1898                                  .closefile:
  1899 00000935 B80100                  	mov ax, 1
  1900 00000938 E82C00                  	call yy_close_file_handles
  1901                                  
  1902                                  @@:
  1903 0000093B 5F                      	pop di
  1904 0000093C 4F                      	dec di
  1905 0000093D 790C                    	jns .next
  1906 0000093F 8026[0200]EF            	clropt [internalflags2], dif2_input_file
  1907 00000944 800E[0200]20            	setopt [internalflags2], dif2_closed_input_file
  1908 00000949 EB04                    	jmp .done
  1909                                  .next:
  1910 0000094B 893E[0000]              	mov word [input_file_handles.active], di
  1911                                  .done:
  1912 0000094F C3                      	retn
  1913                                  %endif
  1914                                  
  1915                                  .notfile:
  1916 00000950 F606[0100]01            	testopt [internalflags3], dif3_input_cmdline
  1917 00000955 740B                    	jz @F
  1918 00000957 8026[0100]FE            	clropt [internalflags3], dif3_input_cmdline
  1919 0000095C 800E[0100]02            	setopt [internalflags3], dif3_input_cmdline_closed
  1920 00000961 C3                      	retn
  1921                                  
  1922                                  @@:
  1923 00000962 31F6                    	xor si, si
  1924 00000964 E9(0000)                	jmp error
  1925                                  
  1926                                  
  1927                                  %if _INPUT_FILE_HANDLES
  1928                                  		; INP:	word [input_file_handles.to_close] = how many
  1929                                  		;	ax = additionally how many (0 or 1)
  1930                                  		;	input_file_handles + di -> first to close
  1931                                  		; OUT:	word [input_file_handles.to_close] = 0
  1932                                  		;	closed handle fields = -1
  1933                                  		; CHG:	ax, bx, di
  1934                                  		; STT:	DOS must be accessible
  1935                                  yy_close_file_handles:
  1936 00000967 51                      	push cx
  1937 00000968 31C9                    	xor cx, cx
  1938 0000096A 870E[0000]              	xchg cx, word [input_file_handles.to_close]
  1939 0000096E 01C1                    	add cx, ax
  1940 00000970 7411                    	jz @FF
  1941                                  @@:
  1942 00000972 BBFFFF                  	mov bx, -1
  1943 00000975 879D[0000]              	xchg bx, word [input_file_handles + di + ifhHandle]
  1944 00000979 B43E                    	mov ah, 3Eh
  1945                                  	doscall
  1491 0000097B E8(0000)            <1>  nearcall _doscall
  1946 0000097E 83C708                  	add di, INPUTFILEHANDLE_size
  1947 00000981 E2EF                    	loop @B
  1948                                  @@:
  1949 00000983 59                      	pop cx
  1950 00000984 C3                      	retn
  1951                                  
  1952                                  
  1953                                  		; INP:	-
  1954                                  		; OUT:	di = active handle offset
  1955                                  		;	bx = active handle
  1956                                  		; CHG:	-
  1957                                  yy_get_handle:
  1958 00000985 8B3E[0000]              	mov di, word [input_file_handles.active]
  1959 00000989 D1E7                    	shl di, 1
  1960 0000098B D1E7                    	shl di, 1
  1961 0000098D D1E7                    	shl di, 1
  1962                                   %if INPUTFILEHANDLE_size != 8
  1963                                    %error Unexpected structure size
  1964                                   %endif
  1965 0000098F 8B9D[0000]              	mov bx, word [input_file_handles + di + ifhHandle]
  1966                                  %endif
  1967 00000993 C3                      	retn
  1968                                  %endif
  1969                                  
  1970                                  
  1971                                  		; INP:	-
  1972                                  		; OUT:	NZ if received any,
  1973                                  		;	 al = character
  1974                                  		;	 ah = scan code or zero
  1975                                  		;	ZR if none received
  1976                                  		; CHG:	ax
  1977                                  		; STT:	ds = ss = debugger segment/selector
  1978                                  getc_if_any:
  1979 00000994 F606[0000]20            	testopt [internalflags3], dif3_input_serial_override
  1980 00000999 755B                    	jnz .serial
  1981 0000099B F606[0000]10            	testopt [internalflags3], dif3_input_terminal_override
  1982 000009A0 754D                    	jnz .terminal
  1983                                  
  1984                                  %if !_LOADER
  1985 000009A2 F606[0300]01            	testopt [internalflags3], dif3_input_re
  1986 000009A7 741D                    	jz @F
  1987 000009A9 56                      	push si
  1988 000009AA 8B36[0000]              	mov si, word [re_buffer.position]
  1989 000009AE 31C0                    	xor ax, ax
  1990 000009B0 AC                      	lodsb
  1991 000009B1 84C0                    	test al, al
  1992 000009B3 8936[0000]              	mov word [re_buffer.position], si
  1993 000009B7 5E                      	pop si
  1994 000009B8 7403E9B900              	jnz .return
  1995 000009BD FF0E[0000]              	dec word [re_buffer.position]
  1996 000009C1 38C0                    	cmp al, al			; ZR
  1997 000009C3 E9B000                  	jmp .return
  1998                                  %endif
  1999                                  
  2000                                  @@:
  2001                                  %if _INPUT_FILE_BOOT
  2002 000009C6 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  2003 000009CB 755B                    	jnz .file
  2004                                  %endif
  2005                                  
  2006 000009CD F606[0100]01            	testopt [internalflags3], dif3_input_cmdline
  2007 000009D2 741B                    	jz @F
  2008 000009D4 56                      	push si
  2009 000009D5 8B36[0000]              	mov si, word [cmdline_buffer.position]
  2010 000009D9 31C0                    	xor ax, ax
  2011 000009DB AC                      	lodsb
  2012 000009DC 84C0                    	test al, al
  2013 000009DE 8936[0000]              	mov word [cmdline_buffer.position], si
  2014 000009E2 5E                      	pop si
  2015 000009E3 7403E98E00              	jnz .return
  2016 000009E8 8026[0100]FE            	clropt [internalflags3], dif3_input_cmdline
  2017 000009ED EBA5                    	jmp getc_if_any
  2018                                  
  2019                                  @@:
  2020                                  .terminal:
  2021 000009EF F606[0000]10            	testopt [serial_flags], sf_use_serial
  2022 000009F4 7411                    	jz @F			; do BIOS keyboard or DOS getc -->
  2023                                  
  2024                                  .serial:
  2025 000009F6 E8(0000)                	call serial_receive_char ; do serial getc (check rx buffer)
  2026 000009F9 747B                    	jz .return		; no data, go and idle -->
  2027 000009FB B400                    	mov ah, 0
  2028 000009FD C3                      	retn
  2029                                  
  2030                                  .raw:
  2031 000009FE F606[0000]10            	testopt [serial_flags], sf_use_serial
  2032 00000A03 75F1                    	jnz .serial
  2033 00000A05 EB61                    	jmp .bios
  2034                                  
  2035                                  @@:
  2036 00000A07 E8(0000)                	call InDOS_or_BIOS_IO
  2037 00000A0A 755C                    	jnz .bios
  2038                                  
  2039 00000A0C F606[0000]10            	testopt [internalflags3], dif3_input_terminal_override
  2040 00000A11 7547                    	jnz .dos_terminal
  2041                                  
  2042                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  2043                                  %if _INPUT_FILE_BOOT
  2044 00000A13 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  2045 00000A18 750E                    	jnz .file
  2046                                  %endif
  2047                                  %if _INPUT_FILE_HANDLES
  2048 00000A1A E8(0000)                	call InDOS_or_BIOS_IO
  2049 00000A1D 753B                    	jnz .file_not
  2050 00000A1F F606[0200]10            	testopt [internalflags2], dif2_input_file
  2051 00000A24 7502                    	jnz .file
  2052                                  %endif
  2053 00000A26 EB32                    	jmp .file_not
  2054                                  
  2055                                  .file:
  2056 00000A28 57                      	push di
  2057 00000A29 53                      	push bx
  2058 00000A2A 51                      	push cx
  2059 00000A2B 52                      	push dx
  2060 00000A2C 31C0                    	xor ax, ax
  2061 00000A2E 50                      	push ax
  2062                                  
  2063 00000A2F 89E2                    	mov dx, sp		; ds:dx -> al byte on stack
  2064 00000A31 B90100                  	mov cx, 1		; buffer length = 1
  2065                                  %if _INPUT_FILE_BOOT
  2066                                   %if _INPUT_FILE_HANDLES
  2067 00000A34 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  2068 00000A39 7408                    	jz @F
  2069                                   %endif
  2070 00000A3B E8(0000)                	call yy_boot_remember_seek
  2071 00000A3E E8(0000)                	call yy_boot_read
  2072 00000A41 EB0B                    	jmp @FF
  2073                                  @@:
  2074                                  %endif
  2075                                  %if _INPUT_FILE_HANDLES
  2076 00000A43 B43F                    	mov ah, 3Fh
  2077 00000A45 E83DFF                  	call yy_get_handle
  2078 00000A48 E89A12                  	call yy_remember_seek
  2079                                  	doscall			; DOS read file (depends on ds = ss)
  1491 00000A4B E8(0000)            <1>  nearcall _doscall
  2080                                  %endif
  2081                                  @@:
  2082 00000A4E 7302                    	jnc @F
  2083 00000A50 31C0                    	xor ax, ax
  2084                                  @@:
  2085 00000A52 85C0                    	test ax, ax
  2086 00000A54 58                      	pop ax
  2087 00000A55 5A                      	pop dx
  2088 00000A56 59                      	pop cx
  2089 00000A57 5B                      	pop bx
  2090 00000A58 5F                      	pop di
  2091 00000A59 C3                      	retn			; ZR if no character read
  2092                                  
  2093                                  .file_not:
  2094                                  %endif
  2095                                  .dos_terminal:
  2096                                  %if 0
  2097                                  	push dx
  2098                                  	mov ah, 06h
  2099                                  	mov dl, -1
  2100                                  	doscall
  2101                                  	jz .return_dx		; none available
  2102                                  		; bugfix: the 06h call is a *destructive* read.
  2103                                  		;  so do not call getc again, just handle the
  2104                                  		;  possible second byte returned.
  2105                                  	call getc_dos_internal_get_extended
  2106                                  	pop dx
  2107                                  	jmp .return_NZ
  2108                                  .return_dx:
  2109                                  	pop dx
  2110                                  	retn
  2111                                  %else
  2112 00000A5A B40B                    	mov ah, 0Bh
  2113                                  	doscall
  1491 00000A5C E8(0000)            <1>  nearcall _doscall
  2114 00000A5F 84C0                    	test al, al
  2115 00000A61 7413                    	jz .return
  2116 00000A63 E8AEFD                  	call getc_dos_internal
  2117 00000A66 EB0A                    	jmp .return_NZ
  2118                                  %endif
  2119                                  
  2120                                  .bios:
  2121 00000A68 B401                    	mov ah, 01h
  2122 00000A6A CD16                    	int 16h			; key available ?
  2123 00000A6C 7408                    	jz .return
  2124 00000A6E 31C0                    	xor ax, ax
  2125 00000A70 CD16                    	int 16h
  2126                                  .return_NZ:
  2127 00000A72 50                      	push ax
  2128 00000A73 0C01                    	or al, 1		; (NZ)
  2129 00000A75 58                      	pop ax
  2130                                  .return:
  2131 00000A76 C3                      	retn
  2132                                  
  2133                                  
  2134                                  		; INP:	-
  2135                                  		; OUT:	-
  2136                                  		; CHG:	ax
  2137                                  		; STT:	ds = ss = debugger segment/selector
  2138                                  		;
  2139                                  		; Idle system, using 2F.1680 (in given mode), or 2F.1680
  2140                                  		; (calling down to 86 Mode), or sti \ hlt.
  2141                                  idle:
  2142 00000A77 FB                      	sti
  2143                                  		; Might be required for dosemu2 in loops. Refer to
  2144                                  		;  https://hg.pushbx.org/ecm/insight/rev/7973d5dd16f7
  2145 00000A78 90                      	nop			; help debugging
  2146                                  
  2147                                  %if _APPLICATION || _DEVICE
  2148                                  %if _BOOTLDR
  2149 00000A79 F606[0100]40            	testopt [internalflags], nodosloaded
  2150 00000A7E 7568                    	jnz .hlt		; can't call 2F -->
  2151                                  %endif
  2152                                  
  2153 00000A80 F606[0300]02            	testopt [options3], opt3_no_idle_2F
  2154 00000A85 7561                    	jnz .hlt
  2155                                   %if _GUARD_86M_INT2F
  2156                                  %if _PM
  2157 00000A87 E8(0000)                	call ispm
  2158 00000A8A 7416                    	jz @FF			; --> (NZ)
  2159                                  %endif
  2160 00000A8C 06                      	push es
  2161 00000A8D 31C0                    	xor ax, ax
  2162 00000A8F 8EC0                    	mov es, ax		; (only used in 86 Mode)
  2163 00000A91 26A1BC00                	mov ax, [es:2Fh * 4]
  2164 00000A95 83F8FF                  	cmp ax, -1
  2165 00000A98 7405                    	je @F			; --> (ZR)
  2166 00000A9A 260B06BE00              	or ax, [es:2Fh * 4 + 2]
  2167                                  @@:
  2168 00000A9F 07                      	pop es
  2169 00000AA0 7409                    	jz @FF
  2170                                  @@:
  2171                                   %endif
  2172 00000AA2 B88016                  	mov ax, 1680h
  2173 00000AA5 CD2F                    	int 2Fh			; release timeslice in multitasker
  2174 00000AA7 84C0                    	test al, al
  2175 00000AA9 7453                    	jz .return		; done idling -->
  2176                                  @@:
  2177                                  %if _PM
  2178 00000AAB E8(0000)                	call ispm
  2179 00000AAE 7538                    	jnz .hlt
  2180                                  
  2181 00000AB0 53                      	push bx
  2182 00000AB1 51                      	push cx
  2183 00000AB2 06                      	push es
  2184 00000AB3 66                      	_386_PM_o32	; push edi
  2185 00000AB4 57                      	push di
  2186 00000AB5 6631FF                  _386	xor edi, edi		; clear EDIH
  2187 00000AB8 31C9                    	xor cx, cx		; (copy no words from stack)
  2188                                  
  2189                                  [cpu 286]
  2190 00000ABA 51                      	push cx			; ss
  2191 00000ABB 51                      	push cx			; sp (0:0 = host should allocate a stack)
  2192 00000ABC 83EC0C                  	sub sp, byte 12		; cs:ip (ignored), segments (uninitialized)
  2193 00000ABF 9C                      	pushf
  2194 00000AC0 51                      	push cx			; EAXH (uninitialized)
  2195 00000AC1 688016                  	push 1680h		; AX
  2196 00000AC4 83EC0C                  	sub sp, byte 12		; ecx, edx, ebx (uninitialized)
  2197 00000AC7 51                      	push cx
  2198 00000AC8 51                      	push cx			; reserved (zero)
  2199 00000AC9 83EC0C                  	sub sp, byte 12		; ebp, esi, edi (uninitialized)
  2200 00000ACC 16                      	push ss
  2201 00000ACD 07                      	pop es
  2202 00000ACE 89E7                    	mov di, sp		; es:(e)di -> 86 Mode call structure
  2203 00000AD0 B80003                  	mov ax, 0300h
  2204 00000AD3 BB2F00                  	mov bx, 2Fh		; bl = interrupt, bh = reserved (zero)
  2205 00000AD6 CD31                    	int 31h			; call real mode 2F.1680
  2206                                  __CPU__
  2207                                  
  2208 00000AD8 83C41C                  	add sp, byte 28		; discard RM call structure
  2209 00000ADB 58                      	pop ax			; get AX
  2210 00000ADC 83C414                  	add sp, byte 20		; discard RM call structure
  2211                                  
  2212 00000ADF 66                      	_386_PM_o32	; pop edi
  2213 00000AE0 5F                      	pop di
  2214 00000AE1 07                      	pop es
  2215 00000AE2 59                      	pop cx
  2216 00000AE3 5B                      	pop bx
  2217                                  
  2218 00000AE4 84C0                    	test al, al
  2219 00000AE6 7416                    	jz .return		; done idling -->
  2220                                  %endif
  2221                                  %endif
  2222                                  .hlt:
  2223                                  %if _PM
  2224 00000AE8 E8(0000)                	call ispm
  2225 00000AEB 7507                    	jnz .hlt_86m
  2226                                  .hlt_pm:
  2227 00000AED F606[0300]80            	testopt [options2], opt2_dpminohlt
  2228 00000AF2 EB05                    	jmp @F			; NZ = DPMI host throws GPF when we execute hlt -->
  2229                                  %endif
  2230                                  .hlt_86m:
  2231 00000AF4 F606[0100]02            	testopt [options], opt1_86mnohlt
  2232                                  @@:
  2233 00000AF9 7503                    	jnz .return
  2234 00000AFB FB                      	sti
  2235 00000AFC F4                      	hlt			; else idle by hlt
  2236 00000AFD 90                      	nop
  2237                                  .return:
  2238 00000AFE C3                      	retn
  2239                                  
  2240                                  
  2241                                  %if _MS_PROMPT_COMPAT
  2242                                  	usesection lDEBUG_DATA_ENTRY
  2242          ------------------       note: usesection lDEBUG_DATA_ENTRY
  2243 00000001 00                      	align 2, db 0
  2244                                  		; REM:	Dispatch table in section lDEBUG_CODE
  2245                                  table_getline_prepare_ldebug:
  2246 00000002 [070B]                  	dw getline_prepare_blank_blank_colon
  2247 00000004 [070B]                  	dw getline_prepare_blank_blank_colon
  2248 00000006 [070B]                  	dw getline_prepare_blank_blank_colon
  2249                                  
  2250                                  		; word +0: other
  2251                                  		; word +2: variable (register)
  2252                                  		; word +4: symbolic F (flag states)
  2253                                  		; REM:	Dispatch table in section lDEBUG_CODE
  2254                                  table_getline_prepare_ms_debug:
  2255 00000008 [070B]                  	dw getline_prepare_blank_blank_colon
  2256 0000000A [FF0A]                  	dw getline_prepare_crlf_colon
  2257 0000000C [0F0B]                  	dw getline_prepare_blank_dash
  2258                                  
  2259                                  
  2260                                  	usesection lDEBUG_CODE
  2260          ------------------       note: usesection lDEBUG_CODE
  2261                                  
  2262                                  getline_prepare_crlf_colon:
  2263 00000AFF E8A2F6                  	call putsline_crlf
  2264 00000B02 BF[0000]                	mov di, line_out
  2265 00000B05 EB04                    	jmp @F
  2266                                  
  2267                                  getline_prepare_blank_blank_colon:
  2268 00000B07 B82020                  	mov ax, 32<<8|32	; add two spaces and a colon
  2269 00000B0A AB                      	stosw
  2270                                  @@:
  2271 00000B0B B03A                    	mov al, ':'
  2272 00000B0D AA                      	stosb
  2273 00000B0E C3                      	retn
  2274                                  
  2275                                  getline_prepare_blank_dash:
  2276 00000B0F B8202D                  	mov ax, '-' << 8 | 32
  2277 00000B12 AB                      	stosw
  2278 00000B13 C3                      	retn
  2279                                  %endif
  2280                                  
  2281                                  
  2282                                  ;	GETLINE - Print a prompt (address in DX, length in CX) and read a line
  2283                                  ;	of input.
  2284                                  ;	GETLINE0 - Same as above, but use the output line (so far), plus two
  2285                                  ;	spaces and a colon, as a prompt.
  2286                                  ;	GETLINE00 - Same as above, but use the output line (so far) as a prompt.
  2287                                  ;	Entry	CX	Length of prompt (getline only)
  2288                                  ;		DX	Address of prompt string (getline only)
  2289                                  ;
  2290                                  ;		DI	Address + 1 of last character in prompt (getline0 and
  2291                                  ;			getline00 only)
  2292                                  ;
  2293                                  ;	Exit	AL	First nonwhite character in input line
  2294                                  ;		SI	Address of the next character after that
  2295                                  ;	Uses	AH,BX,CX,DX,DI
  2296                                  
  2297                                  %ifn _MS_PROMPT_COMPAT
  2298                                  getline0:
  2299                                  	mov ax, 32<<8|32	; add two spaces and a colon
  2300                                  	stosw
  2301                                  	mov al, ':'
  2302                                  	stosb
  2303                                  %endif
  2304                                  getline00:
  2305 00000B14 BA[0000]                	mov dx, line_out
  2306 00000B17 89F9                    	mov cx, di
  2307 00000B19 29D1                    	sub cx, dx
  2308                                  
  2309                                  getline:	; note: this entry is no longer used
  2310 00000B1B 8026[0100]77            	clropt [internalflags3], dif3_quiet_input_single | dif3_return_eof
  2311                                  .use_dif3_flags:
  2312                                  %if _DEBUG && ! _DEBUG_COND
  2313                                  	d0bp
  2314                                  %endif
  2315 00000B20 890E[0000]              	mov word [promptlen], cx	; save length of prompt
  2316 00000B24 8326[0000]00            	and word [terminator_in_line_in.offset], 0
  2317                                  					; reset this when reading new line
  2318                                  
  2319 00000B29 E89F02                  	call getline_is_input_file?
  2320 00000B2C 7303E90801              	jc getline_nofile
  2321                                  
  2322                                  getline_file:
  2323 00000B31 F606[0300]01            	testopt [internalflags3], dif3_input_re
  2324 00000B36 7549                    	jnz .notquiet
  2325                                  
  2326                                  %if _INPUT_FILE_BOOT
  2327 00000B38 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  2328 00000B3D 7412                    	jz @F
  2329 00000B3F B8A000                  	mov ax, LOAD_INPUT_FILE_SIZE
  2330 00000B42 52                      	push dx
  2331 00000B43 F726[0000]              	mul word [load_input_file.active]
  2332 00000B47 5A                      	pop dx
  2333 00000B48 89C7                    	mov di, ax
  2334 00000B4A F685[2700]40            	testopt [load_input_file + di - LOADDATA3 + ldFATType], ifhfQuietInput
  2335 00000B4F EB29                    	jmp .quiet_if_nz
  2336                                  
  2337                                  @@:
  2338                                  %endif
  2339                                  %if _INPUT_FILE_HANDLES
  2340 00000B51 E8(0000)                	call InDOS_or_BIOS_IO
  2341 00000B54 7518                    	jnz @F
  2342 00000B56 F606[0200]10            	testopt [internalflags2], dif2_input_file
  2343 00000B5B 7411                    	jz @F
  2344 00000B5D 8B3E[0000]              	mov di, word [input_file_handles.active]
  2345 00000B61 D1E7                    	shl di, 1
  2346 00000B63 D1E7                    	shl di, 1
  2347 00000B65 D1E7                    	shl di, 1		; to qword array index
  2348                                   %if INPUTFILEHANDLE_size != 8
  2349                                    %error Unexpected structure size
  2350                                   %endif
  2351 00000B67 F685[0300]40            	testopt [input_file_handles + di + ifhFlags], ifhfQuietInput
  2352 00000B6C EB0C                    	jmp .quiet_if_nz
  2353                                  
  2354                                  @@:
  2355                                  %endif
  2356 00000B6E F606[0100]01            	testopt [internalflags3], dif3_input_cmdline
  2357 00000B73 740C                    	jz @F
  2358 00000B75 F606[0300]40            	testopt [options], opt_cmdline_quiet_input
  2359                                  	; jmp .quiet_if_nz
  2360                                  
  2361                                  .quiet_if_nz:
  2362 00000B7A 7405                    	jz @F
  2363                                  .quiet:
  2364 00000B7C 800E[0100]08            	setopt [internalflags3], dif3_quiet_input_single
  2365                                  .notquiet:
  2366                                  @@:
  2367                                  
  2368 00000B81 800E[0200]40            	setopt [internalflags2], dif2_did_getline_file
  2369                                  
  2370                                  
  2371                                  		; This part reads the input line from a file (in the case of
  2372                                  		; `debug < file').  It is necessary to do this by hand because DOS
  2373                                  		; function 0Ah does not handle EOF correctly otherwise.  This is
  2374                                  		; especially important for DEBUG because it traps Control-C.
  2375 00000B86 C706[0000][0000]        	mov word [lastcmd], dmycmd	; disable auto-repeat while reading from a file
  2376                                  
  2377                                  %if _NEWFULLHANDLING
  2378 00000B8C BF[0300]                	mov di, line_in+3	; read max
  2379                                  %else
  2380                                  	mov di, line_in+2
  2381                                  %endif
  2382 00000B8F 8B36[0000]              	mov si, word [bufnext]
  2383 00000B93 3B36[0000]              	cmp si, word [bufend]
  2384 00000B97 7216                    	jb .char_buffered	; if there's a character already
  2385 00000B99 E82908                  	call fillbuf
  2386 00000B9C 7311                    	jnc .fillbuf_had_data
  2387 00000B9E F606[0100]80            	testopt [internalflags3], dif3_return_eof
  2388 00000BA3 7402                    	jz @F
  2389 00000BA5 F9                      	stc
  2390 00000BA6 C3                      	retn
  2391                                  @@:
  2392 00000BA7 E85A02                  	call getline_close_file
  2393 00000BAA 7403E96CFF              	jnz getline
  2394                                  
  2395                                  .fillbuf_had_data:
  2396                                  .char_buffered:
  2397                                  %if _NEWFULLHANDLING
  2398 00000BAF 4F                      	dec di
  2399                                  %endif
  2400                                  
  2401                                  		; Discard an LF if the last character read was CR.
  2402 00000BB0 803E[0000]0D            	cmp byte [notatty], 13	; last parsed character was CR ?
  2403 00000BB5 750A                    	jne .no_lf_skip		; no, nothing more to do -->
  2404 00000BB7 803C0A                  	cmp byte [si], 10	; first read character is LF ?
  2405 00000BBA 7505                    	jne .no_lf_skip		; no -->
  2406 00000BBC 46                      	inc si			; skip the LF
  2407 00000BBD FE06[0000]              	inc byte [notatty]	; avoid repeating this
  2408                                  .no_lf_skip:
  2409                                  
  2410 00000BC1 3B36[0000]              	cmp si, word [bufend]
  2411 00000BC5 740B                    	je @F
  2412 00000BC7 803C40                  	cmp byte [si], '@'	; no display ?
  2413 00000BCA 7506                    	jne @F
  2414                                  
  2415 00000BCC 46                      	inc si			; increment past @
  2416 00000BCD 800E[0100]08            	setopt [internalflags3], dif3_quiet_input_single
  2417                                  @@:
  2418 00000BD2 F606[0100]08            	testopt [internalflags3], dif3_quiet_input_single
  2419 00000BD7 7503                    	jnz gl1
  2420                                  
  2421 00000BD9 E8D3F5                  	call puts		; display prompt (having checked it wasn't EOF)
  2422                                  
  2423                                  		; si-> next character in buffer
  2424                                  		; w[bufend]-> behind last valid character of buffer
  2425                                  gl1:
  2426 00000BDC 8B0E[0000]              	mov cx, word [bufend]
  2427 00000BE0 29F1                    	sub cx, si		; cx = number of valid characters in buffer
  2428 00000BE2 740C                    	jz gl3			; if none -->
  2429                                  gl2:
  2430 00000BE4 AC                      	lodsb
  2431 00000BE5 3C0D                    	cmp al, 13		; (exact match for CR)
  2432 00000BE7 7410                    	je gl4
  2433 00000BE9 3C0A                    	cmp al, 10
  2434 00000BEB 740C                    	je gl4			; if EOL -->
  2435 00000BED AA                      	stosb
  2436 00000BEE E2F4                    	loop gl2		; if more valid characters -->
  2437                                  
  2438                                  		; The buffer is empty. Fill it again.
  2439                                  gl3:
  2440                                  %if _NEWFULLHANDLING
  2441 00000BF0 47                      	inc di
  2442                                  %endif
  2443 00000BF1 E8D107                  	call fillbuf
  2444                                  %if _NEWFULLHANDLING
  2445 00000BF4 4F                      	dec di
  2446                                  %endif
  2447 00000BF5 73E5                    	jnc gl1			; if we have more characters -->
  2448 00000BF7 B00A                    	mov al, 10		; make jump after gl4 always branch
  2449                                  %ifn _NEWFULLHANDLING	; should now always have at least one byte free
  2450                                  	cmp di, line_in+LINE_IN_LEN
  2451                                  	jb @F
  2452                                  	dec si
  2453                                  	dec di
  2454                                  @@:
  2455                                  %endif
  2456                                  
  2457                                  gl4:
  2458 00000BF9 3C0D                    	cmp al, 13		; terminator was CR ?
  2459 00000BFB 7508                    	jne @F			; no -->
  2460 00000BFD E306                    	jcxz @F			; if no other byte buffered -->
  2461 00000BFF 803C0A                  	cmp byte [si], 10	; next byte is an LF ?
  2462 00000C02 7501                    	jne @F			; no -->
  2463 00000C04 AC                      	lodsb			; increment si past the LF and set al = 10
  2464                                  	; dec cx		; (not used in subsequent code)
  2465                                  @@:
  2466 00000C05 8936[0000]              	mov word [bufnext], si
  2467 00000C09 A2[0000]                	mov byte [notatty], al	; store 10 or 13 (depending on the kind of EOL)
  2468                                  
  2469 00000C0C 800E[0100]04            	setopt [internalflags3], dif3_at_line_end
  2470 00000C11 E83507                  	call getline_reset_notatty
  2471                                  
  2472 00000C14 89F9                    	mov cx, di		; (counter is for input without CR)
  2473 00000C16 B00D                    	mov al, 13
  2474 00000C18 AA                      	stosb			; terminate line for our usage
  2475 00000C19 BA[0200]                	mov dx, line_in + 2
  2476 00000C1C 29D1                    	sub cx, dx		; = length of input (no CR)
  2477 00000C1E 880E[0100]              	mov byte [line_in+1], cl
  2478 00000C22 F606[0100]08            	testopt [internalflags3], dif3_quiet_input_single
  2479 00000C27 750D                    	jnz @F
  2480 00000C29 800E[0200]01            	setopt [internalflags], usecharcounter
  2481 00000C2E E87EF5                  	call puts		; print out the received line
  2482 00000C31 8026[0200]FE            	clropt [internalflags], usecharcounter
  2483                                  @@:
  2484 00000C36 E92B01                  	jmp getline_eol		; done
  2485                                  
  2486                                  getline_nofile:
  2487 00000C39 E8910F                  	call yy_reset_buf
  2488 00000C3C C606[0000]00            	mov byte [linecounter], 0	; reset counter
  2489 00000C41 8026[0200]EF            	clropt [internalflags], promptwaiting
  2490 00000C46 51                      	push cx
  2491 00000C47 52                      	push dx
  2492 00000C48 E864F5                  	call puts		; display prompt
  2493 00000C4B 5A                      	pop dx
  2494 00000C4C 59                      	pop cx
  2495 00000C4D F606[0000]10            	testopt [serial_flags], sf_use_serial
  2496 00000C52 7516                    	jnz .getinput_NZ
  2497 00000C54 E8(0000)                	call InDOS_or_BIOS_output
  2498                                  		; Special case: If output is to ROM-BI0S we must use
  2499                                  		;  getinput so as to use putc and friends, not the
  2500                                  		;  DOS interrupt 21h service 0Ah.
  2501 00000C57 7511                    	jnz .getinput_NZ
  2502                                  %if _PM
  2503 00000C59 E8(0000)                	call ispm
  2504 00000C5C 7507                    	jnz @F			; if 86 Mode -->
  2505 00000C5E F606[0100]08            	testopt [options2], opt2_getinput_dpmi
  2506 00000C63 7505                    	jnz .getinput_NZ
  2507                                  @@:
  2508                                  %endif
  2509 00000C65 F606[0100]08            	testopt [options], opt_usegetinput
  2510                                  .getinput_NZ:
  2511 00000C6A 7403E93802              	jnz getinput
  2512                                  
  2513                                  %if _PM
  2514 00000C6F E8(0000)                	call ispm
  2515 00000C72 7537                    	jnz @F			; if 86 Mode -->
  2516 00000C74 F606[0200]04            	testopt [internalflags], canswitchmode
  2517 00000C79 7430                    	jz @F			; can't switch to 86M -->
  2518 00000C7B 800E[0200]08            	setopt [internalflags], modeswitched
  2519                                  				; set flag for resetmode
  2520 00000C80 B000                    	mov al, 0
  2521 00000C82 E8(0000)                	call sr_state		; save state
  2522 00000C85 E8(0000)                	call switchmode 	; switch to 86M
  2523 00000C88 E8(0000)                	call handle_mode_changed	; ! called with flag set
  2524                                  
  2525 00000C8B BE[1000]                	mov si, getline_extra_int23
  2526 00000C8E B023                    	mov al, 23h
  2527 00000C90 E8(0000)                	call install_86m_interrupt_handler
  2528                                  				; override DPMI host's int 23h vector
  2529 00000C93 BA[2400]                	mov dx, getline_extra_int22
  2530 00000C96 B82225                  	mov ax, 2522h
  2531 00000C99 CD21                    	int 21h
  2532 00000C9B 89160A00                	mov word [TPIV], dx	; override our PRI
  2533                                  
  2534 00000C9F BA[0000]                	mov dx, line_in
  2535 00000CA2 B40A                    	mov ah, 0Ah
  2536 00000CA4 CD21                    	int 21h			; call DOS
  2537                                  
  2538 00000CA6 E8ED00                  	call getline_extra_uninstall
  2539                                  				; undo patches
  2540 00000CA9 EB08                    	jmp @FF
  2541                                  				; go to common trail
  2542                                  
  2543                                  @@:
  2544                                  %endif
  2545 00000CAB BA[0000]                	mov dx, line_in
  2546 00000CAE B40A                    	mov ah, 0Ah		; buffered keyboard input
  2547                                  	doscall
  1491 00000CB0 E8(0000)            <1>  nearcall _doscall
  2548                                  
  2549                                  @@:
  2550                                  %if _EXTENSIONS && _EXT_PUTS_GETLINE
  2551 00000CB3 B300                    	mov bl, 0
  2552                                  %endif
  2553                                  
  2554                                  getline_eol_enter_history_and_ext:
  2555                                  %if _EXTENSIONS && _EXT_PUTS_GETLINE
  2556                                  		; byte [line_in + 1] = length
  2557                                  		; line_in + 2 -> text
  2558                                  		; bl = 0 means text is from int 21h service 0Ah
  2559                                  		; bl = 1 means text is from getinput
  2560 00000CB5 E8D100                  	call transfer_to_ext_puts_getline
  2561                                  %endif
  2562                                  
  2563                                  %if _HISTORY
  2564                                   %if 0
  2565                                  
  2566                                  The history buffer is implemented as two arrays that grow towards
  2567                                  the middle from either end of the buffer. The first is a byte array
  2568                                  storing text data that starts at the low end (start) of the buffer.
  2569                                  (This is offset 0 in the separate history segment, if used.) The
  2570                                  text is stored back to back, only the content of the lines, no
  2571                                  separators or terminators.
  2572                                  
  2573                                  The second array gives the *end* of each history entry's text.
  2574                                  There are N + 1 array entries, each a 16-bit offset word, where
  2575                                  N is the amount of history entries in use. The words are used as
  2576                                  displacement from a base that's the start of the history buffer.
  2577                                  (Again, the start base is at offset 0 for the separate history
  2578                                  segment. However, for simplicity of the code we always do store
  2579                                  the actual base start offset into a register and displace from
  2580                                  that, even when the actual value of that register will be zero.)
  2581                                  The very first entry of the high array is special. It always
  2582                                  holds the displacement value zero. When used as a displacement
  2583                                  added to the base this points at the very beginning of the
  2584                                  entire history buffer (and thus the start of the low array).
  2585                                  
  2586                                  The size of a history entry in the low array is obtained by
  2587                                  reading both the entry's end displacement from the high array,
  2588                                  and the prior entry (at the next higher address) also from the
  2589                                  high array to receive the end displacement of the prior history
  2590                                  entry. The end displacement of the prior entry is also the
  2591                                  start displacement of the current entry. The delta of the two
  2592                                  end displacements is the size of this history entry. This also
  2593                                  explains why the very first entry of the high array is needed,
  2594                                  and why it contains a zero displacement. It is needed in order
  2595                                  to determine the start displacement and size of the very first
  2596                                  actual history entry. (We could special case the first entry a
  2597                                  different way but using the special first entry of the high
  2598                                  array that holds a constant zero simplifies the code.)
  2599                                  
  2600                                  The history pointers in the word [history.first] as well as
  2601                                  word [history.last] point at the very first (special) entry
  2602                                  of the high array as well as the very last entry of the high
  2603                                  array. (Because the high array grows from the top down, the
  2604                                  first entry is at the highest address and the last entry is
  2605                                  at the lowest address.) Although the word [history.first] is
  2606                                  currently a constant, we use a variable to enable changing
  2607                                  the history allocation dynamically if desired later. If the
  2608                                  two pointers are one and the same then there is no actual
  2609                                  history entry stored in the history. Otherwise, if the
  2610                                  distance between the last high array entry and the last
  2611                                  low array entry is lower than X + 2 bytes then the history is
  2612                                  too full to insert a new entry, where X is the length of the
  2613                                  new history entry's text data and the additional 2 bytes are
  2614                                  for the high array entry to store the end displacement.
  2615                                  
  2616                                  The special first entry of the high array *must* be
  2617                                  initialised to hold the displacement value zero. This happens
  2618                                  in init.asm for the separate history buffer segment (when
  2619                                  initialising the entire segment with zeroes) or in the
  2620                                  zeroing of most of the DATASTACK section (when initialising
  2621                                  the variables from ..@init_first up to ..@init_behind).
  2622                                  
  2623                                  Insertion is simple, if enough space is left in the history
  2624                                  buffer: Copy the text to behind the last entry of the low
  2625                                  array (this is pointed to by the end displacement in the last
  2626                                  high array entry), then create a new last entry of the high
  2627                                  array which points behind the text's destination.
  2628                                  
  2629                                  Deletion is more difficult. (Generally we will delete the
  2630                                  oldest entry, that is the first history entry.) The second
  2631                                  entry of the high array needs to be deleted. All subsequent
  2632                                  entries of the high array need to move "forward" (towards
  2633                                  the higher address), and also must have the length of the
  2634                                  text of the entry to delete subtracted. In the low array the
  2635                                  text data of the first history entry needs to be overwritten
  2636                                  with any subsequent text data; the entire subsequent text data
  2637                                  must be moved "forward" (towards the lower address) by the
  2638                                  distance that equals the length of the entry's text to delete.
  2639                                  
  2640                                   %endif
  2641                                  
  2642                                  .loop:
  2643 00000CB8 BE[0200]                	mov si, line_in + 2
  2644 00000CBB 31C9                    	xor cx, cx
  2645 00000CBD 0A4CFF                  	or cl, byte [si - 1]
  2646 00000CC0 7503E99D00              	jz .dontenter
  2647                                  	gethistorysegment es
   480 00000CC5 368E06[0000]        <1>  mov %1, word [ss:history.segorsel]
  2648                                  	gethistoryoffset bx
   483 00000CCA BB0000              <1>  mov %1, 0
  2649 00000CCD A1[0000]                	mov ax, word [history.last]
  2650 00000CD0 3B06[0000]              	cmp ax, word [history.first]
  2651 00000CD4 7419                    	je @F			; if there are no history entries -->
  2652 00000CD6 89C7                    	mov di, ax		; -> last displacement in high array
  2653 00000CD8 268B15                  	mov dx, [es:di]		; + bx -> behind last history entry text
  2654 00000CDB 268B7D02                	mov di, [es:di + 2]	; + bx -> at last history entry text
  2655 00000CDF 29FA                    	sub dx, di		; = length of last history entry text
  2656 00000CE1 39D1                    	cmp cx, dx		; length match ?
  2657 00000CE3 750A                    	jne @F			; no -->
  2658                                  
  2659                                  		; always ZR here. would need to keep this in mind if
  2660                                  		;  zero-length entries were considered. (repe cmpsb
  2661                                  		;  with cx = 0 leaves cx, si, di, fl unchanged.)
  2662 00000CE5 8D39                    	lea di, [di + bx]	; -> at last text
  2663 00000CE7 51                      	push cx
  2664 00000CE8 56                      	push si
  2665 00000CE9 F3A6                    	repe cmpsb		; compare candidate text to last text
  2666 00000CEB 5E                      	pop si
  2667 00000CEC 59                      	pop cx
  2668 00000CED 7473                    	je .dontenter		; equal, so skip it -->
  2669                                  @@:
  2670 00000CEF 89C7                    	mov di, ax		; -> last displacement
  2671 00000CF1 268B15                  	mov dx, [es:di]		; + bx -> free space
  2672 00000CF4 01DA                    	add dx, bx		; -> free space
  2673 00000CF6 F7DA                    	neg dx			; - free space start
  2674 00000CF8 7502                    	jnz @F
  2675 00000CFA 4A                      	dec dx			; cause add to overflow (= FFFFh)
  2676 00000CFB 47                      	inc di			; adjust for prior instruction
  2677                                  @@:
  2678 00000CFC 01FA                    	add dx, di		; - free space start + free space end
  2679                                  				;  = free space size
  2680 00000CFE 730A                    	jnc .delete		; invalid (shouldn't happen) -->
  2681 00000D00 7408                    	jz .delete		; zero bytes free -->
  2682 00000D02 4A                      	dec dx
  2683 00000D03 7405                    	jz .delete		; one byte free -->
  2684 00000D05 4A                      	dec dx
  2685                                  	; jz .delete		; one or two bytes free -->
  2686                                  		; Commented, a zero will fail the next check
  2687                                  		;  already. Unless we modify the above code
  2688                                  		;  so that empty lines can be entered into
  2689                                  		;  the history, at which point we do not want
  2690                                  		;  to fail the insertion when only two bytes
  2691                                  		;  are free, ie enough for the displacement and
  2692                                  		;  a zero-byte length text.
  2693                                  
  2694 00000D06 39D1                    	cmp cx, dx
  2695 00000D08 7646                    	jbe .insert		; enough bytes for the new entry -->
  2696                                  .delete:
  2697 00000D0A 3B06[0000]              	cmp ax, word [history.first]
  2698 00000D0E 7508                    	jne @F
  2699                                  
  2700                                  .error:
  2701 00000D10 BA[0000]                	mov dx, msg.history_internal_error
  2702 00000D13 E80FFA                  	call putsz
  2703 00000D16 EB4A                    	jmp .dontenter
  2704                                  
  2705                                  @@:
  2706 00000D18 89C7                    	mov di, ax		; -> at last displacement
  2707 00000D1A 268B3D                  	mov di, [es:di]		; + bx -> after last entry's text
  2708 00000D1D 8B36[0000]              	mov si, word [history.first]
  2709 00000D21 268B74FE                	mov si, [es:si - 2]	; + bx -> at second entry's text
  2710 00000D25 29F7                    	sub di, si		; = after last - after first
  2711                                  				;  = text length excluding first
  2712 00000D27 89F9                    	mov cx, di		; length to move
  2713 00000D29 56                      	push si
  2714 00000D2A 01DE                    	add si, bx		; -> after first entry's text
  2715 00000D2C 89DF                    	mov di, bx		; -> start of buffer
  2716 00000D2E 06                      	push es
  2717 00000D2F 1F                      	pop ds
  2718 00000D30 F3A4                    	rep movsb		; move subsequent text
  2719 00000D32 59                      	pop cx			; = how far we moved (deleted text length)
  2720 00000D33 89C7                    	mov di, ax		; -> at last displacement
  2721 00000D35 8B15                    	mov dx, word [di]	; load last displacement
  2722                                  @@:
  2723 00000D37 47                      	inc di
  2724 00000D38 47                      	inc di			; -> prior displacement
  2725 00000D39 363B3E[0000]            	cmp di, word [ss:history.first]
  2726 00000D3E 7306                    	jae @F			; (hardened, shouldn't ever be above)
  2727 00000D40 29CA                    	sub dx, cx		; adjust next displacement
  2728                                  				;  by deleted text length
  2729 00000D42 8715                    	xchg word [di], dx	; store in prior displacement
  2730                                  				;  and load its old value
  2731 00000D44 EBF1                    	jmp @B
  2732                                  
  2733                                  @@:
  2734 00000D46 16                      	push ss
  2735 00000D47 1F                      	pop ds
  2736 00000D48 8306[0000]02            	add word [history.last], 2
  2737                                  				; deleted one displacement
  2738 00000D4D E968FF                  	jmp .loop
  2739                                  
  2740                                  .insert:
  2741 00000D50 89C7                    	mov di, ax
  2742 00000D52 48                      	dec ax
  2743 00000D53 48                      	dec ax
  2744 00000D54 A3[0000]                	mov word [history.last], ax
  2745 00000D57 268B3D                  	mov di, word [es:di]
  2746 00000D5A 01DF                    	add di, bx
  2747 00000D5C F3A4                    	rep movsb
  2748 00000D5E 29DF                    	sub di, bx
  2749 00000D60 97                      	xchg di, ax		; es:di -> new last history displacement,
  2750                                  				;  ax -> after history text
  2751 00000D61 AB                      	stosw
  2752                                  
  2753                                  .dontenter:
  2754 00000D62 16                      	push ss
  2755 00000D63 07                      	pop es
  2756                                  %endif
  2757                                  
  2758                                  getline_eol:
  2759 00000D64 F606[0100]08            	testopt [internalflags3], dif3_quiet_input_single
  2760 00000D69 750B                    	jnz @F			; NC
  2761 00000D6B B00D                    	mov al, 13
  2762 00000D6D E8D7F9                  	call putc		; fix ZDOS Int21.0A display bug
  2763 00000D70 B00A                    	mov al, 10
  2764 00000D72 E8D2F9                  	call putc
  2765 00000D75 F9                      	stc
  2766                                  @@:
  2767                                  %if _EXTENSIONS && _EXT_PUTS_GETLINE
  2768 00000D76 B302                    	mov bl, 2
  2769 00000D78 80D300                  	adc bl, 0		; = 3 if displayed
  2770 00000D7B E80500                  	call set_si_line_in_and_skipwhite
  2771                                  		; INP:	byte [line_in + 1] = length
  2772                                  		;	line_in + 2 -> text
  2773                                  		;	word [promptlen] = length of prompt
  2774                                  		;	al = first non-whitespace text byte
  2775                                  		;	si -> next text
  2776                                  		;	bl = 2 or 3 means from getline_eol, any line read
  2777                                  		;	bl = 2 if not displayed, = 3 if displayed
  2778                                  		; CHG:	ah, bh, cx, dx, di
  2779                                  		; STT:	ds = es = ss
  2780                                  		;	UP, EI
  2781 00000D7E E80800                  	call transfer_to_ext_puts_getline
  2782 00000D81 F8                      	clc			; NC
  2783 00000D82 C3                      	retn
  2784                                  %endif
  2785                                  
  2786                                  set_si_line_in_and_skipwhite:
  2787 00000D83 BE[0200]                	mov si, line_in+2
  2788 00000D86 E91CF3                  	jmp skipwhite		; NC
  2789                                  
  2790                                  
  2791                                  %if _EXTENSIONS && _EXT_PUTS_GETLINE
  2792                                  transfer_to_ext_puts_getline:
  2793 00000D89 8B0E[0000]              	mov cx, word [ext_puts_getline_handler]
  2794 00000D8D E306                    	jcxz @F
  2795 00000D8F E9120E                  	jmp transfer_ext_cx
  2796                                  
  2797                                  check_section_of puts_getline_ext_done
  2798                                  puts_getline_ext_done: equ $
  2799 00000D92 59                      	pop cx
  2800 00000D93 59                      	pop cx
  2801 00000D94 59                      	pop cx				; discard return addresses
  2802                                  @@:
  2803 00000D95 C3                      	retn
  2804                                  %endif
  2805                                  
  2806                                  
  2807                                  %if _PM
  2808                                  getline_extra_uninstall:
  2809 00000D96 BA[0000]                	mov dx, debug22
  2810 00000D99 B82225                  	mov ax, 2522h
  2811 00000D9C CD21                    	int 21h
  2812 00000D9E 89160A00                	mov word [TPIV], dx	; restore default int 22h (PRI)
  2813 00000DA2 BE[1000]                	mov si, getline_extra_int23
  2814 00000DA5 B023                    	mov al, 23h
  2815 00000DA7 BAFFFF                  	mov dx, -1
  2816 00000DAA E8(0000)                	call UnhookInterruptForce
  2817                                  				; restore DPMI host's int 23h handler
  2818 00000DAD E9(0000)                	jmp resetmode		; return to PM
  2819                                  
  2820                                  	usesection lDEBUG_DATA_ENTRY
  2820          ------------------       note: usesection lDEBUG_DATA_ENTRY
  2821                                  
  2822 0000000E CB90EB10FFFFFFFF4B-     iispentry getline_extra_int23
  2822 00000017 4200EBF300<rep 7h> 
  2823 00000022 F9                      	stc
  2824 00000023 CB                      	retf			; indicate to abort syscall and process
  2825                                  
  2826                                  	align 2
  2827                                  getline_extra_int22:
  2828 00000024 FA                      	cli
  2829                                  .cleartraceflag:
  2830 00000025 FC                      	cld			; reestablish things
  2831 00000026 8CC8                    	mov ax, cs
  2832 00000028 8ED8                    	mov ds, ax
  2833 0000002A 8ED0                    	mov ss, ax
  2834 0000002C 8B26[0000]              	mov sp, word [ savesp ]	; restore stack
  2835 00000030 90                      	times 1 - (($ - $$) & 1) nop	; align in-code parameter
  2836 00000031 E8(0000)                	call entry_to_code_seg
  2837 00000034 [B00D]                  	dw .code
  2838                                  
  2839                                  	usesection lDEBUG_CODE
  2839          ------------------       note: usesection lDEBUG_CODE
  2840                                  
  2841                                  .code:
  2842                                  
  2843 00000DB0 66                      	_386_o32		; mov esp
  2844 00000DB1 8B26[0000]              	mov sp, word [ savesp ]		; restore stack
  2845 00000DB5 83E4FC                  _386	and sp, ~3			; align stack
  2846 00000DB8 66                      	_386_o32
  2847 00000DB9 31C0                    	xor ax, ax
  2848 00000DBB 66                      	_386_o32
  2849 00000DBC 50                      	push ax
  2850 00000DBD 66                      	_386_o32
  2851 00000DBE 9D                      	popf
  2852 00000DBF 8B26[0000]              _386	mov sp, word [ savesp ]		; restore stack
  2853 00000DC3 FC                      	cld
  2854 00000DC4 FB                      	sti
  2855                                  
  2856 00000DC5 E8CEFF                  	call getline_extra_uninstall
  2857                                  				; undo patches and return to PM
  2858 00000DC8 E9(0000)                	jmp handle_ctrl_c	; go to common handler -->
  2859                                  %endif
  2860                                  
  2861                                  
  2862                                  getline_is_input_file?:
  2863 00000DCB F606[0000]20            	testopt [internalflags3], dif3_input_serial_override
  2864 00000DD0 7530                    	jnz .nofile
  2865 00000DD2 F606[0300]01            	testopt [internalflags3], dif3_input_re
  2866 00000DD7 7528                    	jnz .file
  2867 00000DD9 F606[0100]01            	testopt [internalflags3], dif3_input_cmdline
  2868 00000DDE 7521                    	jnz .file
  2869                                  %if _INPUT_FILE_BOOT
  2870 00000DE0 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  2871 00000DE5 751A                    	jnz .file
  2872                                  %endif
  2873 00000DE7 E8(0000)                	call InDOS_or_BIOS_IO
  2874 00000DEA 7516                    	jnz .nofile		; InDOS, not reading from a file -->
  2875                                  %if _INPUT_FILE_HANDLES
  2876 00000DEC F606[0200]10            	testopt [internalflags2], dif2_input_file
  2877 00000DF1 750E                    	jnz .file
  2878                                  %endif
  2879 00000DF3 F606[0000]10            	testopt [serial_flags], sf_use_serial
  2880 00000DF8 7508                    	jnz .nofile
  2881 00000DFA 803E[0000]00            	cmp byte [notatty], 0	; check this weird flag
  2882 00000DFF 7401                    	je .nofile		; not reading from a file -->
  2883                                  
  2884                                  .file:
  2885 00000E01 A8                      	db __TEST_IMM8		; (skip stc, NC)
  2886                                  .nofile:
  2887 00000E02 F9                      	stc
  2888 00000E03 C3                      	retn
  2889                                  
  2890                                  
  2891                                  getline_close_file:
  2892 00000E04 51                      	push cx
  2893                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT || 1
  2894                                  		; EOF reached. if not input file, quit. else, close input file.
  2895                                  %if !_LOADER
  2896 00000E05 F606[0300]01            	testopt [internalflags3], dif3_input_re
  2897 00000E0A 7515                    	jnz .re
  2898                                  %endif
  2899                                  %if _INPUT_FILE_HANDLES && _INPUT_FILE_BOOT
  2900 00000E0C F706[0200]1002          	testopt [internalflags2], dif2_input_file | dif2_input_file_boot, 1
  2901 00000E12 750A                    	jnz @F
  2902                                  %elif _INPUT_FILE_HANDLES
  2903                                  	testopt [internalflags2], dif2_input_file
  2904                                  	jnz @F
  2905                                  %elif _INPUT_FILE_BOOT
  2906                                  	testopt [internalflags2], dif2_input_file_boot
  2907                                  	jnz @F
  2908                                  %endif
  2909 00000E14 F606[0100]01            	testopt [internalflags3], dif3_input_cmdline
  2910 00000E19 7462                    	jz .qq			; if EOF, quit -->
  2911                                  
  2912 00000E1B B1FE                    	mov cl, -2
  2913 00000E1D A9                      	db __TEST_IMM16
  2914                                  @@:
  2915 00000E1E 31C9                    	xor cx, cx
  2916                                  %if !_LOADER
  2917 00000E20 A9                      	db __TEST_IMM16
  2918                                  .re:
  2919 00000E21 B1FF                    	mov cl, -1
  2920                                  %endif
  2921                                  
  2922 00000E23 51                      	push cx
  2923 00000E24 E86900                  	call .resetstuff
  2924 00000E27 59                      	pop cx
  2925                                  
  2926 00000E28 E302                    	jcxz .notre
  2927 00000E2A EB15                    	jmp @F
  2928                                  
  2929                                  .notre:
  2930 00000E2C 59                      	pop cx
  2931 00000E2D F606[0100]04            	testopt [internalflags3], dif3_at_line_end
  2932 00000E32 750C                    	jnz .return		; (NZ)
  2933                                  
  2934 00000E34 B80D0A                  	mov ax, 13 | 10 << 8	; pretend we read a CR LF sequence
  2935 00000E37 AB                      	stosw
  2936 00000E38 893E[0000]              	mov word [bufend], di
  2937 00000E3C 4F                      	dec di
  2938 00000E3D 4F                      	dec di
  2939 00000E3E 38C0                    	cmp al, al		; ZR
  2940                                  .return:
  2941 00000E40 C3                      	retn
  2942                                  
  2943                                  @@:
  2944 00000E41 80F9FE                  	cmp cl, -2
  2945 00000E44 59                      	pop cx
  2946                                  %if !_LOADER
  2947 00000E45 741B                    	je .finish_cmdline
  2948                                  
  2949                                  .finish_re:
  2950 00000E47 F606[0100]04            	testopt [internalflags3], dif3_at_line_end
  2951 00000E4C 750E                    	jnz @F
  2952 00000E4E B82801                  	mov ax, 0128h
  2953 00000E51 E8(0000)                	call setrc
  2954 00000E54 BA[0000]                	mov dx, msg.unexpected_noneol_re
  2955 00000E57 E8C5F8                  	call putsz_error
  2956 00000E5A EB03                    	jmp @FF
  2957                                  @@:
  2958 00000E5C E8B00F                  	call resetrc
  2959                                  @@:
  2960 00000E5F E9(0000)                	jmp dumpregs_extended.exit
  2961                                  %endif
  2962                                  
  2963                                  .finish_cmdline:
  2964 00000E62 F606[0100]04            	testopt [internalflags3], dif3_at_line_end
  2965 00000E67 750E                    	jnz @F
  2966 00000E69 B82901                  	mov ax, 0129h
  2967 00000E6C E8(0000)                	call setrc
  2968 00000E6F BA[0000]                	mov dx, msg.unexpected_noneol_rc
  2969 00000E72 E8AAF8                  	call putsz_error
  2970 00000E75 EB03                    	jmp @FF
  2971                                  @@:
  2972 00000E77 E8950F                  	call resetrc
  2973                                  @@:
  2974 00000E7A E9(0000)                	jmp cmd3
  2975                                  %endif
  2976                                  
  2977                                  .qq:
  2978 00000E7D C606[0200]0D            	mov byte [line_in + 2], 13
  2979 00000E82 E8FEFE                  	call set_si_line_in_and_skipwhite
  2980 00000E85 830E[0000]08            	or word [cmd3_set_options], fakeindos
  2981 00000E8A E8(0000)                	call qq			; if EOF, quit -->
  2982 00000E8D E9(0000)                	jmp cmd3
  2983                                  
  2984                                  .resetstuff:
  2985 00000E90 57                      	push di
  2986 00000E91 E841FA                  	call yy_close_file	; close file
  2987 00000E94 5F                      	pop di
  2988                                  
  2989                                  %if _NEWFULLHANDLING
  2990 00000E95 C706[0000][0300]        	mov word [bufnext], line_in + 3
  2991 00000E9B C706[0000][0300]        	mov word [bufend], line_in + 3
  2992                                  %else
  2993                                  	mov word [bufnext], line_in + 2
  2994                                  	mov word [bufend], line_in + 2
  2995                                  %endif
  2996                                  
  2997 00000EA1 E8A504                  	call getline_reset_notatty
  2998                                  
  2999 00000EA4 E9(0000)                	jmp determine_quiet_output
  3000                                  
  3001                                  
  3002                                  getinput:
  3003                                  %if _EXTENSIONS && _EXT_PUTS_GETLINE
  3004 00000EA7 F616[0000]              	not byte [in_getinput]		; set
  3005                                  %endif
  3006                                  	lframe
  3007                                  	lequ 254,	limit
  3008                                  	lvar word,	columns
  3009                                  	lvar word,	maxpercol
  3010                                  	lvar word,	maxpercolhalf
  3011 00000EAB 5589E58D66FA            	lenter
  3012 00000EB1 06                      	 push es
  3013 00000EB2 52                      	 push dx
  3014                                  	lvar dword,	prompt	; (in line_out buffer)
  3015 00000EB3 31C0                    	xor ax, ax
  3016                                  %if _HISTORY
  3017 00000EB5 50                      	 push ax
  3018                                  	lvar word,	historyentry
  3019                                  %endif
  3020 00000EB6 50                      	 push ax
  3021                                  	lvar word,	length_displayed
  3022 00000EB7 50                      	 push ax
  3023                                  	lvar word,	length_input
  3024 00000EB8 50                      	 push ax
  3025                                  	lvar word,	offset
  3026 00000EB9 50                      	 push ax
  3027                                  	lvar word,	lastskip
  3028 00000EBA 50                      	 push ax
  3029                                  	lvar word,	low_redraw_and_high_beep
  3030                                  	lequ ?low_redraw_and_high_beep,		redraw
  3031                                  	lequ ?low_redraw_and_high_beep + 1,	beep
  3032 00000EBB 50                      	 push ax
  3033                                  	lvar word,	low_cursormove_and_high_append
  3034                                  	lequ ?low_cursormove_and_high_append,	cursormove
  3035                                  	lequ ?low_cursormove_and_high_append + 1,append
  3036 00000EBC 50                      	 push ax
  3037                                  	lvar word,	low_cursorright_and_high_edited
  3038                                  	lequ ?low_cursorright_and_high_edited, cursorright
  3039                                  	lequ ?low_cursorright_and_high_edited + 1, edited
  3040 00000EBD 51                      	 push cx
  3041                                  	lvar word,	column
  3042 00000EBE 51                      	 push cx
  3043                                  	lvar word,	promptlength
  3044                                  
  3045 00000EBF 57                      	push di
  3046 00000EC0 1E                      	push ds
  3047 00000EC1 07                      	pop es
  3048                                  
  3049                                  .next:
  3050 00000EC2 E8(0000)                	call handle_serial_flags_ctrl_c
  3051                                  
  3052 00000EC5 D046EA                  	rol byte [bp + ?redraw], 1
  3053 00000EC8 7203E90701              	jnc .no_do_redraw
  3054                                  .do_redraw:
  3055                                  
  3056 00000ECD E8F203                  	call get_columns
  3057                                  
  3058 00000ED0 8946FE                  	mov word [bp + ?columns], ax
  3059 00000ED3 48                      	dec ax				; $COLS - 1
  3060 00000ED4 2B46E2                  	sub ax, word [bp + ?promptlength]; - $promptlength
  3061 00000ED7 8946FC                  	mov word [bp + ?maxpercol], ax
  3062 00000EDA D1E8                    	shr ax, 1			; int($maxpercol / 2)
  3063 00000EDC 7501                    	jnz @F
  3064 00000EDE 40                      	inc ax				; insure nonzero
  3065                                  @@:
  3066 00000EDF 8946FA                  	mov word [bp + ?maxpercolhalf], ax
  3067                                  
  3068 00000EE2 8B46F0                  	mov ax, [bp + ?length_input]
  3069 00000EE5 89C1                    	mov cx, ax
  3070 00000EE7 31FF                    	xor di, di			; variable "skip"
  3071                                  					; + line_in + 2 -> to display
  3072 00000EE9 3B46FC                  	cmp ax, word [bp + ?maxpercol]
  3073 00000EEC 8B46E4                  	mov ax, word [bp + ?column]	; variable "col"
  3074 00000EEF 763B                    	jna .not_show_a_maxpercol
  3075                                  .show_a_maxpercol:
  3076                                  
  3077 00000EF1 8B56FC                  	mov dx, word [bp + ?maxpercol]
  3078 00000EF4 0356E2                  	add dx, word [bp + ?promptlength]
  3079                                  
  3080 00000EF7 8B5EEC                  	mov bx, word [bp + ?lastskip]
  3081 00000EFA 395EEE                  	cmp word [bp + ?offset], bx
  3082 00000EFD 7307                    	jae .offset_ae_lastskip		; spaghetti branch -->
  3083                                  .not_offset_ae_lastskip:
  3084                                  
  3085                                  @@:
  3086 00000EFF 39D0                    	cmp ax, dx
  3087 00000F01 760B                    	jna .not_col_a_maxpercol
  3088                                  .col_a_maxpercol:
  3089 00000F03 8B5EFA                  	mov bx, [bp + ?maxpercolhalf]	; bx = step length
  3090                                  
  3091                                  .offset_ae_lastskip:		; spaghetti branch target, re-uses the
  3092                                  				;  code of .col_a_maxpercol
  3093                                  	; sub ax, bx			; col -= lastskip
  3094                                  	; add di, bx			; skip += lastskip
  3095                                  	; sub cx, bx			; lessen length of part to display
  3096 00000F06 29D8                    	sub ax, bx			; lessen col
  3097 00000F08 01DF                    	add di, bx			; heighten offset of part to display
  3098 00000F0A 29D9                    	sub cx, bx			; lessen length of part to display
  3099 00000F0C EBF1                    	jmp @B
  3100                                  
  3101                                  .not_col_a_maxpercol:
  3102 00000F0E 3B7EEC                  	cmp di, word [bp + ?lastskip]	; scrolling forwards ?
  3103 00000F11 7711                    	ja @F				; yes --> (else backwards or same)
  3104                                  		; The next check should be redundant with the
  3105                                  		;  one after it. However, the call to puts with
  3106                                  		;  the comment "draw (to move cursor)" will
  3107                                  		;  underflow its counter if ax is decremented
  3108                                  		;  when it was below-or-equal ?promptlength.
  3109                                  		;  Therefore, this check hardens against that.
  3110                                  		; By checking here we ensure that the sub there
  3111                                  		;  doesn't underflow, staying above-or-equal 0.
  3112 00000F13 3B46E2                  	cmp ax, word [bp + ?promptlength]
  3113                                  					; possibly at end ?
  3114 00000F16 760C                    	jbe @F				; no -->
  3115 00000F18 39D0                    	cmp ax, dx			; are we at end ?
  3116 00000F1A 7508                    	jne @F				; no -->
  3117 00000F1C 3B4EFC                  	cmp cx, word [bp + ?maxpercol]	; displaying the last fragment ?
  3118 00000F1F 7603                    	jbe @F				; yes, do not move up -->
  3119 00000F21 48                      	dec ax
  3120 00000F22 47                      	inc di
  3121 00000F23 49                      	dec cx				; move up display by one column
  3122                                  @@:
  3123 00000F24 3B4EFC                  	cmp cx, word [bp + ?maxpercol]
  3124 00000F27 7603                    	jbe @F
  3125 00000F29 8B4EFC                  	mov cx, word [bp + ?maxpercol]
  3126                                  @@:
  3127                                  .not_show_a_maxpercol:
  3128 00000F2C 397EEC                  	cmp word [bp + ?lastskip], di	; need to scroll ?
  3129 00000F2F 7408                    	je @F				; no -->
  3130 00000F31 8366E800                	and word [bp + ?low_cursormove_and_high_append], 0
  3131                                  					; yes, ignore appending status
  3132                                  					; ignore cursor move status too
  3133 00000F35 C646E600                	mov byte [bp + ?cursorright], 0	; also reset this flag
  3134                                  @@:
  3135                                  
  3136 00000F39 897EEC                  	mov word [bp + ?lastskip], di	; update variable for next iteration
  3137 00000F3C 8D95[0200]              	lea dx, [di + line_in + 2]	; -> visible text's data
  3138                                  
  3139 00000F40 89CB                    	mov bx, cx
  3140 00000F42 875EF2                  	xchg bx, word [bp + ?length_displayed]
  3141                                  					; bx = remember how much we had,
  3142                                  					;  and update variable
  3143                                  
  3144 00000F45 D046E8                  	rol byte [bp + ?cursormove], 1	; cursor move without visible window move ?
  3145 00000F48 7250                    	jc .redraw_always_move_cursor	; yes, skip full redraw and also
  3146                                  					;  force to do cursor movement -->
  3147 00000F4A 50                      	push ax
  3148 00000F4B 53                      	push bx
  3149 00000F4C 51                      	push cx
  3150 00000F4D 52                      	push dx
  3151                                  		; On stack:
  3152                                  		;  -> start of visible text's data
  3153                                  		;  length of visible text
  3154                                  		;  prior length of visible text (from prior iteration)
  3155                                  		;  variable "col"
  3156 00000F4E D046E9                  	rol byte [bp + ?append], 1	; text appended without visible window move ?
  3157 00000F51 730E                    	jnc .not_append_redraw		; no, do full redraw -->
  3158 00000F53 F656E9                  	not byte [bp + ?append]		; = 0, reset flag after its use
  3159 00000F56 01CA                    	add dx, cx			; -> behind text to write
  3160 00000F58 4A                      	dec dx				; -> at last codepoint (appended)
  3161 00000F59 B90100                  	mov cx, 1			; only append
  3162                                  %if _GETLINEHIGHLIGHT
  3163                                  		; This appended text is always the very last text
  3164                                  		;  in the buffer so it never should get highlighted.
  3165                                  		; If this build option is not in use then the next
  3166                                  		;  branch is to the call puts below, re-using that
  3167                                  		;  call there that's also used for the full redraw.
  3168 00000F5C E850F2                  	call puts			; draw appended text
  3169                                  %endif
  3170 00000F5F EB1A                    	jmp .after_append_redraw	; skip past more prompt/text redraw
  3171                                  
  3172                                  .not_append_redraw:
  3173 00000F61 51                      	push cx
  3174 00000F62 52                      	push dx
  3175 00000F63 B00D                    	mov al, 13
  3176 00000F65 E8DFF7                  	call putc			; reset to start of line
  3177                                  
  3178 00000F68 C456F6                  	les dx, [bp + ?prompt]
  3179 00000F6B 8B4EE2                  	mov cx, [bp + ?promptlength]
  3180 00000F6E E83EF2                  	call puts			; redraw the prompt
  3181 00000F71 16                      	 push ss
  3182 00000F72 07                      	 pop es				; reset es
  3183 00000F73 5A                      	pop dx
  3184 00000F74 59                      	pop cx				; restore registers for text redraw
  3185                                  %if _GETLINEHIGHLIGHT
  3186                                  					; di for prefix highlight condition
  3187 00000F75 8B5EF0                  	mov bx, word [bp + ?length_input]
  3188                                  					; bx for suffix highlight condition
  3189 00000F78 E87703                  	call puts_with_highlight	; redraw the text
  3190                                  .after_append_redraw:
  3191                                  %else
  3192                                  .after_append_redraw:
  3193                                  	call puts			; redraw the text
  3194                                  %endif
  3195 00000F7B 5A                      	pop dx
  3196 00000F7C 5B                      	pop bx
  3197 00000F7D 59                      	pop cx
  3198                                  		; dx -> start of visible text's data
  3199                                  		; bx = new length of visible text
  3200                                  		; cx = prior length of visible text (from prior iteration)
  3201                                  		; on stack = variable "col"
  3202 00000F7E 29D9                    	sub cx, bx			; = how many blanks needed to overwrite
  3203 00000F80 7609                    	jbe @FF
  3204 00000F82 01CB                    	add bx, cx			; = length displayed
  3205 00000F84 B020                    	mov al, 32
  3206                                  @@:
  3207 00000F86 E8BEF7                  	call putc
  3208 00000F89 E2FB                    	loop @B
  3209                                  @@:
  3210 00000F8B 58                      	pop ax
  3211                                  		; dx -> start of visible text's data
  3212                                  		; ax = variable "col"
  3213                                  		; bx = length of redrawn text (including blanks),
  3214                                  		;  this indicates where the cursor is
  3215                                  
  3216                                  		; The following check determines whether the
  3217                                  		;  cursor is already where we want it to be
  3218                                  		;  after the full redraw is done, including the
  3219                                  		;  blanks after the visible text that were used
  3220                                  		;  to erase the prior visible text (if any).
  3221                                  		; If this branches then the cursor movement is
  3222                                  		;  not needed and thus we're done redrawing.
  3223 00000F8C 01D3                    	add bx, dx
  3224 00000F8E 81EB[0200]              	sub bx, line_in + 2		; offset into line (with length displayed)
  3225 00000F92 035EE2                  	add bx, word [bp + ?promptlength]; offset into display
  3226 00000F95 3B5EE4                  	cmp bx, word [bp + ?column]	; same as column ?
  3227 00000F98 7437                    	je .do_redraw_done		; yes, skip cursor movement stuff -->
  3228                                  
  3229                                  .redraw_always_move_cursor:
  3230 00000F9A C646E800                	mov byte [bp + ?cursormove], 0	; reset flag after its use
  3231                                  
  3232                                  		; dx -> start of visible text's data
  3233                                  		; ax = variable "col"
  3234 00000F9E D046E6                  	rol byte [bp + ?cursorright], 1	; only cursor to the right without
  3235                                  					;  having to scroll the visible text ?
  3236 00000FA1 7312                    	jnc @F				; no, do redraw -->
  3237 00000FA3 F656E6                  	not byte [bp + ?cursorright]	; = 0, reset for next iteration
  3238 00000FA6 B90100                  	mov cx, 1			; length of text to write
  3239 00000FA9 2B46E2                  	sub ax, word [bp + ?promptlength]
  3240                                  					; = offset into input text
  3241 00000FAC 48                      	dec ax				; -> last codepoint of text
  3242                                  	;; test ax, ax			; at start of visible text ?
  3243 00000FAD 741D                    	jz .redraw_cursorright		; yes, leave di so as to highlight
  3244                                  					;  the prefix as appropriate -->
  3245                                  					; (and dx is correct, we'd add zero)
  3246 00000FAF 31FF                    	xor di, di			; else, tell it not to highlight
  3247 00000FB1 01C2                    	add dx, ax			; dx = "skip" + line_in + 2 + index
  3248 00000FB3 EB17                    	jmp .redraw_cursorright
  3249                                  
  3250                                  @@:
  3251 00000FB5 50                      	push ax
  3252 00000FB6 52                      	push dx
  3253 00000FB7 B00D                    	mov al, 13
  3254 00000FB9 E88BF7                  	call putc			; reset cursor
  3255 00000FBC C456F6                  	les dx, [bp + ?prompt]
  3256 00000FBF 8B4EE2                  	mov cx, [bp + ?promptlength]
  3257 00000FC2 E8EAF1                  	call puts			; redraw prompt
  3258 00000FC5 16                      	 push ss
  3259 00000FC6 07                      	 pop es
  3260 00000FC7 5A                      	pop dx				; -> current input text
  3261 00000FC8 59                      	pop cx				; = col
  3262 00000FC9 2B4EE2                  	sub cx, word  [bp + ?promptlength]
  3263                                  					; = offset into input text,
  3264                                  					;  draw that much
  3265                                  .redraw_cursorright:
  3266                                  %if _GETLINEHIGHLIGHT
  3267                                  		; ! di is still set to lastskip value,
  3268                                  		;  or reset to zero if cursor right with
  3269                                  		;  just a single codepoint redraw but the
  3270                                  		;  codepoint to redraw is not at the start
  3271                                  		;  of the visible text.
  3272                                  					; di for prefix highlight condition
  3273                                  		; We need to make sure that the suffix is never
  3274                                  		;  highlighted here because we are writing a
  3275                                  		;  fragment that does not include the last part
  3276                                  		;  of the visible text. By zeroing bx we can
  3277                                  		;  ensure the suffix highlight condition is
  3278                                  		;  always considered to be false.
  3279 00000FCC 31DB                    	xor bx, bx			; bx = 0, never highlight a suffix
  3280 00000FCE E82103                  	call puts_with_highlight
  3281                                  %else
  3282                                  	call puts			; draw (to move cursor)
  3283                                  %endif
  3284                                  
  3285                                  .do_redraw_done:
  3286 00000FD1 F656EA                  	not byte [bp + ?redraw]		; = 0
  3287                                  
  3288                                  .no_do_redraw:
  3289                                  
  3290 00000FD4 D046EB                  	rol byte [bp + ?beep], 1
  3291 00000FD7 7308                    	jnc .no_do_beep
  3292                                  .do_beep:
  3293 00000FD9 B007                    	mov al, 7
  3294 00000FDB E869F7                  	call putc
  3295                                  
  3296 00000FDE F656EB                  	not byte [bp + ?beep]		; = 0
  3297                                  .no_do_beep:
  3298                                  
  3299 00000FE1 E8A5F7                  	call getc			; ax = keycode, al = ASCII or 0
  3300                                  
  3301                                  		; check scancode for int 16h in non-dumb dosemu first
  3302 00000FE4 86C4                    	xchg al, ah
  3303 00000FE6 3C48                    	cmp al, 48h
  3304 00000FE8 7503E9F501              	je .up
  3305 00000FED 3C4B                    	cmp al, 4Bh
  3306 00000FEF 7503E9C201              	je .left
  3307 00000FF4 3C50                    	cmp al, 50h
  3308 00000FF6 7503E90202              	je .down
  3309 00000FFB 3C4D                    	cmp al, 4Dh
  3310 00000FFD 7503E9C701              	je .right
  3311 00001002 3C52                    	cmp al, 52h
  3312 00001004 7503E94B02              	je .insert
  3313 00001009 3C53                    	cmp al, 53h
  3314 0000100B 7503E96801              	je .del
  3315 00001010 3C47                    	cmp al, 47h
  3316 00001012 7503E98501              	je .home
  3317 00001017 3C4F                    	cmp al, 4Fh
  3318 00001019 7503E98A01              	je .end
  3319 0000101E 3C49                    	cmp al, 49h
  3320 00001020 7503E92F02              	je .pageup
  3321 00001025 3C51                    	cmp al, 51h
  3322 00001027 7503E92802              	je .pagedown
  3323                                  
  3324                                  		; not a special scancode, check character returned
  3325 0000102C 86C4                    	xchg al, ah
  3326 0000102E 3C1B                    	cmp al, 1Bh
  3327 00001030 7403E98B00              	jne .not_esc
  3328                                  
  3329                                  		; check escape scancodes for int 16h in -dumb dosemu
  3330                                  		;  or input from serial I/O (picocom/screen/ssh/mate-terminal)
  3331                                  .esc:
  3332 00001035 E851F7                  	call getc
  3333 00001038 3C5B                    	cmp al, '['
  3334 0000103A 7403E91502              	jne .beep
  3335 0000103F E847F7                  	call getc
  3336 00001042 3C41                    	cmp al, 41h
  3337 00001044 7503E99901              	je .up
  3338 00001049 3C44                    	cmp al, 44h
  3339 0000104B 7503E96601              	je .left
  3340 00001050 3C42                    	cmp al, 42h
  3341 00001052 7503E9A601              	je .down
  3342 00001057 3C43                    	cmp al, 43h
  3343 00001059 7503E96B01              	je .right
  3344 0000105E 3C32                    	cmp al, 32h
  3345 00001060 7425                    	je .check_insert
  3346 00001062 3C33                    	cmp al, 33h
  3347 00001064 7421                    	je .check_del
  3348 00001066 3C31                    	cmp al, 31h
  3349 00001068 741D                    	je .check_home
  3350 0000106A 3C34                    	cmp al, 34h
  3351 0000106C 7419                    	je .check_end
  3352 0000106E 3C48                    	cmp al, 48h
  3353 00001070 7503E92701              	je .home
  3354 00001075 3C46                    	cmp al, 46h
  3355 00001077 7503E92C01              	je .end
  3356 0000107C 3C35                    	cmp al, 35h
  3357 0000107E 7407                    	je .check_pageup
  3358 00001080 3C36                    	cmp al, 36h
  3359 00001082 7403                    	je .check_pagedown
  3360 00001084 E9CD01                  	jmp .beep
  3361                                  
  3362                                  
  3363                                  .check_insert:
  3364                                  .check_del:
  3365                                  .check_home:
  3366                                  .check_end:
  3367                                  .check_pageup:
  3368                                  .check_pagedown:
  3369 00001087 50                      	push ax
  3370 00001088 E8FEF6                  	call getc
  3371 0000108B 3C7E                    	cmp al, 7Eh
  3372 0000108D 58                      	pop ax
  3373 0000108E 7403E9C101              	jne .beep
  3374                                  
  3375 00001093 3C32                    	cmp al, 32h
  3376 00001095 7503E9BA01              	je .insert
  3377 0000109A 3C33                    	cmp al, 33h
  3378 0000109C 7503E9D700              	je .del
  3379 000010A1 3C31                    	cmp al, 31h
  3380 000010A3 7503E9F400              	je .home
  3381 000010A8 3C34                    	cmp al, 34h
  3382 000010AA 7503E9F900              	je .end
  3383 000010AF 3C35                    	cmp al, 35h
  3384 000010B1 7503E99E01              	je .pageup
  3385 000010B6 3C36                    	cmp al, 36h
  3386 000010B8 7503E99701              	je .pagedown
  3387                                  
  3388 000010BD E99401                  	jmp .beep
  3389                                  
  3390                                  
  3391                                  .not_esc:
  3392                                  		; check regular characters
  3393 000010C0 84C0                    	test al, al			; waste?
  3394 000010C2 7503E9FBFD              	je .next
  3395 000010C7 3CE0                    	cmp al, 0E0h
  3396 000010C9 7503E9F4FD              	je .next			; waste -->
  3397                                  
  3398 000010CE 3C01                    	cmp al, 'A' - '@'
  3399 000010D0 7503E9C700              	je .home
  3400 000010D5 3C05                    	cmp al, 'E' - '@'
  3401 000010D7 7503E9CC00              	je .end
  3402 000010DC 3C03                    	cmp al, 03h
  3403 000010DE 7503E97801              	je .ctrlc
  3404 000010E3 3C09                    	cmp al, 09h
  3405 000010E5 7503E96A01              	je .beep		; tab
  3406 000010EA 3C08                    	cmp al, 08h
  3407 000010EC 745F                    	je .backspace
  3408 000010EE 3C7F                    	cmp al, 7Fh
  3409                                  		; On the server in int 16h of -dumb dosemu, as well as on
  3410                                  		;  both systems across serial I/O this code is used.
  3411 000010F0 745B                    	je .backspace
  3412 000010F2 3C0A                    	cmp al, 10			; (allow Linux style linebreak)
  3413 000010F4 7503E96501              	je .done
  3414 000010F9 3C0D                    	cmp al, 13			; (match for CR keypress)
  3415 000010FB 7503E95E01              	je .done
  3416                                  
  3417                                  .textcodepoint:
  3418 00001100 8B5EF0                  	mov bx, word [bp + ?length_input]
  3419 00001103 81FBFE00                	cmp bx, ?limit
  3420 00001107 7207                    	jb @F
  3421                                  .redraw_and_beep:
  3422 00001109 C646EAFF                	mov byte [bp + ?redraw], -1
  3423 0000110D E94401                  	jmp .beep
  3424                                  @@:
  3425                                  
  3426 00001110 C646E7FF                	mov byte [bp + ?edited], -1
  3427 00001114 8B56F0                  	mov dx, word [bp + ?length_input]
  3428 00001117 89D1                    	mov cx, dx
  3429 00001119 89D7                    	mov di, dx
  3430 0000111B 16                      	push ss
  3431 0000111C 07                      	pop es
  3432 0000111D 81C7[0200]              	add di, line_in + 2		; di -> behind end of input
  3433 00001121 89FE                    	mov si, di
  3434 00001123 4E                      	dec si				; si -> at last entry of input
  3435 00001124 2B4EEE                  	sub cx, word [bp + ?offset]
  3436 00001127 7504                    	jnz @F				; not appending -->
  3437                                  .textappend:
  3438 00001129 C646E9FF                	mov byte [bp + ?append], -1
  3439                                  @@:
  3440 0000112D FD                      	std				; AMD erratum 109 workaround done
  3441                                  	numdef AMD_ERRATUM_109_WORKAROUND, 1
  3442                                  %if _AMD_ERRATUM_109_WORKAROUND
  3443 0000112E E308                    	jcxz @FF
  3444 00001130 83F914                  	cmp cx, 20
  3445 00001133 7703                    	ja @FF
  3446                                  @@:
  3447 00001135 A4                      	movsb
  3448 00001136 E2FD                    	loop @B
  3449                                  @@:
  3450                                  %endif
  3451 00001138 F3A4                    	rep movsb
  3452 0000113A FC                      	cld
  3453 0000113B 8805                    	mov byte [di], al
  3454 0000113D FF46E4                  	inc word [bp + ?column]
  3455 00001140 FF46EE                  	inc word [bp + ?offset]
  3456 00001143 FF46F0                  	inc word [bp + ?length_input]
  3457                                  .redraw:
  3458 00001146 C646EAFF                	mov byte [bp + ?redraw], -1
  3459 0000114A E975FD                  	jmp .next
  3460                                  
  3461                                  .backspace:
  3462 0000114D 837EEE00                	cmp word [bp + ?offset], 0
  3463 00001151 7422                    	je .backspace_offset_0
  3464                                  
  3465 00001153 C646E7FF                	mov byte [bp + ?edited], -1
  3466 00001157 16                      	push ss
  3467 00001158 07                      	pop es
  3468 00001159 8B7EEE                  	mov di, word [bp + ?offset]
  3469 0000115C 8B4EF0                  	mov cx, word [bp + ?length_input]
  3470 0000115F 29F9                    	sub cx, di			; length after offset
  3471 00001161 81C7[0200]              	add di, line_in + 2		; -> at offset in line
  3472 00001165 89FE                    	mov si, di			; -> at offset in line
  3473 00001167 4F                      	dec di				; -> at offset - 1 in line
  3474 00001168 F3A4                    	rep movsb			; move down additional content
  3475 0000116A FF4EE4                  	dec word [bp + ?column]
  3476 0000116D FF4EEE                  	dec word [bp + ?offset]
  3477 00001170 FF4EF0                  	dec word [bp + ?length_input]
  3478 00001173 EBD1                    	jmp .redraw
  3479                                  
  3480                                  .backspace_offset_0:
  3481                                  .del_offset_ae_length_input:
  3482                                  .left_offset_0:
  3483                                  .right_offset_too_high:
  3484 00001175 E9DC00                  	jmp .beep
  3485                                  
  3486                                  .del:
  3487 00001178 8B46EE                  	mov ax, word [bp + ?offset]
  3488 0000117B 3B46F0                  	cmp ax, word [bp + ?length_input]
  3489 0000117E 73F5                    	jae .del_offset_ae_length_input
  3490 00001180 C646E7FF                	mov byte [bp + ?edited], -1
  3491 00001184 89C7                    	mov di, ax
  3492 00001186 81C7[0200]              	add di, line_in + 2		; -> at current offset
  3493 0000118A 89FE                    	mov si, di
  3494 0000118C 46                      	inc si				; -> after current offset
  3495 0000118D 40                      	inc ax				; offset + 1
  3496 0000118E F7D8                    	neg ax				; - (offset + 1)
  3497 00001190 0346F0                  	add ax, word [bp + ?length_input]; length input - (offset + 1)
  3498 00001193 89C1                    	mov cx, ax
  3499 00001195 F3A4                    	rep movsb			; move down part after deleted point
  3500 00001197 FF4EF0                  	dec word [bp + ?length_input]
  3501 0000119A EBAA                    	jmp .redraw
  3502                                  
  3503                                  .home:
  3504 0000119C 8366EE00                	and word [bp + ?offset], 0
  3505 000011A0 FF76E2                  	push word [bp + ?promptlength]
  3506 000011A3 8F46E4                  	pop word [bp + ?column]
  3507 000011A6 EB9E                    	jmp .redraw
  3508                                  
  3509                                  .end:
  3510 000011A8 8B46F0                  	mov ax, word [bp + ?length_input]
  3511 000011AB 8946EE                  	mov word [bp + ?offset], ax
  3512 000011AE 0346E2                  	add ax, word [bp + ?promptlength]
  3513 000011B1 8946E4                  	mov word [bp + ?column], ax
  3514 000011B4 EB90                    	jmp .redraw
  3515                                  
  3516                                  .left:
  3517 000011B6 837EEE00                	cmp word [bp + ?offset], 0
  3518 000011BA 74B9                    	je .left_offset_0
  3519 000011BC C646E8FF                	mov byte [bp + ?cursormove], -1
  3520 000011C0 FF4EEE                  	dec word [bp + ?offset]
  3521 000011C3 FF4EE4                  	dec word [bp + ?column]
  3522 000011C6 E97DFF                  	jmp .redraw
  3523                                  
  3524                                  .right:
  3525 000011C9 8B46EE                  	mov ax, word [bp + ?offset]
  3526 000011CC 3B46F0                  	cmp ax, word [bp + ?length_input]
  3527 000011CF 73A4                    	jnb .right_offset_too_high
  3528 000011D1 C646E8FF                	mov byte [bp + ?cursormove], -1
  3529 000011D5 C646E6FF                	mov byte [bp + ?cursorright], -1
  3530 000011D9 FF46EE                  	inc word [bp + ?offset]
  3531 000011DC FF46E4                  	inc word [bp + ?column]
  3532 000011DF E964FF                  	jmp .redraw
  3533                                  
  3534                                  .up:
  3535 000011E2 D046E7                  	rol byte [bp + ?edited], 1
  3536 000011E5 726D                    	jc .beep
  3537                                  %if _HISTORY
  3538 000011E7 8B76F4                  	mov si, word [bp + ?historyentry]
  3539 000011EA 85F6                    	test si, si
  3540 000011EC 8D7402                  	lea si, [si + 2]
  3541 000011EF 7504                    	jnz @F
  3542 000011F1 8B36[0000]              	mov si, word [history.last]
  3543                                  @@:
  3544 000011F5 3B36[0000]              	cmp si, word [history.first]
  3545 000011F9 7459                    	je .beep
  3546 000011FB EB1A                    	jmp .copyline
  3547                                  
  3548                                  .down:
  3549 000011FD D046E7                  	rol byte [bp + ?edited], 1
  3550 00001200 7252                    	jc .beep
  3551 00001202 8B76F4                  	mov si, word [bp + ?historyentry]
  3552 00001205 85F6                    	test si, si
  3553 00001207 744B                    	jz .beep
  3554 00001209 3B36[0000]              	cmp si, word [history.last]
  3555 0000120D 7506                    	jne @F
  3556 0000120F 31C0                    	xor ax, ax
  3557 00001211 31C9                    	xor cx, cx
  3558 00001213 EB10                    	jmp .setline
  3559                                  
  3560                                  @@:
  3561 00001215 4E                      	dec si
  3562 00001216 4E                      	dec si
  3563                                  
  3564                                  .copyline:
  3565 00001217 89F0                    	mov ax, si
  3566                                  	gethistorysegment ds
   480 00001219 368E1E[0000]        <1>  mov %1, word [ss:history.segorsel]
  3567 0000121E 8B0C                    	mov cx, [si]
  3568 00001220 8B7402                  	mov si, [si + 2]
  3569 00001223 29F1                    	sub cx, si
  3570                                  
  3571                                  .setline:
  3572 00001225 8946F4                  	mov word [bp + ?historyentry], ax
  3573                                  	gethistoryoffset bx
   483 00001228 BB0000              <1>  mov %1, 0
  3574 0000122B 8D30                    	lea si, [si + bx]
  3575 0000122D 16                      	push ss
  3576 0000122E 07                      	pop es
  3577 0000122F BF[0100]                	mov di, line_in + 1
  3578 00001232 88C8                    	mov al, cl
  3579 00001234 AA                      	stosb
  3580 00001235 F3A4                    	rep movsb
  3581 00001237 B00D                    	mov al, 13
  3582 00001239 AA                      	stosb
  3583 0000123A 16                      	push ss
  3584 0000123B 1F                      	pop ds
  3585                                  %else
  3586                                  .down: equ .beep
  3587                                  
  3588                                  	mov byte [bp + ?edited], -1
  3589                                  %endif
  3590 0000123C 31C0                    	xor ax, ax
  3591 0000123E A0[0100]                	mov al, byte [line_in + 1]
  3592 00001241 8946EE                  	mov word [bp + ?offset], ax
  3593 00001244 8946F0                  	mov word [bp + ?length_input], ax
  3594 00001247 0346E2                  	add ax, word [bp + ?promptlength]
  3595 0000124A 8946E4                  	mov word [bp + ?column], ax
  3596 0000124D 8366EC00                	and word [bp + ?lastskip], 0
  3597 00001251 E9F2FE                  	jmp .redraw
  3598                                  
  3599                                  .insert:
  3600                                  .pageup:
  3601                                  .pagedown:
  3602                                  .beep:
  3603 00001254 C646EBFF                	mov byte [bp + ?beep], -1
  3604 00001258 E967FC                  	jmp .next
  3605                                  
  3606                                  .ctrlc:
  3607 0000125B E9(0000)                	jmp handle_ctrl_c
  3608                                  
  3609                                  .done:
  3610 0000125E 8B7EF0                  	mov di, word [bp + ?length_input]
  3611                                  
  3612 00001261 8B56EC                  	mov dx, word [bp + ?lastskip]
  3613 00001264 0356F2                  	add dx, word [bp + ?length_displayed]
  3614                                  					; offset into line (with length displayed)
  3615 00001267 0356E2                  	add dx, word [bp + ?promptlength]; offset into display
  3616 0000126A 3B56E4                  	cmp dx, word [bp + ?column]	; same as column ?
  3617 0000126D 750A                    	jne @F				; no, always redraw -->
  3618                                  
  3619 0000126F 89F8                    	mov ax, di
  3620 00001271 0346E2                  	add ax, word [bp + ?promptlength]
  3621 00001274 3946FE                  	cmp word [bp + ?columns], ax
  3622 00001277 7720                    	ja .done_no_redraw
  3623                                  
  3624                                  @@:
  3625 00001279 B00D                    	mov al, 13
  3626 0000127B E8C9F4                  	call putc			; reset cursor
  3627 0000127E C456F6                  	les dx, [bp + ?prompt]
  3628 00001281 8B4EE2                  	mov cx, [bp + ?promptlength]	; es:dx length cx -> prompt data
  3629                                  %if _40COLUMNS
  3630 00001284 31C0                    	xor ax, ax			; last fragment length = 0
  3631 00001286 E847F2                  	call puts_break_line
  3632 00001289 16                      	 push ss
  3633 0000128A 07                      	 pop es
  3634 0000128B 8B4EF0                  	mov cx, word [bp + ?length_input]
  3635 0000128E E303                    	jcxz @F				; if empty line -->
  3636 00001290 E862F2                  	call puts_break_line_more	; more follows, do a linebreak if ax == 0
  3637                                  @@:
  3638 00001293 BA[0200]                	mov dx, line_in + 2		; es:dx length cx -> input line data
  3639 00001296 E837F2                  	call puts_break_line		; INP:ax = last fragment length
  3640                                  	; jmp .done_no_redraw
  3641                                  	; (fall through)
  3642                                  %else
  3643                                  	call puts			; redraw prompt
  3644                                  	 push ss
  3645                                  	 pop es
  3646                                  	mov dx, line_in + 2
  3647                                  	mov cx, word [bp + ?length_input]
  3648                                  	call puts			; draw
  3649                                  %endif
  3650                                  
  3651                                  .done_no_redraw:
  3652 00001299 81C7[0200]              	add di, line_in + 2
  3653 0000129D B00D                    	mov al, 13
  3654 0000129F AA                      	stosb				; store the CR (there always is room)
  3655 000012A0 97                      	xchg ax, di			; -> behind CR
  3656                                  %ifn _LINK
  3657                                  	sub al, ((-section.DATASTACK.vstart+100h+ldebug_data_entry_size 				+asmtable1_size+asmtable2_size) 		 +line_in+3) & 0FFh	; length of string, excluding CR
  3660                                  		; (This instruction disregards the unnecessary higher byte.)
  3661                                  %else
  3662 000012A1 2C03                    	sub al, 3
  3663                                   wlcalc byte_ext_line_in, equ $ - 1
  3664                                  %endif
  3665 000012A3 5F                      	pop di				; restore di
  3666 000012A4 A2[0100]                	mov byte [line_in+1], al	; store the length byte
  3667 000012A7 89EC5D                  	lleave code
  3668                                  %if _EXTENSIONS && _EXT_PUTS_GETLINE
  3669 000012AA F616[0000]              	not byte [in_getinput]		; clear
  3670 000012AE B301                    	mov bl, 1
  3671                                  %endif
  3672 000012B0 E902FA                  	jmp getline_eol_enter_history_and_ext
  3673                                  
  3674                                  	lleave ctx
  3675                                  
  3676                                  
  3677                                  fullbsout:
  3678 000012B3 B008                    	mov al, 8
  3679 000012B5 E88FF4                  	call putc
  3680 000012B8 B020                    	mov al, 32
  3681 000012BA E88AF4                  	call putc
  3682 000012BD B008                    	mov al, 8
  3683 000012BF E985F4                  	jmp putc
  3684                                  
  3685                                  
  3686                                  		; INP:	-
  3687                                  		; OUT:	ax = number of columns to use
  3688                                  		; STT:	ds = ss = debugger data selector
  3689                                  get_columns:
  3690 000012C2 31C0                    	xor ax, ax
  3691 000012C4 F606[0000]10            	testopt [serial_flags], sf_use_serial
  3692                                  					; serial ?
  3693 000012C9 7411                    	jz @F				; no -->
  3694 000012CB 0A06[0000]              	or al, byte [serial_columns]	; ax = number of columns if serial
  3695 000012CF 7407                    	jz .default_columns
  3696 000012D1 3C01                    	cmp al, 1
  3697 000012D3 751C                    	jne @FF
  3698 000012D5 48                      	dec ax				; = 0
  3699 000012D6 EB04                    	jmp @F				; use IOC / BDA selection
  3700                                  .default_columns:
  3701 000012D8 B050                    	mov al, 80
  3702 000012DA EB15                    	jmp @FF
  3703                                  @@:
  3704 000012DC 0A06[0000]              	or al, [io_columns]
  3705 000012E0 74F6                    	jz .default_columns
  3706 000012E2 3C01                    	cmp al, 1			; is 1 ?
  3707 000012E4 750B                    	jne @F				; no, use as columns -->
  3708                                  					; yes, automatic (use BDA)
  3709 000012E6 06                      	push es
  3710 000012E7 B84000                  	mov ax, 40h			; 0040h is a bimodal segment/selector
  3711 000012EA 8EC0                    	mov es, ax
  3712 000012EC 26A14A00                	mov ax, word [ es:4Ah ]		; columns on screen
  3713 000012F0 07                      	pop es
  3714                                  @@:
  3715 000012F1 C3                      	retn
  3716                                  
  3717                                  
  3718                                  %if _GETLINEHIGHLIGHT
  3719                                  		; INP:	di = index from total text start to visible text
  3720                                  		;	cx = length of visible text to display
  3721                                  		;	dx -> visible text to display
  3722                                  		;	bx = length of total text
  3723                                  		;	di != 0 if to highlight first codepoint
  3724                                  		;	di + cx < bx if to highlight last codepoint
  3725                                  		; OUT:	if INP:cx == 0,
  3726                                  		;	 just returns
  3727                                  		;	if opt3_getline_highlight not set,
  3728                                  		;	 just chains to puts
  3729                                  		;	no prefix highlight if INP:di == 0,
  3730                                  		;	 else first codepoint displayed highlighted
  3731                                  		;	no suffix highlight if INP:di + INP:cx >= INP:bx,
  3732                                  		;	 else last codepoint displayed highlighted
  3733                                  		;	calls puts and/or putsz to display all text
  3734                                  		; CHG:	ax, bx, cx, dx
  3735                                  puts_with_highlight:
  3736 000012F2 E33F                    	jcxz .retn
  3737 000012F4 F606[0300]01            	testopt [options3], opt3_getline_highlight
  3738 000012F9 7439                    	jz .justputs
  3739 000012FB 51                      	push cx
  3740 000012FC 85FF                    	test di, di			; prefix to highlight ?
  3741 000012FE 7414                    	jz @F				; no -->
  3742                                  .prefix:
  3743 00001300 53                      	push bx
  3744 00001301 E83300                  	call emit_highlight
  3745 00001304 52                      	 push dx			; ! dx on stack
  3746 00001305 51                      	push cx
  3747 00001306 B90100                  	mov cx, 1
  3748 00001309 E8A3EE                  	call puts			; draw one codepoint
  3749 0000130C 59                      	pop cx
  3750 0000130D E83000                  	call emit_unhighlight
  3751 00001310 5A                      	 pop dx				; ! restore dx -> data
  3752 00001311 42                      	inc dx				; -> second codepoint
  3753 00001312 49                      	dec cx				; length one less
  3754 00001313 5B                      	pop bx
  3755                                  @@:
  3756 00001314 58                      	pop ax				; = length of text (including prefix)
  3757 00001315 01F8                    	add ax, di			; = index past last displayed
  3758 00001317 39D8                    	cmp ax, bx			; is it equal to total text length ?
  3759 00001319 7319                    	jae .justputs			; yes, just display -->
  3760                                  
  3761                                  .suffix:
  3762 0000131B E316                    	jcxz .retn			; if no suffix possible -->
  3763 0000131D 49                      	dec cx				; = length of unhighlighted text
  3764 0000131E 89C8                    	mov ax, cx
  3765 00001320 01D0                    	add ax, dx			; -> at codepoint to highlight
  3766 00001322 50                      	push ax
  3767 00001323 E889EE                  	call puts			; draw unhighlighted text
  3768 00001326 E80E00                  	call emit_highlight
  3769 00001329 5A                      	pop dx				; -> at codepoint to highlight
  3770 0000132A B90100                  	mov cx, 1
  3771 0000132D E87FEE                  	call puts			; draw one codepoint
  3772 00001330 E80D00                  	call emit_unhighlight
  3773                                  .retn:
  3774 00001333 C3                      	retn
  3775                                  
  3776                                  .justputs:
  3777 00001334 E978EE                  	jmp puts			; draw text (no highlight)
  3778                                  %endif
  3779                                  
  3780                                  
  3781                                  %if _GETLINEHIGHLIGHT || _DHIGHLIGHT
  3782                                  emit_highlight:
  3783 00001337 52                      	push dx
  3784 00001338 BA[0100]                	mov dx, msg.highlight + 1	; -> ASCIZ escape code
  3785 0000133B E8E7F3                  	call putsz
  3786 0000133E 5A                      	pop dx
  3787 0000133F C3                      	retn
  3788                                  
  3789                                  emit_unhighlight:
  3790 00001340 52                      	push dx
  3791 00001341 BA[0100]                	mov dx, msg.unhighlight + 1	; -> ASCIZ escape code
  3792 00001344 E8DEF3                  	call putsz
  3793 00001347 5A                      	pop dx
  3794 00001348 C3                      	retn
  3795                                  %endif
  3796                                  
  3797                                  
  3798                                  getline_reset_notatty:
  3799 00001349 F606[0300]02            	testopt [internalflags3], dif3_input_re_closed
  3800 0000134E 7421                    	jz @F
  3801 00001350 8026[0300]FD            	clropt [internalflags3], dif3_input_re_closed
  3802 00001355 F606[0100]01            	testopt [internalflags3], dif3_input_cmdline
  3803 0000135A 7515                    	jnz @F
  3804                                  %if _INPUT_FILE_HANDLES
  3805 0000135C E8(0000)                	call InDOS_or_BIOS_IO
  3806 0000135F 7507                    	jnz .notfile1
  3807 00001361 F606[0200]10            	testopt [internalflags2], dif2_input_file
  3808 00001366 7509                    	jnz @F
  3809                                  .notfile1:
  3810                                  %endif
  3811                                  %if _INPUT_FILE_BOOT
  3812 00001368 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  3813 0000136D 7502                    	jnz @F
  3814                                  %endif
  3815 0000136F EB47                    	jmp .clear_notatty
  3816                                  
  3817                                  @@:
  3818 00001371 F606[0100]02            	testopt [internalflags3], dif3_input_cmdline_closed
  3819 00001376 741A                    	jz @F
  3820 00001378 8026[0100]FD            	clropt [internalflags3], dif3_input_cmdline_closed
  3821                                  %if _INPUT_FILE_HANDLES
  3822 0000137D E8(0000)                	call InDOS_or_BIOS_IO
  3823 00001380 7507                    	jnz .notfile2
  3824 00001382 F606[0200]10            	testopt [internalflags2], dif2_input_file
  3825 00001387 7509                    	jnz @F
  3826                                  .notfile2:
  3827                                  %endif
  3828                                  %if _INPUT_FILE_BOOT
  3829 00001389 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  3830 0000138E 7502                    	jnz @F
  3831                                  %endif
  3832 00001390 EB26                    	jmp .clear_notatty
  3833                                  
  3834                                  @@:
  3835                                  %if _INPUT_FILE_BOOT
  3836 00001392 F606[0300]04            	testopt [internalflags2], dif2_closed_input_file_boot
  3837 00001397 7413                    	jz @F
  3838 00001399 8026[0300]FB            	clropt [internalflags2], dif2_closed_input_file_boot
  3839                                  %if _INPUT_FILE_HANDLES
  3840 0000139E E8(0000)                	call InDOS_or_BIOS_IO
  3841 000013A1 7507                    	jnz .notfile3
  3842 000013A3 F606[0200]10            	testopt [internalflags2], dif2_input_file
  3843 000013A8 7502                    	jnz @F
  3844                                  .notfile3:
  3845                                  %endif
  3846 000013AA EB0C                    	jmp .clear_notatty
  3847                                  @@:
  3848                                  %endif
  3849                                  %if _INPUT_FILE_HANDLES
  3850 000013AC F606[0200]20            	testopt [internalflags2], dif2_closed_input_file
  3851 000013B1 7411                    	jz @F
  3852 000013B3 8026[0200]DF            	clropt [internalflags2], dif2_closed_input_file
  3853                                  %else
  3854                                  	jmp @F
  3855                                  %endif
  3856                                  .clear_notatty:
  3857 000013B8 F606[0000]30            	testopt [internalflags], inputfile | notstdinput
  3858 000013BD 7505                    	jnz @F
  3859 000013BF C606[0000]00            	mov byte [notatty], 0	; it _is_ a tty
  3860                                  @@:
  3861 000013C4 C3                      	retn
  3862                                  
  3863                                  
  3864                                  		; Fill input buffer from file.
  3865                                  		;
  3866                                  		; INP:	di-> first available byte in input buffer
  3867                                  		; OUT:	CY if DOS returned an error or EOF occured
  3868                                  		;	NC if no error
  3869                                  		;	si = di
  3870                                  		; CHG:	-
  3871                                  fillbuf:
  3872 000013C5 E8(0000)                	call handle_serial_flags_ctrl_c
  3873 000013C8 50                      	push ax
  3874 000013C9 53                      	push bx
  3875 000013CA 51                      	push cx
  3876 000013CB 52                      	push dx
  3877 000013CC 89FE                    	mov si, di		; we know this already
  3878 000013CE B9[0101]                	mov cx, line_in+LINE_IN_LEN
  3879 000013D1 89FA                    	mov dx, di
  3880 000013D3 29F9                    	sub cx, di
  3881 000013D5 7703E99F00              	jbe .ret_cy		; if no more room -->
  3882                                  
  3883                                  %if !_LOADER
  3884 000013DA F606[0300]01            	testopt [internalflags3], dif3_input_re
  3885 000013DF 7429                    	jz .not_re
  3886 000013E1 56                      	push si
  3887 000013E2 57                      	push di
  3888 000013E3 89CB                    	mov bx, cx
  3889 000013E5 8B36[0000]              	mov si, word [re_buffer.position]
  3890 000013E9 89F7                    	mov di, si
  3891 000013EB B9FFFF                  	mov cx, -1
  3892 000013EE 31C0                    	xor ax, ax
  3893 000013F0 F2AE                    	repne scasb
  3894 000013F2 F7D1                    	not cx
  3895 000013F4 49                      	dec cx
  3896 000013F5 39CB                    	cmp bx, cx
  3897 000013F7 7702                    	ja @F
  3898 000013F9 89D9                    	mov cx, bx
  3899                                  @@:
  3900 000013FB 89C8                    	mov ax, cx
  3901 000013FD 89D7                    	mov di, dx
  3902 000013FF F3A4                    	rep movsb
  3903 00001401 8936[0000]              	mov word [re_buffer.position], si
  3904 00001405 5F                      	pop di
  3905 00001406 5E                      	pop si
  3906 00001407 F8                      	clc
  3907 00001408 EB61                    	jmp .after
  3908                                  
  3909                                  .not_re:
  3910                                  %endif
  3911                                  
  3912                                  %if _INPUT_FILE_BOOT
  3913 0000140A F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  3914 0000140F 7408                    	jz @F
  3915 00001411 E8(0000)                	call yy_boot_remember_seek
  3916 00001414 E8(0000)                	call yy_boot_read
  3917 00001417 EB52                    	jmp .after
  3918                                  @@:
  3919                                  %endif
  3920                                  
  3921                                  %if _INPUT_FILE_HANDLES
  3922 00001419 E8(0000)                	call InDOS_or_BIOS_IO
  3923 0000141C 750E                    	jnz @F
  3924 0000141E F606[0200]10            	testopt [internalflags2], dif2_input_file
  3925 00001423 7407                    	jz @F			; if not input file -->
  3926 00001425 57                      	push di
  3927 00001426 E85CF5                  	call yy_get_handle	; bx = handle
  3928 00001429 5F                      	pop di
  3929 0000142A EB37                    	jmp .file_handle
  3930                                  %endif
  3931                                  
  3932                                  @@:
  3933 0000142C F606[0100]01            	testopt [internalflags3], dif3_input_cmdline
  3934 00001431 7429                    	jz .not_cmdline
  3935 00001433 56                      	push si
  3936 00001434 57                      	push di
  3937 00001435 89CB                    	mov bx, cx
  3938 00001437 8B36[0000]              	mov si, word [cmdline_buffer.position]
  3939 0000143B 89F7                    	mov di, si
  3940 0000143D B9FFFF                  	mov cx, -1
  3941 00001440 31C0                    	xor ax, ax
  3942 00001442 F2AE                    	repne scasb
  3943 00001444 F7D1                    	not cx
  3944 00001446 49                      	dec cx
  3945 00001447 39CB                    	cmp bx, cx
  3946 00001449 7702                    	ja @F
  3947 0000144B 89D9                    	mov cx, bx
  3948                                  @@:
  3949 0000144D 89C8                    	mov ax, cx
  3950 0000144F 89D7                    	mov di, dx
  3951 00001451 F3A4                    	rep movsb
  3952 00001453 8936[0000]              	mov word [cmdline_buffer.position], si
  3953 00001457 5F                      	pop di
  3954 00001458 5E                      	pop si
  3955 00001459 F8                      	clc
  3956 0000145A EB0F                    	jmp .after
  3957                                  
  3958                                  .not_cmdline:
  3959                                  
  3960                                  @@:
  3961 0000145C 31DB                    	xor bx, bx		; bx = handle (0 is STDIN)
  3962 0000145E E8(0000)                	call InDOS_or_BIOS_IO
  3963 00001461 7516                    	jnz .ret_cy
  3964                                  
  3965                                  .file_handle:
  3966 00001463 B43F                    	mov ah, 3Fh		; read from file
  3967 00001465 E87D08                  	call yy_remember_seek
  3968                                  	doscall
  1491 00001468 E8(0000)            <1>  nearcall _doscall
  3969                                  .after:
  3970 0000146B 720C                    	jc .ret_cy		; if error -->
  3971 0000146D 85C0                    	test ax, ax
  3972 0000146F 7408                    	jz .ret_cy		; if EOF -->
  3973 00001471 01C2                    	add dx, ax		; -> behind last valid byte
  3974                                  
  3975 00001473 8026[0100]FB            	clropt [internalflags3], dif3_at_line_end
  3976                                  
  3977 00001478 A8                      	db __TEST_IMM8		; (NC)
  3978                                  .ret_cy:
  3979 00001479 F9                      	stc
  3980 0000147A 8916[0000]              	mov word [bufend], dx	; -> behind last valid byte
  3981 0000147E 5A                      	pop dx
  3982 0000147F 59                      	pop cx
  3983 00001480 5B                      	pop bx
  3984 00001481 58                      	pop ax
  3985 00001482 C3                      	retn
  3986                                  
  3987                                  
  3988                                  %if _EXTENSIONS || _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  3989                                  display_y_or_ext:
  3990 00001483 52                      	push dx
  3991                                   %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  3992 00001484 BA[0000]                	mov dx, msg.y
  3993                                    %if _EXTENSIONS
  3994 00001487 D006[0000]              	rol byte [yy_is_script], 1
  3995 0000148B 7203                    	jc @F
  3996                                    %endif
  3997                                   %endif
  3998                                   %if _EXTENSIONS
  3999 0000148D BA[0000]                	mov dx, msg.ext
  4000                                   %endif
  4001                                  @@:
  4002 00001490 E88CF2                  	call putsz_error
  4003 00001493 5A                      	pop dx
  4004 00001494 C3                      	retn
  4005                                  %endif
  4006                                  
  4007                                  
  4008                                  %if _EXTENSIONS
  4009                                  close_ext: section_of_function
  4010                                   %if _APPLICATION || _DEVICE
  4011 00001495 E8(0000)                	call InDOS
  4012 00001498 7511                    	jnz @F
  4013 0000149A BBFFFF                  	mov bx, -1
  4014 0000149D 871E[0000]              	xchg bx, word [ext_handle]
  4015 000014A1 83FBFF                  	cmp bx, -1
  4016 000014A4 7405                    	je @F
  4017 000014A6 B43E                    	mov ah, 3Eh
  4018                                  	doscall
  1491 000014A8 E8(0000)            <1>  nearcall _doscall
  4019                                  @@:
  4020                                   %endif
  4021 000014AB C3                      	retn
  4022                                  
  4023                                  load_extension:
  4024 000014AC E8C7EB                  	call skipcomma
  4025 000014AF C606[0000]00            	mov byte [yy_is_script], 0
  4026 000014B4 EB08                    	jmp @F
  4027                                  %endif
  4028                                  
  4029                                  %ifn _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  4030                                  yy equ error
  4031                                  %else
  4032                                  yy:
  4033 000014B6 C606[0000]FF            	mov byte [yy_is_script], 0FFh
  4034                                  %endif
  4035                                  %if _EXTENSIONS || _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  4036 000014BB E8(0000)                	call guard_re
  4037                                  @@:
  4038                                  yy_or_ext_no_guard_re:
  4039                                  %if _INPUT_FILE_BOOT || (_EXTENSIONS && _BOOTLDR)
  4040 000014BE F606[0100]40            	testopt [internalflags], nodosloaded
  4041 000014C3 7403E9(0000)            	jnz yy_boot
  4042                                  %endif
  4043                                  %ifn _INPUT_FILE_HANDLES || (_EXTENSIONS && (_APPLICATION || _DEVICE))
  4044                                  	jmp error
  4045                                  %else
  4046                                  %if _EXTENSIONS && (_APPLICATION || _DEVICE)
  4047 000014C8 D006[0000]              	rol byte [yy_is_script], 1
  4048 000014CC 721A                    	jc @F
  4049 000014CE E8(0000)                	call InDOS
  4050 000014D1 E82D01                  	call yy_dos_parse_name
  4051 000014D4 8D54FF                  	lea dx, [si - 1]
  4052 000014D7 8916[0000]              	mov word [ext_cmdline], dx
  4053 000014DB E899EB                  	call skipcomm0
  4054 000014DE 8936[0000]              	mov word [if_exists_then_address], si
  4055 000014E2 E82C02                  	call yy_open_file
  4056 000014E5 E9FE02                  	jmp ext_finish
  4057                                  
  4058                                  @@:
  4059                                  %endif
  4060                                  %ifn _INPUT_FILE_HANDLES
  4061                                  	jmp error
  4062                                  %else
  4063 000014E8 E8(0000)                	call InDOS_or_BIOS_IO
  4064 000014EB E81301                  	call yy_dos_parse_name
  4065                                  
  4066 000014EE F606[0200]10            	testopt [internalflags2], dif2_input_file
  4067 000014F3 7413                    	jz @F
  4068                                  ; IFH = 1
  4069                                  ; IFH - 1 = 0
  4070                                  ; cmp active, 0
  4071                                  ; active >= 0 --> error
  4072                                  
  4073                                  ; IFH = 2
  4074                                  ; IFH - 1 = 1
  4075                                  ; cmp active, 1
  4076                                  ; active >= 1 --> error
  4077 000014F5 833E[0000]0F            	cmp word [input_file_handles.active], _INPUT_FILE_HANDLES - 1
  4078 000014FA 720C                    	jb @F
  4079                                  
  4080 000014FC B80803                  	mov ax, 0308h
  4081 000014FF E8(0000)                	call setrc
  4082 00001502 BA[0000]                	mov dx, msg.yy_too_many_handles
  4083 00001505 E99B01                  	jmp yy_disp_error_1
  4084                                  @@:
  4085                                  
  4086 00001508 803F3A                  	cmp byte [bx], ':'
  4087 0000150B 7560                    	jne .not_yy_goto_subfunction
  4088                                  
  4089 0000150D F606[0200]10            	testopt [internalflags2], dif2_input_file
  4090 00001512 750C                    	jnz @F
  4091                                  
  4092 00001514 E8B4F8                  	call getline_is_input_file?
  4093 00001517 7248                    	jc .no_file
  4094 00001519 F606[0100]01            	testopt [internalflags3], dif3_input_cmdline
  4095 0000151E 7541                    	jnz .no_file
  4096                                  @@:
  4097                                  
  4098 00001520 8B3E[0000]              	mov di, word [terminator_in_line_in.offset]
  4099 00001524 A0[0000]                	mov al, byte [terminator_in_line_in.value]
  4100 00001527 8805                    	mov byte [di], al
  4101                                  
  4102 00001529 43                      	inc bx
  4103 0000152A 89DE                    	mov si, bx
  4104 0000152C E876EB                  	call skipwhite
  4105 0000152F 4E                      	dec si
  4106 00001530 89F5                    	mov bp, si
  4107                                  
  4108 00001532 E89806                  	call yy_reset_buf
  4109                                  
  4110 00001535 31DB                    	xor bx, bx		; bx = handle (0 is STDIN)
  4111                                  %if _INPUT_FILE_HANDLES
  4112 00001537 F606[0200]10            	testopt [internalflags2], dif2_input_file
  4113 0000153C 7405                    	jz @F			; if not input file -->
  4114 0000153E 57                      	push di
  4115 0000153F E843F4                  	call yy_get_handle	; bx = handle
  4116 00001542 5F                      	pop di
  4117                                  @@:
  4118                                  %endif
  4119 00001543 B445                    	mov ah, 45h
  4120                                  	doscall			; duplicate file handle
  1491 00001545 E8(0000)            <1>  nearcall _doscall
  4121 00001548 7303E90202              	jc yy_open_file.error
  4122 0000154D 93                      	xchg ax, bx
  4123                                  
  4124 0000154E 31C9                    	xor cx, cx
  4125 00001550 31D2                    	xor dx, dx
  4126 00001552 B80142                  	mov ax, 4201h		; lseek, from current file position
  4127                                  	doscall			; call DOS
  1491 00001555 E8(0000)            <1>  nearcall _doscall
  4128 00001558 91                      	xchg ax, cx		; dx:cx = current seek
  4129 00001559 87D1                    	xchg dx, cx		; cx:dx = current seek
  4130 0000155B BE0001                  	mov si, ifhfIsDup
  4131 0000155E 93                      	xchg ax, bx
  4132 0000155F EB4F                    	jmp yy_finish
  4133                                  
  4134                                  
  4135                                  .no_file:
  4136 00001561 B80903                  	mov ax, 0309h
  4137 00001564 E8(0000)                	call setrc
  4138 00001567 BA[0000]                	mov dx, msg.yy_no_file
  4139 0000156A E93601                  	jmp yy_disp_error_1
  4140                                  
  4141                                  .not_yy_goto_subfunction:
  4142 0000156D 31ED                    	xor bp, bp
  4143 0000156F E805EB                  	call skipcomm0
  4144 00001572 8936[0000]              	mov word [if_exists_then_address], si
  4145 00001576 E8E1EA                  	call iseol?_or_then
  4146 00001579 7429                    	je .not_yy_goto
  4147                                  
  4148 0000157B 3C3A                    	cmp al, ':'
  4149 0000157D 7403E9(0000)            	jne error
  4150                                  
  4151 00001582 E820EB                  	call skipwhite
  4152 00001585 4E                      	dec si
  4153 00001586 89F5                    	mov bp, si
  4154                                  
  4155                                  @@:
  4156 00001588 AC                      	lodsb
  4157 00001589 3C20                    	cmp al, 32
  4158 0000158B 740D                    	je @F
  4159 0000158D 3C09                    	cmp al, 9
  4160 0000158F 7409                    	je @F
  4161 00001591 3C2C                    	cmp al, ','
  4162 00001593 7405                    	je @F
  4163 00001595 E8D3EA                  	call iseol?
  4164 00001598 75EE                    	jne @B
  4165                                  @@:
  4166 0000159A E8DAEA                  	call skipcomm0
  4167 0000159D 8936[0000]              	mov word [if_exists_then_address], si
  4168 000015A1 E80CEB                  	call chkeol_or_then
  4169                                  
  4170                                  .not_yy_goto:
  4171 000015A4 E86A01                  	call yy_open_file
  4172                                  
  4173                                  		; ax = file handle
  4174 000015A7 E82306                  	call yy_reset_buf
  4175                                  
  4176 000015AA 31C9                    	xor cx, cx
  4177 000015AC 31D2                    	xor dx, dx
  4178 000015AE 31F6                    	xor si, si
  4179                                  yy_finish:
  4180 000015B0 F606[0200]10            	testopt [internalflags2], dif2_input_file
  4181 000015B5 7509                    	jnz @F
  4182 000015B7 800E[0200]10            	setopt [internalflags2], dif2_input_file
  4183 000015BC 31DB                    	xor bx, bx
  4184 000015BE EB18                    	jmp @FF
  4185                                  
  4186                                  @@:
  4187 000015C0 FF06[0000]              	inc word [input_file_handles.active]
  4188 000015C4 8B1E[0000]              	mov bx, word [input_file_handles.active]
  4189 000015C8 D1E3                    	shl bx, 1
  4190 000015CA D1E3                    	shl bx, 1
  4191 000015CC D1E3                    	shl bx, 1		; to qword array index
  4192                                   %if INPUTFILEHANDLE_size != 8
  4193                                    %error Unexpected structure size
  4194                                   %endif
  4195 000015CE 8BBF[FAFF]              	mov di, word [input_file_handles + bx - INPUTFILEHANDLE_size + ifhFlags]
  4196 000015D2 81E700F0                	and di, ifhfTestReserved1 | ifhfTestReserved2 		| ifhfQuietInput | ifhfQuietOutput
  4198 000015D6 09FE                    	or si, di
  4199                                  @@:
  4200                                  
  4201 000015D8 8987[0000]              	mov word [input_file_handles + bx + ifhHandle], ax
  4202 000015DC 89B7[0200]              	mov word [input_file_handles + bx + ifhFlags], si
  4203 000015E0 8997[0400]              	mov word [input_file_handles + bx + ifhParentSeek], dx
  4204 000015E4 898F[0600]              	mov word [input_file_handles + bx + ifhParentSeek + 2], cx
  4205                                  
  4206 000015E8 8026[0300]EF            	clropt [internalflags3], dif3_auxbuff_guarded_1
  4207 000015ED 89EE                    	mov si, bp
  4208 000015EF 85F6                    	test si, si
  4209 000015F1 7403E92D07              	jnz cmd_goto.yy_entry
  4210                                  
  4211                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  4212 000015F6 F606[0300]08            	testopt [internalflags3], dif3_in_if
  4213 000015FB 7403E9(0000)            	jnz if_exists_found_open
  4214                                  %endif
  4215 00001600 C3                      	retn
  4216                                  %endif
  4217                                  %endif
  4218                                  %endif
  4219                                  
  4220                                  
  4221                                  %if _INPUT_FILE_HANDLES || (_EXTENSIONS && (_APPLICATION || _DEVICE))
  4222                                  yy_dos_parse_name: section_of_function
  4223 00001601 740C                    	jz @F
  4224 00001603 B80503                  	mov ax, 0305h
  4225 00001606 E8(0000)                	call setrc
  4226 00001609 BA[0000]                	mov dx, msg.yy_no_dos
  4227 0000160C E99400                  	jmp yy_disp_error_1
  4228                                  
  4229                                  @@:
  4230                                  		; If input_file_handles.to_close is set,
  4231                                  		;  close all left over open files. (This
  4232                                  		;  may only be done when DOS is available.)
  4233 0000160F 31DB                    	xor bx, bx		; if none left open, -> first structure
  4234 00001611 F606[0200]10            	testopt [internalflags2], dif2_input_file
  4235 00001616 740B                    	jz @F
  4236 00001618 8B1E[0000]              	mov bx, word [input_file_handles.active]
  4237 0000161C 43                      	inc bx			; point to first unused structure
  4238 0000161D D1E3                    	shl bx, 1
  4239 0000161F D1E3                    	shl bx, 1
  4240 00001621 D1E3                    	shl bx, 1		; to qword array index
  4241                                   %if INPUTFILEHANDLE_size != 8
  4242                                    %error Unexpected structure size
  4243                                   %endif
  4244                                  @@:
  4245 00001623 89DF                    	mov di, bx		; + input_file_handles -> to close
  4246 00001625 31C0                    	xor ax, ax		; zero base amount to close
  4247 00001627 E83DF3                  	call yy_close_file_handles
  4248                                  				; CHG: ax, bx, di
  4249                                  				; if we remembered to close any, do it now
  4250                                  %if _EXTENSIONS
  4251 0000162A E868FE                  	call close_ext
  4252                                  %endif
  4253                                  %endif
  4254                                  
  4255                                  yy_common_parse_name: section_of_function
  4256 0000162D 8D5CFF                  	lea bx, [si - 1]	; -> start of name
  4257                                  
  4258                                  		; INP:	si - 1 -> text
  4259                                  		;	bx -> buffer to store to, 256 Bytes
  4260                                  		; OUT:	al = first text byte of trailer
  4261                                  		;	si - 1 -> trailer
  4262                                  		;	byte [si - 1] may be NUL written there
  4263                                  		;	 in case that INP:bx == INP:si - 1
  4264                                  		;	bx -> pathname, NUL-terminated
  4265                                  		;	di -> terminator NUL
  4266                                  		;	bx may point into a config path buffer
  4267                                  		; CHG:	ax, dx
  4268                                  yy_common_parse_name_bx_buffer: section_of_function
  4269 00001630 4E                      	dec si
  4270                                  %if _CONFIG || _EXECUTABLE
  4271 00001631 56                      	push si			; -> start of name
  4272 00001632 53                      	push bx			; -> start of buffer (may != si)
  4273                                   %if _EXECUTABLE
  4274 00001633 BB[0000]                	mov bx, init_executable_pathname
  4275 00001636 8B3E[0000]              	mov di, word [init_executable_pathname.end]
  4276 0000163A BA[0000]                	mov dx, msg.executablekeyword
  4277 0000163D E8C0E9                  	call isstring?
  4278 00001640 743D                    	je .execkw
  4279                                   %endif
  4280                                   %if _CONFIG
  4281 00001642 830E[0000]FF            	or word [yy_try_scriptspath], -1
  4282 00001647 BB[0000]                	mov bx, scriptspath
  4283 0000164A 8B3E[0000]              	mov di, word [scriptspath.dir_end]
  4284 0000164E BA[0000]                	mov dx, msg.scriptskeyword
  4285 00001651 E8ACE9                  	call isstring?
  4286 00001654 741B                    	je .kw
  4287 00001656 BB[0000]                	mov bx, configpath
  4288 00001659 8B3E[0000]              	mov di, word [configpath.dir_end]
  4289 0000165D BA[0000]                	mov dx, msg.configkeyword
  4290 00001660 E89DE9                  	call isstring?
  4291 00001663 740C                    	je .kw
  4292 00001665 5B                      	pop bx			; -> start of buffer
  4293 00001666 53                      	push bx
  4294 00001667 89DF                    	mov di, bx		; -> start of buffer
  4295 00001669 BA[0000]                	mov dx, msg.emptykeyword
  4296 0000166C E891E9                  	call isstring?
  4297 0000166F 751F                    	jne @F
  4298                                  .kw:
  4299 00001671 AC                      	lodsb
  4300 00001672 3C3A                    	cmp al, ':'
  4301 00001674 751A                    	jne @F
  4302 00001676 F616[0000]              	not byte [yy_try_scriptspath.nokeywordused]
  4303 0000167A 58                      	pop ax
  4304 0000167B 58                      	pop ax
  4305 0000167C AC                      	lodsb			; load character
  4306 0000167D EB33                    	jmp @FFF
  4307                                   %endif
  4308                                  
  4309                                   %if _EXECUTABLE
  4310                                  .execkw:
  4311 0000167F AC                      	lodsb
  4312 00001680 3C3A                    	cmp al, ':'
  4313 00001682 750C                    	jne @F
  4314 00001684 F616[0000]              	not byte [yy_try_scriptspath.nokeywordused]
  4315 00001688 58                      	pop ax
  4316 00001689 58                      	pop ax
  4317 0000168A AC                      	lodsb			; load character
  4318 0000168B 39FB                    	cmp bx, di		; empty ?
  4319 0000168D 7449                    	je .empty		; yes -->
  4320 0000168F C3                      	retn
  4321                                   %endif
  4322                                  @@:
  4323 00001690 5B                      	pop bx
  4324 00001691 5E                      	pop si
  4325                                  %endif
  4326 00001692 89DF                    	mov di, bx		; -> start of buffer
  4327                                  @@:
  4328 00001694 AC                      	lodsb			; load character
  4329 00001695 E8D3E9                  	call iseol?
  4330 00001698 7518                    	jne @F
  4331 0000169A BA[0000]                	mov dx, msg.yy_requires_filename
  4332 0000169D B80403                  	mov ax, 0304h
  4333 000016A0 E8(0000)                	call setrc
  4334                                  yy_disp_error_1: equ $
  4335 000016A3 B8FF03                  	mov ax, 03FFh
  4336 000016A6 E8(0000)                	call setrc
  4337 000016A9 E8D7FD                  	call display_y_or_ext
  4338 000016AC E870F0                  	call putsz_error
  4339 000016AF E9(0000)                	jmp cmd3
  4340                                  
  4341                                  @@:
  4342                                  .unquoted_loop:
  4343 000016B2 3C20                    	cmp al, 32		; blank or EOL outside quoted part ?
  4344 000016B4 7449                    	je .blank
  4345 000016B6 3C09                    	cmp al, 9
  4346 000016B8 7445                    	je .blank
  4347 000016BA E8AEE9                  	call iseol?		; (includes semicolon in lDebug)
  4348 000016BD 7440                    	je .blank		; yes -->
  4349 000016BF 3C2C                    	cmp al, ','
  4350 000016C1 743C                    	je .blank
  4351 000016C3 3C22                    	cmp al, '"'		; starting quote mark ?
  4352 000016C5 740E                    	je .quoted		; yes -->
  4353 000016C7 AA                      	stosb			; store character
  4354                                  .unquote:
  4355 000016C8 AC                      	lodsb			; load character
  4356 000016C9 EBE7                    	jmp .unquoted_loop	; continue in not-quoted loop -->
  4357                                  
  4358                                  .quoted_loop:
  4359 000016CB E8A1E9                  	call iseol?.notsemicolon; EOL inside quoted part ?
  4360 000016CE 7424                    	je .quoted_eol		; if yes, error -->
  4361 000016D0 3C22                    	cmp al, '"'		; ending quote mark ?
  4362 000016D2 74F4                    	je .unquote		; yes -->
  4363 000016D4 AA                      	stosb			; store character
  4364                                  .quoted:
  4365 000016D5 AC                      	lodsb			; load character
  4366 000016D6 EBF3                    	jmp .quoted_loop	; continue in quoted loop -->
  4367                                  
  4368                                  .empty:
  4369 000016D8 E89CE9                  	call skipcomm0
  4370 000016DB 8936[0000]              	mov word [if_exists_then_address], si
  4371 000016DF F606[0300]08            	testopt [internalflags3], dif3_in_if
  4372 000016E4 7403E9(0000)            	jnz if_exists_not_found
  4373 000016E9 B80603                  	mov ax, 0306h
  4374 000016EC E8(0000)                	call setrc
  4375 000016EF BA[0000]                	mov dx, msg.yy_filename_empty
  4376 000016F2 EBAF                    	jmp yy_disp_error_1
  4377                                  
  4378                                  .quoted_eol:
  4379 000016F4 B80703                  	mov ax, 0307h
  4380 000016F7 E8(0000)                	call setrc
  4381 000016FA BA[0000]                	mov dx, msg.yy_filename_missing_unquote
  4382 000016FD EBA4                    	jmp yy_disp_error_1
  4383                                  
  4384                                  .blank:
  4385 000016FF 39FB                    	cmp bx, di		; empty ?
  4386 00001701 74D5                    	je .empty		; yes -->
  4387                                  				; done
  4388 00001703 50                      	push ax
  4389 00001704 B000                    	mov al, 0
  4390 00001706 8605                    	xchg al, byte [di]	; terminate after filename
  4391 00001708 893E[0000]              	mov word [terminator_in_line_in.offset], di
  4392 0000170C A2[0000]                	mov byte [terminator_in_line_in.value], al
  4393 0000170F 58                      	pop ax
  4394 00001710 C3                      	retn
  4395                                  
  4396                                  
  4397                                  		; INP:	ds:bx -> filename
  4398                                  		; OUT:	File opened,
  4399                                  		;	 ax = file handle
  4400                                  		; STT:	ds = es = ss = debugger data selector/segment
  4401                                  yy_open_file: section_of_function
  4402 00001711 89DF                    	mov di, bx
  4403 00001713 E85400                  	call .setup_opencreate			; ds:si -> pathname
  4404 00001716 B86C71                  	mov ax, 716Ch				; LFN open-create
  4405 00001719 57                      	push di
  4406 0000171A 31FF                    	xor di, di				; alias hint
  4407 0000171C F9                      	stc
  4408                                  	doscall
  1491 0000171D E8(0000)            <1>  nearcall _doscall
  4409 00001720 5F                      	pop di
  4410 00001721 7351                    	jnc .got		; LFN call succeeded -->
  4411                                  
  4412                                  		; Early case for no-LFN-interface available.
  4413                                  	; cmp ax, 1
  4414                                  	; je .try_sfn
  4415 00001723 3D0071                  	cmp ax, 7100h
  4416 00001726 7405                    	je .try_sfn
  4417                                  
  4418 00001728 E84A00                  	call yy_check_lfn
  4419 0000172B 7322                    	jnc .error		; if LFN interface is available, actual error
  4420                                  				; if LFN interface is not available, try SFN
  4421                                  
  4422                                  .try_sfn:
  4423 0000172D E83A00                  	call .setup_opencreate
  4424 00001730 B8006C                  	mov ax, 6C00h				; Open-create
  4425 00001733 F9                      	stc
  4426                                  	doscall
  1491 00001734 E8(0000)            <1>  nearcall _doscall
  4427 00001737 733B                    	jnc .got
  4428                                  
  4429 00001739 83F801                  	cmp ax, 1
  4430 0000173C 7405                    	je .try_old_open
  4431 0000173E 3D006C                  	cmp ax, 6C00h
  4432 00001741 750C                    	jne .error
  4433                                  
  4434                                  .try_old_open:
  4435 00001743 88D8                    	mov al, bl				; access and sharing modes
  4436 00001745 B43D                    	mov ah, 3Dh				; Open
  4437 00001747 89F2                    	mov dx, si				; -> filename
  4438 00001749 F9                      	stc
  4439                                  	doscall
  1491 0000174A E8(0000)            <1>  nearcall _doscall
  4440 0000174D 7325                    	jnc .got
  4441                                  
  4442                                  .error:
  4443                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  4444                                   %if _CONFIG
  4445 0000174F E86F00                  	call retry_open_scriptspath
  4446 00001752 74BD                    	je yy_open_file
  4447                                   %endif
  4448 00001754 F606[0300]08            	testopt [internalflags3], dif3_in_if
  4449 00001759 7403E9(0000)            	jnz if_exists_not_found
  4450                                  %endif
  4451 0000175E B80A03                  	mov ax, 030Ah
  4452 00001761 E8(0000)                	call setrc
  4453 00001764 BA[0000]                	mov dx, msg.yy_error_file_open
  4454 00001767 E939FF                  	jmp yy_disp_error_1
  4455                                  
  4456                                  .setup_opencreate:
  4457 0000176A 89FE                    	mov si, di				; -> filename
  4458 0000176C BBA060                  	mov bx, 0110_0000_1010_0000b		; Auto-commit, no int 24h
  4459                                  						; No inherit
  4460                                  						; DENY WRITE, Read-only
  4461 0000176F 31C9                    	xor cx, cx				; create attribute
  4462 00001771 BA0100                  	mov dx, 0000_0000_0000_0001b		; no create / open, no truncate
  4463                                  .got:
  4464 00001774 C3                      	retn
  4465                                  
  4466                                  
  4467                                  		; INP:	ds:si -> pathname, possibly with drive letter
  4468                                  		; OUT:	NC if LFN services available
  4469                                  		;	CY if no LFN services available
  4470                                  yy_check_lfn: section_of_function
  4471                                  		; Only now, we check whether the used drive supports LFNs.
  4472                                  		; If it does, then we treat the error received as an
  4473                                  		; actual error and cancel here. If not, the SFN function
  4474                                  		; is called next as a fallback.
  4475                                  		;
  4476                                  		; We cannot rely on specific error returns like the
  4477                                  		; expected 7100h CY (or 7100h CF-unchanged) or the similar
  4478                                  		; 0001h CY (Invalid function) because no one agrees on what
  4479                                  		; error code to use.
  4480                                  		;
  4481                                  		; dosemu returns 0003h (Path not found) on FATFS and
  4482                                  		; redirected-non-dosemu drives. But may be changed so as to
  4483                                  		; return 0059h (Function not supported on network).
  4484                                  		; MSWindows 98SE returns 0002h (File not found) on
  4485                                  		; DOS-redirected drives.
  4486                                  		; DOSLFN with Fallback mode enabled supports the call (albeit
  4487                                  		; limited to SFNs).
  4488                                  		;
  4489                                  		; To suss out what the error means, check LFN availability.
  4490                                  		;
  4491                                  		; Refer to https://github.com/stsp/dosemu2/issues/770
  4492 00001775 1E                      	push ds
  4493 00001776 06                      	push es
  4494 00001777 57                      	push di
  4495 00001778 50                      	push ax
  4496                                  	lframe
  4497                                  	lvar 34, fstype_buffer
  4498                                  	lvar 4, pathname_buffer
  4499 00001779 5589E58D66DA            	lenter
  4500                                  
  4501 0000177F AD                      	lodsw			; load first two bytes of pathname
  4502                                  
  4503 00001780 16                      	push ss
  4504 00001781 1F                      	pop ds
  4505 00001782 89E2                    	mov dx, sp		; ds:dx -> ?pathname_buffer
  4506 00001784 16                      	push ss
  4507 00001785 07                      	pop es
  4508 00001786 89E7                    	mov di, sp		; es:di -> ?pathname_buffer
  4509                                  
  4510 00001788 80FC3A                  	cmp ah, ':'		; starts with drive specifier ?
  4511 0000178B 7409                    	je @F			; yes -->
  4512                                  
  4513 0000178D B419                    	mov ah, 19h
  4514                                  	doscall			; get current default drive
  1491 0000178F E8(0000)            <1>  nearcall _doscall
  4515 00001792 0441                    	add al, 'A'		; A: = 0, convert to drive letter
  4516 00001794 B43A                    	mov ah, ':'		; drive specifier
  4517                                  @@:
  4518 00001796 AB                      	stosw
  4519 00001797 B85C00                  	mov ax, '\'		; backslash and zero terminator
  4520 0000179A AB                      	stosw			; es:di -> ?fstype_buffer
  4521                                  
  4522 0000179B 31C0                    	xor ax, ax
  4523 0000179D B91100                  	mov cx, 34 >> 1
  4524 000017A0 57                      	push di
  4525 000017A1 F3AB                    	rep stosw		; initialise ?fstype_buffer to all zeros
  4526 000017A3 5F                      	pop di			; -> ?fstype_buffer
  4527                                  
  4528 000017A4 B92000                  	mov cx, 32		; size of ?fstype_buffer
  4529 000017A7 31DB                    	xor bx, bx		; harden, initialise this
  4530 000017A9 B8A071                  	mov ax, 71A0h		; get volume information
  4531 000017AC F9                      	stc
  4532                                  	doscall			; (depends on ds = es = ss)
  1491 000017AD E8(0000)            <1>  nearcall _doscall
  4533                                  
  4534 000017B0 7207                    	jc @F			; if call not supported -->
  4535                                  				; bx = FS flags
  4536 000017B2 F6C740                  	test bh, 0100_0000b	; LFN interface available ?
  4537 000017B5 F9                      	stc			; if no
  4538 000017B6 7401                    	jz @F			; no -->
  4539                                  
  4540 000017B8 F8                      	clc			; is available
  4541                                  @@:
  4542                                  
  4543 000017B9 89EC5D                  	lleave
  4544 000017BC 58                      	pop ax			; (restore error code)
  4545 000017BD 5F                      	pop di
  4546 000017BE 07                      	pop es
  4547 000017BF 1F                      	pop ds
  4548 000017C0 C3                      	retn
  4549                                  
  4550                                  
  4551                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT || _EXTENSIONS
  4552                                  %if _CONFIG
  4553                                  		; INP:	di -> filepath tried
  4554                                  		;	word [yy_try_scriptspath]
  4555                                  		; OUT:	ZR if to retry,
  4556                                  		;	 bx -> new filepath
  4557                                  		;	NZ if not
  4558                                  		; STT:	es = ds = ss
  4559                                  retry_open_scriptspath: section_of_function
  4560 000017C1 833E[0000]FF            	cmp word [yy_try_scriptspath], -1
  4561 000017C6 751D                    	jne @F					; --> NZ
  4562 000017C8 F616[0000]              	not byte [yy_try_scriptspath.didnotyettry]
  4563 000017CC 89FE                    	mov si, di
  4564 000017CE B9FF00                  	mov cx, 255
  4565 000017D1 B000                    	mov al, 0
  4566 000017D3 F2AE                    	repne scasb
  4567 000017D5 89F9                    	mov cx, di
  4568 000017D7 29F1                    	sub cx, si
  4569 000017D9 8B3E[0000]              	mov di, word [scriptspath.dir_end]
  4570 000017DD F3A4                    	rep movsb
  4571 000017DF AA                      	stosb
  4572 000017E0 BB[0000]                	mov bx, scriptspath
  4573 000017E3 38C0                    	cmp al, al				; ZR
  4574                                  @@:
  4575 000017E5 C3                      	retn
  4576                                  %elif _EXTENSIONS
  4577                                  retry_open_scriptspath: section_of_function
  4578                                  	test sp, sp				; NZ
  4579                                  	retn
  4580                                  %endif
  4581                                  %endif
  4582                                  
  4583                                  %if _EXTENSIONS
  4584                                  ext_finish:
  4585 000017E6 A3[0000]                	mov word [ext_handle], ax
  4586 000017E9 93                      	xchg bx, ax
  4587                                  .boot:
  4588 000017EA 8B3E[0000]              	mov di, word [terminator_in_line_in.offset]
  4589 000017EE A0[0000]                	mov al, byte [terminator_in_line_in.value]
  4590 000017F1 8805                    	mov byte [di], al
  4591                                  
  4592                                  %if _RECLAIM
  4593 000017F3 53                      	push bx
  4594                                   %if _PM
  4595 000017F4 E8C803                  	call get_es_ext
  4596                                   %else
  4597                                  	mov es, word [extseg]
  4598                                   %endif
  4599                                  
  4600                                   %define extcall nearcall
  4601                                   %define extcallcall nearcall
  4602                                   %imacro internalcoderelocation 0-*.nolist
  4603                                   %endmacro
  4604                                   %imacro internaldatarelocation 0-*.nolist
  4605                                   %endmacro
  4606                                   %imacro linkdatarelocation 0-*.nolist
  4607                                   %endmacro
  4608                                   %define relocated(address) address
  4609                                   %assign ELD 0
  4610                                   %include "reclaims.asm"
     1                              <1> 
     2                              <1> ; Public Domain
     3                              <1> 
     4                              <1> loop_free_data:
     5                              <1> .outer:
     6 000017F7 31F6                <1> 	xor si, si
     7                              <1> .inner:
     8 000017F9 8B1E[0000]          <1> 	mov bx, [relocated(extdata_used)]
     9                              <1> linkdatarelocation extdata_used
    10 000017FD 031E[0000]          <1> 	add bx, [relocated(extdata)]
    11                              <1> linkdatarelocation extdata
    12 00001801 3B36[0000]          <1> 	cmp si, [relocated(extseg_used)]
    13                              <1> linkdatarelocation extseg_used		; behind last instance ?
    14 00001805 735A                <1> 	jae .end			; yes -->
    15 00001807 263934              <1> 	cmp word [es:si + eldiStartCode], si
    16 0000180A 7403E96003          <1> 	jne .error			; start matches itself ?
    17 0000180F 26F6441001          <1> 	testopt [es:si + eldiFlags], eldifResident
    18 00001814 7539                <1> 	jnz .next			; is free ?
    19 00001816 268B5406            <1> 	mov dx, word [es:si + eldiEndData]
    20 0000181A 89D0                <1> 	mov ax, dx
    21 0000181C 262B4404            <1> 	sub ax, word [es:si + eldiStartData]
    22                              <1> 					; = length of block
    23 00001820 7303E94A03          <1> 	jc .error			; block must not be negative size -->
    24                              <1> 					; ZR if empty range
    25 00001825 7506                <1> 	jnz @F				; not empty -->
    26                              <1> 					; special zeroing handling
    27 00001827 85D2                <1> 	test dx, dx			; is it already zero ?
    28 00001829 7424                <1> 	jz .next			; yes -->
    29 0000182B EB09                <1> 	jmp @FF				; zero it and re-loop outer -->
    30                              <1> @@:
    31 0000182D 39DA                <1> 	cmp dx, bx			; end > last data ?
    32 0000182F 7603E93B03          <1> 	ja .error			; yes, error -->
    33 00001834 7519                <1> 	jne .next			; end == last data ?
    34                              <1> @@:					; yes, free it
    35 00001836 3B06[0000]          <1> 	cmp ax, word [relocated(extdata_used)]
    36                              <1> linkdatarelocation extdata_used
    37 0000183A 7603E93003          <1> 	ja .error
    38 0000183F 2906[0000]          <1> 	sub word [relocated(extdata_used)], ax
    39                              <1> linkdatarelocation extdata_used		; subtract size of block (or 0)
    40 00001843 31C0                <1> 	xor ax, ax
    41 00001845 26894404            <1> 	mov word [es:si + eldiStartData], ax
    42 00001849 26894406            <1> 	mov word [es:si + eldiEndData], ax
    43                              <1> 					; reset the block data
    44 0000184D EBA8                <1> 	jmp .outer			; restart search for trailing data
    45                              <1> 
    46                              <1> .next:
    47 0000184F 89F2                <1> 	mov dx, si
    48 00001851 83C220              <1> 	add dx, ELD_INSTANCE_size
    49 00001854 268B7402            <1> 	mov si, word [es:si + eldiEndCode]
    50 00001858 39D6                <1> 	cmp si, dx
    51 0000185A 7303E91003          <1> 	jb .error
    52 0000185F EB98                <1> 	jmp .inner
    53                              <1> 
    54                              <1> .end:
    55                              <1> 
    56                              <1> 
    57                              <1> loop_free_code:
    58                              <1> .outer:
    59 00001861 BAFFFF              <1> 	mov dx, -1			; remember no candidate
    60 00001864 31F6                <1> 	xor si, si			; -> start of ext seg
    61                              <1> .inner:
    62 00001866 3B36[0000]          <1> 	cmp si, [relocated(extseg_used)]
    63                              <1> linkdatarelocation extseg_used		; behind last instance ?
    64 0000186A 733D                <1> 	jae .end_inner			; yes -->
    65 0000186C 263934              <1> 	cmp word [es:si + eldiStartCode], si
    66 0000186F 7403E9FB02          <1> 	jne .error			; start matches itself ?
    67 00001874 26F6441001          <1> 	testopt [es:si + eldiFlags], eldifResident
    68 00001879 7519                <1> 	jnz .next_not_free		; is free ?
    69 0000187B 89F2                <1> 	mov dx, si			; -> candidate free block
    70 0000187D 26807C0400          <1> 	cmp byte [es:si + eldiStartData], 0
    71 00001882 750B                <1> 	jne .next_data_used		; is free ?
    72 00001884 26807C0600          <1> 	cmp byte [es:si + eldiEndData], 0
    73 00001889 7504                <1> 	jne .next_data_used		; is free ?
    74 0000188B 31C9                <1> 	xor cx, cx			; remember candidate has no data
    75 0000188D EB08                <1> 	jmp .next
    76                              <1> 
    77                              <1> .next_data_used:
    78 0000188F B90100              <1> 	mov cx, 1			; remember candidate has data
    79 00001892 EB03                <1> 	jmp .next
    80                              <1> 
    81                              <1> .next_not_free:
    82 00001894 BAFFFF              <1> 	mov dx, -1			; remember no candidate (used block)
    83                              <1> .next:
    84 00001897 89F0                <1> 	mov ax, si
    85 00001899 83C020              <1> 	add ax, ELD_INSTANCE_size
    86 0000189C 268B7402            <1> 	mov si, word [es:si + eldiEndCode]
    87 000018A0 39C6                <1> 	cmp si, ax
    88 000018A2 7303E9C802          <1> 	jb .error
    89 000018A7 EBBD                <1> 	jmp .inner
    90                              <1> 
    91                              <1> .end_inner:
    92 000018A9 83FAFF              <1> 	cmp dx, -1			; last ELD instance is free ?
    93 000018AC 742A                <1> 	je .end				; no -->
    94 000018AE 31DB                <1> 	xor bx, bx			; if to not keep ELD instance, = 0
    95 000018B0 E302                <1> 	jcxz .free			; no data ? then use bx = 0 -->
    96 000018B2 B320                <1> 	mov bl, 32			; need to keep ELD instance, = 32
    97                              <1> .free:
    98 000018B4 89D6                <1> 	mov si, dx			; -> instance to free/resize
    99 000018B6 268B4402            <1> 	mov ax, word [es:si + eldiEndCode]
   100 000018BA 3B06[0000]          <1> 	cmp ax, [relocated(extseg_used)] ; validity check
   101                              <1> linkdatarelocation extseg_used
   102 000018BE 7403E9AC02          <1> 	jne .error
   103 000018C3 268B14              <1> 	mov dx, word [es:si + eldiStartCode]
   104 000018C6 29D0                <1> 	sub ax, dx			; size of entire instance
   105 000018C8 01DA                <1> 	add dx, bx			; start of instance + how much to keep
   106 000018CA 26895402            <1> 	mov word [es:si + eldiEndCode], dx
   107                              <1> 					; enter into instance's end
   108 000018CE 29D8                <1> 	sub ax, bx			; size to discard
   109 000018D0 2906[0000]          <1> 	sub word [relocated(extseg_used)], ax ; do discard it
   110                              <1> linkdatarelocation extseg_used
   111 000018D4 85DB                <1> 	test bx, bx			; only resized ?
   112 000018D6 7489                <1> 	jz .outer			; no, go back try to free new last block
   113                              <1> 
   114                              <1> .end:
  4611                                  
  4612                                   %undef extcall
  4613                                   %undef extcallcall
  4614                                   %unimacro internalcoderelocation 0-*.nolist
  4615                                   %unimacro internaldatarelocation 0-*.nolist
  4616                                   %unimacro linkdatarelocation 0-*.nolist
  4617                                   %undef relocated
  4618                                  
  4619 000018D8 5B                      	pop bx
  4620 000018D9 16                      	 push ss
  4621 000018DA 07                      	 pop es
  4622                                  ext_finish_reclaimed:
  4623                                  
  4624                                  loop_free_data.error equ .error_internal
  4625                                  loop_free_code.error equ .error_internal
  4626                                  
  4627                                  %endif
  4628                                  
  4629                                  
  4630                                   %define extcall nearcall
  4631                                   %define extcallcall nearcall
  4632                                   %imacro internalcoderelocation 0-*.nolist
  4633                                   %endmacro
  4634                                   %imacro internaldatarelocation 0-*.nolist
  4635                                   %endmacro
  4636                                   %imacro linkdatarelocation 0-*.nolist
  4637                                   %endmacro
  4638                                   %define relocated(address) address
  4639                                   %assign ELD 0
  4640                                  
  4641                                  %include "loadeld.asm"
     1                              <1> 
     2                              <1> %if 0
     3                              <1> 
     4                              <1> lDebug load Extensions for lDebug
     5                              <1> 
     6                              <1> Copyright (C) 2008-2025 E. C. Masloch
     7                              <1> 
     8                              <1> Usage of the works is permitted provided that this
     9                              <1> instrument is retained with the works, so that any entity
    10                              <1> that uses the works is notified of this instrument.
    11                              <1> 
    12                              <1> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <1> 
    14                              <1> %endif
    15                              <1> 
    16                              <1> %if ELD
    17                              <1> %assign _ELDTRAILER 0
    18                              <1> 		numdef DOSORBOOTIO, 0
    19                              <1> 		numdef ELDCOMPRESSED, 0
    20                              <1> %else
    21                              <1> %assign _DOSORBOOTIO 0
    22                              <1> %assign _ELDCOMPRESSED 0
    23 000018DB 55                  <1> 	push bp
    24                              <1> %endif
    25                              <1> 
    26                              <1> %if _ELDTRAILER
    27 000018DC 31C0                <1> 	xor ax, ax
    28 000018DE A3[0000]            <1> 	mov word [eldheader], ax
    29                              <1> internaldatarelocation
    30 000018E1 A3[0200]            <1> 	mov word [eldheader + 2], ax
    31                              <1> internaldatarelocation
    32                              <1> 
    33 000018E4 91                  <1> 	xchg cx, ax
    34 000018E5 B80242              <1> 	mov ax, 4202h
    35 000018E8 31D2                <1> 	xor dx, dx
    36                              <1> %if _BOOTLDR
    37                              <1>  %if _APPLICATION || _DEVICE
    38 000018EA F606[0100]40        <1> 	testopt [relocated(internalflags)], nodosloaded
    39                              <1> linkdatarelocation internalflags, -3
    40 000018EF 7417                <1> 	jz @F
    41                              <1>  %endif
    42 000018F1 E8(0000)            <1> 	extcallcall yy_boot_seek_start.bx
    43 000018F4 8B0E[F6FF]          <1> 	mov cx, word [load_data - LOADDATA2 + ldFileSize + 2]
    44                              <1> internaldatarelocation
    45 000018F8 8B16[F4FF]          <1> 	mov dx, word [load_data - LOADDATA2 + ldFileSize]
    46                              <1> internaldatarelocation
    47 000018FC E8(0000)            <1> 	extcallcall yy_boot_seek_current.bx
    48 000018FF 8B16[FEFF]          <1> 	mov dx, word [load_data - LOADDATA2 + ldCurrentSeek + 2]
    49                              <1> internaldatarelocation
    50 00001903 A1[FCFF]            <1> 	mov ax, word [load_data - LOADDATA2 + ldCurrentSeek]
    51                              <1> internaldatarelocation
    52                              <1>  %if _APPLICATION || _DEVICE
    53 00001906 EB03                <1> 	jmp @FF
    54                              <1>  %endif
    55                              <1> %endif
    56                              <1> 
    57                              <1> @@:
    58                              <1> %if _APPLICATION || _DEVICE
    59                              <1> 	doscall
  1491 00001908 E8(0000)            <2>  nearcall _doscall
    60                              <1> %endif
    61                              <1> @@:
    62 0000190B 7303E96702          <1> 	jc .io_error
    63                              <1> 
    64 00001910 85D2                <1> 	test dx, dx
    65 00001912 7508                <1> 	jnz @F
    66 00001914 83F830              <1> 	cmp ax, ELD_HEADER_size + ELD_TRAILER_HEADER_size
    67 00001917 7303E98700          <1> 	jb .no_trailer
    68                              <1> @@:
    69                              <1> 
    70 0000191C B80142              <1> 	mov ax, 4201h
    71 0000191F B9FFFF              <1> 	mov cx, -1
    72 00001922 BAF0FF              <1> 	mov dx, - ELD_TRAILER_HEADER_size
    73                              <1> %if _BOOTLDR
    74                              <1>  %if _APPLICATION || _DEVICE
    75 00001925 F606[0100]40        <1> 	testopt [relocated(internalflags)], nodosloaded
    76                              <1> linkdatarelocation internalflags, -3
    77 0000192A 740C                <1> 	jz @F
    78                              <1>  %endif
    79 0000192C E8(0000)            <1> 	extcallcall yy_boot_seek_current.bx
    80 0000192F 8B16[FEFF]          <1> 	mov dx, word [load_data - LOADDATA2 + ldCurrentSeek + 2]
    81                              <1> internaldatarelocation
    82 00001933 A1[FCFF]            <1> 	mov ax, word [load_data - LOADDATA2 + ldCurrentSeek]
    83                              <1> internaldatarelocation
    84                              <1>  %if _APPLICATION || _DEVICE
    85 00001936 EB03                <1> 	jmp @FF
    86                              <1>  %endif
    87                              <1> %endif
    88                              <1> 
    89                              <1> @@:
    90                              <1> %if _APPLICATION || _DEVICE
    91                              <1> 	doscall
  1491 00001938 E8(0000)            <2>  nearcall _doscall
    92                              <1> %endif
    93                              <1> @@:
    94 0000193B 7303E93702          <1> 	jc .io_error
    95                              <1> 
    96 00001940 52                  <1> 	push dx
    97 00001941 50                  <1> 	push ax
    98                              <1> 
    99 00001942 B91000              <1> 	mov cx, fromwords(ELD_TRAILER_HEADER_size_w)
   100 00001945 29CC                <1> 	sub sp, cx
   101 00001947 89E2                <1> 	mov dx, sp
   102                              <1> 
   103 00001949 B43F                <1> 	mov ah, 3Fh
   104                              <1> %if _BOOTLDR
   105                              <1>  %if _APPLICATION || _DEVICE
   106 0000194B F606[0100]40        <1> 	testopt [relocated(internalflags)], nodosloaded
   107                              <1> linkdatarelocation internalflags, -3
   108 00001950 7405                <1> 	jz @F
   109                              <1>  %endif
   110 00001952 E8(0000)            <1> 	extcallcall yy_boot_read.bx
   111                              <1>  %if _APPLICATION || _DEVICE
   112 00001955 EB03                <1> 	jmp @FF
   113                              <1>  %endif
   114                              <1> %endif
   115                              <1> 
   116                              <1> @@:
   117                              <1> %if _APPLICATION || _DEVICE
   118                              <1> 	doscall
  1491 00001957 E8(0000)            <2>  nearcall _doscall
   119                              <1> %endif
   120                              <1> @@:
   121 0000195A 7303E91802          <1> 	jc .io_error
   122 0000195F 89E7                <1> 	mov di, sp
   123 00001961 89E6                <1> 	mov si, sp
   124                              <1> 
   125 00001963 39C8                <1> 	cmp ax, cx
   126 00001965 7539                <1> 	jne .no_trailer_pop
   127                              <1> 
   128 00001967 31D2                <1> 	xor dx, dx
   129 00001969 D1E9                <1> 	shr cx, 1
   130                              <1> @@:
   131 0000196B AD                  <1> 	lodsw
   132 0000196C 01C2                <1> 	add dx, ax
   133 0000196E E2FB                <1> 	loop @B
   134 00001970 752E                <1> 	jnz .no_trailer_pop
   135                              <1> 
   136 00001972 58                  <1> 	pop ax
   137 00001973 3D454C              <1> 	cmp ax, "EL"
   138 00001976 7528                <1> 	jne .no_trailer_pop
   139 00001978 58                  <1> 	pop ax
   140 00001979 3D4431              <1> 	cmp ax, "D1"
   141 0000197C 7522                <1> 	jne .no_trailer_pop
   142 0000197E 58                  <1> 	pop ax
   143 0000197F 3D5441              <1> 	cmp ax, "TA"
   144 00001982 751C                <1> 	jne .no_trailer_pop
   145 00001984 58                  <1> 	pop ax
   146 00001985 3D494C              <1> 	cmp ax, "IL"
   147 00001988 7516                <1> 	jne .no_trailer_pop
   148                              <1> 
   149 0000198A 5E                  <1> 	pop si
   150 0000198B 59                  <1> 	pop cx			; cx:si = displacement to subtract
   151 0000198C 58                  <1> 	pop ax			; reserved
   152 0000198D 58                  <1> 	pop ax			; checksum
   153                              <1> 
   154 0000198E 58                  <1> 	pop ax
   155 0000198F 5A                  <1> 	pop dx			; dx:ax = offset of trailer header
   156 00001990 01F0                <1> 	add ax, si
   157 00001992 11CA                <1> 	adc dx, cx		; dx:ax = offset of header
   158 00001994 7203E9DE01          <1> 	jnc .io_error
   159                              <1> 
   160 00001999 A3[0000]            <1> 	mov word [eldheader], ax
   161                              <1> internaldatarelocation
   162 0000199C 8916[0200]          <1> 	mov word [eldheader + 2], dx
   163                              <1> internaldatarelocation
   164                              <1> 
   165                              <1> .no_trailer_pop:
   166 000019A0 8D6514              <1> 	lea sp, [di + fromwords(ELD_TRAILER_HEADER_size_w) + 4]
   167                              <1> 
   168                              <1> .no_trailer:
   169 000019A3 B80042              <1> 	mov ax, 4200h
   170 000019A6 8B16[0000]          <1> 	mov dx, word [eldheader]
   171                              <1> internaldatarelocation
   172 000019AA 8B0E[0200]          <1> 	mov cx, word [eldheader + 2]
   173                              <1> internaldatarelocation
   174                              <1> 
   175                              <1> %if _BOOTLDR
   176                              <1>  %if _APPLICATION || _DEVICE
   177 000019AE F606[0100]40        <1> 	testopt [relocated(internalflags)], nodosloaded
   178                              <1> linkdatarelocation internalflags, -3
   179 000019B3 7408                <1> 	jz @F
   180                              <1>  %endif
   181 000019B5 E8(0000)            <1> 	extcallcall yy_boot_seek_start.bx
   182 000019B8 E8(0000)            <1> 	extcallcall yy_boot_seek_current.bx
   183                              <1>  %if _APPLICATION || _DEVICE
   184 000019BB EB03                <1> 	jmp @FF
   185                              <1>  %endif
   186                              <1> %endif
   187                              <1> 
   188                              <1> @@:
   189                              <1> %if _APPLICATION || _DEVICE
   190                              <1> 	doscall
  1491 000019BD E8(0000)            <2>  nearcall _doscall
   191                              <1> %endif
   192                              <1> @@:
   193 000019C0 7303E9B201          <1> 	jc .io_error
   194                              <1> %endif
   195                              <1> 
   196 000019C5 B92000              <1> 	mov cx, fromwords(ELD_HEADER_size_w)
   197 000019C8 29CC                <1> 	sub sp, cx
   198 000019CA 89E2                <1> 	mov dx, sp		; es:dx and ds:dx
   199                              <1> %if _ELDCOMPRESSED
   200                              <1> 	push word [eldheader + 2]
   201                              <1> internaldatarelocation
   202                              <1> 	push word [eldheader]
   203                              <1> internaldatarelocation
   204                              <1> 	pop word [depackskip]
   205                              <1> internaldatarelocation
   206                              <1> 	pop word [depackskip + 2]
   207                              <1> internaldatarelocation
   208                              <1> 
   209                              <1> 	call read_and_depack
   210                              <1> %elif _DOSORBOOTIO
   211                              <1> 	mov ax, 3F00h
   212                              <1> 	call dos_or_boot_io
   213                              <1> %else
   214 000019CC B43F                <1> 	mov ah, 3Fh
   215                              <1> %if _BOOTLDR
   216                              <1>  %if _APPLICATION || _DEVICE
   217 000019CE F606[0100]40        <1> 	testopt [relocated(internalflags)], nodosloaded
   218                              <1> linkdatarelocation internalflags, -3
   219 000019D3 7405                <1> 	jz @F
   220                              <1>  %endif
   221 000019D5 E8(0000)            <1> 	extcallcall yy_boot_read.bx
   222                              <1>  %if _APPLICATION || _DEVICE
   223 000019D8 EB03                <1> 	jmp @FF
   224                              <1>  %endif
   225                              <1> %endif
   226                              <1> 
   227                              <1> @@:
   228                              <1> %if _APPLICATION || _DEVICE
   229                              <1> 	doscall
  1491 000019DA E8(0000)            <2>  nearcall _doscall
   230                              <1> %endif
   231                              <1> @@:
   232                              <1> %endif
   233 000019DD 7303E99501          <1> 	jc .io_error
   234 000019E2 39C8                <1> 	cmp ax, cx
   235 000019E4 7403E99601          <1> 	jne .invalid
   236                              <1> 
   237 000019E9 89E7                <1> 	mov di, sp
   238                              <1> 
   239 000019EB 58                  <1> 	pop ax
   240 000019EC 3D454C              <1> 	cmp ax, "EL"
   241 000019EF 7403E98B01          <1> 	jne .invalid
   242 000019F4 58                  <1> 	pop ax
   243 000019F5 3D4431              <1> 	cmp ax, "D1"
   244 000019F8 7403E98201          <1> 	jne .invalid
   245 000019FD 58                  <1> 	pop ax
   246 000019FE 58                  <1> 	pop ax
   247 000019FF 80FC1A              <1> 	cmp ah, 26
   248 00001A02 7403E97801          <1> 	jne .invalid
   249                              <1> 
   250                              <1> %ifn ELD
   251 00001A07 F606[0300]08        <1> 	testopt [internalflags3], dif3_in_if
   252 00001A0C 7403E9(0000)        <1> 	jnz if_exists_found_ext_open
   253                              <1> %endif
   254                              <1> 
   255 00001A11 A1[0000]            <1> 	mov ax, word [relocated(extseg_size)]
   256                              <1> linkdatarelocation extseg_size
   257 00001A14 2B06[0000]          <1> 	sub ax, word [relocated(extseg_used)]
   258                              <1> linkdatarelocation extseg_used
   259 00001A18 7303E95201          <1> 	jc .error_internal
   260                              <1> %if ELD
   261                              <1> 	sub ax, fromparas(relocator_size_p)
   262                              <1> 	jc .error_internal
   263                              <1> %endif
   264                              <1> 
   265 00001A1D 8B4D0C              <1> 	mov cx, word [di + eldhCodeImageLength]
   266                              <1> %if ELD
   267                              <1> 	cmp ax, cx
   268                              <1> 	jb .oom
   269                              <1> %endif
   270 00001A20 034D0E              <1> 	add cx, word [di + eldhCodeAllocLength]
   271 00001A23 7227                <1> 	jc .invalid_CY
   272 00001A25 83C10F              <1> 	add cx, 15
   273 00001A28 7222                <1> 	jc .invalid_CY
   274 00001A2A 80E1F0              <1> 	and cl, ~ 15
   275                              <1> 
   276                              <1> %if ELD
   277                              <1> 	add ax, word [cs:code + eldiEndCode]
   278                              <1> internalcoderelocation
   279                              <1> 	sub ax, word [cs:code + eldiStartCode]
   280                              <1> internalcoderelocation
   281                              <1> %endif
   282 00001A2D 39C8                <1> 	cmp ax, cx
   283 00001A2F 7303E95D01          <1> 	jb .oom
   284                              <1> 
   285 00001A34 8B16[0000]          <1> 	mov dx, word [relocated(extdata_size)]
   286                              <1> linkdatarelocation extdata_size
   287 00001A38 2B16[0000]          <1> 	sub dx, word [relocated(extdata_used)]
   288                              <1> linkdatarelocation extdata_used
   289 00001A3C 7303E92E01          <1> 	jc .error_internal
   290                              <1> 
   291 00001A41 8B7514              <1> 	mov si, word [di + eldhDataImageLength]
   292                              <1> %if ELD
   293                              <1> 	cmp dx, si
   294                              <1> 	jb .oom
   295                              <1> %endif
   296 00001A44 037516              <1> 	add si, word [di + eldhDataAllocLength]
   297 00001A47 7203                <1> 	jc .invalid_CY
   298 00001A49 83C60F              <1> 	add si, 15
   299                              <1> .invalid_CY:
   300 00001A4C 7303E92E01          <1> 	jc .invalid
   301 00001A51 83E6F0              <1> 	and si, ~ 15
   302                              <1> 
   303                              <1> %if ELD
   304                              <1> 	add dx, word [cs:code + eldiEndData]
   305                              <1> internalcoderelocation
   306                              <1> 	sub dx, word [cs:code + eldiStartData]
   307                              <1> internalcoderelocation
   308                              <1> %endif
   309 00001A54 39F2                <1> 	cmp dx, si
   310 00001A56 7303E93601          <1> 	jb .oom
   311                              <1> 
   312 00001A5B 56                  <1> 	push si
   313 00001A5C 51                  <1> 	push cx
   314                              <1> 
   315 00001A5D B80042              <1> 	mov ax, 4200h
   316 00001A60 8B4D0A              <1> 	mov cx, word [di + eldhCodeOffset + 2]
   317 00001A63 8B5508              <1> 	mov dx, word [di + eldhCodeOffset]
   318                              <1> %if ELD || _ELDTRAILER
   319 00001A66 0316[0000]          <1> 	add dx, word [eldheader]
   320                              <1> internaldatarelocation
   321 00001A6A 130E[0200]          <1> 	adc cx, word [eldheader + 2]
   322                              <1> internaldatarelocation
   323                              <1> %else
   324                              <1> 		; ELD header is at seek 0
   325                              <1> %endif
   326                              <1> %if _ELDCOMPRESSED
   327                              <1> 	mov word [depackskip], dx
   328                              <1> internaldatarelocation
   329                              <1> 	mov word [depackskip + 2], cx
   330                              <1> internaldatarelocation
   331                              <1> %elif _DOSORBOOTIO
   332                              <1> 	call dos_or_boot_io
   333                              <1> %else
   334                              <1> %if _BOOTLDR
   335                              <1>  %if _APPLICATION || _DEVICE
   336 00001A6E F606[0100]40        <1> 	testopt [relocated(internalflags)], nodosloaded
   337                              <1> linkdatarelocation internalflags, -3
   338 00001A73 7408                <1> 	jz @F
   339                              <1>  %endif
   340 00001A75 E8(0000)            <1> 	extcallcall yy_boot_seek_start.bx
   341 00001A78 E8(0000)            <1> 	extcallcall yy_boot_seek_current.bx
   342                              <1>  %if _APPLICATION || _DEVICE
   343 00001A7B EB03                <1> 	jmp @FF
   344                              <1>  %endif
   345                              <1> %endif
   346                              <1> 
   347                              <1> @@:
   348                              <1> %if _APPLICATION || _DEVICE
   349                              <1> 	doscall
  1491 00001A7D E8(0000)            <2>  nearcall _doscall
   350                              <1> %endif
   351                              <1> @@:
   352                              <1> %endif
   353 00001A80 7303E9F200          <1> 	jc .io_error
   354                              <1> 
   355 00001A85 8B16[0000]          <1> 	mov dx, word [relocated(extseg_used)]
   356                              <1> linkdatarelocation extseg_used
   357                              <1> %if _PM
   358 00001A89 E8(0000)            <1> 	extcallcall ispm
   359 00001A8C 7506                <1> 	jnz @F
   360 00001A8E 8E1E[0000]          <1> 	mov ds, word [relocated(extdssel)]
   361                              <1> linkdatarelocation extdssel
   362 00001A92 EB04                <1> 	jmp @FF
   363                              <1> 
   364                              <1> @@:
   365                              <1> %endif
   366 00001A94 8E1E[0000]          <1> 	mov ds, word [relocated(extseg)]
   367                              <1> linkdatarelocation extseg
   368                              <1> @@:
   369 00001A98 368B4D0C            <1> 	mov cx, word [ss:di + eldhCodeImageLength]
   370                              <1> %if _ELDCOMPRESSED
   371                              <1> 	push ds
   372                              <1> 	pop es
   373                              <1> 	push ss
   374                              <1> 	pop ds
   375                              <1> 	call read_and_depack
   376                              <1> 	push ss
   377                              <1> 	pop es
   378                              <1> %elif _DOSORBOOTIO
   379                              <1> 	mov ax, 3FFFh
   380                              <1> 	call dos_or_boot_io
   381                              <1> %else
   382 00001A9C B43F                <1> 	mov ah, 3Fh
   383                              <1> %if _BOOTLDR
   384                              <1>  %if _APPLICATION || _DEVICE
   385 00001A9E 36F606[0100]40      <1> 	testopt [ss:relocated(internalflags)], nodosloaded
   386                              <1> linkdatarelocation internalflags, -3
   387 00001AA4 740B                <1> 	jz @F
   388                              <1>  %endif
   389 00001AA6 1E                  <1> 	push ds
   390 00001AA7 07                  <1> 	pop es
   391 00001AA8 16                  <1> 	push ss
   392 00001AA9 1F                  <1> 	pop ds
   393 00001AAA E8(0000)            <1> 	extcallcall yy_boot_read.bx
   394 00001AAD 16                  <1> 	push ss
   395 00001AAE 07                  <1> 	pop es
   396                              <1>  %if _APPLICATION || _DEVICE
   397 00001AAF EB03                <1> 	jmp @FF
   398                              <1>  %endif
   399                              <1> %endif
   400                              <1> 
   401                              <1> @@:
   402                              <1> %if _APPLICATION || _DEVICE
   403                              <1> %if _PM
   404 00001AB1 E8(0000)            <1> 	extcallcall doscall_extseg
   405                              <1> %else
   406                              <1> 	doscall
   407                              <1> %endif
   408                              <1> %endif
   409                              <1> @@:
   410                              <1> %endif
   411 00001AB4 16                  <1> 	 push ss
   412 00001AB5 1F                  <1> 	 pop ds
   413 00001AB6 7303E9BC00          <1> 	jc .io_error
   414 00001ABB 39C1                <1> 	cmp cx, ax
   415 00001ABD 7403E9B500          <1> 	jne .io_error
   416                              <1> 
   417 00001AC2 B80042              <1> 	mov ax, 4200h
   418 00001AC5 8B4D12              <1> 	mov cx, word [di + eldhDataOffset + 2]
   419 00001AC8 8B5510              <1> 	mov dx, word [di + eldhDataOffset]
   420                              <1> %if ELD || _ELDTRAILER
   421 00001ACB 0316[0000]          <1> 	add dx, word [eldheader]
   422                              <1> internaldatarelocation
   423 00001ACF 130E[0200]          <1> 	adc cx, word [eldheader + 2]
   424                              <1> internaldatarelocation
   425                              <1> %else
   426                              <1> 		; ELD header is at seek 0
   427                              <1> %endif
   428                              <1> 
   429                              <1> %if _ELDCOMPRESSED
   430                              <1> 	mov word [depackskip], dx
   431                              <1> internaldatarelocation
   432                              <1> 	mov word [depackskip + 2], cx
   433                              <1> internaldatarelocation
   434                              <1> %elif _DOSORBOOTIO
   435                              <1> 	call dos_or_boot_io
   436                              <1> %else
   437                              <1> %if _BOOTLDR
   438                              <1>  %if _APPLICATION || _DEVICE
   439 00001AD3 F606[0100]40        <1> 	testopt [relocated(internalflags)], nodosloaded
   440                              <1> linkdatarelocation internalflags, -3
   441 00001AD8 7408                <1> 	jz @F
   442                              <1>  %endif
   443 00001ADA E8(0000)            <1> 	extcallcall yy_boot_seek_start.bx
   444 00001ADD E8(0000)            <1> 	extcallcall yy_boot_seek_current.bx
   445                              <1>  %if _APPLICATION || _DEVICE
   446 00001AE0 EB03                <1> 	jmp @FF
   447                              <1>  %endif
   448                              <1> %endif
   449                              <1> 
   450                              <1> @@:
   451                              <1> %if _APPLICATION || _DEVICE
   452                              <1> 	doscall
  1491 00001AE2 E8(0000)            <2>  nearcall _doscall
   453                              <1> %endif
   454                              <1> @@:
   455                              <1> %endif
   456 00001AE5 7303E98D00          <1> 	jc .io_error
   457                              <1> 
   458                              <1> %if ELD
   459                              <1> 	mov dx, word [relocateddata]
   460                              <1> linkdatarelocation extdata
   461                              <1> %else
   462 00001AEA BA[0000]            <1> 	mov dx, ext_data_area
   463                              <1> %endif
   464 00001AED 0316[0000]          <1> 	add dx, word [relocated(extdata_used)]
   465                              <1> linkdatarelocation extdata_used
   466 00001AF1 8B4D14              <1> 	mov cx, word [di + eldhDataImageLength]
   467                              <1> %if _ELDCOMPRESSED
   468                              <1> 	call read_and_depack
   469                              <1> %elif _DOSORBOOTIO
   470                              <1> 	mov ax, 3F00h
   471                              <1> 	call dos_or_boot_io
   472                              <1> %else
   473 00001AF4 B43F                <1> 	mov ah, 3Fh
   474                              <1> %if _BOOTLDR
   475                              <1>  %if _APPLICATION || _DEVICE
   476 00001AF6 F606[0100]40        <1> 	testopt [relocated(internalflags)], nodosloaded
   477                              <1> linkdatarelocation internalflags, -3
   478 00001AFB 7405                <1> 	jz @F
   479                              <1>  %endif
   480 00001AFD E8(0000)            <1> 	extcallcall yy_boot_read.bx
   481                              <1>  %if _APPLICATION || _DEVICE
   482 00001B00 EB03                <1> 	jmp @FF
   483                              <1>  %endif
   484                              <1> %endif
   485                              <1> 
   486                              <1> @@:
   487                              <1> %if _APPLICATION || _DEVICE
   488                              <1> 	doscall
  1491 00001B02 E8(0000)            <2>  nearcall _doscall
   489                              <1> %endif
   490                              <1> @@:
   491                              <1> %endif
   492 00001B05 7270                <1> 	jc .io_error
   493 00001B07 39C1                <1> 	cmp cx, ax
   494 00001B09 756C                <1> 	jne .io_error
   495                              <1> 		; seek now -> behind data image.
   496                              <1> 		; this is expected by library ELDs to find their
   497                              <1> 		;  library images within the file, even if the
   498                              <1> 		;  library ELD was appended using eldapend.
   499                              <1> 
   500                              <1> %if _PM
   501 00001B0B E8B100              <1> 	call get_es_ext
   502                              <1> %else
   503                              <1> 	mov es, word [extseg]
   504                              <1> %endif
   505                              <1> 
   506                              <1> %if ELD
   507                              <1> 	mov bx, word [relocateddata]
   508                              <1> linkdatarelocation extseg_used		; es:bx -> where we loaded code
   509                              <1> 
   510                              <1> 	mov ax, [di + eldhCodeEntrypoint]
   511                              <1> 	add ax, strict word code	; -> entry destination
   512                              <1> internalcoderelocation
   513                              <1> 	mov word [es:relocator.entry], ax
   514                              <1> internalcoderelocation
   515                              <1> 
   516                              <1> 	mov ax, word [di + eldhCodeImageLength]
   517                              <1> 	mov word [es:relocator.codelength], ax
   518                              <1> internalcoderelocation
   519                              <1> 
   520                              <1> 	mov ax, word [di + eldhDataImageLength]
   521                              <1> 	mov word [es:relocator.datalength], ax
   522                              <1> internalcoderelocation
   523                              <1> 
   524                              <1> 	pop ax
   525                              <1> 
   526                              <1> 	mov word [es:bx + eldiStartCode], code
   527                              <1> internalcoderelocation			; fix its start
   528                              <1> 
   529                              <1> 	mov di, ax
   530                              <1> 	add di, word [relocateddata]
   531                              <1> linkdatarelocation extseg_used		; di -> relocator destination
   532                              <1> 	push ax
   533                              <1> 	add ax, fromparas(relocator_size_p)
   534                              <1> 	add word [es:code + eldiEndCode], ax
   535                              <1> internalcoderelocation			; grow our allocation
   536                              <1> 	add word [relocateddata], ax
   537                              <1> linkdatarelocation extseg_used		; ditto
   538                              <1> 	pop ax
   539                              <1> 
   540                              <1> 	mov word [es:relocator.codesource], bx
   541                              <1> internalcoderelocation			; -> start
   542                              <1> 	add ax, strict word code
   543                              <1> internalcoderelocation
   544                              <1> 	mov word [es:bx + eldiEndCode], ax
   545                              <1> 					; -> past destination
   546                              <1> 	mov word [es:relocator.extseg_used], ax
   547                              <1> internalcoderelocation			; new extseg_used
   548                              <1> 
   549                              <1> 	pop ax
   550                              <1> 
   551                              <1> 	mov dx, word [relocateddata]
   552                              <1> linkdatarelocation extdata_used
   553                              <1> 	add dx, word [relocateddata]
   554                              <1> linkdatarelocation extdata
   555                              <1> 
   556                              <1> 	mov word [es:relocator.datasource], dx
   557                              <1> internalcoderelocation
   558                              <1> 
   559                              <1> 	houdini
   560                              <1> 	mov dx, datastart
   561                              <1> internaldatarelocation
   562                              <1> 	mov word [es:bx + eldiStartData], dx
   563                              <1> 	add ax, dx
   564                              <1> 	mov word [es:bx + eldiEndData], ax
   565                              <1> 
   566                              <1> 	sub ax, word [relocateddata]
   567                              <1> linkdatarelocation extdata
   568                              <1> 	mov word [es:relocator.extdata_used], ax
   569                              <1> internalcoderelocation			; new extdata_used
   570                              <1> 
   571                              <1> 	mov dx, code
   572                              <1> internalcoderelocation			; es:dx -> ELD code instance (dest)
   573                              <1> 	mov bx, datastart
   574                              <1> internaldatarelocation
   575                              <1> 
   576                              <1> 	mov si, relocator
   577                              <1> internalcoderelocation
   578                              <1> 	mov cx, relocator_size_w
   579                              <1> 	 push es
   580                              <1> 	 pop ds
   581                              <1> 	push di
   582                              <1> 	rep movsw
   583                              <1> 	pop cx				; -> relocator entry
   584                              <1> 	push ss
   585                              <1> 	pop ds
   586                              <1> %else
   587 00001B0E 58                  <1> 	pop ax				; allocated code size
   588 00001B0F 8B16[0000]          <1> 	mov dx, word [extseg_used]
   589 00001B13 89D5                <1> 	mov bp, dx
   590 00001B15 26895600            <1> 	mov word [es:bp+eldiStartCode], dx
   591                              <1> 					; -> loaded code
   592 00001B19 0306[0000]          <1> 	add ax, word [extseg_used]
   593 00001B1D A3[0000]            <1> 	mov word [extseg_used], ax	; -> behind
   594 00001B20 26894602            <1> 	mov word [es:bp+eldiEndCode], ax; -> behind
   595                              <1> 
   596 00001B24 58                  <1> 	pop ax				; allocated data size
   597 00001B25 8B1E[0000]          <1> 	mov bx, word [extdata_used]
   598 00001B29 81C3[0000]          <1> 	add bx, ext_data_area		; -> loaded data
   599 00001B2D 26895E04            <1> 	mov word [es:bp+eldiStartData], bx
   600 00001B31 0106[0000]          <1> 	add word [extdata_used], ax	; = amount new used
   601 00001B35 01D8                <1> 	add ax, bx			; -> behind
   602 00001B37 26894606            <1> 	mov word [es:bp+eldiEndData], ax
   603                              <1> 
   604 00001B3B 8B4D18              <1> 	mov cx, [di + eldhCodeEntrypoint]
   605 00001B3E 01D1                <1> 	add cx, dx
   606                              <1> %endif
   607 00001B40 83C418              <1> 	add sp, ELD_HEADER_size - 8
   608                              <1> 
   609                              <1> %if ELD
   610                              <1> 	pop si
   611                              <1> 	mov ax, word [relocateddata]
   612                              <1> linkdatarelocation linksel
   613                              <1> 	extcallcall ispm
   614                              <1> 	jz @F
   615                              <1> 	mov ax, word [relocateddata]
   616                              <1> linkdatarelocation linkseg
   617                              <1> @@:
   618                              <1> 
   619                              <1> 	mov di, relocateddata
   620                              <1> linkdatarelocation linkinfoaddress
   621                              <1> 	mov di, [di]
   622                              <1> 	mov ds, ax
   623                              <1> 
   624                              <1> 	jmp cx
   625                              <1> 		; INP:	es:dx -> loaded initial ELD image
   626                              <1> 		;	 ELD instance structure filled
   627                              <1> 		;	es => ELD code area
   628                              <1> 		;	ds:di -> link info
   629                              <1> 		;	ss:bx -> loaded initial data
   630                              <1> 		;	ss:si -> command line tail
   631                              <1> 		;	cs:ip -> entrypoint
   632                              <1> 		;	ss:sp -> far return address for current mode
   633                              <1> 		; STT:	UP, EI
   634                              <1> 		; REM:	if loaded as an ELD by an uncompressed library ELD,
   635                              <1> 		;	 file seek -> behind data image just loaded
   636                              <1> 		;	file seek is not meaningful when loaded as an ELD
   637                              <1> 		;	 by a compressed library ELD
   638                              <1> %else
   639                              <1> ext_finish.bp_is_set equ $
   640 00001B43 5D                  <1> 	pop bp
   641                              <1> 
   642 00001B44 8B36[0000]          <1> 	mov si, word [ext_cmdline]
   643                              <1> 
   644                              <1> %if _MESSAGESEGMENT
   645                              <1>  %if _PM
   646 00001B48 E87EEB              <1> 	call get_messagesegsel
   647                              <1>  %else
   648                              <1>  	mov ds, word [ss:messageseg]
   649                              <1>  %endif
   650                              <1> %endif
   651 00001B4B BF[0000]            <1> 	mov di, linkinfo
   652                              <1> 
   653 00001B4E 0E                  <1> 	push cs
   654 00001B4F E85100              <1> 	call .transfer
   655                              <1> 		; INP:	es:dx -> loaded initial ELD image
   656                              <1> 		;	 ELD instance structure filled
   657                              <1> 		;	es => ELD code area
   658                              <1> 		;	ds:di -> link info
   659                              <1> 		;	ss:bx -> loaded initial data
   660                              <1> 		;	ss:si -> command line tail
   661                              <1> 		;	cs:ip -> entrypoint
   662                              <1> 		;	ss:sp -> far return address for current mode
   663                              <1> 		; STT:	UP, EI
   664                              <1> 		; REM:	file seek -> behind data image just loaded
   665                              <1> %endif
  4642                                  
  4643                                   %undef extcall
  4644                                   %undef extcallcall
  4645                                   %unimacro internalcoderelocation 0-*.nolist
  4646                                   %unimacro internaldatarelocation 0-*.nolist
  4647                                   %unimacro linkdatarelocation 0-*.nolist
  4648                                   %undef relocated
  4649                                  
  4650                                  
  4651 00001B52 3D00FF                  	cmp ax, 0FF00h
  4652 00001B55 7215                    	jb @F
  4653 00001B57 16                      	push ss
  4654 00001B58 07                      	pop es
  4655 00001B59 16                      	push ss
  4656 00001B5A 1F                      	pop ds
  4657 00001B5B BF[0000]                	mov di, msg.eld_error_code
  4658 00001B5E E80AE6                  	call hexword
  4659 00001B61 B40F                    	mov ah, 0Fh
  4660 00001B63 E8(0000)                	call setrc
  4661 00001B66 BA[0000]                	mov dx, msg.eld_load_error
  4662 00001B69 E8B3EB                  	call putsz_error
  4663                                  @@:
  4664 00001B6C E9(0000)                	jmp cmd3
  4665                                  
  4666                                  
  4667                                  .error_internal:
  4668 00001B6F BA[0000]                	mov dx, msg.ext_error_internal
  4669 00001B72 B82C01                  	mov ax, 012Ch
  4670 00001B75 EB20                    	jmp .specificerror
  4671                                  
  4672                                  .io_error:
  4673 00001B77 BA[0000]                	mov dx, msg.ext_error_io
  4674 00001B7A B82D01                  	mov ax, 012Dh
  4675 00001B7D EB06                    	jmp .specificerror_or_if
  4676                                  
  4677                                  .invalid:
  4678 00001B7F BA[0000]                	mov dx, msg.ext_error_invalid
  4679 00001B82 B82E01                  	mov ax, 012Eh
  4680                                  .specificerror_or_if:
  4681 00001B85 F606[0300]08            	testopt [internalflags3], dif3_in_if
  4682 00001B8A 7403E9(0000)            	jnz if_exists_not_found
  4683 00001B8F EB06                    	jmp .specificerror
  4684                                  
  4685                                  .oom:
  4686 00001B91 BA[0000]                	mov dx, msg.ext_error_oom
  4687 00001B94 B82F01                  	mov ax, 012Fh
  4688                                  
  4689                                  .specificerror:
  4690 00001B97 16                      	push ss
  4691 00001B98 1F                      	pop ds
  4692 00001B99 E8(0000)                	call setrc
  4693 00001B9C E880EB                  	call putsz_error
  4694 00001B9F FF26[0000]              	jmp [errret]
  4695                                  
  4696                                  
  4697                                  .transfer:
  4698                                  transfer_ext_cx_NC:
  4699 00001BA3 F8                      	clc
  4700                                  
  4701                                  transfer_ext_cx:
  4702                                  %if _PM
  4703 00001BA4 57                      	push di
  4704 00001BA5 368B3E[0000]            	mov di, word [ss:pm_2_86m_0]
  4705 00001BAA 36FFA5[3600]            	jmp near word [ss:.table + di]
  4706                                  
  4707                                  .pm:
  4708 00001BAF 5F                      	pop di
  4709 00001BB0 36FF36[0000]            	push word [ss:extcssel]		; => code
  4710 00001BB5 51                      	push cx				; -> entrypoint
  4711 00001BB6 CB                      	retf
  4712                                  
  4713                                  .86m:
  4714 00001BB7 5F                      	pop di
  4715                                  %endif
  4716 00001BB8 36FF36[0000]            	push word [ss:extseg]		; => code
  4717 00001BBD 51                      	push cx				; -> entrypoint
  4718 00001BBE CB                      	retf
  4719                                  
  4720                                  %if _PM
  4721                                  	usesection lDEBUG_DATA_ENTRY
  4721          ------------------       note: usesection lDEBUG_DATA_ENTRY
  4722                                  		; REM:	Dispatch table in section lDEBUG_CODE
  4723                                  	align 2, db 0
  4724                                  .table:
  4725 00000036 [B71B]                  	dw .86m
  4726 00000038 [AF1B]                  	dw .pm
  4727                                  
  4728                                  
  4729                                  	usesection lDEBUG_CODE
  4729          ------------------       note: usesection lDEBUG_CODE
  4730                                  get_es_ext:
  4731 00001BBF 8E06[0000]              	mov es, word [extdssel]
  4732 00001BC3 E8(0000)                	call ispm
  4733 00001BC6 7404                    	jz .ret
  4734 00001BC8 8E06[0000]              	mov es, word [extseg]
  4735                                  .ret:
  4736 00001BCC C3                      	retn
  4737                                  %endif
  4738                                  %endif
  4739                                  
  4740                                  		; INP:	word [bufnext], word [bufend]
  4741                                  		; CHG:	-
  4742                                  		;
  4743                                  		; Note:	When reading from a file, we buffer some of the input
  4744                                  		;	 in line_in. When switching to a non-file, or starting
  4745                                  		;	 to read from another file, we have to reset the seek
  4746                                  		;	 position of the (prior) file to avoid losing the data.
  4747                                  		;	This cropped up during yy development, but actually
  4748                                  		;	 affects serial and InDOS input, too. Therefore,
  4749                                  		;	 this function is not below the conditional for yy.
  4750                                  yy_reset_buf: section_of_function
  4751 00001BCD 51                      	push cx
  4752                                  %if _NEWFULLHANDLING
  4753 00001BCE B9[0300]                	mov cx, line_in + 3
  4754                                  %else
  4755                                  	mov cx, line_in + 2
  4756                                  %endif
  4757 00001BD1 870E[0000]              	xchg cx, word [bufnext]
  4758 00001BD5 F7D9                    	neg cx
  4759 00001BD7 030E[0000]              	add cx, word [bufend]	; cx = how much remaining in buffer
  4760                                  %if _NEWFULLHANDLING
  4761 00001BDB C706[0000][0300]        	mov word [bufend], line_in + 3
  4762                                  %else
  4763                                  	mov word [bufend], line_in + 2
  4764                                  %endif
  4765                                  
  4766 00001BE1 F606[0200]40            	testopt [internalflags2], dif2_did_getline_file
  4767 00001BE6 7469                    	jz .not_used
  4768                                  
  4769 00001BE8 50                      	push ax
  4770 00001BE9 52                      	push dx
  4771 00001BEA 53                      	push bx
  4772 00001BEB 89CA                    	mov dx, cx
  4773 00001BED 31C9                    	xor cx, cx
  4774 00001BEF F7DA                    	neg dx			; dx = minus how much remaining
  4775 00001BF1 7456                    	jz .done		; if zero, do not seek at all -->
  4776 00001BF3 49                      	dec cx			; sign extension into cx:dx
  4777                                  
  4778                                  %if !_LOADER
  4779 00001BF4 F606[0300]01            	testopt [internalflags3], dif3_input_re
  4780 00001BF9 7406                    	jz @F
  4781 00001BFB 0116[0000]              	add word [re_buffer.position], dx
  4782 00001BFF EB48                    	jmp .done
  4783                                  @@:
  4784                                  %endif
  4785                                  
  4786                                  %if _INPUT_FILE_BOOT
  4787 00001C01 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  4788 00001C06 741E                    	jz @F
  4789 00001C08 F606[0300]30            	testopt [internalflags3], dif3_auxbuff_guarded_1 | dif3_auxbuff_guarded_2
  4790 00001C0D 7412                    	jz .do_boot_seek
  4791                                  
  4792 00001C0F FF36[0000]              	push word [load_input_file.active]
  4793 00001C13 8F06[0000]              	pop word [boot_remember_seek_handle]
  4794 00001C17 890E[0200]              	mov word [boot_remember_seek_offset + 2], cx
  4795 00001C1B 8916[0000]              	mov word [boot_remember_seek_offset], dx
  4796 00001C1F EB28                    	jmp .done
  4797                                  
  4798                                  .do_boot_seek:
  4799 00001C21 E8(0000)                	call yy_boot_seek_current
  4800 00001C24 EB23                    	jmp .done
  4801                                  @@:
  4802                                  %endif
  4803                                  
  4804                                  %if _INPUT_FILE_HANDLES
  4805 00001C26 F606[0200]10            	testopt [internalflags2], dif2_input_file
  4806 00001C2B 7407                    	jz @F			; if not input file -->
  4807 00001C2D 57                      	push di
  4808 00001C2E E854ED                  	call yy_get_handle	; bx = handle
  4809 00001C31 5F                      	pop di
  4810 00001C32 EB0F                    	jmp .filehandle
  4811                                  @@:
  4812                                  %endif
  4813                                  
  4814 00001C34 F606[0100]01            	testopt [internalflags3], dif3_input_cmdline
  4815 00001C39 7406                    	jz @F
  4816 00001C3B 0116[0000]              	add word [cmdline_buffer.position], dx
  4817 00001C3F EB08                    	jmp .done
  4818                                  @@:
  4819                                  
  4820 00001C41 31DB                    	xor bx, bx		; bx = handle (0 is STDIN)
  4821                                  .filehandle:
  4822 00001C43 B80142                  	mov ax, 4201h		; lseek, from current file position
  4823 00001C46 E80A00                  	call handle_seek_or_remember
  4824                                  
  4825                                  .done:
  4826 00001C49 5B                      	pop bx
  4827 00001C4A 5A                      	pop dx
  4828 00001C4B 58                      	pop ax
  4829                                  
  4830 00001C4C 8026[0200]BF            	clropt [internalflags2], dif2_did_getline_file
  4831                                  
  4832                                  .not_used:
  4833 00001C51 59                      	pop cx
  4834 00001C52 C3                      	retn
  4835                                  
  4836                                  
  4837                                  handle_seek_or_remember:
  4838 00001C53 E8(0000)                	call InDOS
  4839 00001C56 7411                    	jz @F
  4840                                  
  4841 00001C58 A3[0000]                	mov word [indos_remember_seek_function], ax
  4842 00001C5B 891E[0000]              	mov word [indos_remember_seek_handle], bx
  4843 00001C5F 890E[0200]              	mov word [indos_remember_seek_offset + 2], cx
  4844 00001C63 8916[0000]              	mov word [indos_remember_seek_offset], dx
  4845 00001C67 EB03                    	jmp .done
  4846                                  
  4847                                  @@:
  4848                                  	doscall			; call DOS
  1491 00001C69 E8(0000)            <1>  nearcall _doscall
  4849                                  .done:
  4850 00001C6C C3                      	retn
  4851                                  
  4852                                  
  4853                                  yy_reset_buf_and_seek_start:
  4854 00001C6D 51                      	push cx
  4855 00001C6E 50                      	push ax
  4856 00001C6F 52                      	push dx
  4857 00001C70 53                      	push bx
  4858                                  %if _NEWFULLHANDLING
  4859 00001C71 B8[0300]                	mov ax, line_in + 3
  4860                                  %else
  4861                                  	mov ax, line_in + 2
  4862                                  %endif
  4863 00001C74 A3[0000]                	mov word [bufnext], ax
  4864 00001C77 A3[0000]                	mov word [bufend], ax
  4865                                  
  4866 00001C7A 31D2                    	xor dx, dx
  4867 00001C7C 31C9                    	xor cx, cx
  4868                                  
  4869                                  %if !_LOADER
  4870 00001C7E F606[0300]01            	testopt [internalflags3], dif3_input_re
  4871 00001C83 7408                    	jz @F
  4872 00001C85 C706[0000][0000]        	mov word [re_buffer.position], re_buffer
  4873 00001C8B EB37                    	jmp .done
  4874                                  @@:
  4875                                  %endif
  4876                                  
  4877                                  %if _INPUT_FILE_BOOT
  4878 00001C8D F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  4879 00001C92 7408                    	jz @F
  4880 00001C94 E8(0000)                	call yy_boot_clear_remember_seek
  4881 00001C97 E8(0000)                	call yy_boot_seek_start
  4882 00001C9A EB28                    	jmp .done
  4883                                  @@:
  4884                                  %endif
  4885                                  
  4886                                  %if _INPUT_FILE_HANDLES
  4887 00001C9C F606[0200]10            	testopt [internalflags2], dif2_input_file
  4888 00001CA1 7407                    	jz @F			; if not input file -->
  4889 00001CA3 57                      	push di
  4890 00001CA4 E8DEEC                  	call yy_get_handle	; bx = handle
  4891 00001CA7 5F                      	pop di
  4892 00001CA8 EB11                    	jmp .filehandle
  4893                                  @@:
  4894                                  %endif
  4895                                  
  4896 00001CAA F606[0100]01            	testopt [internalflags3], dif3_input_cmdline
  4897 00001CAF 7408                    	jz @F
  4898 00001CB1 C706[0000][0000]        	mov word [cmdline_buffer.position], cmdline_buffer
  4899 00001CB7 EB0B                    	jmp .done
  4900                                  @@:
  4901                                  
  4902 00001CB9 31DB                    	xor bx, bx		; bx = handle (0 is STDIN)
  4903                                  
  4904                                  .filehandle:
  4905 00001CBB E80B00                  	call yy_clear_remember_seek
  4906 00001CBE B80042                  	mov ax, 4200h		; seek from start
  4907 00001CC1 E88FFF                  	call handle_seek_or_remember
  4908                                  .done:
  4909 00001CC4 5B                      	pop bx
  4910 00001CC5 5A                      	pop dx
  4911 00001CC6 58                      	pop ax
  4912 00001CC7 59                      	pop cx
  4913 00001CC8 C3                      	retn
  4914                                  
  4915                                  
  4916                                  yy_clear_remember_seek:
  4917 00001CC9 391E[0000]              	cmp word [indos_remember_seek_handle], bx
  4918 00001CCD 7515                    	jne .ret
  4919                                  .clear:
  4920 00001CCF C706[0000]0142          	mov word [indos_remember_seek_function], 4201h
  4921 00001CD5 830E[0000]FF            	or word [indos_remember_seek_handle], -1
  4922 00001CDA 8326[0200]00            	and word [indos_remember_seek_offset + 2], 0
  4923 00001CDF 8326[0000]00            	and word [indos_remember_seek_offset], 0
  4924                                  .ret:
  4925 00001CE4 C3                      	retn
  4926                                  
  4927                                  
  4928                                  yy_remember_seek:
  4929 00001CE5 391E[0000]              	cmp word [indos_remember_seek_handle], bx
  4930 00001CE9 75F9                    	jne yy_clear_remember_seek.ret
  4931                                  
  4932 00001CEB 50                      	push ax
  4933 00001CEC 51                      	push cx
  4934 00001CED 52                      	push dx
  4935 00001CEE 8B0E[0200]              	mov cx, word [indos_remember_seek_offset + 2]
  4936 00001CF2 8B16[0000]              	mov dx, word [indos_remember_seek_offset]
  4937 00001CF6 A1[0000]                	mov ax, word [indos_remember_seek_function]
  4938                                  	doscall			; call DOS
  1491 00001CF9 E8(0000)            <1>  nearcall _doscall
  4939 00001CFC 5A                      	pop dx
  4940 00001CFD 59                      	pop cx
  4941 00001CFE 58                      	pop ax
  4942 00001CFF EBCE                    	jmp yy_clear_remember_seek.clear
  4943                                  
  4944                                  
  4945                                  cmd_goto:
  4946 00001D01 E8A1E3                  	call skipwhite
  4947 00001D04 3C3A                    	cmp al, ':'
  4948 00001D06 7503                    	jne @F
  4949 00001D08 E89AE3                  	call skipwhite
  4950                                  @@:
  4951                                  
  4952 00001D0B E8BDF0                  	call getline_is_input_file?
  4953 00001D0E 7312                    	jnc @F
  4954 00001D10 BA[0000]                	mov dx, msg.goto_not_file
  4955 00001D13 B80003                  	mov ax, 0300h
  4956 00001D16 E8(0000)                	call setrc
  4957                                  .error:
  4958 00001D19 B8FF03                  	mov ax, 03FFh
  4959 00001D1C E8(0000)                	call setrc
  4960 00001D1F E9FDE9                  	jmp putsz_error
  4961                                  
  4962                                  @@:
  4963 00001D22 4E                      	dec si
  4964                                  .yy_entry:		; si -> destination label
  4965 00001D23 BA[0000]                	mov dx, msg.sof
  4966 00001D26 E8D7E2                  	call isstring?
  4967 00001D29 751B                    	jne @F
  4968 00001D2B E848E3                  	call skipcomma
  4969                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  4970 00001D2E 8936[0000]              	mov word [if_exists_then_address], si
  4971                                  %endif
  4972 00001D32 E87BE3                  	call chkeol_or_then
  4973 00001D35 E8D700                  	call resetrc
  4974 00001D38 E832FF                  	call yy_reset_buf_and_seek_start
  4975                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  4976 00001D3B F606[0300]08            	testopt [internalflags3], dif3_in_if
  4977 00001D40 7403E9(0000)            	jnz if_exists_found_open
  4978                                  %endif
  4979 00001D45 C3                      	retn
  4980                                  
  4981                                  @@:
  4982 00001D46 BA[0000]                	mov dx, msg.eof
  4983 00001D49 E8B4E2                  	call isstring?
  4984 00001D4C 751B                    	jne @F
  4985 00001D4E E825E3                  	call skipcomma
  4986                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  4987 00001D51 8936[0000]              	mov word [if_exists_then_address], si
  4988                                  %endif
  4989 00001D55 E858E3                  	call chkeol_or_then
  4990 00001D58 E8B400                  	call resetrc
  4991 00001D5B E8A6F0                  	call getline_close_file
  4992                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  4993 00001D5E F606[0300]08            	testopt [internalflags3], dif3_in_if
  4994 00001D63 7403E9(0000)            	jnz if_exists_found_closed
  4995                                  %endif
  4996 00001D68 C3                      	retn
  4997                                  
  4998                                  @@:
  4999 00001D69 89F3                    	mov bx, si
  5000 00001D6B B9FFFF                  	mov cx, -1
  5001                                  .loop:
  5002 00001D6E 41                      	inc cx
  5003 00001D6F AC                      	lodsb
  5004 00001D70 3C20                    	cmp al, 32
  5005 00001D72 7409                    	je .end
  5006 00001D74 3C09                    	cmp al, 9
  5007 00001D76 7405                    	je .end
  5008 00001D78 E8F0E2                  	call iseol?
  5009 00001D7B 75F1                    	jne .loop
  5010                                  .end:
  5011 00001D7D C644FF00                	mov byte [si - 1], 0	; terminate
  5012 00001D81 E8F3E2                  	call skipcomm0
  5013                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  5014 00001D84 8936[0000]              	mov word [if_exists_then_address], si
  5015                                  %endif
  5016 00001D88 E825E3                  	call chkeol_or_then
  5017 00001D8B E376                    	jcxz .empty
  5018 00001D8D 41                      	inc cx			; space for zero terminator
  5019 00001D8E 41                      	inc cx			; round up
  5020 00001D8F 80E1FE                  	and cl, ~1		; align to word
  5021 00001D92 89E5                    	mov bp, sp
  5022 00001D94 29CC                    	sub sp, cx		; allocate stack space
  5023 00001D96 89DE                    	mov si, bx		; -> label in line_in
  5024 00001D98 89E7                    	mov di, sp		; -> buffer on stack
  5025 00001D9A 57                      	push di
  5026                                  @@:
  5027 00001D9B AC                      	lodsb
  5028 00001D9C E8B0E2                  	call capitalise		; normalise the name in buffer
  5029 00001D9F AA                      	stosb
  5030 00001DA0 E2F9                    	loop @B			; copy all or all+1
  5031                                  
  5032 00001DA2 E8C8FE                  	call yy_reset_buf_and_seek_start
  5033                                  
  5034                                  .next_line:
  5035 00001DA5 800E[0100]88            	setopt [internalflags3], dif3_quiet_input_single | dif3_return_eof
  5036 00001DAA 31C9                    	xor cx, cx
  5037 00001DAC E871ED                  	call getline.use_dif3_flags
  5038 00001DAF 7228                    	jc .notfound
  5039 00001DB1 89F3                    	mov bx, si
  5040 00001DB3 3C3A                    	cmp al, ':'
  5041 00001DB5 75EE                    	jne .next_line
  5042 00001DB7 E8EBE2                  	call skipwhite
  5043 00001DBA 5A                      	pop dx
  5044 00001DBB 52                      	push dx
  5045 00001DBC 4E                      	dec si
  5046 00001DBD E840E2                  	call isstring?
  5047 00001DC0 75E3                    	jne .next_line
  5048 00001DC2 8D77FF                  	lea si, [bx - 1]
  5049 00001DC5 AC                      	lodsb
  5050 00001DC6 89EC                    	mov sp, bp
  5051 00001DC8 E84400                  	call resetrc
  5052                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  5053 00001DCB F606[0300]08            	testopt [internalflags3], dif3_in_if
  5054 00001DD0 7403E9(0000)            	jnz if_exists_found_open
  5055                                  %endif
  5056 00001DD5 5A                      	pop dx			; return address to cmd3
  5057 00001DD6 E9(0000)                	jmp cmd3_injected
  5058                                  
  5059                                  .notfound:
  5060                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  5061 00001DD9 F606[0300]08            	testopt [internalflags3], dif3_in_if
  5062 00001DDE 751B                    	jnz @F
  5063                                  %endif
  5064 00001DE0 B80103                  	mov ax, 0301h
  5065 00001DE3 E8(0000)                	call setrc
  5066 00001DE6 BA[0000]                	mov dx, msg.goto_not_found.1
  5067 00001DE9 E833E9                  	call putsz_error
  5068 00001DEC 5A                      	pop dx
  5069 00001DED E82FE9                  	call putsz_error
  5070 00001DF0 BA[0000]                	mov dx, msg.goto_not_found.2
  5071 00001DF3 E829E9                  	call putsz_error
  5072 00001DF6 89EC                    	mov sp, bp
  5073 00001DF8 E909F0                  	jmp getline_close_file
  5074                                  
  5075                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  5076                                  @@:
  5077 00001DFB 89EC                    	mov sp, bp
  5078 00001DFD E804F0                  	call getline_close_file
  5079 00001E00 E9(0000)                	jmp if_exists_not_found
  5080                                  %endif
  5081                                  
  5082                                  .empty:
  5083 00001E03 B80203                  	mov ax, 0302h
  5084 00001E06 E8(0000)                	call setrc
  5085 00001E09 BA[0000]                	mov dx, msg.goto_empty
  5086 00001E0C E90AFF                  	jmp .error
  5087                                  
  5088                                  
  5089                                  resetrc:
  5090 00001E0F FF36[0000]              	push word [priorrc]
  5091 00001E13 8F06[0000]              	pop word [rc]
  5092 00001E17 C3                      	retn
  5093                                  
  5094                                  
  5095                                   %ifn _LINK || _LINK_COMPAT
  5096                                  %include "serialp.asm"
  5097                                   %endif
