     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
   209                              <2> %else
   210                              <2> 	usesection lDEBUG_CODE
   210          ------------------  <2>  note: usesection lDEBUG_CODE
   211                              <2> %endif
   212                              <2> section_of FloatToStr
   213                              <2> 
   214                              <2> 
   215                              <2>  %if _DUALCODE && _EXPRDUALCODE
   216                              <2> 	usesection lDEBUG_CODE2
   217                              <2>  %else
   218                              <2> 	usesection lDEBUG_CODE
   218          ------------------  <2>  note: usesection lDEBUG_CODE
   219                              <2>  %endif
   220                              <2> 
   221                              <2> section_of getofsforbx, checkpointer, getrangeX
   222                              <2> section_of getrangeX_have_address_need_length
   223                              <2> section_of getrange, getaddr, getofsforbx_remember_bitness
   224                              <2> section_of remember_bitness, getaddr_taken
   225                              <2> section_of getstr, get_length, get_length_keyword
   226                              <2> section_of isbracketorunaryoperator?, isunaryoperator?, isoperator?
   227                              <2> section_of ..@call_operator_dispatchers
   228                              <2> section_of isseparator?, istype?, isunsignedtype?
   229                              <2> section_of handlesegment, handle3byte, handlebyte, handleword
   230                              <2> section_of handledword, handlepointer
   231                              <2> section_of uoh_abs, uoh_minus, calculate_minus_bxdx, uoh_plus
   232                              <2> section_of uoh_not_bitwise, uoh_not_boolean
   233                              <2> section_of od_minus, od_plus, od_multiply, od_divide, od_modulo, od_retn
   234                              <2> section_of od_above, od_below, od_equal, od_not, od_or, od_and, od_xor
   235                              <2> section_of od_cond, od_o, od_a, od_x, od_c, od_string_common
   236                              <2> section_of of_modulo, of_minus, of_plus, or_hhtype, of_multiply
   237                              <2> section_of set_hhtype, of_divide, of_power
   238                              <2> section_of of_compare_below_equal, of_compare_below, of_compare_not_equal
   239                              <2> section_of of_compare_equal, of_compare_above_equal, of_compare_above
   240                              <2> section_of toboolean, of_helper_compare_true, of_rightop, of_helper_compare
   241                              <2> section_of of_shift_right, of_shift_right_signed, of_shift_left
   242                              <2> section_of of_helper_getshiftdata, of_bit_mirror
   243                              <2> section_of of_or_bitwise, or_hhtype_1, of_or_boolean, of_clr_bitwise
   244                              <2> section_of of_and_bitwise, of_and_boolean, of_xor_bitwise, of_xor_boolean
   245                              <2> section_of of_helper_retbool, of_helper_getbool
   246                              <2> 
   247                              <2> section_of var_cip_setup, var_csp_setup, var_lfsr_setup, var_reverselfsr_setup
   248                              <2> section_of var_dpspsel_setup, var_seldbg_setup, var_mt_setup
   249                              <2> section_of var_ioi_setup, var_psps_setup, var_ppr_setup, var_ppi_setup
   250                              <2> section_of var_iok_setup, var_rhcount_setup
   251                              <2> section_of var_get_psp_segment, var_get_psp_selector
   252                              <2> section_of var_bootldpunit_setup, var_bootsdpunit_setup, var_bootydpunit_setup
   253                              <2> section_of var_bootldppart_setup, var_bootsdppart_setup, var_bootydppart_setup
   254                              <2> section_of var_bootunitflags_setup
   255                              <2> 
   256                              <2> section_of issymbol?, isvariable?, var_mm_setup, var_ri_setup, var_ysf_setup
   257                              <2> section_of default_variable_setup
   258                              <2> section_of var_ext_setup
   259                              <2> section_of var_ext_setup_done
   260                              <2> 
   261                              <2> section_of getstmmxdigit
   262                              <2> section_of getexpression.lit_ishexdigit?, getexpression.lit_isdigit?
   263                              <2> section_of of_cond, count_unary_operators, count_unary_operators_restrict
   264                              <2> section_of get3byte.checksignificantbits, getbyte, checksignificantbitscommon
   265                              <2> section_of getnyb, get_value_range
   266                              <2> 
   267                              <2> section_of getaddrX, getword, getdword, getexpression
   268                              <2> 
   269                              <2> section_of getrangeX.lines, getrangeX.ecx_and_0_valid
   270                              <2> section_of getrange.lines, getrange.ecx_and_0_valid, get_length.lines
   271                              <2> section_of getrangeX.lines_and_uu, getrange.lines_and_uu
   272                              <2> section_of isseparator?.except_L_or_dot, isvariable?.return_name
   273                              <2> section_of getword.checksignificantbits, getbyte.checksignificantbits
   274                              <2> 
   275                              <2> section_of seg_bx_to_sel
   276                              <2> section_of getexpression.countsignificantbits
   277                              <2> section_of ..@rr_checksignificantbits, ..@rr_operatordispatchers
   278                              <2> section_of ..@rr_operatorfunctions, ..@parsecm_getaddr
   279                              <2> section_of stack_check.internal
   280                              <2> 
   281                              <2> 
   282                              <2> 	usesection INIT
   282          ------------------  <2>  note: usesection INIT
   283                              <2> section_of init_capitalise
   284                              <2> section_of init_skipwhite, init_skipwh0
   285                              <2> section_of init_skipcomma, init_skipcomm0
   286                              <2> section_of init_skipequals
   287                              <2> 
   288                              <2> 
   289                              <2> 	usesection lDEBUG_DATA_ENTRY
   289          ------------------  <2>  note: usesection lDEBUG_DATA_ENTRY
   290                              <2> section_of entry_retn
   291                              <2> 
   292                              <2> 
   293                              <2> %if _LINK
   294                              <2>  %include "extern.mac"
     1                              <3> 
     2                              <3> ; expr.asm
     3                              <3>  extern PPLEN, PPLEN_ONLY_PREFIXES, a_addr, alloc_seg, alloc_size
     4                              <3>  extern amis_multiplex_number, asm_options, asm_startoptions
     5                              <3>  extern auxbuff_current_size, auxbuff_segorsel, behind_r_u_addr
     6                              <3>  extern bp_offset, code_seg, code_size, d_addr, dcount_addr
     7                              <3>  extern dcpm_addr, dd_default_length, dd_default_lines, dd_text_and
     8                              <3>  extern debuggerfunction, default_pp_count, default_tp_count
     9                              <3>  extern default_tt_count, device_header_address, device_mcb_paragraphs
    10                              <3>  extern dwcount_addr, dz_addr, e_addr, encodedmach87, entryseg_size
    11                              <3>  extern env_size, envseg, erc, errret
    12                              <3>  extern extdata, extdata_size, extdata_used, extseg, extseg_size
    13                              <3>  extern extseg_used, flagbits.amount, flagnames, flagvaron
    14                              <3>  extern getrange_is_uu, getrange_lines, has_mmx, hhresult
    15                              <3>  extern history.segorsel, historyseg_size, immseg, input_file_handles
    16                              <3>  extern input_file_handles.active, internalflags, internalflags2
    17                              <3>  extern internalflags3, intr8_limit, io_columns, io_columns_getline
    18                              <3>  extern io_end_buffer, io_flags, io_levels, io_rows, io_start_buffer
    19                              <3>  extern line_out, line_out_end, linkinfoaddress, load_data
    20                              <3>  extern load_input_file, load_input_file.active, load_unit_flags
    21                              <3>  extern loaddata_loadedfrom, machine, maxmachinetype, messageseg
    22                              <3>  extern messageseg_size, mmxbuff, msg.as, msg.end, msg.executing
    23                              <3>  extern msg.executing_value_range, msg.from, msg.in, msg.length
    24                              <3>  extern msg.linear, msg.lines, msg.lr, msg.nd, msg.nottaken
    25                              <3>  extern msg.nt, msg.or, msg.questionmark, msg.r, msg.stack_overflow
    26                              <3>  extern msg.stack_overflow.caller, msg.stack_overflow.cond
    27                              <3>  extern msg.stack_overflow.indirection, msg.stack_overflow.linear
    28                              <3>  extern msg.stack_overflow.parens, msg.stack_overflow.precedence
    29                              <3>  extern msg.stack_overflow.value_in, msg.t, msg.taken, msg.to
    30                              <3>  extern msg.value, msgtable_value_range, options, options2, parent
    31                              <3>  extern ppbytes, priorrc, psp22, pspdbe, pspdbg
    32                              <3>  extern qqtermcode, rc_count, rc_limit, re_count, re_limit
    33                              <3>  extern reading_access_variables, reg16names, reg8names, reg_cs
    34                              <3>  extern reg_ds, reg_efl, reg_eip, reg_esp, search_results
    35                              <3>  extern serial_columns, serial_fifo_size, serial_keep_timeout
    36                              <3>  extern serial_rows, serial_use_baseport, serial_use_dl
    37                              <3>  extern serial_use_fifo, serial_use_intnum, serial_use_irqmask
    38                              <3>  extern serial_use_params, serial_var_baseport, serial_var_dl
    39                              <3>  extern serial_var_fifo, serial_var_intnum, serial_var_irqmask
    40                              <3>  extern serial_var_params, sscounter, stack, startoptions
    41                              <3>  extern table_length_keywords, throwsp, transfer_ext_cx
    42                              <3>  extern try_amis_multiplex_number, try_debugger_amis_multiplex_number
    43                              <3>  extern types, types.addresses_minus_end, types.end, u_addr
    44                              <3>  extern usertermcode, uu_default_length, uu_default_lines, vregs
    45                              <3>  extern vregs.amount, writing_access_variables
    46                              <3>  extern flagbits, regs
    47                              <3> 
    48                              <3> ; run.asm
    49                              <3>  extern ..@aa_access_end, ..@aa_access_start, ..@dd_access_end
    50                              <3>  extern ..@dd_access_start, ..@ee_access_end, ..@ee_access_start
    51                              <3>  extern ..@ee_interactive_access_end, ..@ee_interactive_access_start
    52                              <3>  extern ..@hh_indirection_memory_access_end
    53                              <3>  extern ..@hh_indirection_memory_access_start
    54                              <3>  extern ..@readmem_fault_skip_4_near_call, ..@rr_access_end
    55                              <3>  extern ..@rr_access_start, ..@rr_variable_read_access_end
    56                              <3>  extern ..@rr_variable_read_access_start
    57                              <3>  extern ..@rr_variable_write_access_end
    58                              <3>  extern ..@rr_variable_write_access_start, ..@sss_access_end
    59                              <3>  extern ..@sss_access_start, ..@uu_access_end, ..@uu_access_start
    60                              <3>  extern ..@uu_referenced_memory_access_end
    61                              <3>  extern ..@uu_referenced_memory_access_start, ..@uu_simulate_cmps_end
    62                              <3>  extern ..@uu_simulate_cmps_start, ..@uu_simulate_scas_end
    63                              <3>  extern ..@uu_simulate_scas_start, InDOS_or_BIOS_IO, PPLEN_ONLY_STRING
    64                              <3>  extern auxbuff_behind_last_silent
    65                              <3>  extern auxbuff_start_silent, bInDbg, b_bplist.bp, b_bplist.counter
    66                              <3>  extern b_bplist.disabled_mask, b_bplist.idbuffer, b_bplist.used_mask
    67                              <3>  extern b_bplist.when, bb_deferred_message_in_lineout_behind
    68                              <3>  extern bp_display_offset, calcpointbit, cmd2_reset_re, cmd_goto
    69                              <3>  extern debug22.cleartraceflag, decbyte, dmycmd, dumpregs_extended
    70                              <3>  extern enable_rh, entry_to_code_seg, entry_to_code_segsel, eqflag
    71                              <3>  extern eqladdr, exccsip, exception_csip, exception_stack, excloc
    72                              <3>  extern g_bplist.bp, g_bplist.used_count, get_set_id_offset_length
    73                              <3>  extern getc_if_any, getcseipbyte, getint2324, getpsp
    74                              <3>  extern gg_deferred_message, gg_first_cseip_linear
    75                              <3>  extern gg_next_cseip_linear, guard_auxbuff.1_or_2, idle, in_getinput
    76                              <3>  extern int19msg, internalflags6, intr8_counter, lastcmd, msg.again
    77                              <3>  extern msg.alreadytsr, msg.area_aa_access, msg.area_dd_access
    78                              <3>  extern msg.area_ee_access, msg.area_ee_interactive_access
    79                              <3>  extern msg.area_hh_indirection_memory_access, msg.area_rr_access
    80                              <3>  extern msg.area_rr_variable_read_access
    81                              <3>  extern msg.area_rr_variable_write_access, msg.area_run_access
    82                              <3>  extern msg.area_sss_access, msg.area_uu_access
    83                              <3>  extern msg.area_uu_referenced_memory_access
    84                              <3>  extern msg.area_uu_simulate_cmps, msg.area_uu_simulate_scas
    85                              <3>  extern msg.bb_hit.1, msg.bb_hit.2.counter, msg.bb_hitpass_id.after
    86                              <3>  extern msg.bb_hitpass_id.long, msg.bb_hitpass_id.short, msg.bb_pass.1
    87                              <3>  extern msg.cant_bp_linear, msg.cant_bp_linear.address1
    88                              <3>  extern msg.cant_bp_reason, msg.cant_bp_reason0, msg.cant_bp_reason1
    89                              <3>  extern msg.cant_bp_reason2, msg.cant_bp_reason3
    90                              <3>  extern msg.cant_bp_reason3.value, msg.cant_bp_reasonu
    91                              <3>  extern msg.cant_bp_restore, msg.cant_bp_restore.value
    92                              <3>  extern msg.cant_bp_the, msg.cant_bp_type_gg
    93                              <3>  extern msg.cant_bp_type_permanent, msg.cant_bp_type_permanent.index
    94                              <3>  extern msg.cant_bp_type_proceed, msg.cant_bp_write, msg.ctrlc
    95                              <3>  extern msg.empty_message, msg.goto, msg.invalidpsp, msg.list
    96                              <3>  extern msg.list_bp.address1, msg.list_bp.first, msg.list_bp.second
    97                              <3>  extern msg.list_bp.third, msg.list_bp.value, msg.list_bp_csip_16
    98                              <3>  extern msg.list_bp_none, msg.list_bp_not_cseip, msg.notyettsr
    99                              <3>  extern msg.nowattached, msg.nowtsr1, msg.nowtsr2, msg.psphooked
   100                              <3>  extern msg.pspnotfound, msg.remember, msg.selfownedpsp, msg.silent
   101                              <3>  extern msg.warnprefix, msg.while, msg.while_not_true
   102                              <3>  extern msg.while_terminated_after, msg.while_terminated_before
   103                              <3>  extern oldcols, oldcrtp, oldcsrpos, oldmr, options3
   104                              <3>  extern options6, pp_instruction, pp_operand, progexit, progtrm
   105                              <3>  extern rc, reg_eax, reg_es, reg_gs, reg_ss
   106                              <3>  extern run_int, run_sp, run_sp_reserve, savesp, setcseipbyte
   107                              <3>  extern setint2324, setpsp, setpspdbg
   108                              <3>  extern showstring, silence_dump, spadjust, swapscreen
   109                              <3>  extern tmode0, tmode1, tmodes, tmodev, tpg_possible_breakpoint
   110                              <3>  extern tpg_proceed_bp, tt_silent_mode_number, vpage, vrows
   111                              <3>  extern while_buffer, while_buffer.length, writemem
   112                              <3> 
   113                              <3>  extern ..@getcseipbyte_fault_skip_2_near_call
   114                              <3>  extern ..@setcseipbyte_fault_skip_2_near_call
   115                              <3>  extern ..@writemem_fault_skip_4_near_call_a
   116                              <3>  extern ..@writemem_fault_skip_4_near_call_b, int0Cmsg, int0Dmsg
   117                              <3>  extern int0msg, int18msg, int1msg, int3msg, int6msg
   118                              <3>  extern int8_kbd_msg, int8msg, runint_ctrlc_msg, serial_flags
   119                              <3> 
   120                              <3> ; bb.asm
   121                              <3>  extern ..@bb_id_length, ..@bb_id_start, ..@bb_saved_linear
   122                              <3>  extern ..@bb_when_length, ..@bb_when_start, b_bplist.id
   123                              <3>  extern b_bplist.idbuffer.free
   124                              <3>  extern b_bplist.whenbuffer, b_bplist.whenbuffer.free
   125                              <3>  extern bootcmd, crlf, msg.all, msg.at
   126                              <3>  extern msg.bb_no_new, msg.bb_when, msg.boot, msg.bp, msg.bpaddress
   127                              <3>  extern msg.bpcontent, msg.bpcounter, msg.bpdisabled, msg.bpenabled
   128                              <3>  extern msg.bpnone, msg.bpnone_at, msg.bpunused, msg.counter
   129                              <3>  extern msg.existing, msg.id, msg.new, msg.notbu, msg.number
   130                              <3>  extern msg.offset, msg.when, prnquit
   131                              <3> 
   132                              <3> ; rr.asm
   133                              <3>  extern InDOS_or_BIOS_output, cmdline_buffer
   134                              <3>  extern cmdline_buffer.end, cmdline_buffer.position, disflags, ee0a
   135                              <3>  extern error_expr, flagbits_for_40, flagbits_for_80, flagsoff
   136                              <3>  extern flagsoff_style2, flagsoff_style3, flagson, flagson_style23
   137                              <3>  extern get_memref_index_bx, getline00, getline_reset_notatty
   138                              <3>  extern guard_rc, hexnyb.common, hhtype, hhvar, in_re
   139                              <3>  extern mask_4byte, masks, memrefs, memrefs.free, msg.3byte
   140                              <3>  extern msg.abort, msg.append, msg.byte, msg.count, msg.dword
   141                              <3>  extern msg.highlight, msg.internal_error_no_mmx, msg.readonly
   142                              <3>  extern msg.readonly_mem, msg.regs386, msg.regs386_off, msg.regs386_on
   143                              <3>  extern msg.replace, msg.rh, msg.rv_mode.before, msg.rv_mode_r86m
   144                              <3>  extern msg.rv_mode_v86m, msg.rvd, msg.rvd_deviceheader
   145                              <3>  extern msg.rvd_not_device, msg.rvd_size, msg.rvm, msg.rvp
   146                              <3>  extern msg.rvp_application, msg.rvp_boot, msg.rvp_device
   147                              <3>  extern msg.rvp_device_attached, msg.rvp_tsr, msg.rvv
   148                              <3>  extern msg.unexpected_auxbuff_guard, msg.unhighlight, msg.vm_auxseg
   149                              <3>  extern msg.vm_codeseg, msg.vm_dataseg, msg.vm_entryseg, msg.vm_hisseg
   150                              <3>  extern msg.vm_messageseg, msg.vp_dparent, msg.vp_dpra
   151                              <3>  extern msg.vp_dpspsegment, msg.vp_parent, msg.vp_pra
   152                              <3>  extern msg.vp_pspsegment, msg.word, operatorfunctions, psp_parent
   153                              <3>  extern psp_pra, puts_break_line_more, putsline_break_line, re_buffer
   154                              <3>  extern re_buffer.end, re_buffer.position, re_sp, regs_prior
   155                              <3>  extern regs_prior.size, retn_expr, rh_count_number
   156                              <3>  extern rh_display_with_count, shortflagbits, shortflagbits.amount
   157                              <3>  extern shortflagsoff, shortflagson, silence_dump.rh
   158                              <3>  extern silence_dump.rh.all, table_getline_prepare_ldebug
   159                              <3>  extern table_getline_prepare_ms_debug, terminate_silent_dump
   160                              <3>  extern terminate_silent_dump.if_nonnull
   161                              <3> 
   162                              <3> ; rr.asm
   163                              <3>  extern flagbits_for_shl, regs_prior.size_w
   164                              <3> 
   165                              <3> ; aa.asm
   166                              <3>  extern REP_LEN, SEGP_LEN, attach
   167                              <3>  extern ext_aa_after_getline_handler, ext_aa_before_getline_handler
   168                              <3>  extern ext_aa_inject_handler, immasm_length, immasm_rel1632_target
   169                              <3>  extern immasm_rel8_target, msg.aa_internal_error, msg.attach
   170                              <3>  extern prefixlist.after_segment, replist, segprfxtab, showmach
   171                              <3>  extern skipalpha, sm1
   172                              <3> 
   173                              <3> ; uu.asm
   174                              <3>  extern A32P_LEN, GROUP7, MN_DB, MN_LOCK, MN_LOOP
   175                              <3>  extern MN_LOOPNZ, MN_LOOPZ, MN_REP, MN_REPE, MN_REPNE
   176                              <3>  extern MN_SEG, MN_WAIT, N_LOCK, N_LTABA, N_LTABO
   177                              <3>  extern N_WTAB, O32P_AMOUNT, OPTYPES_BASE, REP_DIFF_LEN, REP_SAME_LEN
   178                              <3>  extern SFPGROUP3, SGROUP4, SPARSE_BASE, a32prfxtab, dismach
   179                              <3>  extern dmflags, has_87, immasm_far_target, immasm_imm16, locktab
   180                              <3>  extern ltaba1, ltabo1, mach_87, mnlist, mnlist_a_suffix_allowed
   181                              <3>  extern mnlist_o_suffix_allowed, mnlist_o_suffix_required
   182                              <3>  extern msg.condjump, msg.condnotjump, msg.memrefs_invalid_internal
   183                              <3>  extern msg.uninstall, msg.uu_internal_error, msg.uu_too_many_repeat
   184                              <3>  extern needsmath, needsmath_L, needsmsg, needsmsg.digit_6_ofs
   185                              <3>  extern needsmsg.digit_x_ofs, needsmsg_L, o32prfxtab, obsmach
   186                              <3>  extern obsolete, obsolete_L, opindex, opinfo, oplists
   187                              <3>  extern optypes, ppbytes.string, ppbytes.string_amount, reg_ebp
   188                              <3>  extern reg_ebx, reg_ecx, reg_edi, reg_esi, reg_fs
   189                              <3>  extern regmem, rgnam16, rgnam816, segrgnam, sibbyte
   190                              <3>  extern sqztab, tab_to, uninstall, unused, wtab1
   191                              <3> 
   192                              <3> ; uu.asm
   193                              <3>  extern reg_edx
   194                              <3> 
   195                              <3> ; uu.asm
   196                              <3>  extern MN_BSWAP, MN_O32
   197                              <3> 
   198                              <3> ; uu.asm
   199                              <3>  extern MN_A32
   200                              <3> 
   201                              <3> ; amis.asm
   202                              <3>  extern amisintr_offset, deviceshim_size, ext_amis_handler
   203                              <3> 
   204                              <3> ; boot.asm
   205                              <3>  extern boot_remember_seek_handle
   206                              <3>  extern boot_remember_seek_offset, chkeol_or_then, cmd_goto.yy_entry
   207                              <3>  extern display_y_or_ext, ext_cmdline, ext_finish.boot
   208                              <3>  extern if_exists_found_open, if_exists_not_found
   209                              <3>  extern if_exists_then_address, iseol?_or_then, loadoptiontable
   210                              <3>  extern loadoptiontable.incompatible, loadsettings
   211                              <3>  extern msdos7_message_table, msdos7_message_table.size
   212                              <3>  extern msg.boot_access_error, msg.boot_and, msg.boot_auxbuff_crossing
   213                              <3>  extern msg.boot_badchain, msg.boot_badclusters, msg.boot_badfat
   214                              <3>  extern msg.boot_bpb_load_overlap, msg.boot_bpb_too_low
   215                              <3>  extern msg.boot_cannot_set_both, msg.boot_dot_crlf
   216                              <3>  extern msg.boot_file_not_found, msg.boot_file_too_big_error
   217                              <3>  extern msg.boot_file_too_small_error, msg.boot_internal_error
   218                              <3>  extern msg.boot_invalid_filename, msg.boot_invalid_heads
   219                              <3>  extern msg.boot_invalid_sectors, msg.boot_out_of_memory_error
   220                              <3>  extern msg.boot_partition_cycle_error, msg.boot_partition_not_found
   221                              <3>  extern msg.boot_quit_fail, msg.boot_sector_not_power
   222                              <3>  extern msg.boot_sector_too_large, msg.boot_sector_too_small
   223                              <3>  extern msg.boot_segment_too_low, msg.boot_too_many_partitions_error
   224                              <3>  extern msg.bootfail, msg.bootfail_check_mismatch
   225                              <3>  extern msg.bootfail_check_mismatch.check_got
   226                              <3>  extern msg.bootfail_check_mismatch.check_offset
   227                              <3>  extern msg.bootfail_check_mismatch.check_value, msg.bootfail_code
   228                              <3>  extern msg.bootfail_read, msg.bootfail_read_errorcode
   229                              <3>  extern msg.bootfail_secsizediffer, msg.bootfail_sig
   230                              <3>  extern msg.bootfail_sig_parttable, msg.bootfail_stack_underflow
   231                              <3>  extern msg.bpb, msg.checkoffset, msg.checkvalue, msg.dir
   232                              <3>  extern msg.dirinsteadsize, msg.emptydirname, msg.entry
   233                              <3>  extern msg.guard_auxbuff_error, msg.hidden, msg.hiddenadd
   234                              <3>  extern msg.maxpara, msg.minpara, msg.protocol, msg.quit, msg.read
   235                              <3>  extern msg.sector, msg.sector_alt, msg.segment, msg.write
   236                              <3>  extern msg.yy_empty, msg.yy_filename_empty, msg.yy_no_file
   237                              <3>  extern msg.yy_requires_filename, msg.yy_too_large
   238                              <3>  extern msg.yy_too_many_handles, terminator_in_line_in.offset
   239                              <3>  extern terminator_in_line_in.value, throwret
   240                              <3>  extern yy_boot_attempt_open_pathname, yy_boot_attempt_open_stack
   241                              <3>  extern yy_is_script
   242                              <3> 
   243                              <3> ; cc.asm
   244                              <3>  extern count_var, hh.single, msg.clear, msg.clear_sequence
   245                              <3>  extern msg.range, parsecm
   246                              <3> 
   247                              <3> ; dd.asm
   248                              <3>  extern auxbuff_current_size_minus_24, charcounter
   249                              <3>  extern dstringaddr, dstringtype, firstmcb, firstumcb, intaddress
   250                              <3>  extern lastint, lastint_is_86m_and_mcb, msg.di_empty, msg.di_error
   251                              <3>  extern msg.di_freedos_reloc, msg.di_hidden, msg.di_hma, msg.di_iisp
   252                              <3>  extern msg.di_jmpfar, msg.di_jmpfarindirect, msg.di_multiplex.1
   253                              <3>  extern msg.di_multiplex.2, msg.di_multiplex.3, msg.di_nonstd_iisp
   254                              <3>  extern msg.di_system_low, msg.di_system_mcb, msg.di_system_upper
   255                              <3>  extern msg.di_testhook, msg.di_toomany, msg.di_uninst_iisp
   256                              <3>  extern msg.header, msg.header.length, msg.invmcbadr, msg.prefixes
   257                              <3>  extern msg.tableheader, msg.tableheadertop, msg.top, msg.trailer
   258                              <3>  extern msg.trailer.length, smcbmsg_unknown, smcbtypes
   259                              <3> 
   260                              <3> ; debug.asm
   261                              <3>  extern UnhookInterruptForce, UnhookInterruptForceSim, aa
   262                              <3>  extern adusetup, bb, boot_ebdaflag, boot_initcode
   263                              <3>  extern boot_new_memsizekib, boot_old_memsizekib, cc, code_start, ddd
   264                              <3>  extern device_initcode, driveno, dumpregs_extended.exit, ee
   265                              <3>  extern eld_linkcall.call_cmd3, end_of_ldebug_code, entry_int3_retf
   266                              <3>  extern errcarat, ff, get_86m_interrupt_handler_no_dos, get_columns
   267                              <3>  extern getline_close_file, getline_close_file.resetstuff, gg, hh
   268                              <3>  extern hh_depth, hh_depth_of_single_term, hhflag, ia_restore, ii
   269                              <3>  extern immasm, install_86m_interrupt_handler, int22, int2D, intr0
   270                              <3>  extern intr0C, intr0D, intr1, intr18, intr19
   271                              <3>  extern intr3, intr6, intr8, linkinfo, ll
   272                              <3>  extern ll3, ll_copy_cmdline_and_fcbs
   273                              <3>  extern ll_copy_cmdline_and_fcbs.have_cx
   274                              <3>  extern mm, msg.NULblank, msg.asmoptions_1, msg.boothelp
   275                              <3>  extern msg.build_array, msg.build_long_amount, msg.build_short_amount
   276                              <3>  extern msg.build_version_amount, msg.cannot_hook_2D.invalid
   277                              <3>  extern msg.cannot_hook_2D.nofree, msg.cannotbootquit_memsizes
   278                              <3>  extern msg.condhelp, msg.ensure_no_memory, msg.expressionhelp
   279                              <3>  extern msg.flaghelp, msg.flags_1, msg.guard_rc_error
   280                              <3>  extern msg.guard_re_error, msg.help_array, msg.help_array_amount
   281                              <3>  extern msg.help_re, msg.help_run, msg.help_source, msg.keep
   282                              <3>  extern msg.license, msg.line_out_overflow, msg.n_toolongname
   283                              <3>  extern msg.n_toolongtail, msg.nobootsupp, msg.options_array
   284                              <3>  extern msg.options_array_amount, msg.options_pages, msg.options_scan
   285                              <3>  extern msg.options_scan_amount, msg.qq_a_terminated
   286                              <3>  extern msg.qq_a_unterminated, msg.qq_device_no_c, msg.qq_device_no_d
   287                              <3>  extern msg.qq_device_none_selected, msg.qq_unterm
   288                              <3>  extern msg.rc_limit_reached, msg.re, msg.re_limit_reached
   289                              <3>  extern msg.reghelp, msg.rh_disabled, msg.rh_enabled, msg.run
   290                              <3>  extern msg.serial_cannot_hook, msg.serial_cannot_hook.new_int
   291                              <3>  extern msg.serial_cannot_hook.old_int, msg.serial_cannot_unhook
   292                              <3>  extern msg.serial_cannot_unhook.int, msg.serial_cannot_unhook.nowarn
   293                              <3>  extern msg.serial_late_unhook, msg.serial_late_unhook.int
   294                              <3>  extern msg.serial_no_keep_enter, msg.serial_no_keep_timer
   295                              <3>  extern msg.serial_request_keep, msg.source, msg.string_build
   296                              <3>  extern msg.string_options, msg.string_version
   297                              <3>  extern msg.tsr_cannot_terminate_attached, msg.varhelp, oo, ph_msg, pp
   298                              <3>  extern putrunint, putsz_exthelp, rr, run, section.DEVICESHIM.vstart
   299                              <3>  extern serial_clean_up, serial_clear_fifos, serial_eoi
   300                              <3>  extern serial_init_UART, serial_install_interrupt_handler
   301                              <3>  extern serial_interrupt_handler, serial_uninstall_interrupt_handler
   302                              <3>  extern set_irq, setscreen, sleep_delta_limit, sleep_highest_delta
   303                              <3>  extern sss, tpg_initialise_empty_auxbuff.reset
   304                              <3>  extern transfer_to_ext_puts_getline, tt, update_inttab_optional, uu
   305                              <3>  extern vv, vv_disable, vv_set, ww, yy
   306                              <3> 
   307                              <3> ; debug.asm
   308                              <3>  extern eld_linkcall
   309                              <3> 
   310                              <3> ; ee.asm
   311                              <3>  extern bufend, bufnext, fillbuf, fullbsout
   312                              <3>  extern getline_is_input_file?, line_in, linecounter, load_extension
   313                              <3>  extern msg.ext, notatty, prehak1, run2324
   314                              <3> 
   315                              <3> ; hh.asm
   316                              <3>  extern hh_div_active, hh_div_dividend, hh_div_divisor
   317                              <3>  extern msg.base, msg.group, msg.hh_div_remainder, msg.width
   318                              <3> 
   319                              <3> ; iioo.asm
   320                              <3>  extern if_exists_length, if_exists_si, if_exists_sp
   321                              <3>  extern install, msg.exists, msg.install, msg.not, msg.then
   322                              <3>  extern msg.y, resetrc, yy_or_ext_no_guard_re
   323                              <3> 
   324                              <3> ; immasm.asm
   325                              <3>  extern aa_ret, addrr, condmsg, error_mirror, index
   326                              <3>  extern msg.immasm_error_eip, presizeflags, reg32addr, segmnt
   327                              <3>  extern segrgaddr
   328                              <3> 
   329                              <3> ; msg.asm
   330                              <3>  extern ..@boot_scan_dir_return_fat16_root_entry
   331                              <3>  extern ..@boot_scan_dir_return_filenotfound
   332                              <3>  extern ..@boot_scan_dir_return_subdir_or_fat32_entry
   333                              <3>  extern alloc_size_not_reserved, asciitablenames, boot_init_foundname
   334                              <3>  extern configpath, configpath.dir_end, device_quittable_regs, dpmi32
   335                              <3>  extern execblk.cmdline, ext_command_handler, ext_finish.bp_is_set
   336                              <3>  extern ext_handle, ext_inject_handler, ext_preprocess_handler
   337                              <3>  extern ext_puts_copyoutput_handler, ext_puts_getline_handler
   338                              <3>  extern ext_puts_handler, ext_var, ext_var_amount, ext_var_format
   339                              <3>  extern ext_var_size, extcssel, extdssel, handle_scan_dir_entry
   340                              <3>  extern handle_scan_dir_not_found, history.first, history.last
   341                              <3>  extern indirect_array_errfix, init_executable_pathname
   342                              <3>  extern init_executable_pathname.end, internalflags4, internalflags5
   343                              <3>  extern internalflags7, isvariable_morebyte_nameheaders.ext
   344                              <3>  extern lastcmd_transfer_ext_address, lastcmd_transfer_ext_entry
   345                              <3>  extern line_in.end, linkcall_table, load_adr_dirbuf_segment
   346                              <3>  extern load_check_dir_attr, load_data_lowest, load_kernel_name
   347                              <3>  extern load_yy_direntry, load_yyname_input, load_yyname_next
   348                              <3>  extern near_transfer_ext_address, near_transfer_ext_entry
   349                              <3>  extern next_reserved_segment, options4, options5, options7
   350                              <3>  extern patcharea_intrtn, patcharea_intrtn.segment
   351                              <3>  extern patcharea_intrtn.size, patcharea_run, patcharea_run.segment
   352                              <3>  extern patcharea_run.size, pm_2_86m_0, promptlen, reserved_address
   353                              <3>  extern scriptspath, scriptspath.dir_end
   354                              <3>  extern sss_silent_count, sss_silent_count_used, stack_end, swch1
   355                              <3>  extern while_buffer.end
   356                              <3> 
   357                              <3> ; msg.asm
   358                              <3>  extern install_trying
   359                              <3> 
   360                              <3> ; init.asm
   361                              <3>  extern ..@init_behind, ..@init_first
   362                              <3>  extern ..@patch_no386_ds_6_DATA_ENTRY
   363                              <3>  extern ..@patch_no386_ds_code_or_entry
   364                              <3>  extern ..@patch_no386_iret_code_or_entry, behind_code_truncated
   365                              <3>  extern behind_init, behind_messagesegment_nobits
   366                              <3>  extern behind_messagesegment_nobits_truncated, debug22
   367                              <3>  extern device_header.next, devint23, devint24, entry_retf
   368                              <3>  extern execblk.fcb1, execblk.fcb2, ext_data_area, extcall_table.ret
   369                              <3>  extern extcall_table.segsel, fileext, hVdd, immasm_buffer, initcont
   370                              <3>  extern initcont.boot_entry, initcont.device, inttab, inttab.i06
   371                              <3>  extern inttab.i2D, inttab_number_variable, line_out_overflow
   372                              <3>  extern linkcall_table.code1, linkcall_table.entry
   373                              <3>  extern linkcall_table.init, oldmode, pInDOS, pSDA, regs.size
   374                              <3>  extern switchar, trim_overflow, var_addr_entries
   375                              <3>  extern var_addr_entries.amount
   376                              <3> 
   377                              <3> ; install.asm
   378                              <3>  extern installflags, msg.alreadydisabled
   379                              <3>  extern msg.alreadyenabled, msg.toggle, msg.trydisable, msg.tryenable
   380                              <3> 
   381                              <3> ; ints.asm
   382                              <3>  extern debuggeramissig, inttab_optional
   383                              <3> 
   384                              <3> ; lineio.asm
   385                              <3>  extern auxbuff_amount_silent, cmd3_set_options
   386                              <3>  extern determine_quiet_output, eldheader, getc_repeat_idle
   387                              <3>  extern getline_timer_func, handle_ctrl_c, if_exists_found_closed
   388                              <3>  extern if_exists_found_ext_open, indos_remember_seek_function
   389                              <3>  extern indos_remember_seek_handle, indos_remember_seek_offset
   390                              <3>  extern input_file_handles.to_close, msg.configkeyword
   391                              <3>  extern msg.eld_error_code, msg.eld_load_error, msg.emptykeyword
   392                              <3>  extern msg.eof, msg.executablekeyword, msg.ext_error_internal
   393                              <3>  extern msg.ext_error_invalid, msg.ext_error_io, msg.ext_error_oom
   394                              <3>  extern msg.freedos_ctrlc_workaround, msg.goto_empty
   395                              <3>  extern msg.goto_not_file, msg.goto_not_found.1, msg.goto_not_found.2
   396                              <3>  extern msg.history_internal_error, msg.more, msg.more_over
   397                              <3>  extern msg.more_over_size, msg.more_size, msg.rh_step.1
   398                              <3>  extern msg.rh_step.2, msg.scriptskeyword, msg.silent_error, msg.sof
   399                              <3>  extern msg.unexpected_noneol_rc, msg.unexpected_noneol_re
   400                              <3>  extern msg.yy_error_file_open, msg.yy_filename_missing_unquote
   401                              <3>  extern msg.yy_no_dos, qq, section.DATASTACK.vstart
   402                              <3>  extern serial_check_receive_char, serial_receive_char
   403                              <3>  extern serial_send_char, skip_rh, yy_boot
   404                              <3>  extern yy_boot_clear_remember_seek, yy_boot_close_file, yy_boot_read
   405                              <3>  extern yy_boot_remember_seek, yy_boot_seek_current
   406                              <3>  extern yy_boot_seek_start, yy_try_scriptspath
   407                              <3>  extern yy_try_scriptspath.didnotyettry
   408                              <3>  extern yy_try_scriptspath.nokeywordused
   409                              <3> 
   410                              <3> ; ll.asm
   411                              <3>  extern doserr8, ensuredebuggeeloaded, execblk, execblk.csip
   412                              <3>  extern execblk.sssp, msg.hexerror, msg.ll_unterm, msg.not_while_indos
   413                              <3>  extern msg.tsr_cannot_ll, parselw, reading
   414                              <3>  extern terminate_attached_process, ww1, ww15, zeroregs
   415                              <3> 
   416                              <3> ; mm.asm
   417                              <3>  extern has_287, has_copr, msg.c0, msg.cr, msg8088
   418                              <3>  extern msgx86, no_copr, parsecm_have_address
   419                              <3> 
   420                              <3> ; serialp.asm
   421                              <3>  extern baseport, msg.no_progress, rxfifo, rxhead
   422                              <3>  extern rxtail, serial_fcr_setting, serial_installed_intnum
   423                              <3>  extern serial_save_dl, serial_save_ier, serial_save_irq_mask
   424                              <3>  extern serial_save_irq_off, serial_save_lcr, serial_save_mcr, txfifo
   425                              <3>  extern txhead, txtail
   426                              <3> 
   427                              <3> ; ss.asm
   428                              <3>  extern msg.matches, msg.reverse, msg.seconds, msg.sleep
   429                              <3>  extern msg.ticks, sleep_repeat_idle
   430                              <3> 
   431                              <3> ; vv.asm
   432                              <3>  extern csrpos, msg.nokeep, msg.off, msg.on, msg.vv_disabled
   433                              <3>  extern msg.vv_enable_failure, xmsdrv, xmsmove
   434                              <3> 
   435                              <3> ; ww.asm
   436                              <3>  extern diskful, doserr11, doserr2, doserr3, doserr5
   437                              <3>  extern drive, drivenumber, dskerrs, not_while_indos, nowhexe
   438                              <3>  extern nownull, openerr, openerr1, writing, wwmsg1
   439                              <3>  extern wwmsg2
   440                              <3> 
   441                              <3> 
   442                              <3>  extern bCSAttr, lDEBUG_CODE_to_lDEBUG_CODE2_nearcall_helper
   443                              <3> 
   444                              <3>  extern hook2F.not_in_dos
   445                              <3> 
   446                              <3>  extern cmd4.int3, lDEBUG_CODE2_dualret_helper
   447                              <3>  extern lDEBUG_CODE2_to_lDEBUG_CODE_nearcall_helper
   448                              <3>  extern lDEBUG_CODE_to_lDEBUG_CODE2_dualcall_helper, msg.bu
   449                              <3>  extern msg.bu_relocated, msg.bu_relocated.sign
   450                              <3> 
   451                              <3>  extern nopmsupp
   452                              <3> 
   453                              <3>  extern bAddr32
   454                              <3> 
   455                              <3>  extern descriptor, descriptor.attrib, descriptor.base
   456                              <3>  extern descriptor.limit, gatewrong, msg.d.a_error, msg.d.a_error_code
   457                              <3>  extern msg.d.a_success, msg.d.a_success_sel, msg.d.b_error
   458                              <3>  extern msg.d.b_error_code, msg.d.b_success, msg.d.d_error
   459                              <3>  extern msg.d.d_error_code, msg.d.d_success, msg.d.l_error
   460                              <3>  extern msg.d.l_error_code, msg.d.l_success, msg.d.t_error
   461                              <3>  extern msg.d.t_error_code, msg.d.t_success, msg.deschelp, msg.ofs32
   462                              <3>  extern nodesc
   463                              <3> 
   464                              <3>  extern ..@patch_tsr_quit_run, areastruc_entry.qq_entry, cssel
   465                              <3>  extern ddebugareas.next, debug2F, dpmidisable, dpmientry, dpmihook
   466                              <3>  extern dpmihookamis, dpmihookcs, dpmiwatch, end_of_ldebug_code2
   467                              <3>  extern findinstalleddebugger, get_messagesegsel, handle_mode_changed
   468                              <3>  extern i23pm, msg.cannotpmquit, msg.desc, msg.dpmi_no_hook, msg.msdos
   469                              <3>  extern msg.qq_device_pm, msg.qq_still_pm, msg.qqlate_areas_error
   470                              <3>  extern msg.readonly_verifysegm, msg.readonly_verifysegm.selector
   471                              <3>  extern mydpmientry, nodosext, oldi2F, pm_reset_handlers, scratchsel
   472                              <3>  extern sr_state, switchmode, uninstall_areas.qq_entry
   473                              <3> 
   474                              <3>  extern i24pm
   475                              <3> 
   476                              <3>  extern auxbuff_switchbuffer_size, code2_seg, code2_sel, code2_size
   477                              <3>  extern code_sel, daresult, dssel, immsel
   478                              <3>  extern lDEBUG_CODE2_to_lDEBUG_CODE_dualcall_helper
   479                              <3>  extern lDEBUG_CODE_dualret_helper, messagesel, msg.desctype
   480                              <3>  extern msg.stack_overflow.desctype
   481                              <3> 
   482                              <3>  extern cmd3_mirror
   483                              <3> 
   484                              <3>  extern ..@patch_entry_seg, ..@patch_no386_ds_4, ..@patch_no386_ds_5
   485                              <3>  extern ..@patch_no386_ds_entry_pmint21_1
   486                              <3>  extern ..@patch_no386_ds_entry_pmint21_2, areas_fun, areas_sub
   487                              <3>  extern ddebugareas.prev, linkcall_table.code2
   488                              <3> 
   489                              <3>  extern areas_struc, msg.areasalreadyinstalled
   490                              <3>  extern msg.areasalreadyuninstalled, msg.areasinstalled
   491                              <3>  extern msg.areasnodebuggerfound, msg.areasnotinstalled
   492                              <3>  extern msg.areasnotinstalled.code, msg.areasnotsupported
   493                              <3>  extern msg.areasuninstalled, msg.areasuninstalled.code
   494                              <3> 
   495                              <3>  extern intcall_return_parameter_es_parameter_ds
   496                              <3>  extern lDEBUG_CODE_to_lDEBUG_CODE_dualcall_helper, pop_if, push_if
   497                              <3> 
   498                              <3>  extern isextenderavailable, msg.cannotpmload, nodosextinst
   499                              <3> 
   500                              <3>  extern install_areas, patcharea_pm_exc, patcharea_pm_exc.segment
   501                              <3>  extern patcharea_pm_exc.size
   502                              <3> 
   503                              <3>  extern pmint21
   504                              <3> 
   505                              <3>  extern debuggerexception, entry_to_code_sel, exc6msg, excCmsg
   506                              <3>  extern excDmsg, excEmsg, intrtn2_entry, pmintsave.int21
   507                              <3> 
   508                              <3>  extern convsegs, convsegs.amount_fixed, convsegs.end_fixed
   509                              <3>  extern dpmi_pm2rm, dpmi_pmsav, dpmi_rm2pm, dpmi_rmsav, endexctab
   510                              <3>  extern exc_first, exc_second, excsave, exctab, installdpmimsg
   511                              <3>  extern intrtn_entry.from_installdpmi, pmintsave, pminttab
   512                              <3>  extern pminttab.end, setrmaddr, silence_delete_one_string.internal
   513                              <3> 
   514                              <3>  extern msg.rv_mode_dpmi_16, msg.rv_mode_dpmi_32, msg.vm_code2seg
   515                              <3>  extern msg.vm_selector, msg.vp_dpspsel, msg.vp_pspsel, psp_selector
   516                              <3> 
   517                              <3>  extern ..@getcseipbyte_fault_skip_6_near_call
   518                              <3>  extern ..@hh_code1_indirection_memory_access_end
   519                              <3>  extern ..@hh_code1_indirection_memory_access_start
   520                              <3>  extern ..@readmem_fault_skip_2_near_call
   521                              <3>  extern ..@setcseipbyte_fault_skip_6_near_call
   522                              <3>  extern ..@writemem_fault_skip_2_near_call_a
   523                              <3>  extern ..@writemem_fault_skip_2_near_call_b, behind_code
   524                              <3>  extern behind_code2, convsegs.amount, ddebugareas
   525                              <3>  extern getline_extra_int22.cleartraceflag, msg.list_bp_cseip_32
   526                              <3> 
   527                              <3>  extern MN_O16
   528                              <3> 
   529                              <3>  extern MN_A16
   530                              <3> 
   531                              <3>  extern relocatedzero
   532                              <3> 
   533                              <3>  extern msg.bu_disabled
   534                              <3> 
   535                              <3>  extern reset_interrupts, set_interrupts
   536                              <3> 
   537                              <3>  extern startoptions6
   538                              <3> 
   539                              <3>  extern currentposition, msg.loader_bottom_not_allowed
   540                              <3>  extern msg.loader_too_low_load
   541                              <3> 
   542                              <3>  extern intr_loader_18, intr_loader_19, moveloader_hook_ints
   543                              <3> 
   544                              <3>  extern loader_query, loader_transfer_cmd3, loader_transfer_relocate
   545                              <3> 
   546                              <3>  extern cmd3_int_disable.set_bx_to_dx, cmd3_int_enable.set_bx_to_dx
   547                              <3>  extern ldebug_code_size, movesegrefstable, movetable
   548                              <3>  extern movetable.bottom, msg.isalready, msg.isnow, msg.loader_error
   549                              <3>  extern msg.move, msg.move_auxbuff_error, msg.move_auxdown
   550                              <3>  extern msg.move_auxup, msg.move_ebdanottop, msg.move_empty
   551                              <3>  extern msg.move_int_error, msg.move_int_panic
   552                              <3>  extern msg.move_must_be_bottom, msg.move_nottop, msg.move_oom
   553                              <3>  extern msg.move_rpl, msg.move_toolargeebda, msg.unsupportedmove
   554                              <3>  extern qq_int_unhook_sim.set_bx_to_dx
   555                              <3> 
   556                              <3>  extern moveloader.already, moveloader.bottom_to_hidden
   557                              <3>  extern moveloader.bottom_to_top, moveloader.hidden_to_bottom
   558                              <3>  extern moveloader.hidden_to_top, moveloader.top_to_bottom
   559                              <3>  extern moveloader.top_to_hidden
   560                              <3> 
   561                              <3>  extern moveloader.specificerror, moveloader_check_serial, msg.godebug
   562                              <3>  extern msg.loader_extra, msg.loader_flag, msg.loader_loadseg_low
   563                              <3>  extern msg.loader_must_be_hidden, msg.loader_sign, msg.loader_stack
   564                              <3>  extern msg.loadsupportsignature, msg.loadsupportsignature.size
   565                              <3> 
   566                              <3>  extern depack, hshrink_memory_source.offset
   567                              <3>  extern hshrink_memory_source.segment, indirect_hshrink_message_buffer
   568                              <3>  extern msg.hshrink_error, nontruncated_hshrink_message_buffer
   569                              <3> 
   570                              <3>  extern truncated_hshrink_message_buffer
   571                              <3> 
   572                              <3>  extern patch_boothelp_uncompressed
   295                              <2> %endif
   710                              <1> %endif
   711                              <1> [list -]
   714                              <1> 
   715                              <1> %include "eld.mac"
     1                              <2> %if 0
     2                              <2> 
     3                              <2> Extensions for lDebug macros
     4                              <2> 
     5                              <2> Copyright (C) 2008-2025 E. C. Masloch
     6                              <2> 
     7                              <2> Usage of the works is permitted provided that this
     8                              <2> instrument is retained with the works, so that any entity
     9                              <2> that uses the works is notified of this instrument.
    10                              <2> 
    11                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    12                              <2> 
    13                              <2> %endif
    14                              <2> 
    15                              <2> %ifndef ELD_MAC
    16                              <2> %define ELD_MAC 1
    17                              <2> 
    18                              <2> %include "lmacros3.mac"
     1                              <3> [list -]
    19                              <2> 
    20                              <2> 		; ELD executable header
    21                              <2> 	struc ELD_HEADER
    22 00000000 ????????            <2> eldhSignature:		resb 4	; "ELD1"
    23 00000004 ??????              <2> 			resb 3	; reserved
    24 00000007 ??                  <2> 			resb 1	; 26 (Ctrl-Z)
    25 00000008 ????????            <2> eldhCodeOffset:		resd 1	; position displacement from eldhSignature
    26 0000000C ????                <2> eldhCodeImageLength:	resw 1	; amount bytes, at least 32
    27 0000000E ????                <2> eldhCodeAllocLength:	resw 1	; amount bytes, added to prior. sum < 64 KiB
    28 00000010 ????????            <2> eldhDataOffset:		resd 1
    29 00000014 ????                <2> eldhDataImageLength:	resw 1	; (zero allowed)
    30 00000016 ????                <2> eldhDataAllocLength:	resw 1	; (zero allowed)
    31 00000018 ????                <2> eldhCodeEntrypoint:	resw 1	; within code section, used as displacement
    32 0000001A ????????            <2> eldhReserved:		resb 4	; reserved
    33 0000001E ????                <2> eldhExtensionSize:	resw 1	; from eldhSignature, -> past eldhx fields in use
    34                              <2> 	endstruc
    35                              <2> 	endarea ELD_HEADER, 1
    36                              <2> 
    37                              <2> 	struc ELD_HEADERX
    38 00000000 <res 20h>           <2> eldhxHeader:		resb ELD_HEADER_size
    39 00000020 ????????            <2> eldhxDescriptionOffset:	resd 1	; zero if none, from eldhxHeader. <= 128 Bytes
    40 00000024 ????????            <2> eldhxHelpOffset:	resd 1	; zero if none, from eldhxHeader
    41 00000028 ????????            <2> eldhxLibTable:		resd 1	; zero if none, from eldhxHeader
    42 0000002C ????????            <2> eldhxDateTimeOffset:	resd 1	; zero if none, from eldhxHeader
    43                              <2> 	alignb 16
    44                              <2> 	endstruc
    45                              <2> 
    46                              <2> 	struc ELD_TRAILER_HEADER
    47 00000000 ????????????????    <2> eldthSignature:		resb 8	; "ELD1TAIL"
    48 00000008 ????????            <2> eldthHeaderOffset:	resd 1	; negative displacement from eldthSignature,
    49                              <2> 				;  add this dword to the seek offset
    50 0000000C ????                <2> eldthReserved:		resw 1	; reserved, must be initialised to zero
    51 0000000E ????                <2> eldthChecksum:		resw 1	; sum of all words in trailer header = 0
    52                              <2> 	endstruc
    53                              <2> 	endarea ELD_TRAILER_HEADER, 1
    54                              <2> 
    55                              <2> 	struc ELD_LIBTABLE
    56 00000000 ????                <2> eldltFormat:		resw 1
    57                              <2> 	; 0 = uncompressed
    58                              <2> 	; 2 = heatshrink compressed
    59                              <2> 	; 3 = lzexedat -4 compressed
    60                              <2> 	; 4 = lzexedat -4 -l compressed
    61 00000002 ????                <2> eldltAmount:		resw 1
    62 00000004 ????????            <2> eldltOffset:		resd 1	; from eldhxHeader
    63                              <2> eldltCompressedLength:		; (dword, only present if format 2, 3, or 4)
    64                              <2> 	endstruc
    65                              <2> 	endarea ELD_LIBTABLE, 1
    66                              <2> 
    67                              <2> 		; ELD instance header
    68                              <2> 	struc ELD_INSTANCE
    69 00000000 ????                <2> eldiStartCode:		resw 1	; -> this structure itself (para aligned)
    70 00000002 ????                <2> eldiEndCode:		resw 1	; -> behind memory used by instance (para aligned)
    71 00000004 ????                <2> eldiStartData:		resw 1	; -> data in data entry section (para aligned), or 0
    72 00000006 ????                <2> eldiEndData:		resw 1	; -> behind data (para aligned), or 0
    73 00000008 ????????????????    <2> eldiIdentifier:		resb 8	; blank-filled text
    74 00000010 ????                <2> eldiFlags:		resw 1	; flags
    75                              <2> eldiListing_size equ 14
    76 00000012 <res Eh>            <2> eldiListing:		resb eldiListing_size
    77                              <2> 				; ASCIZ listing file name
    78                              <2> 	endstruc
    79                              <2> 		; flags for eldiFlags:
    80                              <2> eldifResident:		equ 1
    81                              <2> 
    82                              <2> 		; ELD link info header
    83                              <2> 	struc ELD_LINKINFO
    84 00000000 ????                <2> eldlSignature:		resw 1	; 0E1D1h
    85 00000002 ????????            <2> eldlReserved:		resw 2
    86 00000006 ????                <2> eldlUseLinkHash:	resw 1
    87 00000008 ????                <2> eldlDataAmount:		resw 1
    88 0000000A ????                <2> eldlDataPrefixes:	resw 1
    89 0000000C ????                <2> eldlDataEntries:	resw 1
    90 0000000E ????                <2> eldlDataAddresses:	resw 1
    91 00000010 ????                <2> eldlCodeAmount:		resw 1
    92 00000012 ????                <2> eldlCodePrefixes:	resw 1
    93 00000014 ????                <2> eldlCodeEntries:	resw 1
    94 00000016 ????                <2> eldlCodeAddresses:	resw 1
    95                              <2> 	endstruc
    96                              <2> 
    97                              <2> 	numdef ELD_CODE_VSTART, 9001h
    98                              <2> 	numdef ELD_DATA_VSTART, 8000h
    99                              <2> 	numdef ELD_RELOC_VSTART, 8000h
   100                              <2> 
   101                              <2> 	numdef ELD_RECLAIM_HINT, 0
   102                              <2> 	strdef ELD_LISTING, ""
   103                              <2> 	numdef ELD_DATETIME, 0
   104                              <2> 
   105                              <2> %if _ELD_DATETIME
   106                              <2>  %define PUT_ELDHX_DATETIME_OFFSET at eldhxDateTimeOffset, dd DATAOFFSET + datetime - datastart
   107                              <2>  %macro PUT_ELD_DATETIME 0.nolist
   108                              <2> datetime:	asciz __UTC_DATE__,'T',__UTC_TIME__,'Z'
   109                              <2> 		asciz		; for future extension
   110                              <2>  %endmacro
   111                              <2> %else
   112                              <2>  %define PUT_ELDHX_DATETIME_OFFSET
   113                              <2>  %define PUT_ELD_DATETIME
   114                              <2> %endif
   115                              <2> 
   116                              <2> %endif
   716                              <1> 
   717                              <1> %include "install.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug INSTALL command macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2023 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 	struc INSTALLFLAG
    17 00000000 ????                <2> ifKeyword:	resw 1
    18 00000002 ????                <2> ifDescription:	resw 1
    19 00000004 ????                <2> ifOptions:	resw 1
    20 00000006 ????                <2> ifValue:	resw 1
    21 00000008 ????                <2> ifTrying:	resw 1
    22 0000000A ????                <2> ifReserved:	resw 1
    23                              <2> 	endstruc
    24                              <2> 
   718                              <1> 
   719                              <1> %if _SYMBOLIC
   720                              <1> 	defaulting 0			; disable defaulting
   721                              <1> %include "symbols.mac"
   722                              <1> [list -]
   723                              <1> 		; symbolic branch defines *without* defaulting!
   724                              <1> 	numdef ZZ_INSERT_TEMP, 1
   725                              <1> 	numdef XMS_SYMBOL_TABLE, 1
   726                              <1> 	numdef BUFFER_86MM_SLICE, 0
   727                              <1> 	numdef SECOND_SLICE, 0
   728                              <1> 
   729                              <1> 	defaulting 1			; re-enable defaulting
   730                              <1> 
   731                              <1> 		; symbolic branch defines
   732                              <1> 	numdef 86MM_SYMBOL_TABLE_MAX, 256, 256
   733                              <1> %endif
   734                              <1> 
   735                              <1> 	struc SEGADR
   736 00000000 ????????            <1> saOffset:	resd 1
   737 00000004 ????                <1> saSegSel:	resw 1
   738                              <1> %if _PM
   739                              <1> saSegment:	resw 1
   740                              <1> saSelector:	resw 1
   741                              <1> %endif
   742                              <1> 	endstruc
   743                              <1> 
   744                              <1> 	%macro segmentedaddress 0.nolist
   745                              <1> 	istruc SEGADR
   746                              <1> 	iend
   747                              <1> 	%endmacro
   748                              <1> 
   749                              <1> 	struc SEGOFS16ADR
   750 00000000 ????                <1> so16aOffset:	resw 1
   751 00000002 ????                <1> so16aSegSel:	resw 1
   752                              <1> %if _PM
   753                              <1> so16aSegment:	resw 1
   754                              <1> so16aSelector:	resw 1
   755                              <1> %endif
   756                              <1> 	endstruc
   757                              <1> 
   758                              <1> 	%macro segofs16address 0-1.nolist zero
   759                              <1> 	istruc SEGOFS16ADR
   760                              <1> %ifidni %1,zero
   761                              <1> %elifidni %1,minusone
   762                              <1> at so16aOffset,		dw -1
   763                              <1> at so16aSegSel,		dw -1
   764                              <1>  %if _PM
   765                              <1> at so16aSegment,	dw -1
   766                              <1> at so16aSelector,	dw -1
   767                              <1>  %endif
   768                              <1> %else
   769                              <1>  %error Unexpected initialiser keyword
   770                              <1> %endif
   771                              <1> 	iend
   772                              <1> 	%endmacro
   773                              <1> 
   774                              <1> 	struc SEGONLYADR
   775 00000000 ????                <1> soaSegSel:	resw 1
   776                              <1> %if _PM
   777                              <1> soaSegment:	resw 1
   778                              <1> soaSelector:	resw 1
   779                              <1> %endif
   780                              <1> 	endstruc
   781                              <1> 
   782                              <1> 	%macro segonlyaddress 0.nolist
   783                              <1> 	istruc SEGONLYADR
   784                              <1> 	iend
   785                              <1> 	%endmacro
   786                              <1> 
   787                              <1> 
   788                              <1> %if _LOADER
   789                              <1> 	struc MOVETABLEENTRY
   790                              <1> mteIdentifier:		resw 1
   791                              <1> mteArrayIndex:		resw 1
   792                              <1> mteStatusMessage:	resw 1
   793                              <1> mteFromArray:
   794                              <1> mteFromBottom:		resw 1
   795                              <1> mteFromTop:		resw 1
   796                              <1> mteFromHidden:		resw 1
   797                              <1> 	endstruc
   798                              <1> %endif
   799                              <1> 
   800                              <1> %if _BOOTLDR
   801                              <1>  %include "iniload.mac"
     1                              <2> %if 0
     2                              <2> 
     3                              <2> lDebug iniload/boot interfacing structs and macros
     4                              <2> 
     5                              <2> Copyright (C) 2008-2025 E. C. Masloch
     6                              <2> 
     7                              <2> Usage of the works is permitted provided that this
     8                              <2> instrument is retained with the works, so that any entity
     9                              <2> that uses the works is notified of this instrument.
    10                              <2> 
    11                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    12                              <2> 
    13                              <2> %endif
    14                              <2> 
    15                              <2> 
    16                              <2> 	struc BS
    17 00000000 ??????              <2> bsJump:	resb 3
    18 00000003 ????????????????    <2> bsOEM:	resb 8
    19                              <2> bsBPB:
    20                              <2> 	endstruc
    21                              <2> 
    22                              <2> 	struc EBPB		;        BPB sec
    23 00000000 ????                <2> bpbBytesPerSector:	resw 1	; offset 00h 0Bh
    24 00000002 ??                  <2> bpbSectorsPerCluster:	resb 1	; offset 02h 0Dh
    25 00000003 ????                <2> bpbReservedSectors:	resw 1	; offset 03h 0Eh
    26 00000005 ??                  <2> bpbNumFATs:		resb 1	; offset 05h 10h
    27 00000006 ????                <2> bpbNumRootDirEnts:	resw 1	; offset 06h 11h -- 0 for FAT32
    28 00000008 ????                <2> bpbTotalSectors:	resw 1	; offset 08h 13h
    29 0000000A ??                  <2> bpbMediaID:		resb 1	; offset 0Ah 15h
    30 0000000B ????                <2> bpbSectorsPerFAT:	resw 1	; offset 0Bh 16h -- 0 for FAT32
    31 0000000D ????                <2> bpbCHSSectors:		resw 1	; offset 0Dh 18h
    32 0000000F ????                <2> bpbCHSHeads:		resw 1	; offset 0Fh 1Ah
    33 00000011 ????????            <2> bpbHiddenSectors:	resd 1	; offset 11h 1Ch
    34 00000015 ????????            <2> bpbTotalSectorsLarge:	resd 1	; offset 15h 20h
    35                              <2> bpbNew:				; offset 19h 24h
    36                              <2> 
    37 00000019 ????????            <2> ebpbSectorsPerFATLarge:	resd 1	; offset 19h 24h
    38 0000001D ????                <2> ebpbFSFlags:		resw 1	; offset 1Dh 28h
    39 0000001F ????                <2> ebpbFSVersion:		resw 1	; offset 1Fh 2Ah
    40 00000021 ????????            <2> ebpbRootCluster:	resd 1	; offset 21h 2Ch
    41 00000025 ????                <2> ebpbFSINFOSector:	resw 1	; offset 25h 30h
    42 00000027 ????                <2> ebpbBackupSector:	resw 1	; offset 27h 32h
    43 00000029 <res Ch>            <2> ebpbReserved:		resb 12	; offset 29h 34h
    44                              <2> ebpbNew:			; offset 35h 40h
    45                              <2> 	endstruc
    46                              <2> 
    47                              <2> 	struc BPBN		; ofs B16 S16 B32 S32
    48 00000000 ??                  <2> bpbnBootUnit:		resb 1	; 00h 19h 24h 35h 40h
    49 00000001 ??                  <2> 			resb 1	; 01h 1Ah 25h 36h 41h
    50 00000002 ??                  <2> bpbnExtBPBSignature:	resb 1	; 02h 1Bh 26h 37h 42h -- 29h for valid BPBN
    51 00000003 ????????            <2> bpbnSerialNumber:	resd 1	; 03h 1Ch 27h 38h 43h
    52 00000007 <res Bh>            <2> bpbnVolumeLabel:	resb 11	; 07h 20h 2Bh 3Ch 47h
    53 00000012 ????????????????    <2> bpbnFilesystemID:	resb 8	; 12h 2Bh 36h 47h 52h
    54                              <2> 	endstruc		; 1Ah 33h 3Eh 4Fh 5Ah
    55                              <2> 
    56                              <2> 	struc DIRENTRY
    57 00000000 ????????????????    <2> deName:		resb 8
    58 00000008 ??????              <2> deExt:		resb 3
    59 0000000B ??                  <2> deAttrib:	resb 1
    60 0000000C ??                  <2> dePlusSize:	resb 1
    61 0000000D ??????????????      <2> 		resb 7
    62 00000014 ????                <2> deClusterHigh:	resw 1
    63 00000016 ????                <2> deTime:		resw 1
    64 00000018 ????                <2> deDate:		resw 1
    65 0000001A ????                <2> deClusterLow:	resw 1
    66 0000001C ????????            <2> deSize:		resd 1
    67                              <2> 	endstruc
    68                              <2> 
    69                              <2> ATTR_READONLY	equ 1
    70                              <2> ATTR_HIDDEN	equ 2
    71                              <2> ATTR_SYSTEM	equ 4
    72                              <2> ATTR_VOLLABEL	equ 8
    73                              <2> ATTR_DIRECTORY	equ 10h
    74                              <2> ATTR_ARCHIVE	equ 20h
    75                              <2> 
    76                              <2> lsvclSignature		equ "CL"
    77                              <2> lsvclBufferLength	equ 256
    78                              <2> 
    79                              <2> 	struc LOADSTACKVARS, -10h
    80 FFFFFFF0 ????????            <2> lsvFirstCluster:	resd 1
    81 FFFFFFF4 ????????            <2> lsvFATSector:		resd 1
    82 FFFFFFF8 ????                <2> lsvFATSeg:		resw 1
    83 FFFFFFFA ????                <2> lsvLoadSeg:		resw 1
    84 FFFFFFFC ????????            <2> lsvDataStart:		resd 1
    85                              <2> 	endstruc
    86                              <2> 
    87                              <2> 	struc LOADDATA, LOADSTACKVARS - 10h
    88 FFFFFFE0 ????                <2> ldMemoryTop:	resw 1
    89 FFFFFFE2 ????                <2> ldLoadTop:	resw 1
    90 FFFFFFE4 ????                <2> ldSectorSeg:	resw 1
    91 FFFFFFE6 ??                  <2> ldFATType:	resb 1
    92                              <2> ldFlags:
    93 FFFFFFE7 ??                  <2> ldHasLBA:	resb 1
    94 FFFFFFE8 ????                <2> ldClusterSize:	resw 1
    95 FFFFFFEA ????                <2> ldParaPerSector:resw 1
    96                              <2> ldDirCluster:			; dword
    97                              <2> ldLoadingSeg:		; word
    98                              <2> ldQueryPatchValue:	; word
    99                              <2> lsvCommandLine:		; word
   100                              <2> .start:		equ $ - lsvclBufferLength
   101 FFFFFFEC ????                <2> .signature:	resw 1
   102                              <2> ldLoadUntilSeg:		; word
   103                              <2> lsvExtra:		; word
   104 FFFFFFEE ??                  <2> .partition:	resb 1	; byte
   105 FFFFFFEF ??                  <2> .flags:		resb 1	; byte
   106                              <2> 	endstruc
   107                              <2> 
   108                              <2> ldhlfPreserveLoader	equ 4
   109                              <2> 
   110                              <2> lsvefNoDataStart	equ 1
   111                              <2> lsvefPartitionNumber	equ 2
   112                              <2> lsvefPreserveLoader	equ 4
   113                              <2> 
   114                              <2> %if lsvefPreserveLoader != ldhlfPreserveLoader
   115                              <2>  %error Unexpected flag values
   116                              <2> %endif
   117                              <2> 
   118                              <2> 	struc LOADCMDLINE, LOADDATA - lsvclBufferLength
   119                              <2> ldCommandLine:
   120 FFFFFEE0 <res 100h>          <2> .start:		resb lsvclBufferLength
   121                              <2> 	endstruc
   122                              <2> 
   123                              <2> ldfHasLBA:	equ 1
   124                              <2> ldfFATInvalid:	equ 2
   125                              <2> ldfFATBuffered:	equ 4
   126                              <2> ldfDataBuffered: equ 8
   127                              <2> 
   128                              <2> 	struc LOADDATA2, LOADDATA - 10h
   129 FFFFFFD0 ????????            <2> ldRootSector:		resd 1
   130 FFFFFFD4 ????                <2> ldEntriesPerSector:	resw 1
   131                              <2> ldDataSegment:		; word
   132 FFFFFFD6 ????                <2> ldLastAvailableSector:	resw 1
   133                              <2> ldDataSector:		; dword
   134 FFFFFFD8 ????                <2> ldParasLeft:		resw 1
   135 FFFFFFDA ????                <2> ldParasDone:		resw 1
   136                              <2> 	endstruc
   137                              <2> 
   138                              <2> 	struc LOADDATA3, LOADDATA2 - 10h
   139 FFFFFFC0 ????????            <2> ldMaxCluster:		resd 1
   140 FFFFFFC4 ????????            <2> ldFileSize:		resd 1
   141 FFFFFFC8 ????????            <2> ldCurrentCluster:	resd 1
   142 FFFFFFCC ????????            <2> ldCurrentSeek:		resd 1
   143                              <2> 	endstruc
   144                              <2> 
   145                              <2> 	struc LOADERIMAGEIDENT
   146 00000000 ????????            <2> liiSignature:		resb 4		; "NLDR"
   147 00000004 ????                <2> liiVersion:		resb 2		; "00"
   148 00000006 ????                <2> liiChecksum:		resw 1		; word sum of first 8 words = 0
   149 00000008 ????                <2> liiAmountParagraphs:	resw 1
   150 0000000A ????????????        <2> liiReserved:		resw 3
   151 00000010 ????                <2> liiEntryQuerySize:	resw 1		; 0 if not supported
   152                              <2> 		; INP:	cs => NLDR image ident
   153                              <2> 		;	ip = this word field content
   154                              <2> 		;	ax = 60h
   155                              <2> 		; OUT:	ax => behind memory requested (should be >= 60h)
   156                              <2> 		; CHG:	es, ds, di, si, bx, cx, dx
   157                              <2> 		; STT:	far called, UP, EI
   158 00000012 ????                <2> liiEntryRelocate:	resw 1		; 0 if not supported
   159                              <2> 		; INP:	cs => NLDR image ident
   160                              <2> 		;	ip = this word field content
   161                              <2> 		;	ax = 60h
   162                              <2> 		; OUT:	ax => relocated NLDR segment (usually 60h)
   163                              <2> 		; CHG:	es, ds, di, si, bx, cx, dx
   164                              <2> 		; STT:	far called, UP, EI
   165 00000014 ????                <2> liiEntryDebug:		resw 1		; 0 if not supported
   166                              <2> 		; INP:	es = ds = cs = ss => relocated NLDR
   167                              <2> 		;	ip = this word field content
   168                              <2> 		;	sp = next word field content
   169                              <2> 		; STT:	running as debuggee, UP, EI
   170 00000016 ????                <2> liiStackPointer:	resw 1
   171                              <2> 	endstruc
   172                              <2> 
   173                              <2> 	struc LBAPACKET
   174 00000000 ????                <2> lpSize:		resw 1
   175 00000002 ????                <2> lpCount:	resw 1
   176 00000004 ????????            <2> lpBuffer:	resd 1
   177 00000008 ????????????????    <2> lpSector:	resq 1
   178                              <2> 	endstruc
   179                              <2> 
   180                              <2> 	struc PARTINFO
   181 00000000 ??                  <2> piBoot:		resb 1
   182 00000001 ??????              <2> piStartCHS:	resb 3
   183 00000004 ??                  <2> piType:		resb 1
   184 00000005 ??????              <2> piEndCHS:	resb 3
   185 00000008 ????????            <2> piStart:	resd 1
   186 0000000C ????????            <2> piLength:	resd 1
   187                              <2> 	endstruc
   188                              <2> 
   189                              <2> ptEmpty:		equ 0
   190                              <2> ptFAT12:		equ 1
   191                              <2> ptFAT16_16BIT_CHS:	equ 4
   192                              <2> ptExtendedCHS:		equ 5
   193                              <2> ptFAT16_CHS:		equ 6
   194                              <2> ptFAT32_CHS:		equ 0Bh
   195                              <2> ptFAT32:		equ 0Ch
   196                              <2> ptFAT16:		equ 0Eh
   197                              <2> ptExtended:		equ 0Fh
   198                              <2> ptLinux:		equ 83h
   199                              <2> ptExtendedLinux:	equ 85h
   200                              <2> 
   201                              <2> 
   202                              <2> 		; Flags of load_unit_flags
   203                              <2> lufForceCHS:		equ 1
   204                              <2> lufForceLBA:		equ 2
   205                              <2> lufForceGeometry:	equ 4
   206                              <2> luf_mask_writable equ lufForceCHS | lufForceLBA | lufForceGeometry
   802                              <1> 
   803                              <1> LOAD_INPUT_FILE_SIZE equ fromparas(paras(-LOADDATA3 + bsBPB + ebpbNew + BPBN_size))
   804                              <1> 
   805                              <1> 	struc LOADSETTINGS
   806 00000000 ????                <1> lsKernelName:	resw 1	; -> kernel file default name
   807 00000002 ????                <1> lsAddName:	resw 1	; -> additional file default name, may be empty string
   808 00000004 ????                <1> lsMinPara:	resw 1	; how much to load at least, fail if file smaller
   809 00000006 ????                <1> lsMaxPara:	resw 1	; how much to load at most (will round up to sector size)
   810 00000008 ????                <1> lsOptions:	resw 1	; option flags
   811 0000000A ????                <1> lsSegment:	resw 1	; => where to load file
   812 0000000C ????????            <1> lsEntry:	resd 1	; relative segment for CS, value for IP
   813 00000010 ????????            <1> lsBPB:		resd 1	; segment for BPB (-1 auto-BPB), offset for BPB
   814 00000014 ????                <1> lsCheckOffset:	resw 1	; offset in file segment of word to check
   815 00000016 ????                <1> lsCheckValue:	resw 1	; value to check for word, 0 if unused
   816 00000018 ????????????????    <1> lsName:		resq 1	; ASCIZ load protocol name
   817                              <1> 	endstruc
   818                              <1> 
   819                              <1> 		numdef LUF_DEFAULT_DISKETTE, 0
   820                              <1> 		numdef LUF_DEFAULT_HARDDISK, 0
   821                              <1> %endif
   822                              <1> 
   823                              <1> 
   824                              <1> %include "mzheader.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug MZ .EXE header macros
     5                              <2> 
     6                              <2> Copyright (C) 1995-2003 Paul Vojta
     7                              <2> Copyright (C) 2008-2023 E. C. Masloch
     8                              <2> 
     9                              <2> Usage of the works is permitted provided that this
    10                              <2> instrument is retained with the works, so that any entity
    11                              <2> that uses the works is notified of this instrument.
    12                              <2> 
    13                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    14                              <2> 
    15                              <2> %endif
    16                              <2> 
    17                              <2> 
    18                              <2> 	struc EXEHEADER
    19 00000000 ????                <2> exact_struc_at 00h, exeSignature:	resw 1
    20 00000002 ????                <2> exact_struc_at 02h, exeExtraBytes:	resw 1	; bytes in last page
    21 00000004 ????                <2> exact_struc_at 04h, exePages:		resw 1	; number of 512-byte pages. includes the header!
    22 00000006 ????                <2> exact_struc_at 06h, exeRelocItems:	resw 1	; number of relocation items
    23 00000008 ????                <2> exact_struc_at 08h, exeHeaderSize:	resw 1	; header size in 16-byte paragraphs
    24 0000000A ????                <2> exact_struc_at 0Ah, exeMinAlloc:	resw 1	; minimum (bss) allocation in paragraphs
    25 0000000C ????                <2> exact_struc_at 0Ch, exeMaxAlloc:	resw 1	; maximum (bss) allocation in paragraphs
    26 0000000E ????                <2> exact_struc_at 0Eh, exeInitSS:		resw 1	; init ss (is relocated)
    27 00000010 ????                <2> exact_struc_at 10h, exeInitSP:		resw 1	; init sp
    28 00000012 ????                <2> exact_struc_at 12h, exeChecksum:	resw 1
    29                              <2> exact_struc_at 14h, exeInitCSIP:
    30 00000014 ????                <2> exact_struc_at 14h, exeInitIP:		resw 1	; init ip
    31 00000016 ????                <2> exact_struc_at 16h, exeInitCS:		resw 1	; init cs (is relocated)
    32 00000018 ????                <2> exact_struc_at 18h, exeRelocTable:	resw 1	; byte offset of relocation table
    33                              <2> 		; Each relocation item is a word offset and a word segment.
    34                              <2> 		;  The segment of the item itself is relocated as well.
    35 0000001A ????                <2> exact_struc_at 1Ah, exeOverlayNum:	resw 1
    36                              <2> exact_struc_at 1Ch
    37                              <2> 	endstruc
   825                              <1> 
   826                              <1> 
   827                              <1> 	struc INPUTFILEHANDLE
   828 00000000 ????                <1> ifhHandle:	resw 1
   829 00000002 ????                <1> ifhFlags:	resw 1
   830 00000004 ????????            <1> ifhParentSeek:	resd 1
   831                              <1> 	endstruc
   832                              <1> 
   833                              <1> ifhfIsDup:		equ  100h	; before closing, seek it back
   834                              <1> 	; same value as LBA flag for boot load input files
   835                              <1> ifhfTestReserved1:	equ 1000h
   836                              <1> ifhfTestReserved2:	equ 2000h
   837                              <1> ifhfQuietInput:		equ 4000h	; do not display prompt and input
   838                              <1> ifhfQuietOutput:	equ 8000h	; do not display normal output
   839                              <1> 	; these four are valid for both input file handles and
   840                              <1> 	;  boot load input files.
   841                              <1> 
   842                              <1> 
   843                              <1> 	struc AREASTRUC
   844 00000000 <res 18h>           <1> areastrucEntry:		resb 24
   845 00000018 ????????            <1> areastrucNext:		resd 1
   846 0000001C ????????            <1> areastrucPrev:		resd 1
   847 00000020 ????                <1> areastrucSubAmount:	resw 1
   848 00000022 ????                <1> areastrucSubOffset:	resw 1
   849 00000024 ????                <1> areastrucFunAmount:	resw 1
   850 00000026 ????                <1> areastrucFunOffset:	resw 1
   851                              <1> 	endstruc
   852                              <1> 
   853                              <1> 	struc AREASTRUCSUB
   854 00000000 ????????            <1> areastrucsubLinear:	resd 1
   855 00000004 ????????            <1> areastrucsubLinearEnd:	resd 1
   856 00000008 ????                <1> areastrucsubListOffset:	resw 1
   857 0000000A ????                <1> areastrucsubListAmount:	resw 1
   858                              <1> 	endstruc
   859                              <1> 
   860                              <1> 	struc AREASTRUCFUN
   861 00000000 ????????            <1> areastrucfunLinear:	resd 1
   862 00000004 ????????            <1> areastrucfunLinearEnd:	resd 1
   863 00000008 ????                <1> areastrucfunListOffset:	resw 1
   864 0000000A ????                <1> areastrucfunListAmount:	resw 1
   865                              <1> 	endstruc
   866                              <1> 
   867                              <1> 	struc AREA
   868 00000000 ????                <1> areastart:		resw 1
   869 00000002 ????                <1> areaend:		resw 1
   870 00000004 ????                <1> areamessage:		resw 1
   871 00000006 ????                <1> 			resw 1
   872                              <1> 	endstruc
   873                              <1> 
   874                              <1> 
   875                              <1> %include "isvariab.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug isvariable? function strutures and macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2025 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 
    17                              <2> 	struc ISVARIABLESTRUC
    18 00000000 ????                <2> ivName:		resw 1		; -> name (up to 13 bytes, but actually only 11)
    19                              <2> 				;  (search for ivfNameLengthLimit for limit)
    20                              <2> 				;  (length given by ivFlags & ivfNameLengthMask)
    21                              <2> 	; The ivName pointer is only used for more-byte names. It actually
    22                              <2> 	;  contains the trailer of the name, excluding the prefix formed by
    23                              <2> 	;  the first two bytes. This suffix can be the empty string if the
    24                              <2> 	;  variable in question has a two-byte name.
    25                              <2> 	; (For one-byte names this field is unused and contains zero.)
    26 00000002 ????                <2> ivFlags:	resw 1
    27 00000004 ????                <2> ivAddress:	resw 1		; default -> variable
    28                              <2> 	; The ivAddress field is used by default_variable_setup as the base
    29                              <2> 	;  address for the variable(s). It is also used by var_ext_setup as
    30                              <2> 	;  the ELD code section offset to transfer control to. Otherwise, it
    31                              <2> 	;  is usually set to zero and unused.
    32 00000006 ????                <2> ivSetup:	resw 1		; -> set up code (in expr code section)
    33                              <2> 	; INP:	ax = array index (0-based)
    34                              <2> 	;	di = 0
    35                              <2> 	;	cl = default size of variable (1..4)
    36                              <2> 	;	ch = length of variable name
    37                              <2> 	;	bx -> ISVARIABLESTRUC structure
    38                              <2> 	; CHG:	ax, bx, cx, dx, si, di
    39                              <2> 	; OUT:	NC if valid,
    40                              <2> 	;	 bx -> var, di = 0 or di -> mask
    41                              <2> 	;	 cl = size of variable (1..4)
    42                              <2> 	;	 ch = length of variable name
    43 00000008 ??                  <2> ivArrayLast:	resb 1		; 0 if no array, FFh = 256 entries
    44                              <2> 	; The ivArrayLast field is used by the dispatcher to determine
    45                              <2> 	;  whether to support array index expressions. It is checked
    46                              <2> 	;  before decrementing the index if ivfArrayOneBased is set.
    47 00000009 ??                  <2> ivArrayBetween: resb 1		; how many bytes to skip for each index
    48                              <2> 	; The ivArrayBetween field is only used by default_variable_setup.
    49                              <2> 	endstruc
    50                              <2> 
    51                              <2> ivfNameLengthMask:	equ 15	; gives name trailer length, 0 to 11
    52                              <2> ivfNameLengthLimit:	equ 13
    53                              <2> ivfVarLengthShift:	equ 4
    54                              <2> ivfVarLengthMask:	equ 3 << ivfVarLengthShift
    55                              <2> 				; gives default variable size minus 1
    56                              <2> ivfReadOnly:		equ 80h	; variable cannot be written at all
    57                              <2> ivfArrayOneBased:	equ 100h; first array entry is 1 not 0 (ivArrayLast > 0)
    58                              <2> ivfArrayOptional:	equ 200h; array index expression is optional
    59                              <2> ivfSeparatorSpecial:	equ 400h; used for RIxxP/L/S/O
    60                              <2> 
    61                              <2> %define ISVARIABLESTRINGS db "",db ""
    62                              <2> %define IVS_ONEBYTE_NAMES ""
    63                              <2> %define IVS_MOREBYTE_NAMEHEADERS ""
    64                              <2> %assign IVS_HAVE_ONEBYTE 0
    65                              <2> %assign IVS_SINGLE_ONEBYTE 1
    66                              <2> 
    67                              <2> 		; %1 = name string
    68                              <2> 		; %2 = default variable length, 1 to 4
    69                              <2> 		; %3 = flags to set (except name length and var length)
    70                              <2> 		; %4 = ivAddress value
    71                              <2> 		; %5 = ivArrayLast, defaults to 0 (no array)
    72                              <2> 		; %6 = ivArrayBetween, defaults to 0 (immediately consecutive)
    73                              <2> 		; %7 = ivSetup, defaults to default_variable_setup
    74                              <2> 	%macro isvariablestruc 4-7.nolist 0, 0, default_variable_setup
    75                              <2> %push
    76                              <2> %strlen %$namelength %1
    77                              <2> %if %$namelength > ivfNameLengthLimit
    78                              <2>  %error Expected at most 13-byte name (or adjust isvariable? code)
    79                              <2> %endif
    80                              <2> %if IVS_ONEBYTE && %$namelength != 1
    81                              <2>  %error Expected a one-byte name
    82                              <2> %elif ! IVS_ONEBYTE && %$namelength < 2
    83                              <2>  %error Expected at least a two-byte name
    84                              <2> %endif
    85                              <2> %if IVS_ONEBYTE
    86                              <2>  %define IVS_SINGLE_ONEBYTE_NAME %1
    87                              <2>  %if IVS_HAVE_ONEBYTE
    88                              <2>   %assign IVS_SINGLE_ONEBYTE 0
    89                              <2>  %endif
    90                              <2>  %assign IVS_HAVE_ONEBYTE 1
    91                              <2>  %assign %$namelength 0
    92                              <2>  %xdefine IVS_ONEBYTE_NAMES IVS_ONEBYTE_NAMES, %1
    93                              <2>  %%name equ 0
    94                              <2> %else
    95                              <2>  %assign %$namelength %$namelength - 2
    96                              <2>  %substr %$nametrailer %1 3,-1
    97                              <2>  %substr %$nameheader %1 1,2
    98                              <2>  %xdefine IVS_MOREBYTE_NAMEHEADERS IVS_MOREBYTE_NAMEHEADERS, %$nameheader
    99                              <2>  %xdefine ISVARIABLESTRINGS ISVARIABLESTRINGS, %%name:, {db %$nametrailer}
   100                              <2> %endif
   101                              <2> 
   102                              <2> %assign %$varlength %2 - 1	; 0 means one byte, 1 means two bytes,
   103                              <2> 				;  2 means three bytes, 3 means four bytes
   104                              <2> 	istruc ISVARIABLESTRUC
   105                              <2> at ivName,		dw %%name
   106                              <2>  IV_NAME_RELOCATION
   107                              <2> at ivFlags,		dw %$$namelength | (%$$varlength << ivfVarLengthShift) | %3
   108                              <2> at ivAddress,		dw %4
   109                              <2>  IV_ADDRESS_RELOCATION
   110                              <2> at ivSetup,		dw %7
   111                              <2>  IV_SETUP_RELOCATION
   112                              <2> at ivArrayLast,		db %5
   113                              <2> at ivArrayBetween,	db %6
   114                              <2> 	iend
   115                              <2> %pop
   116                              <2> %ifndef SECTION_OF_%7
   117                              <2>  %error Unknown target section for symbol %7
   118                              <2> %elifnidni %[SECTION_OF_%7], _EXPR_SECTION
   119                              <2>  %error Wrong section for symbol %7: section_of=SECTION_OF_%7, expr=_EXPR_SECTION
   120                              <2> %endif
   121                              <2> 	%endmacro
   122                              <2> 
   123                              <2> %define IV_NAME_RELOCATION
   124                              <2> %define IV_ADDRESS_RELOCATION
   125                              <2> %define IV_SETUP_RELOCATION
   126                              <2> 
   127                              <2> 	%macro isvariablestrings 2-*.nolist
   128                              <2> %rep %0
   129                              <2>  %1
   130                              <2>  %rotate 1
   131                              <2> %endrep
   132                              <2> 	%endmacro
   876                              <1> 
   877                              <1> 
   878                              <1> %include "386.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug 386 patch macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2026 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 	numdef LINK, 0
    17                              <2> 
    18                              <2> 	numdef WPT_LABELS, 0
    19                              <2> 		; This used to be required, because CODESECTIONFIXUP used
    20                              <2> 		;  ldebug_data_entry_size, which is not yet defined during
    21                              <2> 		;  assembling of (most) lDEBUG_CODE fragments.
    22                              <2> 		; However, assembling DebugX with this option selected
    23                              <2> 		;  took more than 2 minutes, so the non-label variant
    24                              <2> 		;  is clearly to be preferred when available.
    25                              <2> 		; Now that lDEBUG_CODE has vstart=0 we can use the
    26                              <2> 		;  CODESECTIONFIXUP again and thus disable this option.
    27                              <2> 
    28                              <2> %ifn _LINK
    29                              <2> %define PATCH_NO386_TABLE ""
    30                              <2> %define PATCH_386_TABLE ""
    31                              <2> %define PATCH_NO386_TABLE2 ""
    32                              <2> %define PATCH_386_TABLE2 ""
    33                              <2> %define PATCH_NO386_TABLEENTRY ""
    34                              <2> %define PATCH_386_TABLEENTRY ""
    35                              <2> %endif
    36                              <2> 
    37                              <2> %if _ONLY386
    38                              <2> 		; Default patch macros if only running on 386+.
    39                              <2> %define _386_o32 o32
    40                              <2> %define _386_a32 a32
    41                              <2> %define _386_jmps jmp short
    42                              <2> %define _386_jmpn jmp near
    43                              <2> %define _no386_jmps comment
    44                              <2> %define _no386_jmpn comment
    45                              <2> 	%macro _386 0-1+.nolist
    46                              <2> [cpu 386]			; change CPU type
    47                              <2> 		%1		; write instruction
    48                              <2> __CPU__				; reset CPU type
    49                              <2> 	%endmacro
    50                              <2> %define _no386 comment
    51                              <2> %elif _ONLYNON386
    52                              <2> 		; Default patch macros if only running on non-386.
    53                              <2> %define _386_o32
    54                              <2> %define _386_a32
    55                              <2> %define _386_jmps comment
    56                              <2> %define _386_jmpn comment
    57                              <2> %define _no386_jmps jmp short
    58                              <2> %define _no386_jmpn jmp near
    59                              <2> %define _386 comment
    60                              <2> %define _no386
    61                              <2> %else
    62                              <2> 
    63                              <2> ; These macros are to make DEBUG's 386 support as small as
    64                              <2> ; possible. To achieve this, two patch tables are created
    65                              <2> ; in the initialisation code. One of the tables is used if
    66                              <2> ; the CPU is a 386+, the other one if it isn't. The bytes
    67                              <2> ; pointed to in the used table are over-written with NOP
    68                              <2> ; instructions. (The patched bytes are usually address or
    69                              <2> ; operand size prefixes or jumps that branch to 386/non-386
    70                              <2> ; code.)
    71                              <2> 
    72                              <2> ; There are a few special patches that require the
    73                              <2> ; initialisation code to write specific bytes other than
    74                              <2> ; NOP instructions for lower resident memory usage.
    75                              <2> ; Two are in the run: code, three in pmentry.asm.
    76                              <2> 
    77                              <2> %if _LINK
    78                              <2> 
    79                              <2> %imacro wllist 1-3.nolist
    80                              <2> %ifnempty %3
    81                              <2>  %deftok %%filenametoken %3
    82                              <2> %else
    83                              <2>  %deftok %%filenametoken __FILE__
    84                              <2> %endif
    85                              <2>  global ..@wllist_%1?%[%%l]%[%%filenametoken]
    86                              <2> ..@wllist_%1?%[%%l]%[%%filenametoken]: %2
    87                              <2> %endmacro
    88                              <2> 
    89                              <2> 	%macro patch386 2-3.nolist 1
    90                              <2> %define %%repeat
    91                              <2> %if %3 != 1
    92                              <2>  %define %%repeat r%3_
    93                              <2> %endif
    94                              <2> %ifidn _CURRENT_SECTION, lDEBUG_CODE
    95                              <2>  wllist %[%%repeat]Lpatch_%{1}386_table, %2
    96                              <2> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
    97                              <2>  wllist %[%%repeat]Lpatch_%{1}386_table2, %2
    98                              <2> %elifidn _CURRENT_SECTION, lDEBUG_DATA_ENTRY
    99                              <2>  wllist %[%%repeat]Lpatch_%{1}386_tableentry, %2
   100                              <2> %else
   101                              <2>  %error Wrong section
   102                              <2> %endif
   103                              <2> 	%endmacro
   104                              <2> 
   105                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   106                              <2> 	%macro _386_o32 0-1+.nolist
   107                              <2> _386		o32
   108                              <2> 		%1
   109                              <2> 	%endmacro
   110                              <2> 
   111                              <2> 		; Address size 32-bit prefix if 386+ CPU
   112                              <2> 	%macro _386_a32 0-1+.nolist
   113                              <2> _386		a32
   114                              <2> 		%1
   115                              <2> 	%endmacro
   116                              <2> 
   117                              <2> 		; Short jump if 386+ CPU
   118                              <2> 	%macro _386_jmps 1.nolist
   119                              <2> _386		jmp short %1
   120                              <2> 	%endmacro
   121                              <2> 
   122                              <2> 		; Near jump if 386+ CPU
   123                              <2> 	%macro _386_jmpn 1.nolist
   124                              <2> _386		jmp near %1
   125                              <2> 	%endmacro
   126                              <2> 
   127                              <2> 		; Short jump if no 386+ CPU
   128                              <2> 	%macro _no386_jmps 1.nolist
   129                              <2> _no386		jmp short %1
   130                              <2> 	%endmacro
   131                              <2> 
   132                              <2> 		; Near jump if no 386+ CPU
   133                              <2> 	%macro _no386_jmpn 1.nolist
   134                              <2> _no386		jmp near %1
   135                              <2> 	%endmacro
   136                              <2> 
   137                              <2> 		; Instruction if 386+ CPU
   138                              <2> 	%macro _386 0-1+.nolist
   139                              <2> [cpu 386]			; change CPU type
   140                              <2> %%entry:
   141                              <2> 		%1		; write instruction
   142                              <2> __CPU__				; reset CPU type
   143                              <2> %assign %%length ($ - %%entry)
   144                              <2>  patch386 no, equ %%entry, %%length
   145                              <2> 	%endmacro
   146                              <2> 
   147                              <2> 		; Instruction if no 386+ CPU
   148                              <2> 	%macro _no386 0-1+.nolist
   149                              <2> %%entry:
   150                              <2> 		%1		; write instruction
   151                              <2> %assign %%length ($ - %%entry)
   152                              <2>  patch386 , equ %%entry, %%length
   153                              <2> 	%endmacro
   154                              <2> 
   155                              <2> %else
   156                              <2> 	%macro patch386 2+.nolist
   157                              <2> %ifidn _CURRENT_SECTION, lDEBUG_CODE
   158                              <2>  %define PATCH_%{1}386_TABLE %[PATCH_%{1}386_TABLE], %2
   159                              <2> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
   160                              <2>  %define PATCH_%{1}386_TABLE2 %[PATCH_%{1}386_TABLE2], %2
   161                              <2> %elifidn _CURRENT_SECTION, lDEBUG_DATA_ENTRY
   162                              <2>  %define PATCH_%{1}386_TABLEENTRY %[PATCH_%{1}386_TABLEENTRY], %2
   163                              <2> %else
   164                              <2>  %error Wrong section
   165                              <2> %endif
   166                              <2> 	%endmacro
   167                              <2> 
   168                              <2> %if _WPT_LABELS
   169                              <2> 	; These forms provide verbose info by defining a
   170                              <2> 	; meaningful label for each patch. That fills up
   171                              <2> 	; the map file and might take longer though.
   172                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   173                              <2> 	%macro _386_o32 0-1+.nolist
   174                              <2> %%386_o32:	o32
   175                              <2> patch386 NO, %%386_o32
   176                              <2> 		%1
   177                              <2> 	%endmacro
   178                              <2> 
   179                              <2> 		; Address size 32-bit prefix if 386+ CPU
   180                              <2> 	%macro _386_a32 0-1+.nolist
   181                              <2> %%386_a32:	a32
   182                              <2> patch386 NO, %%386_a32
   183                              <2> 		%1
   184                              <2> 	%endmacro
   185                              <2> 
   186                              <2> 		; Short jump if 386+ CPU
   187                              <2> 	%macro _386_jmps 1.nolist
   188                              <2> %%386_jmps:	jmp short %1
   189                              <2> patch386 NO, %%386_jmps,%%386_jmps+1
   190                              <2> 	%endmacro
   191                              <2> 
   192                              <2> 		; Near jump if 386+ CPU
   193                              <2> 	%macro _386_jmpn 1.nolist
   194                              <2> %%386_jmpn:	jmp near %1
   195                              <2> patch386 NO, %%386_jmpn,%%386_jmpn+1,%%386_jmpn+2
   196                              <2> 	%endmacro
   197                              <2> 
   198                              <2> 		; Short jump if no 386+ CPU
   199                              <2> 	%macro _no386_jmps 1.nolist
   200                              <2> %%no386_jmps:	jmp short %1
   201                              <2> patch386 , %%no386_jmps,%%no386_jmps+1
   202                              <2> 	%endmacro
   203                              <2> 
   204                              <2> 		; Near jump if no 386+ CPU
   205                              <2> 	%macro _no386_jmpn 1.nolist
   206                              <2> %%no386_jmpn:	jmp near %1
   207                              <2> patch386 , %%no386_jmpn,%%no386_jmpn+1,%%no386_jmpn+2
   208                              <2> 	%endmacro
   209                              <2> 
   210                              <2> 		; Instruction if 386+ CPU
   211                              <2> 	%macro _386 0-1+.nolist
   212                              <2> [cpu 386]			; change CPU type
   213                              <2> %%386_instr:	%1		; write instruction
   214                              <2> __CPU__				; reset CPU type
   215                              <2> 
   216                              <2> %assign %%INSTRCOUNT 0
   217                              <2> %rep $-%%386_instr		; count size of instruction
   218                              <2>  patch386 NO, %%386_instr+%[%%INSTRCOUNT]
   219                              <2> 				; write a patch for each byte
   220                              <2>  %assign %%INSTRCOUNT %%INSTRCOUNT+1
   221                              <2> %endrep
   222                              <2> %undef %%INSTRCOUNT
   223                              <2> 	%endmacro
   224                              <2> 
   225                              <2> 		; Instruction if no 386+ CPU
   226                              <2> 	%macro _no386 0-1+.nolist
   227                              <2> %%no386_instr:	%1		; write instruction
   228                              <2> 
   229                              <2> %assign %%INSTRCOUNT 0
   230                              <2> %rep $-%%no386_instr		; count size of instruction
   231                              <2>  patch386 , %%no386_instr+%[%%INSTRCOUNT]
   232                              <2> 				; write a patch for each byte
   233                              <2>  %assign %%INSTRCOUNT %%INSTRCOUNT+1
   234                              <2> %endrep
   235                              <2> %undef %%INSTRCOUNT
   236                              <2> 	%endmacro
   237                              <2> %else	; _WPT_LABELS
   238                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   239                              <2> 	%macro _386_o32 0-1+.nolist
   240                              <2> _386		o32
   241                              <2> 		%1
   242                              <2> 	%endmacro
   243                              <2> 
   244                              <2> 		; Address size 32-bit prefix if 386+ CPU
   245                              <2> 	%macro _386_a32 0-1+.nolist
   246                              <2> _386		a32
   247                              <2> 		%1
   248                              <2> 	%endmacro
   249                              <2> 
   250                              <2> 		; Short jump if 386+ CPU
   251                              <2> 	%macro _386_jmps 1.nolist
   252                              <2> _386		jmp short %1
   253                              <2> 	%endmacro
   254                              <2> 
   255                              <2> 		; Near jump if 386+ CPU
   256                              <2> 	%macro _386_jmpn 1.nolist
   257                              <2> _386		jmp near %1
   258                              <2> 	%endmacro
   259                              <2> 
   260                              <2> 		; Short jump if no 386+ CPU
   261                              <2> 	%macro _no386_jmps 1.nolist
   262                              <2> _no386		jmp short %1
   263                              <2> 	%endmacro
   264                              <2> 
   265                              <2> 		; Near jump if no 386+ CPU
   266                              <2> 	%macro _no386_jmpn 1.nolist
   267                              <2> _no386		jmp near %1
   268                              <2> 	%endmacro
   269                              <2> 
   270                              <2> 		; Instruction if 386+ CPU
   271                              <2> 	%macro _386 0-1+.nolist
   272                              <2> %push
   273                              <2> [cpu 386]			; change CPU type
   274                              <2> %assign %$entry $ + _CURRENT_SECTION %+ FIXUP
   275                              <2> 		%1		; write instruction
   276                              <2> __CPU__				; reset CPU type
   277                              <2> 
   278                              <2> %rep ($ + _CURRENT_SECTION %+ FIXUP) - %$entry
   279                              <2> 				; count size of instruction
   280                              <2>  patch386 NO, %[%$entry]	; write a patch for each byte
   281                              <2>  %assign %$entry %$entry+1
   282                              <2> %endrep
   283                              <2> %pop
   284                              <2> 	%endmacro
   285                              <2> 
   286                              <2> 		; Instruction if no 386+ CPU
   287                              <2> 	%macro _no386 0-1+.nolist
   288                              <2> %push
   289                              <2> %assign %$entry $ + _CURRENT_SECTION %+ FIXUP
   290                              <2> 		%1		; write instruction
   291                              <2> 
   292                              <2> %rep ($ + _CURRENT_SECTION %+ FIXUP) - %$entry
   293                              <2> 				; count size of instruction
   294                              <2>  patch386 , %[%$entry]		; write a patch for each byte
   295                              <2>  %assign %$entry %$entry+1
   296                              <2> %endrep
   297                              <2> %pop
   298                              <2> 	%endmacro
   299                              <2> %endif	; _WPT_LABELS
   300                              <2> %endif	; _LINK
   301                              <2> 
   302                              <2> %endif
   303                              <2> 
   304                              <2> 		; Patch macros but for cases where the 386+
   305                              <2> 		; instructions should only be generated for
   306                              <2> 		; DEBUGX (i.e. for 32-bit DPMI addressing code).
   307                              <2> %if _PM
   308                              <2> %define _386_PM_o32	_386_o32
   309                              <2> %define _386_PM_a32	_386_a32
   310                              <2> %define _386_PM_jmps	_386_jmps
   311                              <2> %define _386_PM_jmpn	_386_jmpn
   312                              <2> %define _386_PM		_386
   313                              <2> %else
   314                              <2> %define _386_PM_o32
   315                              <2> %define _386_PM_a32
   316                              <2> %define _386_PM_jmps	comment
   317                              <2> %define _386_PM_jmpn	comment
   318                              <2> %define _386_PM		comment
   319                              <2> %endif
   320                              <2> 
   321                              <2> 
   322                              <2> %ifn _LINK
   323                              <2> %macro __writepatchtable2 0-*.nolist
   324                              <2> %if %0 & 1
   325                              <2>  %fatal Expected even number of arguments
   326                              <2> %endif
   327                              <2> %rep %0 >> 1
   328                              <2> 	%1 %2
   329                              <2> %rotate 2
   330                              <2> %endrep
   331                              <2> %endmacro
   332                              <2> 
   333                              <2> %macro __patchtable2_entry 0.nolist
   334                              <2>   ; only if this isn't the first (pseudo-)entry
   335                              <2>   %if %$lastcount != 0
   336                              <2>     %assign %$runscount %[%$runscount]+1
   337                              <2>    ; if the offset from %$previous is less than 255
   338                              <2>    %if (%$last-%$previous) < 255
   339                              <2>     %assign %$$method2tablesize %$$method2tablesize+1
   340                              <2>     ; then write a single byte (number of bytes not to patch between)
   341                              <2>     %xdefine %$$method2list %$$method2list,db,%$last-%$previous
   342                              <2>    %else
   343                              <2>     ; otherwise write a 255 ("reposition") and write the 16-bit address afterwards
   344                              <2>     %assign %$$method2tablesize %$$method2tablesize+3
   345                              <2>     %xdefine %$$method2list %$$method2list,db,255,dw,%$last
   346                              <2>     %assign %$reposcount %[%$reposcount]+1
   347                              <2>    %endif
   348                              <2>    %if %$lastcount == 1
   349                              <2>     %assign %$onecount %[%$onecount]+1
   350                              <2>    %endif
   351                              <2>    %assign %$$method2tablesize %$$method2tablesize+1
   352                              <2>    ; and write the number of bytes to be patched
   353                              <2>    %xdefine %$$method2list %$$method2list,db,%$lastcount
   354                              <2>    ; define %$previous for the next entry: it points to the next non-patched byte
   355                              <2>    %define %$previous (%[%$last]+%[%$lastcount])
   356                              <2>   %endif
   357                              <2> %endmacro
   358                              <2> 
   359                              <2> %macro writepatchtable 2-*.nolist
   360                              <2> 
   361                              <2> 	numdef %{1}_FORCE_METHOD, 0
   362                              <2> %push
   363                              <2> 		; Determine length of simple table:
   364                              <2> %assign %$method1tablesize (%0 - 2)*2
   365                              <2> 
   366                              <2> %if !_%{1}_FORCE_METHOD || _%{1}_FORCE_METHOD == 2
   367                              <2> 		; Determine length of complicated table:
   368                              <2> %assign %$method2tablesize 0
   369                              <2> %define %$method2list db,""
   370                              <2> %push
   371                              <2> %if _WPT_LABELS
   372                              <2>  %define %$previous code_start	; if list contains labels
   373                              <2> %else
   374                              <2>  %define %$previous 0
   375                              <2> %endif
   376                              <2> %define %$last %[%$previous]
   377                              <2> %assign %$lastcount 0
   378                              <2> %assign %$onecount 0
   379                              <2> %assign %$reposcount 0
   380                              <2> %assign %$bytescount %0 - 2
   381                              <2> %assign %$runscount 0
   382                              <2> %rotate 1
   383                              <2> %rep %0 - 2
   384                              <2>  %rotate 1
   385                              <2>  ;if  it continues the previous patch   and not too long   and this isn't the first
   386                              <2>  %if ((%$last+%$lastcount) == %1) && (%$lastcount < 255) && (%$lastcount != 0)
   387                              <2>   ; then do not write an entry, just increase the patch's size
   388                              <2>   %assign %$lastcount %[%$lastcount]+1
   389                              <2>  %else
   390                              <2>   ; otherwise write the last entry
   391                              <2>   __patchtable2_entry
   392                              <2>   ; define new %$last to this parameter, %$lastcount to one
   393                              <2>   %define %$last %1
   394                              <2>   %assign %$lastcount 1
   395                              <2>  %endif
   396                              <2> %endrep
   397                              <2> __patchtable2_entry
   398                              <2> 
   399                              <2> ; at the end, there's a patch with offset 0, size 0
   400                              <2> %assign %$$method2tablesize %$$method2tablesize+2
   401                              <2> %xdefine %$$method2list %$$method2list,db,0,db,0
   402                              <2> 
   403                              <2> %assign %$$onecount %$onecount
   404                              <2> %assign %$$reposcount %$reposcount
   405                              <2> %assign %$$bytescount %$bytescount
   406                              <2> %assign %$$runscount %$runscount
   407                              <2> %pop
   408                              <2> %rotate 1
   409                              <2> %endif
   410                              <2> 
   411                              <2> %if _%{1}_FORCE_METHOD == 2
   412                              <2>  %define __%{1}_method 2
   413                              <2> %elif _%{1}_FORCE_METHOD == 1
   414                              <2>  %define __%{1}_method 1
   415                              <2> %else
   416                              <2>  %if _%{1}_FORCE_METHOD
   417                              <2>   %fatal Invalid forced method selected: _%{1}_FORCE_METHOD
   418                              <2>  %endif
   419                              <2>  %if %$method1tablesize > (%$method2tablesize+20)
   420                              <2>   %define __%{1}_method 2
   421                              <2>  %else
   422                              <2>   %define __%{1}_method 1
   423                              <2>  %endif
   424                              <2> %endif
   425                              <2> 
   426                              <2> 
   427                              <2> %1:
   428                              <2> %if __%{1}_method == 2
   429                              <2> 	__writepatchtable2 %$method2list
   430                              <2> 	endarea %1
   431                              <2> %assign %$size %1_size
   432                              <2> %warning %1: %$size bytes (Method 2)
   433                              <2> %warning 1B=%$onecount repo=%$reposcount run=%$runscount byte=%$bytescount
   434                              <2> %else
   435                              <2> %rotate 1
   436                              <2> %rep %0 - 2
   437                              <2> %rotate 1
   438                              <2> 	dw %1
   439                              <2> %endrep
   440                              <2> %rotate 1
   441                              <2> 	endarea %1
   442                              <2> %assign %$size %1_size
   443                              <2> %warning %1: %$size bytes (Method 1)
   444                              <2> %1.amount equ %1_size_w
   445                              <2> %endif
   446                              <2> %pop
   447                              <2> %endmacro
   448                              <2> %endif
   879                              <1> 
   880                              <1> 
   881                              <1> %if _VDD
   882                              <1> ; standard BOPs for communication with DEBXXVDD on NT platforms
   883                              <1> %macro RegisterModule 0.nolist
   884                              <1> 	db 0C4h, 0C4h, 58h, 0
   885                              <1> 	nop
   886                              <1> %endmacro
   887                              <1> %macro UnRegisterModule 0.nolist
   888                              <1> 	db 0C4h, 0C4h, 58h, 1
   889                              <1> 	nop
   890                              <1> %endmacro
   891                              <1> %macro DispatchCall 0.nolist
   892                              <1> 	db 0C4h, 0C4h, 58h, 2
   893                              <1> 	nop
   894                              <1> %endmacro
   895                              <1> %endif
   896                              <1> 
   897                              <1> %assign CODE_INSURE_COUNT 0
   898                              <1> 
   899                              <1> 		; The entry_to_code_seg/_sel dispatcher in lDEBUG_DATA_ENTRY
   900                              <1> 		;  detects mistaken debugger breakpoints in its
   901                              <1> 		;  in-code-parameter by checking for a low-byte
   902                              <1> 		;  value equal to 0CCh (one-byte int3 opcode).
   903                              <1> 		; Therefore, we insure that all destinations jumped to
   904                              <1> 		;  via that dispatcher do not happen to be located
   905                              <1> 		;  on an offset that gives 0CCh in the low byte.
   906                              <1> 	%imacro code_insure_low_byte_not_0CCh 0.nolist
   907                              <1> %ifn _LINK
   908                              <1>  %if (($ - _CURRENT_SECTION %+ _start) & 0FFh) == 0CCh
   909                              <1> 	nop
   910                              <1>   %assign CODE_INSURE_COUNT 1 + CODE_INSURE_COUNT
   911                              <1>  %endif
   912                              <1> %endif
   913                              <1> 	%endmacro
   914                              <1> 
   915                              <1> 
   916                              <1> 		; dual code segments
   917                              <1> %if _DUALCODE && _PM
   918                              <1> 
   919                              <1> %if _DEBUG
   920                              <1> %idefine dualfunction comment
   921                              <1> %else
   922                              <1> %idefine dualfunction code_insure_low_byte_not_0CCh
   923                              <1> %endif
   924                              <1> 
   925                              <1> %idefine dualreturn call _CURRENT_SECTION %+ _dualret_helper
   926                              <1> %idefine dualdistance far
   927                              <1> 	%imacro dualcall 1.nolist
   928                              <1> %ifndef SECTION_OF_%1
   929                              <1>  %error Unknown target section for symbol %1
   930                              <1> %endif
   931                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _dualcall_helper
   932                              <1>  %if _DEBUG
   933                              <1> 	jmp strict short %%skipdata
   934                              <1>  %endif
   935                              <1> 	dw %1
   936                              <1> %%skipdata:
   937                              <1> 	%endmacro
   938                              <1> 	%imacro nearcall 1.nolist
   939                              <1> %ifndef SECTION_OF_%1
   940                              <1>  %error Unknown target section for symbol %1
   941                              <1> %endif
   942                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
   943                              <1> 	call %1
   944                              <1> %else
   945                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _nearcall_helper
   946                              <1>  %if _DEBUG
   947                              <1> 	jmp strict short %%skipdata
   948                              <1>  %endif
   949                              <1> 	dw %1
   950                              <1> %%skipdata:
   951                              <1> %endif
   952                              <1> 	%endmacro
   953                              <1> 
   954                              <1> %elif _DUALCODE && ! _PM
   955                              <1> 
   956                              <1> %idefine dualfunction comment
   957                              <1> %idefine dualreturn
   958                              <1> %idefine dualdistance far
   959                              <1> 
   960                              <1> %ifn _LINK
   961                              <1> %define PATCH_RELOCATE_FROM_lDEBUG_CODE ""
   962                              <1> %define PATCH_RELOCATE_FROM_lDEBUG_CODE2 ""
   963                              <1> 	%imacro dualcall 1.nolist
   964                              <1> %ifndef SECTION_OF_%1
   965                              <1>  %error Unknown target section for symbol %1
   966                              <1> %endif
   967                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
   968                              <1> 	push cs
   969                              <1> 	call %1
   970                              <1> %else
   971                              <1> 	call relocatedzero:%1
   972                              <1> %push
   973                              <1> %assign %$entry ($ + _CURRENT_SECTION %+ FIXUP) - 2
   974                              <1> 	relocatelist _CURRENT_SECTION, %$entry
   975                              <1> %pop
   976                              <1> %endif
   977                              <1> 	%endmacro
   978                              <1> 	%imacro relocatelist 2.nolist
   979                              <1>  %define PATCH_RELOCATE_FROM_%1 %[PATCH_RELOCATE_FROM_%1],%2
   980                              <1> 	%endmacro
   981                              <1> %else		; _LINK
   982                              <1> 	%idefine dualcall dualcall_with_filename __FILE__,
   983                              <1> 	%imacro dualcall_with_filename 2.nolist
   984                              <1> %ifndef SECTION_OF_%2
   985                              <1>  %error Unknown target section for symbol %2
   986                              <1> %endif
   987                              <1> %ifidni %[SECTION_OF_%2], _CURRENT_SECTION
   988                              <1> 	push cs
   989                              <1> 	call %2
   990                              <1> %else
   991                              <1> 	call relocatedzero:%2
   992                              <1> %ifidn _CURRENT_SECTION, lDEBUG_CODE
   993                              <1>  wllist Lrelocate_from_code, equ $ - 2, %1
   994                              <1> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
   995                              <1>  wllist Lrelocate_from_code2, equ $ - 2, %1
   996                              <1> %else
   997                              <1>  %error Wrong section
   998                              <1> %endif
   999                              <1> %endif
  1000                              <1> 	%endmacro
  1001                              <1> %endif		; _LINK
  1002                              <1>  %if _DUALCODENEARDUAL
  1003                              <1> 
  1004                              <1> %if _LINK
  1005                              <1> 	%idefine nearcall nearcall_with_filename __FILE__,
  1006                              <1> 	%imacro nearcall_with_filename 2
  1007                              <1> %ifndef SECTION_OF_%2
  1008                              <1>  %error Unknown target section for symbol %2
  1009                              <1> %endif
  1010                              <1> %ifidni %[SECTION_OF_%2], _CURRENT_SECTION
  1011                              <1> 	call %2
  1012                              <1> %else
  1013                              <1>  %push
  1014                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1015                              <1>  %xdefine %$targetsection SECTION_OF_%2
  1016                              <1>  %deftok %%filenametoken SOURCEFILENAME
  1017                              <1>   %ifndef NEARCALL_THUNK_TO_%2%[%%filenametoken]
  1018                              <1> 	hiddenusesection %$targetsection
  1019                              <1> %define NEARCALL_THUNK_TO_%2%[%%filenametoken] %%nearcall_thunk_to_%2%[%%filenametoken]
  1020                              <1> section_of %%nearcall_thunk_to_%2%[%%filenametoken]
  1021                              <1> dualfunction
  1022                              <1> %%nearcall_thunk_to_%2%[%%filenametoken]:
  1023                              <1> 	call %2
  1024                              <1> 	dualreturn
  1025                              <1> 	retf
  1026                              <1> 
  1027                              <1> 	hiddenusesection %$originalsection
  1028                              <1>   %endif
  1029                              <1>  %pop
  1030                              <1> 	dualcall_with_filename %1, NEARCALL_THUNK_TO_%2%[%%filenametoken]
  1031                              <1> %endif
  1032                              <1> 	%endmacro
  1033                              <1> %elif _LINK_COMPAT	; _LINK
  1034                              <1> 	%imacro nearcall 1
  1035                              <1> %ifndef SECTION_OF_%1
  1036                              <1>  %error Unknown target section for symbol %1
  1037                              <1> %endif
  1038                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1039                              <1> 	call %1
  1040                              <1> %else
  1041                              <1>  %push
  1042                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1043                              <1>  %xdefine %$targetsection SECTION_OF_%1
  1044                              <1>  %deftok %%filenametoken SOURCEFILENAME
  1045                              <1>   %ifndef NEARCALL_THUNK_TO_%1%[%%filenametoken]
  1046                              <1> 	hiddenusesection %$targetsection
  1047                              <1> %define NEARCALL_THUNK_TO_%1%[%%filenametoken] %%nearcall_thunk_to_%1%[%%filenametoken]
  1048                              <1> section_of %%nearcall_thunk_to_%1%[%%filenametoken]
  1049                              <1> dualfunction
  1050                              <1> %%nearcall_thunk_to_%1%[%%filenametoken]:
  1051                              <1> 	call %1
  1052                              <1> 	dualreturn
  1053                              <1> 	retf
  1054                              <1> 
  1055                              <1> 	hiddenusesection %$originalsection
  1056                              <1>   %endif
  1057                              <1>  %pop
  1058                              <1> 	dualcall NEARCALL_THUNK_TO_%1%[%%filenametoken]
  1059                              <1> %endif
  1060                              <1> 	%endmacro
  1061                              <1> %else		; _LINK, _LINK_COMPAT
  1062                              <1> 	%imacro nearcall 1
  1063                              <1> %ifndef SECTION_OF_%1
  1064                              <1>  %error Unknown target section for symbol %1
  1065                              <1> %endif
  1066                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1067                              <1> 	call %1
  1068                              <1> %else
  1069                              <1>  %push
  1070                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1071                              <1>  %xdefine %$targetsection SECTION_OF_%1
  1072                              <1>   %ifndef NEARCALL_THUNK_TO_%1
  1073                              <1> 	hiddenusesection %$targetsection
  1074                              <1> %define NEARCALL_THUNK_TO_%1 %%nearcall_thunk_to_%1
  1075                              <1> section_of %%nearcall_thunk_to_%1
  1076                              <1> dualfunction
  1077                              <1> %%nearcall_thunk_to_%1:
  1078                              <1> 	call %1
  1079                              <1> 	dualreturn
  1080                              <1> 	retf
  1081                              <1> 
  1082                              <1> 	hiddenusesection %$originalsection
  1083                              <1>   %endif
  1084                              <1>  %pop
  1085                              <1> 	dualcall NEARCALL_THUNK_TO_%1
  1086                              <1> %endif
  1087                              <1> 	%endmacro
  1088                              <1> %endif		; _LINK, _LINK_COMPAT
  1089                              <1>  %else
  1090                              <1> 	%imacro nearcall 1.nolist
  1091                              <1> %ifndef SECTION_OF_%1
  1092                              <1>  %error Unknown target section for symbol %1
  1093                              <1> %endif
  1094                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1095                              <1> 	call %1
  1096                              <1> %else
  1097                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _nearcall_helper
  1098                              <1>  %if _DEBUG
  1099                              <1> 	jmp strict short %%skipdata
  1100                              <1>  %endif
  1101                              <1> 	dw %1
  1102                              <1> %%skipdata:
  1103                              <1> %endif
  1104                              <1> 	%endmacro
  1105                              <1>  %endif
  1106                              <1> %elif ! _DUALCODE
  1107                              <1> 
  1108                              <1> %idefine dualfunction comment
  1109                              <1> %idefine dualreturn
  1110                              <1> %idefine dualdistance near
  1111                              <1> 	%imacro dualcall 1.nolist
  1112                              <1> 	call %1
  1113                              <1> 	%endmacro
  1114                              <1> 	%imacro nearcall 1.nolist
  1115                              <1> 	call %1
  1116                              <1> 	%endmacro
  1117                              <1> %assign _SYMBOLICDUALCODE 0
  1118                              <1> %assign _SYMBOLASMDUALCODE 0
  1119                              <1> 
  1120                              <1> %else
  1121                              <1>  %error Unexpected defines
  1122                              <1> %endif
  1123                              <1> 
  1124                              <1> %ifn _SYMBOLICDUALCODE
  1125                              <1>  %assign _SYMBOLASMDUALCODE 0
  1126                              <1> %endif
  1127                              <1> 
  1128                              <1>  %if _SYMBOLIC && _DUALCODE && _SYMBOLASMDUALCODE
  1129                              <1> %idefine dual2function	dualfunction
  1130                              <1> %idefine dual2return	dualreturn
  1131                              <1> %idefine dual2distance	dualdistance
  1132                              <1> %idefine dual2call	dualcall
  1133                              <1>  %else
  1134                              <1> %idefine dual2function comment
  1135                              <1> %idefine dual2return
  1136                              <1> %idefine dual2distance near
  1137                              <1> 	%imacro dual2call 1.nolist
  1138                              <1> 	call %1
  1139                              <1> 	%endmacro
  1140                              <1>  %endif
  1141                              <1> 
  1142                              <1> 
  1143                              <1> 	numdef CHECKSECTION, 0
  1144                              <1> 	numdef CHECKCALLSECTION, _CHECKSECTION
  1145                              <1> 	numdef CHECKJMPSECTION, _CHECKSECTION
  1146                              <1> 	numdef CHECKJCCSECTION, _CHECKSECTION
  1147                              <1> 
  1148                              <1> %if _CHECKCALLSECTION
  1149                              <1> 	%imacro call 1.nolist
  1150                              <1> 	%? %1
  1151                              <1> checksection %1, %?, call
  1152                              <1> 	%endmacro
  1153                              <1> %endif
  1154                              <1> %if _CHECKJMPSECTION
  1155                              <1> 	%imacro jmp 1.nolist
  1156                              <1> 	%? %1
  1157                              <1> checksection %1, %?, jmp
  1158                              <1> 	%endmacro
  1159                              <1> %endif
  1160                              <1> %if _CHECKJCCSECTION
  1161                              <1> 	%imacro je 1.nolist
  1162                              <1> 	%? %1
  1163                              <1> checksection %1, %?, jcc
  1164                              <1> 	%endmacro
  1165                              <1> 	%imacro jne 1.nolist
  1166                              <1> 	%? %1
  1167                              <1> checksection %1, %?, jcc
  1168                              <1> 	%endmacro
  1169                              <1> 	%imacro jz 1.nolist
  1170                              <1> 	%? %1
  1171                              <1> checksection %1, %?, jcc
  1172                              <1> 	%endmacro
  1173                              <1> 	%imacro jnz 1.nolist
  1174                              <1> 	%? %1
  1175                              <1> checksection %1, %?, jcc
  1176                              <1> 	%endmacro
  1177                              <1> 
  1178                              <1> 	%imacro jb 1.nolist
  1179                              <1> 	%? %1
  1180                              <1> checksection %1, %?, jcc
  1181                              <1> 	%endmacro
  1182                              <1> 	%imacro jnb 1.nolist
  1183                              <1> 	%? %1
  1184                              <1> checksection %1, %?, jcc
  1185                              <1> 	%endmacro
  1186                              <1> 	%imacro jbe 1.nolist
  1187                              <1> 	%? %1
  1188                              <1> checksection %1, %?, jcc
  1189                              <1> 	%endmacro
  1190                              <1> 	%imacro jnbe 1.nolist
  1191                              <1> 	%? %1
  1192                              <1> checksection %1, %?, jcc
  1193                              <1> 	%endmacro
  1194                              <1> 	%imacro jc 1.nolist
  1195                              <1> 	%? %1
  1196                              <1> checksection %1, %?, jcc
  1197                              <1> 	%endmacro
  1198                              <1> 	%imacro jnc 1.nolist
  1199                              <1> 	%? %1
  1200                              <1> checksection %1, %?, jcc
  1201                              <1> 	%endmacro
  1202                              <1> 	%imacro ja 1.nolist
  1203                              <1> 	%? %1
  1204                              <1> checksection %1, %?, jcc
  1205                              <1> 	%endmacro
  1206                              <1> 	%imacro jna 1.nolist
  1207                              <1> 	%? %1
  1208                              <1> checksection %1, %?, jcc
  1209                              <1> 	%endmacro
  1210                              <1> 	%imacro jae 1.nolist
  1211                              <1> 	%? %1
  1212                              <1> checksection %1, %?, jcc
  1213                              <1> 	%endmacro
  1214                              <1> 	%imacro jnae 1.nolist
  1215                              <1> 	%? %1
  1216                              <1> checksection %1, %?, jcc
  1217                              <1> 	%endmacro
  1218                              <1> 
  1219                              <1> 	%imacro jl 1.nolist
  1220                              <1> 	%? %1
  1221                              <1> checksection %1, %?, jcc
  1222                              <1> 	%endmacro
  1223                              <1> 	%imacro jnl 1.nolist
  1224                              <1> 	%? %1
  1225                              <1> checksection %1, %?, jcc
  1226                              <1> 	%endmacro
  1227                              <1> 	%imacro jle 1.nolist
  1228                              <1> 	%? %1
  1229                              <1> checksection %1, %?, jcc
  1230                              <1> 	%endmacro
  1231                              <1> 	%imacro jnle 1.nolist
  1232                              <1> 	%? %1
  1233                              <1> checksection %1, %?, jcc
  1234                              <1> 	%endmacro
  1235                              <1> 	%imacro jg 1.nolist
  1236                              <1> 	%? %1
  1237                              <1> checksection %1, %?, jcc
  1238                              <1> 	%endmacro
  1239                              <1> 	%imacro jng 1.nolist
  1240                              <1> 	%? %1
  1241                              <1> checksection %1, %?, jcc
  1242                              <1> 	%endmacro
  1243                              <1> 	%imacro jge 1.nolist
  1244                              <1> 	%? %1
  1245                              <1> checksection %1, %?, jcc
  1246                              <1> 	%endmacro
  1247                              <1> 	%imacro jnge 1.nolist
  1248                              <1> 	%? %1
  1249                              <1> checksection %1, %?, jcc
  1250                              <1> 	%endmacro
  1251                              <1> 
  1252                              <1> 	%imacro jo 1.nolist
  1253                              <1> 	%? %1
  1254                              <1> checksection %1, %?, jcc
  1255                              <1> 	%endmacro
  1256                              <1> 	%imacro jno 1.nolist
  1257                              <1> 	%? %1
  1258                              <1> checksection %1, %?, jcc
  1259                              <1> 	%endmacro
  1260                              <1> 	%imacro jp 1.nolist
  1261                              <1> 	%? %1
  1262                              <1> checksection %1, %?, jcc
  1263                              <1> 	%endmacro
  1264                              <1> 	%imacro jnp 1.nolist
  1265                              <1> 	%? %1
  1266                              <1> checksection %1, %?, jcc
  1267                              <1> 	%endmacro
  1268                              <1> 	%imacro jpe 1.nolist
  1269                              <1> 	%? %1
  1270                              <1> checksection %1, %?, jcc
  1271                              <1> 	%endmacro
  1272                              <1> 	%imacro jnpe 1.nolist
  1273                              <1> 	%? %1
  1274                              <1> checksection %1, %?, jcc
  1275                              <1> 	%endmacro
  1276                              <1> 	%imacro jpo 1.nolist
  1277                              <1> 	%? %1
  1278                              <1> checksection %1, %?, jcc
  1279                              <1> 	%endmacro
  1280                              <1> 	%imacro jnpo 1.nolist
  1281                              <1> 	%? %1
  1282                              <1> checksection %1, %?, jcc
  1283                              <1> 	%endmacro
  1284                              <1> 	%imacro js 1.nolist
  1285                              <1> 	%? %1
  1286                              <1> checksection %1, %?, jcc
  1287                              <1> 	%endmacro
  1288                              <1> 	%imacro jns 1.nolist
  1289                              <1> 	%? %1
  1290                              <1> checksection %1, %?, jcc
  1291                              <1> 	%endmacro
  1292                              <1> 
  1293                              <1> 	%imacro jcxz 1.nolist
  1294                              <1> 	%? %1
  1295                              <1> checksection %1, %?, jcc
  1296                              <1> 	%endmacro
  1297                              <1> 	%imacro jecxz 1.nolist
  1298                              <1> 	%? %1
  1299                              <1> checksection %1, %?, jcc
  1300                              <1> 	%endmacro
  1301                              <1> 	%imacro loop 1.nolist
  1302                              <1> 	%? %1
  1303                              <1> checksection %1, %?, jcc
  1304                              <1> 	%endmacro
  1305                              <1> 	%imacro loopz 1.nolist
  1306                              <1> 	%? %1
  1307                              <1> checksection %1, %?, jcc
  1308                              <1> 	%endmacro
  1309                              <1> 	%imacro loopnz 1.nolist
  1310                              <1> 	%? %1
  1311                              <1> checksection %1, %?, jcc
  1312                              <1> 	%endmacro
  1313                              <1> 	%imacro loope 1.nolist
  1314                              <1> 	%? %1
  1315                              <1> checksection %1, %?, jcc
  1316                              <1> 	%endmacro
  1317                              <1> 	%imacro loopne 1.nolist
  1318                              <1> 	%? %1
  1319                              <1> checksection %1, %?, jcc
  1320                              <1> 	%endmacro
  1321                              <1> %endif
  1322                              <1> 
  1323                              <1> 	%imacro checksection 3.nolist
  1324                              <1> %push
  1325                              <1>  %defstr %$string %1
  1326                              <1>  %substr %$shortword %$string 1, 5
  1327                              <1>  %substr %$shortsep %$string 6, 1
  1328                              <1>  %substr %$nearword %$string 1, 4
  1329                              <1>  %substr %$nearsep %$string 5, 1
  1330                              <1>  %substr %$farword %$string 1, 3
  1331                              <1>  %substr %$farsep %$string 4, 1
  1332                              <1>  %assign %$isshort 0
  1333                              <1>  %ifidni %$shortword, "short"
  1334                              <1>   %if %$shortsep == 32 || %$shortsep == 9
  1335                              <1>    %assign %$isshort 1
  1336                              <1>    %substr %$string %$string 7, -1
  1337                              <1>   %elif %$shortsep == '['
  1338                              <1>    %assign %$isshort 1
  1339                              <1>    %substr %$string %$string 6, -1
  1340                              <1>   %endif
  1341                              <1>  %endif
  1342                              <1>  %assign %$isnear 0
  1343                              <1>  %ifidni %$nearword, "near"
  1344                              <1>   %if %$nearsep == 32 || %$nearsep == 9
  1345                              <1>    %assign %$isnear 1
  1346                              <1>    %substr %$string %$string 6, -1
  1347                              <1>   %elif %$nearsep == '['
  1348                              <1>    %assign %$isnear 1
  1349                              <1>    %substr %$string %$string 5, -1
  1350                              <1>   %endif
  1351                              <1>  %endif
  1352                              <1>  %assign %$isfar 0
  1353                              <1>  %ifidni %$farword, "far"
  1354                              <1>   %if %$farsep == 32 || %$farsep == 9
  1355                              <1>    %assign %$isfar 1
  1356                              <1>    %substr %$string %$string 5, -1
  1357                              <1>   %elif %$farsep == '['
  1358                              <1>    %assign %$isfar 1
  1359                              <1>    %substr %$string %$string 4, -1
  1360                              <1>   %endif
  1361                              <1>  %endif
  1362                              <1> 
  1363                              <1>  %deftok %$token %$string
  1364                              <1> 
  1365                              <1>  %assign %$size 2
  1366                              <1>  %assign %$isreg 0
  1367                              <1>  %assign %$exit 0
  1368                              <1>  %rep 2
  1369                              <1>   %ifn %$exit
  1370                              <1>    %if %$size == 2
  1371                              <1>     %define %$regnames "ax  cx  dx  bx  sp  bp  si  di  "
  1372                              <1>    %elif %$size == 4
  1373                              <1>     %define %$regnames "eax ecx edx ebx esp ebp esi edi "
  1374                              <1>    %endif
  1375                              <1>    %assign %$index 0
  1376                              <1>    %rep 8
  1377                              <1>     %ifn %$exit
  1378                              <1>      %substr %$reg %$regnames %$index * 4 + 1, 4
  1379                              <1>      %deftok %$reg %$reg
  1380                              <1>      %ifnempty %$reg
  1381                              <1>       %ifidni %$reg, %$token
  1382                              <1>        %assign %$isreg %$size
  1383                              <1>        %assign %$exit 1
  1384                              <1>        %exitrep
  1385                              <1>       %endif
  1386                              <1>      %endif
  1387                              <1>     %endif
  1388                              <1>     %assign %$index %$index + 1
  1389                              <1>    %endrep
  1390                              <1>    %if %$exit
  1391                              <1>     %exitrep
  1392                              <1>    %endif
  1393                              <1>    %assign %$size %$size * 2
  1394                              <1>   %endif
  1395                              <1>  %endrep
  1396                              <1> 
  1397                              <1>  %assign %$ismulti 0
  1398                              <1>  %assign %$ismem 0
  1399                              <1>  %strlen %$length %$string
  1400                              <1>  %assign %$ii 0
  1401                              <1>  %rep %$length
  1402                              <1>   %substr %$point %$string %$ii + 1, 1
  1403                              <1>   %if %$point == 32 || %$point == 9
  1404                              <1>    %assign %$ismulti 1
  1405                              <1>   %endif
  1406                              <1>   %ifidn %$point, '['
  1407                              <1>    %assign %$ismem 1
  1408                              <1>   %endif
  1409                              <1>   %assign %$ii %$ii + 1
  1410                              <1>  %endrep
  1411                              <1> 
  1412                              <1>  %assign %$islocal 0
  1413                              <1>  %substr %$point %$string 1, 1
  1414                              <1>  %substr %$prefix %$string 1, 3
  1415                              <1>  %ifidn %$point, '.'
  1416                              <1>   %ifnidn %$prefix, '..@'
  1417                              <1>    %assign %$islocal 1
  1418                              <1>   %endif
  1419                              <1>  %endif
  1420                              <1> 
  1421                              <1>  %if %$isreg
  1422                              <1>   %if %$isreg == 4
  1423                              <1>    %warning 32-bit reg %3: %2 %1
  1424                              <1>   %else
  1425                              <1>    %warning 16-bit reg %3: %2 %1
  1426                              <1>   %endif
  1427                              <1>  %elif %$ismulti || %$ismem
  1428                              <1>   %warning not single %3: %2 %1
  1429                              <1>  %elif %$islocal
  1430                              <1>   %ifidni %3, call
  1431                              <1>    %warning local %3: %2 %1
  1432                              <1>   %endif
  1433                              <1>  %elifdef SECTION_OF_%[%$token]
  1434                              <1>   %ifnidni SECTION_OF_%[%$token], _CURRENT_SECTION
  1435                              <1>    %error Symbol %$token called wrongly: section_of=SECTION_OF_%[%$token], current=_CURRENT_SECTION
  1436                              <1>   %endif
  1437                              <1>  %endif
  1438                              <1> %pop
  1439                              <1> 	%endmacro
  1440                              <1> 
  1441                              <1> 
  1442                              <1> 	struc MEMREF
  1443 00000000 ????????            <1> mrLinear:		resd 1
  1444 00000004 ????????            <1> mrOffset:		resd 1
  1445 00000008 ????                <1> mrSegmentSelector:	resw 1
  1446 0000000A ????                <1> mrFlags:		resw 1
  1447 0000000C ????????            <1> mrLength:		resd 1
  1448                              <1> 	endstruc
  1449                              <1> 
  1450                              <1> 		; Currently only direct branches are allowed when
  1451                              <1> 		;  disassembling from the U command. (That is,
  1452                              <1> 		;  [disflags] & DIS_F_SHOW is clear.) All other
  1453                              <1> 		;  types of references depend on segment registers
  1454                              <1> 		;  and sometimes base and index registers, which are
  1455                              <1> 		;  not known ahead of time. They are only known for
  1456                              <1> 		;  the R command's disassembly. (DIS_F_SHOW set.)
  1457                              <1> 		; (When a mov ss or pop to ss will change ss, a
  1458                              <1> 		;  subsequent instruction using ss will not be
  1459                              <1> 		;  disassembled with the correct ss value.
  1460                              <1> 		;  This should be rare though. We may at a later
  1461                              <1> 		;  point detect this condition and not display
  1462                              <1> 		;  references with ss then.)
  1463                              <1> mrfBranchDirect:	equ    1
  1464                              <1> mrfMem:			equ    2
  1465                              <1> mrfMemSource:		equ    4
  1466                              <1> mrfMemDest:		equ    8
  1467                              <1> mrfA32:			equ   10h
  1468                              <1> mrfString:		equ   20h
  1469                              <1> mrfStringSource:	equ   40h
  1470                              <1> mrfStringDest:		equ   80h
  1471                              <1> mrfUsesSS:		equ  100h
  1472                              <1> mrfBranchIndirect:	equ  200h
  1473                              <1> 
  1474                              <1> 
  1475                              <1> %if _VXCHG && ! _VXCHGBIOS
  1476                              <1> 	struc XMSM
  1477 00000000 ????????            <1> .size_:		resd 1
  1478 00000004 ????                <1> .srchdl:	resw 1
  1479 00000006 ????????            <1> .srcadr:	resd 1
  1480 0000000A ????                <1> .dsthdl:	resw 1
  1481 0000000C ????????            <1> .dstadr:	resd 1
  1482                              <1> 	endstruc
  1483                              <1> %endif
  1484                              <1> 
  1485                              <1> 
  1486                              <1> 	; doscall is used by symbols.asm and run.asm and in
  1487                              <1> 	;  cmd3_close_handle, so define it prior
  1488                              <1> %if _PM && _NOEXTENDER
  1489                              <1> %macro doscall 0
  1490                              <1> 	nearcall _doscall
  1491                              <1> %endmacro
  1492                              <1> %else
  1493                              <1> 		; When we don't support non-extended DPMI all Int21 calls
  1494                              <1> 		; are either in Real Mode or extended (all are real Int21
  1495                              <1> 		; instructions).
  1496                              <1> %macro doscall 0
  1497                              <1> 	int 21h
  1498                              <1> %endmacro
  1499                              <1> %endif
  1500                              <1> 
  1501                              <1> 
  1502                              <1> %if _LINK
  1503                              <1> %imacro wlcalc 1-2.nolist
  1504                              <1> %deftok %%filenametoken __FILE__
  1505                              <1>  global wlcalc_%1?%[%%l]%[%%filenametoken]
  1506                              <1> wlcalc_%1?%[%%l]%[%%filenametoken]: %2
  1507                              <1> %endmacro
  1508                              <1> %endif
  1509                              <1> 
  1510                              <1> %if _BOOTLDR && _LINK
  1511                              <1> %macro lot_equate 2.nolist
  1512                              <1> LOAD_%2 equ %1
  1513                              <1> %endmacro
  1514                              <1> 
  1515                              <1> 	lot_equate    1, SET_DL_UNIT
  1516                              <1> 	lot_equate    2, SET_BL_UNIT
  1517                              <1> 	lot_equate    4, SET_SIDI_CLUSTER
  1518                              <1> 	lot_equate  10h, SET_DSSI_DPT
  1519                              <1> 	lot_equate  20h, PUSH_DPT
  1520                              <1> 	lot_equate  40h, DATASTART_HIDDEN
  1521                              <1> 	lot_equate  80h, SET_AXBX_DATASTART
  1522                              <1> 	lot_equate 100h, SET_DSBP_BPB
  1523                              <1> 	lot_equate 200h, LBA_SET_TYPE
  1524                              <1> 	lot_equate 400h, MESSAGE_TABLE
  1525                              <1> 	lot_equate 800h, SET_AXBX_ROOT_HIDDEN
  1526                              <1> 	lot_equate 1000h, CMDLINE
  1527                              <1> 	lot_equate 2000h, NO_BPB
  1528                              <1> 	lot_equate 4000h, SET_DSSI_PARTINFO
  1529                              <1> %endif
  1530                              <1> 
  1531                              <1> %if _HELP_COMPRESSED
  1532                              <1>  %assign NONCOMPRESSEDFLAG 1
  1533                              <1> %else
  1534                              <1>  %assign NONCOMPRESSEDFLAG 0
  1535                              <1> %endif
  1536                              <1> 
  1537                              <1> [list +]
  1538                              <1> 
  1539                              <1> %if _LINK
  1540                              <1>  %if _ONLY386
  1541                              <1> 	cpu 386
  1542                              <1>  %else
  1543                              <1> 	cpu 8086
  1544                              <1>  %endif
  1545                              <1> 
  1546                              <1> auxbuff_size: equ (_AUXBUFFSIZE+15) & ~15
  1547                              <1> 	endarea auxbuff, 1
  1548                              <1> 
  1549                              <1> auxbuff_max_size: equ (_AUXBUFFMAXSIZE+15) & ~15
  1550                              <1> 	endarea auxbuff_max, 1
  1551                              <1> 
  1552                              <1> %if _INIT_MAX
  1553                              <1>  auxbuff_init_size: equ (_AUXBUFFMAXSIZE+15) & ~15
  1554                              <1> %else
  1555                              <1>  auxbuff_init_size: equ (_AUXBUFFSIZE+15) & ~15
  1556                              <1> %endif
  1557                              <1> 	endarea auxbuff_init, 1
  1558                              <1> 
  1559                              <1>  %include "options.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug options and internal flags
     5                              <2> 
     6                              <2> Copyright (C) 2008-2025 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 
    17                              <2> dispregs32	equ	  1	; RX: 32-bit register display (R, T/P/G)
    18                              <2> traceints	equ	  2	; TM: trace into interrupts (T)
    19                              <2> cpdepchars	equ	  4	; allow dumping of CP-dependent characters (D, DX)
    20                              <2> fakeindos	equ	  8	; always assume InDOS flag non-zero (all)
    21                              <2> nonpagingdevice	equ	 10h	; disallow paged output with [more] prompt (all exc. P, T)
    22                              <2> 	; This option was never used anywhere:
    23                              <2> ; pagingdevice	equ	 20h	; allow paged output with [more] prompt (all exc. P, T)
    24                              <2> 				; paged output is by default on if the output device is StdOut, else off
    25                              <2> hexrn		equ	 40h	; display raw hexadecimal content of FPU registers (RN)
    26                              <2> ;novdd		equ	 80h	; don't use a registered NTVDM VDD (L, W)
    27                              <2> nondospaging	equ	100h	; paging: don't use DOS for input when waiting for a key
    28                              <2> opt1_86mnohlt	equ	200h	; (86 Mode:) HLT doesn't work, don't use it
    29                              <2> biosidles	equ	400h	; don't idle with HLT or Int2F.1680, only call BIOS Int16.00
    30                              <2> opt_usegetinput	equ	800h	; use getinput for int 21h interactive input
    31                              <2> use_si_units	equ    1000h	; in disp_*_size use SI units (kB = 1000, etc)
    32                              <2> use_jedec_units	equ    2000h	; in disp_*_size use JEDEC units (kB = 1024)
    33                              <2> enable_serial	equ    4000h	; enable serial I/O (preferred over DOS or BIOS terminal)
    34                              <2> int8_disable_serial equ	   8000h	; disable serial I/O when breaking due to intr8
    35                              <2> gg_do_not_skip_bp equ	 1_0000h	; gg: do not skip a breakpoint (bb or gg)
    36                              <2> gg_no_autorepeat equ	 2_0000h	; gg: do not auto-repeat
    37                              <2> tp_do_not_skip_bp equ	 4_0000h	; T/TP/P: do not skip a (bb) breakpoint
    38                              <2> gg_bb_hit_no_repeat equ	 8_0000h	; gg: do not auto-repeat after bb hit
    39                              <2> tp_bb_hit_no_repeat equ	10_0000h	; T/TP/P: do not auto-repeat after bb hit
    40                              <2> gg_unexpected_no_repeat equ 20_0000h	; gg: do not auto-repeat after unexpectedinterrupt
    41                              <2> tp_unexpected_no_repeat equ 40_0000h	; T/TP/P
    42                              <2> ss_no_dump:		equ 80_0000h
    43                              <2> %if _SYMBOLIC
    44                              <2> dd_no_blanks_sym:	equ 100_0000h
    45                              <2> zz_no_pm_xms:		equ 200_0000h
    46                              <2> %endif
    47                              <2> rr_disasm_no_rept:	equ 1000_0000h
    48                              <2> rr_disasm_no_show:	equ 2000_0000h
    49                              <2> opt_cmdline_quiet_input:equ 4000_0000h
    50                              <2> opt_cmdline_quiet_output:equ 8000_0000h
    51                              <2> %if _SYMBOLIC
    52                              <2> DEFAULTOPTIONS	equ zz_no_pm_xms
    53                              <2> %else
    54                              <2> DEFAULTOPTIONS	equ 0
    55                              <2> %endif
    56                              <2> 
    57                              <2> 
    58                              <2> opt2_db_header:		equ 1
    59                              <2> opt2_db_trailer:	equ 2
    60                              <2> opt2_dw_header:		equ 10h
    61                              <2> opt2_dw_trailer:	equ 20h
    62                              <2> opt2_dd_header:		equ 100h
    63                              <2> opt2_dd_trailer:	equ 200h
    64                              <2> opt2_getinput_dpmi:	equ 800h
    65                              <2> opt2_hh_compat:		equ 1000h
    66                              <2> opt2_getc_idle:		equ 2000h
    67                              <2> opt2_getc_idle_dpmi:	equ 4000h
    68                              <2> opt2_re_cancel_tpg:	equ 8000h
    69                              <2> opt2_nn_compat:		equ 1_0000h
    70                              <2> opt2_nn_capitalise:	equ 2_0000h
    71                              <2> %if _MS_0RANGE_COMPAT
    72                              <2> opt2_0range_compat:	equ 4_0000h
    73                              <2> %endif
    74                              <2> opt2_rr16_compat:	equ 8_0000h
    75                              <2> opt2_r_prompt_compat:	equ 10_0000h
    76                              <2> opt2_r_separate:	equ 20_0000h
    77                              <2> opt2_r_linebreak_always:equ 40_0000h
    78                              <2> opt2_dpminohlt:		equ 8000_0000h	; DPMI doesn't like hlt
    79                              <2> DEFAULTOPTIONS2	equ opt2_dw_header | opt2_dd_header | opt2_getc_idle_dpmi | opt2_dpminohlt
    80                              <2> 
    81                              <2> 
    82                              <2> opt3_tt_no_paging:	equ 1
    83                              <2> opt3_tp_no_paging:	equ 2
    84                              <2> opt3_pp_no_paging:	equ 4
    85                              <2> opt3_gg_no_paging:	equ 8
    86                              <2> opt3_silence_paging_set:equ 100h
    87                              <2> opt3_silence_paging_on:	equ 200h
    88                              <2> opt3_paging_rc:		equ 1000h
    89                              <2> opt3_paging_yy:		equ 2000h
    90                              <2> opt3_paging_re:		equ 4000h
    91                              <2> opt3_r_highlight_diff:	equ 10000h
    92                              <2> opt3_r_highlight_dumb:	equ 20000h
    93                              <2> opt3_r_highlight_full:	equ 40000h
    94                              <2> opt3_r_highlight_eip:	equ 80000h
    95                              <2> %if _PM
    96                              <2> opt3_ss_b_bit_set:	equ   10_0000h
    97                              <2>  %if _BREAK_INSTALLDPMI
    98                              <2> opt3_break_installdpmi:	equ   20_0000h
    99                              <2>  %endif
   100                              <2> %endif
   101                              <2> %if _DHIGHLIGHT
   102                              <2> opt3_d_highlight:	equ   80_0000h
   103                              <2> %endif
   104                              <2> %if _GETLINEHIGHLIGHT
   105                              <2> opt3_getline_highlight:	equ  100_0000h
   106                              <2> %endif
   107                              <2> opt3_no_idle_2F:	equ  200_0000h
   108                              <2> %if _DELAY_BEFORE_BP
   109                              <2> opt3_delay_before_bp:	equ  400_0000h
   110                              <2> %endif
   111                              <2> opt3_no_call_amis:	equ  800_0000h
   112                              <2> opt3_disable_autorepeat:equ 1000_0000h
   113                              <2> opt3_check_ctrlc_keyb:	equ 2000_0000h
   114                              <2> opt3_check_ctrlc_0bh:	equ 4000_0000h
   115                              <2> opt3_tsr_quit_leave_tf:	equ 8000_0000h
   116                              <2> DEFAULTOPTIONS3	equ opt3_tt_no_paging | opt3_tp_no_paging 		| opt3_pp_no_paging | opt3_gg_no_paging 		| opt3_check_ctrlc_keyb | opt3_check_ctrlc_0bh
   119                              <2> 
   120                              <2> 
   121                              <2> opt4_int_2F_hook:	equ 2
   122                              <2> opt4_int_08_hook:	equ 4
   123                              <2> opt4_int_2D_hook:	equ 8
   124                              <2> %if _CATCHINTFAULTCOND
   125                              <2> opt4_int_fault_hook:	equ 10h
   126                              <2> %endif
   127                              <2> opt4_int_serial_force:	equ 1_0000h
   128                              <2> opt4_int_2F_force:	equ 2_0000h
   129                              <2> opt4_int_08_force:	equ 4_0000h
   130                              <2> opt4_int_2D_force:	equ 8_0000h
   131                              <2> %if _CATCHINT0D
   132                              <2> opt4_int_0D_force:	equ   10_0000h
   133                              <2> %endif
   134                              <2> %if _CATCHINT0C
   135                              <2> opt4_int_0C_force:	equ   20_0000h
   136                              <2> %endif
   137                              <2> opt4_int_00_force:	equ  100_0000h
   138                              <2> opt4_int_01_force:	equ  200_0000h
   139                              <2> opt4_int_03_force:	equ  400_0000h
   140                              <2> opt4_int_06_force:	equ  800_0000h
   141                              <2> opt4_int_18_force:	equ 1000_0000h
   142                              <2> opt4_int_19_force:	equ 2000_0000h
   143                              <2> opt4_int_09_force:	equ 4000_0000h	; not used at the same time as 15h
   144                              <2> opt4_int_15_force:	equ 4000_0000h	; not used at the same time as 09h
   145                              <2> opt4_int_07_force:	equ 8000_0000h
   146                              <2> DEFAULTOPTIONS4 equ opt4_int_2F_hook
   147                              <2> 
   148                              <2> 
   149                              <2> %if _VXCHG
   150                              <2> opt6_vv_mode:		equ 1
   151                              <2> opt6_vv_keep:		equ 2
   152                              <2> opt6_vv_int16:		equ 10h
   153                              <2>  %if _VXCHG_DEFAULT_ON
   154                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq | opt6_vv_mode
   155                              <2>  %else
   156                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq
   157                              <2>  %endif
   158                              <2> %else
   159                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq
   160                              <2> %endif
   161                              <2> %if _DEBUG
   162                              <2> opt6_debug_exception_late:	equ  20h
   163                              <2> opt6_debug_exception_early:	equ  40h
   164                              <2>  %if _DEBUG_COND
   165                              <2> opt6_debug_exception:	equ  80h
   166                              <2> opt6_debug_mode:	equ 100h
   167                              <2>  %endif
   168                              <2> %endif
   169                              <2> opt6_bios_output:	equ 200h
   170                              <2> opt6_flat_binary:	equ 400h
   171                              <2> opt6_big_stack:		equ 800h
   172                              <2> opt6_40_columns:	equ 1000h
   173                              <2> opt6_40_indent_odd:	equ 2000h
   174                              <2> opt6_40_dash:		equ 4000h
   175                              <2> opt6_share_serial_irq:	equ 1_0000h
   176                              <2> opt6_serial_EOI_call:	equ 2_0000h
   177                              <2> %if _RH
   178                              <2> opt6_rh_mode:		equ 10_0000h
   179                              <2> %endif
   180                              <2> %if _DEBUG
   181                              <2> opt6_debug_putrunint_early:	equ  40_0000h
   182                              <2>  %if _DEBUG_COND
   183                              <2> opt6_debug_putrunint:		equ  80_0000h
   184                              <2>  %endif
   185                              <2> %endif
   186                              <2> opt6_bios_io:		equ 100_0000h
   187                              <2> opt6_immasm_display_uu:	equ 200_0000h
   188                              <2> opt6_immasm_debug:	equ 400_0000h
   189                              <2> opt6_immasm_flag:	equ 800_0000h
   190                              <2> opt6_immasm_nobranch:	equ 1000_0000h
   191                              <2> opt6_r_flags_style2:	equ 2000_0000h
   192                              <2> opt6_r_flags_style3:	equ 4000_0000h
   193                              <2> opt6_r_linebreak_conditional:	equ 8000_0000h
   194                              <2> 
   195                              <2> 
   196                              <2> DEFAULTOPTIONS7 equ opt7_no_tsr_ll
   197                              <2> opt7_no_free_oneshot_eld:	equ 1
   198                              <2> opt7_debug_optional_link:	equ 2
   199                              <2> opt7_quiet_install:		equ 4
   200                              <2> opt7_quick_run:			equ 8
   201                              <2> opt7_houdini:			equ 100h
   202                              <2> opt7_debug_run:			equ 200h
   203                              <2> opt7_no_ensure:			equ 1000h
   204                              <2> opt7_no_tsr_ll:			equ 2000h
   205                              <2> 
   206                              <2> 
   207                              <2> oldpacket	equ	  1	; Int25/Int26 packet method available (L, W)
   208                              <2> newpacket	equ	  2	; Int21.7305 packet method available (L, W)
   209                              <2> ntpacket	equ	  4	; VDD registered and usable (L, W)
   210                              <2> pagedcommand	equ	  8	; allows paging in puts
   211                              <2> notstdinput	equ	 10h	; DEBUG's StdIn isn't a device with StdIn bit (is file or other device)
   212                              <2> inputfile	equ	 20h	; DEBUG's StdIn is a file, notstdinput also set
   213                              <2> notstdoutput	equ	 40h	; DEBUG's StdOut isn't a device with StdOut bit (is file or other device)
   214                              <2> outputfile	equ	  80h	; DEBUG's StdOut is a file, notstdoutput also set
   215                              <2> hooked2F	equ	 100h	; Int2F hooked
   216                              <2> nohook2F	equ	 200h	; don't hook Int2F.1687 (required for Win9x, DosEmu?)
   217                              <2> unused_dif1_dpminohlt equ 400h	; DPMI doesn't like hlt
   218                              <2> protectedmode	equ	 800h	; in (DPMI) protected mode
   219                              <2> debuggeeA20	equ	1000h	; state of debuggee's A20
   220                              <2> debuggerA20	equ	2000h	; state of debugger's A20 (will be on if possible)
   221                              <2> nodosloaded	equ	4000h	; No DOS loaded currently (Boot loader mode)
   222                              <2> has386		equ	8000h	; CPU is a 386
   223                              <2> usecharcounter	equ    1_0000h	; don't reset charcounter between calls to puts
   224                              <2> runningnt	equ    2_0000h	; running in NTVDM
   225                              <2> canswitchmode	equ    4_0000h	; can switch modes (auxbuff large enough, DPMI mode switch set up)
   226                              <2> modeswitched	equ    8_0000h	; switched mode (now in the mode that we weren't entered in)
   227                              <2> promptwaiting	equ   10_0000h	; puts: any more output needs to display a prompt first
   228                              <2> switchbuffer	equ   20_0000h	; mode switch needs a buffer (auxbuff)
   229                              <2> tsrmode		equ   40_0000h	; in TSR mode; DPI and DPP not valid
   230                              <2> attachedterm	equ   80_0000h	; the attached process terminated
   231                              <2> runningdosemu	equ  100_0000h	; running in dosemu
   232                              <2> ; load_is_ldp	equ  200_0000h	; boot load: partition specified as "ldp"
   233                              <2> tt_while:	equ  400_0000h	; tt: while condition specified
   234                              <2> tt_p:		equ  800_0000h	; tt: proceed past repeated string instructions
   235                              <2> tt_silent_mode:	equ 1000_0000h	; tt: run should be silent (dump at end)
   236                              <2> tt_silence:	equ 2000_0000h	; tt: silent writing (write to auxbuff instead)
   237                              <2> tt_no_bb:	equ 4000_0000h	; tt: do not use bb breakpoints
   238                              <2> tt_no_bb_first:	equ 8000_0000h	; tt: do not use bb breakpoints at first
   239                              <2> 
   240                              <2> 
   241                              <2> dif2_gg_is_first:	equ   1
   242                              <2> dif2_gg_skip_non_cseip:	equ   2
   243                              <2> dif2_gg_skip_cseip:	equ   4
   244                              <2> dif2_gg_is_gg:		equ   8
   245                              <2> dif2_gg_first_detected:	equ  10h
   246                              <2> dif2_gg_again:		equ  20h
   247                              <2> dif2_tpg_proceed_bp_set:equ  40h
   248                              <2> dif2_tpg_keep_proceed_bp: equ 80h
   249                              <2> dif2_tpg_have_bp:	equ 100h
   250                              <2> dif2_tpg_adjusted_cseip:equ 200h
   251                              <2> dif2_tpg_do_not_adjust:	equ 400h
   252                              <2> dif2_bp_failure:	equ 800h
   253                              <2> dif2_is_pp:		equ 1000h
   254                              <2> %if _SYMBOLIC
   255                              <2> dif2_createdprocess:	equ 800_0000h	; created empty debuggee process
   256                              <2> dif2_sym_req_xms:	equ 2000h
   257                              <2> dif2_sym_req_86mm:	equ 4000h
   258                              <2> dif2_sym_req_mask equ dif2_sym_req_86mm | dif2_sym_req_xms
   259                              <2> dif2_no_pm_xms:		equ 1_0000h
   260                              <2> dif2_xms_detection_done:equ 2_0000h
   261                              <2> %endif
   262                              <2> %if _INPUT_FILE_HANDLES
   263                              <2> dif2_input_file:	equ 10_0000h
   264                              <2> dif2_closed_input_file:	equ 20_0000h
   265                              <2> %endif
   266                              <2> dif2_did_getline_file:	equ 40_0000h
   267                              <2> %if _SYMBOLIC
   268                              <2> dif2_poison:		equ 80_0000h
   269                              <2> %endif
   270                              <2> dif2_boot_loaded_kernel:equ 100_0000h
   271                              <2> %if _INPUT_FILE_BOOT
   272                              <2> dif2_input_file_boot:	equ 200_0000h
   273                              <2> dif2_closed_input_file_boot:	equ 400_0000h
   274                              <2> %endif
   275                              <2> dif2_in_silence_dump:	equ 1000_0000h
   276                              <2> dif2_int31_segment:	equ 2000_0000h
   277                              <2> dif2_nn_compat:		equ 4000_0000h
   278                              <2> dif2_nn_capitalise:	equ 8000_0000h
   279                              <2> 
   280                              <2> 
   281                              <2> dif3_load_is_ldp:	equ 1	; boot load: partition specified as "ldp"
   282                              <2> dif3_load_is_sdp:	equ 2	; boot load: partition specified as "sdp"
   283                              <2> dif3_load_is_ydp:	equ 4	; boot load: partition specified as "ydp"
   284                              <2> dif3_load_is_dp:	equ dif3_load_is_ldp 				| dif3_load_is_sdp 				| dif3_load_is_ydp
   287                              <2> dif3_load_dir_dir:	equ 8
   288                              <2> dif3_input_terminal_override:	equ 10h
   289                              <2> dif3_input_serial_override:	equ 20h
   290                              <2> dif3_if_not:		equ 40h
   291                              <2> dif3_partition_changed:	equ 80h
   292                              <2> ;
   293                              <2> dif3_input_cmdline:	equ 100h; input reading from cmdline_buffer
   294                              <2> dif3_input_cmdline_closed: equ 200h
   295                              <2> dif3_at_line_end:	equ 400h
   296                              <2> dif3_quiet_input_single:equ 800h
   297                              <2> dif3_quiet_output:	equ 1000h
   298                              <2> dif3_unquiet_error:	equ 2000h
   299                              <2> dif3_unquiet_prompt:	equ 4000h
   300                              <2> dif3_unquiet:		equ dif3_unquiet_error | dif3_unquiet_prompt
   301                              <2> dif3_return_eof:	equ 8000h
   302                              <2> dif3_highlighting:	equ 1_0000h
   303                              <2> dif3_do_not_highlight:	equ 2_0000h
   304                              <2> dif3_int10_highlight:	equ 2_0000h
   305                              <2> dif3_nosymbols_1:	equ 4_0000h
   306                              <2> dif3_nosymbols_2:	equ 8_0000h
   307                              <2> %if _PM
   308                              <2> dif3_ss_b_bit_set:	equ  10_0000h
   309                              <2> %endif
   310                              <2> dif3_gotint19:		equ  20_0000h
   311                              <2> dif3_prior_pm:		equ  40_0000h
   312                              <2> %if _DELAY_BEFORE_BP
   313                              <2> dif3_delayed		equ  80_0000h
   314                              <2> %endif
   315                              <2> dif3_input_re:		equ 100_0000h	; input reading from re_buffer
   316                              <2> dif3_input_re_closed:	equ 200_0000h
   317                              <2> dif3_accept_getrange_0:	equ 400_0000h
   318                              <2> %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
   319                              <2> dif3_in_if:		equ 800_0000h
   320                              <2> %endif
   321                              <2> dif3_auxbuff_guarded_1:	equ 1000_0000h
   322                              <2> dif3_auxbuff_guarded_2:	equ 2000_0000h
   323                              <2> dif3_auxbuff_guarded_3:	equ 4000_0000h
   324                              <2> dif3_sss_is_reverse:	equ 8000_0000h
   325                              <2> 
   326                              <2> 
   327                              <2> dif4_int_serial_hooked:	equ 1
   328                              <2> dif4_int_2F_hooked:	equ 2
   329                              <2> dif4_int_08_hooked:	equ 4
   330                              <2> dif4_int_2D_hooked:	equ 8
   331                              <2> %if _CATCHINTFAULTCOND && _CATCHINT0D
   332                              <2> dif4_int_0D_hooked:	equ 10h
   333                              <2> %endif
   334                              <2> %if _CATCHINTFAULTCOND && _CATCHINT0C
   335                              <2> dif4_int_0C_hooked:	equ 20h
   336                              <2> %endif
   337                              <2> %if _LOADER
   338                              <2> dif4_int_18_hooked:	equ 1000h
   339                              <2> dif4_int_19_hooked:	equ 2000h
   340                              <2> %endif
   341                              <2> 
   342                              <2> 
   343                              <2> %if _VXCHG
   344                              <2> dif6_vv_mode:		equ 1
   345                              <2> %endif
   346                              <2> dif6_in_hook2F:		equ 2
   347                              <2> dif6_in_amis_hook2F:	equ 4
   348                              <2> dif6_debug_mode:	equ 100h
   349                              <2> dif6_locked:		equ 200h
   350                              <2> dif6_mcp:		equ 400h
   351                              <2> %if _RH
   352                              <2> dif6_rh_mode_was:	equ  8_0000h
   353                              <2> dif6_rh_mode:		equ 10_0000h
   354                              <2> dif6_rh_mode_2:		equ 20_0000h
   355                              <2> %endif
   356                              <2> dif6_device_mode:	equ 40_0000h
   357                              <2> dif6_cpdepchars:	equ 80_0000h
   358                              <2> %if _IMMASM
   359                              <2> dif6_immasm_no_output:	equ 100_0000h
   360                              <2> dif6_immasm:		equ 200_0000h
   361                              <2> dif6_immasm_rel8:	equ 400_0000h
   362                              <2> %endif
   363                              <2> 
   364                              <2> 
   365                              <2> disasm_lowercase	equ 1
   366                              <2> disasm_commablank	equ 2
   367                              <2> disasm_nasm		equ 4
   368                              <2> disasm_lowercase_refmem:equ 8
   369                              <2> disasm_show_short:	equ 10h
   370                              <2> disasm_show_near:	equ 20h
   371                              <2> disasm_show_far:	equ 40h
   372                              <2> disasm_nec:		equ 80h
   373                              <2> disasm_40_columns:	equ 100h
   374                              <2> disasm_no_indent:	equ 200h
   375                              <2> disasm_msdebug_mnemonofs: equ 400h
   376                              <2> disasm_a16_memref:	equ 1000h
   377                              <2> disasm_a32_memref:	equ 2000h
   378                              <2> disasm_a16_string:	equ 4000h
   379                              <2> disasm_a32_string:	equ 8000h
   380                              <2> disasm_hide_modrm:	equ 10000h
   381                              <2> disasm_asize_loop_nasm:	equ 20000h
   382                              <2> disasm_modrm_always:	equ 40000h
   383                              <2> DEFAULTASMOPTIONS equ disasm_lowercase|disasm_commablank|disasm_nasm 	| disasm_a16_memref | disasm_a32_memref 	| disasm_a16_string | disasm_a32_string
   386                              <2> 
   387                              <2> 	; serial_flags values
   388                              <2> sf_init_done:	equ 1
   389                              <2> sf_ctrl_c:	equ 2
   390                              <2> sf_double_ctrl_c:	equ 4
   391                              <2> sf_built_in_fifo:	equ 8
   392                              <2> sf_use_serial:		equ 10h
  1560                              <1> %endif
    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 E9D018                  	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 7403E94803              	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 E83C03                  	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 E98D18                  	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 E86904                  	call getc.raw			; get a character from BIOS
   561 00000316 EB03                    	jmp short .dispover
   562                                  .getc:
   563 00000318 E84B04                  	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 743B                    	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 7520                    	jnz .notdos
   597 0000034C E8(0000)                	call InDOS_or_BIOS_output
   598 0000034F 751B                    	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 E306                    	jcxz @F
   603                                  %if _PM
   604                                  d5	push di
   605                                  	 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                                  	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                                  	dual2call _doscall_return_es_parameter_es_ds
   626                                  	 add sp, 2			; discard es returned from call
   627                                  d5	pop di
   628                                  %else
   629 00000358 1E                      	push ds
   630 00000359 06                      	 push es
   631 0000035A 1F                      	 pop ds				; ds:dx -> message
   632 0000035B CD21                    	int 21h				; simply call into DOS
   633 0000035D 1F                      	pop ds
   634                                  %endif
   635                                  @@:
   636 0000035E C3                      	retn
   637                                  
   638                                  .ctrlc:
   639                                  %if !_LOADER
   640 0000035F F606[0300]10            	testopt [internalflags2], dif2_in_silence_dump
   641 00000364 7403                    	jz @F
   642 00000366 E8F202                  	call reset_silent_mode
   643                                  @@:
   644                                  %endif
   645 00000369 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 0000036C 55                      	push bp
   667                                  		; Some int 10h functions can corrupt bp, eg
   668                                  		;  06h and 0Eh. Insure to preserve it here.
   669 0000036D 56                      	push si
   670 0000036E F606[0200]01            	testopt [internalflags], usecharcounter
   671 00000373 7505                    	jnz .dontresetcharcounter
   672 00000375 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 0000037A E35F                    	jcxz .return
   681 0000037C 89D6                    	mov si, dx
   682                                  .loop:
   683 0000037E 26AC                    	es lodsb
   684 00000380 3C09                    	cmp al, 9
   685 00000382 750B                    	jne .nottab			; is no tab -->
   686 00000384 A0[0000]                	mov al, byte [ charcounter ]
   687 00000387 2407                    	and al, 7			; at 8 character boundary ?
   688 00000389 B020                    	mov al, 32			; (always replaced by blank)
   689 0000038B 7402                    	jz .nottab			; yes, don't use hack -->
   690 0000038D 41                      	inc cx
   691 0000038E 4E                      	dec si				; find tab again next lodsb
   692                                  .nottab:
   693 0000038F 3C0D                    	cmp al, 13			; (exact match for CR)
   694 00000391 7505                    	jne .notcr
   695                                  .cr:
   696 00000393 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 00000398 3C0A                    	cmp al, 10
   724 0000039A 7406                    	je .dontcount_lf		; must not count line feeds!
   725 0000039C FE06[0000]              	inc byte [ charcounter ]
   726                                  %if _REGSHIGHLIGHT || _GETLINEHIGHLIGHT || _DHIGHLIGHT
   727 000003A0 EB05                    	jmp @F
   728                                  .dontcount_lf:
   729 000003A2 8026[0200]FD            	clropt [internalflags3], dif3_int10_highlight
   730                                  @@:
   731                                  %else
   732                                  .dontcount_lf:
   733                                  %endif
   734 000003A7 F606[0000]10            	testopt [serial_flags], sf_use_serial
   735 000003AC 7405                    	jz @F
   736                                  
   737 000003AE E8(0000)                	call serial_send_char
   738                                  
   739 000003B1 EB26                    	jmp .next
   740                                  @@:
   741                                  
   742                                  %if _REGSHIGHLIGHT || _GETLINEHIGHLIGHT || _DHIGHLIGHT || _CLEAR
   743 000003B3 3C1B                    	cmp al, 27
   744 000003B5 7427                    	je .try_highlight
   745                                  
   746                                  .nohighlight:
   747                                  %endif
   748 000003B7 8A3E[0000]              	mov bh, byte [vpage]		; use the current video page
   749                                  
   750                                  %if _REGSHIGHLIGHT || _GETLINEHIGHLIGHT || _DHIGHLIGHT
   751 000003BB F606[0200]02            	testopt [internalflags3], dif3_int10_highlight
   752 000003C0 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 000003C2 3C20                    	cmp al, 32
   761 000003C4 720D                    	jb @F
   762 000003C6 B409                    	mov ah, 09h
   763 000003C8 8A1E[0000]              	mov bl, byte [.attribute]
   764 000003CC 51                      	push cx
   765 000003CD B90100                  	mov cx, 1
   766 000003D0 CD10                    	int 10h
   767 000003D2 59                      	pop cx
   768                                  @@:
   769                                  %endif
   770                                  
   771 000003D3 B307                    	mov bl, 7
   772 000003D5 B40E                    	mov ah, 0Eh
   773 000003D7 CD10                    	int 10h
   774                                  .next:
   775 000003D9 E2A3                    	loop .loop
   776                                  .return:
   777 000003DB 5E                      	pop si
   778 000003DC 5D                      	pop bp
   779 000003DD C3                      	retn
   780                                  
   781                                  
   782                                  %if _REGSHIGHLIGHT || _GETLINEHIGHLIGHT || _DHIGHLIGHT || _CLEAR
   783                                  .try_highlight:
   784 000003DE F606[0200]02            	testopt [options3], opt3_r_highlight_dumb
   785 000003E3 75D2                    	jnz .nohighlight
   786 000003E5 83F902                  	cmp cx, 2
   787 000003E8 76CD                    	jbe .nohighlight
   788 000003EA 26803C5B                	cmp byte [es:si], '['
   789 000003EE 75C7                    	jne .nohighlight
   790                                   %if _REGSHIGHLIGHT || _GETLINEHIGHLIGHT || _DHIGHLIGHT
   791 000003F0 26807C016D              	cmp byte [es:si + 1], 'm'
   792 000003F5 742F                    	je .highlight_reset
   793                                   %endif
   794 000003F7 83F903                  	cmp cx, 3
   795 000003FA 74BB                    	je .nohighlight
   796                                   %if _CLEAR
   797 000003FC 26807C0132              	cmp byte [es:si + 1], '2'
   798 00000401 7507                    	jne @F
   799 00000403 26807C024A              	cmp byte [es:si + 2], 'J'
   800 00000408 7458                    	je .clear
   801                                  @@:
   802                                   %endif
   803                                   %if _REGSHIGHLIGHT || _GETLINEHIGHLIGHT || _DHIGHLIGHT
   804 0000040A 26807C0137              	cmp byte [es:si + 1], '7'
   805 0000040F 75A6                    	jne .nohighlight
   806 00000411 26807C026D              	cmp byte [es:si + 2], 'm'
   807 00000416 759F                    	jne .nohighlight
   808                                  .highlight_set:
   809 00000418 E87D00                  	call check_dumb_mode
   810 0000041B 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 0000041D 800E[0200]02            	setopt [internalflags3], dif3_int10_highlight
   815 00000422 49                      	dec cx
   816 00000423 46                      	inc si
   817 00000424 EB05                    	jmp @F
   818                                  
   819                                  .highlight_reset:
   820 00000426 E86F00                  	call check_dumb_mode
   821 00000429 748C                    	jz .nohighlight
   822                                  		; Refer to above comment.
   823                                  @@:
   824 0000042B 800E[0200]02            	setopt [internalflags3], dif3_int10_highlight
   825 00000430 E81800                  	call .getattrib
   826 00000433 88E0                    	mov al, ah
   827 00000435 257788                  	and ax, 8877h
   828 00000438 D0C0                    	rol al, 1
   829 0000043A D0C0                    	rol al, 1
   830 0000043C D0C0                    	rol al, 1
   831 0000043E D0C0                    	rol al, 1
   832 00000440 08E0                    	or al, ah
   833 00000442 A2[0000]                	mov byte [.attribute], al
   834                                   %endif
   835                                  
   836                                  .dec_2:
   837 00000445 49                      	dec cx
   838 00000446 49                      	dec cx
   839 00000447 46                      	inc si
   840 00000448 46                      	inc si
   841 00000449 EB8E                    	jmp .next
   842                                  
   843                                  .getattrib:
   844 0000044B FECA                    	dec dl
   845 0000044D B402                    	mov ah, 02h
   846 0000044F 8A3E[0000]              	mov bh, byte [vpage]
   847 00000453 CD10                    	int 10h			; set cursor position
   848 00000455 B408                    	mov ah, 08h
   849 00000457 CD10                    	int 10h			; read attribute to ah
   850 00000459 50                      	push ax
   851 0000045A FEC2                    	inc dl
   852 0000045C B402                    	mov ah, 02h
   853 0000045E CD10                    	int 10h			; set cursor position
   854 00000460 58                      	pop ax
   855 00000461 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 00000462 E83300                  	call check_dumb_mode
   870 00000465 7503E94DFF              	jz .nohighlight
   871                                  
   872 0000046A E8DEFF                  	call .getattrib
   873 0000046D 93                      	xchg bx, ax		; bh = attrib
   874                                  
   875 0000046E 06                      	push es
   876 0000046F B84000                  	mov ax, 40h		; bi-modal seg/sel
   877 00000472 8EC0                    	mov es, ax
   878 00000474 51                      	push cx
   879                                  
   880                                  		; copied from RxANSI
   881 00000475 31C9                    	xor	cx, cx
   882 00000477 268A164A00              	mov	dl, [es:4Ah]		; number of rows
   883 0000047C FECA                    	dec	dl
   884 0000047E 268A368400              	mov	dh, [es:84h]		; number of columns
   885 00000483 B80006                  	mov	ax, 0600h
   886 00000486 CD10                    	int	10h			; Clear screen (bh = attrib)
   887 00000488 31D2                    	xor	dx, dx			; Reset cursor to 0/0
   888 0000048A 8A3E[0000]              	mov bh, byte [vpage]
   889 0000048E B402                    	mov ah, 02h
   890 00000490 CD10                    	int 10h				; Set cursor
   891                                  
   892 00000492 59                      	pop cx
   893 00000493 07                      	pop es
   894                                  
   895 00000494 49                      	dec cx
   896 00000495 46                      	inc si
   897 00000496 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 00000498 50                      	push ax
   906 00000499 51                      	push cx
   907 0000049A B403                    	mov ah, 3
   908 0000049C 8A3E[0000]              	mov bh, byte [vpage]
   909 000004A0 31D2                    	xor dx, dx		; pre-initialise to zero
   910 000004A2 CD10                    	int 10h			; dl = column, dh = row
   911 000004A4 84D2                    	test dl, dl
   912 000004A6 7416                    	jz .ret
   913 000004A8 F606[0300]01            	testopt [internalflags], runningdosemu
   914 000004AD 740D                    	jz .ret_NZ
   915 000004AF B85500                  	mov ax, 55h		; function DOS_HELPER_GET_TERM_TYPE
   916 000004B2 CDE6                    	int 0E6h		; CHG: ax, bx, cx
   917 000004B4 80E401                  	and ah, 1		; ax & 100h = dumb mode
   918 000004B7 80F401                  	xor ah, 1		; NZ if not dumb mode
   919 000004BA EB02                    	jmp .ret
   920                                  .ret_NZ:
   921 000004BC 85E4                    	test sp, sp		; (NZ)
   922                                  .ret:
   923 000004BE 59                      	pop cx
   924 000004BF 58                      	pop ax
   925 000004C0 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 000004C1 89F9                    	mov cx, di
   940 000004C3 BA[0000]                	mov dx, line_out
   941 000004C6 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 000004C8 01C8                    	add ax, cx				; how much in this line if fits
   953 000004CA 8B1E[0000]              	mov bx, word [io_columns_getline]	; = how many columns to fill
   954 000004CE 85DB                    	test bx, bx				; disabled ?
   955 000004D0 7415                    	jz .no_split				; yes, use normal handler -->
   956 000004D2 39D8                    	cmp ax, bx				; total <= columns ?
   957 000004D4 7611                    	jbe .no_input_split			; yes, back to normal code -->
   958 000004D6 56                      	push si
   959 000004D7 89CE                    	mov si, cx				; si = length input
   960 000004D9 29C8                    	sub ax, cx				; restore last fragment length
   961 000004DB 89D9                    	mov cx, bx
   962 000004DD 29C1                    	sub cx, ax				; = how much fits in first line
   963 000004DF 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 000004E1 E81500                  	call puts_partial_write
   972 000004E4 91                      	xchg ax, cx				; ax = last fragment length
   973 000004E5 5E                      	pop si
   974 000004E6 C3                      	retn
   975                                  
   976                                  .no_split:
   977                                  .no_input_split:
   978 000004E7 50                      	push ax
   979 000004E8 E8C4FC                  	call puts
   980 000004EB 58                      	pop ax
   981                                  puts_break_line_more.retn:
   982 000004EC 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 000004ED 85C0                    	test ax, ax
   994 000004EF 75FB                    	jnz .retn
   995 000004F1 BA[0000]                	mov dx, crlf
   996 000004F4 E90C02                  	jmp putsz
   997                                  
   998                                  
   999                                  puts_partial_write.loop:
  1000 000004F7 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 000004F9 53                      	push bx
  1010 000004FA 51                      	push cx
  1011 000004FB 52                      	push dx
  1012 000004FC E8B0FC                  	call puts				; display partial
  1013 000004FF 85F6                    	test si, si				; more to go ?
  1014 00000501 7406                    	jz @F					; no -->
  1015 00000503 BA[0000]                	mov dx, crlf
  1016 00000506 E8FA01                  	call putsz				; put linebreak
  1017                                  @@:
  1018 00000509 5A                      	pop dx
  1019 0000050A 59                      	pop cx
  1020 0000050B 5B                      	pop bx
  1021 0000050C 01CA                    	add dx, cx				; advance pointer
  1022 0000050E 29DE                    	sub si, bx				; subtract from counter
  1023 00000510 73E5                    	jnc .loop				; still above zero, loop -->
  1024 00000512 01DE                    	add si, bx				; restore prior si value
  1025 00000514 89F1                    	mov cx, si
  1026 00000516 53                      	push bx
  1027 00000517 51                      	push cx
  1028 00000518 E894FC                  	call puts				; display last part (possibly empty)
  1029 0000051B 59                      	pop cx					; return cx
  1030 0000051C 5B                      	pop bx
  1031 0000051D 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 0000051E 56                      	push si
  1046 0000051F 57                      	push di
  1047                                  
  1048                                  .try_again:
  1049 00000520 89D6                    	mov si, dx			; es:si -> message
  1050 00000522 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 00000526 A1[0000]                	mov ax, word [auxbuff_current_size]
  1056 00000529 48                      	dec ax
  1057                                  %endif
  1058 0000052A 29F8                    	sub ax, di			; number of bytes left free
  1059                                  					;  (+ 1 byte terminator)
  1060 0000052C 7204                    	jc .delete
  1061 0000052E 39C8                    	cmp ax, cx			; fits ?
  1062 00000530 730B                    	jae .simple			; yes -->
  1063                                  
  1064                                  .delete:
  1065 00000532 06                      	push es
  1066 00000533 8E06[0000]              	mov es, word [auxbuff_segorsel]
  1067 00000537 E81600                  	call silence_delete_one_string
  1068 0000053A 07                      	pop es
  1069 0000053B EBE3                    	jmp .try_again
  1070                                  
  1071                                  .simple:
  1072 0000053D 1E                      	push ds
  1073 0000053E 06                      	push es
  1074 0000053F 06                      	 push es
  1075 00000540 8E06[0000]              	 mov es, word [auxbuff_segorsel]
  1076                                  					; es:di -> next buffer
  1077 00000544 1F                      	 pop ds				; ds:si -> message
  1078 00000545 F3A4                    	rep movsb			; copy over
  1079 00000547 07                      	pop es
  1080 00000548 1F                      	pop ds
  1081 00000549 893E[0000]              	mov word [auxbuff_behind_last_silent], di
  1082                                  					; update pointer
  1083 0000054D 5F                      	pop di
  1084 0000054E 5E                      	pop si
  1085 0000054F 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 00000550 E81F00                  	call .internal			; call internal implementation
  1098 00000553 734F                    	jnc .retn			; no error ? -->
  1099                                  .error:					; else: error, abort command
  1100 00000555 16                      	push ss
  1101 00000556 1F                      	pop ds
  1102 00000557 16                      	push ss
  1103 00000558 07                      	pop es
  1104 00000559 8026[0300]DF            	clropt [internalflags], tt_silence
  1105                                  %if _RH
  1106 0000055E C606[0000]FF            	mov byte [skip_rh], 0FFh
  1107                                  %endif
  1108 00000563 BA[0000]                	mov dx, msg.silent_error
  1109 00000566 E89A01                  	call putsz
  1110 00000569 B83501                  	mov ax, 0135h
  1111 0000056C E8(0000)                	call setrc
  1112 0000056F 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 00000572 51                      	push cx
  1123 00000573 8B0E[0000]              	mov cx, [auxbuff_behind_last_silent]
  1124                                  					; -> next buffer position
  1125                                  %if _PM
  1126                                  	mov di, word [auxbuff_switchbuffer_size]
  1127                                  	sub cx, di
  1128                                  %else
  1129 00000577 31FF                    	xor di, di
  1130                                  %endif
  1131 00000579 B000                    	mov al, 0
  1132 0000057B 3C01                    	cmp al, 1			; initialise to NZ (if cx is zero)
  1133 0000057D F2AE                    	repne scasb
  1134 0000057F F9                      	stc
  1135 00000580 7522                    	jne .retn			; error, no NUL found in data (CY)
  1136                                  		; es:di -> behind first NUL
  1137                                  
  1138 00000582 89FE                    	mov si, di			; es:si -> next message
  1139                                  %if _RH
  1140 00000584 89F8                    	mov ax, di
  1141                                  %endif
  1142                                  %if _PM
  1143                                  	mov di, word [auxbuff_switchbuffer_size]
  1144                                   %if _RH
  1145                                  	sub ax, di			; -> next minus -> first, length of first
  1146                                   %endif
  1147                                  %else
  1148 00000586 31FF                    	xor di, di
  1149                                  %endif
  1150                                  %if _RH
  1151 00000588 2906[0000]              	sub word [auxbuff_start_silent], ax
  1152                                   %if _PM
  1153                                  	jb .reset_start
  1154                                  	cmp word [auxbuff_start_silent], di
  1155                                   %endif
  1156 0000058C 7304                    	jae @F
  1157                                  .reset_start:
  1158 0000058E 893E[0000]              	mov word [auxbuff_start_silent], di
  1159                                  @@:
  1160                                  %endif
  1161 00000592 8B0E[0000]              	mov cx, word [auxbuff_behind_last_silent]
  1162 00000596 06                      	push es
  1163 00000597 1F                      	pop ds				; ds:si -> next message
  1164 00000598 29F1                    	sub cx, si			; remaining buffer
  1165 0000059A F3A4                    	rep movsb			; move to start of silent buffer
  1166 0000059C 16                      	push ss
  1167 0000059D 1F                      	pop ds
  1168 0000059E 893E[0000]              	mov word [auxbuff_behind_last_silent], di
  1169 000005A2 59                      	pop cx
  1170 000005A3 F8                      	clc				; (NC)
  1171                                  .retn:
  1172 000005A4 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 000005A5 F606[0300]10            	testopt [internalflags], tt_silent_mode	; is in use ?
  1186 000005AA 7501                    	jnz @F			; yes -->
  1187 000005AC C3                      	retn			; no. simple
  1188                                  
  1189                                  @@:
  1190                                  %if _RH
  1191 000005AD C606[0000]00            	mov byte [rh_display_with_count], 0
  1192                                  .rh.all:
  1193 000005B2 B8FFFF                  	mov ax, -1
  1194                                  .rh:
  1195 000005B5 A3[0000]                	mov word [auxbuff_amount_silent], ax
  1196                                  %endif
  1197 000005B8 8026[0300]DF            	clropt [internalflags], tt_silence
  1198 000005BD 800E[0300]10            	setopt [internalflags2], dif2_in_silence_dump
  1199                                  
  1200 000005C2 F606[0100]01            	testopt [options3], opt3_silence_paging_set
  1201 000005C7 7413                    	jz @F
  1202 000005C9 F606[0100]02            	testopt [options3], opt3_silence_paging_on
  1203 000005CE 7407                    	jz .turn_paging_off
  1204                                  
  1205                                  .turn_paging_on:
  1206 000005D0 800E[0000]08            	setopt [internalflags], pagedcommand
  1207 000005D5 EB05                    	jmp @F
  1208                                  
  1209                                  .turn_paging_off:
  1210 000005D7 8026[0000]F7            	clropt [internalflags], pagedcommand
  1211                                  @@:
  1212                                  
  1213 000005DC E8BA00                  	call silence_get_start
  1214 000005DF 741E                    	jz .no_number_given
  1215                                  
  1216 000005E1 8B16[0000]              	mov dx, word [tt_silent_mode_number]
  1217 000005E5 85D2                    	test dx, dx
  1218 000005E7 7416                    	jz .no_number_given
  1219                                  
  1220 000005E9 E8BC00                  	call silence_count_zeroes
  1221                                  
  1222                                  %if _RH
  1223 000005EC 8B3E[0000]              	mov di, word [auxbuff_start_silent]
  1224                                  				; reset to -> silent buffered data
  1225                                  %endif
  1226 000005F0 29D3                    	sub bx, dx		; number of dumps - requested number
  1227                                  				;  = excess number of dumps
  1228 000005F2 760B                    	jbe .no_number_given
  1229                                  
  1230 000005F4 89D9                    	mov cx, bx		; use excess number as loop counter
  1231                                  @@:
  1232                                  %if _RH
  1233 000005F6 51                      	push cx
  1234 000005F7 B9FFFF                  	mov cx, -1
  1235                                  	; mov al, 0
  1236 000005FA F2AE                    	repne scasb
  1237 000005FC 59                      	pop cx
  1238                                  %else
  1239                                  	call silence_delete_one_string
  1240                                  				; delete one string
  1241                                  %endif
  1242 000005FD E2F7                    	loop @B			; loop for however many to delete -->
  1243                                  
  1244                                  .no_number_given:
  1245                                  %if _RH
  1246 000005FF 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 00000602 8E06[0000]              	mov es, word [auxbuff_segorsel]
  1259 00000606 8B0E[0000]              	mov cx, word [auxbuff_behind_last_silent]
  1260 0000060A 29F9                    	sub cx, di		; any more data ?
  1261 0000060C 744B                    	jz .return		; no, return -->
  1262 0000060E B000                    	mov al, 0
  1263 00000610 49                      	dec cx			; (in case of branching for next conditional)
  1264 00000611 AE                      	scasb			; starts with a NUL byte ?
  1265 00000612 7404                    	je @F			; yes, skipped -->
  1266 00000614 41                      	inc cx			; (restore cx to original value)
  1267 00000615 4F                      	dec di			; no, decrement
  1268                                  %if _RH
  1269 00000616 EB05                    	jmp @FF
  1270                                  @@:
  1271 00000618 E303                    	jcxz @F			; anything follows the NUL ?
  1272 0000061A E84900                  	call .rh_display_count
  1273                                  %endif
  1274                                  @@:
  1275 0000061D 89FE                    	mov si, di		; es:si -> start of string
  1276                                  
  1277 0000061F 81F90001                	cmp cx, 256		; cx > 256 ?
  1278 00000623 7603                    	jbe @F			; no -->
  1279 00000625 B90001                  	mov cx, 256		; limit to 256 bytes per string
  1280                                  				; (line_out is 264 bytes)
  1281                                  @@:
  1282 00000628 E32F                    	jcxz .return		; (if single byte that was NUL remaining -->)
  1283 0000062A 89CB                    	mov bx, cx		; search string length
  1284 0000062C B000                    	mov al, 0
  1285 0000062E F2AE                    	repne scasb		; scan for NUL bytes
  1286 00000630 7505                    	jne @F			; (if none found: cx = 0)
  1287                                  				; (if any found: cx = remaining length)
  1288 00000632 41                      	inc cx			; cx = remaining length + 1 (do not output NUL)
  1289                                  %if _RH
  1290 00000633 FF0E[0000]              	dec word [auxbuff_amount_silent]
  1291                                  %endif
  1292                                  @@:
  1293 00000637 29CB                    	sub bx, cx		; search length - remaining = found length
  1294 00000639 89D9                    	mov cx, bx		; how much to show
  1295 0000063B 06                      	 push es
  1296 0000063C 1F                      	 pop ds			; ds => auxbuff (ds:si -> start of string)
  1297 0000063D 16                      	 push ss
  1298 0000063E 07                      	 pop es			; es => line_out
  1299 0000063F BF[0000]                	mov di, line_out	; es:di -> line_out
  1300 00000642 51                      	 push cx
  1301 00000643 F3A4                    	rep movsb		; copy over to line_out
  1302 00000645 59                      	 pop cx			; cx = message length
  1303                                  
  1304 00000646 16                      	push ss
  1305 00000647 1F                      	pop ds			; reset seg regs to ss
  1306 00000648 BA[0000]                	mov dx, line_out	; dx -> message, cx = length
  1307 0000064B 56                      	push si
  1308 0000064C E895FB                  	call puts.no_rh		; print out
  1309 0000064F 5F                      	pop di			; -> next silent message
  1310                                  %if _RH
  1311 00000650 833E[0000]00            	cmp word [auxbuff_amount_silent], 0
  1312 00000655 7402                    	je .return
  1313                                  %endif
  1314 00000657 EBA9                    	jmp .loop_line
  1315                                  
  1316                                  .return:
  1317 00000659 16                      	push ss
  1318 0000065A 07                      	pop es
  1319                                  
  1320                                  reset_silent_mode: equ $
  1321 0000065B 8026[0300]CF            	clropt [internalflags], tt_silent_mode | tt_silence
  1322 00000660 8026[0300]EF            	clropt [internalflags2], dif2_in_silence_dump
  1323 00000665 C3                      	retn
  1324                                  
  1325                                  
  1326                                  %if _RH
  1327                                  .rh_display_count:
  1328 00000666 D006[0000]              	rol byte [rh_display_with_count], 1
  1329 0000066A 57                      	push di
  1330 0000066B 51                      	push cx
  1331 0000066C 06                      	push es
  1332 0000066D 7326                    	jnc @F
  1333 0000066F A1[0000]                	mov ax, word [rh_count_number]
  1334 00000672 83F8FF                  	cmp ax, -1
  1335 00000675 741E                    	je @F
  1336 00000677 FF0E[0000]              	dec word [rh_count_number]
  1337 0000067B 16                      	 push ss
  1338 0000067C 07                      	 pop es
  1339 0000067D BF[0000]                	mov di, line_out
  1340 00000680 BE[0000]                	mov si, msg.rh_step.1
  1341 00000683 E8(0000)                	call copy_single_counted_string
  1342 00000686 E8E2FA                  	call hexword
  1343 00000689 BE[0000]                	mov si, msg.rh_step.2
  1344 0000068C E8(0000)                	call copy_single_counted_string
  1345 0000068F E85EFA                  	call decword
  1346 00000692 E80FFB                  	call putsline_crlf
  1347                                  @@:
  1348 00000695 07                      	pop es
  1349 00000696 59                      	pop cx
  1350 00000697 5F                      	pop di
  1351 00000698 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 00000699 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 0000069D 8E06[0000]              	mov es, word [auxbuff_segorsel]
  1372 000006A1 8B0E[0000]              	mov cx, word [auxbuff_behind_last_silent]
  1373 000006A5 29F9                    	sub cx, di
  1374 000006A7 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 000006A8 31DB                    	xor bx, bx		; counter of zeros
  1384                                  @@:
  1385 000006AA 43                      	inc bx			; count zeros (NZ)
  1386 000006AB 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 000006AD F2AE                    	repne scasb		; another zero ?
  1393 000006AF 74F9                    	je @B			; yes, count and search for next -->
  1394                                  				; no, done
  1395                                  @@:
  1396 000006B1 4B                      	dec bx			; drop bias
  1397 000006B2 C3                      	retn
  1398                                  %endif
  1399                                  
  1400                                  
  1401                                  %if _MESSAGESEGMENT && _PM
  1402                                  get_messagesegsel:
  1403                                   	mov ds, word [ss:messagesel]
  1404                                   	call ispm
  1405                                   	jz .ret_pm
  1406                                  .86m:
  1407                                   	mov ds, word [ss:messageseg]
  1408                                  .ret_pm:
  1409                                   	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 000006B3 F6C201                  	test dl, 1
  1424 000006B6 753A                    	jnz .uncompressed
  1425                                  
  1426                                  .compressed:
  1427 000006B8 1E                      	push ds
  1428 000006B9 50                      	push ax
  1429 000006BA 53                      	push bx
  1430 000006BB 51                      	push cx
  1431 000006BC 52                      	push dx
  1432 000006BD 06                      	push es
  1433 000006BE 57                      	push di
  1434 000006BF 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 000006C0 87F2                    	xchg si, dx			; si -> message compressed length
  1441                                  %if _MESSAGESEGMENT
  1442                                   %if _PM
  1443                                  	call get_messagesegsel		; ds => message segment
  1444                                   %else
  1445 000006C2 368E1E[0000]             	mov ds, word [ss:messageseg]	; ds => message segment
  1446                                   %endif
  1447 000006C7 AD                      	lodsw				; = length
  1448                                  %else
  1449                                  	ss lodsw			; = length
  1450                                  %endif
  1451 000006C8 91                      	xchg cx, ax			; = length
  1452 000006C9 368936[0000]            	mov word [ss:hshrink_memory_source.offset], si
  1453                                  					; save offset of data
  1454 000006CE 1E                      	push ds
  1455 000006CF 07                      	pop es				; => message segment
  1456                                  %if _BOOTLDR_DISCARD_HELP
  1457 000006D0 368B3E[0000]            	mov di, [ss:indirect_hshrink_message_buffer]
  1458 000006D5 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 000006D9 06                      	push es
  1465 000006DA 57                      	push di
  1466 000006DB E8(0000)                	call depack			; try depacking
  1467                                  		; ds reset before calling puts
  1468 000006DE 5A                      	pop dx				; display our decompressed string
  1469 000006DF 07                      	pop es
  1470 000006E0 730D                    	jnc @F				; skip next part if not error -->
  1471 000006E2 16                      	push ss
  1472 000006E3 07                      	pop es
  1473 000006E4 16                      	push ss
  1474 000006E5 1F                      	pop ds
  1475 000006E6 B82B01                  	mov ax, 012Bh
  1476 000006E9 E8(0000)                	call setrc
  1477 000006EC BA[0000]                	mov dx, msg.hshrink_error	; if error
  1478                                  @@:
  1479 000006EF 5E                      	pop si
  1480 000006F0 EB1A                    	jmp putsz.saved
  1481                                  
  1482                                  .uncompressed:
  1483 000006F2 80E2FE                  	and dl, ~1
  1484                                  		; fall through to putsz_messagesegsel
  1485                                  
  1486                                  %endif
  1487                                  
  1488                                  putsz_messagesegsel:
  1489 000006F5 1E                      	push ds
  1490                                  %if _MESSAGESEGMENT
  1491                                   %if _PM
  1492                                  	call get_messagesegsel
  1493                                   %else
  1494 000006F6 368E1E[0000]             	mov ds, word [ss:messageseg]
  1495                                   %endif
  1496                                  %else
  1497                                  	push ss
  1498                                  	pop ds
  1499                                  %endif
  1500 000006FB EB07                     	jmp @F
  1501                                  
  1502                                  
  1503                                  putsz_error: section_of_function
  1504 000006FD 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 00000703 1E                      	push ds
  1513                                  @@:
  1514 00000704 50                      	push ax
  1515 00000705 53                      	push bx
  1516 00000706 51                      	push cx
  1517 00000707 52                      	push dx
  1518 00000708 06                      	push es
  1519 00000709 1E                      	 push ds
  1520 0000070A 07                      	 pop es
  1521 0000070B 57                      	push di
  1522                                  .saved:
  1523 0000070C 89D7                    	mov di, dx			; es:di-> string
  1524 0000070E 30C0                    	xor al, al
  1525 00000710 B9FFFF                  	mov cx, -1
  1526 00000713 F2AE                    	repne scasb			; search zero
  1527 00000715 F7D1                    	not cx
  1528 00000717 49                      	dec cx				; cx = length of message
  1529 00000718 5F                      	pop di
  1530 00000719 16                      	 push ss
  1531 0000071A 1F                      	 pop ds				; ds = ss
  1532 0000071B E891FA                  	call puts
  1533 0000071E 07                      	pop es
  1534 0000071F 5A                      	pop dx
  1535 00000720 59                      	pop cx
  1536 00000721 5B                      	pop bx
  1537 00000722 58                      	pop ax
  1538 00000723 1F                      	pop ds
  1539 00000724 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 00000725 53                      	push bx
  1552 00000726 51                      	push cx
  1553 00000727 52                      	push dx
  1554 00000728 06                      	push es
  1555 00000729 1E                      	push ds
  1556 0000072A 16                      	 push ss
  1557 0000072B 07                      	 pop es				; es:dx -> message
  1558 0000072C 16                      	 push ss
  1559 0000072D 1F                      	 pop ds				; ds = ss
  1560 0000072E 50                      	push ax
  1561 0000072F B90100                  	mov cx, 1			; one character
  1562 00000732 89E2                    	mov dx, sp			; ds:dx-> ax on stack
  1563 00000734 E878FA                  	call puts
  1564 00000737 58                      	pop ax
  1565 00000738 1F                      	pop ds
  1566 00000739 07                      	pop es
  1567 0000073A 5A                      	pop dx
  1568 0000073B 59                      	pop cx
  1569 0000073C 5B                      	pop bx
  1570 0000073D 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 0000073E F606[0000]10            	testopt [serial_flags], sf_use_serial
  1580 00000743 750C                    	jnz .serial
  1581 00000745 E8(0000)                	call InDOS_or_BIOS_IO
  1582 00000748 740E                    	jz .dos
  1583                                  .bios:
  1584 0000074A B401                    	mov ah, 01h
  1585 0000074C CD16                    	int 16h			; key available ?
  1586                                  @@:
  1587 0000074E 7412                    	jz .return_ax_0
  1588 00000750 C3                      	retn
  1589                                  
  1590                                  .serial:
  1591 00000751 E8(0000)                	call serial_check_receive_char
  1592                                  				; do serial getc (check rx buffer)
  1593 00000754 B400                    	mov ah, 0
  1594 00000756 EBF6                    	jmp @B
  1595                                  
  1596                                  .dos:
  1597 00000758 B40B                    	mov ah, 0Bh
  1598                                  	doscall
  1497 0000075A CD21                <1>  int 21h
  1599 0000075C B4FF                    	mov ah, -1
  1600 0000075E 84C0                    	test al, al
  1601 00000760 EBEC                    	jmp @B
  1602                                  
  1603                                  .return_ax_0:
  1604 00000762 B80000                  	mov ax, 0
  1605                                  .return:
  1606 00000765 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 00000766 57                      	push di
  1620 00000767 BF[6109]                	mov di, getc_if_any
  1621                                  
  1622 0000076A F606[0000]20            	testopt [internalflags3], dif3_input_serial_override
  1623 0000076F 750C                    	jnz @F
  1624 00000771 F606[0000]10            	testopt [serial_flags], sf_use_serial
  1625 00000776 7505                    	jnz @F
  1626 00000778 E8(0000)                	call InDOS_or_BIOS_IO
  1627 0000077B 7450                    	jz getc_dos_pop_di
  1628                                  @@:
  1629 0000077D EB04                    	jmp @F
  1630                                  
  1631                                  .raw:
  1632 0000077F 57                      	push di
  1633 00000780 BF[CB09]                	mov di, getc_if_any.raw
  1634                                  .loop:
  1635                                  @@:
  1636 00000783 FF16[0000]              	call near word [getline_timer_func]
  1637 00000787 F606[0000]20            	testopt [internalflags3], dif3_input_serial_override
  1638 0000078C 7523                    	jnz @F
  1639 0000078E F606[0300]01            	testopt [internalflags3], dif3_input_re
  1640 00000793 751C                    	jnz @F
  1641                                  %if _INPUT_FILE_BOOT
  1642 00000795 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  1643 0000079A 7515                    	jnz @F
  1644                                  %endif
  1645 0000079C F606[0100]01            	testopt [internalflags3], dif3_input_cmdline
  1646 000007A1 750E                    	jnz @F
  1647 000007A3 F606[0000]10            	testopt [serial_flags], sf_use_serial
  1648 000007A8 7507                    	jnz @F
  1649 000007AA F606[0100]04            	testopt [options], biosidles
  1650                                  				; idling disabled?
  1651 000007AF 7516                    	jnz .rawkey		; yes, just request a key -->
  1652                                  
  1653                                  @@:
  1654 000007B1 FFD7                    	call di			; got a key ?
  1655 000007B3 7516                    	jnz .return		; yes -->
  1656                                  .idle:				; common idling for BIOS keyboard and serial
  1657 000007B5 E8(0000)                	call handle_serial_flags_ctrl_c
  1658                                  %if _SLEEP_NEW
  1659 000007B8 57                      	push di
  1660 000007B9 8B3E[0000]              	mov di, word [getc_repeat_idle]
  1661 000007BD 47                      	inc di
  1662                                  @@:
  1663 000007BE E88102                  	call idle
  1664 000007C1 4F                      	dec di
  1665 000007C2 75FA                    	jnz @B
  1666 000007C4 5F                      	pop di
  1667                                  %else
  1668                                  	call idle
  1669                                  %endif
  1670 000007C5 EBBC                    	jmp .loop		; check again -->
  1671                                  
  1672                                  .rawkey:
  1673 000007C7 31C0                    	xor ax, ax
  1674 000007C9 CD16                    	int 16h			; get the key and scancode
  1675                                  .return:
  1676 000007CB 5F                      	pop di
  1677 000007CC C3                      	retn
  1678                                  
  1679                                  
  1680                                  getc_dos_pop_di:
  1681 000007CD 5F                      	pop di
  1682                                  getc_dos:
  1683                                  %if _PM
  1684                                  	call ispm
  1685                                  	jnz @F			; if 86 Mode -->
  1686                                  	testopt [options2], opt2_getc_idle_dpmi
  1687                                  	jnz @FF
  1688                                  @@:
  1689                                  %endif
  1690 000007CE F606[0100]20            	testopt [options2], opt2_getc_idle
  1691 000007D3 7410                    	jz getc_dos_internal
  1692                                  @@:
  1693                                  .with_idle:
  1694 000007D5 E88901                  	call getc_if_any
  1695 000007D8 7403E9BC00              	jnz .return
  1696 000007DD E8(0000)                	call handle_serial_flags_ctrl_c
  1697 000007E0 E85F02                  	call idle
  1698 000007E3 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 000007E5 F606[0000]10            	testopt [internalflags3], dif3_input_terminal_override
  1709 000007EA 7403E99300              	jnz .terminal
  1710                                  %if !_LOADER
  1711 000007EF F606[0300]01            	testopt [internalflags3], dif3_input_re
  1712 000007F4 741B                    	jz @F
  1713 000007F6 56                      	push si
  1714 000007F7 8B36[0000]              	mov si, word [re_buffer.position]
  1715 000007FB 31C0                    	xor ax, ax
  1716 000007FD AC                      	lodsb
  1717 000007FE 84C0                    	test al, al
  1718 00000800 8936[0000]              	mov word [re_buffer.position], si
  1719 00000804 5E                      	pop si
  1720 00000805 7403E98F00              	jnz .return
  1721 0000080A FF0E[0000]              	dec word [re_buffer.position]
  1722 0000080E E98800                  	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 00000811 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  1732 00000816 750E                    	jnz .file
  1733                                  %endif
  1734                                  %if _INPUT_FILE_HANDLES
  1735 00000818 E8(0000)                	call InDOS_or_BIOS_IO
  1736 0000081B 7545                    	jnz .file_not
  1737 0000081D F606[0200]10            	testopt [internalflags2], dif2_input_file
  1738 00000822 7502                    	jnz .file
  1739                                  %endif
  1740 00000824 EB3C                    	jmp .file_not
  1741                                  
  1742                                  .file:
  1743 00000826 52                      	push dx
  1744 00000827 51                      	push cx
  1745 00000828 53                      	push bx
  1746 00000829 57                      	push di
  1747 0000082A 31C0                    	xor ax, ax		; initialise ah to zero
  1748 0000082C 50                      	push ax
  1749 0000082D 89E2                    	mov dx, sp		; ds:dx -> al byte on stack
  1750 0000082F B90100                  	mov cx, 1
  1751                                  %if _INPUT_FILE_BOOT
  1752                                   %if _INPUT_FILE_HANDLES
  1753 00000832 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  1754 00000837 7408                    	jz @F
  1755                                   %endif
  1756 00000839 E8(0000)                	call yy_boot_remember_seek
  1757 0000083C E8(0000)                	call yy_boot_read
  1758                                   %if _INPUT_FILE_HANDLES
  1759 0000083F EB0A                    	jmp @FF
  1760                                  @@:
  1761                                   %endif
  1762                                  %endif
  1763                                  %if _INPUT_FILE_HANDLES
  1764 00000841 B43F                    	mov ah, 3Fh
  1765 00000843 E80C01                  	call yy_get_handle
  1766 00000846 E85F13                  	call yy_remember_seek
  1767                                  	doscall			; (depends on ds = ss)
  1497 00000849 CD21                <1>  int 21h
  1768                                  %endif
  1769                                  @@:
  1770 0000084B 7204                    	jc @F
  1771 0000084D 85C0                    	test ax, ax
  1772 0000084F 750B                    	jnz .file_got
  1773                                  
  1774                                  @@:
  1775 00000851 E84F00                  	call yy_close_file
  1776 00000854 58                      	pop ax
  1777 00000855 5F                      	pop di
  1778 00000856 5B                      	pop bx
  1779 00000857 59                      	pop cx
  1780 00000858 5A                      	pop dx
  1781 00000859 E90AFF                  	jmp getc
  1782                                  
  1783                                  
  1784                                  .file_got:
  1785 0000085C 58                      	pop ax			; ah = 0, al = character read
  1786 0000085D 5F                      	pop di
  1787 0000085E 5B                      	pop bx
  1788 0000085F 59                      	pop cx
  1789 00000860 5A                      	pop dx
  1790 00000861 C3                      	retn
  1791                                  
  1792                                  .file_not:
  1793                                  %endif
  1794 00000862 F606[0100]01            	testopt [internalflags3], dif3_input_cmdline
  1795 00000867 7419                    	jz @F
  1796 00000869 56                      	push si
  1797 0000086A 8B36[0000]              	mov si, word [cmdline_buffer.position]
  1798 0000086E 31C0                    	xor ax, ax
  1799 00000870 AC                      	lodsb
  1800 00000871 84C0                    	test al, al
  1801 00000873 8936[0000]              	mov word [cmdline_buffer.position], si
  1802 00000877 5E                      	pop si
  1803 00000878 751F                    	jnz .return
  1804 0000087A 8026[0100]FE            	clropt [internalflags3], dif3_input_cmdline
  1805 0000087F E9E4FE                  	jmp getc
  1806                                  
  1807                                  @@:
  1808                                  .terminal:
  1809 00000882 B408                    	mov ah, 8
  1810                                  	doscall			; wait for a key
  1497 00000884 CD21                <1>  int 21h
  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 00000886 80FC4C                  	cmp ah, 4Ch
  1822 00000889 740F                    	je .freedos_ctrlc_workaround
  1823 0000088B B400                    	mov ah, 0		; assume it is ASCII
  1824 0000088D 84C0                    	test al, al
  1825 0000088F 7508                    	jne .return		; ASCII, return with ah zero -->
  1826 00000891 B408                    	mov ah, 8
  1827                                  	doscall			; scancode of non-ASCII key to al
  1497 00000893 CD21                <1>  int 21h
  1828 00000895 86C4                    	xchg al, ah		; to ah
  1829 00000897 B000                    	mov al, 0		; return zero for non-ASCII key
  1830                                  .return:
  1831 00000899 C3                      	retn
  1832                                  
  1833                                  .freedos_ctrlc_workaround:
  1834 0000089A BA[0000]                	mov dx, msg.freedos_ctrlc_workaround
  1835 0000089D E863FE                  	call putsz
  1836 000008A0 E9BCFA                  	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 000008A3 F606[0300]01            	testopt [internalflags3], dif3_input_re
  1846 000008A8 740B                    	jz @F
  1847 000008AA 8026[0300]FE            	clropt [internalflags3], dif3_input_re
  1848 000008AF 800E[0300]02            	setopt [internalflags3], dif3_input_re_closed
  1849 000008B4 C3                      	retn
  1850                                  
  1851                                  @@:
  1852                                  %endif
  1853                                  %if _INPUT_FILE_BOOT
  1854 000008B5 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  1855 000008BA 7406                    	jz @F
  1856 000008BC E8(0000)                	call yy_boot_clear_remember_seek
  1857 000008BF E9(0000)                	jmp yy_boot_close_file
  1858                                  
  1859                                  @@:
  1860                                  %endif
  1861                                  %if _INPUT_FILE_HANDLES
  1862 000008C2 F606[0200]10            	testopt [internalflags2], dif2_input_file
  1863 000008C7 7455                    	jz .notfile
  1864 000008C9 8B3E[0000]              	mov di, word [input_file_handles.active]
  1865 000008CD 57                      	push di
  1866 000008CE D1E7                    	shl di, 1
  1867 000008D0 D1E7                    	shl di, 1
  1868 000008D2 D1E7                    	shl di, 1
  1869                                   %if INPUTFILEHANDLE_size != 8
  1870                                    %error Unexpected structure size
  1871                                   %endif
  1872 000008D4 8B9D[0000]              	mov bx, word [input_file_handles + di + ifhHandle]
  1873 000008D8 E8B112                  	call yy_clear_remember_seek
  1874                                  
  1875 000008DB F685[0300]01            	testopt [input_file_handles + di + ifhFlags], ifhfIsDup
  1876 000008E0 7416                    	jz @F
  1877                                  
  1878 000008E2 51                      	push cx
  1879 000008E3 52                      	push dx
  1880                                  
  1881 000008E4 8B9D[F8FF]              	mov bx, word [input_file_handles + di - INPUTFILEHANDLE_size + ifhHandle]
  1882 000008E8 8B95[0400]              	mov dx, word [input_file_handles + di + ifhParentSeek]
  1883 000008EC 8B8D[0600]              	mov cx, word [input_file_handles + di + ifhParentSeek + 2]
  1884 000008F0 B80042                  	mov ax, 4200h		; seek from start
  1885 000008F3 E82112                  	call handle_seek_or_remember
  1886                                  
  1887 000008F6 5A                      	pop dx
  1888 000008F7 59                      	pop cx
  1889                                  
  1890                                  @@:
  1891                                  
  1892 000008F8 E8(0000)                	call InDOS
  1893 000008FB 7406                    	jz .closefile
  1894                                  
  1895 000008FD FF06[0000]              	inc word [input_file_handles.to_close]
  1896 00000901 EB06                    	jmp @F
  1897                                  
  1898                                  .closefile:
  1899 00000903 B80100                  	mov ax, 1
  1900 00000906 E82C00                  	call yy_close_file_handles
  1901                                  
  1902                                  @@:
  1903 00000909 5F                      	pop di
  1904 0000090A 4F                      	dec di
  1905 0000090B 790C                    	jns .next
  1906 0000090D 8026[0200]EF            	clropt [internalflags2], dif2_input_file
  1907 00000912 800E[0200]20            	setopt [internalflags2], dif2_closed_input_file
  1908 00000917 EB04                    	jmp .done
  1909                                  .next:
  1910 00000919 893E[0000]              	mov word [input_file_handles.active], di
  1911                                  .done:
  1912 0000091D C3                      	retn
  1913                                  %endif
  1914                                  
  1915                                  .notfile:
  1916 0000091E F606[0100]01            	testopt [internalflags3], dif3_input_cmdline
  1917 00000923 740B                    	jz @F
  1918 00000925 8026[0100]FE            	clropt [internalflags3], dif3_input_cmdline
  1919 0000092A 800E[0100]02            	setopt [internalflags3], dif3_input_cmdline_closed
  1920 0000092F C3                      	retn
  1921                                  
  1922                                  @@:
  1923 00000930 31F6                    	xor si, si
  1924 00000932 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 00000935 51                      	push cx
  1937 00000936 31C9                    	xor cx, cx
  1938 00000938 870E[0000]              	xchg cx, word [input_file_handles.to_close]
  1939 0000093C 01C1                    	add cx, ax
  1940 0000093E 7410                    	jz @FF
  1941                                  @@:
  1942 00000940 BBFFFF                  	mov bx, -1
  1943 00000943 879D[0000]              	xchg bx, word [input_file_handles + di + ifhHandle]
  1944 00000947 B43E                    	mov ah, 3Eh
  1945                                  	doscall
  1497 00000949 CD21                <1>  int 21h
  1946 0000094B 83C708                  	add di, INPUTFILEHANDLE_size
  1947 0000094E E2F0                    	loop @B
  1948                                  @@:
  1949 00000950 59                      	pop cx
  1950 00000951 C3                      	retn
  1951                                  
  1952                                  
  1953                                  		; INP:	-
  1954                                  		; OUT:	di = active handle offset
  1955                                  		;	bx = active handle
  1956                                  		; CHG:	-
  1957                                  yy_get_handle:
  1958 00000952 8B3E[0000]              	mov di, word [input_file_handles.active]
  1959 00000956 D1E7                    	shl di, 1
  1960 00000958 D1E7                    	shl di, 1
  1961 0000095A D1E7                    	shl di, 1
  1962                                   %if INPUTFILEHANDLE_size != 8
  1963                                    %error Unexpected structure size
  1964                                   %endif
  1965 0000095C 8B9D[0000]              	mov bx, word [input_file_handles + di + ifhHandle]
  1966                                  %endif
  1967 00000960 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 00000961 F606[0000]20            	testopt [internalflags3], dif3_input_serial_override
  1980 00000966 755B                    	jnz .serial
  1981 00000968 F606[0000]10            	testopt [internalflags3], dif3_input_terminal_override
  1982 0000096D 754D                    	jnz .terminal
  1983                                  
  1984                                  %if !_LOADER
  1985 0000096F F606[0300]01            	testopt [internalflags3], dif3_input_re
  1986 00000974 741D                    	jz @F
  1987 00000976 56                      	push si
  1988 00000977 8B36[0000]              	mov si, word [re_buffer.position]
  1989 0000097B 31C0                    	xor ax, ax
  1990 0000097D AC                      	lodsb
  1991 0000097E 84C0                    	test al, al
  1992 00000980 8936[0000]              	mov word [re_buffer.position], si
  1993 00000984 5E                      	pop si
  1994 00000985 7403E9B700              	jnz .return
  1995 0000098A FF0E[0000]              	dec word [re_buffer.position]
  1996 0000098E 38C0                    	cmp al, al			; ZR
  1997 00000990 E9AE00                  	jmp .return
  1998                                  %endif
  1999                                  
  2000                                  @@:
  2001                                  %if _INPUT_FILE_BOOT
  2002 00000993 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  2003 00000998 755B                    	jnz .file
  2004                                  %endif
  2005                                  
  2006 0000099A F606[0100]01            	testopt [internalflags3], dif3_input_cmdline
  2007 0000099F 741B                    	jz @F
  2008 000009A1 56                      	push si
  2009 000009A2 8B36[0000]              	mov si, word [cmdline_buffer.position]
  2010 000009A6 31C0                    	xor ax, ax
  2011 000009A8 AC                      	lodsb
  2012 000009A9 84C0                    	test al, al
  2013 000009AB 8936[0000]              	mov word [cmdline_buffer.position], si
  2014 000009AF 5E                      	pop si
  2015 000009B0 7403E98C00              	jnz .return
  2016 000009B5 8026[0100]FE            	clropt [internalflags3], dif3_input_cmdline
  2017 000009BA EBA5                    	jmp getc_if_any
  2018                                  
  2019                                  @@:
  2020                                  .terminal:
  2021 000009BC F606[0000]10            	testopt [serial_flags], sf_use_serial
  2022 000009C1 7411                    	jz @F			; do BIOS keyboard or DOS getc -->
  2023                                  
  2024                                  .serial:
  2025 000009C3 E8(0000)                	call serial_receive_char ; do serial getc (check rx buffer)
  2026 000009C6 7479                    	jz .return		; no data, go and idle -->
  2027 000009C8 B400                    	mov ah, 0
  2028 000009CA C3                      	retn
  2029                                  
  2030                                  .raw:
  2031 000009CB F606[0000]10            	testopt [serial_flags], sf_use_serial
  2032 000009D0 75F1                    	jnz .serial
  2033 000009D2 EB5F                    	jmp .bios
  2034                                  
  2035                                  @@:
  2036 000009D4 E8(0000)                	call InDOS_or_BIOS_IO
  2037 000009D7 755A                    	jnz .bios
  2038                                  
  2039 000009D9 F606[0000]10            	testopt [internalflags3], dif3_input_terminal_override
  2040 000009DE 7546                    	jnz .dos_terminal
  2041                                  
  2042                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  2043                                  %if _INPUT_FILE_BOOT
  2044 000009E0 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  2045 000009E5 750E                    	jnz .file
  2046                                  %endif
  2047                                  %if _INPUT_FILE_HANDLES
  2048 000009E7 E8(0000)                	call InDOS_or_BIOS_IO
  2049 000009EA 753A                    	jnz .file_not
  2050 000009EC F606[0200]10            	testopt [internalflags2], dif2_input_file
  2051 000009F1 7502                    	jnz .file
  2052                                  %endif
  2053 000009F3 EB31                    	jmp .file_not
  2054                                  
  2055                                  .file:
  2056 000009F5 57                      	push di
  2057 000009F6 53                      	push bx
  2058 000009F7 51                      	push cx
  2059 000009F8 52                      	push dx
  2060 000009F9 31C0                    	xor ax, ax
  2061 000009FB 50                      	push ax
  2062                                  
  2063 000009FC 89E2                    	mov dx, sp		; ds:dx -> al byte on stack
  2064 000009FE B90100                  	mov cx, 1		; buffer length = 1
  2065                                  %if _INPUT_FILE_BOOT
  2066                                   %if _INPUT_FILE_HANDLES
  2067 00000A01 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  2068 00000A06 7408                    	jz @F
  2069                                   %endif
  2070 00000A08 E8(0000)                	call yy_boot_remember_seek
  2071 00000A0B E8(0000)                	call yy_boot_read
  2072 00000A0E EB0A                    	jmp @FF
  2073                                  @@:
  2074                                  %endif
  2075                                  %if _INPUT_FILE_HANDLES
  2076 00000A10 B43F                    	mov ah, 3Fh
  2077 00000A12 E83DFF                  	call yy_get_handle
  2078 00000A15 E89011                  	call yy_remember_seek
  2079                                  	doscall			; DOS read file (depends on ds = ss)
  1497 00000A18 CD21                <1>  int 21h
  2080                                  %endif
  2081                                  @@:
  2082 00000A1A 7302                    	jnc @F
  2083 00000A1C 31C0                    	xor ax, ax
  2084                                  @@:
  2085 00000A1E 85C0                    	test ax, ax
  2086 00000A20 58                      	pop ax
  2087 00000A21 5A                      	pop dx
  2088 00000A22 59                      	pop cx
  2089 00000A23 5B                      	pop bx
  2090 00000A24 5F                      	pop di
  2091 00000A25 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 00000A26 B40B                    	mov ah, 0Bh
  2113                                  	doscall
  1497 00000A28 CD21                <1>  int 21h
  2114 00000A2A 84C0                    	test al, al
  2115 00000A2C 7413                    	jz .return
  2116 00000A2E E8B4FD                  	call getc_dos_internal
  2117 00000A31 EB0A                    	jmp .return_NZ
  2118                                  %endif
  2119                                  
  2120                                  .bios:
  2121 00000A33 B401                    	mov ah, 01h
  2122 00000A35 CD16                    	int 16h			; key available ?
  2123 00000A37 7408                    	jz .return
  2124 00000A39 31C0                    	xor ax, ax
  2125 00000A3B CD16                    	int 16h
  2126                                  .return_NZ:
  2127 00000A3D 50                      	push ax
  2128 00000A3E 0C01                    	or al, 1		; (NZ)
  2129 00000A40 58                      	pop ax
  2130                                  .return:
  2131 00000A41 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 00000A42 FB                      	sti
  2143                                  		; Might be required for dosemu2 in loops. Refer to
  2144                                  		;  https://hg.pushbx.org/ecm/insight/rev/7973d5dd16f7
  2145 00000A43 90                      	nop			; help debugging
  2146                                  
  2147                                  %if _APPLICATION || _DEVICE
  2148                                  %if _BOOTLDR
  2149 00000A44 F606[0100]40            	testopt [internalflags], nodosloaded
  2150 00000A49 7526                    	jnz .hlt		; can't call 2F -->
  2151                                  %endif
  2152                                  
  2153 00000A4B F606[0300]02            	testopt [options3], opt3_no_idle_2F
  2154 00000A50 751F                    	jnz .hlt
  2155                                   %if _GUARD_86M_INT2F
  2156                                  %if _PM
  2157                                  	call ispm
  2158                                  	jz @FF			; --> (NZ)
  2159                                  %endif
  2160 00000A52 06                      	push es
  2161 00000A53 31C0                    	xor ax, ax
  2162 00000A55 8EC0                    	mov es, ax		; (only used in 86 Mode)
  2163 00000A57 26A1BC00                	mov ax, [es:2Fh * 4]
  2164 00000A5B 83F8FF                  	cmp ax, -1
  2165 00000A5E 7405                    	je @F			; --> (ZR)
  2166 00000A60 260B06BE00              	or ax, [es:2Fh * 4 + 2]
  2167                                  @@:
  2168 00000A65 07                      	pop es
  2169 00000A66 7409                    	jz @FF
  2170                                  @@:
  2171                                   %endif
  2172 00000A68 B88016                  	mov ax, 1680h
  2173 00000A6B CD2F                    	int 2Fh			; release timeslice in multitasker
  2174 00000A6D 84C0                    	test al, al
  2175 00000A6F 740A                    	jz .return		; done idling -->
  2176                                  @@:
  2177                                  %if _PM
  2178                                  	call ispm
  2179                                  	jnz .hlt
  2180                                  
  2181                                  	push bx
  2182                                  	push cx
  2183                                  	push es
  2184                                  	_386_PM_o32	; push edi
  2185                                  	push di
  2186                                  _386	xor edi, edi		; clear EDIH
  2187                                  	xor cx, cx		; (copy no words from stack)
  2188                                  
  2189                                  [cpu 286]
  2190                                  	push cx			; ss
  2191                                  	push cx			; sp (0:0 = host should allocate a stack)
  2192                                  	sub sp, byte 12		; cs:ip (ignored), segments (uninitialized)
  2193                                  	pushf
  2194                                  	push cx			; EAXH (uninitialized)
  2195                                  	push 1680h		; AX
  2196                                  	sub sp, byte 12		; ecx, edx, ebx (uninitialized)
  2197                                  	push cx
  2198                                  	push cx			; reserved (zero)
  2199                                  	sub sp, byte 12		; ebp, esi, edi (uninitialized)
  2200                                  	push ss
  2201                                  	pop es
  2202                                  	mov di, sp		; es:(e)di -> 86 Mode call structure
  2203                                  	mov ax, 0300h
  2204                                  	mov bx, 2Fh		; bl = interrupt, bh = reserved (zero)
  2205                                  	int 31h			; call real mode 2F.1680
  2206                                  __CPU__
  2207                                  
  2208                                  	add sp, byte 28		; discard RM call structure
  2209                                  	pop ax			; get AX
  2210                                  	add sp, byte 20		; discard RM call structure
  2211                                  
  2212                                  	_386_PM_o32	; pop edi
  2213                                  	pop di
  2214                                  	pop es
  2215                                  	pop cx
  2216                                  	pop bx
  2217                                  
  2218                                  	test al, al
  2219                                  	jz .return		; done idling -->
  2220                                  %endif
  2221                                  %endif
  2222                                  .hlt:
  2223                                  %if _PM
  2224                                  	call ispm
  2225                                  	jnz .hlt_86m
  2226                                  .hlt_pm:
  2227                                  	testopt [options2], opt2_dpminohlt
  2228                                  	jmp @F			; NZ = DPMI host throws GPF when we execute hlt -->
  2229                                  %endif
  2230                                  .hlt_86m:
  2231 00000A71 F606[0100]02            	testopt [options], opt1_86mnohlt
  2232                                  @@:
  2233 00000A76 7503                    	jnz .return
  2234 00000A78 FB                      	sti
  2235 00000A79 F4                      	hlt			; else idle by hlt
  2236 00000A7A 90                      	nop
  2237                                  .return:
  2238 00000A7B 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 [840A]                  	dw getline_prepare_blank_blank_colon
  2247 00000004 [840A]                  	dw getline_prepare_blank_blank_colon
  2248 00000006 [840A]                  	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 [840A]                  	dw getline_prepare_blank_blank_colon
  2256 0000000A [7C0A]                  	dw getline_prepare_crlf_colon
  2257 0000000C [8C0A]                  	dw getline_prepare_blank_dash
  2258                                  
  2259                                  
  2260                                  	usesection lDEBUG_CODE
  2260          ------------------       note: usesection lDEBUG_CODE
  2261                                  
  2262                                  getline_prepare_crlf_colon:
  2263 00000A7C E825F7                  	call putsline_crlf
  2264 00000A7F BF[0000]                	mov di, line_out
  2265 00000A82 EB04                    	jmp @F
  2266                                  
  2267                                  getline_prepare_blank_blank_colon:
  2268 00000A84 B82020                  	mov ax, 32<<8|32	; add two spaces and a colon
  2269 00000A87 AB                      	stosw
  2270                                  @@:
  2271 00000A88 B03A                    	mov al, ':'
  2272 00000A8A AA                      	stosb
  2273 00000A8B C3                      	retn
  2274                                  
  2275                                  getline_prepare_blank_dash:
  2276 00000A8C B8202D                  	mov ax, '-' << 8 | 32
  2277 00000A8F AB                      	stosw
  2278 00000A90 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 00000A91 BA[0000]                	mov dx, line_out
  2306 00000A94 89F9                    	mov cx, di
  2307 00000A96 29D1                    	sub cx, dx
  2308                                  
  2309                                  getline:	; note: this entry is no longer used
  2310 00000A98 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 00000A9D 890E[0000]              	mov word [promptlen], cx	; save length of prompt
  2316 00000AA1 8326[0000]00            	and word [terminator_in_line_in.offset], 0
  2317                                  					; reset this when reading new line
  2318                                  
  2319 00000AA6 E82102                  	call getline_is_input_file?
  2320 00000AA9 7303E90801              	jc getline_nofile
  2321                                  
  2322                                  getline_file:
  2323 00000AAE F606[0300]01            	testopt [internalflags3], dif3_input_re
  2324 00000AB3 7549                    	jnz .notquiet
  2325                                  
  2326                                  %if _INPUT_FILE_BOOT
  2327 00000AB5 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  2328 00000ABA 7412                    	jz @F
  2329 00000ABC B8A000                  	mov ax, LOAD_INPUT_FILE_SIZE
  2330 00000ABF 52                      	push dx
  2331 00000AC0 F726[0000]              	mul word [load_input_file.active]
  2332 00000AC4 5A                      	pop dx
  2333 00000AC5 89C7                    	mov di, ax
  2334 00000AC7 F685[2700]40            	testopt [load_input_file + di - LOADDATA3 + ldFATType], ifhfQuietInput
  2335 00000ACC EB29                    	jmp .quiet_if_nz
  2336                                  
  2337                                  @@:
  2338                                  %endif
  2339                                  %if _INPUT_FILE_HANDLES
  2340 00000ACE E8(0000)                	call InDOS_or_BIOS_IO
  2341 00000AD1 7518                    	jnz @F
  2342 00000AD3 F606[0200]10            	testopt [internalflags2], dif2_input_file
  2343 00000AD8 7411                    	jz @F
  2344 00000ADA 8B3E[0000]              	mov di, word [input_file_handles.active]
  2345 00000ADE D1E7                    	shl di, 1
  2346 00000AE0 D1E7                    	shl di, 1
  2347 00000AE2 D1E7                    	shl di, 1		; to qword array index
  2348                                   %if INPUTFILEHANDLE_size != 8
  2349                                    %error Unexpected structure size
  2350                                   %endif
  2351 00000AE4 F685[0300]40            	testopt [input_file_handles + di + ifhFlags], ifhfQuietInput
  2352 00000AE9 EB0C                    	jmp .quiet_if_nz
  2353                                  
  2354                                  @@:
  2355                                  %endif
  2356 00000AEB F606[0100]01            	testopt [internalflags3], dif3_input_cmdline
  2357 00000AF0 740C                    	jz @F
  2358 00000AF2 F606[0300]40            	testopt [options], opt_cmdline_quiet_input
  2359                                  	; jmp .quiet_if_nz
  2360                                  
  2361                                  .quiet_if_nz:
  2362 00000AF7 7405                    	jz @F
  2363                                  .quiet:
  2364 00000AF9 800E[0100]08            	setopt [internalflags3], dif3_quiet_input_single
  2365                                  .notquiet:
  2366                                  @@:
  2367                                  
  2368 00000AFE 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 00000B03 C706[0000][0000]        	mov word [lastcmd], dmycmd	; disable auto-repeat while reading from a file
  2376                                  
  2377                                  %if _NEWFULLHANDLING
  2378 00000B09 BF[0300]                	mov di, line_in+3	; read max
  2379                                  %else
  2380                                  	mov di, line_in+2
  2381                                  %endif
  2382 00000B0C 8B36[0000]              	mov si, word [bufnext]
  2383 00000B10 3B36[0000]              	cmp si, word [bufend]
  2384 00000B14 7216                    	jb .char_buffered	; if there's a character already
  2385 00000B16 E8AB07                  	call fillbuf
  2386 00000B19 7311                    	jnc .fillbuf_had_data
  2387 00000B1B F606[0100]80            	testopt [internalflags3], dif3_return_eof
  2388 00000B20 7402                    	jz @F
  2389 00000B22 F9                      	stc
  2390 00000B23 C3                      	retn
  2391                                  @@:
  2392 00000B24 E8DC01                  	call getline_close_file
  2393 00000B27 7403E96CFF              	jnz getline
  2394                                  
  2395                                  .fillbuf_had_data:
  2396                                  .char_buffered:
  2397                                  %if _NEWFULLHANDLING
  2398 00000B2C 4F                      	dec di
  2399                                  %endif
  2400                                  
  2401                                  		; Discard an LF if the last character read was CR.
  2402 00000B2D 803E[0000]0D            	cmp byte [notatty], 13	; last parsed character was CR ?
  2403 00000B32 750A                    	jne .no_lf_skip		; no, nothing more to do -->
  2404 00000B34 803C0A                  	cmp byte [si], 10	; first read character is LF ?
  2405 00000B37 7505                    	jne .no_lf_skip		; no -->
  2406 00000B39 46                      	inc si			; skip the LF
  2407 00000B3A FE06[0000]              	inc byte [notatty]	; avoid repeating this
  2408                                  .no_lf_skip:
  2409                                  
  2410 00000B3E 3B36[0000]              	cmp si, word [bufend]
  2411 00000B42 740B                    	je @F
  2412 00000B44 803C40                  	cmp byte [si], '@'	; no display ?
  2413 00000B47 7506                    	jne @F
  2414                                  
  2415 00000B49 46                      	inc si			; increment past @
  2416 00000B4A 800E[0100]08            	setopt [internalflags3], dif3_quiet_input_single
  2417                                  @@:
  2418 00000B4F F606[0100]08            	testopt [internalflags3], dif3_quiet_input_single
  2419 00000B54 7503                    	jnz gl1
  2420                                  
  2421 00000B56 E856F6                  	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 00000B59 8B0E[0000]              	mov cx, word [bufend]
  2427 00000B5D 29F1                    	sub cx, si		; cx = number of valid characters in buffer
  2428 00000B5F 740C                    	jz gl3			; if none -->
  2429                                  gl2:
  2430 00000B61 AC                      	lodsb
  2431 00000B62 3C0D                    	cmp al, 13		; (exact match for CR)
  2432 00000B64 7410                    	je gl4
  2433 00000B66 3C0A                    	cmp al, 10
  2434 00000B68 740C                    	je gl4			; if EOL -->
  2435 00000B6A AA                      	stosb
  2436 00000B6B E2F4                    	loop gl2		; if more valid characters -->
  2437                                  
  2438                                  		; The buffer is empty. Fill it again.
  2439                                  gl3:
  2440                                  %if _NEWFULLHANDLING
  2441 00000B6D 47                      	inc di
  2442                                  %endif
  2443 00000B6E E85307                  	call fillbuf
  2444                                  %if _NEWFULLHANDLING
  2445 00000B71 4F                      	dec di
  2446                                  %endif
  2447 00000B72 73E5                    	jnc gl1			; if we have more characters -->
  2448 00000B74 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 00000B76 3C0D                    	cmp al, 13		; terminator was CR ?
  2459 00000B78 7508                    	jne @F			; no -->
  2460 00000B7A E306                    	jcxz @F			; if no other byte buffered -->
  2461 00000B7C 803C0A                  	cmp byte [si], 10	; next byte is an LF ?
  2462 00000B7F 7501                    	jne @F			; no -->
  2463 00000B81 AC                      	lodsb			; increment si past the LF and set al = 10
  2464                                  	; dec cx		; (not used in subsequent code)
  2465                                  @@:
  2466 00000B82 8936[0000]              	mov word [bufnext], si
  2467 00000B86 A2[0000]                	mov byte [notatty], al	; store 10 or 13 (depending on the kind of EOL)
  2468                                  
  2469 00000B89 800E[0100]04            	setopt [internalflags3], dif3_at_line_end
  2470 00000B8E E8B706                  	call getline_reset_notatty
  2471                                  
  2472 00000B91 89F9                    	mov cx, di		; (counter is for input without CR)
  2473 00000B93 B00D                    	mov al, 13
  2474 00000B95 AA                      	stosb			; terminate line for our usage
  2475 00000B96 BA[0200]                	mov dx, line_in + 2
  2476 00000B99 29D1                    	sub cx, dx		; = length of input (no CR)
  2477 00000B9B 880E[0100]              	mov byte [line_in+1], cl
  2478 00000B9F F606[0100]08            	testopt [internalflags3], dif3_quiet_input_single
  2479 00000BA4 750D                    	jnz @F
  2480 00000BA6 800E[0200]01            	setopt [internalflags], usecharcounter
  2481 00000BAB E801F6                  	call puts		; print out the received line
  2482 00000BAE 8026[0200]FE            	clropt [internalflags], usecharcounter
  2483                                  @@:
  2484 00000BB3 E9E200                  	jmp getline_eol		; done
  2485                                  
  2486                                  getline_nofile:
  2487 00000BB6 E8D80E                  	call yy_reset_buf
  2488 00000BB9 C606[0000]00            	mov byte [linecounter], 0	; reset counter
  2489 00000BBE 8026[0200]EF            	clropt [internalflags], promptwaiting
  2490 00000BC3 51                      	push cx
  2491 00000BC4 52                      	push dx
  2492 00000BC5 E8E7F5                  	call puts		; display prompt
  2493 00000BC8 5A                      	pop dx
  2494 00000BC9 59                      	pop cx
  2495 00000BCA F606[0000]10            	testopt [serial_flags], sf_use_serial
  2496 00000BCF 750A                    	jnz .getinput_NZ
  2497 00000BD1 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 00000BD4 7505                    	jnz .getinput_NZ
  2502                                  %if _PM
  2503                                  	call ispm
  2504                                  	jnz @F			; if 86 Mode -->
  2505                                  	testopt [options2], opt2_getinput_dpmi
  2506                                  	jnz .getinput_NZ
  2507                                  @@:
  2508                                  %endif
  2509 00000BD6 F606[0100]08            	testopt [options], opt_usegetinput
  2510                                  .getinput_NZ:
  2511 00000BDB 7403E9C601              	jnz getinput
  2512                                  
  2513                                  %if _PM
  2514                                  	call ispm
  2515                                  	jnz @F			; if 86 Mode -->
  2516                                  	testopt [internalflags], canswitchmode
  2517                                  	jz @F			; can't switch to 86M -->
  2518                                  	setopt [internalflags], modeswitched
  2519                                  				; set flag for resetmode
  2520                                  	mov al, 0
  2521                                  	call sr_state		; save state
  2522                                  	call switchmode 	; switch to 86M
  2523                                  	call handle_mode_changed	; ! called with flag set
  2524                                  
  2525                                  	mov si, getline_extra_int23
  2526                                  	mov al, 23h
  2527                                  	call install_86m_interrupt_handler
  2528                                  				; override DPMI host's int 23h vector
  2529                                  	mov dx, getline_extra_int22
  2530                                  	mov ax, 2522h
  2531                                  	int 21h
  2532                                  	mov word [TPIV], dx	; override our PRI
  2533                                  
  2534                                  	mov dx, line_in
  2535                                  	mov ah, 0Ah
  2536                                  	int 21h			; call DOS
  2537                                  
  2538                                  	call getline_extra_uninstall
  2539                                  				; undo patches
  2540                                  	jmp @FF
  2541                                  				; go to common trail
  2542                                  
  2543                                  @@:
  2544                                  %endif
  2545 00000BE0 BA[0000]                	mov dx, line_in
  2546 00000BE3 B40A                    	mov ah, 0Ah		; buffered keyboard input
  2547                                  	doscall
  1497 00000BE5 CD21                <1>  int 21h
  2548                                  
  2549                                  @@:
  2550                                  %if _EXTENSIONS && _EXT_PUTS_GETLINE
  2551 00000BE7 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 00000BE9 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 00000BEC BE[0200]                	mov si, line_in + 2
  2644 00000BEF 31C9                    	xor cx, cx
  2645 00000BF1 0A4CFF                  	or cl, byte [si - 1]
  2646 00000BF4 7503E99D00              	jz .dontenter
  2647                                  	gethistorysegment es
   480 00000BF9 368E06[0000]        <1>  mov %1, word [ss:history.segorsel]
  2648                                  	gethistoryoffset bx
   483 00000BFE BB0000              <1>  mov %1, 0
  2649 00000C01 A1[0000]                	mov ax, word [history.last]
  2650 00000C04 3B06[0000]              	cmp ax, word [history.first]
  2651 00000C08 7419                    	je @F			; if there are no history entries -->
  2652 00000C0A 89C7                    	mov di, ax		; -> last displacement in high array
  2653 00000C0C 268B15                  	mov dx, [es:di]		; + bx -> behind last history entry text
  2654 00000C0F 268B7D02                	mov di, [es:di + 2]	; + bx -> at last history entry text
  2655 00000C13 29FA                    	sub dx, di		; = length of last history entry text
  2656 00000C15 39D1                    	cmp cx, dx		; length match ?
  2657 00000C17 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 00000C19 8D39                    	lea di, [di + bx]	; -> at last text
  2663 00000C1B 51                      	push cx
  2664 00000C1C 56                      	push si
  2665 00000C1D F3A6                    	repe cmpsb		; compare candidate text to last text
  2666 00000C1F 5E                      	pop si
  2667 00000C20 59                      	pop cx
  2668 00000C21 7473                    	je .dontenter		; equal, so skip it -->
  2669                                  @@:
  2670 00000C23 89C7                    	mov di, ax		; -> last displacement
  2671 00000C25 268B15                  	mov dx, [es:di]		; + bx -> free space
  2672 00000C28 01DA                    	add dx, bx		; -> free space
  2673 00000C2A F7DA                    	neg dx			; - free space start
  2674 00000C2C 7502                    	jnz @F
  2675 00000C2E 4A                      	dec dx			; cause add to overflow (= FFFFh)
  2676 00000C2F 47                      	inc di			; adjust for prior instruction
  2677                                  @@:
  2678 00000C30 01FA                    	add dx, di		; - free space start + free space end
  2679                                  				;  = free space size
  2680 00000C32 730A                    	jnc .delete		; invalid (shouldn't happen) -->
  2681 00000C34 7408                    	jz .delete		; zero bytes free -->
  2682 00000C36 4A                      	dec dx
  2683 00000C37 7405                    	jz .delete		; one byte free -->
  2684 00000C39 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 00000C3A 39D1                    	cmp cx, dx
  2695 00000C3C 7646                    	jbe .insert		; enough bytes for the new entry -->
  2696                                  .delete:
  2697 00000C3E 3B06[0000]              	cmp ax, word [history.first]
  2698 00000C42 7508                    	jne @F
  2699                                  
  2700                                  .error:
  2701 00000C44 BA[0000]                	mov dx, msg.history_internal_error
  2702 00000C47 E8B9FA                  	call putsz
  2703 00000C4A EB4A                    	jmp .dontenter
  2704                                  
  2705                                  @@:
  2706 00000C4C 89C7                    	mov di, ax		; -> at last displacement
  2707 00000C4E 268B3D                  	mov di, [es:di]		; + bx -> after last entry's text
  2708 00000C51 8B36[0000]              	mov si, word [history.first]
  2709 00000C55 268B74FE                	mov si, [es:si - 2]	; + bx -> at second entry's text
  2710 00000C59 29F7                    	sub di, si		; = after last - after first
  2711                                  				;  = text length excluding first
  2712 00000C5B 89F9                    	mov cx, di		; length to move
  2713 00000C5D 56                      	push si
  2714 00000C5E 01DE                    	add si, bx		; -> after first entry's text
  2715 00000C60 89DF                    	mov di, bx		; -> start of buffer
  2716 00000C62 06                      	push es
  2717 00000C63 1F                      	pop ds
  2718 00000C64 F3A4                    	rep movsb		; move subsequent text
  2719 00000C66 59                      	pop cx			; = how far we moved (deleted text length)
  2720 00000C67 89C7                    	mov di, ax		; -> at last displacement
  2721 00000C69 8B15                    	mov dx, word [di]	; load last displacement
  2722                                  @@:
  2723 00000C6B 47                      	inc di
  2724 00000C6C 47                      	inc di			; -> prior displacement
  2725 00000C6D 363B3E[0000]            	cmp di, word [ss:history.first]
  2726 00000C72 7306                    	jae @F			; (hardened, shouldn't ever be above)
  2727 00000C74 29CA                    	sub dx, cx		; adjust next displacement
  2728                                  				;  by deleted text length
  2729 00000C76 8715                    	xchg word [di], dx	; store in prior displacement
  2730                                  				;  and load its old value
  2731 00000C78 EBF1                    	jmp @B
  2732                                  
  2733                                  @@:
  2734 00000C7A 16                      	push ss
  2735 00000C7B 1F                      	pop ds
  2736 00000C7C 8306[0000]02            	add word [history.last], 2
  2737                                  				; deleted one displacement
  2738 00000C81 E968FF                  	jmp .loop
  2739                                  
  2740                                  .insert:
  2741 00000C84 89C7                    	mov di, ax
  2742 00000C86 48                      	dec ax
  2743 00000C87 48                      	dec ax
  2744 00000C88 A3[0000]                	mov word [history.last], ax
  2745 00000C8B 268B3D                  	mov di, word [es:di]
  2746 00000C8E 01DF                    	add di, bx
  2747 00000C90 F3A4                    	rep movsb
  2748 00000C92 29DF                    	sub di, bx
  2749 00000C94 97                      	xchg di, ax		; es:di -> new last history displacement,
  2750                                  				;  ax -> after history text
  2751 00000C95 AB                      	stosw
  2752                                  
  2753                                  .dontenter:
  2754 00000C96 16                      	push ss
  2755 00000C97 07                      	pop es
  2756                                  %endif
  2757                                  
  2758                                  getline_eol:
  2759 00000C98 F606[0100]08            	testopt [internalflags3], dif3_quiet_input_single
  2760 00000C9D 750B                    	jnz @F			; NC
  2761 00000C9F B00D                    	mov al, 13
  2762 00000CA1 E881FA                  	call putc		; fix ZDOS Int21.0A display bug
  2763 00000CA4 B00A                    	mov al, 10
  2764 00000CA6 E87CFA                  	call putc
  2765 00000CA9 F9                      	stc
  2766                                  @@:
  2767                                  %if _EXTENSIONS && _EXT_PUTS_GETLINE
  2768 00000CAA B302                    	mov bl, 2
  2769 00000CAC 80D300                  	adc bl, 0		; = 3 if displayed
  2770 00000CAF 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 00000CB2 E80800                  	call transfer_to_ext_puts_getline
  2782 00000CB5 F8                      	clc			; NC
  2783 00000CB6 C3                      	retn
  2784                                  %endif
  2785                                  
  2786                                  set_si_line_in_and_skipwhite:
  2787 00000CB7 BE[0200]                	mov si, line_in+2
  2788 00000CBA E9E8F3                  	jmp skipwhite		; NC
  2789                                  
  2790                                  
  2791                                  %if _EXTENSIONS && _EXT_PUTS_GETLINE
  2792                                  transfer_to_ext_puts_getline:
  2793 00000CBD 8B0E[0000]              	mov cx, word [ext_puts_getline_handler]
  2794 00000CC1 E306                    	jcxz @F
  2795 00000CC3 E9C40D                  	jmp transfer_ext_cx
  2796                                  
  2797                                  check_section_of puts_getline_ext_done
  2798                                  puts_getline_ext_done: equ $
  2799 00000CC6 59                      	pop cx
  2800 00000CC7 59                      	pop cx
  2801 00000CC8 59                      	pop cx				; discard return addresses
  2802                                  @@:
  2803 00000CC9 C3                      	retn
  2804                                  %endif
  2805                                  
  2806                                  
  2807                                  %if _PM
  2808                                  getline_extra_uninstall:
  2809                                  	mov dx, debug22
  2810                                  	mov ax, 2522h
  2811                                  	int 21h
  2812                                  	mov word [TPIV], dx	; restore default int 22h (PRI)
  2813                                  	mov si, getline_extra_int23
  2814                                  	mov al, 23h
  2815                                  	mov dx, -1
  2816                                  	call UnhookInterruptForce
  2817                                  				; restore DPMI host's int 23h handler
  2818                                  	jmp resetmode		; return to PM
  2819                                  
  2820                                  	usesection lDEBUG_DATA_ENTRY
  2821                                  
  2822                                  iispentry getline_extra_int23
  2823                                  	stc
  2824                                  	retf			; indicate to abort syscall and process
  2825                                  
  2826                                  	align 2
  2827                                  getline_extra_int22:
  2828                                  	cli
  2829                                  .cleartraceflag:
  2830                                  	cld			; reestablish things
  2831                                  	mov ax, cs
  2832                                  	mov ds, ax
  2833                                  	mov ss, ax
  2834                                  	mov sp, word [ savesp ]	; restore stack
  2835                                  	times 1 - (($ - $$) & 1) nop	; align in-code parameter
  2836                                  	call entry_to_code_seg
  2837                                  	dw .code
  2838                                  
  2839                                  	usesection lDEBUG_CODE
  2840                                  
  2841                                  .code:
  2842                                  
  2843                                  	_386_o32		; mov esp
  2844                                  	mov sp, word [ savesp ]		; restore stack
  2845                                  _386	and sp, ~3			; align stack
  2846                                  	_386_o32
  2847                                  	xor ax, ax
  2848                                  	_386_o32
  2849                                  	push ax
  2850                                  	_386_o32
  2851                                  	popf
  2852                                  _386	mov sp, word [ savesp ]		; restore stack
  2853                                  	cld
  2854                                  	sti
  2855                                  
  2856                                  	call getline_extra_uninstall
  2857                                  				; undo patches and return to PM
  2858                                  	jmp handle_ctrl_c	; go to common handler -->
  2859                                  %endif
  2860                                  
  2861                                  
  2862                                  getline_is_input_file?:
  2863 00000CCA F606[0000]20            	testopt [internalflags3], dif3_input_serial_override
  2864 00000CCF 7530                    	jnz .nofile
  2865 00000CD1 F606[0300]01            	testopt [internalflags3], dif3_input_re
  2866 00000CD6 7528                    	jnz .file
  2867 00000CD8 F606[0100]01            	testopt [internalflags3], dif3_input_cmdline
  2868 00000CDD 7521                    	jnz .file
  2869                                  %if _INPUT_FILE_BOOT
  2870 00000CDF F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  2871 00000CE4 751A                    	jnz .file
  2872                                  %endif
  2873 00000CE6 E8(0000)                	call InDOS_or_BIOS_IO
  2874 00000CE9 7516                    	jnz .nofile		; InDOS, not reading from a file -->
  2875                                  %if _INPUT_FILE_HANDLES
  2876 00000CEB F606[0200]10            	testopt [internalflags2], dif2_input_file
  2877 00000CF0 750E                    	jnz .file
  2878                                  %endif
  2879 00000CF2 F606[0000]10            	testopt [serial_flags], sf_use_serial
  2880 00000CF7 7508                    	jnz .nofile
  2881 00000CF9 803E[0000]00            	cmp byte [notatty], 0	; check this weird flag
  2882 00000CFE 7401                    	je .nofile		; not reading from a file -->
  2883                                  
  2884                                  .file:
  2885 00000D00 A8                      	db __TEST_IMM8		; (skip stc, NC)
  2886                                  .nofile:
  2887 00000D01 F9                      	stc
  2888 00000D02 C3                      	retn
  2889                                  
  2890                                  
  2891                                  getline_close_file:
  2892 00000D03 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 00000D04 F606[0300]01            	testopt [internalflags3], dif3_input_re
  2897 00000D09 7515                    	jnz .re
  2898                                  %endif
  2899                                  %if _INPUT_FILE_HANDLES && _INPUT_FILE_BOOT
  2900 00000D0B F706[0200]1002          	testopt [internalflags2], dif2_input_file | dif2_input_file_boot, 1
  2901 00000D11 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 00000D13 F606[0100]01            	testopt [internalflags3], dif3_input_cmdline
  2910 00000D18 7462                    	jz .qq			; if EOF, quit -->
  2911                                  
  2912 00000D1A B1FE                    	mov cl, -2
  2913 00000D1C A9                      	db __TEST_IMM16
  2914                                  @@:
  2915 00000D1D 31C9                    	xor cx, cx
  2916                                  %if !_LOADER
  2917 00000D1F A9                      	db __TEST_IMM16
  2918                                  .re:
  2919 00000D20 B1FF                    	mov cl, -1
  2920                                  %endif
  2921                                  
  2922 00000D22 51                      	push cx
  2923 00000D23 E86900                  	call .resetstuff
  2924 00000D26 59                      	pop cx
  2925                                  
  2926 00000D27 E302                    	jcxz .notre
  2927 00000D29 EB15                    	jmp @F
  2928                                  
  2929                                  .notre:
  2930 00000D2B 59                      	pop cx
  2931 00000D2C F606[0100]04            	testopt [internalflags3], dif3_at_line_end
  2932 00000D31 750C                    	jnz .return		; (NZ)
  2933                                  
  2934 00000D33 B80D0A                  	mov ax, 13 | 10 << 8	; pretend we read a CR LF sequence
  2935 00000D36 AB                      	stosw
  2936 00000D37 893E[0000]              	mov word [bufend], di
  2937 00000D3B 4F                      	dec di
  2938 00000D3C 4F                      	dec di
  2939 00000D3D 38C0                    	cmp al, al		; ZR
  2940                                  .return:
  2941 00000D3F C3                      	retn
  2942                                  
  2943                                  @@:
  2944 00000D40 80F9FE                  	cmp cl, -2
  2945 00000D43 59                      	pop cx
  2946                                  %if !_LOADER
  2947 00000D44 741B                    	je .finish_cmdline
  2948                                  
  2949                                  .finish_re:
  2950 00000D46 F606[0100]04            	testopt [internalflags3], dif3_at_line_end
  2951 00000D4B 750E                    	jnz @F
  2952 00000D4D B82801                  	mov ax, 0128h
  2953 00000D50 E8(0000)                	call setrc
  2954 00000D53 BA[0000]                	mov dx, msg.unexpected_noneol_re
  2955 00000D56 E8A4F9                  	call putsz_error
  2956 00000D59 EB03                    	jmp @FF
  2957                                  @@:
  2958 00000D5B E8730F                  	call resetrc
  2959                                  @@:
  2960 00000D5E E9(0000)                	jmp dumpregs_extended.exit
  2961                                  %endif
  2962                                  
  2963                                  .finish_cmdline:
  2964 00000D61 F606[0100]04            	testopt [internalflags3], dif3_at_line_end
  2965 00000D66 750E                    	jnz @F
  2966 00000D68 B82901                  	mov ax, 0129h
  2967 00000D6B E8(0000)                	call setrc
  2968 00000D6E BA[0000]                	mov dx, msg.unexpected_noneol_rc
  2969 00000D71 E889F9                  	call putsz_error
  2970 00000D74 EB03                    	jmp @FF
  2971                                  @@:
  2972 00000D76 E8580F                  	call resetrc
  2973                                  @@:
  2974 00000D79 E9(0000)                	jmp cmd3
  2975                                  %endif
  2976                                  
  2977                                  .qq:
  2978 00000D7C C606[0200]0D            	mov byte [line_in + 2], 13
  2979 00000D81 E833FF                  	call set_si_line_in_and_skipwhite
  2980 00000D84 830E[0000]08            	or word [cmd3_set_options], fakeindos
  2981 00000D89 E8(0000)                	call qq			; if EOF, quit -->
  2982 00000D8C E9(0000)                	jmp cmd3
  2983                                  
  2984                                  .resetstuff:
  2985 00000D8F 57                      	push di
  2986 00000D90 E810FB                  	call yy_close_file	; close file
  2987 00000D93 5F                      	pop di
  2988                                  
  2989                                  %if _NEWFULLHANDLING
  2990 00000D94 C706[0000][0300]        	mov word [bufnext], line_in + 3
  2991 00000D9A 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 00000DA0 E8A504                  	call getline_reset_notatty
  2998                                  
  2999 00000DA3 E9(0000)                	jmp determine_quiet_output
  3000                                  
  3001                                  
  3002                                  getinput:
  3003                                  %if _EXTENSIONS && _EXT_PUTS_GETLINE
  3004 00000DA6 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 00000DAA 5589E58D66FA            	lenter
  3012 00000DB0 06                      	 push es
  3013 00000DB1 52                      	 push dx
  3014                                  	lvar dword,	prompt	; (in line_out buffer)
  3015 00000DB2 31C0                    	xor ax, ax
  3016                                  %if _HISTORY
  3017 00000DB4 50                      	 push ax
  3018                                  	lvar word,	historyentry
  3019                                  %endif
  3020 00000DB5 50                      	 push ax
  3021                                  	lvar word,	length_displayed
  3022 00000DB6 50                      	 push ax
  3023                                  	lvar word,	length_input
  3024 00000DB7 50                      	 push ax
  3025                                  	lvar word,	offset
  3026 00000DB8 50                      	 push ax
  3027                                  	lvar word,	lastskip
  3028 00000DB9 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 00000DBA 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 00000DBB 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 00000DBC 51                      	 push cx
  3041                                  	lvar word,	column
  3042 00000DBD 51                      	 push cx
  3043                                  	lvar word,	promptlength
  3044                                  
  3045 00000DBE 57                      	push di
  3046 00000DBF 1E                      	push ds
  3047 00000DC0 07                      	pop es
  3048                                  
  3049                                  .next:
  3050 00000DC1 E8(0000)                	call handle_serial_flags_ctrl_c
  3051                                  
  3052 00000DC4 D046EA                  	rol byte [bp + ?redraw], 1
  3053 00000DC7 7203E90701              	jnc .no_do_redraw
  3054                                  .do_redraw:
  3055                                  
  3056 00000DCC E8F203                  	call get_columns
  3057                                  
  3058 00000DCF 8946FE                  	mov word [bp + ?columns], ax
  3059 00000DD2 48                      	dec ax				; $COLS - 1
  3060 00000DD3 2B46E2                  	sub ax, word [bp + ?promptlength]; - $promptlength
  3061 00000DD6 8946FC                  	mov word [bp + ?maxpercol], ax
  3062 00000DD9 D1E8                    	shr ax, 1			; int($maxpercol / 2)
  3063 00000DDB 7501                    	jnz @F
  3064 00000DDD 40                      	inc ax				; insure nonzero
  3065                                  @@:
  3066 00000DDE 8946FA                  	mov word [bp + ?maxpercolhalf], ax
  3067                                  
  3068 00000DE1 8B46F0                  	mov ax, [bp + ?length_input]
  3069 00000DE4 89C1                    	mov cx, ax
  3070 00000DE6 31FF                    	xor di, di			; variable "skip"
  3071                                  					; + line_in + 2 -> to display
  3072 00000DE8 3B46FC                  	cmp ax, word [bp + ?maxpercol]
  3073 00000DEB 8B46E4                  	mov ax, word [bp + ?column]	; variable "col"
  3074 00000DEE 763B                    	jna .not_show_a_maxpercol
  3075                                  .show_a_maxpercol:
  3076                                  
  3077 00000DF0 8B56FC                  	mov dx, word [bp + ?maxpercol]
  3078 00000DF3 0356E2                  	add dx, word [bp + ?promptlength]
  3079                                  
  3080 00000DF6 8B5EEC                  	mov bx, word [bp + ?lastskip]
  3081 00000DF9 395EEE                  	cmp word [bp + ?offset], bx
  3082 00000DFC 7307                    	jae .offset_ae_lastskip		; spaghetti branch -->
  3083                                  .not_offset_ae_lastskip:
  3084                                  
  3085                                  @@:
  3086 00000DFE 39D0                    	cmp ax, dx
  3087 00000E00 760B                    	jna .not_col_a_maxpercol
  3088                                  .col_a_maxpercol:
  3089 00000E02 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 00000E05 29D8                    	sub ax, bx			; lessen col
  3097 00000E07 01DF                    	add di, bx			; heighten offset of part to display
  3098 00000E09 29D9                    	sub cx, bx			; lessen length of part to display
  3099 00000E0B EBF1                    	jmp @B
  3100                                  
  3101                                  .not_col_a_maxpercol:
  3102 00000E0D 3B7EEC                  	cmp di, word [bp + ?lastskip]	; scrolling forwards ?
  3103 00000E10 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 00000E12 3B46E2                  	cmp ax, word [bp + ?promptlength]
  3113                                  					; possibly at end ?
  3114 00000E15 760C                    	jbe @F				; no -->
  3115 00000E17 39D0                    	cmp ax, dx			; are we at end ?
  3116 00000E19 7508                    	jne @F				; no -->
  3117 00000E1B 3B4EFC                  	cmp cx, word [bp + ?maxpercol]	; displaying the last fragment ?
  3118 00000E1E 7603                    	jbe @F				; yes, do not move up -->
  3119 00000E20 48                      	dec ax
  3120 00000E21 47                      	inc di
  3121 00000E22 49                      	dec cx				; move up display by one column
  3122                                  @@:
  3123 00000E23 3B4EFC                  	cmp cx, word [bp + ?maxpercol]
  3124 00000E26 7603                    	jbe @F
  3125 00000E28 8B4EFC                  	mov cx, word [bp + ?maxpercol]
  3126                                  @@:
  3127                                  .not_show_a_maxpercol:
  3128 00000E2B 397EEC                  	cmp word [bp + ?lastskip], di	; need to scroll ?
  3129 00000E2E 7408                    	je @F				; no -->
  3130 00000E30 8366E800                	and word [bp + ?low_cursormove_and_high_append], 0
  3131                                  					; yes, ignore appending status
  3132                                  					; ignore cursor move status too
  3133 00000E34 C646E600                	mov byte [bp + ?cursorright], 0	; also reset this flag
  3134                                  @@:
  3135                                  
  3136 00000E38 897EEC                  	mov word [bp + ?lastskip], di	; update variable for next iteration
  3137 00000E3B 8D95[0200]              	lea dx, [di + line_in + 2]	; -> visible text's data
  3138                                  
  3139 00000E3F 89CB                    	mov bx, cx
  3140 00000E41 875EF2                  	xchg bx, word [bp + ?length_displayed]
  3141                                  					; bx = remember how much we had,
  3142                                  					;  and update variable
  3143                                  
  3144 00000E44 D046E8                  	rol byte [bp + ?cursormove], 1	; cursor move without visible window move ?
  3145 00000E47 7250                    	jc .redraw_always_move_cursor	; yes, skip full redraw and also
  3146                                  					;  force to do cursor movement -->
  3147 00000E49 50                      	push ax
  3148 00000E4A 53                      	push bx
  3149 00000E4B 51                      	push cx
  3150 00000E4C 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 00000E4D D046E9                  	rol byte [bp + ?append], 1	; text appended without visible window move ?
  3157 00000E50 730E                    	jnc .not_append_redraw		; no, do full redraw -->
  3158 00000E52 F656E9                  	not byte [bp + ?append]		; = 0, reset flag after its use
  3159 00000E55 01CA                    	add dx, cx			; -> behind text to write
  3160 00000E57 4A                      	dec dx				; -> at last codepoint (appended)
  3161 00000E58 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 00000E5B E851F3                  	call puts			; draw appended text
  3169                                  %endif
  3170 00000E5E EB1A                    	jmp .after_append_redraw	; skip past more prompt/text redraw
  3171                                  
  3172                                  .not_append_redraw:
  3173 00000E60 51                      	push cx
  3174 00000E61 52                      	push dx
  3175 00000E62 B00D                    	mov al, 13
  3176 00000E64 E8BEF8                  	call putc			; reset to start of line
  3177                                  
  3178 00000E67 C456F6                  	les dx, [bp + ?prompt]
  3179 00000E6A 8B4EE2                  	mov cx, [bp + ?promptlength]
  3180 00000E6D E83FF3                  	call puts			; redraw the prompt
  3181 00000E70 16                      	 push ss
  3182 00000E71 07                      	 pop es				; reset es
  3183 00000E72 5A                      	pop dx
  3184 00000E73 59                      	pop cx				; restore registers for text redraw
  3185                                  %if _GETLINEHIGHLIGHT
  3186                                  					; di for prefix highlight condition
  3187 00000E74 8B5EF0                  	mov bx, word [bp + ?length_input]
  3188                                  					; bx for suffix highlight condition
  3189 00000E77 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 00000E7A 5A                      	pop dx
  3196 00000E7B 5B                      	pop bx
  3197 00000E7C 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 00000E7D 29D9                    	sub cx, bx			; = how many blanks needed to overwrite
  3203 00000E7F 7609                    	jbe @FF
  3204 00000E81 01CB                    	add bx, cx			; = length displayed
  3205 00000E83 B020                    	mov al, 32
  3206                                  @@:
  3207 00000E85 E89DF8                  	call putc
  3208 00000E88 E2FB                    	loop @B
  3209                                  @@:
  3210 00000E8A 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 00000E8B 01D3                    	add bx, dx
  3224 00000E8D 81EB[0200]              	sub bx, line_in + 2		; offset into line (with length displayed)
  3225 00000E91 035EE2                  	add bx, word [bp + ?promptlength]; offset into display
  3226 00000E94 3B5EE4                  	cmp bx, word [bp + ?column]	; same as column ?
  3227 00000E97 7437                    	je .do_redraw_done		; yes, skip cursor movement stuff -->
  3228                                  
  3229                                  .redraw_always_move_cursor:
  3230 00000E99 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 00000E9D D046E6                  	rol byte [bp + ?cursorright], 1	; only cursor to the right without
  3235                                  					;  having to scroll the visible text ?
  3236 00000EA0 7312                    	jnc @F				; no, do redraw -->
  3237 00000EA2 F656E6                  	not byte [bp + ?cursorright]	; = 0, reset for next iteration
  3238 00000EA5 B90100                  	mov cx, 1			; length of text to write
  3239 00000EA8 2B46E2                  	sub ax, word [bp + ?promptlength]
  3240                                  					; = offset into input text
  3241 00000EAB 48                      	dec ax				; -> last codepoint of text
  3242                                  	;; test ax, ax			; at start of visible text ?
  3243 00000EAC 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 00000EAE 31FF                    	xor di, di			; else, tell it not to highlight
  3247 00000EB0 01C2                    	add dx, ax			; dx = "skip" + line_in + 2 + index
  3248 00000EB2 EB17                    	jmp .redraw_cursorright
  3249                                  
  3250                                  @@:
  3251 00000EB4 50                      	push ax
  3252 00000EB5 52                      	push dx
  3253 00000EB6 B00D                    	mov al, 13
  3254 00000EB8 E86AF8                  	call putc			; reset cursor
  3255 00000EBB C456F6                  	les dx, [bp + ?prompt]
  3256 00000EBE 8B4EE2                  	mov cx, [bp + ?promptlength]
  3257 00000EC1 E8EBF2                  	call puts			; redraw prompt
  3258 00000EC4 16                      	 push ss
  3259 00000EC5 07                      	 pop es
  3260 00000EC6 5A                      	pop dx				; -> current input text
  3261 00000EC7 59                      	pop cx				; = col
  3262 00000EC8 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 00000ECB 31DB                    	xor bx, bx			; bx = 0, never highlight a suffix
  3280 00000ECD E82103                  	call puts_with_highlight
  3281                                  %else
  3282                                  	call puts			; draw (to move cursor)
  3283                                  %endif
  3284                                  
  3285                                  .do_redraw_done:
  3286 00000ED0 F656EA                  	not byte [bp + ?redraw]		; = 0
  3287                                  
  3288                                  .no_do_redraw:
  3289                                  
  3290 00000ED3 D046EB                  	rol byte [bp + ?beep], 1
  3291 00000ED6 7308                    	jnc .no_do_beep
  3292                                  .do_beep:
  3293 00000ED8 B007                    	mov al, 7
  3294 00000EDA E848F8                  	call putc
  3295                                  
  3296 00000EDD F656EB                  	not byte [bp + ?beep]		; = 0
  3297                                  .no_do_beep:
  3298                                  
  3299 00000EE0 E883F8                  	call getc			; ax = keycode, al = ASCII or 0
  3300                                  
  3301                                  		; check scancode for int 16h in non-dumb dosemu first
  3302 00000EE3 86C4                    	xchg al, ah
  3303 00000EE5 3C48                    	cmp al, 48h
  3304 00000EE7 7503E9F501              	je .up
  3305 00000EEC 3C4B                    	cmp al, 4Bh
  3306 00000EEE 7503E9C201              	je .left
  3307 00000EF3 3C50                    	cmp al, 50h
  3308 00000EF5 7503E90202              	je .down
  3309 00000EFA 3C4D                    	cmp al, 4Dh
  3310 00000EFC 7503E9C701              	je .right
  3311 00000F01 3C52                    	cmp al, 52h
  3312 00000F03 7503E94B02              	je .insert
  3313 00000F08 3C53                    	cmp al, 53h
  3314 00000F0A 7503E96801              	je .del
  3315 00000F0F 3C47                    	cmp al, 47h
  3316 00000F11 7503E98501              	je .home
  3317 00000F16 3C4F                    	cmp al, 4Fh
  3318 00000F18 7503E98A01              	je .end
  3319 00000F1D 3C49                    	cmp al, 49h
  3320 00000F1F 7503E92F02              	je .pageup
  3321 00000F24 3C51                    	cmp al, 51h
  3322 00000F26 7503E92802              	je .pagedown
  3323                                  
  3324                                  		; not a special scancode, check character returned
  3325 00000F2B 86C4                    	xchg al, ah
  3326 00000F2D 3C1B                    	cmp al, 1Bh
  3327 00000F2F 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 00000F34 E82FF8                  	call getc
  3333 00000F37 3C5B                    	cmp al, '['
  3334 00000F39 7403E91502              	jne .beep
  3335 00000F3E E825F8                  	call getc
  3336 00000F41 3C41                    	cmp al, 41h
  3337 00000F43 7503E99901              	je .up
  3338 00000F48 3C44                    	cmp al, 44h
  3339 00000F4A 7503E96601              	je .left
  3340 00000F4F 3C42                    	cmp al, 42h
  3341 00000F51 7503E9A601              	je .down
  3342 00000F56 3C43                    	cmp al, 43h
  3343 00000F58 7503E96B01              	je .right
  3344 00000F5D 3C32                    	cmp al, 32h
  3345 00000F5F 7425                    	je .check_insert
  3346 00000F61 3C33                    	cmp al, 33h
  3347 00000F63 7421                    	je .check_del
  3348 00000F65 3C31                    	cmp al, 31h
  3349 00000F67 741D                    	je .check_home
  3350 00000F69 3C34                    	cmp al, 34h
  3351 00000F6B 7419                    	je .check_end
  3352 00000F6D 3C48                    	cmp al, 48h
  3353 00000F6F 7503E92701              	je .home
  3354 00000F74 3C46                    	cmp al, 46h
  3355 00000F76 7503E92C01              	je .end
  3356 00000F7B 3C35                    	cmp al, 35h
  3357 00000F7D 7407                    	je .check_pageup
  3358 00000F7F 3C36                    	cmp al, 36h
  3359 00000F81 7403                    	je .check_pagedown
  3360 00000F83 E9CD01                  	jmp .beep
  3361                                  
  3362                                  
  3363                                  .check_insert:
  3364                                  .check_del:
  3365                                  .check_home:
  3366                                  .check_end:
  3367                                  .check_pageup:
  3368                                  .check_pagedown:
  3369 00000F86 50                      	push ax
  3370 00000F87 E8DCF7                  	call getc
  3371 00000F8A 3C7E                    	cmp al, 7Eh
  3372 00000F8C 58                      	pop ax
  3373 00000F8D 7403E9C101              	jne .beep
  3374                                  
  3375 00000F92 3C32                    	cmp al, 32h
  3376 00000F94 7503E9BA01              	je .insert
  3377 00000F99 3C33                    	cmp al, 33h
  3378 00000F9B 7503E9D700              	je .del
  3379 00000FA0 3C31                    	cmp al, 31h
  3380 00000FA2 7503E9F400              	je .home
  3381 00000FA7 3C34                    	cmp al, 34h
  3382 00000FA9 7503E9F900              	je .end
  3383 00000FAE 3C35                    	cmp al, 35h
  3384 00000FB0 7503E99E01              	je .pageup
  3385 00000FB5 3C36                    	cmp al, 36h
  3386 00000FB7 7503E99701              	je .pagedown
  3387                                  
  3388 00000FBC E99401                  	jmp .beep
  3389                                  
  3390                                  
  3391                                  .not_esc:
  3392                                  		; check regular characters
  3393 00000FBF 84C0                    	test al, al			; waste?
  3394 00000FC1 7503E9FBFD              	je .next
  3395 00000FC6 3CE0                    	cmp al, 0E0h
  3396 00000FC8 7503E9F4FD              	je .next			; waste -->
  3397                                  
  3398 00000FCD 3C01                    	cmp al, 'A' - '@'
  3399 00000FCF 7503E9C700              	je .home
  3400 00000FD4 3C05                    	cmp al, 'E' - '@'
  3401 00000FD6 7503E9CC00              	je .end
  3402 00000FDB 3C03                    	cmp al, 03h
  3403 00000FDD 7503E97801              	je .ctrlc
  3404 00000FE2 3C09                    	cmp al, 09h
  3405 00000FE4 7503E96A01              	je .beep		; tab
  3406 00000FE9 3C08                    	cmp al, 08h
  3407 00000FEB 745F                    	je .backspace
  3408 00000FED 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 00000FEF 745B                    	je .backspace
  3412 00000FF1 3C0A                    	cmp al, 10			; (allow Linux style linebreak)
  3413 00000FF3 7503E96501              	je .done
  3414 00000FF8 3C0D                    	cmp al, 13			; (match for CR keypress)
  3415 00000FFA 7503E95E01              	je .done
  3416                                  
  3417                                  .textcodepoint:
  3418 00000FFF 8B5EF0                  	mov bx, word [bp + ?length_input]
  3419 00001002 81FBFE00                	cmp bx, ?limit
  3420 00001006 7207                    	jb @F
  3421                                  .redraw_and_beep:
  3422 00001008 C646EAFF                	mov byte [bp + ?redraw], -1
  3423 0000100C E94401                  	jmp .beep
  3424                                  @@:
  3425                                  
  3426 0000100F C646E7FF                	mov byte [bp + ?edited], -1
  3427 00001013 8B56F0                  	mov dx, word [bp + ?length_input]
  3428 00001016 89D1                    	mov cx, dx
  3429 00001018 89D7                    	mov di, dx
  3430 0000101A 16                      	push ss
  3431 0000101B 07                      	pop es
  3432 0000101C 81C7[0200]              	add di, line_in + 2		; di -> behind end of input
  3433 00001020 89FE                    	mov si, di
  3434 00001022 4E                      	dec si				; si -> at last entry of input
  3435 00001023 2B4EEE                  	sub cx, word [bp + ?offset]
  3436 00001026 7504                    	jnz @F				; not appending -->
  3437                                  .textappend:
  3438 00001028 C646E9FF                	mov byte [bp + ?append], -1
  3439                                  @@:
  3440 0000102C FD                      	std				; AMD erratum 109 workaround done
  3441                                  	numdef AMD_ERRATUM_109_WORKAROUND, 1
  3442                                  %if _AMD_ERRATUM_109_WORKAROUND
  3443 0000102D E308                    	jcxz @FF
  3444 0000102F 83F914                  	cmp cx, 20
  3445 00001032 7703                    	ja @FF
  3446                                  @@:
  3447 00001034 A4                      	movsb
  3448 00001035 E2FD                    	loop @B
  3449                                  @@:
  3450                                  %endif
  3451 00001037 F3A4                    	rep movsb
  3452 00001039 FC                      	cld
  3453 0000103A 8805                    	mov byte [di], al
  3454 0000103C FF46E4                  	inc word [bp + ?column]
  3455 0000103F FF46EE                  	inc word [bp + ?offset]
  3456 00001042 FF46F0                  	inc word [bp + ?length_input]
  3457                                  .redraw:
  3458 00001045 C646EAFF                	mov byte [bp + ?redraw], -1
  3459 00001049 E975FD                  	jmp .next
  3460                                  
  3461                                  .backspace:
  3462 0000104C 837EEE00                	cmp word [bp + ?offset], 0
  3463 00001050 7422                    	je .backspace_offset_0
  3464                                  
  3465 00001052 C646E7FF                	mov byte [bp + ?edited], -1
  3466 00001056 16                      	push ss
  3467 00001057 07                      	pop es
  3468 00001058 8B7EEE                  	mov di, word [bp + ?offset]
  3469 0000105B 8B4EF0                  	mov cx, word [bp + ?length_input]
  3470 0000105E 29F9                    	sub cx, di			; length after offset
  3471 00001060 81C7[0200]              	add di, line_in + 2		; -> at offset in line
  3472 00001064 89FE                    	mov si, di			; -> at offset in line
  3473 00001066 4F                      	dec di				; -> at offset - 1 in line
  3474 00001067 F3A4                    	rep movsb			; move down additional content
  3475 00001069 FF4EE4                  	dec word [bp + ?column]
  3476 0000106C FF4EEE                  	dec word [bp + ?offset]
  3477 0000106F FF4EF0                  	dec word [bp + ?length_input]
  3478 00001072 EBD1                    	jmp .redraw
  3479                                  
  3480                                  .backspace_offset_0:
  3481                                  .del_offset_ae_length_input:
  3482                                  .left_offset_0:
  3483                                  .right_offset_too_high:
  3484 00001074 E9DC00                  	jmp .beep
  3485                                  
  3486                                  .del:
  3487 00001077 8B46EE                  	mov ax, word [bp + ?offset]
  3488 0000107A 3B46F0                  	cmp ax, word [bp + ?length_input]
  3489 0000107D 73F5                    	jae .del_offset_ae_length_input
  3490 0000107F C646E7FF                	mov byte [bp + ?edited], -1
  3491 00001083 89C7                    	mov di, ax
  3492 00001085 81C7[0200]              	add di, line_in + 2		; -> at current offset
  3493 00001089 89FE                    	mov si, di
  3494 0000108B 46                      	inc si				; -> after current offset
  3495 0000108C 40                      	inc ax				; offset + 1
  3496 0000108D F7D8                    	neg ax				; - (offset + 1)
  3497 0000108F 0346F0                  	add ax, word [bp + ?length_input]; length input - (offset + 1)
  3498 00001092 89C1                    	mov cx, ax
  3499 00001094 F3A4                    	rep movsb			; move down part after deleted point
  3500 00001096 FF4EF0                  	dec word [bp + ?length_input]
  3501 00001099 EBAA                    	jmp .redraw
  3502                                  
  3503                                  .home:
  3504 0000109B 8366EE00                	and word [bp + ?offset], 0
  3505 0000109F FF76E2                  	push word [bp + ?promptlength]
  3506 000010A2 8F46E4                  	pop word [bp + ?column]
  3507 000010A5 EB9E                    	jmp .redraw
  3508                                  
  3509                                  .end:
  3510 000010A7 8B46F0                  	mov ax, word [bp + ?length_input]
  3511 000010AA 8946EE                  	mov word [bp + ?offset], ax
  3512 000010AD 0346E2                  	add ax, word [bp + ?promptlength]
  3513 000010B0 8946E4                  	mov word [bp + ?column], ax
  3514 000010B3 EB90                    	jmp .redraw
  3515                                  
  3516                                  .left:
  3517 000010B5 837EEE00                	cmp word [bp + ?offset], 0
  3518 000010B9 74B9                    	je .left_offset_0
  3519 000010BB C646E8FF                	mov byte [bp + ?cursormove], -1
  3520 000010BF FF4EEE                  	dec word [bp + ?offset]
  3521 000010C2 FF4EE4                  	dec word [bp + ?column]
  3522 000010C5 E97DFF                  	jmp .redraw
  3523                                  
  3524                                  .right:
  3525 000010C8 8B46EE                  	mov ax, word [bp + ?offset]
  3526 000010CB 3B46F0                  	cmp ax, word [bp + ?length_input]
  3527 000010CE 73A4                    	jnb .right_offset_too_high
  3528 000010D0 C646E8FF                	mov byte [bp + ?cursormove], -1
  3529 000010D4 C646E6FF                	mov byte [bp + ?cursorright], -1
  3530 000010D8 FF46EE                  	inc word [bp + ?offset]
  3531 000010DB FF46E4                  	inc word [bp + ?column]
  3532 000010DE E964FF                  	jmp .redraw
  3533                                  
  3534                                  .up:
  3535 000010E1 D046E7                  	rol byte [bp + ?edited], 1
  3536 000010E4 726D                    	jc .beep
  3537                                  %if _HISTORY
  3538 000010E6 8B76F4                  	mov si, word [bp + ?historyentry]
  3539 000010E9 85F6                    	test si, si
  3540 000010EB 8D7402                  	lea si, [si + 2]
  3541 000010EE 7504                    	jnz @F
  3542 000010F0 8B36[0000]              	mov si, word [history.last]
  3543                                  @@:
  3544 000010F4 3B36[0000]              	cmp si, word [history.first]
  3545 000010F8 7459                    	je .beep
  3546 000010FA EB1A                    	jmp .copyline
  3547                                  
  3548                                  .down:
  3549 000010FC D046E7                  	rol byte [bp + ?edited], 1
  3550 000010FF 7252                    	jc .beep
  3551 00001101 8B76F4                  	mov si, word [bp + ?historyentry]
  3552 00001104 85F6                    	test si, si
  3553 00001106 744B                    	jz .beep
  3554 00001108 3B36[0000]              	cmp si, word [history.last]
  3555 0000110C 7506                    	jne @F
  3556 0000110E 31C0                    	xor ax, ax
  3557 00001110 31C9                    	xor cx, cx
  3558 00001112 EB10                    	jmp .setline
  3559                                  
  3560                                  @@:
  3561 00001114 4E                      	dec si
  3562 00001115 4E                      	dec si
  3563                                  
  3564                                  .copyline:
  3565 00001116 89F0                    	mov ax, si
  3566                                  	gethistorysegment ds
   480 00001118 368E1E[0000]        <1>  mov %1, word [ss:history.segorsel]
  3567 0000111D 8B0C                    	mov cx, [si]
  3568 0000111F 8B7402                  	mov si, [si + 2]
  3569 00001122 29F1                    	sub cx, si
  3570                                  
  3571                                  .setline:
  3572 00001124 8946F4                  	mov word [bp + ?historyentry], ax
  3573                                  	gethistoryoffset bx
   483 00001127 BB0000              <1>  mov %1, 0
  3574 0000112A 8D30                    	lea si, [si + bx]
  3575 0000112C 16                      	push ss
  3576 0000112D 07                      	pop es
  3577 0000112E BF[0100]                	mov di, line_in + 1
  3578 00001131 88C8                    	mov al, cl
  3579 00001133 AA                      	stosb
  3580 00001134 F3A4                    	rep movsb
  3581 00001136 B00D                    	mov al, 13
  3582 00001138 AA                      	stosb
  3583 00001139 16                      	push ss
  3584 0000113A 1F                      	pop ds
  3585                                  %else
  3586                                  .down: equ .beep
  3587                                  
  3588                                  	mov byte [bp + ?edited], -1
  3589                                  %endif
  3590 0000113B 31C0                    	xor ax, ax
  3591 0000113D A0[0100]                	mov al, byte [line_in + 1]
  3592 00001140 8946EE                  	mov word [bp + ?offset], ax
  3593 00001143 8946F0                  	mov word [bp + ?length_input], ax
  3594 00001146 0346E2                  	add ax, word [bp + ?promptlength]
  3595 00001149 8946E4                  	mov word [bp + ?column], ax
  3596 0000114C 8366EC00                	and word [bp + ?lastskip], 0
  3597 00001150 E9F2FE                  	jmp .redraw
  3598                                  
  3599                                  .insert:
  3600                                  .pageup:
  3601                                  .pagedown:
  3602                                  .beep:
  3603 00001153 C646EBFF                	mov byte [bp + ?beep], -1
  3604 00001157 E967FC                  	jmp .next
  3605                                  
  3606                                  .ctrlc:
  3607 0000115A E9(0000)                	jmp handle_ctrl_c
  3608                                  
  3609                                  .done:
  3610 0000115D 8B7EF0                  	mov di, word [bp + ?length_input]
  3611                                  
  3612 00001160 8B56EC                  	mov dx, word [bp + ?lastskip]
  3613 00001163 0356F2                  	add dx, word [bp + ?length_displayed]
  3614                                  					; offset into line (with length displayed)
  3615 00001166 0356E2                  	add dx, word [bp + ?promptlength]; offset into display
  3616 00001169 3B56E4                  	cmp dx, word [bp + ?column]	; same as column ?
  3617 0000116C 750A                    	jne @F				; no, always redraw -->
  3618                                  
  3619 0000116E 89F8                    	mov ax, di
  3620 00001170 0346E2                  	add ax, word [bp + ?promptlength]
  3621 00001173 3946FE                  	cmp word [bp + ?columns], ax
  3622 00001176 7720                    	ja .done_no_redraw
  3623                                  
  3624                                  @@:
  3625 00001178 B00D                    	mov al, 13
  3626 0000117A E8A8F5                  	call putc			; reset cursor
  3627 0000117D C456F6                  	les dx, [bp + ?prompt]
  3628 00001180 8B4EE2                  	mov cx, [bp + ?promptlength]	; es:dx length cx -> prompt data
  3629                                  %if _40COLUMNS
  3630 00001183 31C0                    	xor ax, ax			; last fragment length = 0
  3631 00001185 E840F3                  	call puts_break_line
  3632 00001188 16                      	 push ss
  3633 00001189 07                      	 pop es
  3634 0000118A 8B4EF0                  	mov cx, word [bp + ?length_input]
  3635 0000118D E303                    	jcxz @F				; if empty line -->
  3636 0000118F E85BF3                  	call puts_break_line_more	; more follows, do a linebreak if ax == 0
  3637                                  @@:
  3638 00001192 BA[0200]                	mov dx, line_in + 2		; es:dx length cx -> input line data
  3639 00001195 E830F3                  	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 00001198 81C7[0200]              	add di, line_in + 2
  3653 0000119C B00D                    	mov al, 13
  3654 0000119E AA                      	stosb				; store the CR (there always is room)
  3655 0000119F 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 000011A0 2C03                    	sub al, 3
  3663                                   wlcalc byte_ext_line_in, equ $ - 1
  3664                                  %endif
  3665 000011A2 5F                      	pop di				; restore di
  3666 000011A3 A2[0100]                	mov byte [line_in+1], al	; store the length byte
  3667 000011A6 89EC5D                  	lleave code
  3668                                  %if _EXTENSIONS && _EXT_PUTS_GETLINE
  3669 000011A9 F616[0000]              	not byte [in_getinput]		; clear
  3670 000011AD B301                    	mov bl, 1
  3671                                  %endif
  3672 000011AF E937FA                  	jmp getline_eol_enter_history_and_ext
  3673                                  
  3674                                  	lleave ctx
  3675                                  
  3676                                  
  3677                                  fullbsout:
  3678 000011B2 B008                    	mov al, 8
  3679 000011B4 E86EF5                  	call putc
  3680 000011B7 B020                    	mov al, 32
  3681 000011B9 E869F5                  	call putc
  3682 000011BC B008                    	mov al, 8
  3683 000011BE E964F5                  	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 000011C1 31C0                    	xor ax, ax
  3691 000011C3 F606[0000]10            	testopt [serial_flags], sf_use_serial
  3692                                  					; serial ?
  3693 000011C8 7411                    	jz @F				; no -->
  3694 000011CA 0A06[0000]              	or al, byte [serial_columns]	; ax = number of columns if serial
  3695 000011CE 7407                    	jz .default_columns
  3696 000011D0 3C01                    	cmp al, 1
  3697 000011D2 751C                    	jne @FF
  3698 000011D4 48                      	dec ax				; = 0
  3699 000011D5 EB04                    	jmp @F				; use IOC / BDA selection
  3700                                  .default_columns:
  3701 000011D7 B050                    	mov al, 80
  3702 000011D9 EB15                    	jmp @FF
  3703                                  @@:
  3704 000011DB 0A06[0000]              	or al, [io_columns]
  3705 000011DF 74F6                    	jz .default_columns
  3706 000011E1 3C01                    	cmp al, 1			; is 1 ?
  3707 000011E3 750B                    	jne @F				; no, use as columns -->
  3708                                  					; yes, automatic (use BDA)
  3709 000011E5 06                      	push es
  3710 000011E6 B84000                  	mov ax, 40h			; 0040h is a bimodal segment/selector
  3711 000011E9 8EC0                    	mov es, ax
  3712 000011EB 26A14A00                	mov ax, word [ es:4Ah ]		; columns on screen
  3713 000011EF 07                      	pop es
  3714                                  @@:
  3715 000011F0 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 000011F1 E33F                    	jcxz .retn
  3737 000011F3 F606[0300]01            	testopt [options3], opt3_getline_highlight
  3738 000011F8 7439                    	jz .justputs
  3739 000011FA 51                      	push cx
  3740 000011FB 85FF                    	test di, di			; prefix to highlight ?
  3741 000011FD 7414                    	jz @F				; no -->
  3742                                  .prefix:
  3743 000011FF 53                      	push bx
  3744 00001200 E83300                  	call emit_highlight
  3745 00001203 52                      	 push dx			; ! dx on stack
  3746 00001204 51                      	push cx
  3747 00001205 B90100                  	mov cx, 1
  3748 00001208 E8A4EF                  	call puts			; draw one codepoint
  3749 0000120B 59                      	pop cx
  3750 0000120C E83000                  	call emit_unhighlight
  3751 0000120F 5A                      	 pop dx				; ! restore dx -> data
  3752 00001210 42                      	inc dx				; -> second codepoint
  3753 00001211 49                      	dec cx				; length one less
  3754 00001212 5B                      	pop bx
  3755                                  @@:
  3756 00001213 58                      	pop ax				; = length of text (including prefix)
  3757 00001214 01F8                    	add ax, di			; = index past last displayed
  3758 00001216 39D8                    	cmp ax, bx			; is it equal to total text length ?
  3759 00001218 7319                    	jae .justputs			; yes, just display -->
  3760                                  
  3761                                  .suffix:
  3762 0000121A E316                    	jcxz .retn			; if no suffix possible -->
  3763 0000121C 49                      	dec cx				; = length of unhighlighted text
  3764 0000121D 89C8                    	mov ax, cx
  3765 0000121F 01D0                    	add ax, dx			; -> at codepoint to highlight
  3766 00001221 50                      	push ax
  3767 00001222 E88AEF                  	call puts			; draw unhighlighted text
  3768 00001225 E80E00                  	call emit_highlight
  3769 00001228 5A                      	pop dx				; -> at codepoint to highlight
  3770 00001229 B90100                  	mov cx, 1
  3771 0000122C E880EF                  	call puts			; draw one codepoint
  3772 0000122F E80D00                  	call emit_unhighlight
  3773                                  .retn:
  3774 00001232 C3                      	retn
  3775                                  
  3776                                  .justputs:
  3777 00001233 E979EF                  	jmp puts			; draw text (no highlight)
  3778                                  %endif
  3779                                  
  3780                                  
  3781                                  %if _GETLINEHIGHLIGHT || _DHIGHLIGHT
  3782                                  emit_highlight:
  3783 00001236 52                      	push dx
  3784 00001237 BA[0100]                	mov dx, msg.highlight + 1	; -> ASCIZ escape code
  3785 0000123A E8C6F4                  	call putsz
  3786 0000123D 5A                      	pop dx
  3787 0000123E C3                      	retn
  3788                                  
  3789                                  emit_unhighlight:
  3790 0000123F 52                      	push dx
  3791 00001240 BA[0100]                	mov dx, msg.unhighlight + 1	; -> ASCIZ escape code
  3792 00001243 E8BDF4                  	call putsz
  3793 00001246 5A                      	pop dx
  3794 00001247 C3                      	retn
  3795                                  %endif
  3796                                  
  3797                                  
  3798                                  getline_reset_notatty:
  3799 00001248 F606[0300]02            	testopt [internalflags3], dif3_input_re_closed
  3800 0000124D 7421                    	jz @F
  3801 0000124F 8026[0300]FD            	clropt [internalflags3], dif3_input_re_closed
  3802 00001254 F606[0100]01            	testopt [internalflags3], dif3_input_cmdline
  3803 00001259 7515                    	jnz @F
  3804                                  %if _INPUT_FILE_HANDLES
  3805 0000125B E8(0000)                	call InDOS_or_BIOS_IO
  3806 0000125E 7507                    	jnz .notfile1
  3807 00001260 F606[0200]10            	testopt [internalflags2], dif2_input_file
  3808 00001265 7509                    	jnz @F
  3809                                  .notfile1:
  3810                                  %endif
  3811                                  %if _INPUT_FILE_BOOT
  3812 00001267 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  3813 0000126C 7502                    	jnz @F
  3814                                  %endif
  3815 0000126E EB47                    	jmp .clear_notatty
  3816                                  
  3817                                  @@:
  3818 00001270 F606[0100]02            	testopt [internalflags3], dif3_input_cmdline_closed
  3819 00001275 741A                    	jz @F
  3820 00001277 8026[0100]FD            	clropt [internalflags3], dif3_input_cmdline_closed
  3821                                  %if _INPUT_FILE_HANDLES
  3822 0000127C E8(0000)                	call InDOS_or_BIOS_IO
  3823 0000127F 7507                    	jnz .notfile2
  3824 00001281 F606[0200]10            	testopt [internalflags2], dif2_input_file
  3825 00001286 7509                    	jnz @F
  3826                                  .notfile2:
  3827                                  %endif
  3828                                  %if _INPUT_FILE_BOOT
  3829 00001288 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  3830 0000128D 7502                    	jnz @F
  3831                                  %endif
  3832 0000128F EB26                    	jmp .clear_notatty
  3833                                  
  3834                                  @@:
  3835                                  %if _INPUT_FILE_BOOT
  3836 00001291 F606[0300]04            	testopt [internalflags2], dif2_closed_input_file_boot
  3837 00001296 7413                    	jz @F
  3838 00001298 8026[0300]FB            	clropt [internalflags2], dif2_closed_input_file_boot
  3839                                  %if _INPUT_FILE_HANDLES
  3840 0000129D E8(0000)                	call InDOS_or_BIOS_IO
  3841 000012A0 7507                    	jnz .notfile3
  3842 000012A2 F606[0200]10            	testopt [internalflags2], dif2_input_file
  3843 000012A7 7502                    	jnz @F
  3844                                  .notfile3:
  3845                                  %endif
  3846 000012A9 EB0C                    	jmp .clear_notatty
  3847                                  @@:
  3848                                  %endif
  3849                                  %if _INPUT_FILE_HANDLES
  3850 000012AB F606[0200]20            	testopt [internalflags2], dif2_closed_input_file
  3851 000012B0 7411                    	jz @F
  3852 000012B2 8026[0200]DF            	clropt [internalflags2], dif2_closed_input_file
  3853                                  %else
  3854                                  	jmp @F
  3855                                  %endif
  3856                                  .clear_notatty:
  3857 000012B7 F606[0000]30            	testopt [internalflags], inputfile | notstdinput
  3858 000012BC 7505                    	jnz @F
  3859 000012BE C606[0000]00            	mov byte [notatty], 0	; it _is_ a tty
  3860                                  @@:
  3861 000012C3 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 000012C4 E8(0000)                	call handle_serial_flags_ctrl_c
  3873 000012C7 50                      	push ax
  3874 000012C8 53                      	push bx
  3875 000012C9 51                      	push cx
  3876 000012CA 52                      	push dx
  3877 000012CB 89FE                    	mov si, di		; we know this already
  3878 000012CD B9[0101]                	mov cx, line_in+LINE_IN_LEN
  3879 000012D0 89FA                    	mov dx, di
  3880 000012D2 29F9                    	sub cx, di
  3881 000012D4 7703E99E00              	jbe .ret_cy		; if no more room -->
  3882                                  
  3883                                  %if !_LOADER
  3884 000012D9 F606[0300]01            	testopt [internalflags3], dif3_input_re
  3885 000012DE 7429                    	jz .not_re
  3886 000012E0 56                      	push si
  3887 000012E1 57                      	push di
  3888 000012E2 89CB                    	mov bx, cx
  3889 000012E4 8B36[0000]              	mov si, word [re_buffer.position]
  3890 000012E8 89F7                    	mov di, si
  3891 000012EA B9FFFF                  	mov cx, -1
  3892 000012ED 31C0                    	xor ax, ax
  3893 000012EF F2AE                    	repne scasb
  3894 000012F1 F7D1                    	not cx
  3895 000012F3 49                      	dec cx
  3896 000012F4 39CB                    	cmp bx, cx
  3897 000012F6 7702                    	ja @F
  3898 000012F8 89D9                    	mov cx, bx
  3899                                  @@:
  3900 000012FA 89C8                    	mov ax, cx
  3901 000012FC 89D7                    	mov di, dx
  3902 000012FE F3A4                    	rep movsb
  3903 00001300 8936[0000]              	mov word [re_buffer.position], si
  3904 00001304 5F                      	pop di
  3905 00001305 5E                      	pop si
  3906 00001306 F8                      	clc
  3907 00001307 EB60                    	jmp .after
  3908                                  
  3909                                  .not_re:
  3910                                  %endif
  3911                                  
  3912                                  %if _INPUT_FILE_BOOT
  3913 00001309 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  3914 0000130E 7408                    	jz @F
  3915 00001310 E8(0000)                	call yy_boot_remember_seek
  3916 00001313 E8(0000)                	call yy_boot_read
  3917 00001316 EB51                    	jmp .after
  3918                                  @@:
  3919                                  %endif
  3920                                  
  3921                                  %if _INPUT_FILE_HANDLES
  3922 00001318 E8(0000)                	call InDOS_or_BIOS_IO
  3923 0000131B 750E                    	jnz @F
  3924 0000131D F606[0200]10            	testopt [internalflags2], dif2_input_file
  3925 00001322 7407                    	jz @F			; if not input file -->
  3926 00001324 57                      	push di
  3927 00001325 E82AF6                  	call yy_get_handle	; bx = handle
  3928 00001328 5F                      	pop di
  3929 00001329 EB37                    	jmp .file_handle
  3930                                  %endif
  3931                                  
  3932                                  @@:
  3933 0000132B F606[0100]01            	testopt [internalflags3], dif3_input_cmdline
  3934 00001330 7429                    	jz .not_cmdline
  3935 00001332 56                      	push si
  3936 00001333 57                      	push di
  3937 00001334 89CB                    	mov bx, cx
  3938 00001336 8B36[0000]              	mov si, word [cmdline_buffer.position]
  3939 0000133A 89F7                    	mov di, si
  3940 0000133C B9FFFF                  	mov cx, -1
  3941 0000133F 31C0                    	xor ax, ax
  3942 00001341 F2AE                    	repne scasb
  3943 00001343 F7D1                    	not cx
  3944 00001345 49                      	dec cx
  3945 00001346 39CB                    	cmp bx, cx
  3946 00001348 7702                    	ja @F
  3947 0000134A 89D9                    	mov cx, bx
  3948                                  @@:
  3949 0000134C 89C8                    	mov ax, cx
  3950 0000134E 89D7                    	mov di, dx
  3951 00001350 F3A4                    	rep movsb
  3952 00001352 8936[0000]              	mov word [cmdline_buffer.position], si
  3953 00001356 5F                      	pop di
  3954 00001357 5E                      	pop si
  3955 00001358 F8                      	clc
  3956 00001359 EB0E                    	jmp .after
  3957                                  
  3958                                  .not_cmdline:
  3959                                  
  3960                                  @@:
  3961 0000135B 31DB                    	xor bx, bx		; bx = handle (0 is STDIN)
  3962 0000135D E8(0000)                	call InDOS_or_BIOS_IO
  3963 00001360 7515                    	jnz .ret_cy
  3964                                  
  3965                                  .file_handle:
  3966 00001362 B43F                    	mov ah, 3Fh		; read from file
  3967 00001364 E84108                  	call yy_remember_seek
  3968                                  	doscall
  1497 00001367 CD21                <1>  int 21h
  3969                                  .after:
  3970 00001369 720C                    	jc .ret_cy		; if error -->
  3971 0000136B 85C0                    	test ax, ax
  3972 0000136D 7408                    	jz .ret_cy		; if EOF -->
  3973 0000136F 01C2                    	add dx, ax		; -> behind last valid byte
  3974                                  
  3975 00001371 8026[0100]FB            	clropt [internalflags3], dif3_at_line_end
  3976                                  
  3977 00001376 A8                      	db __TEST_IMM8		; (NC)
  3978                                  .ret_cy:
  3979 00001377 F9                      	stc
  3980 00001378 8916[0000]              	mov word [bufend], dx	; -> behind last valid byte
  3981 0000137C 5A                      	pop dx
  3982 0000137D 59                      	pop cx
  3983 0000137E 5B                      	pop bx
  3984 0000137F 58                      	pop ax
  3985 00001380 C3                      	retn
  3986                                  
  3987                                  
  3988                                  %if _EXTENSIONS || _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  3989                                  display_y_or_ext:
  3990 00001381 52                      	push dx
  3991                                   %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  3992 00001382 BA[0000]                	mov dx, msg.y
  3993                                    %if _EXTENSIONS
  3994 00001385 D006[0000]              	rol byte [yy_is_script], 1
  3995 00001389 7203                    	jc @F
  3996                                    %endif
  3997                                   %endif
  3998                                   %if _EXTENSIONS
  3999 0000138B BA[0000]                	mov dx, msg.ext
  4000                                   %endif
  4001                                  @@:
  4002 0000138E E86CF3                  	call putsz_error
  4003 00001391 5A                      	pop dx
  4004 00001392 C3                      	retn
  4005                                  %endif
  4006                                  
  4007                                  
  4008                                  %if _EXTENSIONS
  4009                                  close_ext: section_of_function
  4010                                   %if _APPLICATION || _DEVICE
  4011 00001393 E8(0000)                	call InDOS
  4012 00001396 7510                    	jnz @F
  4013 00001398 BBFFFF                  	mov bx, -1
  4014 0000139B 871E[0000]              	xchg bx, word [ext_handle]
  4015 0000139F 83FBFF                  	cmp bx, -1
  4016 000013A2 7404                    	je @F
  4017 000013A4 B43E                    	mov ah, 3Eh
  4018                                  	doscall
  1497 000013A6 CD21                <1>  int 21h
  4019                                  @@:
  4020                                   %endif
  4021 000013A8 C3                      	retn
  4022                                  
  4023                                  load_extension:
  4024 000013A9 E8CAEC                  	call skipcomma
  4025 000013AC C606[0000]00            	mov byte [yy_is_script], 0
  4026 000013B1 EB08                    	jmp @F
  4027                                  %endif
  4028                                  
  4029                                  %ifn _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  4030                                  yy equ error
  4031                                  %else
  4032                                  yy:
  4033 000013B3 C606[0000]FF            	mov byte [yy_is_script], 0FFh
  4034                                  %endif
  4035                                  %if _EXTENSIONS || _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  4036 000013B8 E8(0000)                	call guard_re
  4037                                  @@:
  4038                                  yy_or_ext_no_guard_re:
  4039                                  %if _INPUT_FILE_BOOT || (_EXTENSIONS && _BOOTLDR)
  4040 000013BB F606[0100]40            	testopt [internalflags], nodosloaded
  4041 000013C0 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 000013C5 D006[0000]              	rol byte [yy_is_script], 1
  4048 000013C9 721A                    	jc @F
  4049 000013CB E8(0000)                	call InDOS
  4050 000013CE E82B01                  	call yy_dos_parse_name
  4051 000013D1 8D54FF                  	lea dx, [si - 1]
  4052 000013D4 8916[0000]              	mov word [ext_cmdline], dx
  4053 000013D8 E89CEC                  	call skipcomm0
  4054 000013DB 8936[0000]              	mov word [if_exists_then_address], si
  4055 000013DF E82A02                  	call yy_open_file
  4056 000013E2 E9F702                  	jmp ext_finish
  4057                                  
  4058                                  @@:
  4059                                  %endif
  4060                                  %ifn _INPUT_FILE_HANDLES
  4061                                  	jmp error
  4062                                  %else
  4063 000013E5 E8(0000)                	call InDOS_or_BIOS_IO
  4064 000013E8 E81101                  	call yy_dos_parse_name
  4065                                  
  4066 000013EB F606[0200]10            	testopt [internalflags2], dif2_input_file
  4067 000013F0 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 000013F2 833E[0000]0F            	cmp word [input_file_handles.active], _INPUT_FILE_HANDLES - 1
  4078 000013F7 720C                    	jb @F
  4079                                  
  4080 000013F9 B80803                  	mov ax, 0308h
  4081 000013FC E8(0000)                	call setrc
  4082 000013FF BA[0000]                	mov dx, msg.yy_too_many_handles
  4083 00001402 E99901                  	jmp yy_disp_error_1
  4084                                  @@:
  4085                                  
  4086 00001405 803F3A                  	cmp byte [bx], ':'
  4087 00001408 755E                    	jne .not_yy_goto_subfunction
  4088                                  
  4089 0000140A F606[0200]10            	testopt [internalflags2], dif2_input_file
  4090 0000140F 750C                    	jnz @F
  4091                                  
  4092 00001411 E8B6F8                  	call getline_is_input_file?
  4093 00001414 7246                    	jc .no_file
  4094 00001416 F606[0100]01            	testopt [internalflags3], dif3_input_cmdline
  4095 0000141B 753F                    	jnz .no_file
  4096                                  @@:
  4097                                  
  4098 0000141D 8B3E[0000]              	mov di, word [terminator_in_line_in.offset]
  4099 00001421 A0[0000]                	mov al, byte [terminator_in_line_in.value]
  4100 00001424 8805                    	mov byte [di], al
  4101                                  
  4102 00001426 43                      	inc bx
  4103 00001427 89DE                    	mov si, bx
  4104 00001429 E879EC                  	call skipwhite
  4105 0000142C 4E                      	dec si
  4106 0000142D 89F5                    	mov bp, si
  4107                                  
  4108 0000142F E85F06                  	call yy_reset_buf
  4109                                  
  4110 00001432 31DB                    	xor bx, bx		; bx = handle (0 is STDIN)
  4111                                  %if _INPUT_FILE_HANDLES
  4112 00001434 F606[0200]10            	testopt [internalflags2], dif2_input_file
  4113 00001439 7405                    	jz @F			; if not input file -->
  4114 0000143B 57                      	push di
  4115 0000143C E813F5                  	call yy_get_handle	; bx = handle
  4116 0000143F 5F                      	pop di
  4117                                  @@:
  4118                                  %endif
  4119 00001440 B445                    	mov ah, 45h
  4120                                  	doscall			; duplicate file handle
  1497 00001442 CD21                <1>  int 21h
  4121 00001444 7303E9FE01              	jc yy_open_file.error
  4122 00001449 93                      	xchg ax, bx
  4123                                  
  4124 0000144A 31C9                    	xor cx, cx
  4125 0000144C 31D2                    	xor dx, dx
  4126 0000144E B80142                  	mov ax, 4201h		; lseek, from current file position
  4127                                  	doscall			; call DOS
  1497 00001451 CD21                <1>  int 21h
  4128 00001453 91                      	xchg ax, cx		; dx:cx = current seek
  4129 00001454 87D1                    	xchg dx, cx		; cx:dx = current seek
  4130 00001456 BE0001                  	mov si, ifhfIsDup
  4131 00001459 93                      	xchg ax, bx
  4132 0000145A EB4F                    	jmp yy_finish
  4133                                  
  4134                                  
  4135                                  .no_file:
  4136 0000145C B80903                  	mov ax, 0309h
  4137 0000145F E8(0000)                	call setrc
  4138 00001462 BA[0000]                	mov dx, msg.yy_no_file
  4139 00001465 E93601                  	jmp yy_disp_error_1
  4140                                  
  4141                                  .not_yy_goto_subfunction:
  4142 00001468 31ED                    	xor bp, bp
  4143 0000146A E80AEC                  	call skipcomm0
  4144 0000146D 8936[0000]              	mov word [if_exists_then_address], si
  4145 00001471 E8E6EB                  	call iseol?_or_then
  4146 00001474 7429                    	je .not_yy_goto
  4147                                  
  4148 00001476 3C3A                    	cmp al, ':'
  4149 00001478 7403E9(0000)            	jne error
  4150                                  
  4151 0000147D E825EC                  	call skipwhite
  4152 00001480 4E                      	dec si
  4153 00001481 89F5                    	mov bp, si
  4154                                  
  4155                                  @@:
  4156 00001483 AC                      	lodsb
  4157 00001484 3C20                    	cmp al, 32
  4158 00001486 740D                    	je @F
  4159 00001488 3C09                    	cmp al, 9
  4160 0000148A 7409                    	je @F
  4161 0000148C 3C2C                    	cmp al, ','
  4162 0000148E 7405                    	je @F
  4163 00001490 E8D8EB                  	call iseol?
  4164 00001493 75EE                    	jne @B
  4165                                  @@:
  4166 00001495 E8DFEB                  	call skipcomm0
  4167 00001498 8936[0000]              	mov word [if_exists_then_address], si
  4168 0000149C E811EC                  	call chkeol_or_then
  4169                                  
  4170                                  .not_yy_goto:
  4171 0000149F E86A01                  	call yy_open_file
  4172                                  
  4173                                  		; ax = file handle
  4174 000014A2 E8EC05                  	call yy_reset_buf
  4175                                  
  4176 000014A5 31C9                    	xor cx, cx
  4177 000014A7 31D2                    	xor dx, dx
  4178 000014A9 31F6                    	xor si, si
  4179                                  yy_finish:
  4180 000014AB F606[0200]10            	testopt [internalflags2], dif2_input_file
  4181 000014B0 7509                    	jnz @F
  4182 000014B2 800E[0200]10            	setopt [internalflags2], dif2_input_file
  4183 000014B7 31DB                    	xor bx, bx
  4184 000014B9 EB18                    	jmp @FF
  4185                                  
  4186                                  @@:
  4187 000014BB FF06[0000]              	inc word [input_file_handles.active]
  4188 000014BF 8B1E[0000]              	mov bx, word [input_file_handles.active]
  4189 000014C3 D1E3                    	shl bx, 1
  4190 000014C5 D1E3                    	shl bx, 1
  4191 000014C7 D1E3                    	shl bx, 1		; to qword array index
  4192                                   %if INPUTFILEHANDLE_size != 8
  4193                                    %error Unexpected structure size
  4194                                   %endif
  4195 000014C9 8BBF[FAFF]              	mov di, word [input_file_handles + bx - INPUTFILEHANDLE_size + ifhFlags]
  4196 000014CD 81E700F0                	and di, ifhfTestReserved1 | ifhfTestReserved2 		| ifhfQuietInput | ifhfQuietOutput
  4198 000014D1 09FE                    	or si, di
  4199                                  @@:
  4200                                  
  4201 000014D3 8987[0000]              	mov word [input_file_handles + bx + ifhHandle], ax
  4202 000014D7 89B7[0200]              	mov word [input_file_handles + bx + ifhFlags], si
  4203 000014DB 8997[0400]              	mov word [input_file_handles + bx + ifhParentSeek], dx
  4204 000014DF 898F[0600]              	mov word [input_file_handles + bx + ifhParentSeek + 2], cx
  4205                                  
  4206 000014E3 8026[0300]EF            	clropt [internalflags3], dif3_auxbuff_guarded_1
  4207 000014E8 89EE                    	mov si, bp
  4208 000014EA 85F6                    	test si, si
  4209 000014EC 7403E9F406              	jnz cmd_goto.yy_entry
  4210                                  
  4211                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  4212 000014F1 F606[0300]08            	testopt [internalflags3], dif3_in_if
  4213 000014F6 7403E9(0000)            	jnz if_exists_found_open
  4214                                  %endif
  4215 000014FB 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 000014FC 740C                    	jz @F
  4224 000014FE B80503                  	mov ax, 0305h
  4225 00001501 E8(0000)                	call setrc
  4226 00001504 BA[0000]                	mov dx, msg.yy_no_dos
  4227 00001507 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 0000150A 31DB                    	xor bx, bx		; if none left open, -> first structure
  4234 0000150C F606[0200]10            	testopt [internalflags2], dif2_input_file
  4235 00001511 740B                    	jz @F
  4236 00001513 8B1E[0000]              	mov bx, word [input_file_handles.active]
  4237 00001517 43                      	inc bx			; point to first unused structure
  4238 00001518 D1E3                    	shl bx, 1
  4239 0000151A D1E3                    	shl bx, 1
  4240 0000151C D1E3                    	shl bx, 1		; to qword array index
  4241                                   %if INPUTFILEHANDLE_size != 8
  4242                                    %error Unexpected structure size
  4243                                   %endif
  4244                                  @@:
  4245 0000151E 89DF                    	mov di, bx		; + input_file_handles -> to close
  4246 00001520 31C0                    	xor ax, ax		; zero base amount to close
  4247 00001522 E810F4                  	call yy_close_file_handles
  4248                                  				; CHG: ax, bx, di
  4249                                  				; if we remembered to close any, do it now
  4250                                  %if _EXTENSIONS
  4251 00001525 E86BFE                  	call close_ext
  4252                                  %endif
  4253                                  %endif
  4254                                  
  4255                                  yy_common_parse_name: section_of_function
  4256 00001528 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 0000152B 4E                      	dec si
  4270                                  %if _CONFIG || _EXECUTABLE
  4271 0000152C 56                      	push si			; -> start of name
  4272 0000152D 53                      	push bx			; -> start of buffer (may != si)
  4273                                   %if _EXECUTABLE
  4274 0000152E BB[0000]                	mov bx, init_executable_pathname
  4275 00001531 8B3E[0000]              	mov di, word [init_executable_pathname.end]
  4276 00001535 BA[0000]                	mov dx, msg.executablekeyword
  4277 00001538 E8C5EA                  	call isstring?
  4278 0000153B 743D                    	je .execkw
  4279                                   %endif
  4280                                   %if _CONFIG
  4281 0000153D 830E[0000]FF            	or word [yy_try_scriptspath], -1
  4282 00001542 BB[0000]                	mov bx, scriptspath
  4283 00001545 8B3E[0000]              	mov di, word [scriptspath.dir_end]
  4284 00001549 BA[0000]                	mov dx, msg.scriptskeyword
  4285 0000154C E8B1EA                  	call isstring?
  4286 0000154F 741B                    	je .kw
  4287 00001551 BB[0000]                	mov bx, configpath
  4288 00001554 8B3E[0000]              	mov di, word [configpath.dir_end]
  4289 00001558 BA[0000]                	mov dx, msg.configkeyword
  4290 0000155B E8A2EA                  	call isstring?
  4291 0000155E 740C                    	je .kw
  4292 00001560 5B                      	pop bx			; -> start of buffer
  4293 00001561 53                      	push bx
  4294 00001562 89DF                    	mov di, bx		; -> start of buffer
  4295 00001564 BA[0000]                	mov dx, msg.emptykeyword
  4296 00001567 E896EA                  	call isstring?
  4297 0000156A 751F                    	jne @F
  4298                                  .kw:
  4299 0000156C AC                      	lodsb
  4300 0000156D 3C3A                    	cmp al, ':'
  4301 0000156F 751A                    	jne @F
  4302 00001571 F616[0000]              	not byte [yy_try_scriptspath.nokeywordused]
  4303 00001575 58                      	pop ax
  4304 00001576 58                      	pop ax
  4305 00001577 AC                      	lodsb			; load character
  4306 00001578 EB33                    	jmp @FFF
  4307                                   %endif
  4308                                  
  4309                                   %if _EXECUTABLE
  4310                                  .execkw:
  4311 0000157A AC                      	lodsb
  4312 0000157B 3C3A                    	cmp al, ':'
  4313 0000157D 750C                    	jne @F
  4314 0000157F F616[0000]              	not byte [yy_try_scriptspath.nokeywordused]
  4315 00001583 58                      	pop ax
  4316 00001584 58                      	pop ax
  4317 00001585 AC                      	lodsb			; load character
  4318 00001586 39FB                    	cmp bx, di		; empty ?
  4319 00001588 7449                    	je .empty		; yes -->
  4320 0000158A C3                      	retn
  4321                                   %endif
  4322                                  @@:
  4323 0000158B 5B                      	pop bx
  4324 0000158C 5E                      	pop si
  4325                                  %endif
  4326 0000158D 89DF                    	mov di, bx		; -> start of buffer
  4327                                  @@:
  4328 0000158F AC                      	lodsb			; load character
  4329 00001590 E8D8EA                  	call iseol?
  4330 00001593 7518                    	jne @F
  4331 00001595 BA[0000]                	mov dx, msg.yy_requires_filename
  4332 00001598 B80403                  	mov ax, 0304h
  4333 0000159B E8(0000)                	call setrc
  4334                                  yy_disp_error_1: equ $
  4335 0000159E B8FF03                  	mov ax, 03FFh
  4336 000015A1 E8(0000)                	call setrc
  4337 000015A4 E8DAFD                  	call display_y_or_ext
  4338 000015A7 E853F1                  	call putsz_error
  4339 000015AA E9(0000)                	jmp cmd3
  4340                                  
  4341                                  @@:
  4342                                  .unquoted_loop:
  4343 000015AD 3C20                    	cmp al, 32		; blank or EOL outside quoted part ?
  4344 000015AF 7449                    	je .blank
  4345 000015B1 3C09                    	cmp al, 9
  4346 000015B3 7445                    	je .blank
  4347 000015B5 E8B3EA                  	call iseol?		; (includes semicolon in lDebug)
  4348 000015B8 7440                    	je .blank		; yes -->
  4349 000015BA 3C2C                    	cmp al, ','
  4350 000015BC 743C                    	je .blank
  4351 000015BE 3C22                    	cmp al, '"'		; starting quote mark ?
  4352 000015C0 740E                    	je .quoted		; yes -->
  4353 000015C2 AA                      	stosb			; store character
  4354                                  .unquote:
  4355 000015C3 AC                      	lodsb			; load character
  4356 000015C4 EBE7                    	jmp .unquoted_loop	; continue in not-quoted loop -->
  4357                                  
  4358                                  .quoted_loop:
  4359 000015C6 E8A6EA                  	call iseol?.notsemicolon; EOL inside quoted part ?
  4360 000015C9 7424                    	je .quoted_eol		; if yes, error -->
  4361 000015CB 3C22                    	cmp al, '"'		; ending quote mark ?
  4362 000015CD 74F4                    	je .unquote		; yes -->
  4363 000015CF AA                      	stosb			; store character
  4364                                  .quoted:
  4365 000015D0 AC                      	lodsb			; load character
  4366 000015D1 EBF3                    	jmp .quoted_loop	; continue in quoted loop -->
  4367                                  
  4368                                  .empty:
  4369 000015D3 E8A1EA                  	call skipcomm0
  4370 000015D6 8936[0000]              	mov word [if_exists_then_address], si
  4371 000015DA F606[0300]08            	testopt [internalflags3], dif3_in_if
  4372 000015DF 7403E9(0000)            	jnz if_exists_not_found
  4373 000015E4 B80603                  	mov ax, 0306h
  4374 000015E7 E8(0000)                	call setrc
  4375 000015EA BA[0000]                	mov dx, msg.yy_filename_empty
  4376 000015ED EBAF                    	jmp yy_disp_error_1
  4377                                  
  4378                                  .quoted_eol:
  4379 000015EF B80703                  	mov ax, 0307h
  4380 000015F2 E8(0000)                	call setrc
  4381 000015F5 BA[0000]                	mov dx, msg.yy_filename_missing_unquote
  4382 000015F8 EBA4                    	jmp yy_disp_error_1
  4383                                  
  4384                                  .blank:
  4385 000015FA 39FB                    	cmp bx, di		; empty ?
  4386 000015FC 74D5                    	je .empty		; yes -->
  4387                                  				; done
  4388 000015FE 50                      	push ax
  4389 000015FF B000                    	mov al, 0
  4390 00001601 8605                    	xchg al, byte [di]	; terminate after filename
  4391 00001603 893E[0000]              	mov word [terminator_in_line_in.offset], di
  4392 00001607 A2[0000]                	mov byte [terminator_in_line_in.value], al
  4393 0000160A 58                      	pop ax
  4394 0000160B 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 0000160C 89DF                    	mov di, bx
  4403 0000160E E85100                  	call .setup_opencreate			; ds:si -> pathname
  4404 00001611 B86C71                  	mov ax, 716Ch				; LFN open-create
  4405 00001614 57                      	push di
  4406 00001615 31FF                    	xor di, di				; alias hint
  4407 00001617 F9                      	stc
  4408                                  	doscall
  1497 00001618 CD21                <1>  int 21h
  4409 0000161A 5F                      	pop di
  4410 0000161B 734F                    	jnc .got		; LFN call succeeded -->
  4411                                  
  4412                                  		; Early case for no-LFN-interface available.
  4413                                  	; cmp ax, 1
  4414                                  	; je .try_sfn
  4415 0000161D 3D0071                  	cmp ax, 7100h
  4416 00001620 7405                    	je .try_sfn
  4417                                  
  4418 00001622 E84800                  	call yy_check_lfn
  4419 00001625 7320                    	jnc .error		; if LFN interface is available, actual error
  4420                                  				; if LFN interface is not available, try SFN
  4421                                  
  4422                                  .try_sfn:
  4423 00001627 E83800                  	call .setup_opencreate
  4424 0000162A B8006C                  	mov ax, 6C00h				; Open-create
  4425 0000162D F9                      	stc
  4426                                  	doscall
  1497 0000162E CD21                <1>  int 21h
  4427 00001630 733A                    	jnc .got
  4428                                  
  4429 00001632 83F801                  	cmp ax, 1
  4430 00001635 7405                    	je .try_old_open
  4431 00001637 3D006C                  	cmp ax, 6C00h
  4432 0000163A 750B                    	jne .error
  4433                                  
  4434                                  .try_old_open:
  4435 0000163C 88D8                    	mov al, bl				; access and sharing modes
  4436 0000163E B43D                    	mov ah, 3Dh				; Open
  4437 00001640 89F2                    	mov dx, si				; -> filename
  4438 00001642 F9                      	stc
  4439                                  	doscall
  1497 00001643 CD21                <1>  int 21h
  4440 00001645 7325                    	jnc .got
  4441                                  
  4442                                  .error:
  4443                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  4444                                   %if _CONFIG
  4445 00001647 E86D00                  	call retry_open_scriptspath
  4446 0000164A 74C0                    	je yy_open_file
  4447                                   %endif
  4448 0000164C F606[0300]08            	testopt [internalflags3], dif3_in_if
  4449 00001651 7403E9(0000)            	jnz if_exists_not_found
  4450                                  %endif
  4451 00001656 B80A03                  	mov ax, 030Ah
  4452 00001659 E8(0000)                	call setrc
  4453 0000165C BA[0000]                	mov dx, msg.yy_error_file_open
  4454 0000165F E93CFF                  	jmp yy_disp_error_1
  4455                                  
  4456                                  .setup_opencreate:
  4457 00001662 89FE                    	mov si, di				; -> filename
  4458 00001664 BBA060                  	mov bx, 0110_0000_1010_0000b		; Auto-commit, no int 24h
  4459                                  						; No inherit
  4460                                  						; DENY WRITE, Read-only
  4461 00001667 31C9                    	xor cx, cx				; create attribute
  4462 00001669 BA0100                  	mov dx, 0000_0000_0000_0001b		; no create / open, no truncate
  4463                                  .got:
  4464 0000166C 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 0000166D 1E                      	push ds
  4493 0000166E 06                      	push es
  4494 0000166F 57                      	push di
  4495 00001670 50                      	push ax
  4496                                  	lframe
  4497                                  	lvar 34, fstype_buffer
  4498                                  	lvar 4, pathname_buffer
  4499 00001671 5589E58D66DA            	lenter
  4500                                  
  4501 00001677 AD                      	lodsw			; load first two bytes of pathname
  4502                                  
  4503 00001678 16                      	push ss
  4504 00001679 1F                      	pop ds
  4505 0000167A 89E2                    	mov dx, sp		; ds:dx -> ?pathname_buffer
  4506 0000167C 16                      	push ss
  4507 0000167D 07                      	pop es
  4508 0000167E 89E7                    	mov di, sp		; es:di -> ?pathname_buffer
  4509                                  
  4510 00001680 80FC3A                  	cmp ah, ':'		; starts with drive specifier ?
  4511 00001683 7408                    	je @F			; yes -->
  4512                                  
  4513 00001685 B419                    	mov ah, 19h
  4514                                  	doscall			; get current default drive
  1497 00001687 CD21                <1>  int 21h
  4515 00001689 0441                    	add al, 'A'		; A: = 0, convert to drive letter
  4516 0000168B B43A                    	mov ah, ':'		; drive specifier
  4517                                  @@:
  4518 0000168D AB                      	stosw
  4519 0000168E B85C00                  	mov ax, '\'		; backslash and zero terminator
  4520 00001691 AB                      	stosw			; es:di -> ?fstype_buffer
  4521                                  
  4522 00001692 31C0                    	xor ax, ax
  4523 00001694 B91100                  	mov cx, 34 >> 1
  4524 00001697 57                      	push di
  4525 00001698 F3AB                    	rep stosw		; initialise ?fstype_buffer to all zeros
  4526 0000169A 5F                      	pop di			; -> ?fstype_buffer
  4527                                  
  4528 0000169B B92000                  	mov cx, 32		; size of ?fstype_buffer
  4529 0000169E 31DB                    	xor bx, bx		; harden, initialise this
  4530 000016A0 B8A071                  	mov ax, 71A0h		; get volume information
  4531 000016A3 F9                      	stc
  4532                                  	doscall			; (depends on ds = es = ss)
  1497 000016A4 CD21                <1>  int 21h
  4533                                  
  4534 000016A6 7207                    	jc @F			; if call not supported -->
  4535                                  				; bx = FS flags
  4536 000016A8 F6C740                  	test bh, 0100_0000b	; LFN interface available ?
  4537 000016AB F9                      	stc			; if no
  4538 000016AC 7401                    	jz @F			; no -->
  4539                                  
  4540 000016AE F8                      	clc			; is available
  4541                                  @@:
  4542                                  
  4543 000016AF 89EC5D                  	lleave
  4544 000016B2 58                      	pop ax			; (restore error code)
  4545 000016B3 5F                      	pop di
  4546 000016B4 07                      	pop es
  4547 000016B5 1F                      	pop ds
  4548 000016B6 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 000016B7 833E[0000]FF            	cmp word [yy_try_scriptspath], -1
  4561 000016BC 751D                    	jne @F					; --> NZ
  4562 000016BE F616[0000]              	not byte [yy_try_scriptspath.didnotyettry]
  4563 000016C2 89FE                    	mov si, di
  4564 000016C4 B9FF00                  	mov cx, 255
  4565 000016C7 B000                    	mov al, 0
  4566 000016C9 F2AE                    	repne scasb
  4567 000016CB 89F9                    	mov cx, di
  4568 000016CD 29F1                    	sub cx, si
  4569 000016CF 8B3E[0000]              	mov di, word [scriptspath.dir_end]
  4570 000016D3 F3A4                    	rep movsb
  4571 000016D5 AA                      	stosb
  4572 000016D6 BB[0000]                	mov bx, scriptspath
  4573 000016D9 38C0                    	cmp al, al				; ZR
  4574                                  @@:
  4575 000016DB 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 000016DC A3[0000]                	mov word [ext_handle], ax
  4586 000016DF 93                      	xchg bx, ax
  4587                                  .boot:
  4588 000016E0 8B3E[0000]              	mov di, word [terminator_in_line_in.offset]
  4589 000016E4 A0[0000]                	mov al, byte [terminator_in_line_in.value]
  4590 000016E7 8805                    	mov byte [di], al
  4591                                  
  4592                                  %if _RECLAIM
  4593 000016E9 53                      	push bx
  4594                                   %if _PM
  4595                                  	call get_es_ext
  4596                                   %else
  4597 000016EA 8E06[0000]              	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 000016EE 31F6                <1> 	xor si, si
     7                              <1> .inner:
     8 000016F0 8B1E[0000]          <1> 	mov bx, [relocated(extdata_used)]
     9                              <1> linkdatarelocation extdata_used
    10 000016F4 031E[0000]          <1> 	add bx, [relocated(extdata)]
    11                              <1> linkdatarelocation extdata
    12 000016F8 3B36[0000]          <1> 	cmp si, [relocated(extseg_used)]
    13                              <1> linkdatarelocation extseg_used		; behind last instance ?
    14 000016FC 735A                <1> 	jae .end			; yes -->
    15 000016FE 263934              <1> 	cmp word [es:si + eldiStartCode], si
    16 00001701 7403E94F03          <1> 	jne .error			; start matches itself ?
    17 00001706 26F6441001          <1> 	testopt [es:si + eldiFlags], eldifResident
    18 0000170B 7539                <1> 	jnz .next			; is free ?
    19 0000170D 268B5406            <1> 	mov dx, word [es:si + eldiEndData]
    20 00001711 89D0                <1> 	mov ax, dx
    21 00001713 262B4404            <1> 	sub ax, word [es:si + eldiStartData]
    22                              <1> 					; = length of block
    23 00001717 7303E93903          <1> 	jc .error			; block must not be negative size -->
    24                              <1> 					; ZR if empty range
    25 0000171C 7506                <1> 	jnz @F				; not empty -->
    26                              <1> 					; special zeroing handling
    27 0000171E 85D2                <1> 	test dx, dx			; is it already zero ?
    28 00001720 7424                <1> 	jz .next			; yes -->
    29 00001722 EB09                <1> 	jmp @FF				; zero it and re-loop outer -->
    30                              <1> @@:
    31 00001724 39DA                <1> 	cmp dx, bx			; end > last data ?
    32 00001726 7603E92A03          <1> 	ja .error			; yes, error -->
    33 0000172B 7519                <1> 	jne .next			; end == last data ?
    34                              <1> @@:					; yes, free it
    35 0000172D 3B06[0000]          <1> 	cmp ax, word [relocated(extdata_used)]
    36                              <1> linkdatarelocation extdata_used
    37 00001731 7603E91F03          <1> 	ja .error
    38 00001736 2906[0000]          <1> 	sub word [relocated(extdata_used)], ax
    39                              <1> linkdatarelocation extdata_used		; subtract size of block (or 0)
    40 0000173A 31C0                <1> 	xor ax, ax
    41 0000173C 26894404            <1> 	mov word [es:si + eldiStartData], ax
    42 00001740 26894406            <1> 	mov word [es:si + eldiEndData], ax
    43                              <1> 					; reset the block data
    44 00001744 EBA8                <1> 	jmp .outer			; restart search for trailing data
    45                              <1> 
    46                              <1> .next:
    47 00001746 89F2                <1> 	mov dx, si
    48 00001748 83C220              <1> 	add dx, ELD_INSTANCE_size
    49 0000174B 268B7402            <1> 	mov si, word [es:si + eldiEndCode]
    50 0000174F 39D6                <1> 	cmp si, dx
    51 00001751 7303E9FF02          <1> 	jb .error
    52 00001756 EB98                <1> 	jmp .inner
    53                              <1> 
    54                              <1> .end:
    55                              <1> 
    56                              <1> 
    57                              <1> loop_free_code:
    58                              <1> .outer:
    59 00001758 BAFFFF              <1> 	mov dx, -1			; remember no candidate
    60 0000175B 31F6                <1> 	xor si, si			; -> start of ext seg
    61                              <1> .inner:
    62 0000175D 3B36[0000]          <1> 	cmp si, [relocated(extseg_used)]
    63                              <1> linkdatarelocation extseg_used		; behind last instance ?
    64 00001761 733D                <1> 	jae .end_inner			; yes -->
    65 00001763 263934              <1> 	cmp word [es:si + eldiStartCode], si
    66 00001766 7403E9EA02          <1> 	jne .error			; start matches itself ?
    67 0000176B 26F6441001          <1> 	testopt [es:si + eldiFlags], eldifResident
    68 00001770 7519                <1> 	jnz .next_not_free		; is free ?
    69 00001772 89F2                <1> 	mov dx, si			; -> candidate free block
    70 00001774 26807C0400          <1> 	cmp byte [es:si + eldiStartData], 0
    71 00001779 750B                <1> 	jne .next_data_used		; is free ?
    72 0000177B 26807C0600          <1> 	cmp byte [es:si + eldiEndData], 0
    73 00001780 7504                <1> 	jne .next_data_used		; is free ?
    74 00001782 31C9                <1> 	xor cx, cx			; remember candidate has no data
    75 00001784 EB08                <1> 	jmp .next
    76                              <1> 
    77                              <1> .next_data_used:
    78 00001786 B90100              <1> 	mov cx, 1			; remember candidate has data
    79 00001789 EB03                <1> 	jmp .next
    80                              <1> 
    81                              <1> .next_not_free:
    82 0000178B BAFFFF              <1> 	mov dx, -1			; remember no candidate (used block)
    83                              <1> .next:
    84 0000178E 89F0                <1> 	mov ax, si
    85 00001790 83C020              <1> 	add ax, ELD_INSTANCE_size
    86 00001793 268B7402            <1> 	mov si, word [es:si + eldiEndCode]
    87 00001797 39C6                <1> 	cmp si, ax
    88 00001799 7303E9B702          <1> 	jb .error
    89 0000179E EBBD                <1> 	jmp .inner
    90                              <1> 
    91                              <1> .end_inner:
    92 000017A0 83FAFF              <1> 	cmp dx, -1			; last ELD instance is free ?
    93 000017A3 742A                <1> 	je .end				; no -->
    94 000017A5 31DB                <1> 	xor bx, bx			; if to not keep ELD instance, = 0
    95 000017A7 E302                <1> 	jcxz .free			; no data ? then use bx = 0 -->
    96 000017A9 B320                <1> 	mov bl, 32			; need to keep ELD instance, = 32
    97                              <1> .free:
    98 000017AB 89D6                <1> 	mov si, dx			; -> instance to free/resize
    99 000017AD 268B4402            <1> 	mov ax, word [es:si + eldiEndCode]
   100 000017B1 3B06[0000]          <1> 	cmp ax, [relocated(extseg_used)] ; validity check
   101                              <1> linkdatarelocation extseg_used
   102 000017B5 7403E99B02          <1> 	jne .error
   103 000017BA 268B14              <1> 	mov dx, word [es:si + eldiStartCode]
   104 000017BD 29D0                <1> 	sub ax, dx			; size of entire instance
   105 000017BF 01DA                <1> 	add dx, bx			; start of instance + how much to keep
   106 000017C1 26895402            <1> 	mov word [es:si + eldiEndCode], dx
   107                              <1> 					; enter into instance's end
   108 000017C5 29D8                <1> 	sub ax, bx			; size to discard
   109 000017C7 2906[0000]          <1> 	sub word [relocated(extseg_used)], ax ; do discard it
   110                              <1> linkdatarelocation extseg_used
   111 000017CB 85DB                <1> 	test bx, bx			; only resized ?
   112 000017CD 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 000017CF 5B                      	pop bx
  4620 000017D0 16                      	 push ss
  4621 000017D1 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 000017D2 55                  <1> 	push bp
    24                              <1> %endif
    25                              <1> 
    26                              <1> %if _ELDTRAILER
    27 000017D3 31C0                <1> 	xor ax, ax
    28 000017D5 A3[0000]            <1> 	mov word [eldheader], ax
    29                              <1> internaldatarelocation
    30 000017D8 A3[0200]            <1> 	mov word [eldheader + 2], ax
    31                              <1> internaldatarelocation
    32                              <1> 
    33 000017DB 91                  <1> 	xchg cx, ax
    34 000017DC B80242              <1> 	mov ax, 4202h
    35 000017DF 31D2                <1> 	xor dx, dx
    36                              <1> %if _BOOTLDR
    37                              <1>  %if _APPLICATION || _DEVICE
    38 000017E1 F606[0100]40        <1> 	testopt [relocated(internalflags)], nodosloaded
    39                              <1> linkdatarelocation internalflags, -3
    40 000017E6 7417                <1> 	jz @F
    41                              <1>  %endif
    42 000017E8 E8(0000)            <1> 	extcallcall yy_boot_seek_start.bx
    43 000017EB 8B0E[F6FF]          <1> 	mov cx, word [load_data - LOADDATA2 + ldFileSize + 2]
    44                              <1> internaldatarelocation
    45 000017EF 8B16[F4FF]          <1> 	mov dx, word [load_data - LOADDATA2 + ldFileSize]
    46                              <1> internaldatarelocation
    47 000017F3 E8(0000)            <1> 	extcallcall yy_boot_seek_current.bx
    48 000017F6 8B16[FEFF]          <1> 	mov dx, word [load_data - LOADDATA2 + ldCurrentSeek + 2]
    49                              <1> internaldatarelocation
    50 000017FA A1[FCFF]            <1> 	mov ax, word [load_data - LOADDATA2 + ldCurrentSeek]
    51                              <1> internaldatarelocation
    52                              <1>  %if _APPLICATION || _DEVICE
    53 000017FD EB02                <1> 	jmp @FF
    54                              <1>  %endif
    55                              <1> %endif
    56                              <1> 
    57                              <1> @@:
    58                              <1> %if _APPLICATION || _DEVICE
    59                              <1> 	doscall
  1497 000017FF CD21                <2>  int 21h
    60                              <1> %endif
    61                              <1> @@:
    62 00001801 7303E95702          <1> 	jc .io_error
    63                              <1> 
    64 00001806 85D2                <1> 	test dx, dx
    65 00001808 7508                <1> 	jnz @F
    66 0000180A 83F830              <1> 	cmp ax, ELD_HEADER_size + ELD_TRAILER_HEADER_size
    67 0000180D 7303E98500          <1> 	jb .no_trailer
    68                              <1> @@:
    69                              <1> 
    70 00001812 B80142              <1> 	mov ax, 4201h
    71 00001815 B9FFFF              <1> 	mov cx, -1
    72 00001818 BAF0FF              <1> 	mov dx, - ELD_TRAILER_HEADER_size
    73                              <1> %if _BOOTLDR
    74                              <1>  %if _APPLICATION || _DEVICE
    75 0000181B F606[0100]40        <1> 	testopt [relocated(internalflags)], nodosloaded
    76                              <1> linkdatarelocation internalflags, -3
    77 00001820 740C                <1> 	jz @F
    78                              <1>  %endif
    79 00001822 E8(0000)            <1> 	extcallcall yy_boot_seek_current.bx
    80 00001825 8B16[FEFF]          <1> 	mov dx, word [load_data - LOADDATA2 + ldCurrentSeek + 2]
    81                              <1> internaldatarelocation
    82 00001829 A1[FCFF]            <1> 	mov ax, word [load_data - LOADDATA2 + ldCurrentSeek]
    83                              <1> internaldatarelocation
    84                              <1>  %if _APPLICATION || _DEVICE
    85 0000182C EB02                <1> 	jmp @FF
    86                              <1>  %endif
    87                              <1> %endif
    88                              <1> 
    89                              <1> @@:
    90                              <1> %if _APPLICATION || _DEVICE
    91                              <1> 	doscall
  1497 0000182E CD21                <2>  int 21h
    92                              <1> %endif
    93                              <1> @@:
    94 00001830 7303E92802          <1> 	jc .io_error
    95                              <1> 
    96 00001835 52                  <1> 	push dx
    97 00001836 50                  <1> 	push ax
    98                              <1> 
    99 00001837 B91000              <1> 	mov cx, fromwords(ELD_TRAILER_HEADER_size_w)
   100 0000183A 29CC                <1> 	sub sp, cx
   101 0000183C 89E2                <1> 	mov dx, sp
   102                              <1> 
   103 0000183E B43F                <1> 	mov ah, 3Fh
   104                              <1> %if _BOOTLDR
   105                              <1>  %if _APPLICATION || _DEVICE
   106 00001840 F606[0100]40        <1> 	testopt [relocated(internalflags)], nodosloaded
   107                              <1> linkdatarelocation internalflags, -3
   108 00001845 7405                <1> 	jz @F
   109                              <1>  %endif
   110 00001847 E8(0000)            <1> 	extcallcall yy_boot_read.bx
   111                              <1>  %if _APPLICATION || _DEVICE
   112 0000184A EB02                <1> 	jmp @FF
   113                              <1>  %endif
   114                              <1> %endif
   115                              <1> 
   116                              <1> @@:
   117                              <1> %if _APPLICATION || _DEVICE
   118                              <1> 	doscall
  1497 0000184C CD21                <2>  int 21h
   119                              <1> %endif
   120                              <1> @@:
   121 0000184E 7303E90A02          <1> 	jc .io_error
   122 00001853 89E7                <1> 	mov di, sp
   123 00001855 89E6                <1> 	mov si, sp
   124                              <1> 
   125 00001857 39C8                <1> 	cmp ax, cx
   126 00001859 7539                <1> 	jne .no_trailer_pop
   127                              <1> 
   128 0000185B 31D2                <1> 	xor dx, dx
   129 0000185D D1E9                <1> 	shr cx, 1
   130                              <1> @@:
   131 0000185F AD                  <1> 	lodsw
   132 00001860 01C2                <1> 	add dx, ax
   133 00001862 E2FB                <1> 	loop @B
   134 00001864 752E                <1> 	jnz .no_trailer_pop
   135                              <1> 
   136 00001866 58                  <1> 	pop ax
   137 00001867 3D454C              <1> 	cmp ax, "EL"
   138 0000186A 7528                <1> 	jne .no_trailer_pop
   139 0000186C 58                  <1> 	pop ax
   140 0000186D 3D4431              <1> 	cmp ax, "D1"
   141 00001870 7522                <1> 	jne .no_trailer_pop
   142 00001872 58                  <1> 	pop ax
   143 00001873 3D5441              <1> 	cmp ax, "TA"
   144 00001876 751C                <1> 	jne .no_trailer_pop
   145 00001878 58                  <1> 	pop ax
   146 00001879 3D494C              <1> 	cmp ax, "IL"
   147 0000187C 7516                <1> 	jne .no_trailer_pop
   148                              <1> 
   149 0000187E 5E                  <1> 	pop si
   150 0000187F 59                  <1> 	pop cx			; cx:si = displacement to subtract
   151 00001880 58                  <1> 	pop ax			; reserved
   152 00001881 58                  <1> 	pop ax			; checksum
   153                              <1> 
   154 00001882 58                  <1> 	pop ax
   155 00001883 5A                  <1> 	pop dx			; dx:ax = offset of trailer header
   156 00001884 01F0                <1> 	add ax, si
   157 00001886 11CA                <1> 	adc dx, cx		; dx:ax = offset of header
   158 00001888 7203E9D001          <1> 	jnc .io_error
   159                              <1> 
   160 0000188D A3[0000]            <1> 	mov word [eldheader], ax
   161                              <1> internaldatarelocation
   162 00001890 8916[0200]          <1> 	mov word [eldheader + 2], dx
   163                              <1> internaldatarelocation
   164                              <1> 
   165                              <1> .no_trailer_pop:
   166 00001894 8D6514              <1> 	lea sp, [di + fromwords(ELD_TRAILER_HEADER_size_w) + 4]
   167                              <1> 
   168                              <1> .no_trailer:
   169 00001897 B80042              <1> 	mov ax, 4200h
   170 0000189A 8B16[0000]          <1> 	mov dx, word [eldheader]
   171                              <1> internaldatarelocation
   172 0000189E 8B0E[0200]          <1> 	mov cx, word [eldheader + 2]
   173                              <1> internaldatarelocation
   174                              <1> 
   175                              <1> %if _BOOTLDR
   176                              <1>  %if _APPLICATION || _DEVICE
   177 000018A2 F606[0100]40        <1> 	testopt [relocated(internalflags)], nodosloaded
   178                              <1> linkdatarelocation internalflags, -3
   179 000018A7 7408                <1> 	jz @F
   180                              <1>  %endif
   181 000018A9 E8(0000)            <1> 	extcallcall yy_boot_seek_start.bx
   182 000018AC E8(0000)            <1> 	extcallcall yy_boot_seek_current.bx
   183                              <1>  %if _APPLICATION || _DEVICE
   184 000018AF EB02                <1> 	jmp @FF
   185                              <1>  %endif
   186                              <1> %endif
   187                              <1> 
   188                              <1> @@:
   189                              <1> %if _APPLICATION || _DEVICE
   190                              <1> 	doscall
  1497 000018B1 CD21                <2>  int 21h
   191                              <1> %endif
   192                              <1> @@:
   193 000018B3 7303E9A501          <1> 	jc .io_error
   194                              <1> %endif
   195                              <1> 
   196 000018B8 B92000              <1> 	mov cx, fromwords(ELD_HEADER_size_w)
   197 000018BB 29CC                <1> 	sub sp, cx
   198 000018BD 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 000018BF B43F                <1> 	mov ah, 3Fh
   215                              <1> %if _BOOTLDR
   216                              <1>  %if _APPLICATION || _DEVICE
   217 000018C1 F606[0100]40        <1> 	testopt [relocated(internalflags)], nodosloaded
   218                              <1> linkdatarelocation internalflags, -3
   219 000018C6 7405                <1> 	jz @F
   220                              <1>  %endif
   221 000018C8 E8(0000)            <1> 	extcallcall yy_boot_read.bx
   222                              <1>  %if _APPLICATION || _DEVICE
   223 000018CB EB02                <1> 	jmp @FF
   224                              <1>  %endif
   225                              <1> %endif
   226                              <1> 
   227                              <1> @@:
   228                              <1> %if _APPLICATION || _DEVICE
   229                              <1> 	doscall
  1497 000018CD CD21                <2>  int 21h
   230                              <1> %endif
   231                              <1> @@:
   232                              <1> %endif
   233 000018CF 7303E98901          <1> 	jc .io_error
   234 000018D4 39C8                <1> 	cmp ax, cx
   235 000018D6 7403E98A01          <1> 	jne .invalid
   236                              <1> 
   237 000018DB 89E7                <1> 	mov di, sp
   238                              <1> 
   239 000018DD 58                  <1> 	pop ax
   240 000018DE 3D454C              <1> 	cmp ax, "EL"
   241 000018E1 7403E97F01          <1> 	jne .invalid
   242 000018E6 58                  <1> 	pop ax
   243 000018E7 3D4431              <1> 	cmp ax, "D1"
   244 000018EA 7403E97601          <1> 	jne .invalid
   245 000018EF 58                  <1> 	pop ax
   246 000018F0 58                  <1> 	pop ax
   247 000018F1 80FC1A              <1> 	cmp ah, 26
   248 000018F4 7403E96C01          <1> 	jne .invalid
   249                              <1> 
   250                              <1> %ifn ELD
   251 000018F9 F606[0300]08        <1> 	testopt [internalflags3], dif3_in_if
   252 000018FE 7403E9(0000)        <1> 	jnz if_exists_found_ext_open
   253                              <1> %endif
   254                              <1> 
   255 00001903 A1[0000]            <1> 	mov ax, word [relocated(extseg_size)]
   256                              <1> linkdatarelocation extseg_size
   257 00001906 2B06[0000]          <1> 	sub ax, word [relocated(extseg_used)]
   258                              <1> linkdatarelocation extseg_used
   259 0000190A 7303E94601          <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 0000190F 8B4D0C              <1> 	mov cx, word [di + eldhCodeImageLength]
   266                              <1> %if ELD
   267                              <1> 	cmp ax, cx
   268                              <1> 	jb .oom
   269                              <1> %endif
   270 00001912 034D0E              <1> 	add cx, word [di + eldhCodeAllocLength]
   271 00001915 7227                <1> 	jc .invalid_CY
   272 00001917 83C10F              <1> 	add cx, 15
   273 0000191A 7222                <1> 	jc .invalid_CY
   274 0000191C 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 0000191F 39C8                <1> 	cmp ax, cx
   283 00001921 7303E95101          <1> 	jb .oom
   284                              <1> 
   285 00001926 8B16[0000]          <1> 	mov dx, word [relocated(extdata_size)]
   286                              <1> linkdatarelocation extdata_size
   287 0000192A 2B16[0000]          <1> 	sub dx, word [relocated(extdata_used)]
   288                              <1> linkdatarelocation extdata_used
   289 0000192E 7303E92201          <1> 	jc .error_internal
   290                              <1> 
   291 00001933 8B7514              <1> 	mov si, word [di + eldhDataImageLength]
   292                              <1> %if ELD
   293                              <1> 	cmp dx, si
   294                              <1> 	jb .oom
   295                              <1> %endif
   296 00001936 037516              <1> 	add si, word [di + eldhDataAllocLength]
   297 00001939 7203                <1> 	jc .invalid_CY
   298 0000193B 83C60F              <1> 	add si, 15
   299                              <1> .invalid_CY:
   300 0000193E 7303E92201          <1> 	jc .invalid
   301 00001943 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 00001946 39F2                <1> 	cmp dx, si
   310 00001948 7303E92A01          <1> 	jb .oom
   311                              <1> 
   312 0000194D 56                  <1> 	push si
   313 0000194E 51                  <1> 	push cx
   314                              <1> 
   315 0000194F B80042              <1> 	mov ax, 4200h
   316 00001952 8B4D0A              <1> 	mov cx, word [di + eldhCodeOffset + 2]
   317 00001955 8B5508              <1> 	mov dx, word [di + eldhCodeOffset]
   318                              <1> %if ELD || _ELDTRAILER
   319 00001958 0316[0000]          <1> 	add dx, word [eldheader]
   320                              <1> internaldatarelocation
   321 0000195C 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 00001960 F606[0100]40        <1> 	testopt [relocated(internalflags)], nodosloaded
   337                              <1> linkdatarelocation internalflags, -3
   338 00001965 7408                <1> 	jz @F
   339                              <1>  %endif
   340 00001967 E8(0000)            <1> 	extcallcall yy_boot_seek_start.bx
   341 0000196A E8(0000)            <1> 	extcallcall yy_boot_seek_current.bx
   342                              <1>  %if _APPLICATION || _DEVICE
   343 0000196D EB02                <1> 	jmp @FF
   344                              <1>  %endif
   345                              <1> %endif
   346                              <1> 
   347                              <1> @@:
   348                              <1> %if _APPLICATION || _DEVICE
   349                              <1> 	doscall
  1497 0000196F CD21                <2>  int 21h
   350                              <1> %endif
   351                              <1> @@:
   352                              <1> %endif
   353 00001971 7303E9E700          <1> 	jc .io_error
   354                              <1> 
   355 00001976 8B16[0000]          <1> 	mov dx, word [relocated(extseg_used)]
   356                              <1> linkdatarelocation extseg_used
   357                              <1> %if _PM
   358                              <1> 	extcallcall ispm
   359                              <1> 	jnz @F
   360                              <1> 	mov ds, word [relocated(extdssel)]
   361                              <1> linkdatarelocation extdssel
   362                              <1> 	jmp @FF
   363                              <1> 
   364                              <1> @@:
   365                              <1> %endif
   366 0000197A 8E1E[0000]          <1> 	mov ds, word [relocated(extseg)]
   367                              <1> linkdatarelocation extseg
   368                              <1> @@:
   369 0000197E 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 00001982 B43F                <1> 	mov ah, 3Fh
   383                              <1> %if _BOOTLDR
   384                              <1>  %if _APPLICATION || _DEVICE
   385 00001984 36F606[0100]40      <1> 	testopt [ss:relocated(internalflags)], nodosloaded
   386                              <1> linkdatarelocation internalflags, -3
   387 0000198A 740B                <1> 	jz @F
   388                              <1>  %endif
   389 0000198C 1E                  <1> 	push ds
   390 0000198D 07                  <1> 	pop es
   391 0000198E 16                  <1> 	push ss
   392 0000198F 1F                  <1> 	pop ds
   393 00001990 E8(0000)            <1> 	extcallcall yy_boot_read.bx
   394 00001993 16                  <1> 	push ss
   395 00001994 07                  <1> 	pop es
   396                              <1>  %if _APPLICATION || _DEVICE
   397 00001995 EB02                <1> 	jmp @FF
   398                              <1>  %endif
   399                              <1> %endif
   400                              <1> 
   401                              <1> @@:
   402                              <1> %if _APPLICATION || _DEVICE
   403                              <1> %if _PM
   404                              <1> 	extcallcall doscall_extseg
   405                              <1> %else
   406                              <1> 	doscall
  1497 00001997 CD21                <2>  int 21h
   407                              <1> %endif
   408                              <1> %endif
   409                              <1> @@:
   410                              <1> %endif
   411 00001999 16                  <1> 	 push ss
   412 0000199A 1F                  <1> 	 pop ds
   413 0000199B 7303E9BD00          <1> 	jc .io_error
   414 000019A0 39C1                <1> 	cmp cx, ax
   415 000019A2 7403E9B600          <1> 	jne .io_error
   416                              <1> 
   417 000019A7 B80042              <1> 	mov ax, 4200h
   418 000019AA 8B4D12              <1> 	mov cx, word [di + eldhDataOffset + 2]
   419 000019AD 8B5510              <1> 	mov dx, word [di + eldhDataOffset]
   420                              <1> %if ELD || _ELDTRAILER
   421 000019B0 0316[0000]          <1> 	add dx, word [eldheader]
   422                              <1> internaldatarelocation
   423 000019B4 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 000019B8 F606[0100]40        <1> 	testopt [relocated(internalflags)], nodosloaded
   440                              <1> linkdatarelocation internalflags, -3
   441 000019BD 7408                <1> 	jz @F
   442                              <1>  %endif
   443 000019BF E8(0000)            <1> 	extcallcall yy_boot_seek_start.bx
   444 000019C2 E8(0000)            <1> 	extcallcall yy_boot_seek_current.bx
   445                              <1>  %if _APPLICATION || _DEVICE
   446 000019C5 EB02                <1> 	jmp @FF
   447                              <1>  %endif
   448                              <1> %endif
   449                              <1> 
   450                              <1> @@:
   451                              <1> %if _APPLICATION || _DEVICE
   452                              <1> 	doscall
  1497 000019C7 CD21                <2>  int 21h
   453                              <1> %endif
   454                              <1> @@:
   455                              <1> %endif
   456 000019C9 7303E98F00          <1> 	jc .io_error
   457                              <1> 
   458                              <1> %if ELD
   459                              <1> 	mov dx, word [relocateddata]
   460                              <1> linkdatarelocation extdata
   461                              <1> %else
   462 000019CE BA[0000]            <1> 	mov dx, ext_data_area
   463                              <1> %endif
   464 000019D1 0316[0000]          <1> 	add dx, word [relocated(extdata_used)]
   465                              <1> linkdatarelocation extdata_used
   466 000019D5 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 000019D8 B43F                <1> 	mov ah, 3Fh
   474                              <1> %if _BOOTLDR
   475                              <1>  %if _APPLICATION || _DEVICE
   476 000019DA F606[0100]40        <1> 	testopt [relocated(internalflags)], nodosloaded
   477                              <1> linkdatarelocation internalflags, -3
   478 000019DF 7405                <1> 	jz @F
   479                              <1>  %endif
   480 000019E1 E8(0000)            <1> 	extcallcall yy_boot_read.bx
   481                              <1>  %if _APPLICATION || _DEVICE
   482 000019E4 EB02                <1> 	jmp @FF
   483                              <1>  %endif
   484                              <1> %endif
   485                              <1> 
   486                              <1> @@:
   487                              <1> %if _APPLICATION || _DEVICE
   488                              <1> 	doscall
  1497 000019E6 CD21                <2>  int 21h
   489                              <1> %endif
   490                              <1> @@:
   491                              <1> %endif
   492 000019E8 7273                <1> 	jc .io_error
   493 000019EA 39C1                <1> 	cmp cx, ax
   494 000019EC 756F                <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                              <1> 	call get_es_ext
   502                              <1> %else
   503 000019EE 8E06[0000]          <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 000019F2 58                  <1> 	pop ax				; allocated code size
   588 000019F3 8B16[0000]          <1> 	mov dx, word [extseg_used]
   589 000019F7 89D5                <1> 	mov bp, dx
   590 000019F9 26895600            <1> 	mov word [es:bp+eldiStartCode], dx
   591                              <1> 					; -> loaded code
   592 000019FD 0306[0000]          <1> 	add ax, word [extseg_used]
   593 00001A01 A3[0000]            <1> 	mov word [extseg_used], ax	; -> behind
   594 00001A04 26894602            <1> 	mov word [es:bp+eldiEndCode], ax; -> behind
   595                              <1> 
   596 00001A08 58                  <1> 	pop ax				; allocated data size
   597 00001A09 8B1E[0000]          <1> 	mov bx, word [extdata_used]
   598 00001A0D 81C3[0000]          <1> 	add bx, ext_data_area		; -> loaded data
   599 00001A11 26895E04            <1> 	mov word [es:bp+eldiStartData], bx
   600 00001A15 0106[0000]          <1> 	add word [extdata_used], ax	; = amount new used
   601 00001A19 01D8                <1> 	add ax, bx			; -> behind
   602 00001A1B 26894606            <1> 	mov word [es:bp+eldiEndData], ax
   603                              <1> 
   604 00001A1F 8B4D18              <1> 	mov cx, [di + eldhCodeEntrypoint]
   605 00001A22 01D1                <1> 	add cx, dx
   606                              <1> %endif
   607 00001A24 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 00001A27 5D                  <1> 	pop bp
   641                              <1> 
   642 00001A28 8B36[0000]          <1> 	mov si, word [ext_cmdline]
   643                              <1> 
   644                              <1> %if _MESSAGESEGMENT
   645                              <1>  %if _PM
   646                              <1> 	call get_messagesegsel
   647                              <1>  %else
   648 00001A2C 368E1E[0000]        <1>  	mov ds, word [ss:messageseg]
   649                              <1>  %endif
   650                              <1> %endif
   651 00001A31 BF[0000]            <1> 	mov di, linkinfo
   652                              <1> 
   653 00001A34 0E                  <1> 	push cs
   654 00001A35 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 00001A38 3D00FF                  	cmp ax, 0FF00h
  4652 00001A3B 7215                    	jb @F
  4653 00001A3D 16                      	push ss
  4654 00001A3E 07                      	pop es
  4655 00001A3F 16                      	push ss
  4656 00001A40 1F                      	pop ds
  4657 00001A41 BF[0000]                	mov di, msg.eld_error_code
  4658 00001A44 E824E7                  	call hexword
  4659 00001A47 B40F                    	mov ah, 0Fh
  4660 00001A49 E8(0000)                	call setrc
  4661 00001A4C BA[0000]                	mov dx, msg.eld_load_error
  4662 00001A4F E8ABEC                  	call putsz_error
  4663                                  @@:
  4664 00001A52 E9(0000)                	jmp cmd3
  4665                                  
  4666                                  
  4667                                  .error_internal:
  4668 00001A55 BA[0000]                	mov dx, msg.ext_error_internal
  4669 00001A58 B82C01                  	mov ax, 012Ch
  4670 00001A5B EB20                    	jmp .specificerror
  4671                                  
  4672                                  .io_error:
  4673 00001A5D BA[0000]                	mov dx, msg.ext_error_io
  4674 00001A60 B82D01                  	mov ax, 012Dh
  4675 00001A63 EB06                    	jmp .specificerror_or_if
  4676                                  
  4677                                  .invalid:
  4678 00001A65 BA[0000]                	mov dx, msg.ext_error_invalid
  4679 00001A68 B82E01                  	mov ax, 012Eh
  4680                                  .specificerror_or_if:
  4681 00001A6B F606[0300]08            	testopt [internalflags3], dif3_in_if
  4682 00001A70 7403E9(0000)            	jnz if_exists_not_found
  4683 00001A75 EB06                    	jmp .specificerror
  4684                                  
  4685                                  .oom:
  4686 00001A77 BA[0000]                	mov dx, msg.ext_error_oom
  4687 00001A7A B82F01                  	mov ax, 012Fh
  4688                                  
  4689                                  .specificerror:
  4690 00001A7D 16                      	push ss
  4691 00001A7E 1F                      	pop ds
  4692 00001A7F E8(0000)                	call setrc
  4693 00001A82 E878EC                  	call putsz_error
  4694 00001A85 FF26[0000]              	jmp [errret]
  4695                                  
  4696                                  
  4697                                  .transfer:
  4698                                  transfer_ext_cx_NC:
  4699 00001A89 F8                      	clc
  4700                                  
  4701                                  transfer_ext_cx:
  4702                                  %if _PM
  4703                                  	push di
  4704                                  	mov di, word [ss:pm_2_86m_0]
  4705                                  	jmp near word [ss:.table + di]
  4706                                  
  4707                                  .pm:
  4708                                  	pop di
  4709                                  	push word [ss:extcssel]		; => code
  4710                                  	push cx				; -> entrypoint
  4711                                  	retf
  4712                                  
  4713                                  .86m:
  4714                                  	pop di
  4715                                  %endif
  4716 00001A8A 36FF36[0000]            	push word [ss:extseg]		; => code
  4717 00001A8F 51                      	push cx				; -> entrypoint
  4718 00001A90 CB                      	retf
  4719                                  
  4720                                  %if _PM
  4721                                  	usesection lDEBUG_DATA_ENTRY
  4722                                  		; REM:	Dispatch table in section lDEBUG_CODE
  4723                                  	align 2, db 0
  4724                                  .table:
  4725                                  	dw .86m
  4726                                  	dw .pm
  4727                                  
  4728                                  
  4729                                  	usesection lDEBUG_CODE
  4730                                  get_es_ext:
  4731                                  	mov es, word [extdssel]
  4732                                  	call ispm
  4733                                  	jz .ret
  4734                                  	mov es, word [extseg]
  4735                                  .ret:
  4736                                  	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 00001A91 51                      	push cx
  4752                                  %if _NEWFULLHANDLING
  4753 00001A92 B9[0300]                	mov cx, line_in + 3
  4754                                  %else
  4755                                  	mov cx, line_in + 2
  4756                                  %endif
  4757 00001A95 870E[0000]              	xchg cx, word [bufnext]
  4758 00001A99 F7D9                    	neg cx
  4759 00001A9B 030E[0000]              	add cx, word [bufend]	; cx = how much remaining in buffer
  4760                                  %if _NEWFULLHANDLING
  4761 00001A9F C706[0000][0300]        	mov word [bufend], line_in + 3
  4762                                  %else
  4763                                  	mov word [bufend], line_in + 2
  4764                                  %endif
  4765                                  
  4766 00001AA5 F606[0200]40            	testopt [internalflags2], dif2_did_getline_file
  4767 00001AAA 7469                    	jz .not_used
  4768                                  
  4769 00001AAC 50                      	push ax
  4770 00001AAD 52                      	push dx
  4771 00001AAE 53                      	push bx
  4772 00001AAF 89CA                    	mov dx, cx
  4773 00001AB1 31C9                    	xor cx, cx
  4774 00001AB3 F7DA                    	neg dx			; dx = minus how much remaining
  4775 00001AB5 7456                    	jz .done		; if zero, do not seek at all -->
  4776 00001AB7 49                      	dec cx			; sign extension into cx:dx
  4777                                  
  4778                                  %if !_LOADER
  4779 00001AB8 F606[0300]01            	testopt [internalflags3], dif3_input_re
  4780 00001ABD 7406                    	jz @F
  4781 00001ABF 0116[0000]              	add word [re_buffer.position], dx
  4782 00001AC3 EB48                    	jmp .done
  4783                                  @@:
  4784                                  %endif
  4785                                  
  4786                                  %if _INPUT_FILE_BOOT
  4787 00001AC5 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  4788 00001ACA 741E                    	jz @F
  4789 00001ACC F606[0300]30            	testopt [internalflags3], dif3_auxbuff_guarded_1 | dif3_auxbuff_guarded_2
  4790 00001AD1 7412                    	jz .do_boot_seek
  4791                                  
  4792 00001AD3 FF36[0000]              	push word [load_input_file.active]
  4793 00001AD7 8F06[0000]              	pop word [boot_remember_seek_handle]
  4794 00001ADB 890E[0200]              	mov word [boot_remember_seek_offset + 2], cx
  4795 00001ADF 8916[0000]              	mov word [boot_remember_seek_offset], dx
  4796 00001AE3 EB28                    	jmp .done
  4797                                  
  4798                                  .do_boot_seek:
  4799 00001AE5 E8(0000)                	call yy_boot_seek_current
  4800 00001AE8 EB23                    	jmp .done
  4801                                  @@:
  4802                                  %endif
  4803                                  
  4804                                  %if _INPUT_FILE_HANDLES
  4805 00001AEA F606[0200]10            	testopt [internalflags2], dif2_input_file
  4806 00001AEF 7407                    	jz @F			; if not input file -->
  4807 00001AF1 57                      	push di
  4808 00001AF2 E85DEE                  	call yy_get_handle	; bx = handle
  4809 00001AF5 5F                      	pop di
  4810 00001AF6 EB0F                    	jmp .filehandle
  4811                                  @@:
  4812                                  %endif
  4813                                  
  4814 00001AF8 F606[0100]01            	testopt [internalflags3], dif3_input_cmdline
  4815 00001AFD 7406                    	jz @F
  4816 00001AFF 0116[0000]              	add word [cmdline_buffer.position], dx
  4817 00001B03 EB08                    	jmp .done
  4818                                  @@:
  4819                                  
  4820 00001B05 31DB                    	xor bx, bx		; bx = handle (0 is STDIN)
  4821                                  .filehandle:
  4822 00001B07 B80142                  	mov ax, 4201h		; lseek, from current file position
  4823 00001B0A E80A00                  	call handle_seek_or_remember
  4824                                  
  4825                                  .done:
  4826 00001B0D 5B                      	pop bx
  4827 00001B0E 5A                      	pop dx
  4828 00001B0F 58                      	pop ax
  4829                                  
  4830 00001B10 8026[0200]BF            	clropt [internalflags2], dif2_did_getline_file
  4831                                  
  4832                                  .not_used:
  4833 00001B15 59                      	pop cx
  4834 00001B16 C3                      	retn
  4835                                  
  4836                                  
  4837                                  handle_seek_or_remember:
  4838 00001B17 E8(0000)                	call InDOS
  4839 00001B1A 7411                    	jz @F
  4840                                  
  4841 00001B1C A3[0000]                	mov word [indos_remember_seek_function], ax
  4842 00001B1F 891E[0000]              	mov word [indos_remember_seek_handle], bx
  4843 00001B23 890E[0200]              	mov word [indos_remember_seek_offset + 2], cx
  4844 00001B27 8916[0000]              	mov word [indos_remember_seek_offset], dx
  4845 00001B2B EB02                    	jmp .done
  4846                                  
  4847                                  @@:
  4848                                  	doscall			; call DOS
  1497 00001B2D CD21                <1>  int 21h
  4849                                  .done:
  4850 00001B2F C3                      	retn
  4851                                  
  4852                                  
  4853                                  yy_reset_buf_and_seek_start:
  4854 00001B30 51                      	push cx
  4855 00001B31 50                      	push ax
  4856 00001B32 52                      	push dx
  4857 00001B33 53                      	push bx
  4858                                  %if _NEWFULLHANDLING
  4859 00001B34 B8[0300]                	mov ax, line_in + 3
  4860                                  %else
  4861                                  	mov ax, line_in + 2
  4862                                  %endif
  4863 00001B37 A3[0000]                	mov word [bufnext], ax
  4864 00001B3A A3[0000]                	mov word [bufend], ax
  4865                                  
  4866 00001B3D 31D2                    	xor dx, dx
  4867 00001B3F 31C9                    	xor cx, cx
  4868                                  
  4869                                  %if !_LOADER
  4870 00001B41 F606[0300]01            	testopt [internalflags3], dif3_input_re
  4871 00001B46 7408                    	jz @F
  4872 00001B48 C706[0000][0000]        	mov word [re_buffer.position], re_buffer
  4873 00001B4E EB37                    	jmp .done
  4874                                  @@:
  4875                                  %endif
  4876                                  
  4877                                  %if _INPUT_FILE_BOOT
  4878 00001B50 F606[0300]02            	testopt [internalflags2], dif2_input_file_boot
  4879 00001B55 7408                    	jz @F
  4880 00001B57 E8(0000)                	call yy_boot_clear_remember_seek
  4881 00001B5A E8(0000)                	call yy_boot_seek_start
  4882 00001B5D EB28                    	jmp .done
  4883                                  @@:
  4884                                  %endif
  4885                                  
  4886                                  %if _INPUT_FILE_HANDLES
  4887 00001B5F F606[0200]10            	testopt [internalflags2], dif2_input_file
  4888 00001B64 7407                    	jz @F			; if not input file -->
  4889 00001B66 57                      	push di
  4890 00001B67 E8E8ED                  	call yy_get_handle	; bx = handle
  4891 00001B6A 5F                      	pop di
  4892 00001B6B EB11                    	jmp .filehandle
  4893                                  @@:
  4894                                  %endif
  4895                                  
  4896 00001B6D F606[0100]01            	testopt [internalflags3], dif3_input_cmdline
  4897 00001B72 7408                    	jz @F
  4898 00001B74 C706[0000][0000]        	mov word [cmdline_buffer.position], cmdline_buffer
  4899 00001B7A EB0B                    	jmp .done
  4900                                  @@:
  4901                                  
  4902 00001B7C 31DB                    	xor bx, bx		; bx = handle (0 is STDIN)
  4903                                  
  4904                                  .filehandle:
  4905 00001B7E E80B00                  	call yy_clear_remember_seek
  4906 00001B81 B80042                  	mov ax, 4200h		; seek from start
  4907 00001B84 E890FF                  	call handle_seek_or_remember
  4908                                  .done:
  4909 00001B87 5B                      	pop bx
  4910 00001B88 5A                      	pop dx
  4911 00001B89 58                      	pop ax
  4912 00001B8A 59                      	pop cx
  4913 00001B8B C3                      	retn
  4914                                  
  4915                                  
  4916                                  yy_clear_remember_seek:
  4917 00001B8C 391E[0000]              	cmp word [indos_remember_seek_handle], bx
  4918 00001B90 7515                    	jne .ret
  4919                                  .clear:
  4920 00001B92 C706[0000]0142          	mov word [indos_remember_seek_function], 4201h
  4921 00001B98 830E[0000]FF            	or word [indos_remember_seek_handle], -1
  4922 00001B9D 8326[0200]00            	and word [indos_remember_seek_offset + 2], 0
  4923 00001BA2 8326[0000]00            	and word [indos_remember_seek_offset], 0
  4924                                  .ret:
  4925 00001BA7 C3                      	retn
  4926                                  
  4927                                  
  4928                                  yy_remember_seek:
  4929 00001BA8 391E[0000]              	cmp word [indos_remember_seek_handle], bx
  4930 00001BAC 75F9                    	jne yy_clear_remember_seek.ret
  4931                                  
  4932 00001BAE 50                      	push ax
  4933 00001BAF 51                      	push cx
  4934 00001BB0 52                      	push dx
  4935 00001BB1 8B0E[0200]              	mov cx, word [indos_remember_seek_offset + 2]
  4936 00001BB5 8B16[0000]              	mov dx, word [indos_remember_seek_offset]
  4937 00001BB9 A1[0000]                	mov ax, word [indos_remember_seek_function]
  4938                                  	doscall			; call DOS
  1497 00001BBC CD21                <1>  int 21h
  4939 00001BBE 5A                      	pop dx
  4940 00001BBF 59                      	pop cx
  4941 00001BC0 58                      	pop ax
  4942 00001BC1 EBCF                    	jmp yy_clear_remember_seek.clear
  4943                                  
  4944                                  
  4945                                  cmd_goto:
  4946 00001BC3 E8DFE4                  	call skipwhite
  4947 00001BC6 3C3A                    	cmp al, ':'
  4948 00001BC8 7503                    	jne @F
  4949 00001BCA E8D8E4                  	call skipwhite
  4950                                  @@:
  4951                                  
  4952 00001BCD E8FAF0                  	call getline_is_input_file?
  4953 00001BD0 7312                    	jnc @F
  4954 00001BD2 BA[0000]                	mov dx, msg.goto_not_file
  4955 00001BD5 B80003                  	mov ax, 0300h
  4956 00001BD8 E8(0000)                	call setrc
  4957                                  .error:
  4958 00001BDB B8FF03                  	mov ax, 03FFh
  4959 00001BDE E8(0000)                	call setrc
  4960 00001BE1 E919EB                  	jmp putsz_error
  4961                                  
  4962                                  @@:
  4963 00001BE4 4E                      	dec si
  4964                                  .yy_entry:		; si -> destination label
  4965 00001BE5 BA[0000]                	mov dx, msg.sof
  4966 00001BE8 E815E4                  	call isstring?
  4967 00001BEB 751B                    	jne @F
  4968 00001BED E886E4                  	call skipcomma
  4969                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  4970 00001BF0 8936[0000]              	mov word [if_exists_then_address], si
  4971                                  %endif
  4972 00001BF4 E8B9E4                  	call chkeol_or_then
  4973 00001BF7 E8D700                  	call resetrc
  4974 00001BFA E833FF                  	call yy_reset_buf_and_seek_start
  4975                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  4976 00001BFD F606[0300]08            	testopt [internalflags3], dif3_in_if
  4977 00001C02 7403E9(0000)            	jnz if_exists_found_open
  4978                                  %endif
  4979 00001C07 C3                      	retn
  4980                                  
  4981                                  @@:
  4982 00001C08 BA[0000]                	mov dx, msg.eof
  4983 00001C0B E8F2E3                  	call isstring?
  4984 00001C0E 751B                    	jne @F
  4985 00001C10 E863E4                  	call skipcomma
  4986                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  4987 00001C13 8936[0000]              	mov word [if_exists_then_address], si
  4988                                  %endif
  4989 00001C17 E896E4                  	call chkeol_or_then
  4990 00001C1A E8B400                  	call resetrc
  4991 00001C1D E8E3F0                  	call getline_close_file
  4992                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  4993 00001C20 F606[0300]08            	testopt [internalflags3], dif3_in_if
  4994 00001C25 7403E9(0000)            	jnz if_exists_found_closed
  4995                                  %endif
  4996 00001C2A C3                      	retn
  4997                                  
  4998                                  @@:
  4999 00001C2B 89F3                    	mov bx, si
  5000 00001C2D B9FFFF                  	mov cx, -1
  5001                                  .loop:
  5002 00001C30 41                      	inc cx
  5003 00001C31 AC                      	lodsb
  5004 00001C32 3C20                    	cmp al, 32
  5005 00001C34 7409                    	je .end
  5006 00001C36 3C09                    	cmp al, 9
  5007 00001C38 7405                    	je .end
  5008 00001C3A E82EE4                  	call iseol?
  5009 00001C3D 75F1                    	jne .loop
  5010                                  .end:
  5011 00001C3F C644FF00                	mov byte [si - 1], 0	; terminate
  5012 00001C43 E831E4                  	call skipcomm0
  5013                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  5014 00001C46 8936[0000]              	mov word [if_exists_then_address], si
  5015                                  %endif
  5016 00001C4A E863E4                  	call chkeol_or_then
  5017 00001C4D E376                    	jcxz .empty
  5018 00001C4F 41                      	inc cx			; space for zero terminator
  5019 00001C50 41                      	inc cx			; round up
  5020 00001C51 80E1FE                  	and cl, ~1		; align to word
  5021 00001C54 89E5                    	mov bp, sp
  5022 00001C56 29CC                    	sub sp, cx		; allocate stack space
  5023 00001C58 89DE                    	mov si, bx		; -> label in line_in
  5024 00001C5A 89E7                    	mov di, sp		; -> buffer on stack
  5025 00001C5C 57                      	push di
  5026                                  @@:
  5027 00001C5D AC                      	lodsb
  5028 00001C5E E8EEE3                  	call capitalise		; normalise the name in buffer
  5029 00001C61 AA                      	stosb
  5030 00001C62 E2F9                    	loop @B			; copy all or all+1
  5031                                  
  5032 00001C64 E8C9FE                  	call yy_reset_buf_and_seek_start
  5033                                  
  5034                                  .next_line:
  5035 00001C67 800E[0100]88            	setopt [internalflags3], dif3_quiet_input_single | dif3_return_eof
  5036 00001C6C 31C9                    	xor cx, cx
  5037 00001C6E E82CEE                  	call getline.use_dif3_flags
  5038 00001C71 7228                    	jc .notfound
  5039 00001C73 89F3                    	mov bx, si
  5040 00001C75 3C3A                    	cmp al, ':'
  5041 00001C77 75EE                    	jne .next_line
  5042 00001C79 E829E4                  	call skipwhite
  5043 00001C7C 5A                      	pop dx
  5044 00001C7D 52                      	push dx
  5045 00001C7E 4E                      	dec si
  5046 00001C7F E87EE3                  	call isstring?
  5047 00001C82 75E3                    	jne .next_line
  5048 00001C84 8D77FF                  	lea si, [bx - 1]
  5049 00001C87 AC                      	lodsb
  5050 00001C88 89EC                    	mov sp, bp
  5051 00001C8A E84400                  	call resetrc
  5052                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  5053 00001C8D F606[0300]08            	testopt [internalflags3], dif3_in_if
  5054 00001C92 7403E9(0000)            	jnz if_exists_found_open
  5055                                  %endif
  5056 00001C97 5A                      	pop dx			; return address to cmd3
  5057 00001C98 E9(0000)                	jmp cmd3_injected
  5058                                  
  5059                                  .notfound:
  5060                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  5061 00001C9B F606[0300]08            	testopt [internalflags3], dif3_in_if
  5062 00001CA0 751B                    	jnz @F
  5063                                  %endif
  5064 00001CA2 B80103                  	mov ax, 0301h
  5065 00001CA5 E8(0000)                	call setrc
  5066 00001CA8 BA[0000]                	mov dx, msg.goto_not_found.1
  5067 00001CAB E84FEA                  	call putsz_error
  5068 00001CAE 5A                      	pop dx
  5069 00001CAF E84BEA                  	call putsz_error
  5070 00001CB2 BA[0000]                	mov dx, msg.goto_not_found.2
  5071 00001CB5 E845EA                  	call putsz_error
  5072 00001CB8 89EC                    	mov sp, bp
  5073 00001CBA E946F0                  	jmp getline_close_file
  5074                                  
  5075                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  5076                                  @@:
  5077 00001CBD 89EC                    	mov sp, bp
  5078 00001CBF E841F0                  	call getline_close_file
  5079 00001CC2 E9(0000)                	jmp if_exists_not_found
  5080                                  %endif
  5081                                  
  5082                                  .empty:
  5083 00001CC5 B80203                  	mov ax, 0302h
  5084 00001CC8 E8(0000)                	call setrc
  5085 00001CCB BA[0000]                	mov dx, msg.goto_empty
  5086 00001CCE E90AFF                  	jmp .error
  5087                                  
  5088                                  
  5089                                  resetrc:
  5090 00001CD1 FF36[0000]              	push word [priorrc]
  5091 00001CD5 8F06[0000]              	pop word [rc]
  5092 00001CD9 C3                      	retn
  5093                                  
  5094                                  
  5095                                   %ifn _LINK || _LINK_COMPAT
  5096                                  %include "serialp.asm"
  5097                                   %endif
