     1                                  
     2                                  %if 0
     3                                  
     4                                  lDebug - libre 86-DOS debugger
     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 "debug.asm"
    18                                  [list -]
    14                              <3> [list -]
    14                              <2> [list -]
    86                              <1> [list -]
    86          ------------------  <1>  note: Disable usesection detection
    86          ------------------  <1>  note: usesection lDEBUG_DATA_ENTRY
    86          ------------------  <1>  note: usesection ASMTABLE1
    86          ------------------  <1>  note: usesection ASMTABLE2
    86          ------------------  <1>  note: usesection DATASTACKBASE
    86          ------------------  <1>  note: usesection MESSAGESEGMENT
    86          ------------------  <1>  note: usesection lDEBUG_CODE
    86          ------------------  <1>  note: usesection lDEBUG_CODE2
    86          ------------------  <1>  note: usesection INIT
    86          ------------------  <1>  note: usesection WLEMITALIGNINITEND
    86          ------------------  <1>  note: usesection DEVICESHIM
    86          ------------------  <1>  note: usesection WLEMITALIGNRELOCZERO
    68                              <2> %endif
    69                              <2> 
    70                              <2> 
    71                              <2> 	usesection lDEBUG_CODE
    71          ------------------  <2>  note: usesection lDEBUG_CODE
    72                              <2> section_of puts, trimputs, puts_ext_done, puts_ext_next
    73                              <2> section_of putsz_exthelp, code_retf
    74                              <2> section_of puts_getline_ext_done
    75                              <2> section_of puts_copyoutput_ext_done
    76                              <2> section_of guard_auxbuff, guard_re
    77                              <2> section_of handle_serial_flags_ctrl_c
    78                              <2> section_of hexword_high
    79                              <2> section_of call_int2D
    80                              <2> section_of copy_single_counted_string
    81                              <2> section_of intchk
    82                              <2> section_of IsIISPEntry?
    83                              <2> section_of dd_store
    84                              <2> section_of dohack, getsegmented, hexbyte, hexnyb, iseol?.notsemicolon
    85                              <2> section_of peekc, getc, prephack, readmem, setds2si, setds2bx, setes2dx
    86                              <2> section_of silence_get_start, silence_get_start.have_di, silence_count_zeroes
    87                              <2> section_of setrmlimit, skipcomm0, unhack
    88                              <2> section_of skipequals
    89                              <2> section_of to_errret_pop
    90                              <2> section_of cmd3.have_cx_convenience
    91                              <2> section_of verifysegm, verifysegm_or_error
    92                              <2> section_of pp16, resetmode, resetmode_and_test_d_b_bit
    93                              <2> section_of pp_fix32bitflags, proceedbreakpoint
    94                              <2> section_of putsz, hexword, skipcomma, cmd3, cmd3_not_ext, cmd3_preprocessed
    95                              <2> section_of hexdword
    96                              <2> section_of cmd3_not_inject, cmd3_injected
    97                              <2> section_of aa_not_inject, aa_injected, aa_before_getline, aa_after_getline
    98                              <2> section_of transfer_ext_cx_nearcall_from_code2
    99                              <2> section_of traceone, unexpectedinterrupt, dumpregs_no_disasm
   100                              <2> section_of aa_imm_entry, ia_restore_a_addr, ia_restore_u_addr, disasm
   101                              <2> section_of ia_restore_ds
   102                              <2> %ifn _SYMBOLIC
   103                              <2> section_of selector_to_segment
   104                              <2> %endif
   105                              <2> section_of disp_al, disp_al_hex, disp_al_nybble_hex, disp_ax_dec, disp_ax_hex
   106                              <2> section_of disp_dxax_times_cx_width_bx_size
   107                              <2> section_of disp_dxax_times_cx_width_bx_size.store
   108                              <2> section_of disp_message, disp_message_length_cx
   109                              <2> section_of ispm
   110                              <2> section_of setrc, error
   111                              <2> section_of _doscall, _doscall_return_es, _doscall_return_es_parameter_es_ds
   112                              <2> section_of intcall_ext_return_es, close_ext, doscall_extseg
   113                              <2> section_of yy_reset_buf
   114                              <2> section_of init_bootcmd
   115                              <2> 
   116                              <2> section_of InDOS, bootgetmemorysize
   117                              <2> section_of chkeol, decword, decdword
   118                              <2> section_of dec_dword_minwidth
   119                              <2> section_of getexpression.lit_isdigit?, getexpression.lit_ishexdigit?
   120                              <2> section_of getlinearaddr
   121                              <2> section_of getlinear_d_b
   122                              <2> section_of getlinear_high_limit
   123                              <2> section_of getlinear_32bit
   124                              <2> section_of getlinear_high_limit.do_not_use_test
   125                              <2> section_of getlinear_common
   126                              <2> section_of ifsep, iseol?, isseparator?, isstring?, movp
   127                              <2> section_of putc, putsline, putsline_crlf, putsz_error
   128                              <2> section_of setrmsegm
   129                              <2> section_of skipwh0, skipwhite
   130                              <2> section_of test_d_b_bit, test_high_limit, push_cxdx_or_edx
   131                              <2> section_of capitalise
   132                              <2> section_of setes2ax
   133                              <2> section_of zz_copy_strings_to_str_buffer
   134                              <2> section_of call_xms_move, zz_call_xms, zz_detect_xms
   135                              <2> section_of code2_to_code_ret_to_ext
   136                              <2> section_of yy_dos_parse_name, yy_open_file, yy_check_lfn
   137                              <2> section_of yy_common_parse_name
   138                              <2> section_of yy_common_parse_name_bx_buffer
   139                              <2> section_of retry_open_scriptspath
   140                              <2> section_of yy_boot_read.bx, yy_boot_seek_start.bx, yy_boot_seek_current.bx
   141                              <2> section_of yy_boot_parse_name, yy_boot_open_file
   142                              <2> section_of yy_boot_parse_name_bx_buffer
   143                              <2> section_of near_transfer_ext_return, scan_dir_aux, read_sector
   144                              <2> section_of yy_boot_init_dir, got_yyentry, scan_dir_entry
   145                              <2> section_of ..@yy_filename_empty, boot_parse_fn
   146                              <2> section_of count_store, count_store.maybe_0
   147                              <2> section_of loader_get_resident_address, loader_prepare_resident
   148                              <2> 
   149                              <2> 
   150                              <2>  %if _SYMBOLIC && _DUALCODE && _SYMBOLASMDUALCODE
   151                              <2> 	usesection lDEBUG_CODE2
   152                              <2>  %else
   153                              <2> 	usesection lDEBUG_CODE
   153          ------------------  <2>  note: usesection lDEBUG_CODE
   154                              <2>  %endif
   155                              <2> section_of bxcx_to_cx_paragraphs
   156                              <2> section_of zz_list_symbol.first, zz_list_symbol.subsequent
   157                              <2> section_of zz_xms_to_86mm, zz_xms_try_free, zz_xms_try_free_handle
   158                              <2> section_of zz_86mm_to_xms, zz_del_match.add_poison_entrypoint
   159                              <2> section_of zz_free_nonxms, zz_free_xms, zz_free_reset, zz_free_dos
   160                              <2> section_of zz_get_literal, zz_restore_strat, zz_save_strat
   161                              <2> section_of zz_switch_s, zz_transfer_buffer
   162                              <2> 
   163                              <2> 
   164                              <2> %if _SYMBOLIC
   165                              <2>  %if _DUALCODE && _SYMBOLICDUALCODE
   166                              <2> 	usesection lDEBUG_CODE2
   167                              <2>  %else
   168                              <2> 	usesection lDEBUG_CODE
   169                              <2>  %endif
   170                              <2> section_of shift_left_4_bxcx
   171                              <2> section_of selector_to_segment
   172                              <2> 
   173                              <2> section_of anti_normalise_pointer_with_displacement_bxcx, displaystring
   174                              <2> section_of getfarpointer.hash, getfarpointer.main, getfarpointer.str
   175                              <2> section_of move_delete_farpointer.hash, move_delete_farpointer.hash.sidi
   176                              <2> section_of move_delete_farpointer.main, move_delete_farpointer.str.sidi
   177                              <2> section_of move_insert_farpointer.hash, move_insert_farpointer.hash.sidi
   178                              <2> section_of move_insert_farpointer.main, move_insert_farpointer.main.sidi
   179                              <2> section_of move_insert_farpointer.str.sidi
   180                              <2> section_of normalise_pointer, normalise_pointer_with_displacement_bxcx
   181                              <2> section_of pointer_to_linear
   182                              <2> section_of save_slice_farpointer.hash, save_slice_farpointer.main
   183                              <2> section_of save_slice_farpointer.str
   184                              <2> section_of segment_to_selector
   185                              <2> section_of zz_insert, zz_match_symbol, zz_match_symbol.continue, zz_relocate
   186                              <2> 
   187                              <2> section_of binsearchhash, binsearchmain
   188                              <2> section_of check_second_slice
   189                              <2> section_of disp_size_hash, disp_size_main, disp_size_str
   190                              <2> section_of displayresult, getstring1, getstring2
   191                              <2> section_of increment_ss_ref_count
   192                              <2> section_of list_sym_storage_usage, str_index_to_pointer
   193                              <2> section_of zz_commit_insert, zz_compact, zz_compact_expand_check_nonxms
   194                              <2> section_of zz_compact_expand_check_xms
   195                              <2> section_of zz_delete_hash, zz_delete_main, zz_delete_main_and_its_hash
   196                              <2> section_of zz_delete_string, zz_expand, zz_expand_common
   197                              <2> section_of zz_get_symstr_length_bytes
   198                              <2> section_of zz_get_symstr_length_bytes.ssLength_in_cx
   199                              <2> section_of zz_get_symstr_length_indices
   200                              <2> section_of zz_get_symstr_length_indices.ssLength_in_cx
   201                              <2> section_of zz_hash, zz_hash.bx_init
   202                              <2> section_of zz_insert_main.linklist, zz_reloc_main, zz_reloc_str
   203                              <2> section_of zz_store_pre_str, zz_store_string, zz_store_string.hash_bx
   204                              <2> section_of zz_unlink_main_next
   205                              <2> %endif
   206                              <2> 
   207                              <2> %if _DUALCODE
   208                              <2> 	usesection lDEBUG_CODE2
   208          ------------------  <2>  note: usesection lDEBUG_CODE2
   209                              <2> %else
   210                              <2> 	usesection lDEBUG_CODE
   211                              <2> %endif
   212                              <2> section_of FloatToStr
   213                              <2> 
   214                              <2> 
   215                              <2>  %if _DUALCODE && _EXPRDUALCODE
   216                              <2> 	usesection lDEBUG_CODE2
   216          ------------------  <2>  note: usesection lDEBUG_CODE2
   217                              <2>  %else
   218                              <2> 	usesection lDEBUG_CODE
   219                              <2>  %endif
   220                              <2> 
   221                              <2> section_of getofsforbx, checkpointer, getrangeX
   222                              <2> section_of getrangeX_have_address_need_length
   223                              <2> section_of getrange, getaddr, getofsforbx_remember_bitness
   224                              <2> section_of remember_bitness, getaddr_taken
   225                              <2> section_of getstr, get_length, get_length_keyword
   226                              <2> section_of isbracketorunaryoperator?, isunaryoperator?, isoperator?
   227                              <2> section_of ..@call_operator_dispatchers
   228                              <2> section_of isseparator?, istype?, isunsignedtype?
   229                              <2> section_of handlesegment, handle3byte, handlebyte, handleword
   230                              <2> section_of handledword, handlepointer
   231                              <2> section_of uoh_abs, uoh_minus, calculate_minus_bxdx, uoh_plus
   232                              <2> section_of uoh_not_bitwise, uoh_not_boolean
   233                              <2> section_of od_minus, od_plus, od_multiply, od_divide, od_modulo, od_retn
   234                              <2> section_of od_above, od_below, od_equal, od_not, od_or, od_and, od_xor
   235                              <2> section_of od_cond, od_o, od_a, od_x, od_c, od_string_common
   236                              <2> section_of of_modulo, of_minus, of_plus, or_hhtype, of_multiply
   237                              <2> section_of set_hhtype, of_divide, of_power
   238                              <2> section_of of_compare_below_equal, of_compare_below, of_compare_not_equal
   239                              <2> section_of of_compare_equal, of_compare_above_equal, of_compare_above
   240                              <2> section_of toboolean, of_helper_compare_true, of_rightop, of_helper_compare
   241                              <2> section_of of_shift_right, of_shift_right_signed, of_shift_left
   242                              <2> section_of of_helper_getshiftdata, of_bit_mirror
   243                              <2> section_of of_or_bitwise, or_hhtype_1, of_or_boolean, of_clr_bitwise
   244                              <2> section_of of_and_bitwise, of_and_boolean, of_xor_bitwise, of_xor_boolean
   245                              <2> section_of of_helper_retbool, of_helper_getbool
   246                              <2> 
   247                              <2> section_of var_cip_setup, var_csp_setup, var_lfsr_setup, var_reverselfsr_setup
   248                              <2> section_of var_dpspsel_setup, var_seldbg_setup, var_mt_setup
   249                              <2> section_of var_ioi_setup, var_psps_setup, var_ppr_setup, var_ppi_setup
   250                              <2> section_of var_iok_setup, var_rhcount_setup
   251                              <2> section_of var_get_psp_segment, var_get_psp_selector
   252                              <2> section_of var_bootldpunit_setup, var_bootsdpunit_setup, var_bootydpunit_setup
   253                              <2> section_of var_bootldppart_setup, var_bootsdppart_setup, var_bootydppart_setup
   254                              <2> section_of var_bootunitflags_setup
   255                              <2> 
   256                              <2> section_of issymbol?, isvariable?, var_mm_setup, var_ri_setup, var_ysf_setup
   257                              <2> section_of default_variable_setup
   258                              <2> section_of var_ext_setup
   259                              <2> section_of var_ext_setup_done
   260                              <2> 
   261                              <2> section_of getstmmxdigit
   262                              <2> section_of getexpression.lit_ishexdigit?, getexpression.lit_isdigit?
   263                              <2> section_of of_cond, count_unary_operators, count_unary_operators_restrict
   264                              <2> section_of get3byte.checksignificantbits, getbyte, checksignificantbitscommon
   265                              <2> section_of getnyb, get_value_range
   266                              <2> 
   267                              <2> section_of getaddrX, getword, getdword, getexpression
   268                              <2> 
   269                              <2> section_of getrangeX.lines, getrangeX.ecx_and_0_valid
   270                              <2> section_of getrange.lines, getrange.ecx_and_0_valid, get_length.lines
   271                              <2> section_of getrangeX.lines_and_uu, getrange.lines_and_uu
   272                              <2> section_of isseparator?.except_L_or_dot, isvariable?.return_name
   273                              <2> section_of getword.checksignificantbits, getbyte.checksignificantbits
   274                              <2> 
   275                              <2> section_of seg_bx_to_sel
   276                              <2> section_of getexpression.countsignificantbits
   277                              <2> section_of ..@rr_checksignificantbits, ..@rr_operatordispatchers
   278                              <2> section_of ..@rr_operatorfunctions, ..@parsecm_getaddr
   279                              <2> section_of stack_check.internal
   280                              <2> 
   281                              <2> 
   282                              <2> 	usesection INIT
   282          ------------------  <2>  note: usesection INIT
   283                              <2> section_of init_capitalise
   284                              <2> section_of init_skipwhite, init_skipwh0
   285                              <2> section_of init_skipcomma, init_skipcomm0
   286                              <2> section_of init_skipequals
   287                              <2> 
   288                              <2> 
   289                              <2> 	usesection lDEBUG_DATA_ENTRY
   289          ------------------  <2>  note: usesection lDEBUG_DATA_ENTRY
   290                              <2> section_of entry_retn
   291                              <2> 
   292                              <2> 
   293                              <2> %if _LINK
   294                              <2>  %include "extern.mac"
     1                              <3> 
     2                              <3> ; expr.asm
     3                              <3>  extern PPLEN, PPLEN_ONLY_PREFIXES, a_addr, alloc_seg, alloc_size
     4                              <3>  extern amis_multiplex_number, asm_options, asm_startoptions
     5                              <3>  extern auxbuff_current_size, auxbuff_segorsel, behind_r_u_addr
     6                              <3>  extern bp_offset, code_seg, code_size, d_addr, dcount_addr
     7                              <3>  extern dcpm_addr, dd_default_length, dd_default_lines, dd_text_and
     8                              <3>  extern debuggerfunction, default_pp_count, default_tp_count
     9                              <3>  extern default_tt_count, device_header_address, device_mcb_paragraphs
    10                              <3>  extern dwcount_addr, dz_addr, e_addr, encodedmach87, entryseg_size
    11                              <3>  extern env_size, envseg, erc, errret
    12                              <3>  extern extdata, extdata_size, extdata_used, extseg, extseg_size
    13                              <3>  extern extseg_used, flagbits.amount, flagnames, flagvaron
    14                              <3>  extern getrange_is_uu, getrange_lines, has_mmx, hhresult
    15                              <3>  extern history.segorsel, historyseg_size, immseg, input_file_handles
    16                              <3>  extern input_file_handles.active, internalflags, internalflags2
    17                              <3>  extern internalflags3, intr8_limit, io_columns, io_columns_getline
    18                              <3>  extern io_end_buffer, io_flags, io_levels, io_rows, io_start_buffer
    19                              <3>  extern line_out, line_out_end, linkinfoaddress, load_data
    20                              <3>  extern load_input_file, load_input_file.active, load_unit_flags
    21                              <3>  extern loaddata_loadedfrom, machine, maxmachinetype, messageseg
    22                              <3>  extern messageseg_size, mmxbuff, msg.as, msg.end, msg.executing
    23                              <3>  extern msg.executing_value_range, msg.from, msg.in, msg.length
    24                              <3>  extern msg.linear, msg.lines, msg.lr, msg.nd, msg.nottaken
    25                              <3>  extern msg.nt, msg.or, msg.questionmark, msg.r, msg.stack_overflow
    26                              <3>  extern msg.stack_overflow.caller, msg.stack_overflow.cond
    27                              <3>  extern msg.stack_overflow.indirection, msg.stack_overflow.linear
    28                              <3>  extern msg.stack_overflow.parens, msg.stack_overflow.precedence
    29                              <3>  extern msg.stack_overflow.value_in, msg.t, msg.taken, msg.to
    30                              <3>  extern msg.value, msgtable_value_range, options, options2, parent
    31                              <3>  extern ppbytes, priorrc, psp22, pspdbe, pspdbg
    32                              <3>  extern qqtermcode, rc_count, rc_limit, re_count, re_limit
    33                              <3>  extern reading_access_variables, reg16names, reg8names, reg_cs
    34                              <3>  extern reg_ds, reg_efl, reg_eip, reg_esp, search_results
    35                              <3>  extern serial_columns, serial_fifo_size, serial_keep_timeout
    36                              <3>  extern serial_rows, serial_use_baseport, serial_use_dl
    37                              <3>  extern serial_use_fifo, serial_use_intnum, serial_use_irqmask
    38                              <3>  extern serial_use_params, serial_var_baseport, serial_var_dl
    39                              <3>  extern serial_var_fifo, serial_var_intnum, serial_var_irqmask
    40                              <3>  extern serial_var_params, sscounter, stack, startoptions
    41                              <3>  extern table_length_keywords, throwsp, transfer_ext_cx
    42                              <3>  extern try_amis_multiplex_number, try_debugger_amis_multiplex_number
    43                              <3>  extern types, types.addresses_minus_end, types.end, u_addr
    44                              <3>  extern usertermcode, uu_default_length, uu_default_lines, vregs
    45                              <3>  extern vregs.amount, writing_access_variables
    46                              <3>  extern flagbits, regs
    47                              <3> 
    48                              <3> ; run.asm
    49                              <3>  extern ..@aa_access_end, ..@aa_access_start, ..@dd_access_end
    50                              <3>  extern ..@dd_access_start, ..@ee_access_end, ..@ee_access_start
    51                              <3>  extern ..@ee_interactive_access_end, ..@ee_interactive_access_start
    52                              <3>  extern ..@hh_indirection_memory_access_end
    53                              <3>  extern ..@hh_indirection_memory_access_start
    54                              <3>  extern ..@readmem_fault_skip_4_near_call, ..@rr_access_end
    55                              <3>  extern ..@rr_access_start, ..@rr_variable_read_access_end
    56                              <3>  extern ..@rr_variable_read_access_start
    57                              <3>  extern ..@rr_variable_write_access_end
    58                              <3>  extern ..@rr_variable_write_access_start, ..@sss_access_end
    59                              <3>  extern ..@sss_access_start, ..@uu_access_end, ..@uu_access_start
    60                              <3>  extern ..@uu_referenced_memory_access_end
    61                              <3>  extern ..@uu_referenced_memory_access_start, ..@uu_simulate_cmps_end
    62                              <3>  extern ..@uu_simulate_cmps_start, ..@uu_simulate_scas_end
    63                              <3>  extern ..@uu_simulate_scas_start, InDOS_or_BIOS_IO, PPLEN_ONLY_STRING
    64                              <3>  extern auxbuff_behind_last_silent
    65                              <3>  extern auxbuff_start_silent, bInDbg, b_bplist.bp, b_bplist.counter
    66                              <3>  extern b_bplist.disabled_mask, b_bplist.idbuffer, b_bplist.used_mask
    67                              <3>  extern b_bplist.when, bb_deferred_message_in_lineout_behind
    68                              <3>  extern bp_display_offset, calcpointbit, cmd2_reset_re, cmd_goto
    69                              <3>  extern debug22.cleartraceflag, decbyte, dmycmd, dumpregs_extended
    70                              <3>  extern enable_rh, entry_to_code_seg, entry_to_code_segsel, eqflag
    71                              <3>  extern eqladdr, exccsip, exception_csip, exception_stack, excloc
    72                              <3>  extern g_bplist.bp, g_bplist.used_count, get_set_id_offset_length
    73                              <3>  extern getc_if_any, getcseipbyte, getint2324, getpsp
    74                              <3>  extern gg_deferred_message, gg_first_cseip_linear
    75                              <3>  extern gg_next_cseip_linear, guard_auxbuff.1_or_2, idle, in_getinput
    76                              <3>  extern int19msg, internalflags6, intr8_counter, lastcmd, msg.again
    77                              <3>  extern msg.alreadytsr, msg.area_aa_access, msg.area_dd_access
    78                              <3>  extern msg.area_ee_access, msg.area_ee_interactive_access
    79                              <3>  extern msg.area_hh_indirection_memory_access, msg.area_rr_access
    80                              <3>  extern msg.area_rr_variable_read_access
    81                              <3>  extern msg.area_rr_variable_write_access, msg.area_run_access
    82                              <3>  extern msg.area_sss_access, msg.area_uu_access
    83                              <3>  extern msg.area_uu_referenced_memory_access
    84                              <3>  extern msg.area_uu_simulate_cmps, msg.area_uu_simulate_scas
    85                              <3>  extern msg.bb_hit.1, msg.bb_hit.2.counter, msg.bb_hitpass_id.after
    86                              <3>  extern msg.bb_hitpass_id.long, msg.bb_hitpass_id.short, msg.bb_pass.1
    87                              <3>  extern msg.cant_bp_linear, msg.cant_bp_linear.address1
    88                              <3>  extern msg.cant_bp_reason, msg.cant_bp_reason0, msg.cant_bp_reason1
    89                              <3>  extern msg.cant_bp_reason2, msg.cant_bp_reason3
    90                              <3>  extern msg.cant_bp_reason3.value, msg.cant_bp_reasonu
    91                              <3>  extern msg.cant_bp_restore, msg.cant_bp_restore.value
    92                              <3>  extern msg.cant_bp_the, msg.cant_bp_type_gg
    93                              <3>  extern msg.cant_bp_type_permanent, msg.cant_bp_type_permanent.index
    94                              <3>  extern msg.cant_bp_type_proceed, msg.cant_bp_write, msg.ctrlc
    95                              <3>  extern msg.empty_message, msg.goto, msg.invalidpsp, msg.list
    96                              <3>  extern msg.list_bp.address1, msg.list_bp.first, msg.list_bp.second
    97                              <3>  extern msg.list_bp.third, msg.list_bp.value, msg.list_bp_csip_16
    98                              <3>  extern msg.list_bp_none, msg.list_bp_not_cseip, msg.notyettsr
    99                              <3>  extern msg.nowattached, msg.nowtsr1, msg.nowtsr2, msg.psphooked
   100                              <3>  extern msg.pspnotfound, msg.remember, msg.selfownedpsp, msg.silent
   101                              <3>  extern msg.warnprefix, msg.while, msg.while_not_true
   102                              <3>  extern msg.while_terminated_after, msg.while_terminated_before
   103                              <3>  extern oldcols, oldcrtp, oldcsrpos, oldmr, options3
   104                              <3>  extern options6, pp_instruction, pp_operand, progexit, progtrm
   105                              <3>  extern rc, reg_eax, reg_es, reg_gs, reg_ss
   106                              <3>  extern run_int, run_sp, run_sp_reserve, savesp, setcseipbyte
   107                              <3>  extern setint2324, setpsp, setpspdbg
   108                              <3>  extern showstring, silence_dump, spadjust, swapscreen
   109                              <3>  extern tmode0, tmode1, tmodes, tmodev, tpg_possible_breakpoint
   110                              <3>  extern tpg_proceed_bp, tt_silent_mode_number, vpage, vrows
   111                              <3>  extern while_buffer, while_buffer.length, writemem
   112                              <3> 
   113                              <3>  extern ..@getcseipbyte_fault_skip_2_near_call
   114                              <3>  extern ..@setcseipbyte_fault_skip_2_near_call
   115                              <3>  extern ..@writemem_fault_skip_4_near_call_a
   116                              <3>  extern ..@writemem_fault_skip_4_near_call_b, int0Cmsg, int0Dmsg
   117                              <3>  extern int0msg, int18msg, int1msg, int3msg, int6msg
   118                              <3>  extern int8_kbd_msg, int8msg, runint_ctrlc_msg, serial_flags
   119                              <3> 
   120                              <3> ; bb.asm
   121                              <3>  extern ..@bb_id_length, ..@bb_id_start, ..@bb_saved_linear
   122                              <3>  extern ..@bb_when_length, ..@bb_when_start, b_bplist.id
   123                              <3>  extern b_bplist.idbuffer.free
   124                              <3>  extern b_bplist.whenbuffer, b_bplist.whenbuffer.free
   125                              <3>  extern bootcmd, crlf, msg.all, msg.at
   126                              <3>  extern msg.bb_no_new, msg.bb_when, msg.boot, msg.bp, msg.bpaddress
   127                              <3>  extern msg.bpcontent, msg.bpcounter, msg.bpdisabled, msg.bpenabled
   128                              <3>  extern msg.bpnone, msg.bpnone_at, msg.bpunused, msg.counter
   129                              <3>  extern msg.existing, msg.id, msg.new, msg.notbu, msg.number
   130                              <3>  extern msg.offset, msg.when, prnquit
   131                              <3> 
   132                              <3> ; rr.asm
   133                              <3>  extern InDOS_or_BIOS_output, cmdline_buffer
   134                              <3>  extern cmdline_buffer.end, cmdline_buffer.position, disflags, ee0a
   135                              <3>  extern error_expr, flagbits_for_40, flagbits_for_80, flagsoff
   136                              <3>  extern flagsoff_style2, flagsoff_style3, flagson, flagson_style23
   137                              <3>  extern get_memref_index_bx, getline00, getline_reset_notatty
   138                              <3>  extern guard_rc, hexnyb.common, hhtype, hhvar, in_re
   139                              <3>  extern mask_4byte, masks, memrefs, memrefs.free, msg.3byte
   140                              <3>  extern msg.abort, msg.append, msg.byte, msg.count, msg.dword
   141                              <3>  extern msg.highlight, msg.internal_error_no_mmx, msg.readonly
   142                              <3>  extern msg.readonly_mem, msg.regs386, msg.regs386_off, msg.regs386_on
   143                              <3>  extern msg.replace, msg.rh, msg.rv_mode.before, msg.rv_mode_r86m
   144                              <3>  extern msg.rv_mode_v86m, msg.rvd, msg.rvd_deviceheader
   145                              <3>  extern msg.rvd_not_device, msg.rvd_size, msg.rvm, msg.rvp
   146                              <3>  extern msg.rvp_application, msg.rvp_boot, msg.rvp_device
   147                              <3>  extern msg.rvp_device_attached, msg.rvp_tsr, msg.rvv
   148                              <3>  extern msg.unexpected_auxbuff_guard, msg.unhighlight, msg.vm_auxseg
   149                              <3>  extern msg.vm_codeseg, msg.vm_dataseg, msg.vm_entryseg, msg.vm_hisseg
   150                              <3>  extern msg.vm_messageseg, msg.vp_dparent, msg.vp_dpra
   151                              <3>  extern msg.vp_dpspsegment, msg.vp_parent, msg.vp_pra
   152                              <3>  extern msg.vp_pspsegment, msg.word, operatorfunctions, psp_parent
   153                              <3>  extern psp_pra, puts_break_line_more, putsline_break_line, re_buffer
   154                              <3>  extern re_buffer.end, re_buffer.position, re_sp, regs_prior
   155                              <3>  extern regs_prior.size, retn_expr, rh_count_number
   156                              <3>  extern rh_display_with_count, shortflagbits, shortflagbits.amount
   157                              <3>  extern shortflagsoff, shortflagson, silence_dump.rh
   158                              <3>  extern silence_dump.rh.all, table_getline_prepare_ldebug
   159                              <3>  extern table_getline_prepare_ms_debug, terminate_silent_dump
   160                              <3>  extern terminate_silent_dump.if_nonnull
   161                              <3> 
   162                              <3> ; rr.asm
   163                              <3>  extern flagbits_for_shl, regs_prior.size_w
   164                              <3> 
   165                              <3> ; aa.asm
   166                              <3>  extern REP_LEN, SEGP_LEN, attach
   167                              <3>  extern ext_aa_after_getline_handler, ext_aa_before_getline_handler
   168                              <3>  extern ext_aa_inject_handler, immasm_length, immasm_rel1632_target
   169                              <3>  extern immasm_rel8_target, msg.aa_internal_error, msg.attach
   170                              <3>  extern prefixlist.after_segment, replist, segprfxtab, showmach
   171                              <3>  extern skipalpha, sm1
   172                              <3> 
   173                              <3> ; uu.asm
   174                              <3>  extern A32P_LEN, GROUP7, MN_DB, MN_LOCK, MN_LOOP
   175                              <3>  extern MN_LOOPNZ, MN_LOOPZ, MN_REP, MN_REPE, MN_REPNE
   176                              <3>  extern MN_SEG, MN_WAIT, N_LOCK, N_LTABA, N_LTABO
   177                              <3>  extern N_WTAB, O32P_AMOUNT, OPTYPES_BASE, REP_DIFF_LEN, REP_SAME_LEN
   178                              <3>  extern SFPGROUP3, SGROUP4, SPARSE_BASE, a32prfxtab, dismach
   179                              <3>  extern dmflags, has_87, immasm_far_target, immasm_imm16, locktab
   180                              <3>  extern ltaba1, ltabo1, mach_87, mnlist, mnlist_a_suffix_allowed
   181                              <3>  extern mnlist_o_suffix_allowed, mnlist_o_suffix_required
   182                              <3>  extern msg.condjump, msg.condnotjump, msg.memrefs_invalid_internal
   183                              <3>  extern msg.uninstall, msg.uu_internal_error, msg.uu_too_many_repeat
   184                              <3>  extern needsmath, needsmath_L, needsmsg, needsmsg.digit_6_ofs
   185                              <3>  extern needsmsg.digit_x_ofs, needsmsg_L, o32prfxtab, obsmach
   186                              <3>  extern obsolete, obsolete_L, opindex, opinfo, oplists
   187                              <3>  extern optypes, ppbytes.string, ppbytes.string_amount, reg_ebp
   188                              <3>  extern reg_ebx, reg_ecx, reg_edi, reg_esi, reg_fs
   189                              <3>  extern regmem, rgnam16, rgnam816, segrgnam, sibbyte
   190                              <3>  extern sqztab, tab_to, uninstall, unused, wtab1
   191                              <3> 
   192                              <3> ; uu.asm
   193                              <3>  extern reg_edx
   194                              <3> 
   195                              <3> ; uu.asm
   196                              <3>  extern MN_BSWAP, MN_O32
   197                              <3> 
   198                              <3> ; uu.asm
   199                              <3>  extern MN_A32
   200                              <3> 
   201                              <3> ; amis.asm
   202                              <3>  extern amisintr_offset, deviceshim_size, ext_amis_handler
   203                              <3> 
   204                              <3> ; boot.asm
   205                              <3>  extern boot_remember_seek_handle
   206                              <3>  extern boot_remember_seek_offset, chkeol_or_then, cmd_goto.yy_entry
   207                              <3>  extern display_y_or_ext, ext_cmdline, ext_finish.boot
   208                              <3>  extern if_exists_found_open, if_exists_not_found
   209                              <3>  extern if_exists_then_address, iseol?_or_then, loadoptiontable
   210                              <3>  extern loadoptiontable.incompatible, loadsettings
   211                              <3>  extern msdos7_message_table, msdos7_message_table.size
   212                              <3>  extern msg.boot_access_error, msg.boot_and, msg.boot_auxbuff_crossing
   213                              <3>  extern msg.boot_badchain, msg.boot_badclusters, msg.boot_badfat
   214                              <3>  extern msg.boot_bpb_load_overlap, msg.boot_bpb_too_low
   215                              <3>  extern msg.boot_cannot_set_both, msg.boot_dot_crlf
   216                              <3>  extern msg.boot_file_not_found, msg.boot_file_too_big_error
   217                              <3>  extern msg.boot_file_too_small_error, msg.boot_internal_error
   218                              <3>  extern msg.boot_invalid_filename, msg.boot_invalid_heads
   219                              <3>  extern msg.boot_invalid_sectors, msg.boot_out_of_memory_error
   220                              <3>  extern msg.boot_partition_cycle_error, msg.boot_partition_not_found
   221                              <3>  extern msg.boot_quit_fail, msg.boot_sector_not_power
   222                              <3>  extern msg.boot_sector_too_large, msg.boot_sector_too_small
   223                              <3>  extern msg.boot_segment_too_low, msg.boot_too_many_partitions_error
   224                              <3>  extern msg.bootfail, msg.bootfail_check_mismatch
   225                              <3>  extern msg.bootfail_check_mismatch.check_got
   226                              <3>  extern msg.bootfail_check_mismatch.check_offset
   227                              <3>  extern msg.bootfail_check_mismatch.check_value, msg.bootfail_code
   228                              <3>  extern msg.bootfail_read, msg.bootfail_read_errorcode
   229                              <3>  extern msg.bootfail_secsizediffer, msg.bootfail_sig
   230                              <3>  extern msg.bootfail_sig_parttable, msg.bootfail_stack_underflow
   231                              <3>  extern msg.bpb, msg.checkoffset, msg.checkvalue, msg.dir
   232                              <3>  extern msg.dirinsteadsize, msg.emptydirname, msg.entry
   233                              <3>  extern msg.guard_auxbuff_error, msg.hidden, msg.hiddenadd
   234                              <3>  extern msg.maxpara, msg.minpara, msg.protocol, msg.quit, msg.read
   235                              <3>  extern msg.sector, msg.sector_alt, msg.segment, msg.write
   236                              <3>  extern msg.yy_empty, msg.yy_filename_empty, msg.yy_no_file
   237                              <3>  extern msg.yy_requires_filename, msg.yy_too_large
   238                              <3>  extern msg.yy_too_many_handles, terminator_in_line_in.offset
   239                              <3>  extern terminator_in_line_in.value, throwret
   240                              <3>  extern yy_boot_attempt_open_pathname, yy_boot_attempt_open_stack
   241                              <3>  extern yy_is_script
   242                              <3> 
   243                              <3> ; cc.asm
   244                              <3>  extern count_var, hh.single, msg.clear, msg.clear_sequence
   245                              <3>  extern msg.range, parsecm
   246                              <3> 
   247                              <3> ; dd.asm
   248                              <3>  extern auxbuff_current_size_minus_24, charcounter
   249                              <3>  extern dstringaddr, dstringtype, firstmcb, firstumcb, intaddress
   250                              <3>  extern lastint, lastint_is_86m_and_mcb, msg.di_empty, msg.di_error
   251                              <3>  extern msg.di_freedos_reloc, msg.di_hidden, msg.di_hma, msg.di_iisp
   252                              <3>  extern msg.di_jmpfar, msg.di_jmpfarindirect, msg.di_multiplex.1
   253                              <3>  extern msg.di_multiplex.2, msg.di_multiplex.3, msg.di_nonstd_iisp
   254                              <3>  extern msg.di_system_low, msg.di_system_mcb, msg.di_system_upper
   255                              <3>  extern msg.di_testhook, msg.di_toomany, msg.di_uninst_iisp
   256                              <3>  extern msg.header, msg.header.length, msg.invmcbadr, msg.prefixes
   257                              <3>  extern msg.tableheader, msg.tableheadertop, msg.top, msg.trailer
   258                              <3>  extern msg.trailer.length, smcbmsg_unknown, smcbtypes
   259                              <3> 
   260                              <3> ; debug.asm
   261                              <3>  extern UnhookInterruptForce, UnhookInterruptForceSim, aa
   262                              <3>  extern adusetup, bb, boot_ebdaflag, boot_initcode
   263                              <3>  extern boot_new_memsizekib, boot_old_memsizekib, cc, code_start, ddd
   264                              <3>  extern device_initcode, driveno, dumpregs_extended.exit, ee
   265                              <3>  extern eld_linkcall.call_cmd3, end_of_ldebug_code, entry_int3_retf
   266                              <3>  extern errcarat, ff, get_86m_interrupt_handler_no_dos, get_columns
   267                              <3>  extern getline_close_file, getline_close_file.resetstuff, gg, hh
   268                              <3>  extern hh_depth, hh_depth_of_single_term, hhflag, ia_restore, ii
   269                              <3>  extern immasm, install_86m_interrupt_handler, int22, int2D, intr0
   270                              <3>  extern intr0C, intr0D, intr1, intr18, intr19
   271                              <3>  extern intr3, intr6, intr8, linkinfo, ll
   272                              <3>  extern ll3, ll_copy_cmdline_and_fcbs
   273                              <3>  extern ll_copy_cmdline_and_fcbs.have_cx
   274                              <3>  extern mm, msg.NULblank, msg.asmoptions_1, msg.boothelp
   275                              <3>  extern msg.build_array, msg.build_long_amount, msg.build_short_amount
   276                              <3>  extern msg.build_version_amount, msg.cannot_hook_2D.invalid
   277                              <3>  extern msg.cannot_hook_2D.nofree, msg.cannotbootquit_memsizes
   278                              <3>  extern msg.condhelp, msg.ensure_no_memory, msg.expressionhelp
   279                              <3>  extern msg.flaghelp, msg.flags_1, msg.guard_rc_error
   280                              <3>  extern msg.guard_re_error, msg.help_array, msg.help_array_amount
   281                              <3>  extern msg.help_re, msg.help_run, msg.help_source, msg.keep
   282                              <3>  extern msg.license, msg.line_out_overflow, msg.n_toolongname
   283                              <3>  extern msg.n_toolongtail, msg.nobootsupp, msg.options_array
   284                              <3>  extern msg.options_array_amount, msg.options_pages, msg.options_scan
   285                              <3>  extern msg.options_scan_amount, msg.qq_a_terminated
   286                              <3>  extern msg.qq_a_unterminated, msg.qq_device_no_c, msg.qq_device_no_d
   287                              <3>  extern msg.qq_device_none_selected, msg.qq_unterm
   288                              <3>  extern msg.rc_limit_reached, msg.re, msg.re_limit_reached
   289                              <3>  extern msg.reghelp, msg.rh_disabled, msg.rh_enabled, msg.run
   290                              <3>  extern msg.serial_cannot_hook, msg.serial_cannot_hook.new_int
   291                              <3>  extern msg.serial_cannot_hook.old_int, msg.serial_cannot_unhook
   292                              <3>  extern msg.serial_cannot_unhook.int, msg.serial_cannot_unhook.nowarn
   293                              <3>  extern msg.serial_late_unhook, msg.serial_late_unhook.int
   294                              <3>  extern msg.serial_no_keep_enter, msg.serial_no_keep_timer
   295                              <3>  extern msg.serial_request_keep, msg.source, msg.string_build
   296                              <3>  extern msg.string_options, msg.string_version
   297                              <3>  extern msg.tsr_cannot_terminate_attached, msg.varhelp, oo, ph_msg, pp
   298                              <3>  extern putrunint, putsz_exthelp, rr, run, section.DEVICESHIM.vstart
   299                              <3>  extern serial_clean_up, serial_clear_fifos, serial_eoi
   300                              <3>  extern serial_init_UART, serial_install_interrupt_handler
   301                              <3>  extern serial_interrupt_handler, serial_uninstall_interrupt_handler
   302                              <3>  extern set_irq, setscreen, sleep_delta_limit, sleep_highest_delta
   303                              <3>  extern sss, tpg_initialise_empty_auxbuff.reset
   304                              <3>  extern transfer_to_ext_puts_getline, tt, update_inttab_optional, uu
   305                              <3>  extern vv, vv_disable, vv_set, ww, yy
   306                              <3> 
   307                              <3> ; debug.asm
   308                              <3>  extern eld_linkcall
   309                              <3> 
   310                              <3> ; ee.asm
   311                              <3>  extern bufend, bufnext, fillbuf, fullbsout
   312                              <3>  extern getline_is_input_file?, line_in, linecounter, load_extension
   313                              <3>  extern msg.ext, notatty, prehak1, run2324
   314                              <3> 
   315                              <3> ; hh.asm
   316                              <3>  extern hh_div_active, hh_div_dividend, hh_div_divisor
   317                              <3>  extern msg.base, msg.group, msg.hh_div_remainder, msg.width
   318                              <3> 
   319                              <3> ; iioo.asm
   320                              <3>  extern if_exists_length, if_exists_si, if_exists_sp
   321                              <3>  extern install, msg.exists, msg.install, msg.not, msg.then
   322                              <3>  extern msg.y, resetrc, yy_or_ext_no_guard_re
   323                              <3> 
   324                              <3> ; immasm.asm
   325                              <3>  extern aa_ret, addrr, condmsg, error_mirror, index
   326                              <3>  extern msg.immasm_error_eip, presizeflags, reg32addr, segmnt
   327                              <3>  extern segrgaddr
   328                              <3> 
   329                              <3> ; msg.asm
   330                              <3>  extern ..@boot_scan_dir_return_fat16_root_entry
   331                              <3>  extern ..@boot_scan_dir_return_filenotfound
   332                              <3>  extern ..@boot_scan_dir_return_subdir_or_fat32_entry
   333                              <3>  extern alloc_size_not_reserved, asciitablenames, boot_init_foundname
   334                              <3>  extern configpath, configpath.dir_end, device_quittable_regs, dpmi32
   335                              <3>  extern execblk.cmdline, ext_command_handler, ext_finish.bp_is_set
   336                              <3>  extern ext_handle, ext_inject_handler, ext_preprocess_handler
   337                              <3>  extern ext_puts_copyoutput_handler, ext_puts_getline_handler
   338                              <3>  extern ext_puts_handler, ext_var, ext_var_amount, ext_var_format
   339                              <3>  extern ext_var_size, extcssel, extdssel, handle_scan_dir_entry
   340                              <3>  extern handle_scan_dir_not_found, history.first, history.last
   341                              <3>  extern indirect_array_errfix, init_executable_pathname
   342                              <3>  extern init_executable_pathname.end, internalflags4, internalflags5
   343                              <3>  extern internalflags7, isvariable_morebyte_nameheaders.ext
   344                              <3>  extern lastcmd_transfer_ext_address, lastcmd_transfer_ext_entry
   345                              <3>  extern line_in.end, linkcall_table, load_adr_dirbuf_segment
   346                              <3>  extern load_check_dir_attr, load_data_lowest, load_kernel_name
   347                              <3>  extern load_yy_direntry, load_yyname_input, load_yyname_next
   348                              <3>  extern near_transfer_ext_address, near_transfer_ext_entry
   349                              <3>  extern next_reserved_segment, options4, options5, options7
   350                              <3>  extern patcharea_intrtn, patcharea_intrtn.segment
   351                              <3>  extern patcharea_intrtn.size, patcharea_run, patcharea_run.segment
   352                              <3>  extern patcharea_run.size, pm_2_86m_0, promptlen, reserved_address
   353                              <3>  extern scriptspath, scriptspath.dir_end
   354                              <3>  extern sss_silent_count, sss_silent_count_used, stack_end, swch1
   355                              <3>  extern while_buffer.end
   356                              <3> 
   357                              <3> ; msg.asm
   358                              <3>  extern install_trying
   359                              <3> 
   360                              <3> ; init.asm
   361                              <3>  extern ..@init_behind, ..@init_first
   362                              <3>  extern ..@patch_no386_ds_6_DATA_ENTRY
   363                              <3>  extern ..@patch_no386_ds_code_or_entry
   364                              <3>  extern ..@patch_no386_iret_code_or_entry, behind_code_truncated
   365                              <3>  extern behind_init, behind_messagesegment_nobits
   366                              <3>  extern behind_messagesegment_nobits_truncated, debug22
   367                              <3>  extern device_header.next, devint23, devint24, entry_retf
   368                              <3>  extern execblk.fcb1, execblk.fcb2, ext_data_area, extcall_table.ret
   369                              <3>  extern extcall_table.segsel, fileext, hVdd, immasm_buffer, initcont
   370                              <3>  extern initcont.boot_entry, initcont.device, inttab, inttab.i06
   371                              <3>  extern inttab.i2D, inttab_number_variable, line_out_overflow
   372                              <3>  extern linkcall_table.code1, linkcall_table.entry
   373                              <3>  extern linkcall_table.init, oldmode, pInDOS, pSDA, regs.size
   374                              <3>  extern switchar, trim_overflow, var_addr_entries
   375                              <3>  extern var_addr_entries.amount
   376                              <3> 
   377                              <3> ; install.asm
   378                              <3>  extern installflags, msg.alreadydisabled
   379                              <3>  extern msg.alreadyenabled, msg.toggle, msg.trydisable, msg.tryenable
   380                              <3> 
   381                              <3> ; ints.asm
   382                              <3>  extern debuggeramissig, inttab_optional
   383                              <3> 
   384                              <3> ; lineio.asm
   385                              <3>  extern auxbuff_amount_silent, cmd3_set_options
   386                              <3>  extern determine_quiet_output, eldheader, getc_repeat_idle
   387                              <3>  extern getline_timer_func, handle_ctrl_c, if_exists_found_closed
   388                              <3>  extern if_exists_found_ext_open, indos_remember_seek_function
   389                              <3>  extern indos_remember_seek_handle, indos_remember_seek_offset
   390                              <3>  extern input_file_handles.to_close, msg.configkeyword
   391                              <3>  extern msg.eld_error_code, msg.eld_load_error, msg.emptykeyword
   392                              <3>  extern msg.eof, msg.executablekeyword, msg.ext_error_internal
   393                              <3>  extern msg.ext_error_invalid, msg.ext_error_io, msg.ext_error_oom
   394                              <3>  extern msg.freedos_ctrlc_workaround, msg.goto_empty
   395                              <3>  extern msg.goto_not_file, msg.goto_not_found.1, msg.goto_not_found.2
   396                              <3>  extern msg.history_internal_error, msg.more, msg.more_over
   397                              <3>  extern msg.more_over_size, msg.more_size, msg.rh_step.1
   398                              <3>  extern msg.rh_step.2, msg.scriptskeyword, msg.silent_error, msg.sof
   399                              <3>  extern msg.unexpected_noneol_rc, msg.unexpected_noneol_re
   400                              <3>  extern msg.yy_error_file_open, msg.yy_filename_missing_unquote
   401                              <3>  extern msg.yy_no_dos, qq, section.DATASTACK.vstart
   402                              <3>  extern serial_check_receive_char, serial_receive_char
   403                              <3>  extern serial_send_char, skip_rh, yy_boot
   404                              <3>  extern yy_boot_clear_remember_seek, yy_boot_close_file, yy_boot_read
   405                              <3>  extern yy_boot_remember_seek, yy_boot_seek_current
   406                              <3>  extern yy_boot_seek_start, yy_try_scriptspath
   407                              <3>  extern yy_try_scriptspath.didnotyettry
   408                              <3>  extern yy_try_scriptspath.nokeywordused
   409                              <3> 
   410                              <3> ; ll.asm
   411                              <3>  extern doserr8, ensuredebuggeeloaded, execblk, execblk.csip
   412                              <3>  extern execblk.sssp, msg.hexerror, msg.ll_unterm, msg.not_while_indos
   413                              <3>  extern msg.tsr_cannot_ll, parselw, reading
   414                              <3>  extern terminate_attached_process, ww1, ww15, zeroregs
   415                              <3> 
   416                              <3> ; mm.asm
   417                              <3>  extern has_287, has_copr, msg.c0, msg.cr, msg8088
   418                              <3>  extern msgx86, no_copr, parsecm_have_address
   419                              <3> 
   420                              <3> ; serialp.asm
   421                              <3>  extern baseport, msg.no_progress, rxfifo, rxhead
   422                              <3>  extern rxtail, serial_fcr_setting, serial_installed_intnum
   423                              <3>  extern serial_save_dl, serial_save_ier, serial_save_irq_mask
   424                              <3>  extern serial_save_irq_off, serial_save_lcr, serial_save_mcr, txfifo
   425                              <3>  extern txhead, txtail
   426                              <3> 
   427                              <3> ; ss.asm
   428                              <3>  extern msg.matches, msg.reverse, msg.seconds, msg.sleep
   429                              <3>  extern msg.ticks, sleep_repeat_idle
   430                              <3> 
   431                              <3> ; vv.asm
   432                              <3>  extern csrpos, msg.nokeep, msg.off, msg.on, msg.vv_disabled
   433                              <3>  extern msg.vv_enable_failure, xmsdrv, xmsmove
   434                              <3> 
   435                              <3> ; ww.asm
   436                              <3>  extern diskful, doserr11, doserr2, doserr3, doserr5
   437                              <3>  extern drive, drivenumber, dskerrs, not_while_indos, nowhexe
   438                              <3>  extern nownull, openerr, openerr1, writing, wwmsg1
   439                              <3>  extern wwmsg2
   440                              <3> 
   441                              <3> 
   442                              <3>  extern bCSAttr, lDEBUG_CODE_to_lDEBUG_CODE2_nearcall_helper
   443                              <3> 
   444                              <3>  extern hook2F.not_in_dos
   445                              <3> 
   446                              <3>  extern cmd4.int3, lDEBUG_CODE2_dualret_helper
   447                              <3>  extern lDEBUG_CODE2_to_lDEBUG_CODE_nearcall_helper
   448                              <3>  extern lDEBUG_CODE_to_lDEBUG_CODE2_dualcall_helper, msg.bu
   449                              <3>  extern msg.bu_relocated, msg.bu_relocated.sign
   450                              <3> 
   451                              <3>  extern nopmsupp
   452                              <3> 
   453                              <3>  extern bAddr32
   454                              <3> 
   455                              <3>  extern descriptor, descriptor.attrib, descriptor.base
   456                              <3>  extern descriptor.limit, gatewrong, msg.d.a_error, msg.d.a_error_code
   457                              <3>  extern msg.d.a_success, msg.d.a_success_sel, msg.d.b_error
   458                              <3>  extern msg.d.b_error_code, msg.d.b_success, msg.d.d_error
   459                              <3>  extern msg.d.d_error_code, msg.d.d_success, msg.d.l_error
   460                              <3>  extern msg.d.l_error_code, msg.d.l_success, msg.d.t_error
   461                              <3>  extern msg.d.t_error_code, msg.d.t_success, msg.deschelp, msg.ofs32
   462                              <3>  extern nodesc
   463                              <3> 
   464                              <3>  extern ..@patch_tsr_quit_run, areastruc_entry.qq_entry, cssel
   465                              <3>  extern ddebugareas.next, debug2F, dpmidisable, dpmientry, dpmihook
   466                              <3>  extern dpmihookamis, dpmihookcs, dpmiwatch, end_of_ldebug_code2
   467                              <3>  extern findinstalleddebugger, get_messagesegsel, handle_mode_changed
   468                              <3>  extern i23pm, msg.cannotpmquit, msg.desc, msg.dpmi_no_hook, msg.msdos
   469                              <3>  extern msg.qq_device_pm, msg.qq_still_pm, msg.qqlate_areas_error
   470                              <3>  extern msg.readonly_verifysegm, msg.readonly_verifysegm.selector
   471                              <3>  extern mydpmientry, nodosext, oldi2F, pm_reset_handlers, scratchsel
   472                              <3>  extern sr_state, switchmode, uninstall_areas.qq_entry
   473                              <3> 
   474                              <3>  extern i24pm
   475                              <3> 
   476                              <3>  extern auxbuff_switchbuffer_size, code2_seg, code2_sel, code2_size
   477                              <3>  extern code_sel, daresult, dssel, immsel
   478                              <3>  extern lDEBUG_CODE2_to_lDEBUG_CODE_dualcall_helper
   479                              <3>  extern lDEBUG_CODE_dualret_helper, messagesel, msg.desctype
   480                              <3>  extern msg.stack_overflow.desctype
   481                              <3> 
   482                              <3>  extern cmd3_mirror
   483                              <3> 
   484                              <3>  extern ..@patch_entry_seg, ..@patch_no386_ds_4, ..@patch_no386_ds_5
   485                              <3>  extern ..@patch_no386_ds_entry_pmint21_1
   486                              <3>  extern ..@patch_no386_ds_entry_pmint21_2, areas_fun, areas_sub
   487                              <3>  extern ddebugareas.prev, linkcall_table.code2
   488                              <3> 
   489                              <3>  extern areas_struc, msg.areasalreadyinstalled
   490                              <3>  extern msg.areasalreadyuninstalled, msg.areasinstalled
   491                              <3>  extern msg.areasnodebuggerfound, msg.areasnotinstalled
   492                              <3>  extern msg.areasnotinstalled.code, msg.areasnotsupported
   493                              <3>  extern msg.areasuninstalled, msg.areasuninstalled.code
   494                              <3> 
   495                              <3>  extern intcall_return_parameter_es_parameter_ds
   496                              <3>  extern lDEBUG_CODE_to_lDEBUG_CODE_dualcall_helper, pop_if, push_if
   497                              <3> 
   498                              <3>  extern isextenderavailable, msg.cannotpmload, nodosextinst
   499                              <3> 
   500                              <3>  extern install_areas, patcharea_pm_exc, patcharea_pm_exc.segment
   501                              <3>  extern patcharea_pm_exc.size
   502                              <3> 
   503                              <3>  extern pmint21
   504                              <3> 
   505                              <3>  extern debuggerexception, entry_to_code_sel, exc6msg, excCmsg
   506                              <3>  extern excDmsg, excEmsg, intrtn2_entry, pmintsave.int21
   507                              <3> 
   508                              <3>  extern convsegs, convsegs.amount_fixed, convsegs.end_fixed
   509                              <3>  extern dpmi_pm2rm, dpmi_pmsav, dpmi_rm2pm, dpmi_rmsav, endexctab
   510                              <3>  extern exc_first, exc_second, excsave, exctab, installdpmimsg
   511                              <3>  extern intrtn_entry.from_installdpmi, pmintsave, pminttab
   512                              <3>  extern pminttab.end, setrmaddr, silence_delete_one_string.internal
   513                              <3> 
   514                              <3>  extern msg.rv_mode_dpmi_16, msg.rv_mode_dpmi_32, msg.vm_code2seg
   515                              <3>  extern msg.vm_selector, msg.vp_dpspsel, msg.vp_pspsel, psp_selector
   516                              <3> 
   517                              <3>  extern ..@getcseipbyte_fault_skip_6_near_call
   518                              <3>  extern ..@hh_code1_indirection_memory_access_end
   519                              <3>  extern ..@hh_code1_indirection_memory_access_start
   520                              <3>  extern ..@readmem_fault_skip_2_near_call
   521                              <3>  extern ..@setcseipbyte_fault_skip_6_near_call
   522                              <3>  extern ..@writemem_fault_skip_2_near_call_a
   523                              <3>  extern ..@writemem_fault_skip_2_near_call_b, behind_code
   524                              <3>  extern behind_code2, convsegs.amount, ddebugareas
   525                              <3>  extern getline_extra_int22.cleartraceflag, msg.list_bp_cseip_32
   526                              <3> 
   527                              <3>  extern MN_O16
   528                              <3> 
   529                              <3>  extern MN_A16
   530                              <3> 
   531                              <3>  extern relocatedzero
   532                              <3> 
   533                              <3>  extern msg.bu_disabled
   534                              <3> 
   535                              <3>  extern reset_interrupts, set_interrupts
   536                              <3> 
   537                              <3>  extern startoptions6
   538                              <3> 
   539                              <3>  extern currentposition, msg.loader_bottom_not_allowed
   540                              <3>  extern msg.loader_too_low_load
   541                              <3> 
   542                              <3>  extern intr_loader_18, intr_loader_19, moveloader_hook_ints
   543                              <3> 
   544                              <3>  extern loader_query, loader_transfer_cmd3, loader_transfer_relocate
   545                              <3> 
   546                              <3>  extern cmd3_int_disable.set_bx_to_dx, cmd3_int_enable.set_bx_to_dx
   547                              <3>  extern ldebug_code_size, movesegrefstable, movetable
   548                              <3>  extern movetable.bottom, msg.isalready, msg.isnow, msg.loader_error
   549                              <3>  extern msg.move, msg.move_auxbuff_error, msg.move_auxdown
   550                              <3>  extern msg.move_auxup, msg.move_ebdanottop, msg.move_empty
   551                              <3>  extern msg.move_int_error, msg.move_int_panic
   552                              <3>  extern msg.move_must_be_bottom, msg.move_nottop, msg.move_oom
   553                              <3>  extern msg.move_rpl, msg.move_toolargeebda, msg.unsupportedmove
   554                              <3>  extern qq_int_unhook_sim.set_bx_to_dx
   555                              <3> 
   556                              <3>  extern moveloader.already, moveloader.bottom_to_hidden
   557                              <3>  extern moveloader.bottom_to_top, moveloader.hidden_to_bottom
   558                              <3>  extern moveloader.hidden_to_top, moveloader.top_to_bottom
   559                              <3>  extern moveloader.top_to_hidden
   560                              <3> 
   561                              <3>  extern moveloader.specificerror, moveloader_check_serial, msg.godebug
   562                              <3>  extern msg.loader_extra, msg.loader_flag, msg.loader_loadseg_low
   563                              <3>  extern msg.loader_must_be_hidden, msg.loader_sign, msg.loader_stack
   564                              <3>  extern msg.loadsupportsignature, msg.loadsupportsignature.size
   565                              <3> 
   566                              <3>  extern depack, hshrink_memory_source.offset
   567                              <3>  extern hshrink_memory_source.segment, indirect_hshrink_message_buffer
   568                              <3>  extern msg.hshrink_error, nontruncated_hshrink_message_buffer
   569                              <3> 
   570                              <3>  extern truncated_hshrink_message_buffer
   571                              <3> 
   572                              <3>  extern patch_boothelp_uncompressed
   295                              <2> %endif
   710                              <1> %endif
   711                              <1> [list -]
   714                              <1> 
   715                              <1> %include "eld.mac"
     1                              <2> %if 0
     2                              <2> 
     3                              <2> Extensions for lDebug macros
     4                              <2> 
     5                              <2> Copyright (C) 2008-2025 E. C. Masloch
     6                              <2> 
     7                              <2> Usage of the works is permitted provided that this
     8                              <2> instrument is retained with the works, so that any entity
     9                              <2> that uses the works is notified of this instrument.
    10                              <2> 
    11                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    12                              <2> 
    13                              <2> %endif
    14                              <2> 
    15                              <2> %ifndef ELD_MAC
    16                              <2> %define ELD_MAC 1
    17                              <2> 
    18                              <2> %include "lmacros3.mac"
     1                              <3> [list -]
    19                              <2> 
    20                              <2> 		; ELD executable header
    21                              <2> 	struc ELD_HEADER
    22 00000000 ????????            <2> eldhSignature:		resb 4	; "ELD1"
    23 00000004 ??????              <2> 			resb 3	; reserved
    24 00000007 ??                  <2> 			resb 1	; 26 (Ctrl-Z)
    25 00000008 ????????            <2> eldhCodeOffset:		resd 1	; position displacement from eldhSignature
    26 0000000C ????                <2> eldhCodeImageLength:	resw 1	; amount bytes, at least 32
    27 0000000E ????                <2> eldhCodeAllocLength:	resw 1	; amount bytes, added to prior. sum < 64 KiB
    28 00000010 ????????            <2> eldhDataOffset:		resd 1
    29 00000014 ????                <2> eldhDataImageLength:	resw 1	; (zero allowed)
    30 00000016 ????                <2> eldhDataAllocLength:	resw 1	; (zero allowed)
    31 00000018 ????                <2> eldhCodeEntrypoint:	resw 1	; within code section, used as displacement
    32 0000001A ????????            <2> eldhReserved:		resb 4	; reserved
    33 0000001E ????                <2> eldhExtensionSize:	resw 1	; from eldhSignature, -> past eldhx fields in use
    34                              <2> 	endstruc
    35                              <2> 	endarea ELD_HEADER, 1
    36                              <2> 
    37                              <2> 	struc ELD_HEADERX
    38 00000000 <res 20h>           <2> eldhxHeader:		resb ELD_HEADER_size
    39 00000020 ????????            <2> eldhxDescriptionOffset:	resd 1	; zero if none, from eldhxHeader. <= 128 Bytes
    40 00000024 ????????            <2> eldhxHelpOffset:	resd 1	; zero if none, from eldhxHeader
    41 00000028 ????????            <2> eldhxLibTable:		resd 1	; zero if none, from eldhxHeader
    42 0000002C ????????            <2> eldhxDateTimeOffset:	resd 1	; zero if none, from eldhxHeader
    43                              <2> 	alignb 16
    44                              <2> 	endstruc
    45                              <2> 
    46                              <2> 	struc ELD_TRAILER_HEADER
    47 00000000 ????????????????    <2> eldthSignature:		resb 8	; "ELD1TAIL"
    48 00000008 ????????            <2> eldthHeaderOffset:	resd 1	; negative displacement from eldthSignature,
    49                              <2> 				;  add this dword to the seek offset
    50 0000000C ????                <2> eldthReserved:		resw 1	; reserved, must be initialised to zero
    51 0000000E ????                <2> eldthChecksum:		resw 1	; sum of all words in trailer header = 0
    52                              <2> 	endstruc
    53                              <2> 	endarea ELD_TRAILER_HEADER, 1
    54                              <2> 
    55                              <2> 	struc ELD_LIBTABLE
    56 00000000 ????                <2> eldltFormat:		resw 1
    57                              <2> 	; 0 = uncompressed
    58                              <2> 	; 2 = heatshrink compressed
    59                              <2> 	; 3 = lzexedat -4 compressed
    60                              <2> 	; 4 = lzexedat -4 -l compressed
    61 00000002 ????                <2> eldltAmount:		resw 1
    62 00000004 ????????            <2> eldltOffset:		resd 1	; from eldhxHeader
    63                              <2> eldltCompressedLength:		; (dword, only present if format 2, 3, or 4)
    64                              <2> 	endstruc
    65                              <2> 	endarea ELD_LIBTABLE, 1
    66                              <2> 
    67                              <2> 		; ELD instance header
    68                              <2> 	struc ELD_INSTANCE
    69 00000000 ????                <2> eldiStartCode:		resw 1	; -> this structure itself (para aligned)
    70 00000002 ????                <2> eldiEndCode:		resw 1	; -> behind memory used by instance (para aligned)
    71 00000004 ????                <2> eldiStartData:		resw 1	; -> data in data entry section (para aligned), or 0
    72 00000006 ????                <2> eldiEndData:		resw 1	; -> behind data (para aligned), or 0
    73 00000008 ????????????????    <2> eldiIdentifier:		resb 8	; blank-filled text
    74 00000010 ????                <2> eldiFlags:		resw 1	; flags
    75                              <2> eldiListing_size equ 14
    76 00000012 <res Eh>            <2> eldiListing:		resb eldiListing_size
    77                              <2> 				; ASCIZ listing file name
    78                              <2> 	endstruc
    79                              <2> 		; flags for eldiFlags:
    80                              <2> eldifResident:		equ 1
    81                              <2> 
    82                              <2> 		; ELD link info header
    83                              <2> 	struc ELD_LINKINFO
    84 00000000 ????                <2> eldlSignature:		resw 1	; 0E1D1h
    85 00000002 ????????            <2> eldlReserved:		resw 2
    86 00000006 ????                <2> eldlUseLinkHash:	resw 1
    87 00000008 ????                <2> eldlDataAmount:		resw 1
    88 0000000A ????                <2> eldlDataPrefixes:	resw 1
    89 0000000C ????                <2> eldlDataEntries:	resw 1
    90 0000000E ????                <2> eldlDataAddresses:	resw 1
    91 00000010 ????                <2> eldlCodeAmount:		resw 1
    92 00000012 ????                <2> eldlCodePrefixes:	resw 1
    93 00000014 ????                <2> eldlCodeEntries:	resw 1
    94 00000016 ????                <2> eldlCodeAddresses:	resw 1
    95                              <2> 	endstruc
    96                              <2> 
    97                              <2> 	numdef ELD_CODE_VSTART, 9001h
    98                              <2> 	numdef ELD_DATA_VSTART, 8000h
    99                              <2> 	numdef ELD_RELOC_VSTART, 8000h
   100                              <2> 
   101                              <2> 	numdef ELD_RECLAIM_HINT, 0
   102                              <2> 	strdef ELD_LISTING, ""
   103                              <2> 	numdef ELD_DATETIME, 0
   104                              <2> 
   105                              <2> %if _ELD_DATETIME
   106                              <2>  %define PUT_ELDHX_DATETIME_OFFSET at eldhxDateTimeOffset, dd DATAOFFSET + datetime - datastart
   107                              <2>  %macro PUT_ELD_DATETIME 0.nolist
   108                              <2> datetime:	asciz __UTC_DATE__,'T',__UTC_TIME__,'Z'
   109                              <2> 		asciz		; for future extension
   110                              <2>  %endmacro
   111                              <2> %else
   112                              <2>  %define PUT_ELDHX_DATETIME_OFFSET
   113                              <2>  %define PUT_ELD_DATETIME
   114                              <2> %endif
   115                              <2> 
   116                              <2> %endif
   716                              <1> 
   717                              <1> %include "install.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug INSTALL command macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2023 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 	struc INSTALLFLAG
    17 00000000 ????                <2> ifKeyword:	resw 1
    18 00000002 ????                <2> ifDescription:	resw 1
    19 00000004 ????                <2> ifOptions:	resw 1
    20 00000006 ????                <2> ifValue:	resw 1
    21 00000008 ????                <2> ifTrying:	resw 1
    22 0000000A ????                <2> ifReserved:	resw 1
    23                              <2> 	endstruc
    24                              <2> 
   718                              <1> 
   719                              <1> %if _SYMBOLIC
   720                              <1> 	defaulting 0			; disable defaulting
   721                              <1> %include "symbols.mac"
   722                              <1> [list -]
   723                              <1> 		; symbolic branch defines *without* defaulting!
   724                              <1> 	numdef ZZ_INSERT_TEMP, 1
   725                              <1> 	numdef XMS_SYMBOL_TABLE, 1
   726                              <1> 	numdef BUFFER_86MM_SLICE, 0
   727                              <1> 	numdef SECOND_SLICE, 0
   728                              <1> 
   729                              <1> 	defaulting 1			; re-enable defaulting
   730                              <1> 
   731                              <1> 		; symbolic branch defines
   732                              <1> 	numdef 86MM_SYMBOL_TABLE_MAX, 256, 256
   733                              <1> %endif
   734                              <1> 
   735                              <1> 	struc SEGADR
   736 00000000 ????????            <1> saOffset:	resd 1
   737 00000004 ????                <1> saSegSel:	resw 1
   738                              <1> %if _PM
   739 00000006 ????                <1> saSegment:	resw 1
   740 00000008 ????                <1> saSelector:	resw 1
   741                              <1> %endif
   742                              <1> 	endstruc
   743                              <1> 
   744                              <1> 	%macro segmentedaddress 0.nolist
   745                              <1> 	istruc SEGADR
   746                              <1> 	iend
   747                              <1> 	%endmacro
   748                              <1> 
   749                              <1> 	struc SEGOFS16ADR
   750 00000000 ????                <1> so16aOffset:	resw 1
   751 00000002 ????                <1> so16aSegSel:	resw 1
   752                              <1> %if _PM
   753 00000004 ????                <1> so16aSegment:	resw 1
   754 00000006 ????                <1> so16aSelector:	resw 1
   755                              <1> %endif
   756                              <1> 	endstruc
   757                              <1> 
   758                              <1> 	%macro segofs16address 0-1.nolist zero
   759                              <1> 	istruc SEGOFS16ADR
   760                              <1> %ifidni %1,zero
   761                              <1> %elifidni %1,minusone
   762                              <1> at so16aOffset,		dw -1
   763                              <1> at so16aSegSel,		dw -1
   764                              <1>  %if _PM
   765                              <1> at so16aSegment,	dw -1
   766                              <1> at so16aSelector,	dw -1
   767                              <1>  %endif
   768                              <1> %else
   769                              <1>  %error Unexpected initialiser keyword
   770                              <1> %endif
   771                              <1> 	iend
   772                              <1> 	%endmacro
   773                              <1> 
   774                              <1> 	struc SEGONLYADR
   775 00000000 ????                <1> soaSegSel:	resw 1
   776                              <1> %if _PM
   777 00000002 ????                <1> soaSegment:	resw 1
   778 00000004 ????                <1> soaSelector:	resw 1
   779                              <1> %endif
   780                              <1> 	endstruc
   781                              <1> 
   782                              <1> 	%macro segonlyaddress 0.nolist
   783                              <1> 	istruc SEGONLYADR
   784                              <1> 	iend
   785                              <1> 	%endmacro
   786                              <1> 
   787                              <1> 
   788                              <1> %if _LOADER
   789                              <1> 	struc MOVETABLEENTRY
   790                              <1> mteIdentifier:		resw 1
   791                              <1> mteArrayIndex:		resw 1
   792                              <1> mteStatusMessage:	resw 1
   793                              <1> mteFromArray:
   794                              <1> mteFromBottom:		resw 1
   795                              <1> mteFromTop:		resw 1
   796                              <1> mteFromHidden:		resw 1
   797                              <1> 	endstruc
   798                              <1> %endif
   799                              <1> 
   800                              <1> %if _BOOTLDR
   801                              <1>  %include "iniload.mac"
     1                              <2> %if 0
     2                              <2> 
     3                              <2> lDebug iniload/boot interfacing structs and macros
     4                              <2> 
     5                              <2> Copyright (C) 2008-2025 E. C. Masloch
     6                              <2> 
     7                              <2> Usage of the works is permitted provided that this
     8                              <2> instrument is retained with the works, so that any entity
     9                              <2> that uses the works is notified of this instrument.
    10                              <2> 
    11                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    12                              <2> 
    13                              <2> %endif
    14                              <2> 
    15                              <2> 
    16                              <2> 	struc BS
    17 00000000 ??????              <2> bsJump:	resb 3
    18 00000003 ????????????????    <2> bsOEM:	resb 8
    19                              <2> bsBPB:
    20                              <2> 	endstruc
    21                              <2> 
    22                              <2> 	struc EBPB		;        BPB sec
    23 00000000 ????                <2> bpbBytesPerSector:	resw 1	; offset 00h 0Bh
    24 00000002 ??                  <2> bpbSectorsPerCluster:	resb 1	; offset 02h 0Dh
    25 00000003 ????                <2> bpbReservedSectors:	resw 1	; offset 03h 0Eh
    26 00000005 ??                  <2> bpbNumFATs:		resb 1	; offset 05h 10h
    27 00000006 ????                <2> bpbNumRootDirEnts:	resw 1	; offset 06h 11h -- 0 for FAT32
    28 00000008 ????                <2> bpbTotalSectors:	resw 1	; offset 08h 13h
    29 0000000A ??                  <2> bpbMediaID:		resb 1	; offset 0Ah 15h
    30 0000000B ????                <2> bpbSectorsPerFAT:	resw 1	; offset 0Bh 16h -- 0 for FAT32
    31 0000000D ????                <2> bpbCHSSectors:		resw 1	; offset 0Dh 18h
    32 0000000F ????                <2> bpbCHSHeads:		resw 1	; offset 0Fh 1Ah
    33 00000011 ????????            <2> bpbHiddenSectors:	resd 1	; offset 11h 1Ch
    34 00000015 ????????            <2> bpbTotalSectorsLarge:	resd 1	; offset 15h 20h
    35                              <2> bpbNew:				; offset 19h 24h
    36                              <2> 
    37 00000019 ????????            <2> ebpbSectorsPerFATLarge:	resd 1	; offset 19h 24h
    38 0000001D ????                <2> ebpbFSFlags:		resw 1	; offset 1Dh 28h
    39 0000001F ????                <2> ebpbFSVersion:		resw 1	; offset 1Fh 2Ah
    40 00000021 ????????            <2> ebpbRootCluster:	resd 1	; offset 21h 2Ch
    41 00000025 ????                <2> ebpbFSINFOSector:	resw 1	; offset 25h 30h
    42 00000027 ????                <2> ebpbBackupSector:	resw 1	; offset 27h 32h
    43 00000029 <res Ch>            <2> ebpbReserved:		resb 12	; offset 29h 34h
    44                              <2> ebpbNew:			; offset 35h 40h
    45                              <2> 	endstruc
    46                              <2> 
    47                              <2> 	struc BPBN		; ofs B16 S16 B32 S32
    48 00000000 ??                  <2> bpbnBootUnit:		resb 1	; 00h 19h 24h 35h 40h
    49 00000001 ??                  <2> 			resb 1	; 01h 1Ah 25h 36h 41h
    50 00000002 ??                  <2> bpbnExtBPBSignature:	resb 1	; 02h 1Bh 26h 37h 42h -- 29h for valid BPBN
    51 00000003 ????????            <2> bpbnSerialNumber:	resd 1	; 03h 1Ch 27h 38h 43h
    52 00000007 <res Bh>            <2> bpbnVolumeLabel:	resb 11	; 07h 20h 2Bh 3Ch 47h
    53 00000012 ????????????????    <2> bpbnFilesystemID:	resb 8	; 12h 2Bh 36h 47h 52h
    54                              <2> 	endstruc		; 1Ah 33h 3Eh 4Fh 5Ah
    55                              <2> 
    56                              <2> 	struc DIRENTRY
    57 00000000 ????????????????    <2> deName:		resb 8
    58 00000008 ??????              <2> deExt:		resb 3
    59 0000000B ??                  <2> deAttrib:	resb 1
    60 0000000C ??                  <2> dePlusSize:	resb 1
    61 0000000D ??????????????      <2> 		resb 7
    62 00000014 ????                <2> deClusterHigh:	resw 1
    63 00000016 ????                <2> deTime:		resw 1
    64 00000018 ????                <2> deDate:		resw 1
    65 0000001A ????                <2> deClusterLow:	resw 1
    66 0000001C ????????            <2> deSize:		resd 1
    67                              <2> 	endstruc
    68                              <2> 
    69                              <2> ATTR_READONLY	equ 1
    70                              <2> ATTR_HIDDEN	equ 2
    71                              <2> ATTR_SYSTEM	equ 4
    72                              <2> ATTR_VOLLABEL	equ 8
    73                              <2> ATTR_DIRECTORY	equ 10h
    74                              <2> ATTR_ARCHIVE	equ 20h
    75                              <2> 
    76                              <2> lsvclSignature		equ "CL"
    77                              <2> lsvclBufferLength	equ 256
    78                              <2> 
    79                              <2> 	struc LOADSTACKVARS, -10h
    80 FFFFFFF0 ????????            <2> lsvFirstCluster:	resd 1
    81 FFFFFFF4 ????????            <2> lsvFATSector:		resd 1
    82 FFFFFFF8 ????                <2> lsvFATSeg:		resw 1
    83 FFFFFFFA ????                <2> lsvLoadSeg:		resw 1
    84 FFFFFFFC ????????            <2> lsvDataStart:		resd 1
    85                              <2> 	endstruc
    86                              <2> 
    87                              <2> 	struc LOADDATA, LOADSTACKVARS - 10h
    88 FFFFFFE0 ????                <2> ldMemoryTop:	resw 1
    89 FFFFFFE2 ????                <2> ldLoadTop:	resw 1
    90 FFFFFFE4 ????                <2> ldSectorSeg:	resw 1
    91 FFFFFFE6 ??                  <2> ldFATType:	resb 1
    92                              <2> ldFlags:
    93 FFFFFFE7 ??                  <2> ldHasLBA:	resb 1
    94 FFFFFFE8 ????                <2> ldClusterSize:	resw 1
    95 FFFFFFEA ????                <2> ldParaPerSector:resw 1
    96                              <2> ldDirCluster:			; dword
    97                              <2> ldLoadingSeg:		; word
    98                              <2> ldQueryPatchValue:	; word
    99                              <2> lsvCommandLine:		; word
   100                              <2> .start:		equ $ - lsvclBufferLength
   101 FFFFFFEC ????                <2> .signature:	resw 1
   102                              <2> ldLoadUntilSeg:		; word
   103                              <2> lsvExtra:		; word
   104 FFFFFFEE ??                  <2> .partition:	resb 1	; byte
   105 FFFFFFEF ??                  <2> .flags:		resb 1	; byte
   106                              <2> 	endstruc
   107                              <2> 
   108                              <2> ldhlfPreserveLoader	equ 4
   109                              <2> 
   110                              <2> lsvefNoDataStart	equ 1
   111                              <2> lsvefPartitionNumber	equ 2
   112                              <2> lsvefPreserveLoader	equ 4
   113                              <2> 
   114                              <2> %if lsvefPreserveLoader != ldhlfPreserveLoader
   115                              <2>  %error Unexpected flag values
   116                              <2> %endif
   117                              <2> 
   118                              <2> 	struc LOADCMDLINE, LOADDATA - lsvclBufferLength
   119                              <2> ldCommandLine:
   120 FFFFFEE0 <res 100h>          <2> .start:		resb lsvclBufferLength
   121                              <2> 	endstruc
   122                              <2> 
   123                              <2> ldfHasLBA:	equ 1
   124                              <2> ldfFATInvalid:	equ 2
   125                              <2> ldfFATBuffered:	equ 4
   126                              <2> ldfDataBuffered: equ 8
   127                              <2> 
   128                              <2> 	struc LOADDATA2, LOADDATA - 10h
   129 FFFFFFD0 ????????            <2> ldRootSector:		resd 1
   130 FFFFFFD4 ????                <2> ldEntriesPerSector:	resw 1
   131                              <2> ldDataSegment:		; word
   132 FFFFFFD6 ????                <2> ldLastAvailableSector:	resw 1
   133                              <2> ldDataSector:		; dword
   134 FFFFFFD8 ????                <2> ldParasLeft:		resw 1
   135 FFFFFFDA ????                <2> ldParasDone:		resw 1
   136                              <2> 	endstruc
   137                              <2> 
   138                              <2> 	struc LOADDATA3, LOADDATA2 - 10h
   139 FFFFFFC0 ????????            <2> ldMaxCluster:		resd 1
   140 FFFFFFC4 ????????            <2> ldFileSize:		resd 1
   141 FFFFFFC8 ????????            <2> ldCurrentCluster:	resd 1
   142 FFFFFFCC ????????            <2> ldCurrentSeek:		resd 1
   143                              <2> 	endstruc
   144                              <2> 
   145                              <2> 	struc LOADERIMAGEIDENT
   146 00000000 ????????            <2> liiSignature:		resb 4		; "NLDR"
   147 00000004 ????                <2> liiVersion:		resb 2		; "00"
   148 00000006 ????                <2> liiChecksum:		resw 1		; word sum of first 8 words = 0
   149 00000008 ????                <2> liiAmountParagraphs:	resw 1
   150 0000000A ????????????        <2> liiReserved:		resw 3
   151 00000010 ????                <2> liiEntryQuerySize:	resw 1		; 0 if not supported
   152                              <2> 		; INP:	cs => NLDR image ident
   153                              <2> 		;	ip = this word field content
   154                              <2> 		;	ax = 60h
   155                              <2> 		; OUT:	ax => behind memory requested (should be >= 60h)
   156                              <2> 		; CHG:	es, ds, di, si, bx, cx, dx
   157                              <2> 		; STT:	far called, UP, EI
   158 00000012 ????                <2> liiEntryRelocate:	resw 1		; 0 if not supported
   159                              <2> 		; INP:	cs => NLDR image ident
   160                              <2> 		;	ip = this word field content
   161                              <2> 		;	ax = 60h
   162                              <2> 		; OUT:	ax => relocated NLDR segment (usually 60h)
   163                              <2> 		; CHG:	es, ds, di, si, bx, cx, dx
   164                              <2> 		; STT:	far called, UP, EI
   165 00000014 ????                <2> liiEntryDebug:		resw 1		; 0 if not supported
   166                              <2> 		; INP:	es = ds = cs = ss => relocated NLDR
   167                              <2> 		;	ip = this word field content
   168                              <2> 		;	sp = next word field content
   169                              <2> 		; STT:	running as debuggee, UP, EI
   170 00000016 ????                <2> liiStackPointer:	resw 1
   171                              <2> 	endstruc
   172                              <2> 
   173                              <2> 	struc LBAPACKET
   174 00000000 ????                <2> lpSize:		resw 1
   175 00000002 ????                <2> lpCount:	resw 1
   176 00000004 ????????            <2> lpBuffer:	resd 1
   177 00000008 ????????????????    <2> lpSector:	resq 1
   178                              <2> 	endstruc
   179                              <2> 
   180                              <2> 	struc PARTINFO
   181 00000000 ??                  <2> piBoot:		resb 1
   182 00000001 ??????              <2> piStartCHS:	resb 3
   183 00000004 ??                  <2> piType:		resb 1
   184 00000005 ??????              <2> piEndCHS:	resb 3
   185 00000008 ????????            <2> piStart:	resd 1
   186 0000000C ????????            <2> piLength:	resd 1
   187                              <2> 	endstruc
   188                              <2> 
   189                              <2> ptEmpty:		equ 0
   190                              <2> ptFAT12:		equ 1
   191                              <2> ptFAT16_16BIT_CHS:	equ 4
   192                              <2> ptExtendedCHS:		equ 5
   193                              <2> ptFAT16_CHS:		equ 6
   194                              <2> ptFAT32_CHS:		equ 0Bh
   195                              <2> ptFAT32:		equ 0Ch
   196                              <2> ptFAT16:		equ 0Eh
   197                              <2> ptExtended:		equ 0Fh
   198                              <2> ptLinux:		equ 83h
   199                              <2> ptExtendedLinux:	equ 85h
   200                              <2> 
   201                              <2> 
   202                              <2> 		; Flags of load_unit_flags
   203                              <2> lufForceCHS:		equ 1
   204                              <2> lufForceLBA:		equ 2
   205                              <2> lufForceGeometry:	equ 4
   206                              <2> luf_mask_writable equ lufForceCHS | lufForceLBA | lufForceGeometry
   802                              <1> 
   803                              <1> LOAD_INPUT_FILE_SIZE equ fromparas(paras(-LOADDATA3 + bsBPB + ebpbNew + BPBN_size))
   804                              <1> 
   805                              <1> 	struc LOADSETTINGS
   806 00000000 ????                <1> lsKernelName:	resw 1	; -> kernel file default name
   807 00000002 ????                <1> lsAddName:	resw 1	; -> additional file default name, may be empty string
   808 00000004 ????                <1> lsMinPara:	resw 1	; how much to load at least, fail if file smaller
   809 00000006 ????                <1> lsMaxPara:	resw 1	; how much to load at most (will round up to sector size)
   810 00000008 ????                <1> lsOptions:	resw 1	; option flags
   811 0000000A ????                <1> lsSegment:	resw 1	; => where to load file
   812 0000000C ????????            <1> lsEntry:	resd 1	; relative segment for CS, value for IP
   813 00000010 ????????            <1> lsBPB:		resd 1	; segment for BPB (-1 auto-BPB), offset for BPB
   814 00000014 ????                <1> lsCheckOffset:	resw 1	; offset in file segment of word to check
   815 00000016 ????                <1> lsCheckValue:	resw 1	; value to check for word, 0 if unused
   816 00000018 ????????????????    <1> lsName:		resq 1	; ASCIZ load protocol name
   817                              <1> 	endstruc
   818                              <1> 
   819                              <1> 		numdef LUF_DEFAULT_DISKETTE, 0
   820                              <1> 		numdef LUF_DEFAULT_HARDDISK, 0
   821                              <1> %endif
   822                              <1> 
   823                              <1> 
   824                              <1> %include "mzheader.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug MZ .EXE header macros
     5                              <2> 
     6                              <2> Copyright (C) 1995-2003 Paul Vojta
     7                              <2> Copyright (C) 2008-2023 E. C. Masloch
     8                              <2> 
     9                              <2> Usage of the works is permitted provided that this
    10                              <2> instrument is retained with the works, so that any entity
    11                              <2> that uses the works is notified of this instrument.
    12                              <2> 
    13                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    14                              <2> 
    15                              <2> %endif
    16                              <2> 
    17                              <2> 
    18                              <2> 	struc EXEHEADER
    19 00000000 ????                <2> exact_struc_at 00h, exeSignature:	resw 1
    20 00000002 ????                <2> exact_struc_at 02h, exeExtraBytes:	resw 1	; bytes in last page
    21 00000004 ????                <2> exact_struc_at 04h, exePages:		resw 1	; number of 512-byte pages. includes the header!
    22 00000006 ????                <2> exact_struc_at 06h, exeRelocItems:	resw 1	; number of relocation items
    23 00000008 ????                <2> exact_struc_at 08h, exeHeaderSize:	resw 1	; header size in 16-byte paragraphs
    24 0000000A ????                <2> exact_struc_at 0Ah, exeMinAlloc:	resw 1	; minimum (bss) allocation in paragraphs
    25 0000000C ????                <2> exact_struc_at 0Ch, exeMaxAlloc:	resw 1	; maximum (bss) allocation in paragraphs
    26 0000000E ????                <2> exact_struc_at 0Eh, exeInitSS:		resw 1	; init ss (is relocated)
    27 00000010 ????                <2> exact_struc_at 10h, exeInitSP:		resw 1	; init sp
    28 00000012 ????                <2> exact_struc_at 12h, exeChecksum:	resw 1
    29                              <2> exact_struc_at 14h, exeInitCSIP:
    30 00000014 ????                <2> exact_struc_at 14h, exeInitIP:		resw 1	; init ip
    31 00000016 ????                <2> exact_struc_at 16h, exeInitCS:		resw 1	; init cs (is relocated)
    32 00000018 ????                <2> exact_struc_at 18h, exeRelocTable:	resw 1	; byte offset of relocation table
    33                              <2> 		; Each relocation item is a word offset and a word segment.
    34                              <2> 		;  The segment of the item itself is relocated as well.
    35 0000001A ????                <2> exact_struc_at 1Ah, exeOverlayNum:	resw 1
    36                              <2> exact_struc_at 1Ch
    37                              <2> 	endstruc
   825                              <1> 
   826                              <1> 
   827                              <1> 	struc INPUTFILEHANDLE
   828 00000000 ????                <1> ifhHandle:	resw 1
   829 00000002 ????                <1> ifhFlags:	resw 1
   830 00000004 ????????            <1> ifhParentSeek:	resd 1
   831                              <1> 	endstruc
   832                              <1> 
   833                              <1> ifhfIsDup:		equ  100h	; before closing, seek it back
   834                              <1> 	; same value as LBA flag for boot load input files
   835                              <1> ifhfTestReserved1:	equ 1000h
   836                              <1> ifhfTestReserved2:	equ 2000h
   837                              <1> ifhfQuietInput:		equ 4000h	; do not display prompt and input
   838                              <1> ifhfQuietOutput:	equ 8000h	; do not display normal output
   839                              <1> 	; these four are valid for both input file handles and
   840                              <1> 	;  boot load input files.
   841                              <1> 
   842                              <1> 
   843                              <1> 	struc AREASTRUC
   844 00000000 <res 18h>           <1> areastrucEntry:		resb 24
   845 00000018 ????????            <1> areastrucNext:		resd 1
   846 0000001C ????????            <1> areastrucPrev:		resd 1
   847 00000020 ????                <1> areastrucSubAmount:	resw 1
   848 00000022 ????                <1> areastrucSubOffset:	resw 1
   849 00000024 ????                <1> areastrucFunAmount:	resw 1
   850 00000026 ????                <1> areastrucFunOffset:	resw 1
   851                              <1> 	endstruc
   852                              <1> 
   853                              <1> 	struc AREASTRUCSUB
   854 00000000 ????????            <1> areastrucsubLinear:	resd 1
   855 00000004 ????????            <1> areastrucsubLinearEnd:	resd 1
   856 00000008 ????                <1> areastrucsubListOffset:	resw 1
   857 0000000A ????                <1> areastrucsubListAmount:	resw 1
   858                              <1> 	endstruc
   859                              <1> 
   860                              <1> 	struc AREASTRUCFUN
   861 00000000 ????????            <1> areastrucfunLinear:	resd 1
   862 00000004 ????????            <1> areastrucfunLinearEnd:	resd 1
   863 00000008 ????                <1> areastrucfunListOffset:	resw 1
   864 0000000A ????                <1> areastrucfunListAmount:	resw 1
   865                              <1> 	endstruc
   866                              <1> 
   867                              <1> 	struc AREA
   868 00000000 ????                <1> areastart:		resw 1
   869 00000002 ????                <1> areaend:		resw 1
   870 00000004 ????                <1> areamessage:		resw 1
   871 00000006 ????                <1> 			resw 1
   872                              <1> 	endstruc
   873                              <1> 
   874                              <1> 
   875                              <1> %include "isvariab.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug isvariable? function strutures and macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2025 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 
    17                              <2> 	struc ISVARIABLESTRUC
    18 00000000 ????                <2> ivName:		resw 1		; -> name (up to 13 bytes, but actually only 11)
    19                              <2> 				;  (search for ivfNameLengthLimit for limit)
    20                              <2> 				;  (length given by ivFlags & ivfNameLengthMask)
    21                              <2> 	; The ivName pointer is only used for more-byte names. It actually
    22                              <2> 	;  contains the trailer of the name, excluding the prefix formed by
    23                              <2> 	;  the first two bytes. This suffix can be the empty string if the
    24                              <2> 	;  variable in question has a two-byte name.
    25                              <2> 	; (For one-byte names this field is unused and contains zero.)
    26 00000002 ????                <2> ivFlags:	resw 1
    27 00000004 ????                <2> ivAddress:	resw 1		; default -> variable
    28                              <2> 	; The ivAddress field is used by default_variable_setup as the base
    29                              <2> 	;  address for the variable(s). It is also used by var_ext_setup as
    30                              <2> 	;  the ELD code section offset to transfer control to. Otherwise, it
    31                              <2> 	;  is usually set to zero and unused.
    32 00000006 ????                <2> ivSetup:	resw 1		; -> set up code (in expr code section)
    33                              <2> 	; INP:	ax = array index (0-based)
    34                              <2> 	;	di = 0
    35                              <2> 	;	cl = default size of variable (1..4)
    36                              <2> 	;	ch = length of variable name
    37                              <2> 	;	bx -> ISVARIABLESTRUC structure
    38                              <2> 	; CHG:	ax, bx, cx, dx, si, di
    39                              <2> 	; OUT:	NC if valid,
    40                              <2> 	;	 bx -> var, di = 0 or di -> mask
    41                              <2> 	;	 cl = size of variable (1..4)
    42                              <2> 	;	 ch = length of variable name
    43 00000008 ??                  <2> ivArrayLast:	resb 1		; 0 if no array, FFh = 256 entries
    44                              <2> 	; The ivArrayLast field is used by the dispatcher to determine
    45                              <2> 	;  whether to support array index expressions. It is checked
    46                              <2> 	;  before decrementing the index if ivfArrayOneBased is set.
    47 00000009 ??                  <2> ivArrayBetween: resb 1		; how many bytes to skip for each index
    48                              <2> 	; The ivArrayBetween field is only used by default_variable_setup.
    49                              <2> 	endstruc
    50                              <2> 
    51                              <2> ivfNameLengthMask:	equ 15	; gives name trailer length, 0 to 11
    52                              <2> ivfNameLengthLimit:	equ 13
    53                              <2> ivfVarLengthShift:	equ 4
    54                              <2> ivfVarLengthMask:	equ 3 << ivfVarLengthShift
    55                              <2> 				; gives default variable size minus 1
    56                              <2> ivfReadOnly:		equ 80h	; variable cannot be written at all
    57                              <2> ivfArrayOneBased:	equ 100h; first array entry is 1 not 0 (ivArrayLast > 0)
    58                              <2> ivfArrayOptional:	equ 200h; array index expression is optional
    59                              <2> ivfSeparatorSpecial:	equ 400h; used for RIxxP/L/S/O
    60                              <2> 
    61                              <2> %define ISVARIABLESTRINGS db "",db ""
    62                              <2> %define IVS_ONEBYTE_NAMES ""
    63                              <2> %define IVS_MOREBYTE_NAMEHEADERS ""
    64                              <2> %assign IVS_HAVE_ONEBYTE 0
    65                              <2> %assign IVS_SINGLE_ONEBYTE 1
    66                              <2> 
    67                              <2> 		; %1 = name string
    68                              <2> 		; %2 = default variable length, 1 to 4
    69                              <2> 		; %3 = flags to set (except name length and var length)
    70                              <2> 		; %4 = ivAddress value
    71                              <2> 		; %5 = ivArrayLast, defaults to 0 (no array)
    72                              <2> 		; %6 = ivArrayBetween, defaults to 0 (immediately consecutive)
    73                              <2> 		; %7 = ivSetup, defaults to default_variable_setup
    74                              <2> 	%macro isvariablestruc 4-7.nolist 0, 0, default_variable_setup
    75                              <2> %push
    76                              <2> %strlen %$namelength %1
    77                              <2> %if %$namelength > ivfNameLengthLimit
    78                              <2>  %error Expected at most 13-byte name (or adjust isvariable? code)
    79                              <2> %endif
    80                              <2> %if IVS_ONEBYTE && %$namelength != 1
    81                              <2>  %error Expected a one-byte name
    82                              <2> %elif ! IVS_ONEBYTE && %$namelength < 2
    83                              <2>  %error Expected at least a two-byte name
    84                              <2> %endif
    85                              <2> %if IVS_ONEBYTE
    86                              <2>  %define IVS_SINGLE_ONEBYTE_NAME %1
    87                              <2>  %if IVS_HAVE_ONEBYTE
    88                              <2>   %assign IVS_SINGLE_ONEBYTE 0
    89                              <2>  %endif
    90                              <2>  %assign IVS_HAVE_ONEBYTE 1
    91                              <2>  %assign %$namelength 0
    92                              <2>  %xdefine IVS_ONEBYTE_NAMES IVS_ONEBYTE_NAMES, %1
    93                              <2>  %%name equ 0
    94                              <2> %else
    95                              <2>  %assign %$namelength %$namelength - 2
    96                              <2>  %substr %$nametrailer %1 3,-1
    97                              <2>  %substr %$nameheader %1 1,2
    98                              <2>  %xdefine IVS_MOREBYTE_NAMEHEADERS IVS_MOREBYTE_NAMEHEADERS, %$nameheader
    99                              <2>  %xdefine ISVARIABLESTRINGS ISVARIABLESTRINGS, %%name:, {db %$nametrailer}
   100                              <2> %endif
   101                              <2> 
   102                              <2> %assign %$varlength %2 - 1	; 0 means one byte, 1 means two bytes,
   103                              <2> 				;  2 means three bytes, 3 means four bytes
   104                              <2> 	istruc ISVARIABLESTRUC
   105                              <2> at ivName,		dw %%name
   106                              <2>  IV_NAME_RELOCATION
   107                              <2> at ivFlags,		dw %$$namelength | (%$$varlength << ivfVarLengthShift) | %3
   108                              <2> at ivAddress,		dw %4
   109                              <2>  IV_ADDRESS_RELOCATION
   110                              <2> at ivSetup,		dw %7
   111                              <2>  IV_SETUP_RELOCATION
   112                              <2> at ivArrayLast,		db %5
   113                              <2> at ivArrayBetween,	db %6
   114                              <2> 	iend
   115                              <2> %pop
   116                              <2> %ifndef SECTION_OF_%7
   117                              <2>  %error Unknown target section for symbol %7
   118                              <2> %elifnidni %[SECTION_OF_%7], _EXPR_SECTION
   119                              <2>  %error Wrong section for symbol %7: section_of=SECTION_OF_%7, expr=_EXPR_SECTION
   120                              <2> %endif
   121                              <2> 	%endmacro
   122                              <2> 
   123                              <2> %define IV_NAME_RELOCATION
   124                              <2> %define IV_ADDRESS_RELOCATION
   125                              <2> %define IV_SETUP_RELOCATION
   126                              <2> 
   127                              <2> 	%macro isvariablestrings 2-*.nolist
   128                              <2> %rep %0
   129                              <2>  %1
   130                              <2>  %rotate 1
   131                              <2> %endrep
   132                              <2> 	%endmacro
   876                              <1> 
   877                              <1> 
   878                              <1> %include "386.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug 386 patch macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2026 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 	numdef LINK, 0
    17                              <2> 
    18                              <2> 	numdef WPT_LABELS, 0
    19                              <2> 		; This used to be required, because CODESECTIONFIXUP used
    20                              <2> 		;  ldebug_data_entry_size, which is not yet defined during
    21                              <2> 		;  assembling of (most) lDEBUG_CODE fragments.
    22                              <2> 		; However, assembling DebugX with this option selected
    23                              <2> 		;  took more than 2 minutes, so the non-label variant
    24                              <2> 		;  is clearly to be preferred when available.
    25                              <2> 		; Now that lDEBUG_CODE has vstart=0 we can use the
    26                              <2> 		;  CODESECTIONFIXUP again and thus disable this option.
    27                              <2> 
    28                              <2> %ifn _LINK
    29                              <2> %define PATCH_NO386_TABLE ""
    30                              <2> %define PATCH_386_TABLE ""
    31                              <2> %define PATCH_NO386_TABLE2 ""
    32                              <2> %define PATCH_386_TABLE2 ""
    33                              <2> %define PATCH_NO386_TABLEENTRY ""
    34                              <2> %define PATCH_386_TABLEENTRY ""
    35                              <2> %endif
    36                              <2> 
    37                              <2> %if _ONLY386
    38                              <2> 		; Default patch macros if only running on 386+.
    39                              <2> %define _386_o32 o32
    40                              <2> %define _386_a32 a32
    41                              <2> %define _386_jmps jmp short
    42                              <2> %define _386_jmpn jmp near
    43                              <2> %define _no386_jmps comment
    44                              <2> %define _no386_jmpn comment
    45                              <2> 	%macro _386 0-1+.nolist
    46                              <2> [cpu 386]			; change CPU type
    47                              <2> 		%1		; write instruction
    48                              <2> __CPU__				; reset CPU type
    49                              <2> 	%endmacro
    50                              <2> %define _no386 comment
    51                              <2> %elif _ONLYNON386
    52                              <2> 		; Default patch macros if only running on non-386.
    53                              <2> %define _386_o32
    54                              <2> %define _386_a32
    55                              <2> %define _386_jmps comment
    56                              <2> %define _386_jmpn comment
    57                              <2> %define _no386_jmps jmp short
    58                              <2> %define _no386_jmpn jmp near
    59                              <2> %define _386 comment
    60                              <2> %define _no386
    61                              <2> %else
    62                              <2> 
    63                              <2> ; These macros are to make DEBUG's 386 support as small as
    64                              <2> ; possible. To achieve this, two patch tables are created
    65                              <2> ; in the initialisation code. One of the tables is used if
    66                              <2> ; the CPU is a 386+, the other one if it isn't. The bytes
    67                              <2> ; pointed to in the used table are over-written with NOP
    68                              <2> ; instructions. (The patched bytes are usually address or
    69                              <2> ; operand size prefixes or jumps that branch to 386/non-386
    70                              <2> ; code.)
    71                              <2> 
    72                              <2> ; There are a few special patches that require the
    73                              <2> ; initialisation code to write specific bytes other than
    74                              <2> ; NOP instructions for lower resident memory usage.
    75                              <2> ; Two are in the run: code, three in pmentry.asm.
    76                              <2> 
    77                              <2> %if _LINK
    78                              <2> 
    79                              <2> %imacro wllist 1-3.nolist
    80                              <2> %ifnempty %3
    81                              <2>  %deftok %%filenametoken %3
    82                              <2> %else
    83                              <2>  %deftok %%filenametoken __FILE__
    84                              <2> %endif
    85                              <2>  global ..@wllist_%1?%[%%l]%[%%filenametoken]
    86                              <2> ..@wllist_%1?%[%%l]%[%%filenametoken]: %2
    87                              <2> %endmacro
    88                              <2> 
    89                              <2> 	%macro patch386 2-3.nolist 1
    90                              <2> %define %%repeat
    91                              <2> %if %3 != 1
    92                              <2>  %define %%repeat r%3_
    93                              <2> %endif
    94                              <2> %ifidn _CURRENT_SECTION, lDEBUG_CODE
    95                              <2>  wllist %[%%repeat]Lpatch_%{1}386_table, %2
    96                              <2> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
    97                              <2>  wllist %[%%repeat]Lpatch_%{1}386_table2, %2
    98                              <2> %elifidn _CURRENT_SECTION, lDEBUG_DATA_ENTRY
    99                              <2>  wllist %[%%repeat]Lpatch_%{1}386_tableentry, %2
   100                              <2> %else
   101                              <2>  %error Wrong section
   102                              <2> %endif
   103                              <2> 	%endmacro
   104                              <2> 
   105                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   106                              <2> 	%macro _386_o32 0-1+.nolist
   107                              <2> _386		o32
   108                              <2> 		%1
   109                              <2> 	%endmacro
   110                              <2> 
   111                              <2> 		; Address size 32-bit prefix if 386+ CPU
   112                              <2> 	%macro _386_a32 0-1+.nolist
   113                              <2> _386		a32
   114                              <2> 		%1
   115                              <2> 	%endmacro
   116                              <2> 
   117                              <2> 		; Short jump if 386+ CPU
   118                              <2> 	%macro _386_jmps 1.nolist
   119                              <2> _386		jmp short %1
   120                              <2> 	%endmacro
   121                              <2> 
   122                              <2> 		; Near jump if 386+ CPU
   123                              <2> 	%macro _386_jmpn 1.nolist
   124                              <2> _386		jmp near %1
   125                              <2> 	%endmacro
   126                              <2> 
   127                              <2> 		; Short jump if no 386+ CPU
   128                              <2> 	%macro _no386_jmps 1.nolist
   129                              <2> _no386		jmp short %1
   130                              <2> 	%endmacro
   131                              <2> 
   132                              <2> 		; Near jump if no 386+ CPU
   133                              <2> 	%macro _no386_jmpn 1.nolist
   134                              <2> _no386		jmp near %1
   135                              <2> 	%endmacro
   136                              <2> 
   137                              <2> 		; Instruction if 386+ CPU
   138                              <2> 	%macro _386 0-1+.nolist
   139                              <2> [cpu 386]			; change CPU type
   140                              <2> %%entry:
   141                              <2> 		%1		; write instruction
   142                              <2> __CPU__				; reset CPU type
   143                              <2> %assign %%length ($ - %%entry)
   144                              <2>  patch386 no, equ %%entry, %%length
   145                              <2> 	%endmacro
   146                              <2> 
   147                              <2> 		; Instruction if no 386+ CPU
   148                              <2> 	%macro _no386 0-1+.nolist
   149                              <2> %%entry:
   150                              <2> 		%1		; write instruction
   151                              <2> %assign %%length ($ - %%entry)
   152                              <2>  patch386 , equ %%entry, %%length
   153                              <2> 	%endmacro
   154                              <2> 
   155                              <2> %else
   156                              <2> 	%macro patch386 2+.nolist
   157                              <2> %ifidn _CURRENT_SECTION, lDEBUG_CODE
   158                              <2>  %define PATCH_%{1}386_TABLE %[PATCH_%{1}386_TABLE], %2
   159                              <2> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
   160                              <2>  %define PATCH_%{1}386_TABLE2 %[PATCH_%{1}386_TABLE2], %2
   161                              <2> %elifidn _CURRENT_SECTION, lDEBUG_DATA_ENTRY
   162                              <2>  %define PATCH_%{1}386_TABLEENTRY %[PATCH_%{1}386_TABLEENTRY], %2
   163                              <2> %else
   164                              <2>  %error Wrong section
   165                              <2> %endif
   166                              <2> 	%endmacro
   167                              <2> 
   168                              <2> %if _WPT_LABELS
   169                              <2> 	; These forms provide verbose info by defining a
   170                              <2> 	; meaningful label for each patch. That fills up
   171                              <2> 	; the map file and might take longer though.
   172                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   173                              <2> 	%macro _386_o32 0-1+.nolist
   174                              <2> %%386_o32:	o32
   175                              <2> patch386 NO, %%386_o32
   176                              <2> 		%1
   177                              <2> 	%endmacro
   178                              <2> 
   179                              <2> 		; Address size 32-bit prefix if 386+ CPU
   180                              <2> 	%macro _386_a32 0-1+.nolist
   181                              <2> %%386_a32:	a32
   182                              <2> patch386 NO, %%386_a32
   183                              <2> 		%1
   184                              <2> 	%endmacro
   185                              <2> 
   186                              <2> 		; Short jump if 386+ CPU
   187                              <2> 	%macro _386_jmps 1.nolist
   188                              <2> %%386_jmps:	jmp short %1
   189                              <2> patch386 NO, %%386_jmps,%%386_jmps+1
   190                              <2> 	%endmacro
   191                              <2> 
   192                              <2> 		; Near jump if 386+ CPU
   193                              <2> 	%macro _386_jmpn 1.nolist
   194                              <2> %%386_jmpn:	jmp near %1
   195                              <2> patch386 NO, %%386_jmpn,%%386_jmpn+1,%%386_jmpn+2
   196                              <2> 	%endmacro
   197                              <2> 
   198                              <2> 		; Short jump if no 386+ CPU
   199                              <2> 	%macro _no386_jmps 1.nolist
   200                              <2> %%no386_jmps:	jmp short %1
   201                              <2> patch386 , %%no386_jmps,%%no386_jmps+1
   202                              <2> 	%endmacro
   203                              <2> 
   204                              <2> 		; Near jump if no 386+ CPU
   205                              <2> 	%macro _no386_jmpn 1.nolist
   206                              <2> %%no386_jmpn:	jmp near %1
   207                              <2> patch386 , %%no386_jmpn,%%no386_jmpn+1,%%no386_jmpn+2
   208                              <2> 	%endmacro
   209                              <2> 
   210                              <2> 		; Instruction if 386+ CPU
   211                              <2> 	%macro _386 0-1+.nolist
   212                              <2> [cpu 386]			; change CPU type
   213                              <2> %%386_instr:	%1		; write instruction
   214                              <2> __CPU__				; reset CPU type
   215                              <2> 
   216                              <2> %assign %%INSTRCOUNT 0
   217                              <2> %rep $-%%386_instr		; count size of instruction
   218                              <2>  patch386 NO, %%386_instr+%[%%INSTRCOUNT]
   219                              <2> 				; write a patch for each byte
   220                              <2>  %assign %%INSTRCOUNT %%INSTRCOUNT+1
   221                              <2> %endrep
   222                              <2> %undef %%INSTRCOUNT
   223                              <2> 	%endmacro
   224                              <2> 
   225                              <2> 		; Instruction if no 386+ CPU
   226                              <2> 	%macro _no386 0-1+.nolist
   227                              <2> %%no386_instr:	%1		; write instruction
   228                              <2> 
   229                              <2> %assign %%INSTRCOUNT 0
   230                              <2> %rep $-%%no386_instr		; count size of instruction
   231                              <2>  patch386 , %%no386_instr+%[%%INSTRCOUNT]
   232                              <2> 				; write a patch for each byte
   233                              <2>  %assign %%INSTRCOUNT %%INSTRCOUNT+1
   234                              <2> %endrep
   235                              <2> %undef %%INSTRCOUNT
   236                              <2> 	%endmacro
   237                              <2> %else	; _WPT_LABELS
   238                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   239                              <2> 	%macro _386_o32 0-1+.nolist
   240                              <2> _386		o32
   241                              <2> 		%1
   242                              <2> 	%endmacro
   243                              <2> 
   244                              <2> 		; Address size 32-bit prefix if 386+ CPU
   245                              <2> 	%macro _386_a32 0-1+.nolist
   246                              <2> _386		a32
   247                              <2> 		%1
   248                              <2> 	%endmacro
   249                              <2> 
   250                              <2> 		; Short jump if 386+ CPU
   251                              <2> 	%macro _386_jmps 1.nolist
   252                              <2> _386		jmp short %1
   253                              <2> 	%endmacro
   254                              <2> 
   255                              <2> 		; Near jump if 386+ CPU
   256                              <2> 	%macro _386_jmpn 1.nolist
   257                              <2> _386		jmp near %1
   258                              <2> 	%endmacro
   259                              <2> 
   260                              <2> 		; Short jump if no 386+ CPU
   261                              <2> 	%macro _no386_jmps 1.nolist
   262                              <2> _no386		jmp short %1
   263                              <2> 	%endmacro
   264                              <2> 
   265                              <2> 		; Near jump if no 386+ CPU
   266                              <2> 	%macro _no386_jmpn 1.nolist
   267                              <2> _no386		jmp near %1
   268                              <2> 	%endmacro
   269                              <2> 
   270                              <2> 		; Instruction if 386+ CPU
   271                              <2> 	%macro _386 0-1+.nolist
   272                              <2> %push
   273                              <2> [cpu 386]			; change CPU type
   274                              <2> %assign %$entry $ + _CURRENT_SECTION %+ FIXUP
   275                              <2> 		%1		; write instruction
   276                              <2> __CPU__				; reset CPU type
   277                              <2> 
   278                              <2> %rep ($ + _CURRENT_SECTION %+ FIXUP) - %$entry
   279                              <2> 				; count size of instruction
   280                              <2>  patch386 NO, %[%$entry]	; write a patch for each byte
   281                              <2>  %assign %$entry %$entry+1
   282                              <2> %endrep
   283                              <2> %pop
   284                              <2> 	%endmacro
   285                              <2> 
   286                              <2> 		; Instruction if no 386+ CPU
   287                              <2> 	%macro _no386 0-1+.nolist
   288                              <2> %push
   289                              <2> %assign %$entry $ + _CURRENT_SECTION %+ FIXUP
   290                              <2> 		%1		; write instruction
   291                              <2> 
   292                              <2> %rep ($ + _CURRENT_SECTION %+ FIXUP) - %$entry
   293                              <2> 				; count size of instruction
   294                              <2>  patch386 , %[%$entry]		; write a patch for each byte
   295                              <2>  %assign %$entry %$entry+1
   296                              <2> %endrep
   297                              <2> %pop
   298                              <2> 	%endmacro
   299                              <2> %endif	; _WPT_LABELS
   300                              <2> %endif	; _LINK
   301                              <2> 
   302                              <2> %endif
   303                              <2> 
   304                              <2> 		; Patch macros but for cases where the 386+
   305                              <2> 		; instructions should only be generated for
   306                              <2> 		; DEBUGX (i.e. for 32-bit DPMI addressing code).
   307                              <2> %if _PM
   308                              <2> %define _386_PM_o32	_386_o32
   309                              <2> %define _386_PM_a32	_386_a32
   310                              <2> %define _386_PM_jmps	_386_jmps
   311                              <2> %define _386_PM_jmpn	_386_jmpn
   312                              <2> %define _386_PM		_386
   313                              <2> %else
   314                              <2> %define _386_PM_o32
   315                              <2> %define _386_PM_a32
   316                              <2> %define _386_PM_jmps	comment
   317                              <2> %define _386_PM_jmpn	comment
   318                              <2> %define _386_PM		comment
   319                              <2> %endif
   320                              <2> 
   321                              <2> 
   322                              <2> %ifn _LINK
   323                              <2> %macro __writepatchtable2 0-*.nolist
   324                              <2> %if %0 & 1
   325                              <2>  %fatal Expected even number of arguments
   326                              <2> %endif
   327                              <2> %rep %0 >> 1
   328                              <2> 	%1 %2
   329                              <2> %rotate 2
   330                              <2> %endrep
   331                              <2> %endmacro
   332                              <2> 
   333                              <2> %macro __patchtable2_entry 0.nolist
   334                              <2>   ; only if this isn't the first (pseudo-)entry
   335                              <2>   %if %$lastcount != 0
   336                              <2>     %assign %$runscount %[%$runscount]+1
   337                              <2>    ; if the offset from %$previous is less than 255
   338                              <2>    %if (%$last-%$previous) < 255
   339                              <2>     %assign %$$method2tablesize %$$method2tablesize+1
   340                              <2>     ; then write a single byte (number of bytes not to patch between)
   341                              <2>     %xdefine %$$method2list %$$method2list,db,%$last-%$previous
   342                              <2>    %else
   343                              <2>     ; otherwise write a 255 ("reposition") and write the 16-bit address afterwards
   344                              <2>     %assign %$$method2tablesize %$$method2tablesize+3
   345                              <2>     %xdefine %$$method2list %$$method2list,db,255,dw,%$last
   346                              <2>     %assign %$reposcount %[%$reposcount]+1
   347                              <2>    %endif
   348                              <2>    %if %$lastcount == 1
   349                              <2>     %assign %$onecount %[%$onecount]+1
   350                              <2>    %endif
   351                              <2>    %assign %$$method2tablesize %$$method2tablesize+1
   352                              <2>    ; and write the number of bytes to be patched
   353                              <2>    %xdefine %$$method2list %$$method2list,db,%$lastcount
   354                              <2>    ; define %$previous for the next entry: it points to the next non-patched byte
   355                              <2>    %define %$previous (%[%$last]+%[%$lastcount])
   356                              <2>   %endif
   357                              <2> %endmacro
   358                              <2> 
   359                              <2> %macro writepatchtable 2-*.nolist
   360                              <2> 
   361                              <2> 	numdef %{1}_FORCE_METHOD, 0
   362                              <2> %push
   363                              <2> 		; Determine length of simple table:
   364                              <2> %assign %$method1tablesize (%0 - 2)*2
   365                              <2> 
   366                              <2> %if !_%{1}_FORCE_METHOD || _%{1}_FORCE_METHOD == 2
   367                              <2> 		; Determine length of complicated table:
   368                              <2> %assign %$method2tablesize 0
   369                              <2> %define %$method2list db,""
   370                              <2> %push
   371                              <2> %if _WPT_LABELS
   372                              <2>  %define %$previous code_start	; if list contains labels
   373                              <2> %else
   374                              <2>  %define %$previous 0
   375                              <2> %endif
   376                              <2> %define %$last %[%$previous]
   377                              <2> %assign %$lastcount 0
   378                              <2> %assign %$onecount 0
   379                              <2> %assign %$reposcount 0
   380                              <2> %assign %$bytescount %0 - 2
   381                              <2> %assign %$runscount 0
   382                              <2> %rotate 1
   383                              <2> %rep %0 - 2
   384                              <2>  %rotate 1
   385                              <2>  ;if  it continues the previous patch   and not too long   and this isn't the first
   386                              <2>  %if ((%$last+%$lastcount) == %1) && (%$lastcount < 255) && (%$lastcount != 0)
   387                              <2>   ; then do not write an entry, just increase the patch's size
   388                              <2>   %assign %$lastcount %[%$lastcount]+1
   389                              <2>  %else
   390                              <2>   ; otherwise write the last entry
   391                              <2>   __patchtable2_entry
   392                              <2>   ; define new %$last to this parameter, %$lastcount to one
   393                              <2>   %define %$last %1
   394                              <2>   %assign %$lastcount 1
   395                              <2>  %endif
   396                              <2> %endrep
   397                              <2> __patchtable2_entry
   398                              <2> 
   399                              <2> ; at the end, there's a patch with offset 0, size 0
   400                              <2> %assign %$$method2tablesize %$$method2tablesize+2
   401                              <2> %xdefine %$$method2list %$$method2list,db,0,db,0
   402                              <2> 
   403                              <2> %assign %$$onecount %$onecount
   404                              <2> %assign %$$reposcount %$reposcount
   405                              <2> %assign %$$bytescount %$bytescount
   406                              <2> %assign %$$runscount %$runscount
   407                              <2> %pop
   408                              <2> %rotate 1
   409                              <2> %endif
   410                              <2> 
   411                              <2> %if _%{1}_FORCE_METHOD == 2
   412                              <2>  %define __%{1}_method 2
   413                              <2> %elif _%{1}_FORCE_METHOD == 1
   414                              <2>  %define __%{1}_method 1
   415                              <2> %else
   416                              <2>  %if _%{1}_FORCE_METHOD
   417                              <2>   %fatal Invalid forced method selected: _%{1}_FORCE_METHOD
   418                              <2>  %endif
   419                              <2>  %if %$method1tablesize > (%$method2tablesize+20)
   420                              <2>   %define __%{1}_method 2
   421                              <2>  %else
   422                              <2>   %define __%{1}_method 1
   423                              <2>  %endif
   424                              <2> %endif
   425                              <2> 
   426                              <2> 
   427                              <2> %1:
   428                              <2> %if __%{1}_method == 2
   429                              <2> 	__writepatchtable2 %$method2list
   430                              <2> 	endarea %1
   431                              <2> %assign %$size %1_size
   432                              <2> %warning %1: %$size bytes (Method 2)
   433                              <2> %warning 1B=%$onecount repo=%$reposcount run=%$runscount byte=%$bytescount
   434                              <2> %else
   435                              <2> %rotate 1
   436                              <2> %rep %0 - 2
   437                              <2> %rotate 1
   438                              <2> 	dw %1
   439                              <2> %endrep
   440                              <2> %rotate 1
   441                              <2> 	endarea %1
   442                              <2> %assign %$size %1_size
   443                              <2> %warning %1: %$size bytes (Method 1)
   444                              <2> %1.amount equ %1_size_w
   445                              <2> %endif
   446                              <2> %pop
   447                              <2> %endmacro
   448                              <2> %endif
   879                              <1> 
   880                              <1> 
   881                              <1> %if _VDD
   882                              <1> ; standard BOPs for communication with DEBXXVDD on NT platforms
   883                              <1> %macro RegisterModule 0.nolist
   884                              <1> 	db 0C4h, 0C4h, 58h, 0
   885                              <1> 	nop
   886                              <1> %endmacro
   887                              <1> %macro UnRegisterModule 0.nolist
   888                              <1> 	db 0C4h, 0C4h, 58h, 1
   889                              <1> 	nop
   890                              <1> %endmacro
   891                              <1> %macro DispatchCall 0.nolist
   892                              <1> 	db 0C4h, 0C4h, 58h, 2
   893                              <1> 	nop
   894                              <1> %endmacro
   895                              <1> %endif
   896                              <1> 
   897                              <1> %assign CODE_INSURE_COUNT 0
   898                              <1> 
   899                              <1> 		; The entry_to_code_seg/_sel dispatcher in lDEBUG_DATA_ENTRY
   900                              <1> 		;  detects mistaken debugger breakpoints in its
   901                              <1> 		;  in-code-parameter by checking for a low-byte
   902                              <1> 		;  value equal to 0CCh (one-byte int3 opcode).
   903                              <1> 		; Therefore, we insure that all destinations jumped to
   904                              <1> 		;  via that dispatcher do not happen to be located
   905                              <1> 		;  on an offset that gives 0CCh in the low byte.
   906                              <1> 	%imacro code_insure_low_byte_not_0CCh 0.nolist
   907                              <1> %ifn _LINK
   908                              <1>  %if (($ - _CURRENT_SECTION %+ _start) & 0FFh) == 0CCh
   909                              <1> 	nop
   910                              <1>   %assign CODE_INSURE_COUNT 1 + CODE_INSURE_COUNT
   911                              <1>  %endif
   912                              <1> %endif
   913                              <1> 	%endmacro
   914                              <1> 
   915                              <1> 
   916                              <1> 		; dual code segments
   917                              <1> %if _DUALCODE && _PM
   918                              <1> 
   919                              <1> %if _DEBUG
   920                              <1> %idefine dualfunction comment
   921                              <1> %else
   922                              <1> %idefine dualfunction code_insure_low_byte_not_0CCh
   923                              <1> %endif
   924                              <1> 
   925                              <1> %idefine dualreturn call _CURRENT_SECTION %+ _dualret_helper
   926                              <1> %idefine dualdistance far
   927                              <1> 	%imacro dualcall 1.nolist
   928                              <1> %ifndef SECTION_OF_%1
   929                              <1>  %error Unknown target section for symbol %1
   930                              <1> %endif
   931                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _dualcall_helper
   932                              <1>  %if _DEBUG
   933                              <1> 	jmp strict short %%skipdata
   934                              <1>  %endif
   935                              <1> 	dw %1
   936                              <1> %%skipdata:
   937                              <1> 	%endmacro
   938                              <1> 	%imacro nearcall 1.nolist
   939                              <1> %ifndef SECTION_OF_%1
   940                              <1>  %error Unknown target section for symbol %1
   941                              <1> %endif
   942                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
   943                              <1> 	call %1
   944                              <1> %else
   945                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _nearcall_helper
   946                              <1>  %if _DEBUG
   947                              <1> 	jmp strict short %%skipdata
   948                              <1>  %endif
   949                              <1> 	dw %1
   950                              <1> %%skipdata:
   951                              <1> %endif
   952                              <1> 	%endmacro
   953                              <1> 
   954                              <1> %elif _DUALCODE && ! _PM
   955                              <1> 
   956                              <1> %idefine dualfunction comment
   957                              <1> %idefine dualreturn
   958                              <1> %idefine dualdistance far
   959                              <1> 
   960                              <1> %ifn _LINK
   961                              <1> %define PATCH_RELOCATE_FROM_lDEBUG_CODE ""
   962                              <1> %define PATCH_RELOCATE_FROM_lDEBUG_CODE2 ""
   963                              <1> 	%imacro dualcall 1.nolist
   964                              <1> %ifndef SECTION_OF_%1
   965                              <1>  %error Unknown target section for symbol %1
   966                              <1> %endif
   967                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
   968                              <1> 	push cs
   969                              <1> 	call %1
   970                              <1> %else
   971                              <1> 	call relocatedzero:%1
   972                              <1> %push
   973                              <1> %assign %$entry ($ + _CURRENT_SECTION %+ FIXUP) - 2
   974                              <1> 	relocatelist _CURRENT_SECTION, %$entry
   975                              <1> %pop
   976                              <1> %endif
   977                              <1> 	%endmacro
   978                              <1> 	%imacro relocatelist 2.nolist
   979                              <1>  %define PATCH_RELOCATE_FROM_%1 %[PATCH_RELOCATE_FROM_%1],%2
   980                              <1> 	%endmacro
   981                              <1> %else		; _LINK
   982                              <1> 	%idefine dualcall dualcall_with_filename __FILE__,
   983                              <1> 	%imacro dualcall_with_filename 2.nolist
   984                              <1> %ifndef SECTION_OF_%2
   985                              <1>  %error Unknown target section for symbol %2
   986                              <1> %endif
   987                              <1> %ifidni %[SECTION_OF_%2], _CURRENT_SECTION
   988                              <1> 	push cs
   989                              <1> 	call %2
   990                              <1> %else
   991                              <1> 	call relocatedzero:%2
   992                              <1> %ifidn _CURRENT_SECTION, lDEBUG_CODE
   993                              <1>  wllist Lrelocate_from_code, equ $ - 2, %1
   994                              <1> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
   995                              <1>  wllist Lrelocate_from_code2, equ $ - 2, %1
   996                              <1> %else
   997                              <1>  %error Wrong section
   998                              <1> %endif
   999                              <1> %endif
  1000                              <1> 	%endmacro
  1001                              <1> %endif		; _LINK
  1002                              <1>  %if _DUALCODENEARDUAL
  1003                              <1> 
  1004                              <1> %if _LINK
  1005                              <1> 	%idefine nearcall nearcall_with_filename __FILE__,
  1006                              <1> 	%imacro nearcall_with_filename 2
  1007                              <1> %ifndef SECTION_OF_%2
  1008                              <1>  %error Unknown target section for symbol %2
  1009                              <1> %endif
  1010                              <1> %ifidni %[SECTION_OF_%2], _CURRENT_SECTION
  1011                              <1> 	call %2
  1012                              <1> %else
  1013                              <1>  %push
  1014                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1015                              <1>  %xdefine %$targetsection SECTION_OF_%2
  1016                              <1>  %deftok %%filenametoken SOURCEFILENAME
  1017                              <1>   %ifndef NEARCALL_THUNK_TO_%2%[%%filenametoken]
  1018                              <1> 	hiddenusesection %$targetsection
  1019                              <1> %define NEARCALL_THUNK_TO_%2%[%%filenametoken] %%nearcall_thunk_to_%2%[%%filenametoken]
  1020                              <1> section_of %%nearcall_thunk_to_%2%[%%filenametoken]
  1021                              <1> dualfunction
  1022                              <1> %%nearcall_thunk_to_%2%[%%filenametoken]:
  1023                              <1> 	call %2
  1024                              <1> 	dualreturn
  1025                              <1> 	retf
  1026                              <1> 
  1027                              <1> 	hiddenusesection %$originalsection
  1028                              <1>   %endif
  1029                              <1>  %pop
  1030                              <1> 	dualcall_with_filename %1, NEARCALL_THUNK_TO_%2%[%%filenametoken]
  1031                              <1> %endif
  1032                              <1> 	%endmacro
  1033                              <1> %elif _LINK_COMPAT	; _LINK
  1034                              <1> 	%imacro nearcall 1
  1035                              <1> %ifndef SECTION_OF_%1
  1036                              <1>  %error Unknown target section for symbol %1
  1037                              <1> %endif
  1038                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1039                              <1> 	call %1
  1040                              <1> %else
  1041                              <1>  %push
  1042                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1043                              <1>  %xdefine %$targetsection SECTION_OF_%1
  1044                              <1>  %deftok %%filenametoken SOURCEFILENAME
  1045                              <1>   %ifndef NEARCALL_THUNK_TO_%1%[%%filenametoken]
  1046                              <1> 	hiddenusesection %$targetsection
  1047                              <1> %define NEARCALL_THUNK_TO_%1%[%%filenametoken] %%nearcall_thunk_to_%1%[%%filenametoken]
  1048                              <1> section_of %%nearcall_thunk_to_%1%[%%filenametoken]
  1049                              <1> dualfunction
  1050                              <1> %%nearcall_thunk_to_%1%[%%filenametoken]:
  1051                              <1> 	call %1
  1052                              <1> 	dualreturn
  1053                              <1> 	retf
  1054                              <1> 
  1055                              <1> 	hiddenusesection %$originalsection
  1056                              <1>   %endif
  1057                              <1>  %pop
  1058                              <1> 	dualcall NEARCALL_THUNK_TO_%1%[%%filenametoken]
  1059                              <1> %endif
  1060                              <1> 	%endmacro
  1061                              <1> %else		; _LINK, _LINK_COMPAT
  1062                              <1> 	%imacro nearcall 1
  1063                              <1> %ifndef SECTION_OF_%1
  1064                              <1>  %error Unknown target section for symbol %1
  1065                              <1> %endif
  1066                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1067                              <1> 	call %1
  1068                              <1> %else
  1069                              <1>  %push
  1070                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1071                              <1>  %xdefine %$targetsection SECTION_OF_%1
  1072                              <1>   %ifndef NEARCALL_THUNK_TO_%1
  1073                              <1> 	hiddenusesection %$targetsection
  1074                              <1> %define NEARCALL_THUNK_TO_%1 %%nearcall_thunk_to_%1
  1075                              <1> section_of %%nearcall_thunk_to_%1
  1076                              <1> dualfunction
  1077                              <1> %%nearcall_thunk_to_%1:
  1078                              <1> 	call %1
  1079                              <1> 	dualreturn
  1080                              <1> 	retf
  1081                              <1> 
  1082                              <1> 	hiddenusesection %$originalsection
  1083                              <1>   %endif
  1084                              <1>  %pop
  1085                              <1> 	dualcall NEARCALL_THUNK_TO_%1
  1086                              <1> %endif
  1087                              <1> 	%endmacro
  1088                              <1> %endif		; _LINK, _LINK_COMPAT
  1089                              <1>  %else
  1090                              <1> 	%imacro nearcall 1.nolist
  1091                              <1> %ifndef SECTION_OF_%1
  1092                              <1>  %error Unknown target section for symbol %1
  1093                              <1> %endif
  1094                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1095                              <1> 	call %1
  1096                              <1> %else
  1097                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _nearcall_helper
  1098                              <1>  %if _DEBUG
  1099                              <1> 	jmp strict short %%skipdata
  1100                              <1>  %endif
  1101                              <1> 	dw %1
  1102                              <1> %%skipdata:
  1103                              <1> %endif
  1104                              <1> 	%endmacro
  1105                              <1>  %endif
  1106                              <1> %elif ! _DUALCODE
  1107                              <1> 
  1108                              <1> %idefine dualfunction comment
  1109                              <1> %idefine dualreturn
  1110                              <1> %idefine dualdistance near
  1111                              <1> 	%imacro dualcall 1.nolist
  1112                              <1> 	call %1
  1113                              <1> 	%endmacro
  1114                              <1> 	%imacro nearcall 1.nolist
  1115                              <1> 	call %1
  1116                              <1> 	%endmacro
  1117                              <1> %assign _SYMBOLICDUALCODE 0
  1118                              <1> %assign _SYMBOLASMDUALCODE 0
  1119                              <1> 
  1120                              <1> %else
  1121                              <1>  %error Unexpected defines
  1122                              <1> %endif
  1123                              <1> 
  1124                              <1> %ifn _SYMBOLICDUALCODE
  1125                              <1>  %assign _SYMBOLASMDUALCODE 0
  1126                              <1> %endif
  1127                              <1> 
  1128                              <1>  %if _SYMBOLIC && _DUALCODE && _SYMBOLASMDUALCODE
  1129                              <1> %idefine dual2function	dualfunction
  1130                              <1> %idefine dual2return	dualreturn
  1131                              <1> %idefine dual2distance	dualdistance
  1132                              <1> %idefine dual2call	dualcall
  1133                              <1>  %else
  1134                              <1> %idefine dual2function comment
  1135                              <1> %idefine dual2return
  1136                              <1> %idefine dual2distance near
  1137                              <1> 	%imacro dual2call 1.nolist
  1138                              <1> 	call %1
  1139                              <1> 	%endmacro
  1140                              <1>  %endif
  1141                              <1> 
  1142                              <1> 
  1143                              <1> 	numdef CHECKSECTION, 0
  1144                              <1> 	numdef CHECKCALLSECTION, _CHECKSECTION
  1145                              <1> 	numdef CHECKJMPSECTION, _CHECKSECTION
  1146                              <1> 	numdef CHECKJCCSECTION, _CHECKSECTION
  1147                              <1> 
  1148                              <1> %if _CHECKCALLSECTION
  1149                              <1> 	%imacro call 1.nolist
  1150                              <1> 	%? %1
  1151                              <1> checksection %1, %?, call
  1152                              <1> 	%endmacro
  1153                              <1> %endif
  1154                              <1> %if _CHECKJMPSECTION
  1155                              <1> 	%imacro jmp 1.nolist
  1156                              <1> 	%? %1
  1157                              <1> checksection %1, %?, jmp
  1158                              <1> 	%endmacro
  1159                              <1> %endif
  1160                              <1> %if _CHECKJCCSECTION
  1161                              <1> 	%imacro je 1.nolist
  1162                              <1> 	%? %1
  1163                              <1> checksection %1, %?, jcc
  1164                              <1> 	%endmacro
  1165                              <1> 	%imacro jne 1.nolist
  1166                              <1> 	%? %1
  1167                              <1> checksection %1, %?, jcc
  1168                              <1> 	%endmacro
  1169                              <1> 	%imacro jz 1.nolist
  1170                              <1> 	%? %1
  1171                              <1> checksection %1, %?, jcc
  1172                              <1> 	%endmacro
  1173                              <1> 	%imacro jnz 1.nolist
  1174                              <1> 	%? %1
  1175                              <1> checksection %1, %?, jcc
  1176                              <1> 	%endmacro
  1177                              <1> 
  1178                              <1> 	%imacro jb 1.nolist
  1179                              <1> 	%? %1
  1180                              <1> checksection %1, %?, jcc
  1181                              <1> 	%endmacro
  1182                              <1> 	%imacro jnb 1.nolist
  1183                              <1> 	%? %1
  1184                              <1> checksection %1, %?, jcc
  1185                              <1> 	%endmacro
  1186                              <1> 	%imacro jbe 1.nolist
  1187                              <1> 	%? %1
  1188                              <1> checksection %1, %?, jcc
  1189                              <1> 	%endmacro
  1190                              <1> 	%imacro jnbe 1.nolist
  1191                              <1> 	%? %1
  1192                              <1> checksection %1, %?, jcc
  1193                              <1> 	%endmacro
  1194                              <1> 	%imacro jc 1.nolist
  1195                              <1> 	%? %1
  1196                              <1> checksection %1, %?, jcc
  1197                              <1> 	%endmacro
  1198                              <1> 	%imacro jnc 1.nolist
  1199                              <1> 	%? %1
  1200                              <1> checksection %1, %?, jcc
  1201                              <1> 	%endmacro
  1202                              <1> 	%imacro ja 1.nolist
  1203                              <1> 	%? %1
  1204                              <1> checksection %1, %?, jcc
  1205                              <1> 	%endmacro
  1206                              <1> 	%imacro jna 1.nolist
  1207                              <1> 	%? %1
  1208                              <1> checksection %1, %?, jcc
  1209                              <1> 	%endmacro
  1210                              <1> 	%imacro jae 1.nolist
  1211                              <1> 	%? %1
  1212                              <1> checksection %1, %?, jcc
  1213                              <1> 	%endmacro
  1214                              <1> 	%imacro jnae 1.nolist
  1215                              <1> 	%? %1
  1216                              <1> checksection %1, %?, jcc
  1217                              <1> 	%endmacro
  1218                              <1> 
  1219                              <1> 	%imacro jl 1.nolist
  1220                              <1> 	%? %1
  1221                              <1> checksection %1, %?, jcc
  1222                              <1> 	%endmacro
  1223                              <1> 	%imacro jnl 1.nolist
  1224                              <1> 	%? %1
  1225                              <1> checksection %1, %?, jcc
  1226                              <1> 	%endmacro
  1227                              <1> 	%imacro jle 1.nolist
  1228                              <1> 	%? %1
  1229                              <1> checksection %1, %?, jcc
  1230                              <1> 	%endmacro
  1231                              <1> 	%imacro jnle 1.nolist
  1232                              <1> 	%? %1
  1233                              <1> checksection %1, %?, jcc
  1234                              <1> 	%endmacro
  1235                              <1> 	%imacro jg 1.nolist
  1236                              <1> 	%? %1
  1237                              <1> checksection %1, %?, jcc
  1238                              <1> 	%endmacro
  1239                              <1> 	%imacro jng 1.nolist
  1240                              <1> 	%? %1
  1241                              <1> checksection %1, %?, jcc
  1242                              <1> 	%endmacro
  1243                              <1> 	%imacro jge 1.nolist
  1244                              <1> 	%? %1
  1245                              <1> checksection %1, %?, jcc
  1246                              <1> 	%endmacro
  1247                              <1> 	%imacro jnge 1.nolist
  1248                              <1> 	%? %1
  1249                              <1> checksection %1, %?, jcc
  1250                              <1> 	%endmacro
  1251                              <1> 
  1252                              <1> 	%imacro jo 1.nolist
  1253                              <1> 	%? %1
  1254                              <1> checksection %1, %?, jcc
  1255                              <1> 	%endmacro
  1256                              <1> 	%imacro jno 1.nolist
  1257                              <1> 	%? %1
  1258                              <1> checksection %1, %?, jcc
  1259                              <1> 	%endmacro
  1260                              <1> 	%imacro jp 1.nolist
  1261                              <1> 	%? %1
  1262                              <1> checksection %1, %?, jcc
  1263                              <1> 	%endmacro
  1264                              <1> 	%imacro jnp 1.nolist
  1265                              <1> 	%? %1
  1266                              <1> checksection %1, %?, jcc
  1267                              <1> 	%endmacro
  1268                              <1> 	%imacro jpe 1.nolist
  1269                              <1> 	%? %1
  1270                              <1> checksection %1, %?, jcc
  1271                              <1> 	%endmacro
  1272                              <1> 	%imacro jnpe 1.nolist
  1273                              <1> 	%? %1
  1274                              <1> checksection %1, %?, jcc
  1275                              <1> 	%endmacro
  1276                              <1> 	%imacro jpo 1.nolist
  1277                              <1> 	%? %1
  1278                              <1> checksection %1, %?, jcc
  1279                              <1> 	%endmacro
  1280                              <1> 	%imacro jnpo 1.nolist
  1281                              <1> 	%? %1
  1282                              <1> checksection %1, %?, jcc
  1283                              <1> 	%endmacro
  1284                              <1> 	%imacro js 1.nolist
  1285                              <1> 	%? %1
  1286                              <1> checksection %1, %?, jcc
  1287                              <1> 	%endmacro
  1288                              <1> 	%imacro jns 1.nolist
  1289                              <1> 	%? %1
  1290                              <1> checksection %1, %?, jcc
  1291                              <1> 	%endmacro
  1292                              <1> 
  1293                              <1> 	%imacro jcxz 1.nolist
  1294                              <1> 	%? %1
  1295                              <1> checksection %1, %?, jcc
  1296                              <1> 	%endmacro
  1297                              <1> 	%imacro jecxz 1.nolist
  1298                              <1> 	%? %1
  1299                              <1> checksection %1, %?, jcc
  1300                              <1> 	%endmacro
  1301                              <1> 	%imacro loop 1.nolist
  1302                              <1> 	%? %1
  1303                              <1> checksection %1, %?, jcc
  1304                              <1> 	%endmacro
  1305                              <1> 	%imacro loopz 1.nolist
  1306                              <1> 	%? %1
  1307                              <1> checksection %1, %?, jcc
  1308                              <1> 	%endmacro
  1309                              <1> 	%imacro loopnz 1.nolist
  1310                              <1> 	%? %1
  1311                              <1> checksection %1, %?, jcc
  1312                              <1> 	%endmacro
  1313                              <1> 	%imacro loope 1.nolist
  1314                              <1> 	%? %1
  1315                              <1> checksection %1, %?, jcc
  1316                              <1> 	%endmacro
  1317                              <1> 	%imacro loopne 1.nolist
  1318                              <1> 	%? %1
  1319                              <1> checksection %1, %?, jcc
  1320                              <1> 	%endmacro
  1321                              <1> %endif
  1322                              <1> 
  1323                              <1> 	%imacro checksection 3.nolist
  1324                              <1> %push
  1325                              <1>  %defstr %$string %1
  1326                              <1>  %substr %$shortword %$string 1, 5
  1327                              <1>  %substr %$shortsep %$string 6, 1
  1328                              <1>  %substr %$nearword %$string 1, 4
  1329                              <1>  %substr %$nearsep %$string 5, 1
  1330                              <1>  %substr %$farword %$string 1, 3
  1331                              <1>  %substr %$farsep %$string 4, 1
  1332                              <1>  %assign %$isshort 0
  1333                              <1>  %ifidni %$shortword, "short"
  1334                              <1>   %if %$shortsep == 32 || %$shortsep == 9
  1335                              <1>    %assign %$isshort 1
  1336                              <1>    %substr %$string %$string 7, -1
  1337                              <1>   %elif %$shortsep == '['
  1338                              <1>    %assign %$isshort 1
  1339                              <1>    %substr %$string %$string 6, -1
  1340                              <1>   %endif
  1341                              <1>  %endif
  1342                              <1>  %assign %$isnear 0
  1343                              <1>  %ifidni %$nearword, "near"
  1344                              <1>   %if %$nearsep == 32 || %$nearsep == 9
  1345                              <1>    %assign %$isnear 1
  1346                              <1>    %substr %$string %$string 6, -1
  1347                              <1>   %elif %$nearsep == '['
  1348                              <1>    %assign %$isnear 1
  1349                              <1>    %substr %$string %$string 5, -1
  1350                              <1>   %endif
  1351                              <1>  %endif
  1352                              <1>  %assign %$isfar 0
  1353                              <1>  %ifidni %$farword, "far"
  1354                              <1>   %if %$farsep == 32 || %$farsep == 9
  1355                              <1>    %assign %$isfar 1
  1356                              <1>    %substr %$string %$string 5, -1
  1357                              <1>   %elif %$farsep == '['
  1358                              <1>    %assign %$isfar 1
  1359                              <1>    %substr %$string %$string 4, -1
  1360                              <1>   %endif
  1361                              <1>  %endif
  1362                              <1> 
  1363                              <1>  %deftok %$token %$string
  1364                              <1> 
  1365                              <1>  %assign %$size 2
  1366                              <1>  %assign %$isreg 0
  1367                              <1>  %assign %$exit 0
  1368                              <1>  %rep 2
  1369                              <1>   %ifn %$exit
  1370                              <1>    %if %$size == 2
  1371                              <1>     %define %$regnames "ax  cx  dx  bx  sp  bp  si  di  "
  1372                              <1>    %elif %$size == 4
  1373                              <1>     %define %$regnames "eax ecx edx ebx esp ebp esi edi "
  1374                              <1>    %endif
  1375                              <1>    %assign %$index 0
  1376                              <1>    %rep 8
  1377                              <1>     %ifn %$exit
  1378                              <1>      %substr %$reg %$regnames %$index * 4 + 1, 4
  1379                              <1>      %deftok %$reg %$reg
  1380                              <1>      %ifnempty %$reg
  1381                              <1>       %ifidni %$reg, %$token
  1382                              <1>        %assign %$isreg %$size
  1383                              <1>        %assign %$exit 1
  1384                              <1>        %exitrep
  1385                              <1>       %endif
  1386                              <1>      %endif
  1387                              <1>     %endif
  1388                              <1>     %assign %$index %$index + 1
  1389                              <1>    %endrep
  1390                              <1>    %if %$exit
  1391                              <1>     %exitrep
  1392                              <1>    %endif
  1393                              <1>    %assign %$size %$size * 2
  1394                              <1>   %endif
  1395                              <1>  %endrep
  1396                              <1> 
  1397                              <1>  %assign %$ismulti 0
  1398                              <1>  %assign %$ismem 0
  1399                              <1>  %strlen %$length %$string
  1400                              <1>  %assign %$ii 0
  1401                              <1>  %rep %$length
  1402                              <1>   %substr %$point %$string %$ii + 1, 1
  1403                              <1>   %if %$point == 32 || %$point == 9
  1404                              <1>    %assign %$ismulti 1
  1405                              <1>   %endif
  1406                              <1>   %ifidn %$point, '['
  1407                              <1>    %assign %$ismem 1
  1408                              <1>   %endif
  1409                              <1>   %assign %$ii %$ii + 1
  1410                              <1>  %endrep
  1411                              <1> 
  1412                              <1>  %assign %$islocal 0
  1413                              <1>  %substr %$point %$string 1, 1
  1414                              <1>  %substr %$prefix %$string 1, 3
  1415                              <1>  %ifidn %$point, '.'
  1416                              <1>   %ifnidn %$prefix, '..@'
  1417                              <1>    %assign %$islocal 1
  1418                              <1>   %endif
  1419                              <1>  %endif
  1420                              <1> 
  1421                              <1>  %if %$isreg
  1422                              <1>   %if %$isreg == 4
  1423                              <1>    %warning 32-bit reg %3: %2 %1
  1424                              <1>   %else
  1425                              <1>    %warning 16-bit reg %3: %2 %1
  1426                              <1>   %endif
  1427                              <1>  %elif %$ismulti || %$ismem
  1428                              <1>   %warning not single %3: %2 %1
  1429                              <1>  %elif %$islocal
  1430                              <1>   %ifidni %3, call
  1431                              <1>    %warning local %3: %2 %1
  1432                              <1>   %endif
  1433                              <1>  %elifdef SECTION_OF_%[%$token]
  1434                              <1>   %ifnidni SECTION_OF_%[%$token], _CURRENT_SECTION
  1435                              <1>    %error Symbol %$token called wrongly: section_of=SECTION_OF_%[%$token], current=_CURRENT_SECTION
  1436                              <1>   %endif
  1437                              <1>  %endif
  1438                              <1> %pop
  1439                              <1> 	%endmacro
  1440                              <1> 
  1441                              <1> 
  1442                              <1> 	struc MEMREF
  1443 00000000 ????????            <1> mrLinear:		resd 1
  1444 00000004 ????????            <1> mrOffset:		resd 1
  1445 00000008 ????                <1> mrSegmentSelector:	resw 1
  1446 0000000A ????                <1> mrFlags:		resw 1
  1447 0000000C ????????            <1> mrLength:		resd 1
  1448                              <1> 	endstruc
  1449                              <1> 
  1450                              <1> 		; Currently only direct branches are allowed when
  1451                              <1> 		;  disassembling from the U command. (That is,
  1452                              <1> 		;  [disflags] & DIS_F_SHOW is clear.) All other
  1453                              <1> 		;  types of references depend on segment registers
  1454                              <1> 		;  and sometimes base and index registers, which are
  1455                              <1> 		;  not known ahead of time. They are only known for
  1456                              <1> 		;  the R command's disassembly. (DIS_F_SHOW set.)
  1457                              <1> 		; (When a mov ss or pop to ss will change ss, a
  1458                              <1> 		;  subsequent instruction using ss will not be
  1459                              <1> 		;  disassembled with the correct ss value.
  1460                              <1> 		;  This should be rare though. We may at a later
  1461                              <1> 		;  point detect this condition and not display
  1462                              <1> 		;  references with ss then.)
  1463                              <1> mrfBranchDirect:	equ    1
  1464                              <1> mrfMem:			equ    2
  1465                              <1> mrfMemSource:		equ    4
  1466                              <1> mrfMemDest:		equ    8
  1467                              <1> mrfA32:			equ   10h
  1468                              <1> mrfString:		equ   20h
  1469                              <1> mrfStringSource:	equ   40h
  1470                              <1> mrfStringDest:		equ   80h
  1471                              <1> mrfUsesSS:		equ  100h
  1472                              <1> mrfBranchIndirect:	equ  200h
  1473                              <1> 
  1474                              <1> 
  1475                              <1> %if _VXCHG && ! _VXCHGBIOS
  1476                              <1> 	struc XMSM
  1477 00000000 ????????            <1> .size_:		resd 1
  1478 00000004 ????                <1> .srchdl:	resw 1
  1479 00000006 ????????            <1> .srcadr:	resd 1
  1480 0000000A ????                <1> .dsthdl:	resw 1
  1481 0000000C ????????            <1> .dstadr:	resd 1
  1482                              <1> 	endstruc
  1483                              <1> %endif
  1484                              <1> 
  1485                              <1> 
  1486                              <1> 	; doscall is used by symbols.asm and run.asm and in
  1487                              <1> 	;  cmd3_close_handle, so define it prior
  1488                              <1> %if _PM && _NOEXTENDER
  1489                              <1> %macro doscall 0
  1490                              <1> 	nearcall _doscall
  1491                              <1> %endmacro
  1492                              <1> %else
  1493                              <1> 		; When we don't support non-extended DPMI all Int21 calls
  1494                              <1> 		; are either in Real Mode or extended (all are real Int21
  1495                              <1> 		; instructions).
  1496                              <1> %macro doscall 0
  1497                              <1> 	int 21h
  1498                              <1> %endmacro
  1499                              <1> %endif
  1500                              <1> 
  1501                              <1> 
  1502                              <1> %if _LINK
  1503                              <1> %imacro wlcalc 1-2.nolist
  1504                              <1> %deftok %%filenametoken __FILE__
  1505                              <1>  global wlcalc_%1?%[%%l]%[%%filenametoken]
  1506                              <1> wlcalc_%1?%[%%l]%[%%filenametoken]: %2
  1507                              <1> %endmacro
  1508                              <1> %endif
  1509                              <1> 
  1510                              <1> %if _BOOTLDR && _LINK
  1511                              <1> %macro lot_equate 2.nolist
  1512                              <1> LOAD_%2 equ %1
  1513                              <1> %endmacro
  1514                              <1> 
  1515                              <1> 	lot_equate    1, SET_DL_UNIT
  1516                              <1> 	lot_equate    2, SET_BL_UNIT
  1517                              <1> 	lot_equate    4, SET_SIDI_CLUSTER
  1518                              <1> 	lot_equate  10h, SET_DSSI_DPT
  1519                              <1> 	lot_equate  20h, PUSH_DPT
  1520                              <1> 	lot_equate  40h, DATASTART_HIDDEN
  1521                              <1> 	lot_equate  80h, SET_AXBX_DATASTART
  1522                              <1> 	lot_equate 100h, SET_DSBP_BPB
  1523                              <1> 	lot_equate 200h, LBA_SET_TYPE
  1524                              <1> 	lot_equate 400h, MESSAGE_TABLE
  1525                              <1> 	lot_equate 800h, SET_AXBX_ROOT_HIDDEN
  1526                              <1> 	lot_equate 1000h, CMDLINE
  1527                              <1> 	lot_equate 2000h, NO_BPB
  1528                              <1> 	lot_equate 4000h, SET_DSSI_PARTINFO
  1529                              <1> %endif
  1530                              <1> 
  1531                              <1> %if _HELP_COMPRESSED
  1532                              <1>  %assign NONCOMPRESSEDFLAG 1
  1533                              <1> %else
  1534                              <1>  %assign NONCOMPRESSEDFLAG 0
  1535                              <1> %endif
  1536                              <1> 
  1537                              <1> [list +]
  1538                              <1> 
  1539                              <1> %if _LINK
  1540                              <1>  %if _ONLY386
  1541                              <1> 	cpu 386
  1542                              <1>  %else
  1543                              <1> 	cpu 8086
  1544                              <1>  %endif
  1545                              <1> 
  1546                              <1> auxbuff_size: equ (_AUXBUFFSIZE+15) & ~15
  1547                              <1> 	endarea auxbuff, 1
  1548                              <1> 
  1549                              <1> auxbuff_max_size: equ (_AUXBUFFMAXSIZE+15) & ~15
  1550                              <1> 	endarea auxbuff_max, 1
  1551                              <1> 
  1552                              <1> %if _INIT_MAX
  1553                              <1>  auxbuff_init_size: equ (_AUXBUFFMAXSIZE+15) & ~15
  1554                              <1> %else
  1555                              <1>  auxbuff_init_size: equ (_AUXBUFFSIZE+15) & ~15
  1556                              <1> %endif
  1557                              <1> 	endarea auxbuff_init, 1
  1558                              <1> 
  1559                              <1>  %include "options.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug options and internal flags
     5                              <2> 
     6                              <2> Copyright (C) 2008-2025 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 
    17                              <2> dispregs32	equ	  1	; RX: 32-bit register display (R, T/P/G)
    18                              <2> traceints	equ	  2	; TM: trace into interrupts (T)
    19                              <2> cpdepchars	equ	  4	; allow dumping of CP-dependent characters (D, DX)
    20                              <2> fakeindos	equ	  8	; always assume InDOS flag non-zero (all)
    21                              <2> nonpagingdevice	equ	 10h	; disallow paged output with [more] prompt (all exc. P, T)
    22                              <2> 	; This option was never used anywhere:
    23                              <2> ; pagingdevice	equ	 20h	; allow paged output with [more] prompt (all exc. P, T)
    24                              <2> 				; paged output is by default on if the output device is StdOut, else off
    25                              <2> hexrn		equ	 40h	; display raw hexadecimal content of FPU registers (RN)
    26                              <2> ;novdd		equ	 80h	; don't use a registered NTVDM VDD (L, W)
    27                              <2> nondospaging	equ	100h	; paging: don't use DOS for input when waiting for a key
    28                              <2> opt1_86mnohlt	equ	200h	; (86 Mode:) HLT doesn't work, don't use it
    29                              <2> biosidles	equ	400h	; don't idle with HLT or Int2F.1680, only call BIOS Int16.00
    30                              <2> opt_usegetinput	equ	800h	; use getinput for int 21h interactive input
    31                              <2> use_si_units	equ    1000h	; in disp_*_size use SI units (kB = 1000, etc)
    32                              <2> use_jedec_units	equ    2000h	; in disp_*_size use JEDEC units (kB = 1024)
    33                              <2> enable_serial	equ    4000h	; enable serial I/O (preferred over DOS or BIOS terminal)
    34                              <2> int8_disable_serial equ	   8000h	; disable serial I/O when breaking due to intr8
    35                              <2> gg_do_not_skip_bp equ	 1_0000h	; gg: do not skip a breakpoint (bb or gg)
    36                              <2> gg_no_autorepeat equ	 2_0000h	; gg: do not auto-repeat
    37                              <2> tp_do_not_skip_bp equ	 4_0000h	; T/TP/P: do not skip a (bb) breakpoint
    38                              <2> gg_bb_hit_no_repeat equ	 8_0000h	; gg: do not auto-repeat after bb hit
    39                              <2> tp_bb_hit_no_repeat equ	10_0000h	; T/TP/P: do not auto-repeat after bb hit
    40                              <2> gg_unexpected_no_repeat equ 20_0000h	; gg: do not auto-repeat after unexpectedinterrupt
    41                              <2> tp_unexpected_no_repeat equ 40_0000h	; T/TP/P
    42                              <2> ss_no_dump:		equ 80_0000h
    43                              <2> %if _SYMBOLIC
    44                              <2> dd_no_blanks_sym:	equ 100_0000h
    45                              <2> zz_no_pm_xms:		equ 200_0000h
    46                              <2> %endif
    47                              <2> rr_disasm_no_rept:	equ 1000_0000h
    48                              <2> rr_disasm_no_show:	equ 2000_0000h
    49                              <2> opt_cmdline_quiet_input:equ 4000_0000h
    50                              <2> opt_cmdline_quiet_output:equ 8000_0000h
    51                              <2> %if _SYMBOLIC
    52                              <2> DEFAULTOPTIONS	equ zz_no_pm_xms
    53                              <2> %else
    54                              <2> DEFAULTOPTIONS	equ 0
    55                              <2> %endif
    56                              <2> 
    57                              <2> 
    58                              <2> opt2_db_header:		equ 1
    59                              <2> opt2_db_trailer:	equ 2
    60                              <2> opt2_dw_header:		equ 10h
    61                              <2> opt2_dw_trailer:	equ 20h
    62                              <2> opt2_dd_header:		equ 100h
    63                              <2> opt2_dd_trailer:	equ 200h
    64                              <2> opt2_getinput_dpmi:	equ 800h
    65                              <2> opt2_hh_compat:		equ 1000h
    66                              <2> opt2_getc_idle:		equ 2000h
    67                              <2> opt2_getc_idle_dpmi:	equ 4000h
    68                              <2> opt2_re_cancel_tpg:	equ 8000h
    69                              <2> opt2_nn_compat:		equ 1_0000h
    70                              <2> opt2_nn_capitalise:	equ 2_0000h
    71                              <2> %if _MS_0RANGE_COMPAT
    72                              <2> opt2_0range_compat:	equ 4_0000h
    73                              <2> %endif
    74                              <2> opt2_rr16_compat:	equ 8_0000h
    75                              <2> opt2_r_prompt_compat:	equ 10_0000h
    76                              <2> opt2_r_separate:	equ 20_0000h
    77                              <2> opt2_r_linebreak_always:equ 40_0000h
    78                              <2> opt2_dpminohlt:		equ 8000_0000h	; DPMI doesn't like hlt
    79                              <2> DEFAULTOPTIONS2	equ opt2_dw_header | opt2_dd_header | opt2_getc_idle_dpmi | opt2_dpminohlt
    80                              <2> 
    81                              <2> 
    82                              <2> opt3_tt_no_paging:	equ 1
    83                              <2> opt3_tp_no_paging:	equ 2
    84                              <2> opt3_pp_no_paging:	equ 4
    85                              <2> opt3_gg_no_paging:	equ 8
    86                              <2> opt3_silence_paging_set:equ 100h
    87                              <2> opt3_silence_paging_on:	equ 200h
    88                              <2> opt3_paging_rc:		equ 1000h
    89                              <2> opt3_paging_yy:		equ 2000h
    90                              <2> opt3_paging_re:		equ 4000h
    91                              <2> opt3_r_highlight_diff:	equ 10000h
    92                              <2> opt3_r_highlight_dumb:	equ 20000h
    93                              <2> opt3_r_highlight_full:	equ 40000h
    94                              <2> opt3_r_highlight_eip:	equ 80000h
    95                              <2> %if _PM
    96                              <2> opt3_ss_b_bit_set:	equ   10_0000h
    97                              <2>  %if _BREAK_INSTALLDPMI
    98                              <2> opt3_break_installdpmi:	equ   20_0000h
    99                              <2>  %endif
   100                              <2> %endif
   101                              <2> %if _DHIGHLIGHT
   102                              <2> opt3_d_highlight:	equ   80_0000h
   103                              <2> %endif
   104                              <2> %if _GETLINEHIGHLIGHT
   105                              <2> opt3_getline_highlight:	equ  100_0000h
   106                              <2> %endif
   107                              <2> opt3_no_idle_2F:	equ  200_0000h
   108                              <2> %if _DELAY_BEFORE_BP
   109                              <2> opt3_delay_before_bp:	equ  400_0000h
   110                              <2> %endif
   111                              <2> opt3_no_call_amis:	equ  800_0000h
   112                              <2> opt3_disable_autorepeat:equ 1000_0000h
   113                              <2> opt3_check_ctrlc_keyb:	equ 2000_0000h
   114                              <2> opt3_check_ctrlc_0bh:	equ 4000_0000h
   115                              <2> opt3_tsr_quit_leave_tf:	equ 8000_0000h
   116                              <2> DEFAULTOPTIONS3	equ opt3_tt_no_paging | opt3_tp_no_paging 		| opt3_pp_no_paging | opt3_gg_no_paging 		| opt3_check_ctrlc_keyb | opt3_check_ctrlc_0bh
   119                              <2> 
   120                              <2> 
   121                              <2> opt4_int_2F_hook:	equ 2
   122                              <2> opt4_int_08_hook:	equ 4
   123                              <2> opt4_int_2D_hook:	equ 8
   124                              <2> %if _CATCHINTFAULTCOND
   125                              <2> opt4_int_fault_hook:	equ 10h
   126                              <2> %endif
   127                              <2> opt4_int_serial_force:	equ 1_0000h
   128                              <2> opt4_int_2F_force:	equ 2_0000h
   129                              <2> opt4_int_08_force:	equ 4_0000h
   130                              <2> opt4_int_2D_force:	equ 8_0000h
   131                              <2> %if _CATCHINT0D
   132                              <2> opt4_int_0D_force:	equ   10_0000h
   133                              <2> %endif
   134                              <2> %if _CATCHINT0C
   135                              <2> opt4_int_0C_force:	equ   20_0000h
   136                              <2> %endif
   137                              <2> opt4_int_00_force:	equ  100_0000h
   138                              <2> opt4_int_01_force:	equ  200_0000h
   139                              <2> opt4_int_03_force:	equ  400_0000h
   140                              <2> opt4_int_06_force:	equ  800_0000h
   141                              <2> opt4_int_18_force:	equ 1000_0000h
   142                              <2> opt4_int_19_force:	equ 2000_0000h
   143                              <2> opt4_int_09_force:	equ 4000_0000h	; not used at the same time as 15h
   144                              <2> opt4_int_15_force:	equ 4000_0000h	; not used at the same time as 09h
   145                              <2> opt4_int_07_force:	equ 8000_0000h
   146                              <2> DEFAULTOPTIONS4 equ opt4_int_2F_hook
   147                              <2> 
   148                              <2> 
   149                              <2> %if _VXCHG
   150                              <2> opt6_vv_mode:		equ 1
   151                              <2> opt6_vv_keep:		equ 2
   152                              <2> opt6_vv_int16:		equ 10h
   153                              <2>  %if _VXCHG_DEFAULT_ON
   154                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq | opt6_vv_mode
   155                              <2>  %else
   156                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq
   157                              <2>  %endif
   158                              <2> %else
   159                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq
   160                              <2> %endif
   161                              <2> %if _DEBUG
   162                              <2> opt6_debug_exception_late:	equ  20h
   163                              <2> opt6_debug_exception_early:	equ  40h
   164                              <2>  %if _DEBUG_COND
   165                              <2> opt6_debug_exception:	equ  80h
   166                              <2> opt6_debug_mode:	equ 100h
   167                              <2>  %endif
   168                              <2> %endif
   169                              <2> opt6_bios_output:	equ 200h
   170                              <2> opt6_flat_binary:	equ 400h
   171                              <2> opt6_big_stack:		equ 800h
   172                              <2> opt6_40_columns:	equ 1000h
   173                              <2> opt6_40_indent_odd:	equ 2000h
   174                              <2> opt6_40_dash:		equ 4000h
   175                              <2> opt6_share_serial_irq:	equ 1_0000h
   176                              <2> opt6_serial_EOI_call:	equ 2_0000h
   177                              <2> %if _RH
   178                              <2> opt6_rh_mode:		equ 10_0000h
   179                              <2> %endif
   180                              <2> %if _DEBUG
   181                              <2> opt6_debug_putrunint_early:	equ  40_0000h
   182                              <2>  %if _DEBUG_COND
   183                              <2> opt6_debug_putrunint:		equ  80_0000h
   184                              <2>  %endif
   185                              <2> %endif
   186                              <2> opt6_bios_io:		equ 100_0000h
   187                              <2> opt6_immasm_display_uu:	equ 200_0000h
   188                              <2> opt6_immasm_debug:	equ 400_0000h
   189                              <2> opt6_immasm_flag:	equ 800_0000h
   190                              <2> opt6_immasm_nobranch:	equ 1000_0000h
   191                              <2> opt6_r_flags_style2:	equ 2000_0000h
   192                              <2> opt6_r_flags_style3:	equ 4000_0000h
   193                              <2> opt6_r_linebreak_conditional:	equ 8000_0000h
   194                              <2> 
   195                              <2> 
   196                              <2> DEFAULTOPTIONS7 equ opt7_no_tsr_ll
   197                              <2> opt7_no_free_oneshot_eld:	equ 1
   198                              <2> opt7_debug_optional_link:	equ 2
   199                              <2> opt7_quiet_install:		equ 4
   200                              <2> opt7_quick_run:			equ 8
   201                              <2> opt7_houdini:			equ 100h
   202                              <2> opt7_debug_run:			equ 200h
   203                              <2> opt7_no_ensure:			equ 1000h
   204                              <2> opt7_no_tsr_ll:			equ 2000h
   205                              <2> 
   206                              <2> 
   207                              <2> oldpacket	equ	  1	; Int25/Int26 packet method available (L, W)
   208                              <2> newpacket	equ	  2	; Int21.7305 packet method available (L, W)
   209                              <2> ntpacket	equ	  4	; VDD registered and usable (L, W)
   210                              <2> pagedcommand	equ	  8	; allows paging in puts
   211                              <2> notstdinput	equ	 10h	; DEBUG's StdIn isn't a device with StdIn bit (is file or other device)
   212                              <2> inputfile	equ	 20h	; DEBUG's StdIn is a file, notstdinput also set
   213                              <2> notstdoutput	equ	 40h	; DEBUG's StdOut isn't a device with StdOut bit (is file or other device)
   214                              <2> outputfile	equ	  80h	; DEBUG's StdOut is a file, notstdoutput also set
   215                              <2> hooked2F	equ	 100h	; Int2F hooked
   216                              <2> nohook2F	equ	 200h	; don't hook Int2F.1687 (required for Win9x, DosEmu?)
   217                              <2> unused_dif1_dpminohlt equ 400h	; DPMI doesn't like hlt
   218                              <2> protectedmode	equ	 800h	; in (DPMI) protected mode
   219                              <2> debuggeeA20	equ	1000h	; state of debuggee's A20
   220                              <2> debuggerA20	equ	2000h	; state of debugger's A20 (will be on if possible)
   221                              <2> nodosloaded	equ	4000h	; No DOS loaded currently (Boot loader mode)
   222                              <2> has386		equ	8000h	; CPU is a 386
   223                              <2> usecharcounter	equ    1_0000h	; don't reset charcounter between calls to puts
   224                              <2> runningnt	equ    2_0000h	; running in NTVDM
   225                              <2> canswitchmode	equ    4_0000h	; can switch modes (auxbuff large enough, DPMI mode switch set up)
   226                              <2> modeswitched	equ    8_0000h	; switched mode (now in the mode that we weren't entered in)
   227                              <2> promptwaiting	equ   10_0000h	; puts: any more output needs to display a prompt first
   228                              <2> switchbuffer	equ   20_0000h	; mode switch needs a buffer (auxbuff)
   229                              <2> tsrmode		equ   40_0000h	; in TSR mode; DPI and DPP not valid
   230                              <2> attachedterm	equ   80_0000h	; the attached process terminated
   231                              <2> runningdosemu	equ  100_0000h	; running in dosemu
   232                              <2> ; load_is_ldp	equ  200_0000h	; boot load: partition specified as "ldp"
   233                              <2> tt_while:	equ  400_0000h	; tt: while condition specified
   234                              <2> tt_p:		equ  800_0000h	; tt: proceed past repeated string instructions
   235                              <2> tt_silent_mode:	equ 1000_0000h	; tt: run should be silent (dump at end)
   236                              <2> tt_silence:	equ 2000_0000h	; tt: silent writing (write to auxbuff instead)
   237                              <2> tt_no_bb:	equ 4000_0000h	; tt: do not use bb breakpoints
   238                              <2> tt_no_bb_first:	equ 8000_0000h	; tt: do not use bb breakpoints at first
   239                              <2> 
   240                              <2> 
   241                              <2> dif2_gg_is_first:	equ   1
   242                              <2> dif2_gg_skip_non_cseip:	equ   2
   243                              <2> dif2_gg_skip_cseip:	equ   4
   244                              <2> dif2_gg_is_gg:		equ   8
   245                              <2> dif2_gg_first_detected:	equ  10h
   246                              <2> dif2_gg_again:		equ  20h
   247                              <2> dif2_tpg_proceed_bp_set:equ  40h
   248                              <2> dif2_tpg_keep_proceed_bp: equ 80h
   249                              <2> dif2_tpg_have_bp:	equ 100h
   250                              <2> dif2_tpg_adjusted_cseip:equ 200h
   251                              <2> dif2_tpg_do_not_adjust:	equ 400h
   252                              <2> dif2_bp_failure:	equ 800h
   253                              <2> dif2_is_pp:		equ 1000h
   254                              <2> %if _SYMBOLIC
   255                              <2> dif2_createdprocess:	equ 800_0000h	; created empty debuggee process
   256                              <2> dif2_sym_req_xms:	equ 2000h
   257                              <2> dif2_sym_req_86mm:	equ 4000h
   258                              <2> dif2_sym_req_mask equ dif2_sym_req_86mm | dif2_sym_req_xms
   259                              <2> dif2_no_pm_xms:		equ 1_0000h
   260                              <2> dif2_xms_detection_done:equ 2_0000h
   261                              <2> %endif
   262                              <2> %if _INPUT_FILE_HANDLES
   263                              <2> dif2_input_file:	equ 10_0000h
   264                              <2> dif2_closed_input_file:	equ 20_0000h
   265                              <2> %endif
   266                              <2> dif2_did_getline_file:	equ 40_0000h
   267                              <2> %if _SYMBOLIC
   268                              <2> dif2_poison:		equ 80_0000h
   269                              <2> %endif
   270                              <2> dif2_boot_loaded_kernel:equ 100_0000h
   271                              <2> %if _INPUT_FILE_BOOT
   272                              <2> dif2_input_file_boot:	equ 200_0000h
   273                              <2> dif2_closed_input_file_boot:	equ 400_0000h
   274                              <2> %endif
   275                              <2> dif2_in_silence_dump:	equ 1000_0000h
   276                              <2> dif2_int31_segment:	equ 2000_0000h
   277                              <2> dif2_nn_compat:		equ 4000_0000h
   278                              <2> dif2_nn_capitalise:	equ 8000_0000h
   279                              <2> 
   280                              <2> 
   281                              <2> dif3_load_is_ldp:	equ 1	; boot load: partition specified as "ldp"
   282                              <2> dif3_load_is_sdp:	equ 2	; boot load: partition specified as "sdp"
   283                              <2> dif3_load_is_ydp:	equ 4	; boot load: partition specified as "ydp"
   284                              <2> dif3_load_is_dp:	equ dif3_load_is_ldp 				| dif3_load_is_sdp 				| dif3_load_is_ydp
   287                              <2> dif3_load_dir_dir:	equ 8
   288                              <2> dif3_input_terminal_override:	equ 10h
   289                              <2> dif3_input_serial_override:	equ 20h
   290                              <2> dif3_if_not:		equ 40h
   291                              <2> dif3_partition_changed:	equ 80h
   292                              <2> ;
   293                              <2> dif3_input_cmdline:	equ 100h; input reading from cmdline_buffer
   294                              <2> dif3_input_cmdline_closed: equ 200h
   295                              <2> dif3_at_line_end:	equ 400h
   296                              <2> dif3_quiet_input_single:equ 800h
   297                              <2> dif3_quiet_output:	equ 1000h
   298                              <2> dif3_unquiet_error:	equ 2000h
   299                              <2> dif3_unquiet_prompt:	equ 4000h
   300                              <2> dif3_unquiet:		equ dif3_unquiet_error | dif3_unquiet_prompt
   301                              <2> dif3_return_eof:	equ 8000h
   302                              <2> dif3_highlighting:	equ 1_0000h
   303                              <2> dif3_do_not_highlight:	equ 2_0000h
   304                              <2> dif3_int10_highlight:	equ 2_0000h
   305                              <2> dif3_nosymbols_1:	equ 4_0000h
   306                              <2> dif3_nosymbols_2:	equ 8_0000h
   307                              <2> %if _PM
   308                              <2> dif3_ss_b_bit_set:	equ  10_0000h
   309                              <2> %endif
   310                              <2> dif3_gotint19:		equ  20_0000h
   311                              <2> dif3_prior_pm:		equ  40_0000h
   312                              <2> %if _DELAY_BEFORE_BP
   313                              <2> dif3_delayed		equ  80_0000h
   314                              <2> %endif
   315                              <2> dif3_input_re:		equ 100_0000h	; input reading from re_buffer
   316                              <2> dif3_input_re_closed:	equ 200_0000h
   317                              <2> dif3_accept_getrange_0:	equ 400_0000h
   318                              <2> %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
   319                              <2> dif3_in_if:		equ 800_0000h
   320                              <2> %endif
   321                              <2> dif3_auxbuff_guarded_1:	equ 1000_0000h
   322                              <2> dif3_auxbuff_guarded_2:	equ 2000_0000h
   323                              <2> dif3_auxbuff_guarded_3:	equ 4000_0000h
   324                              <2> dif3_sss_is_reverse:	equ 8000_0000h
   325                              <2> 
   326                              <2> 
   327                              <2> dif4_int_serial_hooked:	equ 1
   328                              <2> dif4_int_2F_hooked:	equ 2
   329                              <2> dif4_int_08_hooked:	equ 4
   330                              <2> dif4_int_2D_hooked:	equ 8
   331                              <2> %if _CATCHINTFAULTCOND && _CATCHINT0D
   332                              <2> dif4_int_0D_hooked:	equ 10h
   333                              <2> %endif
   334                              <2> %if _CATCHINTFAULTCOND && _CATCHINT0C
   335                              <2> dif4_int_0C_hooked:	equ 20h
   336                              <2> %endif
   337                              <2> %if _LOADER
   338                              <2> dif4_int_18_hooked:	equ 1000h
   339                              <2> dif4_int_19_hooked:	equ 2000h
   340                              <2> %endif
   341                              <2> 
   342                              <2> 
   343                              <2> %if _VXCHG
   344                              <2> dif6_vv_mode:		equ 1
   345                              <2> %endif
   346                              <2> dif6_in_hook2F:		equ 2
   347                              <2> dif6_in_amis_hook2F:	equ 4
   348                              <2> dif6_debug_mode:	equ 100h
   349                              <2> dif6_locked:		equ 200h
   350                              <2> dif6_mcp:		equ 400h
   351                              <2> %if _RH
   352                              <2> dif6_rh_mode_was:	equ  8_0000h
   353                              <2> dif6_rh_mode:		equ 10_0000h
   354                              <2> dif6_rh_mode_2:		equ 20_0000h
   355                              <2> %endif
   356                              <2> dif6_device_mode:	equ 40_0000h
   357                              <2> dif6_cpdepchars:	equ 80_0000h
   358                              <2> %if _IMMASM
   359                              <2> dif6_immasm_no_output:	equ 100_0000h
   360                              <2> dif6_immasm:		equ 200_0000h
   361                              <2> dif6_immasm_rel8:	equ 400_0000h
   362                              <2> %endif
   363                              <2> 
   364                              <2> 
   365                              <2> disasm_lowercase	equ 1
   366                              <2> disasm_commablank	equ 2
   367                              <2> disasm_nasm		equ 4
   368                              <2> disasm_lowercase_refmem:equ 8
   369                              <2> disasm_show_short:	equ 10h
   370                              <2> disasm_show_near:	equ 20h
   371                              <2> disasm_show_far:	equ 40h
   372                              <2> disasm_nec:		equ 80h
   373                              <2> disasm_40_columns:	equ 100h
   374                              <2> disasm_no_indent:	equ 200h
   375                              <2> disasm_msdebug_mnemonofs: equ 400h
   376                              <2> disasm_a16_memref:	equ 1000h
   377                              <2> disasm_a32_memref:	equ 2000h
   378                              <2> disasm_a16_string:	equ 4000h
   379                              <2> disasm_a32_string:	equ 8000h
   380                              <2> disasm_hide_modrm:	equ 10000h
   381                              <2> disasm_asize_loop_nasm:	equ 20000h
   382                              <2> disasm_modrm_always:	equ 40000h
   383                              <2> DEFAULTASMOPTIONS equ disasm_lowercase|disasm_commablank|disasm_nasm 	| disasm_a16_memref | disasm_a32_memref 	| disasm_a16_string | disasm_a32_string
   386                              <2> 
   387                              <2> 	; serial_flags values
   388                              <2> sf_init_done:	equ 1
   389                              <2> sf_ctrl_c:	equ 2
   390                              <2> sf_double_ctrl_c:	equ 4
   391                              <2> sf_built_in_fifo:	equ 8
   392                              <2> sf_use_serial:		equ 10h
  1560                              <1> %endif
    32                                  [list +]
    33                                  
    34                                  %ifn _LINK
    35                                  %ifndef _MAP
    36                                  %elifempty _MAP
    37                                  %else	; defined non-empty, str or non-str
    38                                  	[map all _MAP]
    39                                  %endif
    40                                  
    41                                  %if _ONLY386
    42                                  	cpu 386
    43                                  %else
    44                                  	cpu 8086
    45                                  %endif
    46                                  
    47                                  %include "sections.mac"
    48                                  
    49                                  
    50                                  		; This is used to refer to the program image parts
    51                                  		;  that are always to be placed at a fixed position
    52                                  		;  directly behind the PSP. (These never need to be
    53                                  		;  relocated in application mode, except if the /T
    54                                  		;  switch is used.)
    55                                  %define DATAENTRYTABLESIZE (ldebug_data_entry_size 			+ asmtable1_size 			+ asmtable2_size)
    58                                  
    59                                  		; The following are offsets from the PSP segment,
    60                                  		;  in application mode. They refer to the sources
    61                                  		;  of these section images in the program image.
    62                                  		; Device driver and bootloaded mode early on will
    63                                  		;  set up ds so that ds:100h -> program image,
    64                                  		;  mimicking the application mode with a pseudo-PSP
    65                                  		;  segment address.
    66                                  		; Device driver mode will relocate everything to end
    67                                  		;  up with device shim, pseudo MCB (16 bytes), PSP
    68                                  		;  (256 bytes), data/entry, asmtables, data/stack,
    69                                  		;  message. After that the auxbuff, history buffer,
    70                                  		;  code1, code2, environment, and ext segment can be
    71                                  		;  placed. Finally a single paragraph is reserved
    72                                  		;  for an SD container MCB.
    73                                  		; For application mode, data/entry and asmtables
    74                                  		;  are not usually relocated. The original PSP is
    75                                  		;  used as is too. Behind the asmtables, the setup
    76                                  		;  is similar to device mode. The exception is that
    77                                  		;  the entire resident debugger, process and all,
    78                                  		;  can be relocated late in init, by using the /T
    79                                  		;  switch to init.
    80                                  		; Boot loaded mode will relocate everything to end
    81                                  		;  up at the top of the LMA, including the "NDEB"
    82                                  		;  image identification paragraph (always on a KiB
    83                                  		;  boundary), the pseudo PSP, and then all the
    84                                  		;  resident sections. (To fill to a KiB-aligned
    85                                  		;  size, some padding may follow at the end.)
    86                                  %define MESSAGESECTIONOFFSET (100h + DATAENTRYTABLESIZE)
    87                                  %define CODESECTIONOFFSET (MESSAGESECTIONOFFSET + messagesegment_size)
    88                                  %define INITSECTIONOFFSET (CODESECTIONOFFSET+ldebug_code_size+ldebug_code2_size)
    89                                  
    90                                  		; These targets indicate where to place the code
    91                                  		;  code sections and auxbuff when boot loaded.
    92                                  		;  This uses full segments (not truncated).
    93                                  %define BOOTCODETARGET1 (MESSAGESECTIONOFFSET + messagesegment_nobits_size + datastack_size)
    94                                  %define BOOTCODETARGET2 (BOOTCODETARGET1+auxbuff_size)
    95                                  %define BOOTAUXTARGET1 (BOOTCODETARGET1+ldebug_code_size+ldebug_code2_size)
    96                                  %define BOOTAUXTARGET2 BOOTCODETARGET1
    97                                  %define BOOTAUXTARGET3 (BOOTAUXTARGET1+auxbuff_size)
    98                                  
    99                                  %if _BOOTLDR_DISCARD || _BOOTLDR_DISCARD_HELP
   100                                  		; If the message and/or code section is truncated
   101                                  		;  then non-boot-loaded modes have to calculate
   102                                  		;  their layouts with the truncated sizes. The
   103                                  		;  CODETARGET1 is based on MESSAGESECTIONOFFSET
   104                                  		;  because CODESECTIONOFFSET already implies the
   105                                  		;  use of the untruncated message segment.
   106                                  %define CODETARGET1 (MESSAGESECTIONOFFSET + messagesegment_nobits_truncated_size + datastack_size)
   107                                  %define CODETARGET2 (CODETARGET1+auxbuff_size)
   108                                  %define AUXTARGET1 (CODETARGET1+ldebug_code_bootldr_truncated_size+ldebug_code2_size)
   109                                  %define AUXTARGET2 CODETARGET1
   110                                  %define AUXTARGET3 (AUXTARGET1+auxbuff_size)
   111                                  %else
   112                                  		; If no section is truncated we can just directly
   113                                  		;  re-use the layouts, same as things were before
   114                                  		;  the sections were made to be truncated.
   115                                  %xdefine CODETARGET1 BOOTCODETARGET1
   116                                  %xdefine CODETARGET2 BOOTCODETARGET2
   117                                  %xdefine AUXTARGET1 BOOTAUXTARGET1
   118                                  %xdefine AUXTARGET2 BOOTAUXTARGET2
   119                                  %xdefine AUXTARGET3 BOOTAUXTARGET3
   120                                  %endif
   121                                  
   122                                  		; This calculation allows for all the sections
   123                                  		;  that are stored in the program image (the
   124                                  		;  first term) plus the data/stack section,
   125                                  		;  auxbuff twice (twice for if layout 3 needed),
   126                                  		;  and the separate history segment. After init
   127                                  		;  is relocated this high, all destinations for
   128                                  		;  the to-be resident sections can be written to.
   129                                  		; (Now also includes the environment block and
   130                                  		;  the ext code segment.)
   131                                  		; This is based on the application PSP segment.
   132                                  		; Update: This may be not large enough for the
   133                                  		;  aux and ext buffers if _INIT_MAX=0. In this
   134                                  		;  case, init may have to relocate itself a
   135                                  		;  second time later to make space for the full
   136                                  		;  buffers.
   137                                  %define APPINITTARGET (INITSECTIONOFFSET 			+ datastack_size 			+ ext_data_nonboot_add_size 			+ auxbuff_size + auxbuff_init_size 			+ historysegment_size 			+ app_env_size 			+ extsegment_size)
   144                                  		; The early stack goes behind the init target.
   145                                  %define APPINITSTACK_START (APPINITTARGET+init_size)
   146                                  APPINITSTACK_SIZE equ 512	; must be even
   147                                  		; This is the size of the application mode
   148                                  		;  process memory block required while still
   149                                  		;  using the init stack behind init target.
   150                                  %define APPINITSTACK_END (APPINITSTACK_START+APPINITSTACK_SIZE)
   151                                  
   152                                  BOOTINITSTACK_SIZE equ 512	; must be divisible by 16
   153                                  		; Similar to APPINITTARGET this calculates
   154                                  		;  the size needed for the maximum size resident
   155                                  		;  image once installed. The auxbuff size twice,
   156                                  		;  history segment, data/stack section, and the
   157                                  		;  INITSECTIONOFFSET are the same here. The final
   158                                  		;  +16 is for the NDEB image identification
   159                                  		;  paragraph. The KiB macros are to round up the
   160                                  		;  size to the next kibi byte boundary as we will
   161                                  		;  install by modifying the int 12h return value,
   162                                  		;  which has kibi byte granularity.
   163                                  		; (Now also includes the environment block and
   164                                  		;  the ext code segment.)
   165                                  %define BOOTDELTA	(fromkib(kib(auxbuff_size * 2 				+ historysegment_boot_size 				+ boot_env_size 				+ extsegment_boot_size 				+ datastack_size 				+ INITSECTIONOFFSET + 16)))
   171                                  
   172                                  %if _DEVICE
   173                                  		; This is the size of the shim, the pseudo MCB,
   174                                  		;  as well as the process we will create.
   175                                  %define DEVICEADJUST	(deviceshim_size + 110h)
   176                                  		; Like APPINITTARGET, except we need to add
   177                                  		;  in the device adjust for the additional things
   178                                  		;  to place before the resident image.
   179                                  		; The final 10h is for the SD container MCB space
   180                                  		;  reserved at the end of our resident allocation.
   181                                  		; Question: Is the PSP size included in the define
   182                                  		;  INITSECTIONOFFSET redundant with DEVICEADJUST?
   183                                  		;  Even if this is true it has very little negative
   184                                  		;  effects, we would simply need 256 more bytes
   185                                  		;  than would be required.
   186                                  		; Answer: No, it isn't redundant. The first PSP size
   187                                  		;  is to translate from the entrypoint ds (where
   188                                  		;  ds:100h -> program image) to the device header.
   189                                  		;  The second PSP size is for the actual PSP that is
   190                                  		;  allocated eventually.
   191                                  %define DEVICEINITTARGET (INITSECTIONOFFSET 			+ DEVICEADJUST 			+ datastack_size 			+ ext_data_nonboot_add_size 			+ auxbuff_size + auxbuff_init_size 			+ historysegment_size 			+ dev_env_size 			+ extsegment_size 			+ 10h)
   200                                  		; The minus 100h is because the target calculates
   201                                  		;  from the pseudo PSP location on entry (cs - 10h).
   202                                  		;  To check the size we can subtract this term so as
   203                                  		;  to not use more than needed.
   204                                  		; This adds the shim size as the shim exists in its
   205                                  		;  own section behind the init section. It will be
   206                                  		;  discarded at this spot after it was copied to the
   207                                  		;  resident position of the device header.
   208                                  		; No temporary stack in or behind the init section is
   209                                  		;  used because the device installer provides a
   210                                  		;  perfectly valid stack for us to use.
   211                                  %define DEVICEINITSIZE (DEVICEINITTARGET - 100h 			+ init_size 			+ deviceshim_size)
   214                                  %endif	; _DEVICE
   215                                  %endif	; _LINK
   216                                  
   217                                  
   218                                  %if _LINK
   219                                   global behind_progbits_dataentry, behind_messagesegment
   220                                   global behind_deviceshim
   221                                  	usesection lDEBUG_DATA_ENTRY
   221          ------------------       note: usesection lDEBUG_DATA_ENTRY
   222                                  	align 16, nop
   223                                  	usesection ASMTABLE1
   223          ------------------       note: usesection ASMTABLE1
   224                                  	align 16, nop
   225                                  	usesection ASMTABLE2
   225          ------------------       note: usesection ASMTABLE2
   226                                  	align 16, nop
   227                                  	usesection DATASTACKBASE
   227          ------------------       note: usesection DATASTACKBASE
   228                                  	align 16, nop
   229                                  behind_progbits_dataentry:
   230                                  	usesection MESSAGESEGMENT
   230          ------------------       note: usesection MESSAGESEGMENT
   231                                  	align 16, nop
   232                                  	usesection lDEBUG_CODE
   232          ------------------       note: usesection lDEBUG_CODE
   233                                  	align 16, nop
   234                                  behind_messagesegment:
   235                                  %ifn _MESSAGESEGMENT
   236                                  behind_messagesegment_nobits_truncated:
   237                                  %endif
   238                                  	usesection lDEBUG_CODE2
   238          ------------------       note: usesection lDEBUG_CODE2
   239                                  	align 16, nop
   240                                  behind_code:
   241                                  	usesection INIT
   241          ------------------       note: usesection INIT
   242                                  	align 16, nop
   243                                  behind_code2:
   244                                  	usesection WLEMITALIGNINITEND
   244          ------------------       note: usesection WLEMITALIGNINITEND
   245                                  behind_init:
   246                                  	usesection DEVICESHIM
   246          ------------------       note: usesection DEVICESHIM
   247                                  	align 16, nop
   248                                  	usesection WLEMITALIGNRELOCZERO
   248          ------------------       note: usesection WLEMITALIGNRELOCZERO
   249                                  behind_deviceshim:
   250                                  relocatedzero:
   251                                  
   252                                  %include "patch.mac"
     1                              <1> 
     2                              <1> %if 0
     3                              <1> 
     4                              <1> lDebug patch area segment equates
     5                              <1> 
     6                              <1> Copyright (C) 2008-2026 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 _RUN2_ENTRY_SECTION
    17                              <1> patcharea_run.segment equ pspdbg
    18                              <1> %else
    19                              <1> patcharea_run.segment equ code_seg
    20                              <1> %endif
    21                              <1> patcharea_intrtn.segment equ pspdbg
    22                              <1> patcharea_pm_exc.segment equ pspdbg
   253                                  
   254                                  	usesection lDEBUG_DATA_ENTRY
   254          ------------------       note: usesection lDEBUG_DATA_ENTRY
   255 00000000 00<rep 100h>            	times 256 db 0
   256                                  ..start:
   257                                  %endif
   258                                  
   259                                  
   260                                  %if _DEVICE
   261                                  		; The final resident copy of this device header
   262                                  		;  is relocated from the shim to in front of our
   263                                  		;  PSP. Therefore, this space after the PSP can
   264                                  		;  be re-used for the newly expanded N buffer.
   265                                  		;  (Refer to N_BUFFER_END.)
   266                                  
   267                                  		; The device header is of a fixed format.
   268                                  		;  For our purposes, the 4-byte code for
   269                                  		;  each the strategy entry and the
   270                                  		;  interrupt entry is part of this format.
   271                                  		; (DOS may read the attributes or entrypoint
   272                                  		;  offsets before calling either, so the
   273                                  		;  inicomp stage needs to recreate in its
   274                                  		;  entrypoints part exactly what we have here.)
   275                                  %macro writedeviceheader 3
   276                                  	hiddenusesection %1
   277                                  %2:
   278                                  .next:
   279                                  %ifidni %1, DEVICESHIM
   280                                  	dd -1
   281                                  %else
   282                                  	fill 2, -1, jmp strict short j_zero_entrypoint
   283                                  	dw -1
   284                                  %endif
   285                                  .attributes:
   286                                  	dw 8800h			; character device, open/close supported
   287                                  		; Setting bit 800h means that opening the device
   288                                  		;  will already cause a critical error. This
   289                                  		;  discourages opening the character device.
   290                                  		;  As we never use it we want to avoid opens.
   291                                  .strategy:
   292                                  	dw .strategy_entry %3		; -> strategy entry
   293                                  .interrupt:
   294                                  	dw .interrupt_entry %3		; -> interrupt entry
   295                                  .name:
   296                                  	fill 8, 32, db "LDEBUG$$"	; character device name
   297                                  .strategy_entry:
   298                                  	fill 4, 90h, jmp %2 %+ .device_entrypoint
   299                                  .interrupt_entry:
   300                                  	fill 4, 90h, retf
   301                                  %endmacro
   302                                  
   303                                  writedeviceheader lDEBUG_DATA_ENTRY, device_header, - 100h
   276                              <1>  hiddenusesection %1
   276          ------------------  <1>  note: usesection lDEBUG_DATA_ENTRY
   277                              <1> %2:
   278                              <1> .next:
   279                              <1> %ifidni %1, DEVICESHIM
   280                              <1>  dd -1
   281                              <1> %else
   282 00000100 EB3E                <1>  fill 2, -1, jmp strict short j_zero_entrypoint
   283 00000102 FFFF                <1>  dw -1
   284                              <1> %endif
   285                              <1> .attributes:
   286 00000104 0088                <1>  dw 8800h
   287                              <1> 
   288                              <1> 
   289                              <1> 
   290                              <1> 
   291                              <1> .strategy:
   292 00000106 [1200]              <1>  dw .strategy_entry %3
   293                              <1> .interrupt:
   294 00000108 [1600]              <1>  dw .interrupt_entry %3
   295                              <1> .name:
   296 0000010A 4C44454255472424    <1>  fill 8, 32, db "LDEBUG$$"
   297                              <1> .strategy_entry:
   298 00000112 EB3690<rep 2h>      <1>  fill 4, 90h, jmp %2 %+ .device_entrypoint
   299                              <1> .interrupt_entry:
   300 00000116 CB90<rep 3h>        <1>  fill 4, 90h, retf
   304                                  .pass_lcfg:
   305 0000011A 00000000                	dd 0				; (not used yet)
   306                                  %else
   307                                  	jmp initcode_j
   308                                  %endif
   309                                  
   310                                  		; Startup codes can be discarded after one of
   311                                  		;  them is used to enter the initialisation part.
   312                                  		;  Therefore the N buffer is now extended past
   313                                  		;  these codes, refer to N_BUFFER_END.
   314                                  %if _BOOTLDR
   315 0000011E 00<rep 2h>              	align 32, db 0
   316                                   %if !_LINK && ($ - $$) != 32
   317                                    %error Wrong kernel iniload entrypoint
   318                                   %endif
   319                                   %if _LINK && ($ - $$) != 256 + 32
   320                                    %error Wrong kernel iniload entrypoint
   321                                   %endif
   322 00000120 BB[0000]                	mov bx, boot_initcode
   323                                  %endif
   324                                  
   325                                  %if _BOOTLDR || _DEVICE
   326                                  		; INP:	cs:0 => program image
   327                                  		;	INIT:bx -> init entrypoint
   328                                  device_boot_common_entrypoint:
   329 00000123 8CC8                    	mov ax, cs
   330 00000125 83E810                  	sub ax, 10h
   331 00000128 8ED8                    	mov ds, ax	; => would-be PSP before program image
   332 0000012A EB18                    	jmp @F
   333                                  %endif
   334 0000012C 00<rep 14h>             	align 64, db 0
   335                                   %if !_LINK && ($ - $$) != 64
   336                                    %error Wrong application entrypoint
   337                                   %endif
   338                                   %if _LINK && ($ - $$) != 256 + 64
   339                                    %error Wrong application entrypoint
   340                                   %endif
   341                                  
   342                                  		; INP:	cs = ds => PSP
   343                                  j_zero_entrypoint:
   344                                  initcode_j:
   345 00000140 8CC8                    	mov ax, cs
   346 00000142 31DB                    	xor bx, bx
   347                                  
   348                                  		; INP:	ds:100h = ax:100h -> program image
   349                                  		;	INIT:bx -> init entrypoint
   350                                  @@:
   351                                  %if _LINK
   352 00000144 05[0000]                	add ax, strict word relocatedzero + 0
   353                                  wlcalc word_segrel_INIT, equ $ - 2
   354                                  %else
   355                                  	add ax, paras(INITSECTIONOFFSET)
   356                                  			; => original INIT section in program image
   357                                  %endif
   358 00000147 50                      	push ax
   359 00000148 53                      	push bx
   360 00000149 CB                      	retf		; dispatch to INIT code
   361                                  
   362                                  
   363                                  %if _DEVICE
   364                                  		; INP:	es:bx -> device request header
   365                                  		;	ss:sp -> a DOS stack, far return address to DOS
   366                                  		;	cs:0 -> our start image
   367                                  		; OUT:	bx = offset of init function in INIT segment
   368                                  		;	ss:sp -> bx, fl, ds, ax, far return address
   369                                  device_header.device_entrypoint:
   370 0000014A 26807F0200              	cmp byte [es:bx + 2], 0		; command code 0 (init) ?
   371 0000014F 7414                    	je @F
   372                                  
   373 00000151 26C747030001            	mov word [es:bx + 3], 0100h	; no error, done
   374 00000157 26807F020E              	cmp byte [es:bx + 2], 0Eh	; command code 0Eh (close) ?
   375 0000015C 7406                    	je .retf			; yes, accept it -->
   376 0000015E 26C747030381            	mov word [es:bx + 3], 8103h	; error, done, code: unknown command
   377 00000164 CB                      .retf:	retf
   378                                  
   379                                  @@:
   380 00000165 50                      	push ax
   381 00000166 1E                      	push ds
   382 00000167 9C                      	pushf
   383 00000168 53                      	push bx
   384 00000169 BB[0000]                	mov bx, device_initcode
   385 0000016C EBB5                    	jmp device_boot_common_entrypoint
   386                                  
   387                                  
   388                                  writedeviceheader DEVICESHIM, shim_device_header, - 0
   276                              <1>  hiddenusesection %1
   276          ------------------  <1>  note: usesection DEVICESHIM
   277                              <1> %2:
   278                              <1> .next:
   279                              <1> %ifidni %1, DEVICESHIM
   280 00000000 FFFFFFFF            <1>  dd -1
   281                              <1> %else
   282                              <1>  fill 2, -1, jmp strict short j_zero_entrypoint
   283                              <1>  dw -1
   284                              <1> %endif
   285                              <1> .attributes:
   286 00000004 0088                <1>  dw 8800h
   287                              <1> 
   288                              <1> 
   289                              <1> 
   290                              <1> 
   291                              <1> .strategy:
   292 00000006 [1200]              <1>  dw .strategy_entry %3
   293                              <1> .interrupt:
   294 00000008 [1600]              <1>  dw .interrupt_entry %3
   295                              <1> .name:
   296 0000000A 4C44454255472424    <1>  fill 8, 32, db "LDEBUG$$"
   297                              <1> .strategy_entry:
   298 00000012 EB0690<rep 2h>      <1>  fill 4, 90h, jmp %2 %+ .device_entrypoint
   299                              <1> .interrupt_entry:
   300 00000016 CB90<rep 3h>        <1>  fill 4, 90h, retf
   389                                  shim_device_header.device_entrypoint:
   390 0000001A 26C747030001            	mov word [es:bx + 3], 0100h	; no error, done
   391 00000020 26807F020E              	cmp byte [es:bx + 2], 0Eh	; command code 0Eh (close) ?
   392 00000025 7406                    	je .retf			; yes, accept it -->
   393 00000027 26C747030381            	mov word [es:bx + 3], 8103h	; error, done, code: unknown command
   394 0000002D CB                      .retf:	retf
   395                                  
   396 0000002E 90<rep 2h>              	align 16
   397                                  deviceshim_size	equ $ - $$
   398                                  	endarea deviceshim, 1
   399                                  
   400                                  
   401                                  	usesection lDEBUG_DATA_ENTRY
   401          ------------------       note: usesection lDEBUG_DATA_ENTRY
   402                                  %else
   403                                  deviceshim_size	equ 0
   404                                  %endif
   405                                  
   406                                  
   407                                  	align 2, db 0
   408                                  N_BUFFER_END equ $		; end of N buffer (starts in PSP at 80h)
   409                                  
   410 0000016E [0000][0000][0000]-     cmdlist:	repeatdw aa,bb,cc,ddd,ee,ff,gg,hh,ii,error,kk,ll,mm,nn,oo
   410 00000174 [0000][0000][0000]-
   410 0000017A [0000][0000][0000]-
   410 00000180 [3E16][770B][0000]-
   410 00000186 [0000][580B][0000] 
   411 0000018C [0000][980E][0000]-     		repeatdw pp,qq,rr,sss,tt,uu,vv,ww,xx,yy
   411 00000192 [0000][0000][0000]-
   411 00000198 [0000][0000][3E16]-
   411 0000019E [0000]             
   412                                  %if _SYMBOLIC
   413                                  		dw zz
   414                                  %endif
   415                                  
   416                                  %if _LOADER
   417                                  aa equ error
   418                                  cc equ error
   419                                  kk equ error
   420                                  ll equ error
   421                                  nn equ error
   422                                  pp equ error
   423                                  tt equ error
   424                                  ww equ error
   425                                  %endif
   426                                  
   427                                  
   428                                  %ifn _LINK
   429                                  %include "options.mac"
   430                                  %endif
   431                                  
   432                                  	align 4, db 0
   433                                  				; options, startoptions and internalflags
   434                                  				; have to be consecutive
   435 000001A0 00000000                options:	dd DEFAULTOPTIONS ; run-time options
   436 000001A4 10410080                options2:	dd DEFAULTOPTIONS2
   437 000001A8 0F000060                options3:	dd DEFAULTOPTIONS3
   438 000001AC 02000000                options4:	dd DEFAULTOPTIONS4
   439 000001B0 00000000                options5:	dd 0
   440 000001B4 00000100                options6:	dd DEFAULTOPTIONS6
   441 000001B8 00200000                options7:	dd DEFAULTOPTIONS7
   442                                  	; options, options2, options3, options4, options5, options6, options7
   443                                  	;  are each assumed to be dwords
   444                                  	;  and all consecutive in expr.asm isvariable?
   445                                  
   446 000001BC 00000000                startoptions:	dd DEFAULTOPTIONS ; options as determined during startup; read-only for user
   447 000001C0 10410080                startoptions2:	dd DEFAULTOPTIONS2
   448 000001C4 0F000060                startoptions3:	dd DEFAULTOPTIONS3
   449 000001C8 02000000                startoptions4:	dd DEFAULTOPTIONS4
   450 000001CC 00000000                startoptions5:	dd 0
   451 000001D0 00000100                startoptions6:	dd DEFAULTOPTIONS6
   452 000001D4 00200000                startoptions7:	dd DEFAULTOPTIONS7
   453                                  	; startoptions, startoptions2, startoptions3, startoptions4,
   454                                  	;  startoptions5, startoptions6
   455                                  	;  are each assumed
   456                                  	;  to be dwords and all consecutive in expr.asm isvariable?
   457                                  
   458 000001D8 F8308000                internalflags:	dd attachedterm|pagedcommand|notstdinput|inputfile|notstdoutput|outputfile|debuggeeA20|debuggerA20
   459                                  				; flags only modified by DEBUG itself
   460                                  internalflags2:
   461                                  %if _SYMBOLIC
   462                                  		dd dif2_sym_req_xms | dif2_sym_req_86mm
   463                                  %else
   464 000001DC 00000000                		dd 0
   465                                  %endif
   466 000001E0 80040000                internalflags3:	dd dif3_partition_changed | dif3_at_line_end
   467 000001E4 00000000                internalflags4:	dd 0
   468 000001E8 00000000                internalflags5:	dd 0
   469                                  internalflags6:
   470                                  %if _MCP
   471                                   %assign DIF6MCP dif6_mcp
   472                                  %else
   473                                   %assign DIF6MCP 0
   474                                  %endif
   475                                  %if (_DEBUG && ! _DEBUG_COND) || _LOADER
   476                                  		dd DIF6MCP | dif6_debug_mode	; always indicate debuggable
   477                                  %else
   478 000001EC 00000000                		dd DIF6MCP
   479                                  %endif
   480 000001F0 00000000                internalflags7:	dd 0
   481                                  	; internalflags, internalflags2, internalflags3, internalflags4,
   482                                  	;  internalflags5, internalflags6, internalflags7
   483                                  	;  are each assumed
   484                                  	;  to be dwords and all consecutive in expr.asm isvariable?
   485                                  
   486                                  %if !_LOADER
   487 000001F4 07F00000                asm_options:	dd DEFAULTASMOPTIONS
   488                                  asm_startoptions:
   489 000001F8 07F00000                		dd DEFAULTASMOPTIONS
   490                                  
   491 000001FC 00000000                gg_first_cseip_linear:	dd 0
   492 00000200 00000000                gg_next_cseip_linear:	dd 0
   493 00000204 00000000                tpg_possible_breakpoint:dd 0
   494 00000208 [0000]                  gg_deferred_message:	dw msg.empty_message
   495                                  bb_deferred_message_in_lineout_behind:
   496 0000020A 0000                    			dw 0
   497                                  		align 4, db 0
   498 0000020C 00<rep 9h>              tpg_proceed_bp:		times BPSIZE db 0
   499                                  %if _DEBUG1
   500                                  		align 2, db 0
   501                                  test_records_Readmem:		times 6 * 16 db 0
   502                                  test_records_Writemem:		times 6 * 16 db 0
   503                                  test_records_getLinear:		times 6 * 16 db 0
   504                                  test_records_getSegmented:	times 6 * 16 db 0
   505                                  
   506                                  test_readmem_value:		db 0
   507                                  %endif
   508 00000215 00                      pp_instruction:		db 0
   509                                  %if _RH
   510 00000216 00                      skip_rh:	db 0
   511                                  %endif
   512                                  %if _RH || _SWHILEBUFFER || _RECMDWHILEBUFFER || _EXTENSIONS
   513 00000217 00                      in_re:		db 0
   514                                  %endif
   515                                  		align 4, db 0
   516 00000218 00000000                pp_operand:		dd 0
   517                                  %if _PM && _DEBUG_PM_ENTRY
   518                                  debug_pm_entry_total:	dd 0
   519                                  debug_pm_entry_esph:	dd 0
   520                                  debug_pm_entry_b:	dd 0
   521                                  %endif
   522                                  %endif
   523                                  %if _LOADER
   524                                  currentposition:	db 2	; 0 = bottom, 1 = top, 2 = hidden
   525                                  			db 0
   526                                  %endif
   527                                  		align 2, db 0
   528 0000021C 0000                    code_seg:	dw 0		; LOADER-relocate
   529                                  %if _PM
   530 0000021E 0000                    code_sel:	dw 0
   531                                  %endif
   532                                  %if _DUALCODE
   533 00000220 0000                    code2_seg:	dw 0
   534                                   %if _PM
   535 00000222 0000                    code2_sel:	dw 0
   536                                   %endif
   537                                  %endif
   538                                  %if _IMMASM
   539 00000224 0000                    immseg:		dw 0
   540                                  %endif
   541                                  %if _MESSAGESEGMENT
   542                                   %if _ELDLINKINFO
   543 00000226 [0000]                  linkinfoaddress:dw linkinfo
   544                                   %endif
   545 00000228 0000                    messageseg:	dw 0		; LOADER-relocate
   546                                   %if _PM
   547 0000022A 0000                    messagesel:	dw 0
   548                                   %endif
   549                                  %endif
   550                                  %if _EXTENSIONS
   551 0000022C 0000                    extseg:		dw 0		; LOADER-relocate
   552                                   %if _PM
   553 0000022E 0000                    extcssel:	dw 0
   554                                   %if extseg + 2 != extcssel
   555                                    %error code_ret_to_ext expects extcssel after extseg
   556                                   %endif
   557 00000230 0000                    extdssel:	dw 0
   558                                   %else
   559                                  extcssel equ extseg
   560                                  extdssel equ extseg
   561                                   %endif
   562                                  %endif
   563                                  %if _APP_ENV_SIZE || _DEV_ENV_SIZE || _BOOT_ENV_SIZE
   564 00000232 0000                    envseg:		dw 0		; (includes pseudo-MCB)	; LOADER-relocate
   565 00000234 0000                    env_size:	dw 0
   566                                  %endif
   567                                  
   568                                  %if _LINK
   569 00000236 [7050]                  entryseg_size:		dw end_of_datastack
   570 00000238 [0000]                  code_size:		dw behind_code wrt lDEBUG_CODE	; may truncate
   571                                  %if _DUALCODE
   572 0000023A [0000]                  code2_size:		dw behind_code2 wrt lDEBUG_CODE2
   573                                  %endif
   574                                  %if _HISTORY_SEPARATE_FIXED && _HISTORY
   575 0000023C 0020                    historyseg_size:	dw historysegment_boot_size
   576                                  %endif
   577                                  %if _MESSAGESEGMENT
   578 0000023E [0000]                  messageseg_size:	dw behind_messagesegment_nobits wrt MESSAGESEGMENT
   579                                  						; may truncate
   580                                  %endif
   581                                  %if _HELP_COMPRESSED && _BOOTLDR_DISCARD_HELP
   582                                  indirect_hshrink_message_buffer:
   583 00000240 [0000]                  			dw nontruncated_hshrink_message_buffer
   584                                  %endif
   585                                  %else
   586                                  entryseg_size:		dw 100h + DATAENTRYTABLESIZE + datastack_size
   587                                  code_size:		dw ldebug_code_size	; may truncate
   588                                  %if _DUALCODE
   589                                  code2_size:		dw ldebug_code2_size
   590                                  %endif
   591                                  %if _HISTORY_SEPARATE_FIXED && _HISTORY
   592                                  historyseg_size:	dw historysegment_boot_size
   593                                  %endif
   594                                  %if _MESSAGESEGMENT
   595                                  messageseg_size:	dw messagesegment_nobits_size	; may truncate
   596                                  %endif
   597                                  %if _HELP_COMPRESSED && _BOOTLDR_DISCARD_HELP
   598                                  indirect_hshrink_message_buffer:
   599                                  			dw nontruncated_hshrink_message_buffer
   600                                  %endif
   601                                  %endif
   602                                  
   603                                  %if _EXTENSIONS
   604 00000242 0020                    extseg_size:		dw extsegment_size
   605 00000244 0000                    extseg_used:		dw 0
   606 00000246 [7010]                  extdata:		dw ext_data_area
   607 00000248 0040                    extdata_size:		dw ext_data_area.size
   608 0000024A 0000                    extdata_used:		dw 0
   609 0000024C 0000                    ext_command_handler:	dw 0
   610 0000024E 0000                    ext_preprocess_handler:	dw 0
   611 00000250 0000                    ext_inject_handler:	dw 0
   612                                  %if !_LOADER
   613 00000252 0000                    ext_aa_before_getline_handler:	dw 0
   614 00000254 0000                    ext_aa_inject_handler:		dw 0
   615 00000256 0000                    ext_aa_after_getline_handler:	dw 0
   616                                  %endif
   617 00000258 0000                    ext_puts_handler:	dw 0
   618 0000025A 0000                    ext_puts_copyoutput_handler:	dw 0
   619                                  %if _EXT_PUTS_GETLINE
   620 0000025C 0000                    ext_puts_getline_handler:	dw 0
   621                                  %endif
   622                                  %if _CATCHINT2D
   623 0000025E 0000                    ext_amis_handler:	dw 0
   624                                  %endif
   625                                  %if _EXT_PUTS_GETLINE
   626 00000260 00                      in_getinput:		db 0
   627 00000261 00                      			db 0	; reserved, zeroed in cmd3
   628                                  %endif
   629 00000262 0000                    pm_2_86m_0:		dw 0	; for fast, fl preserving dispatch
   630                                  
   631                                  extcall_table:
   632                                  .ret:
   633 00000264 [9414]                  	dw entry_ret_to_ext
   634                                   %if _PM
   635 00000266 0000                    	dw 0
   636                                   %endif
   637 00000268 [DD07]                  	dw code_ret_to_ext
   638                                   %if _PM
   639 0000026A 0000                    	dw 0
   640                                   %endif
   641                                   %if _DUALCODE
   642 0000026C [0800]                  	dw code2_ret_to_ext
   643                                    %if _PM
   644 0000026E 0000                    	dw 0
   645                                    %endif
   646                                   %endif
   647                                  
   648                                  .segsel:
   649 00000270 [760C]                  	dw pspdbg
   650                                   %if _PM
   651 00000272 [0000]                  	dw cssel
   652                                   %endif
   653 00000274 [1C02]                  	dw code_seg
   654                                   %if _PM
   655 00000276 [1E02]                  	dw code_sel
   656                                   %endif
   657                                   %if _DUALCODE
   658 00000278 [2002]                  	dw code2_seg
   659                                    %if _PM
   660 0000027A [2202]                  	dw code2_sel
   661                                    %endif
   662                                   %endif
   663                                  %endif
   664 0000027C 0000                    alloc_size:		dw 0
   665 0000027E 0000                    alloc_seg:		dw 0	; LOADER-relocate
   666                                  %if !_LOADER
   667 00000280 0000                    next_reserved_segment:	dw 0
   668 00000282 0000                    alloc_size_not_reserved:dw 0
   669 00000284 0000                    reserved_address:	dw 0
   670                                  %endif
   671                                  
   672 00000286 0D                      		db 13
   673 00000287 0D<rep 9h>              		align 16, db 13	; insure the cmdline_buffer is prefixed by CR
   674                                  cmdline_buffer:
   675                                  .size:		equ _RC_BUFFER_SIZE
   676 00000290 00<rep 100h>            		times .size db 0
   677                                  .end:
   678 00000390 [9002]                  .position:	dw cmdline_buffer
   679                                  
   680                                  %if !_LOADER
   681 00000392 0D                      		db 13
   682 00000393 0D                      		align 2, db 13	; insure the re_buffer is prefixed by CR
   683                                  re_buffer:
   684                                  .size:		equ _RE_BUFFER_SIZE
   685 00000394 405200<rep 7FEh>        		fill .size,0,db "@R"
   686                                  .end:
   687 00000B94 [9403]                  .position:	dw re_buffer
   688                                  
   689 00000B96 00<rep 2h>              		align 4, db 0
   690 00000B98 00000000                re_count:	dd 0
   691 00000B9C 00010000                re_limit:	dd 256
   692                                  %endif
   693                                  		align 4, db 0
   694 00000BA0 00000000                rc_count:	dd 0
   695 00000BA4 00100000                rc_limit:	dd 4096
   696                                  
   697                                  		align 2, db 0
   698 00000BA8 0000                    cmd3_set_options:		dw 0
   699                                  %if _PM
   700 00000BAA 0000                    auxbuff_switchbuffer_size:	dw 0
   701                                  %endif
   702 00000BAC 00<rep 6h>              auxbuff_segorsel:segonlyaddress		; LOADER-relocate
   703                                  %if !_LOADER
   704                                  auxbuff_behind_last_silent:
   705 00000BB2 0000                    		dw 0		; -> behind last silent buffer entry
   706                                  %if _RH
   707                                  auxbuff_start_silent:
   708 00000BB4 0000                    		dw 0
   709                                  auxbuff_amount_silent:
   710 00000BB6 0000                    		dw 0
   711                                  %endif
   712                                  %endif
   713                                  auxbuff_current_size:
   714 00000BB8 1020                    		dw auxbuff_size
   715                                  %if _ELDLINKINFO || _AUXBUFFSIZE != _AUXBUFFMAXSIZE
   716                                  auxbuff_current_size_minus_24:
   717 00000BBA F81F                    		dw auxbuff_size - 24
   718                                  %endif
   719                                  
   720                                  %if !_LOADER
   721                                  tt_silent_mode_number:
   722 00000BBC 0000                    		dw 0		; if non-zero: maximum amount of dumps
   723                                  				;  displayed after T/TP/P while silent
   724                                  %endif
   725                                  %if _SYMBOLIC
   726                                  created_psp:	dw 0
   727                                  created_size:	dw 0
   728                                  %endif
   729                                  %if _CONFIG
   730 00000BBE 0000                    yy_boot_attempt_open_stack:	dw 0
   731 00000BC0 0000                    yy_boot_attempt_open_pathname:	dw 0
   732                                  %endif
   733                                  
   734                                  %if _INPUT_FILE_HANDLES
   735 00000BC2 90<rep 6h>              		align INPUTFILEHANDLE_size
   736                                  input_file_handles:
   737 00000BC8 FF<rep 80h>             		times _INPUT_FILE_HANDLES * INPUTFILEHANDLE_size db -1
   738 00000C48 0000                    .active:	dw 0
   739 00000C4A 0000                    .to_close:	dw 0
   740                                  %endif
   741                                  	align 2, db 0
   742 00000C4C 0142                    indos_remember_seek_function:	dw 4201h
   743 00000C4E FFFF                    indos_remember_seek_handle:	dw -1
   744                                  	align 4, db 0
   745 00000C50 00000000                indos_remember_seek_offset:	dd 0
   746                                  %if _INPUT_FILE_BOOT
   747                                  	align 4, db 0
   748 00000C54 00000000                boot_remember_seek_offset:	dd 0
   749                                  	align 2, db 0
   750 00000C58 FFFF                    boot_remember_seek_handle:	dw -1
   751                                  %endif
   752                                   %if _EXTENSIONS
   753                                  	alignb 2
   754 00000C5A FFFF                    ext_handle:	dw -1
   755                                   %endif
   756                                  
   757 00000C5C 00                      charcounter:	db 0		; used by raw output to handle tab
   758 00000C5D 00                      linecounter:	db 0		; used by paging in puts
   759 00000C5E 00<rep 2h>              	align 4, db 0
   760 00000C60 [7010]                  savesp:		dw stack_end	; saved stack pointer
   761 00000C62 0000                    		dw 0		; 0 to set high word of esp
   762                                  %if !_LOADER
   763 00000C64 0000                    re_sp:		dw 0
   764                                  %endif
   765 00000C66 [0000]                  errret:		dw cmd3		; return here if error
   766 00000C68 [6C16]                  throwret:	dw errhandler	; return here if error - priority, no display
   767 00000C6A [7010]                  throwsp:	dw stack_end	; stack pointer set before jumping to throwret
   768 00000C6C 0000                    run_sp:		dw 0		; stack pointer when running
   769 00000C6E 0000                    		dw 0		; (zero for esph)
   770 00000C70 0000                    run_sp_reserve:	dw 0		; additional space to reserve between the
   771                                  				;  near return address of run and the run_sp
   772 00000C72 4000                    spadjust:	dw 40h 		; adjust sp by this amount for save
   773                                  %if _SYMBOLIC
   774                                  stack_low_address:
   775                                  		dw str_buffer	; low end of stack, default = str_buffer
   776                                  %endif
   777                                  
   778                                  %if !_LOADER
   779 00000C74 0000                    pspdbe:		dw 0		; debuggee's PSP (86M segment)
   780                                  				;  unless DIF&attachedterm or bootloaded
   781                                  %endif
   782                                  %ifn _MESSAGESEGMENT
   783                                   %if _ELDLINKINFO
   784                                  linkinfoaddress:dw linkinfo
   785                                   %endif
   786                                  %endif
   787 00000C76 0000                    pspdbg:		dw 0		; debugger's PSP (86M segment)	; LOADER-relocate
   788                                  
   789                                  %if _LINK
   790                                   %ifn _PM
   791                                  dssel equ pspdbg
   792                                   %endif
   793                                  %endif
   794                                  
   795                                  %if !_LOADER
   796                                  	align 4, db 0
   797 00000C78 0000000000000000        run2324:	dd 0,0		; debuggee's interrupt vectors 23h and 24h (both modes)
   798                                  %if _PM
   799 00000C80 00000000                		dd 0
   800 00000C84 [0000][0000]            dbg2324:	dw i23pm, i24pm
   801                                  %endif
   802                                  %if _VDD
   803 00000C88 FFFF                    hVdd:		dw -1		; NTVDM VDD handle
   804                                  %endif
   805 00000C8A 00<rep 2h>              	align 4, db 0
   806 00000C8C 0000000000000000        sav2324:	dd 0,0		; debugger's interrupt vectors 23h and 24h (real-mode only)
   807 00000C94 00                      hakstat:	db 0		; whether we have hacked the vectors or not
   808                                  %if _MS_0RANGE_COMPAT
   809 00000C95 00                      getrange_is_uu:	db 0
   810                                  %endif
   811 00000C96 00<rep 2h>              	align 4, db 0
   812 00000C98 00000000                psp22:		dd 0		; original terminate address from our PSP
   813 00000C9C 0000                    parent:		dw 0		; original parent process from our PSP (must follow psp22)
   814                                  %if _MCB || _INT || _EXTENSIONS
   815 00000C9E FFFF                    firstmcb:	dw -1		; start of MCB chain (always segment)
   816 00000CA0 FFFF                    firstumcb:	dw -1
   817                                  %endif
   818 00000CA2 00<rep 8h>              pInDOS:		segofs16address	; far16 address of InDOS flag (bimodal)
   819                                  %if _USESDA
   820 00000CAA FFFFFFFFFFFFFFFF        pSDA:		segofs16address minusone
   821                                  				; far16 address of SDA (bimodal)
   822                                  %endif
   823                                  %endif
   824 00000CB2 00                      machine:	db 0		; type of processor for assembler and disassembler (1..6)
   825 00000CB3 00                      has_87:		db 0		; if there is a math coprocessor present
   826 00000CB4 00                      mach_87:	db 0		; type of coprocessor present
   827 00000CB5 00                      encodedmach87:	db 0		; C0 = no coproceasor, C = coprocessor present,
   828                                  				;  C2 = 287 present on a 386
   829                                  %if _MMXSUPP
   830 00000CB6 00                      has_mmx:	db 0
   831                                  %endif
   832                                  %if _VXCHG
   833                                   %ifn _VXCHGBIOS
   834 00000CB7 00                      		align 4, db 0
   835 00000CB8 00000000                xmsdrv:	dd 0		; XMM driver address, obtained thru int 2F, ax=4310h
   836                                  xmsmove:istruc XMSM	; XMS block move struct, used to save/restore screens
   837 00000CBC 00<rep 10h>             	iend
   838                                   %endif
   839                                  align 2, db 0
   840 00000CCC 0000                    csrpos:	dw 0		; cursor position of currently inactive screen
   841 00000CCE 00                      vrows:	db 0		; current rows; to see if debuggee changed video mode
   842                                  %endif
   843                                  %if _ALTVID		; exchange some video BIOS data fields for option /2.
   844 00000CCF 0000                    oldcsrpos:	dw 0	; cursor position
   845 00000CD1 0000                    oldcrtp:	dw 0	; CRTC port
   846 00000CD3 5000                    oldcols:	dw 80	; columns
   847                                  oldmr:	; label word
   848 00000CD5 00                      oldmode:	db 0	; video mode
   849 00000CD6 18                      oldrows:	db 24	; rows - 1
   850                                  %endif
   851 00000CD7 01                      bInDbg:		db 1		; 1=debugger is running
   852 00000CD8 0A                      notatty:	db 10		; if standard input is from a file
   853                                  				; this is also used for a linebreak processing hack
   854 00000CD9 00                      vpage:		db 0		; video page the debugger is to use for BIOS output
   855                                  %if _MCLOPT
   856                                  master_pic_base:db _MCLOPT_DEFAULT
   857                                  %endif
   858 00000CDA 00                      switchar:	db 0		; switch character
   859 00000CDB 20                      swch1:		db ' '		; switch character if it's a slash
   860                                  	align 2, db 0
   861                                  dd_default_length:
   862 00000CDC 8000                    		dw 80h
   863                                  dd_default_lines:
   864 00000CDE 0000                    		dw 0
   865                                  %if !_LOADER
   866                                  uu_default_length:
   867 00000CE0 2000                    		dw 20h
   868                                  uu_default_lines:
   869 00000CE2 0000                    		dw 0
   870                                  %endif
   871 00000CE4 0000                    promptlen:	dw 0		; length of prompt
   872 00000CE6 [1200]                  bufnext:	dw line_in+2	; address of next available character
   873 00000CE8 [1200]                  bufend:		dw line_in+2	; address + 1 of last valid character
   874                                  %if _EXTENSIONS
   875                                  indirect_array_errfix:
   876 00000CEA 0000                    		dw 0		; -> errfix.eld's array, 0 if none installed
   877                                  %endif
   878 00000CEC 0000                    rc:		dw 0
   879 00000CEE 0000                    priorrc:	dw 0
   880 00000CF0 0000                    erc:		dw 0
   881                                  %if _HISTORY
   882                                  history:
   883                                   %if _HISTORY_SEPARATE_FIXED
   884 00000CF2 00<rep 6h>              .segorsel:	segonlyaddress	; LOADER-relocate
   885 00000CF8 FE1F                    .first:		dw historysegment_boot_size - 2
   886 00000CFA FE1F                    .last:		dw historysegment_boot_size - 2
   887                                   %else
   888                                  .first:		dw historybuffer.end - 2
   889                                  .last:		dw historybuffer.end - 2
   890                                   %endif
   891                                  %endif
   892                                  
   893                                  var_addr_entries:
   894                                  %if !_LOADER
   895 00000CFC 00<rep Ah>              a_addr:		segmentedaddress; address for next A command
   896                                  %endif
   897 00000D06 00<rep Ah>              d_addr:		segmentedaddress; address for next D command; must follow a_addr
   898                                  %if !_LOADER
   899 00000D10 00<rep Ah>              behind_r_u_addr:segmentedaddress; address behind R's disassembly
   900 00000D1A 00<rep Ah>              u_addr:		segmentedaddress; address for next U command; must follow d_addr
   901                                  %endif
   902 00000D24 00<rep Ah>              e_addr:		segmentedaddress; address for current/next E command
   903                                  %if _DSTRINGS
   904 00000D2E 00<rep Ah>              dz_addr:	segmentedaddress; address for next ASCIZ string
   905 00000D38 00<rep Ah>              dcpm_addr:	segmentedaddress; address for next $-terminated string
   906 00000D42 00<rep Ah>              dcount_addr:	segmentedaddress; address for next byte-counted string
   907 00000D4C 00<rep Ah>              dwcount_addr:	segmentedaddress; address for next word-counted string
   908                                  %endif
   909                                  var_addr_entries.amount equ ($ - var_addr_entries) / SEGADR_size
   910                                  %if _DX
   911                                  x_addr:		dd 0		; (phys) address for next DX command
   912                                  %endif
   913                                  %if _DSTRINGS
   914 00000D56 00                      dstringtype:	db 0		; FFh byte-counted, FEh word-counted, else terminator byte
   915 00000D57 00                      	align 2, db 0
   916 00000D58 [2E0D]                  dstringaddr:	dw dz_addr	; -> address of last string
   917                                  %endif
   918                                  %if _INT
   919 00000D5A 00<rep 2h>              	align 4, db 0
   920 00000D5C 00000000                intaddress:	dd 0
   921                                  lastint_is_86m_and_mcb:
   922 00000D60 0000                    		dw 0
   923 00000D62 00                      lastint:	db 0
   924                                  %endif
   925                                  %if !_LOADER
   926 00000D63 00                      	align 4, db 0
   927                                  search_results:
   928                                  %if _PM
   929 00000D64 00<rep 60h>             		times 6 * search_results_amount db 0
   930                                  %else
   931                                  		times 4 * search_results_amount db 0
   932                                  %endif
   933                                  	align 4, db 0
   934 00000DC4 00000000                sscounter:	dd 0
   935 00000DC8 00                      eqflag:		db 0		; flag indicating presence of `=' operand
   936 00000DC9 00                      	align 2, db 0
   937 00000DCA 000000000000            eqladdr:	dw 0,0,0	; address of `=' operand in G, P and T command
   938                                  	align 2, db 0
   939 00000DD0 0000                    run_int:	dw 0		; interrupt type that stopped the running
   940                                  %endif
   941 00000DD2 [B105]                  lastcmd:	dw dmycmd
   942                                  %if _EXTENSIONS
   943                                  lastcmd_transfer_ext_address:
   944 00000DD4 0000                    		dw 0
   945                                  near_transfer_ext_address:
   946 00000DD6 0000                    		dw 0
   947                                  %endif
   948                                  %if !_LOADER
   949 00000DD8 00                      fileext:	db 0		; file extension (0 if no file name)
   950                                  %endif
   951                                  
   952 00000DD9 00<rep 3h>              	align 4, db 0
   953 00000DDC 00000000                mmxbuff:	dd 0		; buffer with a (read-only) part of MMX register
   954                                  				; for access from within expressions
   955                                  %if _CATCHINT08
   956 00000DE0 0000                    intr8_counter:	dw 0
   957 00000DE2 5A00                    intr8_limit:	dw 18 * 5	; ca 5 seconds
   958                                  %endif
   959                                  %if !_LOADER
   960 00000DE4 00                      maxmachinetype:	db 0
   961                                  %endif
   962                                  serial_rows:
   963 00000DE5 18                      		db 24
   964                                  serial_columns:
   965 00000DE6 50                      		db 80
   966                                  serial_keep_timeout:
   967 00000DE7 0F                      		db 15
   968                                  %if _USE_TX_FIFO
   969                                  serial_fifo_size:
   970 00000DE8 10                      		db _BI_TX_FIFO_SIZE
   971                                  			; size of built-in TX fifo (1 is as if no FIFO)
   972                                  %endif
   973 00000DE9 00                      serial_flags:	db 0	; flags in options.mac
   974                                  
   975 00000DEA 0B                      serial_var_intnum:	db _INTNUM
   976 00000DEB 03                      serial_var_params:	db _UART_PARAMS
   977 00000DEC 00                      serial_var_fifo:	db _UART_FIFO
   978 00000DED 00                      	align 2, db 0
   979 00000DEE F802                    serial_var_baseport:	dw _UART_BASE
   980 00000DF0 0C00                    serial_var_dl:		dw _UART_RATE
   981 00000DF2 0800                    serial_var_irqmask:	dw _OFFMASK
   982                                  
   983 00000DF4 01                      io_rows:	db 1
   984 00000DF5 01                      io_columns:	db 1
   985                                  	align 2, db 0
   986                                  %if _40COLUMNS
   987 00000DF6 0000                    io_columns_getline:	dw 0			; byte variable zero-extended
   988                                  %endif
   989 00000DF8 0000                    io_start_buffer:	dw 0
   990 00000DFA 0000                    io_end_buffer:		dw 0
   991 00000DFC FF00                    io_levels:		dw 255
   992 00000DFE 0300                    io_flags:		dw DEFAULTIOFLAGS
   993                                  iof_extra_iol_for_tpg_re:	equ 1
   994                                  iof_extra_iol_for_rc:		equ 2
   995                                  DEFAULTIOFLAGS equ iof_extra_iol_for_tpg_re | iof_extra_iol_for_rc
   996                                  
   997                                  	align 2, db 0
   998 00000E00 0000                    getline_timer_count:	dw 0
   999 00000E02 0000                    getline_timer_last:	dw 0
  1000 00000E04 [B105]                  getline_timer_func:	dw dmycmd
  1001                                  
  1002                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  1003                                  	align 2, db 0
  1004 00000E06 0000                    if_exists_then_address:	dw 0
  1005 00000E08 0000                    if_exists_si:		dw 0
  1006 00000E0A 0000                    if_exists_sp:		dw 0
  1007 00000E0C 0000                    if_exists_length:	dw 0
  1008                                  %endif
  1009                                  
  1010                                  	align 2, db 0
  1011                                  terminator_in_line_in:
  1012 00000E0E 0000                    .offset:		dw 0
  1013 00000E10 00                      .value:			db 0
  1014                                  
  1015                                  %if !_LOADER
  1016 00000E11 00                      qqtermcode:		db 0
  1017                                  	align 2, db 0
  1018 00000E12 0000                    device_mcb_paragraphs:	dw 0
  1019 00000E14 00000000                device_header_address:	dd 0
  1020                                  %endif
  1021                                  
  1022                                  	align 2, db 0
  1023                                  inttab_optional:
  1024                                  .:
  1025                                  serial_installed_intnum: equ $
  1026 00000E18 0001                    	dw 100h
  1027 00000E1A [0000]                  	dw serial_interrupt_handler
  1028 00000E1C 0100                    	dw dif4_int_serial_hooked
  1029                                  %if _LOADER
  1030                                  	dw 118h
  1031                                  	dw intr_loader_18
  1032                                  	dw dif4_int_18_hooked
  1033                                  	dw 119h
  1034                                  	dw intr_loader_19
  1035                                  	dw dif4_int_19_hooked
  1036                                  %endif
  1037                                  %if _PM
  1038 00000E1E 2F01                    	dw 12Fh
  1039 00000E20 [0000]                  	dw debug2F
  1040 00000E22 0200                    	dw dif4_int_2F_hooked
  1041                                  %endif
  1042                                  %if _CATCHINT08
  1043 00000E24 0801                    	dw 108h
  1044 00000E26 [0000]                  	dw intr8
  1045 00000E28 0400                    	dw dif4_int_08_hooked
  1046                                  %endif
  1047                                  %if _CATCHINTFAULTCOND && _CATCHINT0D
  1048 00000E2A 0D01                    	dw 10Dh
  1049 00000E2C [0000]                  	dw intr0D
  1050 00000E2E 1000                    	dw dif4_int_0D_hooked
  1051                                  %endif
  1052                                  %if _CATCHINTFAULTCOND && _CATCHINT0C
  1053 00000E30 0C01                    	dw 10Ch
  1054 00000E32 [0000]                  	dw intr0C
  1055 00000E34 2000                    	dw dif4_int_0C_hooked
  1056                                  %endif
  1057                                  .amount: equ ($ - .) / 6
  1058 00000E36 0000                    	dw 0
  1059                                  
  1060                                  
  1061                                  amisintr_offset:
  1062 00000E38 [490E]                  	dw inttab
  1063                                  
  1064                                  inttab_pre:
  1065 00000E3A 00<rep Fh>              	times 3 * inttab_optional.amount db 0
  1066                                  
  1067                                  inttab:
  1068                                  %if _CATCHINT00
  1069 00000E49 00                      	db 0
  1070 00000E4A [0000]                  	dw intr0	; table of interrupt initialization stuff
  1071                                  %endif
  1072                                  %if _CATCHINT01
  1073 00000E4C 01                      	db 1
  1074 00000E4D [0000]                  	dw intr1
  1075                                  %endif
  1076                                  %if _CATCHINT03
  1077 00000E4F 03                      	db 3
  1078 00000E50 [0000]                  	dw intr3
  1079                                  %endif
  1080                                  %if _CATCHINT07
  1081                                  	db 7
  1082                                  	dw intr7
  1083                                  %endif
  1084                                  %if ! _CATCHINTFAULTCOND && _CATCHINT0C
  1085                                  	db 0Ch
  1086                                  	dw intr0C
  1087                                  %endif
  1088                                  %if ! _CATCHINTFAULTCOND && _CATCHINT0D
  1089                                  	db 0Dh
  1090                                  	dw intr0D
  1091                                  %endif
  1092                                  %if _CATCHINT18
  1093 00000E52 18                      	db 18h
  1094 00000E53 [0000]                  	dw intr18
  1095                                  %endif
  1096                                  %if _CATCHINT19
  1097 00000E55 19                      	db 19h
  1098 00000E56 [0000]                  	dw intr19
  1099                                  %endif
  1100                                  %if _CATCHSYSREQ
  1101                                  	db _SYSREQINT
  1102                                  	dw intr_sysreq
  1103                                  %endif
  1104                                  %if _CATCHINT06
  1105 00000E58 06                      .i06:	db 6
  1106 00000E59 [0000]                  	dw intr6
  1107                                  %endif
  1108                                  	endarea inttab
  1109                                  	inttab_number equ inttab_size / 3
  1110                                  %if _CATCHINT2D
  1111 00000E5B 2D                      .i2D:	db 2Dh
  1112 00000E5C [0000]                  	dw int2D
  1113                                  %endif
  1114                                  
  1115                                  
  1116                                  intforcetab:
  1117                                  %if _CATCHINT00
  1118 00000E5E 01                      	db opt4_int_00_force >> 24
  1119                                  %endif
  1120                                  %if _CATCHINT01
  1121 00000E5F 02                      	db opt4_int_01_force >> 24
  1122                                  %endif
  1123                                  %if _CATCHINT03
  1124 00000E60 04                      	db opt4_int_03_force >> 24
  1125                                  %endif
  1126                                  %if _CATCHINT07
  1127                                  	db opt4_int_07_force >> 24
  1128                                  %endif
  1129                                  %if _CATCHINT0C
  1130 00000E61 00                      	db opt4_int_0C_force >> 24
  1131                                  %endif
  1132                                  %if _CATCHINT0D
  1133 00000E62 00                      	db opt4_int_0D_force >> 24
  1134                                  %endif
  1135                                  %if _CATCHINT18
  1136 00000E63 10                      	db opt4_int_18_force >> 24
  1137                                  %endif
  1138                                  %if _CATCHINT19
  1139 00000E64 20                      	db opt4_int_19_force >> 24
  1140                                  %endif
  1141                                  %if _CATCHSYSREQ
  1142                                   %if _SYSREQINT == 09h
  1143                                  	db opt4_int_09_force >> 24
  1144                                   %elif _SYSREQINT == 15h
  1145                                  	db opt4_int_15_force >> 24
  1146                                   %else
  1147                                    %error Unknown SysReq interrupt
  1148                                   %endif
  1149                                  %endif
  1150                                  %if _CATCHINT06
  1151 00000E65 08                      	db opt4_int_06_force >> 24
  1152                                  %endif
  1153                                  
  1154                                  %if _CATCHINT06 && _DETECT95LX
  1155                                  	align 2, db 0
  1156                                  inttab_number_variable:
  1157 00000E66 0600                    	dw inttab_number
  1158                                  %endif
  1159                                  
  1160                                  
  1161                                  %if !_LOADER
  1162                                  	align 2, db 0
  1163                                  		; Parameter block for EXEC call
  1164                                  execblk:
  1165 00000E68 0000                    		dw 0		;(00) zero: copy the parent's environment
  1166 00000E6A 00000000                .cmdline:	dw 0,0		;(02) address of command tail to copy
  1167 00000E6E 5C000000                .fcb1:		dw 5Ch,0	;(06) address of first FCB to copy
  1168 00000E72 6C000000                .fcb2:		dw 6Ch,0	;(10) address of second FCB to copy
  1169 00000E76 00000000                .sssp:		dw 0,0		;(14) initial SS:SP
  1170 00000E7A 00000000                .csip:		dw 0,0		;(18) initial CS:IP
  1171                                  %endif
  1172                                  
  1173                                  
  1174                                  		; Register save area (32 words).
  1175                                  		; must be DWORD aligned, used as stack
  1176 00000E7E 00<rep 2h>              	align 4, db 0
  1177                                  regs:
  1178 00000E80 00000000                reg_eax:	dd 0	;+00 eax
  1179 00000E84 00000000                reg_ebx:	dd 0	;+04 ebx
  1180 00000E88 00000000                reg_ecx:	dd 0	;+08 ecx
  1181 00000E8C 00000000                reg_edx:	dd 0	;+12 edx
  1182 00000E90 00000000                reg_esp:	dd 0	;+16 esp
  1183 00000E94 00000000                reg_ebp:	dd 0	;+20 ebp
  1184 00000E98 00000000                reg_esi:	dd 0	;+24 esi
  1185 00000E9C 00000000                reg_edi:	dd 0	;+28 edi
  1186 00000EA0 00000000                reg_ds:		dd 0	;+32  ds (high word unused)
  1187 00000EA4 00000000                reg_es:		dd 0	;+36  es (high word unused)
  1188 00000EA8 00000000                reg_ss:		dd 0	;+40  ss (high word unused)
  1189 00000EAC 00000000                reg_cs:		dd 0	;+44  cs (high word unused)
  1190 00000EB0 00000000                reg_fs:		dd 0	;+48  fs (high word unused)
  1191 00000EB4 00000000                reg_gs:		dd 0	;+52  gs (high word unused)
  1192 00000EB8 00000000                reg_eip:	dd 0	;+56 eip
  1193 00000EBC 00000000                reg_efl:	dd 0	;+60 efl(ags)
  1194                                  regs.end:
  1195                                  regs.size: equ regs.end - regs
  1196                                  regs.size_w equ regs.size / 2
  1197                                  
  1198                                  %if _REGSHIGHLIGHT
  1199                                  regs_prior:
  1200                                  .:
  1201 00000EC0 00000000<rep 10h>       	times 16 dd 0
  1202                                  .end:
  1203                                  .size: equ .end - .
  1204                                  .size_w equ .size / 2
  1205                                  
  1206                                  %if .size != regs.size
  1207                                   %error regs prior save area size mismatch
  1208                                  %endif
  1209                                  %endif
  1210                                  
  1211                                  %if _DEVICE
  1212                                  device_quittable_regs:
  1213                                  .:
  1214 00000F00 00000000<rep 10h>       	times 16 dd 0
  1215                                  .end:
  1216                                  .size: equ .end - .
  1217                                  .size_w equ .size / 2
  1218                                  
  1219                                  %if .size != regs.size
  1220                                   %error regs prior save area size mismatch
  1221                                  %endif
  1222                                  %endif
  1223                                  
  1224                                  %if _VARIABLES
  1225                                  vregs:
  1226                                  .amount: equ 256
  1227 00000F40 00000000<rep 100h>      	times .amount dd 0	; internal v0..vff
  1228                                   %if _LINK && VREGSAMOUNT != .amount
  1229                                    %error Wrong amount of vregs
  1230                                   %endif
  1231                                  %endif
  1232                                  
  1233                                  %if _BOOTLDR
  1234                                  	align 2, db 0
  1235                                  boot_init_foundname:
  1236 00001340 00<rep Dh>              	times 8+1+3+1 db 0
  1237                                  %endif
  1238                                  %if _EXECUTABLE
  1239 0000134D 00                      	align 2, db 0
  1240                                  init_executable_pathname:
  1241 0000134E 00<rep 80h>             	times 128 db 0
  1242 000013CE [4E13]                  .end:	dw init_executable_pathname
  1243                                  %endif
  1244                                  
  1245                                  ; possible byte encoding of lDebug variables for dynamic computations:
  1246                                  ; xxxxyyyy
  1247                                  ; 10: register
  1248                                  ;   xx: size (0 = 1, 1 = 2, 2 = 4)
  1249                                  ;     yyyy: 0..15: register as stored in the register save area
  1250                                  ;                  as SIL, DIL, BPL, SPL aren't supported these map to xH
  1251                                  ;                  xSL, IPL and FLL are invalid, ExS are invalid
  1252                                  ; 1011: variable
  1253                                  ;     yyyy: which variable. variables are always dword-sized
  1254                                  ; 11000000: 32-bit compound, next byte stores: xxxxyyyy first, second 16-bit reg
  1255                                  ; 11000001..11111111: available for encoding other compound regs, vars, indirection,
  1256                                  ;                     symbols, types etc
  1257                                  ; 0xxxxxxx: operators
  1258                                  
  1259                                  
  1260                                  %if !_LOADER
  1261                                  ; Instruction set information needed for the 'p' command.
  1262                                  ; ppbytes and ppinfo needs to be consecutive.
  1263 000013D0 6667262E363E6465F2-     ppbytes:db 66h,67h,26h,2Eh,36h,3Eh,64h,65h,0F2h,0F3h,0F0h	; prefixes
  1263 000013D9 F3F0               
  1264                                  PPLEN_ONLY_PREFIXES	equ $-ppbytes
  1265                                  .string:
  1266 000013DB ACADAAABA4A5            	db 0ACh,0ADh,0AAh,0ABh,0A4h,0A5h	; lods,stos,movs
  1267 000013E1 6C6D6E6F                	db 6Ch,6Dh,6Eh,6Fh			; ins,outs
  1268 000013E5 A6A7AEAF                	db 0A6h,0A7h,0AEh,0AFh			; cmps,scas
  1269                                  PPLEN_ONLY_STRING	equ $-ppbytes
  1270                                  .string_amount:		equ $ - .string
  1271 000013E9 CCCD                    	db 0CCh,0CDh				; int instructions
  1272 000013EB E0E1E2                  	db 0E0h,0E1h,0E2h			; loop instructions
  1273 000013EE E8                      	db 0E8h					; call rel16/32
  1274 000013EF 9A                      	db 09Ah					; call far seg16:16/32
  1275                                  ;	(This last one is done explicitly by the code.)
  1276                                  ;	db 0FFh					; FF/2 or FF/3: indirect call
  1277                                  
  1278                                  PPLEN	equ	$-ppbytes	; size of the above table
  1279                                  
  1280                                  ;	Info for the above, respectively. This MUST follow
  1281                                  ;	 immediately after ppbytes, as we add + PPLEN - 1 to
  1282                                  ;	 di after repne scasb to index into this (ppinfo).
  1283                                  ;	80h = prefix; 82h = operand size prefix; 81h = address size prefix.
  1284                                  ;	If the high bit is not set, the next highest bit (40h) indicates
  1285                                  ;	 that the instruction size depends on whether there is an operand
  1286                                  ;	 size prefix; if set, under o32 two bytes are added to the size.
  1287                                  ;	 (This is only used for direct near and far call.)
  1288                                  ;	If both the two highest bits are clear, then PP_STRDEST,
  1289                                  ;	 PP_STRSRC, or PP_STRSRC2 may be set. This only happens for
  1290                                  ;	 string instructions, which always are neither prefixes nor
  1291                                  ;	 use additional bytes.
  1292                                  ;	The remaining bits tell the number of additional bytes in the
  1293                                  ;	 instruction. This is at most 4. It must be below-or-equal to
  1294                                  ;	 7, or if PP_VARSIZ is used, 5 (so the sum stays below 8).
  1295                                  
  1296                                  %if 0	; moved to debug.mac
  1297                                  PP_ADRSIZ	equ 01h
  1298                                  PP_OPSIZ	equ 02h
  1299                                  PP_PREFIX	equ 80h
  1300                                  PP_VARSIZ	equ 40h
  1301                                  PP_STRDEST	equ 20h
  1302                                  PP_STRSRC	equ 10h
  1303                                  PP_STRSRC2	equ 08h
  1304                                  PP_SIZ_MASK	equ 07h
  1305                                  %endif
  1306                                  
  1307 000013F0 8281                    ppinfo:	db PP_PREFIX | PP_OPSIZ, PP_PREFIX | PP_ADRSIZ
  1308 000013F2 80<rep 9h>              	times 9 db PP_PREFIX		; prefixes
  1309 000013FB 1010                    	db PP_STRSRC, PP_STRSRC		; lods
  1310 000013FD 2020                    	db PP_STRDEST, PP_STRDEST	; stos
  1311 000013FF 3030                    	db PP_STRDEST | PP_STRSRC, PP_STRDEST | PP_STRSRC
  1312                                  					; movs
  1313 00001401 2020                    	db PP_STRDEST, PP_STRDEST	; ins
  1314 00001403 1010                    	db PP_STRSRC, PP_STRSRC		; outs
  1315 00001405 1818                    	db PP_STRSRC2 | PP_STRSRC, PP_STRSRC2 | PP_STRSRC
  1316                                  					; cmps
  1317 00001407 0808                    	db PP_STRSRC2, PP_STRSRC2	; scas
  1318 00001409 0001                    	db 0,1				; int
  1319 0000140B 010101                  	db 1,1,1			; loop
  1320 0000140E 42                      	db PP_VARSIZ | 2		; call rel16/32 with displacement
  1321 0000140F 44                      	db PP_VARSIZ | 4		; call far 16:16 or 16:32 immediate
  1322                                  
  1323                                  %if PPLEN != $-ppinfo
  1324                                   %error "ppinfo table has wrong size"
  1325                                  %endif
  1326                                  
  1327                                  
  1328                                  %include "asmops.mac"
     1                              <1> 
     2                              <1> %if 0
     3                              <1> 
     4                              <1> lDebug assembler/disassembler table operands
     5                              <1> 
     6                              <1> Copyright (C) 1995-2003 Paul Vojta
     7                              <1> Copyright (C) 2008-2026 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> ;	Equates for instruction operands.
    19                              <1> ;	First the sizes.
    20                              <1> 
    21                              <1> OP_ALL		equ 40h		; byte/word/dword operand (could be 30h but ...)
    22                              <1> OP_1632		equ 50h		; word or dword operand
    23                              <1> OP_8		equ 60h		; byte operand
    24                              <1> OP_16		equ 70h		; word operand
    25                              <1> OP_32		equ 80h		; dword operand
    26                              <1> OP_64		equ 90h		; qword operand
    27                              <1> OP_1632_DEFAULT	equ 0A0h	; word or dword or default opsize
    28                              <1> OP_1632_DEFAULT_ASM	equ 0B0h; asm: word or dword or default opsize,
    29                              <1> 				;  disasm: word or dword
    30                              <1> 
    31                              <1> OP_SIZE	equ OP_ALL		; the lowest of these
    32                              <1> 
    33                              <1> ;	These operand types need to be combined with a size.
    34                              <1> ;	Bits 0 to 3 give one of these types (maximum 15),
    35                              <1> ;	 and bits 4 to 7 specify the size. Table entries
    36                              <1> ;	 for these are identified by detecting that they
    37                              <1> ;	 are above-or-equal OP_SIZE.
    38                              <1> ;	The first parameter to the opsizeditem macro is the
    39                              <1> ;	 name of the item. It has to match the names used in
    40                              <1> ;	 the instr.key and debugtbl.inc files.
    41                              <1> ;	The second parameter is the entry for bittab that
    42                              <1> ;	 is used by aa.asm (the assembler).
    43                              <1> ;	The third parameter is the suffix used to create the
    44                              <1> ;	 entry for asmjmp (prefix aop_) and disjmp2 (dop_).
    45                              <1> 
    46                              <1> %macro opsizeditem 3.nolist
    47                              <1>  %1 equ nextindex
    48                              <1>  %xdefine BITTAB_OPSIZEDITEMS BITTAB_OPSIZEDITEMS,%2
    49                              <1>  %xdefine ASMJMP_OPSIZEDITEMS ASMJMP_OPSIZEDITEMS,aop_%3
    50                              <1>  %xdefine DISJMP2_OPSIZEDITEMS DISJMP2_OPSIZEDITEMS,dop_%3
    51                              <1>  %assign nextindex nextindex + 1
    52                              <1> %endmacro
    53                              <1> %assign nextindex 0
    54                              <1> %define BITTAB_OPSIZEDITEMS ""
    55                              <1> %define ASMJMP_OPSIZEDITEMS ""
    56                              <1> %define DISJMP2_OPSIZEDITEMS ""
    57                              <1> opsizeditem OP_IMM,	ARG_IMMED,	imm	; immediate
    58                              <1> opsizeditem OP_IMM_NOT_EXTEND,	ARG_IMMED,	imm_not_extend	; immediate
    59                              <1> 		; This one is for showing the WORD/DWORD size keyword if the
    60                              <1> 		;  value could fit into an imms8.
    61                              <1> opsizeditem OP_RM,ARG_DEREF+ARG_JUSTREG,rm	; reg/mem
    62                              <1> opsizeditem OP_M,	ARG_DEREF,	m	; mem (but not reg)
    63                              <1> opsizeditem OP_R_MOD,	ARG_JUSTREG,	r_mod	; register, determined from MOD R/M part
    64                              <1> opsizeditem OP_MOFFS,	ARG_DEREF,	moffs	; memory offset; e.g., [1234]
    65                              <1> opsizeditem OP_R,	ARG_JUSTREG,	r	; reg part of reg/mem byte
    66                              <1> opsizeditem OP_R_ADD,	ARG_JUSTREG,	r_add	; register, determined from instruction byte
    67                              <1> opsizeditem OP_AX,	ARG_JUSTREG,	ax	; al or ax or eax
    68                              <1> %if nextindex > 16
    69                              <1>  %error Too many op sized items
    70                              <1> %endif
    71                              <1> 
    72                              <1> ;	These don't need a size.
    73                              <1> ;	Because the size needs to be clear to indicate
    74                              <1> ;	 that one of these is to be used, the maximum
    75                              <1> ;	 value for these is 63 (as 64 is OP_SIZE).
    76                              <1> ;	The minimum value for these is 1 because a 0
    77                              <1> ;	 without size means the end of an op list (OP_END).
    78                              <1> ;	The first parameter to the opitem macro is the name
    79                              <1> ;	 of the item. It has to match the names used in the
    80                              <1> ;	 instr.key and debugtbl.inc files.
    81                              <1> ;	The second parameter is the entry for bittab that
    82                              <1> ;	 is used by aa.asm (the assembler). The third
    83                              <1> ;	 parameter is the entry for asmjmp.
    84                              <1> ;	The fourth parameter is the entry for optab as used
    85                              <1> ;	 by uu.asm (the disassembler).
    86                              <1> ;
    87                              <1> ;	asm_siznum contains entries for OP_M64 to OP_MXX.
    88                              <1> ;	 (The order has to match their opitem order.)
    89                              <1> ;	asm_regnum contains entries for OP_DX to OP_GS.
    90                              <1> ;	 (The order has to match their opitem order.)
    91                              <1> 
    92                              <1> %macro opitem 4.nolist
    93                              <1>  %1 equ nextindex
    94                              <1>  %xdefine BITTAB_OPITEMS BITTAB_OPITEMS,%2
    95                              <1>  %xdefine ASMJMP_OPITEMS ASMJMP_OPITEMS,%3
    96                              <1>  %xdefine OPTAB_OPITEMS OPTAB_OPITEMS,%4
    97                              <1>  %assign nextindex nextindex + 1
    98                              <1> %endmacro
    99                              <1> 	OP_END	equ 0
   100                              <1> %assign nextindex 1
   101                              <1> %define BITTAB_OPITEMS ""
   102                              <1> %define ASMJMP_OPITEMS ""
   103                              <1> %define OPTAB_OPITEMS ""
   104                              <1> 	; order of the following (ao17 entries) must match asm_siznum in aa.asm
   105                              <1> OP_FIRST_ASM_SIZNUM	equ nextindex	; corresponding to asm_siznum start
   106                              <1> opitem OP_M64,		ARG_DEREF,	ao17,dop_m64	; qword memory (obsolete?)
   107                              <1> opitem OP_MFLOAT,	ARG_DEREF,	ao17,dop_mfloat	; float memory
   108                              <1> opitem OP_MDOUBLE,	ARG_DEREF,	ao17,dop_mdouble; double-precision floating memory
   109                              <1> opitem OP_M80,		ARG_DEREF,	ao17,dop_m80	; tbyte memory
   110                              <1> opitem OP_MXX,		ARG_DEREF,	ao17,dop_mxx	; memory (size unknown)
   111                              <1> opitem OP_FARIMM,	ARG_FARADDR,	ao21,dop_farimm	; far16/far32 immediate
   112                              <1> opitem OP_FAR_OFFSET,	ARG_IMMED,	aop_faroffset,da_internal_error	; far offset-only
   113                              <1> opitem OP_REL8,		ARG_IMMED,	ao23,dop_rel8	; byte address relative to IP
   114                              <1> opitem OP_REL1632,	ARG_IMMED,	ao25,dop_rel1632; word or dword address relative to IP
   115                              <1> opitem OP_1CHK,		ARG_WEIRDREG,	ao29,dop49	; check for ST(1)
   116                              <1> opitem OP_STI,		ARG_WEIRDREG,	aop_sti,dop_sti	; ST(I)
   117                              <1> opitem OP_CR,		ARG_WEIRDREG,	aop_cr,dop_cr	; CRx
   118                              <1> opitem OP_DR,		ARG_WEIRDREG,	ao34,dop_dr	; DRx
   119                              <1> opitem OP_TR,		ARG_WEIRDREG,	ao35,dop_tr	; TRx
   120                              <1> opitem OP_SEGREG,	ARG_WEIRDREG,	ao39,dop_segreg	; segment register
   121                              <1> opitem OP_IMMS8,	ARG_IMMED,	ao41,dop_imms8 	; sign extended immediate byte
   122                              <1> opitem OP_IMMS8_EXTEND,	ARG_IMMED,	ao41_extend,dop_imms8		; add etc word/dword r/m, imms8
   123                              <1> opitem OP_IMM8,		ARG_IMMED,	ao42,dop_imm8	; immediate byte (other args may be (d)word)
   124                              <1> opitem OP_IMM8_OPTIONAL,ARG_IMMED,	ao42,dop_imm8_optional
   125                              <1> opitem OP_IMM8_INT,	ARG_IMMED,	ao42,dop_imm8_int		; immediate byte for int
   126                              <1> opitem OP_IMM8_SHIFTROT,ARG_IMMED,	ao42,dop_imm8_shiftrot		; immediate byte for shift/rotate
   127                              <1> opitem OP_MMX,		ARG_WEIRDREG,	aop_mmx,dop_mmx	; MMx
   128                              <1> opitem OP_MMX_MOD,	ARG_WEIRDREG,	aop_mmx_mod,dop_mmx_mod	; MMx, but in ModR/M part
   129                              <1> opitem OP_X,		0FFh,	ao_x,	dop_x		; OPX byte follows
   130                              <1> opitem OP_SHOSIZ,	0FFh,	ao44,	dop_shosiz	; set flag to always show the size
   131                              <1> opitem OP_ASM_MOVX,	0FFh,	ao_movx,dop60a		; enforce next operand size to be specified
   132                              <1> opitem OP_SHORT,	0FFh,	ao_short,dop_short	; allow short keyword
   133                              <1> opitem OP_NEAR,		0FFh,	ao_near,dop_near	; allow near keyword
   134                              <1> opitem OP_FAR,		0FFh,	ao_far,	dop_far		; allow far keyword
   135                              <1> opitem OP_FAR_REQUIRED,	0FFh,	ao_far_required,dop_far_required	; require far keyword
   136                              <1> opitem OP_FAR_M,	0FFh,	ao_modifier_continue,dop_far_m		; les, lds, lss, lfs, lgs, or jmp/call far mem
   137                              <1> opitem OP_DOUBLE_M,	0FFh,	ao_modifier_continue,dop_double_m	; bound
   138                              <1> opitem OP_M_SRC,	0FFh,	ao_modifier_continue,dop_m_src
   139                              <1> opitem OP_M_DST,	0FFh,	ao_modifier_continue,dop_m_dst
   140                              <1> opitem OP_M_SRC_DST,	0FFh,	ao_modifier_continue,dop_m_src_dst
   141                              <1> opitem OP_STACK_PUSH,	0FFh,	ac09_internal_error,dop_stack_push
   142                              <1> opitem OP_STACK_POP,	0FFh,	ac09_internal_error,dop_stack_pop
   143                              <1> opitem OP_STACK_SPECIAL,0FFh,	ac09_internal_error,dop_stack_special
   144                              <1> opitem OP_M_ALWAYS_16,	0FFh,	ao_m_always_16,dop_m_always_16
   145                              <1> opitem OP_E_CX,	ARG_JUSTREG,	aop_e_cx, da_e_cx			; (E)CX
   146                              <1> OP_FIRST_STRING equ nextindex
   147                              <1> opitem OP_1,	ARG_IMMED,	ao46, "1"	; 1 (simple "string" ops from here on)
   148                              <1> opitem OP_3,	ARG_IMMED,	ao47, "3"	; 3
   149                              <1> 	; order of the following (ao48 entries) must match asm_regnum in aa.asm
   150                              <1> OP_FIRST_ASM_REGNUM	equ nextindex	; corresponding to asm_regnum start
   151                              <1> opitem OP_DX,	ARG_JUSTREG,	ao48, "DX"	; DX
   152                              <1> opitem OP_CL,	ARG_JUSTREG,	ao48, "CL"	; CL
   153                              <1> opitem OP_ST,	ARG_WEIRDREG,	ao48, "ST"	; ST (top of coprocessor stack)
   154                              <1> opitem OP_CS,	ARG_WEIRDREG,	ao48, "CS"	; CS
   155                              <1> opitem OP_DS,	ARG_WEIRDREG,	ao48, "DS"	; DS
   156                              <1> opitem OP_ES,	ARG_WEIRDREG,	ao48, "ES"	; ES
   157                              <1> opitem OP_FS,	ARG_WEIRDREG,	ao48, "FS"	; FS
   158                              <1> opitem OP_GS,	ARG_WEIRDREG,	ao48, "GS"	; GS
   159                              <1> opitem OP_SS,	ARG_WEIRDREG,	ao48, "SS"	; SS
   160                              <1> OP_AFTER_LAST equ nextindex
   161                              <1> %if nextindex > OP_SIZE
   162                              <1>  %error Too many op items
   163                              <1> %endif
   164                              <1> OP_AMOUNT_TABLE	equ nextindex + 16 - 1
   165                              <1> 		; nextindex: amount sizeless types
   166                              <1> 		; 16: OP_SIZE combined types
   167                              <1> 		; -1: OP_END does not occur in tables
   168                              <1> 
   169                              <1> ; The following are extensions to sizeless OP_ items.
   170                              <1> ;  After an OP_X operand, a byte giving an index into
   171                              <1> ;  the OPX tables follows in the list. This is never
   172                              <1> ;  used with a size so we can make use of the full
   173                              <1> ;  eight bits. First macro parameter is the name which
   174                              <1> ;  matches the use in instr.key. Second parameter is
   175                              <1> ;  the routine in the assembler to dispatch to. Third
   176                              <1> ;  parameter is the routine in the disassembler.
   177                              <1> ; Only used for some disassembler extensions for now.
   178                              <1> 
   179                              <1> %macro opxitem 3.nolist
   180                              <1>  %1 equ nextindex
   181                              <1>  %xdefine ASMJMP_OPXITEMS ASMJMP_OPXITEMS,%2
   182                              <1>  %xdefine DISJMP_OPXITEMS DISJMP_OPXITEMS,%3
   183                              <1>  %assign nextindex nextindex + 1
   184                              <1> %endmacro
   185                              <1> %assign nextindex 0
   186                              <1> %define ASMJMP_OPXITEMS ""
   187                              <1> %define DISJMP_OPXITEMS ""
   188                              <1> opxitem OPX_NOTHING,	ao_modifier_continue, dop60a
   189                              <1> opxitem OPX_MOD_IF_REG,	ao_modifier_continue, dop_mod_if_reg
   190                              <1> opxitem OPX_MOD_IF_MEMOFFS_AND_OTHER_REG_AL_AX_EAX, ao_modifier_continue, 	dop_mod_if_memoffs_and_other_acc
   192                              <1> opxitem OPX_MOD_IF_OTHER_REG_AX_EAX, ao_modifier_continue, 	dop_mod_if_other_acc_1632
   194                              <1> opxitem OPX_MOD_IF_REG_1632, ao_modifier_continue, 	dop_mod_if_reg_1632
   196                              <1> opxitem OPX_MOD_IF_REG_AL_AX_EAX, ao_modifier_continue, 	dop_mod_if_reg_acc
   198                              <1> opxitem OPX_MOD_IF_REG_AX_EAX, ao_modifier_continue, 	dop_mod_if_reg_acc_1632
   200                              <1> opxitem OPX_MODALWAYS_IF_REG, ao_modifier_continue, 	dop_modalways_if_reg
   202                              <1> opxitem OPX_LOOP_OPTION, ac09_internal_error, dop_loop_option
   203                              <1> opxitem OPX_MOD_FORCE_3, ao_modifier_continue, dop_mod_force_3
   204                              <1> %if nextindex > 256
   205                              <1>  %error Too many opx items
   206                              <1> %endif
  1329                                  
  1330                                  
  1331                                  	; Instructions that have an implicit operand subject to a segment prefix.
  1332                                  	; This means a prefixed segment is allowed by the strict assembler, and
  1333                                  	; the disassembler treats a segment prefix as part of the instruction and
  1334                                  	; displays it in front of the instruction's mnemonic.
  1335                                  	; (outs, movs, cmps, lods, xlat).
  1336                                  segprfxtab:
  1337 00001410 6E6FA4A5A6A7ACAD        	db 06Eh,06Fh,0A4h,0A5h,0A6h,0A7h,0ACh,0ADh
  1338                                  a32prfxtab:
  1339 00001418 D7                      	db 0D7h				; xlat, last in segprfxtab, first in a32prfxtab
  1340                                  SEGP_LEN equ $-segprfxtab
  1341                                  
  1342                                  		; Instructions that can be used with REPE/REPNE.
  1343                                  		; (ins, outs, movs, stos, lods; cmps, scas)
  1344 00001419 6C6EA4AAAC              replist:db 06Ch,06Eh,0A4h,0AAh,0ACh	; REP (no difference)
  1345                                  REP_SAME_LEN equ $-replist		; number of indifferent replist entries
  1346 0000141E A6AE                    	db 0A6h,0AEh			; REPE/REPNE
  1347                                  REP_LEN equ $-replist
  1348                                  REP_DIFF_LEN equ REP_LEN-REP_SAME_LEN	; number of replist entries with difference
  1349                                  
  1350                                  A32P_LEN equ $-a32prfxtab
  1351                                  
  1352                                  ; prfxtab P_LEN REP_LEN REPE_REPNE_LEN
  1353                                  
  1354                                  		; All the instructions in replist also have an implicit operand
  1355                                  		; subject to ASIZE (similar to segprfxtab). Additionally, the
  1356                                  		; xlat instruction (0D7h) has such an implicit operand too.
  1357                                  		; maskmovq too.
  1358                                  
  1359                                  	align 2, db 0
  1360                                  o32prfxtab:
  1361 00001420 0E001E0006001600-       	dw 0Eh, 1Eh, 06h, 16h, SPARSE_BASE + 0A0h, SPARSE_BASE + 0A8h
  1361 00001428 [A000][A800]       
  1362                                  	; push cs, push ds, push es, push ss, push fs, push gs
  1363 0000142C 1F0007001700[A100]-     	dw 1Fh, 07h, 17h, SPARSE_BASE + 0A1h, SPARSE_BASE + 0A9h
  1363 00001434 [A900]             
  1364                                  	; pop ds, pop es, pop ss, pop fs, pop gs
  1365                                  O32P_AMOUNT equ ($ - o32prfxtab) / 2
  1366                                  
  1367                                   %ifn _LINK
  1368                                  	%include "asmtabs.asm"
  1369                                   %endif
  1370                                  %endif
  1371                                  
  1372                                  
  1373                                   %ifn _LINK || _LINK_COMPAT
  1374                                  	usesection lDEBUG_DATA_ENTRY
  1375                                  
  1376                                  msg_start:
  1377                                  	%include "msg.asm"
  1378                                  
  1379                                  msg_end:
  1380                                  
  1381                                  	numdef SHOWMSGSIZE, _DEFAULTSHOWSIZE
  1382                                  %if _SHOWMSGSIZE
  1383                                  %assign MSGSIZE msg_end - msg_start
  1384                                  %warning msg holds MSGSIZE bytes
  1385                                  %endif
  1386                                   %endif
  1387                                  
  1388                                  
  1389                                  	usesection lDEBUG_DATA_ENTRY
  1389          ------------------       note: usesection lDEBUG_DATA_ENTRY
  1390                                  
  1391                                  ..@symhint_trace_caller_entry_to_code_segsel:
  1392                                  entry_to_code_segsel:
  1393                                  %if _PM
  1394 00001436 57                      	push di
  1395 00001437 2E8B3E[6202]            	mov di, word [cs:pm_2_86m_0]
  1396 0000143C 2EFFA5[4214]            	jmp near word [cs:.table + di]
  1397                                  
  1398                                  		; REM:	Dispatch table in section lDEBUG_DATA_ENTRY
  1399 00001441 90                      	align 2
  1400                                  .table:
  1401 00001442 [4E14]                  	dw .86m
  1402 00001444 [4614]                  	dw .pm
  1403                                  
  1404                                  .pm:
  1405 00001446 5F                      	pop di
  1406                                  ..@symhint_trace_caller_entry_to_code_sel:
  1407                                  entry_to_code_sel: equ $
  1408 00001447 50                      	push ax
  1409 00001448 2EA1[1E02]              	mov ax, word [cs:code_sel]
  1410 0000144C EB06                    	jmp entry_to_code_common
  1411                                  
  1412                                  .86m:
  1413 0000144E 5F                      	pop di
  1414                                  %endif
  1415                                  
  1416                                  		; INP:	word [cs:ip] = near address to jump to in other segment
  1417                                  ..@symhint_trace_caller_entry_to_code_seg:
  1418                                  entry_to_code_seg:
  1419 0000144F 50                      	push ax			; word space for ?jumpaddress_ip, is ax
  1420 00001450 2EA1[1C02]              	mov ax, word [cs:code_seg]
  1421                                  
  1422                                  entry_to_code_common:
  1423                                  	lframe 0
  1424                                  	lpar word, jumpaddress_cs_and_orig_ip
  1425                                  	lpar word, jumpaddress_ip
  1426 00001454 5589E5                  	lenter
  1427                                  
  1428 00001457 56                      	push si
  1429 00001458 9C                      	pushf
  1430 00001459 FC                      	cld
  1431                                  
  1432 0000145A 874604                  	xchg word [bp + ?jumpaddress_cs_and_orig_ip], ax	; fill function segment
  1433 0000145D 89C6                    	mov si, ax
  1434 0000145F 2EAD                    	cs lodsw
  1435                                  %if _DEBUG && !(_LINK || _LINK_COMPAT)
  1436                                  	cmp al, 0CCh		; debugger breakpoint ?
  1437                                  	jne @F			; no -->
  1438                                  	int3			; break to make it remove the breakpoint
  1439                                  	dec si
  1440                                  	dec si
  1441                                  	cs lodsw		; reload the word
  1442                                  	cmp al, 0CCh
  1443                                  	jne @F
  1444                                  
  1445                                  .l:
  1446                                  	int3
  1447                                  	jmp .l
  1448                                  
  1449                                  @@:
  1450                                  %endif
  1451 00001461 874602                  	xchg word [bp + ?jumpaddress_ip], ax		; fill function offset
  1452                                  		; (and restore ax)
  1453                                  
  1454 00001464 9D                      	popf
  1455 00001465 5E                      	pop si
  1456                                  
  1457 00001466 5D                      	lleave
  1458 00001467 CB                      	retf			; jump to dword [bp + ?jumpaddress]
  1459                                  
  1460                                  
  1461                                  %if !_LOADER
  1462                                  		; debug22 - Interrupt 22h handler
  1463                                  		;
  1464                                  		; This is for DEBUG itself: it's a catch-all for the various Int23
  1465                                  		; and Int24 calls that may occur unpredictably at any time. What we
  1466                                  		; do is pretend to be a command interpreter (which we are, in a sense,
  1467                                  		; just with different sort of commands) by setting our parent PSP
  1468                                  		; value equal to our own PSP so that DOS does not free our memory when
  1469                                  		; we quit. Therefore control ends up here when DOS detects Control-C
  1470                                  		; or an Abort in the critical error prompt is selected.
  1471                                  debug22:
  1472 00001468 FA                      	cli
  1473                                  .cleartraceflag:
  1474 00001469 FC                      	cld			; reestablish things
  1475 0000146A 8CC8                    	mov ax, cs
  1476 0000146C 8ED8                    	mov ds, ax
  1477 0000146E 8ED0                    	mov ss, ax
  1478 00001470 8B26[600C]              	mov sp, word [ savesp ]	; restore stack
  1479                                  %if _PM
  1480 00001474 C606[6202]00            	mov byte [pm_2_86m_0], 0
  1481 00001479 8026[D901]F7            	clropt [internalflags], protectedmode	; reset PM flag
  1482                                  %endif
  1483 0000147E 90                      	times 1 - (($ - $$) & 1) nop	; align in-code parameter
  1484 0000147F E8CDFF                  	call entry_to_code_seg
  1485 00001482 [3305]                  	dw cmd2_reset_re_maybe_pm
  1486                                  %endif
  1487                                  
  1488                                  
  1489                                  %if _DUALCODE
  1490                                  	usesection lDEBUG_CODE2
  1490          ------------------       note: usesection lDEBUG_CODE2
  1491                                   %if $ - $$
  1492                                    %error cmd3_mirror is not at offset 0 in lDEBUG_CODE2
  1493                                   %endif
  1494                                  cmd3_mirror:
  1495 00000000 B9                      	db 0B9h				; mov cx, imm16 (cx = nonzero)
  1496 00000001 31C9                    	xor cx, cx			; cx = 0
  1497 00000003 E82400[0300]            	dualcall cmd3.have_cx_convenience
  1498                                  %endif
  1499                                  
  1500                                  
  1501                                  	usesection lDEBUG_CODE
  1501          ------------------       note: usesection lDEBUG_CODE
  1502                                  %if $ - $$
  1503                                   %error cmd3 is not at offset 0 in lDEBUG_CODE
  1504                                  %endif
  1505                                  
  1506                                  	code_insure_low_byte_not_0CCh
  1507                                  		; Begin main command loop.
  1508                                  cmd3: section_of_function
  1509                                  		; A convenience entrypoint: Entering
  1510                                  		;  cmd3 at offset 1 instead of 0 will
  1511                                  		;  make the debugger additionally
  1512                                  		;  display a linebreak early on.
  1513 00000000 B9                      	db 0B9h				; mov cx, imm16 (cx = nonzero)
  1514 00000001 31C9                    	xor cx, cx			; cx = 0
  1515                                  .have_cx_convenience:
  1516                                  
  1517 00000003 16                      	push ss
  1518 00000004 1F                      	pop ds
  1519 00000005 66                      	_386_o32		; mov esp
  1520 00000006 8B26[600C]              	mov sp, word [ savesp ]		; restore stack
  1521 0000000A 83E4FC                  _386	and sp, ~3			; align stack
  1522 0000000D 66                      	_386_o32
  1523 0000000E 31C0                    	xor ax, ax
  1524 00000010 66                      	_386_o32
  1525 00000011 50                      	push ax
  1526 00000012 66                      	_386_o32
  1527 00000013 9D                      	popf
  1528 00000014 8B26[600C]              _386	mov sp, word [ savesp ]		; restore stack
  1529 00000018 FC                      	cld
  1530 00000019 FB                      	sti
  1531 0000001A C706[660C][0000]        	mov word [ errret ], cmd3
  1532 00000020 C706[680C][6C16]        	mov word [ throwret ], errhandler
  1533 00000026 8926[6A0C]              	mov word [ throwsp ], sp
  1534                                  %if _SYMBOLIC
  1535                                  	mov word [ stack_low_address ], str_buffer
  1536                                  %endif
  1537 0000002A 31C0                    	xor ax, ax
  1538                                  %if _EXTENSIONS && _EXT_PUTS_GETLINE
  1539 0000002C A3[6002]                	mov word [in_getinput], ax	; set this byte and reserved next byte
  1540                                  %endif
  1541 0000002F 8706[A80B]              	xchg ax, word [cmd3_set_options]
  1542 00000033 0906[A001]              	or word [options], ax
  1543                                  
  1544 00000037 1E                      	push ds
  1545 00000038 07                      	pop es
  1546 00000039 E302                    	jcxz @F
  1547 0000003B EB06                    	jmp @FF
  1548                                  @@:
  1549 0000003D BA[0000]                	mov dx, crlf
  1550 00000040 E8(0000)                	call putsz
  1551                                  @@:
  1552                                  
  1553                                  %if _SYMBOLIC
  1554                                  	clropt [internalflags2], dif2_xms_detection_done
  1555                                  	nearcall zz_save_strat
  1556                                  %endif
  1557                                  
  1558 00000043 31FF                    	xor di, di
  1559 00000045 873E[0E0E]              	xchg di, word [terminator_in_line_in.offset]
  1560 00000049 85FF                    	test di, di
  1561 0000004B 7409                    	jz @F
  1562 0000004D 803D00                  	cmp byte [di], 0
  1563 00000050 7504                    	jne @F
  1564 00000052 A0[100E]                	mov al, byte [terminator_in_line_in.value]
  1565 00000055 AA                      	stosb
  1566                                  @@:
  1567                                  
  1568 00000056 8326[700C]00            	and word [run_sp_reserve], 0
  1569                                  %if !_LOADER
  1570                                  %if _RH || _SWHILEBUFFER || _RECMDWHILEBUFFER || _EXTENSIONS
  1571 0000005B D006[1702]              	rol byte [in_re], 1
  1572 0000005F 7205                    	jc @F
  1573 00000061 8026[DB01]FB            	clropt [internalflags], tt_while
  1574                                  @@:
  1575                                  %endif
  1576                                  %endif
  1577                                  %if _RH
  1578 00000066 8026[EE01]EF            	clropt [internalflags6], dif6_rh_mode
  1579 0000006B C606[1602]00            	mov byte [skip_rh], 0
  1580                                  %endif
  1581                                  %if _IMMASM
  1582 00000070 8026[EF01]FC            	clropt [internalflags6], dif6_immasm_no_output | dif6_immasm
  1583                                  %endif
  1584 00000075 8026[E101]DF            	clropt [internalflags3], dif3_unquiet_error
  1585                                  %if _REGSHIGHLIGHT
  1586 0000007A 8026[E201]FD            	clropt [internalflags3], dif3_do_not_highlight
  1587                                  %endif
  1588                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  1589 0000007F 8026[E301]E7            	clropt [internalflags3], dif3_auxbuff_guarded_1 | dif3_in_if
  1590                                  %else
  1591                                  	clropt [internalflags3], dif3_auxbuff_guarded_1
  1592                                  %endif
  1593 00000084 8026[E001]CF            	clropt [internalflags3], 		dif3_input_serial_override | dif3_input_terminal_override
  1595 00000089 8026[DF01]EF            	clropt [internalflags2], dif2_in_silence_dump
  1596                                  %if _PM
  1597                                   %if _DEBUG
  1598                                  	clropt [internalflags6], dif6_in_hook2F | dif6_in_amis_hook2F
  1599                                   %else
  1600 0000008E 8026[EC01]FB            	clropt [internalflags6], dif6_in_amis_hook2F
  1601                                   %endif
  1602 00000093 E8(0000)                	call resetmode
  1603                                  %endif
  1604                                  
  1605                                  %ifn _VXCHG
  1606                                  	mov ah, 0Fh
  1607                                  	int 10h
  1608                                  	mov byte [vpage], bh			; update page
  1609                                  %endif
  1610                                  
  1611                                  %if _TEST_HELP_FILE
  1612                                  cmd3_close_handle:
  1613                                  	call InDOS
  1614                                  	jnz @F
  1615                                  	mov ah, 3Eh
  1616                                  	mov bx, -1
  1617                                  	xchg bx, [handle]
  1618                                  	cmp bx, -1
  1619                                  	je @F
  1620                                  	doscall
  1621                                  @@:
  1622                                  %endif
  1623                                  
  1624                                  %if _EXTENSIONS
  1625                                  cmd3_close_ext:
  1626 00000096 E8(0000)                	call close_ext
  1627                                  %endif
  1628                                  
  1629                                  %if _RH
  1630                                  cmd3_rh_init:
  1631 00000099 F606[B601]10            	testopt [options6], opt6_rh_mode
  1632 0000009E 7419                    	jz .check_disable
  1633                                  .check_enable:
  1634 000000A0 F606[EE01]08            	testopt [internalflags6], dif6_rh_mode_was
  1635 000000A5 7529                    	jnz .done
  1636                                  .enable:
  1637                                  		; guarded_1 is always reset by cmd3
  1638                                  		; guarded_2 is only set by RE indicating silent mode
  1639                                  		; so we never want to not enable RH mode
  1640 000000A7 800E[E301]40            	setopt [internalflags3], dif3_auxbuff_guarded_3
  1641 000000AC 800E[EE01]08            	setopt [internalflags6], dif6_rh_mode_was
  1642                                  
  1643 000000B1 E8(0000)                	call tpg_initialise_empty_auxbuff.reset
  1644                                  
  1645 000000B4 BA[0000]                	mov dx, msg.rh_enabled
  1646 000000B7 EB14                    	jmp .done_putsz
  1647                                  
  1648                                  .check_disable:
  1649 000000B9 F606[EE01]08            	testopt [internalflags6], dif6_rh_mode_was
  1650 000000BE 7410                    	jz .done
  1651                                  .disable:
  1652 000000C0 8026[E301]BF            	clropt [internalflags3], dif3_auxbuff_guarded_3
  1653 000000C5 8026[EE01]F7            	clropt [internalflags6], dif6_rh_mode_was
  1654 000000CA BA[0000]                	mov dx, msg.rh_disabled
  1655                                  
  1656                                  .done_putsz:
  1657 000000CD E8(0000)                	call putsz
  1658                                  .done:
  1659                                  %endif
  1660                                  
  1661                                  %if _DEBUG && _DEBUG_COND
  1662                                  cmd3_debug_mode_init:
  1663                                  	testopt [options6], opt6_debug_mode
  1664                                  	jz .check_disable
  1665                                  .check_enable:
  1666                                  	testopt [internalflags6], dif6_debug_mode
  1667                                  	jnz .done
  1668                                  	call reset_interrupts
  1669                                  	setopt [internalflags6], dif6_debug_mode
  1670                                  	jmp .done
  1671                                  
  1672                                  .check_disable:
  1673                                  	testopt [internalflags6], dif6_debug_mode
  1674                                  	jz .done
  1675                                  	call set_interrupts
  1676                                  	clropt [internalflags6], dif6_debug_mode
  1677                                  .done:
  1678                                   %endif
  1679                                  
  1680                                  
  1681                                  %if _PM
  1682                                  cmd3_int2F_init:
  1683 000000D0 B02F                    	mov al, 2Fh		; interrupt number
  1684 000000D2 BE[0000]                	mov si, debug2F		; -> IISP entry header
  1685                                  
  1686 000000D5 F606[AC01]02            	testopt [options4], opt4_int_2F_hook
  1687 000000DA 750D                    	jnz .done
  1688                                  .check_disable:
  1689 000000DC BA0200                  	mov dx, opt4_int_2F_force >> 16
  1690                                   %if (opt4_int_2F_force >> 16) == dif4_int_2F_hooked
  1691 000000DF E83606                  	call cmd3_int_disable.set_bx_to_dx
  1692                                   %else
  1693                                  	mov bx, dif4_int_2F_hooked
  1694                                  	call cmd3_int_disable
  1695                                   %endif
  1696 000000E2 7205                    	jc .done
  1697 000000E4 8026[D901]FE            	clropt [internalflags], hooked2F
  1698                                  
  1699                                  .done:
  1700                                  %endif
  1701                                  
  1702                                  
  1703                                  %if _CATCHINTFAULTCOND && _CATCHINT0D
  1704                                  cmd3_int0D_init:
  1705 000000E9 B00D                    	mov al, 0Dh		; interrupt number
  1706 000000EB BE[0000]                	mov si, intr0D		; -> IISP entry header
  1707 000000EE BA1000                  	mov dx, opt4_int_0D_force >> 16
  1708                                   %if (opt4_int_0D_force >> 16) == dif4_int_0D_hooked
  1709 000000F1 89D3                    	mov bx, dx
  1710                                   %else
  1711                                  	mov bx, dif4_int_0D_hooked
  1712                                   %endif
  1713                                  
  1714 000000F3 F606[AC01]10            	testopt [options4], opt4_int_fault_hook
  1715 000000F8 7405                    	jz .check_disable
  1716                                  .check_enable:
  1717 000000FA E80806                  	call cmd3_int_enable
  1718 000000FD EB03                    	jmp .done
  1719                                  
  1720                                  .check_disable:
  1721 000000FF E81806                  	call cmd3_int_disable
  1722                                  
  1723                                  .done:
  1724                                  %endif
  1725                                  
  1726                                  
  1727                                  %if _CATCHINTFAULTCOND && _CATCHINT0C
  1728                                  cmd3_int0C_init:
  1729 00000102 B00C                    	mov al, 0Ch		; interrupt number
  1730 00000104 BE[0000]                	mov si, intr0C		; -> IISP entry header
  1731 00000107 BA2000                  	mov dx, opt4_int_0C_force >> 16
  1732                                   %if (opt4_int_0C_force >> 16) == dif4_int_0C_hooked
  1733 0000010A 89D3                    	mov bx, dx
  1734                                   %else
  1735                                  	mov bx, dif4_int_0C_hooked
  1736                                   %endif
  1737                                  
  1738 0000010C F606[AC01]10            	testopt [options4], opt4_int_fault_hook
  1739 00000111 7405                    	jz .check_disable
  1740                                  .check_enable:
  1741 00000113 E8EF05                  	call cmd3_int_enable
  1742 00000116 EB03                    	jmp .done
  1743                                  
  1744                                  .check_disable:
  1745 00000118 E8FF05                  	call cmd3_int_disable
  1746                                  
  1747                                  .done:
  1748                                  %endif
  1749                                  
  1750                                  
  1751                                  %if _CATCHINT08
  1752                                  cmd3_int08_init:
  1753 0000011B B008                    	mov al, 08h		; interrupt number
  1754 0000011D BE[0000]                	mov si, intr8		; -> IISP entry header
  1755 00000120 BA0400                  	mov dx, opt4_int_08_force >> 16
  1756                                   %if (opt4_int_08_force >> 16) == dif4_int_08_hooked
  1757 00000123 89D3                    	mov bx, dx
  1758                                   %else
  1759                                  	mov bx, dif4_int_08_hooked
  1760                                   %endif
  1761                                  
  1762 00000125 F606[AC01]04            	testopt [options4], opt4_int_08_hook
  1763 0000012A 7405                    	jz .check_disable
  1764                                  .check_enable:
  1765 0000012C E8D605                  	call cmd3_int_enable
  1766 0000012F EB03                    	jmp .done
  1767                                  
  1768                                  .check_disable:
  1769 00000131 E8E605                  	call cmd3_int_disable
  1770                                  
  1771                                  .done:
  1772                                  %endif
  1773                                  
  1774                                  
  1775                                  %if _CATCHINT2D
  1776                                  cmd3_int2D_init:
  1777 00000134 B02D                    	mov al, 2Dh		; interrupt number
  1778 00000136 BE[0000]                	mov si, int2D		; -> IISP entry header
  1779 00000139 BB0800                  	mov bx, dif4_int_2D_hooked
  1780 0000013C BA0800                  	mov dx, opt4_int_2D_force >> 16
  1781                                  
  1782 0000013F F606[AC01]08            	testopt [options4], opt4_int_2D_hook
  1783 00000144 7447                    	jz .check_disable
  1784                                  .check_enable:
  1785 00000146 851E[E401]              	test word [internalflags4], bx
  1786 0000014A 7544                    	jnz .done
  1787                                  
  1788 0000014C E8(0000)                	call intchk			; ZR if offset = -1 or segment = 0
  1789                                  					; CHG: ax, dx, bx
  1790 0000014F 742F                    	jz .fail
  1791                                  
  1792 00000151 8A26[0000]              	mov ah, byte [try_amis_multiplex_number]
  1793 00000155 B000                    	mov al, 00h
  1794                                  		; function 0 changes dx, di, cx, al
  1795                                  %if _PM
  1796 00000157 E8C509                  	call call_int2D
  1797                                  %else
  1798                                  	int 2Dh				; enquire whether there's anyone
  1799                                  %endif
  1800 0000015A 84C0                    	test al, al
  1801 0000015C 7414                    	jz .got
  1802                                  
  1803 0000015E 31C0                    	xor ax, ax			; start with multiplex number 0
  1804                                  .loopplex:
  1805 00000160 B000                    	mov al, 00h			; AMIS installation check
  1806                                  		; function 0 changes dx, di, cx, al
  1807                                  %if _PM
  1808 00000162 E8BA09                  	call call_int2D
  1809                                  %else
  1810                                  	int 2Dh				; enquire whether there's anyone
  1811                                  %endif
  1812 00000165 84C0                    	test al, al			; free ?
  1813 00000167 7409                    	jz .got				; yes, put it to use -->
  1814 00000169 FEC4                    	inc ah
  1815 0000016B 75F3                    	jnz .loopplex			; try next multiplexer -->
  1816                                  
  1817 0000016D BA[0000]                	mov dx, msg.cannot_hook_2D.nofree
  1818 00000170 EB11                    	jmp .fail_putsz
  1819                                  
  1820                                  .got:
  1821 00000172 8826[0000]              	mov byte [amis_multiplex_number], ah
  1822                                  
  1823 00000176 B02D                    	mov al, 2Dh		; interrupt number
  1824 00000178 BB0800                  	mov bx, dif4_int_2D_hooked
  1825 0000017B E88D05                  	call cmd3_int_enable.need
  1826 0000017E EB10                    	jmp .done
  1827                                  
  1828                                  .fail:
  1829 00000180 BA[0000]                	mov dx, msg.cannot_hook_2D.invalid
  1830                                  .fail_putsz:
  1831 00000183 E8(0000)                	call putsz
  1832 00000186 8026[AC01]F7            	clropt [options4], opt4_int_2D_hook
  1833 0000018B EB03                    	jmp .done
  1834                                  
  1835                                  .check_disable:
  1836 0000018D E88A05                  	call cmd3_int_disable
  1837                                  
  1838                                  .done:
  1839                                  %endif
  1840                                  
  1841                                  
  1842 00000190 F606[E301]01            	testopt [internalflags3], dif3_input_re
  1843 00000195 7403E9F001              	jnz cmd3_continue_1_re
  1844 0000019A 8026[A501]7F            	clropt [options2], opt2_re_cancel_tpg
  1845                                  %if !_LOADER
  1846 0000019F E8(0000)                	call silence_dump
  1847                                  %endif
  1848                                  
  1849                                  
  1850                                  cmd3_serial_init:
  1851 000001A2 F606[A101]40            	testopt [options], enable_serial
  1852 000001A7 7503E94D01              	jz .check_disable_serial
  1853                                  .check_enable_serial:
  1854 000001AC F606[E90D]01            	testopt [serial_flags], sf_init_done
  1855 000001B1 7408                    	jz .enable_serial
  1856                                  		; If we disabled the actual use flag prior somehow
  1857                                  		;  (sf_use_serial clear) but we get here with
  1858                                  		;  sf_init_done set then re-enable use of serial I/O.
  1859 000001B3 800E[E90D]10            	setopt [serial_flags], sf_use_serial
  1860 000001B8 E98501                  	jmp .done_serial
  1861                                  
  1862                                  .enable_serial:
  1863                                  
  1864 000001BB A0[EA0D]                	mov al, byte [serial_var_intnum]
  1865 000001BE A2[480C]                	mov byte [serial_use_intnum], al
  1866 000001C1 A0[EB0D]                	mov al, byte [serial_var_params]
  1867 000001C4 A2[490C]                	mov byte [serial_use_params], al
  1868 000001C7 A0[EC0D]                	mov al, byte [serial_var_fifo]
  1869 000001CA A2[4A0C]                	mov byte [serial_use_fifo], al
  1870 000001CD A1[EE0D]                	mov ax, word [serial_var_baseport]
  1871 000001D0 A3[4E0C]                	mov word [serial_use_baseport], ax
  1872 000001D3 A1[F00D]                	mov ax, word [serial_var_dl]
  1873 000001D6 A3[500C]                	mov word [serial_use_dl], ax
  1874 000001D9 A1[F20D]                	mov ax, word [serial_var_irqmask]
  1875 000001DC A3[520C]                	mov word [serial_use_irqmask], ax
  1876 000001DF E8(0000)                  call  serial_clear_fifos
  1877 000001E2 E8(0000)                  call  serial_install_interrupt_handler
  1878 000001E5 7317                    	jnc @F
  1879 000001E7 BF[0000]                	mov di, msg.serial_cannot_hook.old_int
  1880 000001EA A0[180E]                	mov al, byte [serial_installed_intnum]
  1881 000001ED E8(0000)                	call hexbyte
  1882 000001F0 BF[0000]                	mov di, msg.serial_cannot_hook.new_int
  1883 000001F3 A0[480C]                	mov al, byte [serial_use_intnum]
  1884 000001F6 E8(0000)                	call hexbyte
  1885 000001F9 BA[0000]                	mov dx, msg.serial_cannot_hook
  1886 000001FC EB52                    	jmp .no_keep
  1887                                  
  1888                                  @@:
  1889 000001FE C606[0800]80            	mov byte [serial_interrupt_handler + ieEOI], 80h
  1890 00000203 E8(0000)                  call  serial_init_UART
  1891                                  
  1892 00000206 800E[E90D]11            	setopt [serial_flags], sf_init_done | sf_use_serial
  1893                                  
  1894 0000020B BA[0000]                	mov dx, msg.serial_request_keep
  1895 0000020E E8(0000)                	call putsz
  1896                                  
  1897 00000211 BF[2E0B]                	mov di, line_out
  1898                                  %if _DEBUG
  1899                                   %if _DEBUG_COND
  1900                                  	testopt [internalflags6], dif6_debug_mode
  1901                                  	jz @F
  1902                                   %endif
  1903                                  	mov al, '~'		; indicate instance is to be debugged
  1904                                  	stosb
  1905                                  @@:
  1906                                  %endif
  1907 00000214 B83D20                  	mov ax, "= "
  1908 00000217 AB                      	stosw
  1909                                  
  1910 00000218 31C0                    	xor ax, ax
  1911 0000021A A3[000E]                	mov word [getline_timer_count], ax
  1912 0000021D 06                      	push es
  1913 0000021E B84000                  	mov ax, 40h
  1914 00000221 8EC0                    	mov es, ax
  1915 00000223 26A16C00                	mov ax, word [es:6Ch]
  1916 00000227 A3[020E]                	mov word [getline_timer_last], ax
  1917 0000022A 07                      	pop es
  1918 0000022B C706[040E][6002]        	mov word [getline_timer_func], .timer
  1919                                  
  1920                                  		; if we're executing from the command line
  1921                                  		;  buffer or a Y file then we want to
  1922                                  		;  override input to be from serial for the
  1923                                  		;  KEEP confirmation prompt.
  1924                                  		; output is always to serial if we're here.
  1925 00000231 800E[E001]20            	setopt [internalflags3], dif3_input_serial_override
  1926 00000236 E8(0000)                	call getline00
  1927 00000239 8026[E001]DF            	clropt [internalflags3], dif3_input_serial_override
  1928                                  
  1929 0000023E E8(0000)                	call skipcomm0
  1930 00000241 4E                      	dec si
  1931 00000242 BA[0000]                	mov dx, msg.keep
  1932 00000245 E8(0000)                	call isstring?
  1933 00000248 7503E9F300              	je .done_serial
  1934                                  
  1935 0000024D BA[0000]                	mov dx, msg.serial_no_keep_enter
  1936                                  .no_keep:
  1937                                  		; Immediately disable use of serial I/O.
  1938 00000250 8026[E90D]EF            	clropt [serial_flags], sf_use_serial
  1939                                  		; Set the flag for next cmd3 loop to properly disable
  1940                                  		;  and de-initialise the serial port.
  1941 00000255 8026[A101]BF            	clropt [options], enable_serial
  1942 0000025A E8(0000)                	call putsz
  1943 0000025D E9A0FD                  	jmp cmd3
  1944                                  
  1945                                  
  1946                                  .timer:
  1947 00000260 50                      	push ax
  1948 00000261 52                      	push dx
  1949 00000262 51                      	push cx
  1950 00000263 53                      	push bx
  1951 00000264 06                      	push es
  1952                                  
  1953 00000265 BA4000                  	mov dx, 40h
  1954 00000268 8EC2                    	mov es, dx
  1955                                  
  1956 0000026A B00B                      mov al, 0Bh	; request In-Service Register (ISR)
  1957 0000026C E6A0                      out 0A0h, al	; from secondary PIC
  1958 0000026E E4A0                      in al, 0A0h	; read the ISR
  1959 00000270 8406[530C]                test al, byte [serial_use_irqmask + 1]
  1960 00000274 756B                      jnz .timer_ours
  1961 00000276 B00B                      mov al, 0Bh	; request In-Service Register (ISR)
  1962 00000278 E620                      out 20h, al	; from primary PIC
  1963 0000027A E420                      in al, 20h	; read the ISR
  1964 0000027C 24FB                      and al, ~100b
  1965 0000027E 8406[520C]                test al, byte [serial_use_irqmask]
  1966 00000282 755D                      jnz .timer_ours
  1967                                  .timer_ours_done:
  1968                                  
  1969 00000284 8B0E[3E0C]                mov cx, word [serial_save_irq_mask]
  1970 00000288 31DB                      xor bx, bx		; all bits clear (= IRQ ON)
  1971 0000028A E8(0000)                  call set_irq		; enable IRQs and get prior status
  1972 0000028D 85DB                      test bx, bx		; IRQs were still enabled ?
  1973 0000028F 7405                      jz @F			; yes, fine -->
  1974 00000291 8026[B601]FE              clropt [options6], opt6_share_serial_irq
  1975                                  			; no, make sure not to chain any longer
  1976                                  @@:
  1977 00000296 8B0E[000E]              	mov cx, word [getline_timer_count]
  1978 0000029A 8B16[020E]              	mov dx, word [getline_timer_last]
  1979                                  
  1980                                  %if _SLEEP_NEW
  1981 0000029E 26A16C00                	mov ax, word [es:6Ch]
  1982 000002A2 39C2                    	cmp dx, ax
  1983 000002A4 7445                    	je .timer_next
  1984 000002A6 F7DA                    	neg dx			; minus prior tick
  1985 000002A8 01C2                    	add dx, ax		; new tick - prior tick
  1986                                  
  1987 000002AA 3B16[0000]              	cmp dx, word [sleep_delta_limit]
  1988 000002AE 7609                    	jbe @F
  1989 000002B0 8B16[0000]              	mov dx, word [sleep_delta_limit]
  1990 000002B4 85D2                    	test dx, dx
  1991 000002B6 7501                    	jnz @F
  1992 000002B8 42                      	inc dx			; limit 0 would lead to stagnant sleep
  1993                                  @@:
  1994 000002B9 3B16[0000]              	cmp dx, word [sleep_highest_delta]
  1995 000002BD 7604                    	jbe @F
  1996 000002BF 8916[0000]              	mov word [sleep_highest_delta], dx
  1997                                  @@:
  1998 000002C3 01D1                    	add cx, dx
  1999 000002C5 7303                    	jnc @F
  2000 000002C7 B9FFFF                  	mov cx, -1
  2001                                  @@:
  2002 000002CA 89C2                    	mov dx, ax
  2003                                  %else
  2004                                  	cmp dx, word [es:6Ch]
  2005                                  	je .timer_next
  2006                                  	mov dx, word [es:6Ch]
  2007                                  	inc cx
  2008                                  %endif
  2009 000002CC B012                    	mov al, 18
  2010 000002CE F626[E70D]              	mul byte [serial_keep_timeout]
  2011 000002D2 85C0                    	test ax, ax
  2012 000002D4 7415                    	jz .timer_next
  2013 000002D6 39C1                    	cmp cx, ax
  2014 000002D8 7211                    	jb .timer_next
  2015                                  
  2016 000002DA 07                      	pop es
  2017 000002DB BA[0000]                	mov dx, msg.serial_no_keep_timer
  2018 000002DE E96FFF                  	jmp .no_keep
  2019                                  
  2020                                  .timer_ours:
  2021 000002E1 800E[B601]02            	setopt [options6], opt6_serial_EOI_call
  2022 000002E6 E8(0000)                  call serial_eoi
  2023 000002E9 EB99                    	jmp .timer_ours_done
  2024                                  
  2025                                  .timer_next:
  2026 000002EB 890E[000E]              	mov word [getline_timer_count], cx
  2027 000002EF 8916[020E]              	mov word [getline_timer_last], dx
  2028 000002F3 07                      	pop es
  2029 000002F4 5B                      	pop bx
  2030 000002F5 59                      	pop cx
  2031 000002F6 5A                      	pop dx
  2032 000002F7 58                      	pop ax
  2033 000002F8 C3                      	retn
  2034                                  
  2035                                  
  2036                                  .check_disable_serial:
  2037                                  		; If serial is initialised, uninstall it.
  2038 000002F9 F606[E90D]01            	testopt [serial_flags], sf_init_done
  2039 000002FE 751D                    	jnz .disable_serial
  2040                                  		; Not initialised. Is the interrupt still hooked?
  2041 00000300 F606[E401]01            	testopt [internalflags4], dif4_int_serial_hooked
  2042 00000305 7439                    	jz .done_serial
  2043                                  		; Try unhooking the interrupt handler.
  2044 00000307 E8(0000)                	call serial_uninstall_interrupt_handler
  2045 0000030A 7234                    	jc .done_serial			; if it failed again -->
  2046 0000030C BF[0000]                	mov di, msg.serial_late_unhook.int
  2047 0000030F A0[180E]                	mov al, byte [serial_installed_intnum]
  2048 00000312 E8(0000)                	call hexbyte
  2049 00000315 BA[0000]                	mov dx, msg.serial_late_unhook
  2050 00000318 E8(0000)                	call putsz
  2051 0000031B EB23                    	jmp .done_serial
  2052                                  
  2053                                  .disable_serial:
  2054                                  
  2055 0000031D E8(0000)                  call serial_clean_up
  2056 00000320 7319                    	jnc @F
  2057                                  		; Immediately disable use of serial I/O,
  2058                                  		;  so that our error message goes to the
  2059                                  		;  local terminal rather than to serial I/O.
  2060 00000322 8026[E90D]EF            	clropt [serial_flags], sf_use_serial
  2061 00000327 BF[0000]                	mov di, msg.serial_cannot_unhook.int
  2062 0000032A A0[180E]                	mov al, byte [serial_installed_intnum]
  2063 0000032D E8(0000)                	call hexbyte
  2064 00000330 BA[0000]                	mov dx, msg.serial_cannot_unhook
  2065 00000333 E8(0000)                	call putsz
  2066 00000336 C606[0800]00            	mov byte [serial_interrupt_handler + ieEOI], 0
  2067                                  					; we do not issue EOI any longer
  2068                                  @@:
  2069 0000033B 8026[E90D]EE            	clropt [serial_flags], sf_init_done | sf_use_serial
  2070                                  .done_serial:
  2071                                  
  2072                                  
  2073                                  %if _VXCHG
  2074                                  cmd3_vv_set:
  2075 00000340 E8(0000)                	call vv_set
  2076                                  %endif
  2077                                  
  2078                                  
  2079                                  %if _PM
  2080                                  cmd3_ss_init:
  2081 00000343 E85706                  	call ispm
  2082 00000346 752F                    	jnz .done
  2083                                  
  2084                                  subcpu 286
  2085 00000348 8CD3                    	mov bx, ss
  2086 0000034A 0F02CB                  	lar cx, bx
  2087 0000034D 7528                    	jnz .done
  2088 0000034F C1E908                  	shr cx, 8
  2089                                  
  2090 00000352 F606[AA01]10            	testopt [options3], opt3_ss_b_bit_set
  2091 00000357 740B                    	jz .check_clear
  2092                                  .check_set:
  2093 00000359 F606[E201]10            	testopt [internalflags3], dif3_ss_b_bit_set
  2094 0000035E 7517                    	jnz .done
  2095                                  
  2096 00000360 B540                    	mov ch, 40h
  2097 00000362 EB07                    	jmp @F
  2098                                  
  2099                                  .check_clear:
  2100 00000364 F606[E201]10            	testopt [internalflags3], dif3_ss_b_bit_set
  2101 00000369 740C                    	jz .done
  2102                                  
  2103                                  @@:
  2104 0000036B B80900                  	mov ax, 0009h
  2105 0000036E CD31                    	int 31h
  2106 00000370 7205                    	jc .done
  2107                                  
  2108 00000372 8036[E201]10            	xoropt [internalflags3], dif3_ss_b_bit_set
  2109                                  subcpureset
  2110                                  
  2111                                  .done:
  2112                                  %endif
  2113                                  
  2114                                  
  2115                                  %if _IMMASM
  2116 00000377 FF16[0000]              	call near [ ia_restore ]
  2117                                  %endif
  2118                                  
  2119 0000037B F606[B901]10            	testopt [options7], opt7_no_ensure
  2120 00000380 7508                    	jnz .skip
  2121                                  
  2122                                  %if _PM
  2123 00000382 E81806                  	call ispm
  2124 00000385 7403                    	jz @F
  2125                                  %endif
  2126                                  %if !_LOADER
  2127 00000387 E85216                  	call ensuredebuggeeloaded	; if no task is active, create a dummy one
  2128                                  %endif
  2129                                  %if _PM && 0
  2130                                  	jmp @FF
  2131                                  @@:
  2132                                  	testopt [internalflags], attachedterm
  2133                                  	jz @F
  2134                                  	mov dx, .message
  2135                                  	call putsz
  2136                                  
  2137                                  	usesection lDEBUG_DATA_ENTRY
  2138                                  .message:	ascizline "Attached term is set in PM!"
  2139                                  	usesection lDEBUG_CODE
  2140                                  %endif
  2141                                  @@:
  2142                                  .skip:
  2143                                  
  2144                                  
  2145                                  cmd3_continue_1_re:
  2146 0000038A BF[2E0B]                	mov di, line_out	; build prompt
  2147                                  %if _DEBUG
  2148                                   %if _DEBUG_COND
  2149                                  	testopt [internalflags6], dif6_debug_mode
  2150                                  	jz @F
  2151                                   %endif
  2152                                  	mov al, '~'		; indicate instance is to be debugged
  2153                                  	stosb
  2154                                  @@:
  2155                                  %endif
  2156                                  %if !_LOADER
  2157                                  %if _INDOS_PROMPT
  2158 0000038D E8B914                  	call InDOS
  2159 00000390 740F                    	jz @F
  2160                                   %if _BOOTLDR
  2161 00000392 F606[D901]40            	testopt [internalflags], nodosloaded
  2162                                  				; boot mode ?
  2163                                    %if _INDOS_PROMPT_NOBOOT
  2164 00000397 7508                    	jnz @F			; yes, do not show special prompt -->
  2165                                    %elif _INDOS_PROMPT_NOFLAG
  2166                                  	jnz .indos_prompt	; yes, show special prompt -->
  2167                                  				;  (do not call .real_indos check)
  2168                                    %endif
  2169                                   %endif
  2170                                   %if _INDOS_PROMPT_NOFLAG
  2171                                    %if _APPLICATION || _DEVICE
  2172                                  		; Never branches to here if bootloaded,
  2173                                  		;  so no need to handle only bootloaded.
  2174 00000399 E8BB14                  	call InDOS.real_indos	; real InDOS set ?
  2175 0000039C 7403                    	jz @F			; no, do not show special prompt -->
  2176                                    %endif
  2177                                   %endif
  2178                                  .indos_prompt:
  2179 0000039E B021                    	mov al, '!'
  2180 000003A0 AA                      	stosb
  2181                                  @@:
  2182                                  %endif
  2183                                  %endif
  2184                                  %if !_LOADER
  2185 000003A1 B02D                    	mov al, '-'		; main prompt
  2186                                  %else
  2187                                  	mov al, '*'
  2188                                  %endif
  2189                                  %if _PM
  2190 000003A3 E8F705                  	call ispm
  2191 000003A6 7502                    	jnz .realmode
  2192 000003A8 B023                    	mov al, '#'		; PM main prompt
  2193                                  .realmode:
  2194                                  %endif
  2195 000003AA F606[E101]01            	testopt [internalflags3], dif3_input_cmdline
  2196 000003AF 7402                    	jz @F
  2197 000003B1 B026                    	mov al, '&'
  2198                                  @@:
  2199 000003B3 F606[E301]01            	testopt [internalflags3], dif3_input_re
  2200 000003B8 7402                    	jz @F
  2201 000003BA B025                    	mov al, '%'
  2202                                  @@:
  2203 000003BC AA                      	stosb
  2204                                  
  2205 000003BD C606[0000]00            	mov byte [hhflag], 0
  2206 000003C2 8326[0000]00            	and word [hh_depth], 0
  2207 000003C7 8326[0000]00            	and word [hh_depth_of_single_term], 0
  2208 000003CC C706[040E][B105]        	mov word [getline_timer_func], dmycmd
  2209 000003D2 8026[DA01]FE            	clropt [internalflags], usecharcounter	; reset this automatically
  2210                                  
  2211 000003D7 F606[E301]01            	testopt [internalflags3], dif3_input_re
  2212 000003DC 7515                    	jnz cmd3_continue_2_re
  2213                                  
  2214 000003DE 800E[D801]08            	setopt [internalflags], pagedcommand	; 2009-02-21: default to page all commands
  2215 000003E3 8026[DB01]CF            	clropt [internalflags], tt_silence | tt_silent_mode
  2216                                  				; reset, in case it's still set
  2217 000003E8 8126[DC01]3FF7          	clropt [internalflags2], dif2_tpg_proceed_bp_set | 			dif2_bp_failure | dif2_tpg_keep_proceed_bp, 1
  2219                                  %if _INPUT_FILE_HANDLES
  2220 000003EE 8026[DE01]DF            	clropt [internalflags2], dif2_closed_input_file
  2221                                  %endif
  2222                                  
  2223                                  cmd3_continue_2_re:
  2224 000003F3 E83E03                  	call determine_quiet_output
  2225                                  
  2226 000003F6 31C9                    	xor cx, cx
  2227 000003F8 870E[EC0C]              	xchg cx, word [rc]	; reset rc
  2228 000003FC 890E[EE0C]              	mov word [priorrc], cx	; make prior value available
  2229 00000400 E304                    	jcxz @F
  2230 00000402 890E[F00C]              	mov word [erc], cx	; update to last non-zero value
  2231                                  @@:
  2232                                  
  2233                                  %if !_LOADER
  2234                                  cmd3_check_relimit:
  2235 00000406 F606[E301]01            	testopt [internalflags3], dif3_input_re
  2236 0000040B 7425                    	jz cmd3_continue_not_re
  2237                                  
  2238 0000040D 8306[980B]01            	add word [re_count], 1
  2239 00000412 8316[9A0B]00            	adc word [re_count + 2], 0
  2240 00000417 8B16[9E0B]              	mov dx, word [re_limit + 2]
  2241 0000041B A1[9C0B]                	mov ax, word [re_limit]
  2242 0000041E 3916[9A0B]              	cmp word [re_count + 2], dx
  2243 00000422 7504                    	jne @F
  2244 00000424 3906[980B]              	cmp word [re_count], ax
  2245                                  @@:
  2246                                  		; This branch bypasses cmd3_check_rclimit
  2247                                  		;  because RE buffer commands should not
  2248                                  		;  count towards the RC limit.
  2249 00000428 765C                    	jbe cmd3_continue_relimit_not_reached
  2250                                  
  2251 0000042A BA[0000]                	mov dx, msg.re_limit_reached
  2252 0000042D B84301                  	mov ax, 0143h
  2253 00000430 EB3D                    	jmp cmd3_check_common
  2254                                  
  2255                                  cmd3_continue_not_re:
  2256                                  %endif
  2257                                  
  2258                                  cmd3_check_rclimit:
  2259                                  
  2260                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  2261                                  		; If executing from a script file then
  2262                                  		;  command doesn't count for RC limit.
  2263                                  %if _INPUT_FILE_BOOT
  2264 00000432 F606[DF01]02            	testopt [internalflags2], dif2_input_file_boot
  2265 00000437 754D                    	jnz .file
  2266                                  %endif
  2267                                  %if _INPUT_FILE_HANDLES
  2268 00000439 E80D14                  	call InDOS
  2269 0000043C 7507                    	jnz .file_not
  2270 0000043E F606[DE01]10            	testopt [internalflags2], dif2_input_file
  2271 00000443 7541                    	jnz .file
  2272                                  %endif
  2273                                  .file_not:
  2274                                  
  2275                                  .file: equ cmd3_continue_rclimit_not_reached
  2276                                  %endif
  2277                                  
  2278 00000445 F606[E101]01            	testopt [internalflags3], dif3_input_cmdline
  2279 0000044A 743A                    	jz cmd3_continue_not_rc
  2280                                  
  2281 0000044C 8306[A00B]01            	add word [rc_count], 1
  2282 00000451 8316[A20B]00            	adc word [rc_count + 2], 0
  2283 00000456 8B16[A60B]              	mov dx, word [rc_limit + 2]
  2284 0000045A A1[A40B]                	mov ax, word [rc_limit]
  2285 0000045D 3916[A20B]              	cmp word [rc_count + 2], dx
  2286 00000461 7504                    	jne @F
  2287 00000463 3906[A00B]              	cmp word [rc_count], ax
  2288                                  @@:
  2289 00000467 761D                    	jbe cmd3_continue_rclimit_not_reached
  2290                                  
  2291 00000469 BA[0000]                	mov dx, msg.rc_limit_reached
  2292 0000046C B84401                  	mov ax, 0144h
  2293                                  cmd3_check_common:
  2294 0000046F E8(0000)                	call putsz_error
  2295 00000472 E81F12                  	call setrc
  2296 00000475 800E[E101]04            	setopt [internalflags3], dif3_at_line_end
  2297 0000047A A1[EC0C]                	mov ax, word [rc]
  2298 0000047D A3[EE0C]                	mov word [priorrc], ax
  2299 00000480 E8(0000)                	call getline_close_file
  2300 00000483 E97AFB                  	jmp cmd3
  2301                                  
  2302                                  cmd3_continue_not_rc:
  2303                                  cmd3_continue_rclimit_not_reached:
  2304                                  cmd3_continue_relimit_not_reached:
  2305                                  
  2306                                  cmd3_check_line_out_overflow:
  2307 00000486 813E[360C]4226          	cmp word [line_out_overflow], 2642h
  2308 0000048C 740C                    	je @F
  2309 0000048E C706[360C]4226          	mov word [line_out_overflow], 2642h
  2310 00000494 BA[0000]                	mov dx, msg.line_out_overflow
  2311 00000497 E8(0000)                	call putsz_error
  2312                                  @@:
  2313                                  
  2314                                  cmd3_getline:
  2315                                  %if _EXTENSIONS
  2316 0000049A 31C9                    	xor cx, cx
  2317 0000049C 870E[5002]              	xchg cx, word [ext_inject_handler]
  2318 000004A0 E303                    	jcxz cmd3_not_inject
  2319 000004A2 E9(0000)                	jmp transfer_ext_cx
  2320                                  
  2321                                  cmd3_not_inject: section_of_function
  2322 000004A5 8B26[600C]              	mov sp, word [ savesp ]		; restore stack
  2323 000004A9 E8(0000)                	call getline00		; prompted input, also resets linecounter
  2324                                  cmd3_injected: section_of_function
  2325 000004AC 8B26[600C]              	mov sp, word [ savesp ]		; restore stack
  2326                                  
  2327                                  
  2328 000004B0 8B0E[4E02]              	mov cx, word [ext_preprocess_handler]
  2329 000004B4 E303                    	jcxz cmd3_preprocessed
  2330 000004B6 E9(0000)                	jmp transfer_ext_cx
  2331                                  
  2332                                  cmd3_preprocessed: section_of_function
  2333 000004B9 16                      	push ss
  2334 000004BA 1F                      	pop ds
  2335 000004BB 16                      	push ss
  2336 000004BC 07                      	pop es
  2337 000004BD 8B26[600C]              	mov sp, word [ savesp ]		; restore stack
  2338                                  
  2339                                  
  2340 000004C1 8B0E[4C02]              	mov cx, word [ext_command_handler]
  2341 000004C5 E303                    	jcxz cmd3_not_ext
  2342 000004C7 E9(0000)                	jmp transfer_ext_cx
  2343                                  
  2344                                  cmd3_not_ext: section_of_function
  2345 000004CA 16                      	push ss
  2346 000004CB 1F                      	pop ds
  2347 000004CC 16                      	push ss
  2348 000004CD 07                      	pop es
  2349 000004CE 8B26[600C]              	mov sp, word [ savesp ]		; restore stack
  2350 000004D2 4E                      	dec si
  2351 000004D3 AC                      	lodsb
  2352                                  %else
  2353                                  	call getline00		; prompted input, also resets linecounter
  2354                                  cmd3_injected: section_of_function
  2355                                  %endif
  2356                                  
  2357 000004D4 E8(0000)                	call iseol?.notsemicolon
  2358 000004D7 7518                    	jne cmd3_notblank
  2359 000004D9 F606[AB01]10            	testopt [options3], opt3_disable_autorepeat
  2360 000004DE 7508                    	jnz @F
  2361 000004E0 8B16[D20D]              	mov dx, word [lastcmd]
  2362 000004E4 8804                    	mov byte [si], al
  2363 000004E6 EB43                    	jmp short cmd4
  2364                                  
  2365                                  @@:
  2366 000004E8 C706[D20D][B105]        	mov word [lastcmd], dmycmd
  2367 000004EE E90FFB                  	jmp cmd3
  2368                                  
  2369                                  cmd3_notblank:
  2370                                  %if _SYMBOLIC
  2371                                  	clropt [internalflags3], dif3_nosymbols_1
  2372                                  %endif
  2373 000004F1 C706[D20D][B105]        	mov word [lastcmd], dmycmd
  2374 000004F7 3C3B                    	cmp al, ';'
  2375 000004F9 7435                    	je cmd3_j1		; if comment -->
  2376 000004FB 3C3A                    	cmp al, ':'
  2377 000004FD 7431                    	je cmd3_j1		; if jump label -->
  2378 000004FF 3C3F                    	cmp al, '?'
  2379 00000501 7503E9C400              	je help			; if request for help -->
  2380 00000506 3C2E                    	cmp al, '.'
  2381 00000508 7503E9(0000)            	je immasm		; if assembling/immediate execution -->
  2382 0000050D 3C2D                    	cmp al, '-'
  2383 0000050F 7503                    	jne @F			; if not no symbol prefix -->
  2384                                  %if _SYMBOLIC
  2385                                  	setopt [internalflags3], dif3_nosymbols_1
  2386                                  %endif
  2387 00000511 E8(0000)                	call skipwhite		; skip to next command letter
  2388                                  		; Empty line (autorepeat) not valid.
  2389                                  		; Comment not valid. Goto label not valid.
  2390                                  		; Help request not valid.
  2391                                  @@:
  2392 00000514 E8(0000)                	call capitalise
  2393 00000517 2C41                    	sub al, 'A'
  2394                                  %if _SYMBOLIC
  2395                                  	cmp al, 'Z' - 'A'
  2396                                  	ja error		; if not recognised -->
  2397                                  	je @F			; if Z, do not commit -->
  2398                                  	nearcall zz_commit_insert	; if not Z, commit now
  2399                                  @@:
  2400                                  %else
  2401 00000519 3C18                    	cmp al, 'Y' - 'A'
  2402 0000051B 7603E91E11              	ja error		; if not recognised -->
  2403                                  %endif
  2404 00000520 98                      	cbw
  2405 00000521 93                      	xchg bx, ax
  2406 00000522 E8(0000)                	call skipcomma
  2407 00000525 D1E3                    	shl bx, 1
  2408 00000527 8B97[6E01]              	mov dx, word [ cmdlist+bx ]
  2409                                  cmd4:
  2410 0000052B BF[2E0B]                	mov di, line_out
  2411                                  %if _DEBUG || _LOADER
  2412                                  	db __TEST_IMM8		; (skip int3)
  2413                                  .int3:
  2414                                  	int3			; used by BU command
  2415                                  %endif
  2416 0000052E FFD2                    	call dx
  2417                                  cmd3_j1:
  2418 00000530 E9CDFA                  	jmp cmd3		; back to the top
  2419                                  
  2420                                  
  2421                                  %if !_LOADER
  2422                                  	code_insure_low_byte_not_0CCh
  2423                                  cmd2_reset_re_maybe_pm:
  2424                                  
  2425 00000533 66                      	_386_o32		; mov esp
  2426 00000534 8B26[600C]              	mov sp, word [ savesp ]		; restore stack
  2427 00000538 83E4FC                  _386	and sp, ~3			; align stack
  2428 0000053B 66                      	_386_o32
  2429 0000053C 31C0                    	xor ax, ax
  2430 0000053E 66                      	_386_o32
  2431 0000053F 50                      	push ax
  2432 00000540 66                      	_386_o32
  2433 00000541 9D                      	popf
  2434 00000542 8B26[600C]              _386	mov sp, word [ savesp ]		; restore stack
  2435 00000546 FC                      	cld
  2436 00000547 FB                      	sti
  2437                                  
  2438                                  %if _PM
  2439 00000548 E8(0000)                	call handle_mode_changed
  2440                                  %endif
  2441                                  %endif
  2442                                  
  2443                                  	code_insure_low_byte_not_0CCh
  2444                                  cmd2_reset_re:
  2445 0000054B 8B1E[FC0D]              	mov bx, word [io_levels]
  2446                                  .entry_bx_levels:
  2447 0000054F 31C9                    	xor cx, cx
  2448                                  .entry_bx_levels_cx_cmdline:
  2449 00000551 31D2                    	xor dx, dx
  2450                                  %if _INPUT_FILE_HANDLES
  2451 00000553 F606[DE01]10            	testopt [internalflags2], dif2_input_file
  2452 00000558 7405                    	jz @F
  2453 0000055A 030E[480C]              	add cx, word [input_file_handles.active]
  2454 0000055E 41                      	inc cx
  2455                                  @@:
  2456                                  %endif
  2457                                  %if _INPUT_FILE_BOOT
  2458 0000055F F606[DF01]02            	testopt [internalflags2], dif2_input_file_boot
  2459 00000564 7405                    	jz @F
  2460 00000566 030E[0000]              	add cx, word [load_input_file.active]
  2461 0000056A 41                      	inc cx
  2462                                  @@:
  2463                                  %endif
  2464                                  %if !_LOADER
  2465 0000056B F606[E301]01            	testopt [internalflags3], dif3_input_re
  2466 00000570 740D                    	jz @F
  2467 00000572 41                      	inc cx
  2468 00000573 42                      	inc dx
  2469                                  		; Flag: If we abort anything (effective IOL >= 1)
  2470                                  		;  then we need to cancel RE buffer execution.
  2471                                  		;  This is so because RE execution is always the
  2472                                  		;  topmost command source, taking precedence over
  2473                                  		;  yy as well as RC buffer execution.
  2474 00000574 F606[FE0D]01            	testopt [io_flags], iof_extra_iol_for_tpg_re
  2475 00000579 7404                    	jz @F
  2476 0000057B 43                      	inc bx
  2477 0000057C 7501                    	jnz @F
  2478 0000057E 4B                      	dec bx
  2479                                  @@:
  2480                                  %endif
  2481 0000057F F606[E101]01            	testopt [internalflags3], dif3_input_cmdline
  2482 00000584 740C                    	jz @F
  2483 00000586 41                      	inc cx
  2484 00000587 F606[FE0D]02            	testopt [io_flags], iof_extra_iol_for_rc
  2485 0000058C 7404                    	jz @F
  2486 0000058E 43                      	inc bx
  2487 0000058F 7501                    	jnz @F
  2488 00000591 4B                      	dec bx
  2489                                  @@:
  2490 00000592 39D9                    	cmp cx, bx
  2491 00000594 7602                    	jbe @F
  2492 00000596 89D9                    	mov cx, bx
  2493                                  @@:
  2494 00000598 E396                    	jcxz cmd3_j1			; IOL zero or nothing active -->
  2495 0000059A 1E                      	push ds
  2496 0000059B 07                      	pop es
  2497                                  @@:
  2498 0000059C 51                      	push cx
  2499 0000059D 52                      	push dx
  2500 0000059E E8(0000)                	call getline_close_file.resetstuff
  2501 000005A1 5A                      	pop dx
  2502 000005A2 59                      	pop cx
  2503 000005A3 E2F7                    	loop @B
  2504                                  %if !_LOADER
  2505 000005A5 85D2                    	test dx, dx			; first cancelled was RE ?
  2506 000005A7 7487                    	jz cmd3_j1			; no, just proceed now -->
  2507 000005A9 800E[A501]80            	setopt [options2], opt2_re_cancel_tpg
  2508                                  					; set to cancel command
  2509 000005AE E9(0000)                	jmp dumpregs_extended.exit	; clean up RE state
  2510                                  %else
  2511                                  	jmp cmd3_j1
  2512                                  %endif
  2513                                  
  2514                                  dmycmd:
  2515 000005B1 C3                      	retn
  2516                                  
  2517                                  %if _EXTENSIONS
  2518                                  lastcmd_transfer_ext_entry:
  2519                                   %if _LINK
  2520 000005B2 B9[0000]                	mov cx, eld_linkcall.call_cmd3
  2521                                   wlcalc word_minusext_eld_linkcall, equ $ - 2
  2522                                   %else
  2523                                  	mov cx, eld_linkcall.call_cmd3 - eld_linkcall
  2524                                   %endif
  2525 000005B5 51                      	push cx
  2526 000005B6 8B0E[D40D]              	mov cx, word [lastcmd_transfer_ext_address]
  2527 000005BA E9(0000)                	jmp transfer_ext_cx
  2528                                  
  2529                                  near_transfer_ext_entry:
  2530 000005BD 51                      	push cx
  2531 000005BE 8B0E[D60D]              	mov cx, word [near_transfer_ext_address]
  2532 000005C2 E9(0000)                	jmp transfer_ext_cx
  2533                                  		; INP:	cx = entrypoint ip
  2534                                  		;	ss:sp -> original cx value, near return address
  2535                                  
  2536                                  		; INP:	ss:sp -> three words to discard, cx, near return
  2537                                  near_transfer_ext_return: section_of_function
  2538 000005C5 59                      	pop cx				; discard near return address
  2539 000005C6 59                      	pop cx
  2540 000005C7 59                      	pop cx				; discard far return address
  2541 000005C8 59                      	pop cx				; restore cx
  2542 000005C9 C3                      	retn				; return
  2543                                  %endif
  2544                                  
  2545                                  help:
  2546 000005CA E8(0000)                	call skipcomma
  2547 000005CD E8(0000)                	call capitalise
  2548                                  %if _EXTHELP
  2549                                   %if _COND
  2550 000005D0 BA[0000]                	mov dx, msg.condhelp
  2551 000005D3 3C43                    	cmp al, 'C'
  2552 000005D5 7503E99200              	je .spec
  2553                                   %endif
  2554                                   %if _OPTIONS
  2555 000005DA 3C4F                    	cmp al, 'O'
  2556 000005DC 7503E9AC00              	je .options		; option help -->
  2557                                   %endif
  2558                                   %if _EXPRESSIONS
  2559 000005E1 BA[0000]                	mov dx, msg.expressionhelp
  2560 000005E4 3C45                    	cmp al, 'E'
  2561 000005E6 7503E98100              	je .spec
  2562                                   %endif
  2563                                  %endif
  2564                                  %if _EMS
  2565                                  	mov dx, msg.xhelp
  2566                                  	cmp al, 'X'
  2567                                  	je .spec
  2568                                  %endif
  2569 000005EB 4E                      	dec si
  2570                                   %if _BOOTLDR && _EXTHELPBOOT
  2571 000005EC BA[0000]                	mov dx, msg.boot
  2572 000005EF E8(0000)                	call isstring?
  2573 000005F2 BA[0000]                	mov dx, msg.boothelp
  2574                                    %if _LINK || _LINK_COMPAT
  2575                                  patch_boothelp_uncompressed: equ $ - 2
  2576                                    %endif
  2577 000005F5 7475                    	je .spec
  2578                                   %endif
  2579                                  %if _PM
  2580 000005F7 BA[0000]                	mov dx, msg.desc
  2581 000005FA E8(0000)                	call isstring?
  2582 000005FD BA[0000]                	mov dx, msg.deschelp
  2583 00000600 746A                    	je .spec
  2584                                  %endif
  2585                                  %if _EXTHELP
  2586 00000602 BA[0000]                	mov dx, msg.source
  2587 00000605 E8(0000)                	call isstring?
  2588 00000608 BA[0000]                	mov dx, msg.help_source
  2589 0000060B 745F                    	je .spec
  2590                                  %endif
  2591                                  %if !_LOADER
  2592 0000060D BA[0000]                	mov dx, msg.re
  2593 00000610 E8(0000)                	call isstring?
  2594 00000613 BA[0000]                	mov dx, msg.help_re
  2595 00000616 7454                    	je .spec
  2596 00000618 BA[0000]                	mov dx, msg.run
  2597 0000061B E8(0000)                	call isstring?
  2598 0000061E BA[0000]                	mov dx, msg.help_run
  2599 00000621 7449                    	je .spec
  2600                                  %endif
  2601 00000623 BA[0000]                	mov dx, msg.string_version
  2602 00000626 E8(0000)                	call isstring?
  2603 00000629 BB[0000]                	mov bx, msg.build_array
  2604 0000062C B9[0000]                	mov cx, msg.build_version_amount
  2605 0000062F 744D                    	je .spec_multi
  2606 00000631 BA[0000]                	mov dx, msg.string_build
  2607 00000634 E8(0000)                	call isstring?
  2608                                   %if _LINK_COMPAT
  2609 00000637 B9[0000]                	mov cx, msg.build_short_amount
  2610                                   %else
  2611                                  	mov cl, msg.build_short_amount
  2612                                   %endif
  2613 0000063A 7442                    	je .spec_multi
  2614 0000063C AC                      	lodsb
  2615 0000063D E8(0000)                	call capitalise
  2616                                   %if _LINK_COMPAT
  2617 00000640 B9[0000]                	mov cx, msg.build_long_amount
  2618                                   %else
  2619                                  	mov cl, msg.build_long_amount
  2620                                   %endif
  2621 00000643 3C42                    	cmp al, 'B'
  2622 00000645 7437                    	je .spec_multi		; build info -->
  2623                                  %if _EXTHELP
  2624 00000647 BA[0000]                	mov dx, msg.license
  2625 0000064A 3C4C                    	cmp al, 'L'
  2626 0000064C 741E                    	je .spec		; licence -->
  2627 0000064E BA[0000]                	mov dx, msg.flaghelp
  2628 00000651 3C46                    	cmp al, 'F'
  2629 00000653 7417                    	je .spec		; flag help -->
  2630 00000655 BA[0000]                	mov dx, msg.reghelp
  2631 00000658 3C52                    	cmp al, 'R'
  2632 0000065A 7410                    	je .spec		; register help -->
  2633                                   %if _VARIABLES || _OPTIONS || _PSPVARIABLES
  2634 0000065C BA[0000]                	mov dx, msg.varhelp
  2635 0000065F 3C56                    	cmp al, 'V'
  2636 00000661 7409                    	je .spec		; variable help -->
  2637                                   %endif
  2638                                  %endif
  2639 00000663 BB[0000]                	mov bx, msg.help_array	; default help
  2640                                   %if _LINK_COMPAT
  2641 00000666 B9[0000]                	mov cx, msg.help_array_amount
  2642                                   %else
  2643                                  	mov cl, msg.help_array_amount
  2644                                   %endif
  2645 00000669 4E                      	dec si
  2646 0000066A EB12                    	jmp .spec_multi
  2647                                  
  2648                                  .spec:
  2649 0000066C AC                      	lodsb
  2650 0000066D E8(0000)                	call chkeol
  2651                                  %if _MESSAGESEGMENT || _HELP_COMPRESSED
  2652 00000670 E8(0000)                	call putsz_exthelp
  2653 00000673 EB03                    	jmp cmd3_j1a
  2654                                  %endif
  2655                                  
  2656                                  prnquit:
  2657 00000675 E8(0000)                	call putsz		; print string
  2658                                  cmd3_j1a:
  2659 00000678 E9B5FE                  	jmp cmd3_j1		; done
  2660                                  
  2661 0000067B E9C00F                  errorj1:jmp error
  2662                                  
  2663                                  help.spec_multi:
  2664 0000067E AC                      	lodsb
  2665 0000067F E8(0000)                	call chkeol
  2666                                  .loop:
  2667 00000682 8B17                    	mov dx, word [bx]
  2668 00000684 E8(0000)                	call putsz_exthelp
  2669 00000687 43                      	inc bx
  2670 00000688 43                      	inc bx
  2671 00000689 E2F7                    	loop .loop
  2672 0000068B EBEB                    	jmp short cmd3_j1a
  2673                                  
  2674                                  %if _EXTHELP && _OPTIONS
  2675                                  help.options:
  2676 0000068D 89F3                    	mov bx, si
  2677 0000068F E8(0000)                	call skipwhite
  2678 00000692 E8(0000)                	call iseol?
  2679 00000695 7443                    	je .all
  2680 00000697 E8(0000)                	call capitalise
  2681 0000069A 3C41                    	cmp al, 'A'
  2682 0000069C BA[0000]                	mov dx, msg.asmoptions_1
  2683 0000069F 7427                    	je .single
  2684 000006A1 3C49                    	cmp al, 'I'
  2685 000006A3 BA[0000]                	mov dx, msg.flags_1
  2686 000006A6 7420                    	je .single
  2687 000006A8 BF[0000]                	mov di, msg.options_scan
  2688 000006AB B9[0000]                	mov cx, msg.options_scan_amount
  2689 000006AE F2AE                    	repne scasb
  2690 000006B0 7518                    	jne .pages
  2691 000006B2 81EF[0100]              	sub di, msg.options_scan + 1
  2692 000006B6 D1E7                    	shl di, 1
  2693 000006B8 8BBD[0000]              	mov di, word [msg.options_array + di]
  2694 000006BC 89FA                    	mov dx, di
  2695                                  %if _MESSAGESEGMENT
  2696 000006BE 1E                      	push ds
  2697                                   %if _PM
  2698 000006BF E8(0000)                	call get_messagesegsel
  2699                                   %else
  2700                                   	mov ds, word [ss:messageseg]
  2701                                   %endif
  2702                                   %if _HELP_COMPRESSED
  2703 000006C2 833D05                  	cmp word [di], 2 + !!_LZEXEDAT * 3
  2704                                   %else
  2705                                  	cmp byte [di], 0
  2706                                   %endif
  2707 000006C5 1F                      	pop ds
  2708                                  %else
  2709                                   %if _HELP_COMPRESSED
  2710                                  	cmp word [di], 2 + !!_LZEXEDAT * 3
  2711                                   %else
  2712                                  	cmp byte [di], 0
  2713                                   %endif
  2714                                  %endif
  2715 000006C6 74B3                    	je errorj1
  2716                                  .single:
  2717 000006C8 EBA2                    	jmp help.spec
  2718                                  
  2719                                  .pages:
  2720 000006CA 8D77FF                  	lea si, [bx - 1]
  2721 000006CD BA[0000]                	mov dx, msg.string_options
  2722 000006D0 E8(0000)                	call isstring?
  2723 000006D3 75A6                    	jne errorj1
  2724 000006D5 BA[0000]                	mov dx, msg.options_pages
  2725 000006D8 EBEE                    	jmp .single
  2726                                  
  2727                                  .all:
  2728 000006DA BB[0000]                	mov bx, msg.options_array
  2729 000006DD B9[0000]                	mov cx, msg.options_array_amount
  2730                                  .loop:
  2731 000006E0 8B3F                    	mov di, word [bx]
  2732 000006E2 8B17                    	mov dx, word [bx]
  2733 000006E4 E8(0000)                	call putsz_exthelp
  2734 000006E7 43                      	inc bx
  2735 000006E8 43                      	inc bx
  2736                                  %if _MESSAGESEGMENT
  2737 000006E9 1E                      	push ds
  2738                                   %if _PM
  2739 000006EA E8(0000)                	call get_messagesegsel
  2740                                   %else
  2741                                   	mov ds, word [ss:messageseg]
  2742                                   %endif
  2743                                   %if _HELP_COMPRESSED
  2744 000006ED 833D05                  	cmp word [di], 2 + !!_LZEXEDAT * 3
  2745                                   %else
  2746                                  	cmp byte [di], 0
  2747                                   %endif
  2748 000006F0 1F                      	pop ds
  2749                                  %else
  2750                                   %if _HELP_COMPRESSED
  2751                                  	cmp word [di], 2 + !!_LZEXEDAT * 3
  2752                                   %else
  2753                                  	cmp byte [di], 0
  2754                                   %endif
  2755                                  %endif
  2756 000006F1 740B                    	je @F
  2757 000006F3 83F901                  	cmp cx, 1
  2758 000006F6 7406                    	je @F
  2759 000006F8 BA[0000]                	mov dx, crlf
  2760 000006FB E8(0000)                	call putsz
  2761                                  @@:
  2762 000006FE E2E0                    	loop .loop
  2763 00000700 E9FDF8                  	jmp cmd3
  2764                                  %endif
  2765                                  
  2766                                  
  2767                                  %if (_CATCHINTFAULTCOND && _CATCHINT0D) 	|| (_CATCHINTFAULTCOND && _CATCHINT0C) 	|| _CATCHINT2D || _CATCHINT08 || _LOADER
  2770                                  		; INP:	ds:si -> IISP entry header
  2771                                  		;	al = interrupt number
  2772                                  		;	bx = interrupt hooked status flag (dif4 low word)
  2773                                  		; OUT:	-
  2774                                  		; CHG:	ax, bx, cx, dx, di, si
  2775                                  cmd3_int_enable.set_bx_to_dx:
  2776 00000703 89D3                    	mov bx, dx
  2777                                  
  2778                                  cmd3_int_enable:
  2779 00000705 851E[E401]              	test word [internalflags4], bx
  2780 00000709 750C                    	jnz .ret
  2781                                  
  2782                                  .need:
  2783 0000070B 53                      	push bx
  2784 0000070C E8(0000)                	call install_86m_interrupt_handler
  2785 0000070F 5B                      	pop bx
  2786 00000710 091E[E401]              	or word [internalflags4], bx
  2787 00000714 E8(0000)                	call update_inttab_optional
  2788                                  .ret:
  2789 00000717 C3                      	retn
  2790                                  %endif
  2791                                  
  2792                                  
  2793                                  %if (_CATCHINTFAULTCOND && _CATCHINT0D) 	|| (_CATCHINTFAULTCOND && _CATCHINT0C) 	|| _CATCHINT2D || _CATCHINT08 || _PM || _LOADER
  2796                                  		; INP:	ds:si -> IISP entry header
  2797                                  		;	al = interrupt number
  2798                                  		;	dx = interrupt unhook force flag (dif4 high word)
  2799                                  		;	bx = interrupt hooked status flag (dif4 low word)
  2800                                  		; OUT:	NC if successfully unhooked
  2801                                  		;	 dif4 low word cleared
  2802                                  		;	CY if already unhooked or failed to unhook,
  2803                                  		;	 ZR if already unhooked
  2804                                  		;	  (dif4 low word is clear)
  2805                                  		;	 NZ if failed to unhook
  2806                                  		;	  (dif4 low word is still set)
  2807                                  		; CHG:	ax, bx, di, si
  2808                                  cmd3_int_disable.set_bx_to_dx:
  2809 00000718 89D3                    	mov bx, dx
  2810                                  
  2811                                  cmd3_int_disable:
  2812 0000071A 851E[E401]              	test word [internalflags4], bx
  2813 0000071E 7412                    	jz .ret_CY		; --> (ZR)
  2814                                  
  2815 00000720 E8(0000)                	call UnhookInterruptForce
  2816 00000723 720B                    	jc .ret_CY_NZ
  2817                                  
  2818 00000725 F7D3                    	not bx
  2819 00000727 211E[E401]              	and word [internalflags4], bx
  2820 0000072B E8(0000)                	call update_inttab_optional
  2821 0000072E F8                      	clc			; (NC)
  2822 0000072F C3                      	retn
  2823                                  
  2824                                  .ret_CY_NZ:
  2825 00000730 85E4                    	test sp, sp		; (NZ)
  2826                                  .ret_CY:
  2827 00000732 F9                      	stc			; (CY)
  2828 00000733 C3                      	retn
  2829                                  %endif
  2830                                  
  2831                                  
  2832                                  determine_quiet_output:
  2833 00000734 8026[E101]EF            	clropt [internalflags3], dif3_quiet_output
  2834                                  
  2835 00000739 57                      	push di
  2836 0000073A 50                      	push ax
  2837 0000073B F606[E301]01            	testopt [internalflags3], dif3_input_re
  2838 00000740 7549                    	jnz .notquiet
  2839                                  
  2840                                  %if _INPUT_FILE_BOOT
  2841 00000742 F606[DF01]02            	testopt [internalflags2], dif2_input_file_boot
  2842 00000747 7412                    	jz @F
  2843 00000749 B8A000                  	mov ax, LOAD_INPUT_FILE_SIZE
  2844 0000074C 52                      	push dx
  2845 0000074D F726[0000]              	mul word [load_input_file.active]
  2846 00000751 5A                      	pop dx
  2847 00000752 89C7                    	mov di, ax
  2848 00000754 F685[2700]80            	testopt [load_input_file + di - LOADDATA3 + ldFATType], ifhfQuietOutput
  2849 00000759 EB29                    	jmp .quiet_if_nz
  2850                                  
  2851                                  @@:
  2852                                  %endif
  2853                                  %if _INPUT_FILE_HANDLES
  2854 0000075B E8EB10                  	call InDOS
  2855 0000075E 7518                    	jnz @F
  2856                                  
  2857 00000760 F606[DE01]10            	testopt [internalflags2], dif2_input_file
  2858 00000765 7411                    	jz @F
  2859 00000767 8B3E[480C]              	mov di, word [input_file_handles.active]
  2860 0000076B D1E7                    	shl di, 1
  2861 0000076D D1E7                    	shl di, 1
  2862 0000076F D1E7                    	shl di, 1		; to qword array index
  2863                                   %if INPUTFILEHANDLE_size != 8
  2864                                    %error Unexpected structure size
  2865                                   %endif
  2866 00000771 F685[CB0B]80            	testopt [input_file_handles + di + ifhFlags], ifhfQuietOutput
  2867 00000776 EB0C                    	jmp .quiet_if_nz
  2868                                  
  2869                                  @@:
  2870                                  %endif
  2871 00000778 F606[E101]01            	testopt [internalflags3], dif3_input_cmdline
  2872 0000077D 740C                    	jz @F
  2873 0000077F F606[A301]80            	testopt [options], opt_cmdline_quiet_output
  2874                                  	; jmp .quiet_if_nz
  2875                                  
  2876                                  .quiet_if_nz:
  2877 00000784 7405                    	jz @F
  2878                                  .quiet:
  2879 00000786 800E[E101]10            	setopt [internalflags3], dif3_quiet_output
  2880                                  .notquiet:
  2881                                  @@:
  2882 0000078B 58                      	pop ax
  2883 0000078C 5F                      	pop di
  2884 0000078D C3                      	retn
  2885                                  
  2886                                  
  2887                                  guard_auxbuff.1_or_2:
  2888 0000078E F606[E301]30            	testopt [internalflags3], dif3_auxbuff_guarded_1 		| dif3_auxbuff_guarded_2
  2890 00000793 EB05                    	jmp @F
  2891                                  
  2892                                  guard_auxbuff: section_of_function
  2893 00000795 F606[E301]70            	testopt [internalflags3], dif3_auxbuff_guarded_1 		| dif3_auxbuff_guarded_2 		| dif3_auxbuff_guarded_3
  2896                                  @@:
  2897 0000079A 7506                    	jnz @F
  2898 0000079C 800E[E301]10            	setopt [internalflags3], dif3_auxbuff_guarded_1
  2899 000007A1 C3                      	retn
  2900                                  
  2901                                  @@:
  2902 000007A2 B80101                  	mov ax, 0101h
  2903 000007A5 E8EC0E                  	call setrc
  2904 000007A8 BA[0000]                	mov dx, msg.guard_auxbuff_error
  2905                                  .putsz_error:
  2906 000007AB E8(0000)                	call putsz
  2907 000007AE E94FF8                  	jmp cmd3
  2908                                  
  2909                                  
  2910                                  		; This is used to disallow commands
  2911                                  		;  while reading from the RE buffer.
  2912                                  guard_re: section_of_function
  2913                                  %if !_LOADER
  2914 000007B1 F606[E301]01            	testopt [internalflags3], dif3_input_re
  2915 000007B6 7501                    	jnz @F
  2916 000007B8 C3                      	retn
  2917                                  
  2918                                  @@:
  2919 000007B9 BA[0000]                	mov dx, msg.guard_re_error
  2920 000007BC EB0B                    	jmp guard_rc.specificerror102
  2921                                  %else
  2922                                  	retn
  2923                                  %endif
  2924                                  
  2925                                  		; This is used to disallow commands
  2926                                  		;  while reading from the RC buffer.
  2927                                  guard_rc:
  2928 000007BE F606[E101]01            	testopt [internalflags3], dif3_input_cmdline
  2929 000007C3 7501                    	jnz @F
  2930 000007C5 C3                      	retn
  2931                                  
  2932                                  @@:
  2933 000007C6 BA[0000]                	mov dx, msg.guard_rc_error
  2934                                  .specificerror102:
  2935 000007C9 B80201                  	mov ax, 0102h
  2936 000007CC E8C50E                  	call setrc
  2937 000007CF EBDA                    	jmp guard_auxbuff.putsz_error
  2938                                  
  2939                                  
  2940                                  %if _EXTENSIONS
  2941                                  	usesection lDEBUG_DATA_ENTRY
  2941          ------------------       note: usesection lDEBUG_DATA_ENTRY
  2942                                  	align 2, db 0
  2943                                  linkcall_table:
  2944 00001484 0000                    .init:	dw 0
  2945 00001486 0600                    	dw (.end - .) / 2
  2946                                  .:
  2947 00001488 0000                    	dw 0
  2948 0000148A 0000                    .code1:	dw 0
  2949                                   %if _DUALCODE
  2950 0000148C 0100                    	dw 1
  2951 0000148E 0000                    .code2:	dw 0
  2952                                   %endif
  2953 00001490 0200                    	dw 2
  2954 00001492 0000                    .entry:	dw 0
  2955                                  .end:
  2956                                  
  2957                                  		; INP:	_PM=0: ss:sp -> dword far return address
  2958                                  		;	_PM=1: ss:sp -> word near return address
  2959                                  		;		followed by an uninitialised placeholder word
  2960                                  		; CHG:	- (not even flags)
  2961                                  entry_ret_to_ext:
  2962                                   %if _PM
  2963 00001494 E89FFF                  	call entry_to_code_segsel
  2964 00001497 [DD07]                  	dw code_ret_to_ext
  2965                                   %else
  2966                                  	retf		; simple
  2967                                   %endif
  2968                                  
  2969                                  
  2970                                  	usesection lDEBUG_CODE
  2970          ------------------       note: usesection lDEBUG_CODE
  2971                                   %if _DUALCODE && _PM
  2972                                  		; INP:	ss:sp -> dword dual call return address (to discard)
  2973                                  		;	ss:sp + 4 -> word near return address
  2974                                  		;		followed by an uninitialised placeholder word
  2975                                  		; CHG:	- (not even flags)
  2976                                  dualfunction
  2977                                  code2_to_code_ret_to_ext: section_of_function
  2978                                  	lframe 0
  2979                                  	lpar word, dualseg
  2980                                  	lpar word, dualofs
  2981 000007D1 5589E5                  	lenter
  2982 000007D4 FF7600                  	push word [bp + ?frame_bp]
  2983 000007D7 8F4604                  	pop word [bp + ?dualseg]
  2984                                  	lleave ctx
  2985 000007DA 5D                      	pop bp			; (discard)
  2986 000007DB 5D                      	pop bp			; (discard)
  2987 000007DC 5D                      	pop bp			; restore bp
  2988                                  		; fall through to code_ret_to_ext
  2989                                   %endif
  2990                                  
  2991                                  		; INP:	_PM=0: ss:sp -> dword far return address
  2992                                  		;	_PM=1: ss:sp -> word near return address
  2993                                  		;		followed by an uninitialised placeholder word
  2994                                  		; CHG:	- (not even flags)
  2995                                  code_ret_to_ext:
  2996                                   %if _PM
  2997                                  		; ss:sp -> word near return address, placeholder word
  2998                                  	lframe 0
  2999                                  	lpar word, retseg
  3000                                  	lpar word, retofs
  3001 000007DD 5589E5                  	lenter
  3002 000007E0 57                      	push di
  3003 000007E1 368B3E[6202]            	mov di, word [ss:pm_2_86m_0]
  3004                                    %if extseg + 2 != extcssel
  3005                                     %error code_ret_to_ext expects extcssel after extseg
  3006                                    %endif
  3007 000007E6 36FFB5[2C02]            	push word [ss:extseg + di]
  3008 000007EB 8F4604                  	pop word [bp + ?retseg]
  3009 000007EE 5F                      	pop di
  3010 000007EF 5D                      	lleave , optimiserestoresp
  3011                                   %endif
  3012                                  code_retf: section_of_function
  3013 000007F0 CB                      	retf			; now return to ext
  3014                                  
  3015                                   %if _DUALCODE
  3016                                  	usesection lDEBUG_CODE2
  3016          ------------------       note: usesection lDEBUG_CODE2
  3017                                  code2_ret_to_ext:
  3018                                    %if _PM
  3019 00000008 E81F00[D107]            	dualcall code2_to_code_ret_to_ext
  3020                                    %else
  3021                                  	retf			; simple case if _PM=0
  3022                                    %endif
  3023                                   %endif
  3024                                  %endif
  3025                                  
  3026                                  %ifn _EXTENSIONS
  3027                                  code_retf: section_of_function
  3028                                  	retf
  3029                                  %endif
  3030                                  
  3031                                  %ifn _LINK_COMPAT
  3032                                   %ifn _LINK
  3033                                  %include "amis.asm"
  3034                                   %endif
  3035                                  
  3036                                  	usesection lDEBUG_CODE
  3037                                  
  3038                                  %if _DEBUG4 || _DEBUG5
  3039                                  %define _DEB_ASM_PREFIX
  3040                                  %include "deb.asm"
  3041                                  %endif
  3042                                  
  3043                                  
  3044                                   %ifn _LINK
  3045                                  %if !_LOADER
  3046                                  %include "aa.asm"
  3047                                  %endif
  3048                                  %include "dd.asm"
  3049                                  %if _RN
  3050                                   %imacro internaldatarelocation 0-*.nolist
  3051                                   %endmacro
  3052                                   %include "fptostr.asm"
  3053                                   %unimacro internaldatarelocation 0-*.nolist
  3054                                  %endif
  3055                                  %include "run.asm"
  3056                                  %include "install.asm"
  3057                                  %include "uu.asm"
  3058                                  %if _IMMASM
  3059                                  %include "immasm.asm"
  3060                                  %else
  3061                                  immasm:
  3062                                  	lodsb
  3063                                  	call chkeol
  3064                                  	jmp cmd3
  3065                                  %endif
  3066                                  %if _HELP_COMPRESSED
  3067                                  	overridedef STANDALONE, 0
  3068                                  %include "helpdepk.asm"
  3069                                  	resetdef STANDALONE
  3070                                  %endif
  3071                                   %endif
  3072                                  %else		; _LINK_COMPAT
  3073                                  %if _DEBUG4 || _DEBUG5
  3074                                  %define _DEB_ASM_PREFIX
  3075                                  %include "deb.asm"
  3076                                  %endif
  3077                                  %endif		; _LINK_COMPAT
  3078                                  
  3079                                  	usesection lDEBUG_DATA_ENTRY
  3079          ------------------       note: usesection lDEBUG_DATA_ENTRY
  3080                                  
  3081                                  %if _PM || _CATCHINT07 || _CATCHINT0C || _CATCHINT0D
  3082 00001499 00<rep 3h>              	align 4, db 0
  3083 0000149C 00000000                exception_csip:	dd 0	; 16:16 far 16-bit address of debugger exception
  3084                                   %if _AREAS
  3085 000014A0 0000<rep 4h>            exception_stack:times 4 dw 0
  3086                                  			; stack of debugger exception
  3087                                   %endif
  3088                                  %endif
  3089                                  
  3090                                  %if _PM
  3091                                   %ifn _LINK || _LINK_COMPAT
  3092                                  %include "pmdata.asm"
  3093                                  %include "pminit.asm"
  3094                                  %include "pmentry.asm"
  3095                                   %endif
  3096                                  
  3097                                  
  3098                                  	usesection lDEBUG_CODE
  3098          ------------------       note: usesection lDEBUG_CODE
  3099                                  
  3100                                  subcpu 286
  3101                                  resetmode_and_test_d_b_bit: section_of_function
  3102                                  %if _PM
  3103 000007F1 E8(0000)                	call resetmode
  3104                                  %endif
  3105                                  
  3106                                  		; Test if bx is a 32-bit selector
  3107                                  		;  (as opposed to a 16-bit selector or a segment)
  3108                                  		;
  3109                                  		; INP:	bx = selector (PM) or segment (86M)
  3110                                  		; OUT:	NZ = 32-bit
  3111                                  		;	ZR = 16-bit (always if 86M)
  3112                                  		;	NC
  3113                                  		; REM:	This checks whether a code segment's D bit or
  3114                                  		;	 a stack segment's B bit is set. This operation
  3115                                  		;	 is not meaningful otherwise.
  3116                                  test_d_b_bit: section_of_function
  3117 000007F4 E8A601                  _386	call ispm
  3118 000007F7 7403                    _386	jz .pm				; 386 and PM, check selector -->
  3119                                  		; not PM or no 386
  3120                                  .ZR:
  3121 000007F9 38C0                    	cmp al, al			; ZR, NC
  3122 000007FB C3                      	retn
  3123                                  .pm:
  3124                                  [cpu 386]
  3125 000007FC 6650                    	push eax
  3126 000007FE 6631C0                  	xor eax, eax			; use rights = 0 if inaccessible
  3127 00000801 660F02C3                	lar eax, ebx			; access rights
  3128                                  		; eax is unchanged if the access rights are inaccessible
  3129                                  		;  (and NZ is set in that case)
  3130 00000805 66A900004000            	test eax, 400000h		; test bit (NC)
  3131 0000080B 6658                    	pop eax
  3132 0000080D C3                      	retn
  3133                                  __CPU__
  3134                                  
  3135                                  
  3136                                  		; Test if selector in bx has a limit beyond 64 KiB - 1 B
  3137                                  		;
  3138                                  		; INP:	bx = selector (PM) or segment (86M)
  3139                                  		; OUT:	NZ = limit above 64 KiB - 1 B
  3140                                  		;	ZR = limit below 64 KiB (always if 86M)
  3141                                  		;	NC
  3142                                  test_high_limit: section_of_function
  3143 0000080E E88C01                  _386	call ispm
  3144 00000811 7402                    _386	jz .pm				; 386 and PM, check selector -->
  3145                                  		; not PM or no 386
  3146 00000813 EBE4                    	jmp test_d_b_bit.ZR
  3147                                  
  3148                                  .pm:
  3149                                  [cpu 386]
  3150 00000815 6650                    	push eax
  3151 00000817 6631C0                  	xor eax, eax			; use limit = 0 if inaccessible
  3152 0000081A 660F03C3                	lsl eax, ebx			; segment limit
  3153                                  		; eax is unchanged if the segment limit is inaccessible
  3154                                  		;  (and NZ is set in that case)
  3155 0000081E 66A90000FFFF            	test eax, 0FFFF_0000h		; (NC) ZR if low limit, else NZ
  3156 00000824 6658                    	pop eax
  3157 00000826 C3                      	retn
  3158                                  __CPU__
  3159                                  
  3160                                  subcpureset	; subcpu used in pminit.asm (!_LINK)
  3161                                  %endif	; _PM
  3162                                  
  3163                                  %if _NOEXTENDER
  3164                                  		; When we support non-extended DPMI, some calls to Int21
  3165                                  		; are (extended) Int21 calls and some are (not extended)
  3166                                  		; calls down to the real mode Int21. doscall is a macro
  3167                                  		; that will always call the non-extended Int21.
  3168                                  
  3169                                  		; Execute a non-extended DOS call
  3170                                  _doscall: section_of_function
  3171 00000827 57                      	push di
  3172 00000828 368B3E[6202]            	mov di, word [ss:pm_2_86m_0]
  3173 0000082D 36FFA5[A814]            	jmp near word [ss:.table + di]
  3174                                  
  3175                                  	usesection lDEBUG_DATA_ENTRY
  3175          ------------------       note: usesection lDEBUG_DATA_ENTRY
  3176                                  		; REM:	Dispatch table in section lDEBUG_CODE
  3177                                  	align 2, db 0
  3178                                  .table:
  3179 000014A8 [3E08]                  	dw .86m_pop
  3180 000014AA [3208]                  	dw .pm_pop
  3181                                  
  3182                                  	usesection lDEBUG_CODE
  3182          ------------------       note: usesection lDEBUG_CODE
  3183                                  .pm_pop:
  3184 00000832 5F                      	pop di
  3185                                  subcpu 286
  3186                                  		; Execute a non-extended DOS call from PM
  3187                                  .pm:
  3188 00000833 36FF36[760C]            	push word [ss:pspdbg]
  3189 00000838 6A21                    	push 21h
  3190 0000083A E89A02                  	call intcall
  3191 0000083D C3                      	retn
  3192                                  subcpureset
  3193                                  .86m_pop:
  3194 0000083E 5F                      	pop di
  3195 0000083F E90502                  	jmp _int21
  3196                                  %endif
  3197                                  
  3198                                  
  3199                                  %if _DUALCODE
  3200                                  %push
  3201                                  %assign %$counter 0
  3202                                  
  3203                                  %rep 2
  3204                                  
  3205                                  %if %$counter == 0
  3206                                  %define %$currentindex 0
  3207                                  %define %$currentname lDEBUG_CODE
  3208                                  %define %$othername lDEBUG_CODE2
  3209                                  %define %$othersegvar code2_seg
  3210                                  %define %$otherselvar code2_sel
  3211                                  %else
  3212                                  %define %$currentindex 1
  3213                                  %define %$currentname lDEBUG_CODE2
  3214                                  %define %$othername lDEBUG_CODE
  3215                                  %define %$othersegvar code_seg
  3216                                  %define %$otherselvar code_sel
  3217                                  %endif
  3218                                  
  3219                                  	hiddenusesection %$currentname
  3220                                  %if _PM
  3221                                  %$currentname %+ _to_ %+ %$currentname %+ _dualcall_helper:
  3222                                  	push ax		; placeholder
  3223                                  	push ax		; chain
  3224                                  	lframe 0
  3225                                  	lpar word,	offset_segment
  3226                                  	lpar word,	placeholder
  3227                                  	lpar word,	chain
  3228                                  	lenter
  3229                                  	push bx
  3230                                  	mov bx, word [bp + ?offset_segment]
  3231                                  %if _DEBUG
  3232                                  	mov word [bp + ?placeholder], bx
  3233                                  	push word [cs:bx + 2]
  3234                                  %else
  3235                                  	push word [cs:bx]
  3236                                  	lea bx, [bx + 2]
  3237                                  	mov word [bp + ?placeholder], bx
  3238                                  %endif
  3239                                  	pop word [bp + ?chain]
  3240                                  	mov word [bp + ?offset_segment], %$$currentindex
  3241                                  	pop bx
  3242                                  	lleave
  3243                                  	retn
  3244                                  
  3245                                  %$currentname %+ _to_ %+ %$othername %+ _dualcall_helper:
  3246                                  	push ax		; placeholder
  3247                                  	push ax		; chain
  3248                                  	push ax		; chain
  3249                                  	lframe 0
  3250                                  	lpar word,	offset_segment
  3251                                  	lpar word,	placeholder
  3252                                  	lpar dword,	chain
  3253                                  	lenter
  3254                                  	push bx
  3255                                  	mov bx, word [bp + ?offset_segment]
  3256                                  %if _DEBUG
  3257                                  	mov word [bp + ?placeholder], bx
  3258                                  	push word [cs:bx + 2]
  3259                                  %else
  3260                                  	push word [cs:bx]
  3261                                  	lea bx, [bx + 2]
  3262                                  	mov word [bp + ?placeholder], bx
  3263                                  %endif
  3264                                  	pop word [bp + ?chain]
  3265                                  	mov bx, word [ss:pm_2_86m_0]
  3266                                  %if %$$othersegvar + 2 != %$$otherselvar
  3267                                   %error Expected sel variable after seg variable
  3268                                  %endif
  3269                                  	mov bx, word [ss:%$$othersegvar + bx]
  3270                                  	mov word [bp + ?chain + 2], bx
  3271                                  	mov word [bp + ?offset_segment], %$$currentindex
  3272                                  	pop bx
  3273                                  	lleave
  3274                                  	retf
  3275                                  
  3276                                  
  3277                                  %$currentname %+ _dualret_helper:
  3278                                  	lframe near
  3279                                  	lpar word,	index_segment
  3280                                  	lpar word,	offset
  3281                                  	lpar_return
  3282                                  	lenter
  3283                                  	push bx
  3284                                  	push di
  3285                                  
  3286                                  %if code_seg + 2 != code_sel
  3287                                   %error Unexpected layout
  3288                                  %endif
  3289                                  %if code2_seg + 2 != code2_sel
  3290                                   %error Unexpected layout
  3291                                  %endif
  3292                                  	mov bx, word [bp + ?index_segment]
  3293                                  	mov bl, byte [ss:.table + bx]	; multiply without fl change
  3294                                  	mov di, word [ss:pm_2_86m_0]
  3295                                  	mov bx, word [ss:code_seg + bx + di]
  3296                                  	mov word [bp + ?index_segment], bx
  3297                                  	pop di
  3298                                  	pop bx
  3299                                  	lleave
  3300                                  	lret
  3301                                  
  3302                                  	usesection lDEBUG_DATA_ENTRY
  3303                                  .table:
  3304                                  	db 0
  3305                                  	db code2_seg - code_seg
  3306                                  
  3307                                  	hiddenusesection %$currentname
  3308                                  %endif
  3309                                  
  3310                                  
  3311                                  %ifn _DUALCODE && ! _PM && _DUALCODENEARDUAL
  3312                                  %$currentname %+ _to_ %+ %$othername %+ _nearcall_helper:
  3313                                  	push ax		; return_offset
  3314                                  	push ax		; placeholder
  3315                                  	push ax		; chain
  3316                                  	push ax		; chain
  3317                                  	lframe 0
  3318                                  	lpar word,	offset_segment
  3319                                  	lpar word,	return_offset	; far return
  3320                                  	lpar word,	placeholder	; near return
  3321                                  	lpar dword,	chain		; far target address
  3322                                  	lenter
  3323                                  	push bx
  3324                                  	mov bx, word [bp + ?offset_segment]
  3325                                  %if _DEBUG
  3326                                  	mov word [bp + ?return_offset], bx
  3327                                  	push word [cs:bx + 2]
  3328                                  %else
  3329                                  	push word [cs:bx]
  3330                                  	lea bx, [bx + 2]
  3331                                  	mov word [bp + ?return_offset], bx
  3332                                  %endif
  3333                                  	pop word [bp + ?chain]
  3334                                  
  3335                                  %if _PM
  3336                                  	mov bx, word [ss:pm_2_86m_0]
  3337                                  %if %$$othersegvar + 2 != %$$otherselvar
  3338                                   %error Expected sel variable after seg variable
  3339                                  %endif
  3340                                  	mov bx, word [ss:%$$othersegvar + bx]
  3341                                  %else
  3342                                  	mov bx, word [ss:%$$othersegvar]
  3343                                  %endif
  3344                                  	mov word [bp + ?chain + 2], bx
  3345                                  %if _PM
  3346                                  	mov word [bp + ?offset_segment], %$$currentindex
  3347                                  %else
  3348                                  	mov word [bp + ?offset_segment], cs
  3349                                  %endif
  3350                                  	mov word [bp + ?placeholder], %$$othername %+ _retf_from_dual
  3351                                  	pop bx
  3352                                  	lleave
  3353                                  	retf
  3354                                  
  3355                                  %$currentname %+ _retf_from_dual:
  3356                                  	dualreturn
  3357                                  	retf
  3358                                  %endif
  3359                                  
  3360                                  
  3361                                  %assign %$counter %$counter + 1
  3362                                  %endrep
  3204                              <1> 
  3205                              <1> %if %$counter == 0
  3206                              <1> %define %$currentindex 0
  3207                              <1> %define %$currentname lDEBUG_CODE
  3208                              <1> %define %$othername lDEBUG_CODE2
  3209                              <1> %define %$othersegvar code2_seg
  3210                              <1> %define %$otherselvar code2_sel
  3211                              <1> %else
  3212                              <1> %define %$currentindex 1
  3213                              <1> %define %$currentname lDEBUG_CODE2
  3214                              <1> %define %$othername lDEBUG_CODE
  3215                              <1> %define %$othersegvar code_seg
  3216                              <1> %define %$otherselvar code_sel
  3217                              <1> %endif
  3218                              <1> 
  3219                              <1>  hiddenusesection %$currentname
  3219          ------------------  <1>  note: usesection lDEBUG_CODE
  3220                              <1> %if _PM
  3221                              <1> %$currentname %+ _to_ %+ %$currentname %+ _dualcall_helper:
  3222 00000842 50                  <1>  push ax
  3223 00000843 50                  <1>  push ax
  3224                              <1>  lframe 0
  3225                              <1>  lpar word, offset_segment
  3226                              <1>  lpar word, placeholder
  3227                              <1>  lpar word, chain
  3228 00000844 5589E5              <1>  lenter
  3229 00000847 53                  <1>  push bx
  3230 00000848 8B5E06              <1>  mov bx, word [bp + ?offset_segment]
  3231                              <1> %if _DEBUG
  3232                              <1>  mov word [bp + ?placeholder], bx
  3233                              <1>  push word [cs:bx + 2]
  3234                              <1> %else
  3235 0000084B 2EFF37              <1>  push word [cs:bx]
  3236 0000084E 8D5F02              <1>  lea bx, [bx + 2]
  3237 00000851 895E04              <1>  mov word [bp + ?placeholder], bx
  3238                              <1> %endif
  3239 00000854 8F4602              <1>  pop word [bp + ?chain]
  3240 00000857 C746060000          <1>  mov word [bp + ?offset_segment], %$$currentindex
  3241 0000085C 5B                  <1>  pop bx
  3242 0000085D 5D                  <1>  lleave
  3243 0000085E C3                  <1>  retn
  3244                              <1> 
  3245                              <1> %$currentname %+ _to_ %+ %$othername %+ _dualcall_helper:
  3246 0000085F 50                  <1>  push ax
  3247 00000860 50                  <1>  push ax
  3248 00000861 50                  <1>  push ax
  3249                              <1>  lframe 0
  3250                              <1>  lpar word, offset_segment
  3251                              <1>  lpar word, placeholder
  3252                              <1>  lpar dword, chain
  3253 00000862 5589E5              <1>  lenter
  3254 00000865 53                  <1>  push bx
  3255 00000866 8B5E08              <1>  mov bx, word [bp + ?offset_segment]
  3256                              <1> %if _DEBUG
  3257                              <1>  mov word [bp + ?placeholder], bx
  3258                              <1>  push word [cs:bx + 2]
  3259                              <1> %else
  3260 00000869 2EFF37              <1>  push word [cs:bx]
  3261 0000086C 8D5F02              <1>  lea bx, [bx + 2]
  3262 0000086F 895E06              <1>  mov word [bp + ?placeholder], bx
  3263                              <1> %endif
  3264 00000872 8F4602              <1>  pop word [bp + ?chain]
  3265 00000875 368B1E[6202]        <1>  mov bx, word [ss:pm_2_86m_0]
  3266                              <1> %if %$$othersegvar + 2 != %$$otherselvar
  3267                              <1>  %error Expected sel variable after seg variable
  3268                              <1> %endif
  3269 0000087A 368B9F[2002]        <1>  mov bx, word [ss:%$$othersegvar + bx]
  3270 0000087F 895E04              <1>  mov word [bp + ?chain + 2], bx
  3271 00000882 C746080000          <1>  mov word [bp + ?offset_segment], %$$currentindex
  3272 00000887 5B                  <1>  pop bx
  3273 00000888 5D                  <1>  lleave
  3274 00000889 CB                  <1>  retf
  3275                              <1> 
  3276                              <1> 
  3277                              <1> %$currentname %+ _dualret_helper:
  3278                              <1>  lframe near
  3279                              <1>  lpar word, index_segment
  3280                              <1>  lpar word, offset
  3281                              <1>  lpar_return
  3282 0000088A 5589E5              <1>  lenter
  3283 0000088D 53                  <1>  push bx
  3284 0000088E 57                  <1>  push di
  3285                              <1> 
  3286                              <1> %if code_seg + 2 != code_sel
  3287                              <1>  %error Unexpected layout
  3288                              <1> %endif
  3289                              <1> %if code2_seg + 2 != code2_sel
  3290                              <1>  %error Unexpected layout
  3291                              <1> %endif
  3292 0000088F 8B5E06              <1>  mov bx, word [bp + ?index_segment]
  3293 00000892 368A9F[AC14]        <1>  mov bl, byte [ss:.table + bx]
  3294 00000897 368B3E[6202]        <1>  mov di, word [ss:pm_2_86m_0]
  3295 0000089C 368B99[1C02]        <1>  mov bx, word [ss:code_seg + bx + di]
  3296 000008A1 895E06              <1>  mov word [bp + ?index_segment], bx
  3297 000008A4 5F                  <1>  pop di
  3298 000008A5 5B                  <1>  pop bx
  3299 000008A6 5D                  <1>  lleave
  3300 000008A7 C3                  <1>  lret
  3301                              <1> 
  3302                              <1>  usesection lDEBUG_DATA_ENTRY
  3302          ------------------  <1>  note: usesection lDEBUG_DATA_ENTRY
  3303                              <1> .table:
  3304 000014AC 00                  <1>  db 0
  3305 000014AD 04                  <1>  db code2_seg - code_seg
  3306                              <1> 
  3307                              <1>  hiddenusesection %$currentname
  3307          ------------------  <1>  note: usesection lDEBUG_CODE
  3308                              <1> %endif
  3309                              <1> 
  3310                              <1> 
  3311                              <1> %ifn _DUALCODE && ! _PM && _DUALCODENEARDUAL
  3312                              <1> %$currentname %+ _to_ %+ %$othername %+ _nearcall_helper:
  3313 000008A8 50                  <1>  push ax
  3314 000008A9 50                  <1>  push ax
  3315 000008AA 50                  <1>  push ax
  3316 000008AB 50                  <1>  push ax
  3317                              <1>  lframe 0
  3318                              <1>  lpar word, offset_segment
  3319                              <1>  lpar word, return_offset
  3320                              <1>  lpar word, placeholder
  3321                              <1>  lpar dword, chain
  3322 000008AC 5589E5              <1>  lenter
  3323 000008AF 53                  <1>  push bx
  3324 000008B0 8B5E0A              <1>  mov bx, word [bp + ?offset_segment]
  3325                              <1> %if _DEBUG
  3326                              <1>  mov word [bp + ?return_offset], bx
  3327                              <1>  push word [cs:bx + 2]
  3328                              <1> %else
  3329 000008B3 2EFF37              <1>  push word [cs:bx]
  3330 000008B6 8D5F02              <1>  lea bx, [bx + 2]
  3331 000008B9 895E08              <1>  mov word [bp + ?return_offset], bx
  3332                              <1> %endif
  3333 000008BC 8F4602              <1>  pop word [bp + ?chain]
  3334                              <1> 
  3335                              <1> %if _PM
  3336 000008BF 368B1E[6202]        <1>  mov bx, word [ss:pm_2_86m_0]
  3337                              <1> %if %$$othersegvar + 2 != %$$otherselvar
  3338                              <1>  %error Expected sel variable after seg variable
  3339                              <1> %endif
  3340 000008C4 368B9F[2002]        <1>  mov bx, word [ss:%$$othersegvar + bx]
  3341                              <1> %else
  3342                              <1>  mov bx, word [ss:%$$othersegvar]
  3343                              <1> %endif
  3344 000008C9 895E04              <1>  mov word [bp + ?chain + 2], bx
  3345                              <1> %if _PM
  3346 000008CC C7460A0000          <1>  mov word [bp + ?offset_segment], %$$currentindex
  3347                              <1> %else
  3348                              <1>  mov word [bp + ?offset_segment], cs
  3349                              <1> %endif
  3350 000008D1 C74606[A400]        <1>  mov word [bp + ?placeholder], %$$othername %+ _retf_from_dual
  3351 000008D6 5B                  <1>  pop bx
  3352 000008D7 5D                  <1>  lleave
  3353 000008D8 CB                  <1>  retf
  3354                              <1> 
  3355                              <1> %$currentname %+ _retf_from_dual:
  3356 000008D9 E8AEFF              <1>  dualreturn
  3357 000008DC CB                  <1>  retf
  3358                              <1> %endif
  3359                              <1> 
  3360                              <1> 
  3361                              <1> %assign %$counter %$counter + 1
  3204                              <1> 
  3205                              <1> %if %$counter == 0
  3206                              <1> %define %$currentindex 0
  3207                              <1> %define %$currentname lDEBUG_CODE
  3208                              <1> %define %$othername lDEBUG_CODE2
  3209                              <1> %define %$othersegvar code2_seg
  3210                              <1> %define %$otherselvar code2_sel
  3211                              <1> %else
  3212                              <1> %define %$currentindex 1
  3213                              <1> %define %$currentname lDEBUG_CODE2
  3214                              <1> %define %$othername lDEBUG_CODE
  3215                              <1> %define %$othersegvar code_seg
  3216                              <1> %define %$otherselvar code_sel
  3217                              <1> %endif
  3218                              <1> 
  3219                              <1>  hiddenusesection %$currentname
  3219          ------------------  <1>  note: usesection lDEBUG_CODE2
  3220                              <1> %if _PM
  3221                              <1> %$currentname %+ _to_ %+ %$currentname %+ _dualcall_helper:
  3222 0000000D 50                  <1>  push ax
  3223 0000000E 50                  <1>  push ax
  3224                              <1>  lframe 0
  3225                              <1>  lpar word, offset_segment
  3226                              <1>  lpar word, placeholder
  3227                              <1>  lpar word, chain
  3228 0000000F 5589E5              <1>  lenter
  3229 00000012 53                  <1>  push bx
  3230 00000013 8B5E06              <1>  mov bx, word [bp + ?offset_segment]
  3231                              <1> %if _DEBUG
  3232                              <1>  mov word [bp + ?placeholder], bx
  3233                              <1>  push word [cs:bx + 2]
  3234                              <1> %else
  3235 00000016 2EFF37              <1>  push word [cs:bx]
  3236 00000019 8D5F02              <1>  lea bx, [bx + 2]
  3237 0000001C 895E04              <1>  mov word [bp + ?placeholder], bx
  3238                              <1> %endif
  3239 0000001F 8F4602              <1>  pop word [bp + ?chain]
  3240 00000022 C746060100          <1>  mov word [bp + ?offset_segment], %$$currentindex
  3241 00000027 5B                  <1>  pop bx
  3242 00000028 5D                  <1>  lleave
  3243 00000029 C3                  <1>  retn
  3244                              <1> 
  3245                              <1> %$currentname %+ _to_ %+ %$othername %+ _dualcall_helper:
  3246 0000002A 50                  <1>  push ax
  3247 0000002B 50                  <1>  push ax
  3248 0000002C 50                  <1>  push ax
  3249                              <1>  lframe 0
  3250                              <1>  lpar word, offset_segment
  3251                              <1>  lpar word, placeholder
  3252                              <1>  lpar dword, chain
  3253 0000002D 5589E5              <1>  lenter
  3254 00000030 53                  <1>  push bx
  3255 00000031 8B5E08              <1>  mov bx, word [bp + ?offset_segment]
  3256                              <1> %if _DEBUG
  3257                              <1>  mov word [bp + ?placeholder], bx
  3258                              <1>  push word [cs:bx + 2]
  3259                              <1> %else
  3260 00000034 2EFF37              <1>  push word [cs:bx]
  3261 00000037 8D5F02              <1>  lea bx, [bx + 2]
  3262 0000003A 895E06              <1>  mov word [bp + ?placeholder], bx
  3263                              <1> %endif
  3264 0000003D 8F4602              <1>  pop word [bp + ?chain]
  3265 00000040 368B1E[6202]        <1>  mov bx, word [ss:pm_2_86m_0]
  3266                              <1> %if %$$othersegvar + 2 != %$$otherselvar
  3267                              <1>  %error Expected sel variable after seg variable
  3268                              <1> %endif
  3269 00000045 368B9F[1C02]        <1>  mov bx, word [ss:%$$othersegvar + bx]
  3270 0000004A 895E04              <1>  mov word [bp + ?chain + 2], bx
  3271 0000004D C746080100          <1>  mov word [bp + ?offset_segment], %$$currentindex
  3272 00000052 5B                  <1>  pop bx
  3273 00000053 5D                  <1>  lleave
  3274 00000054 CB                  <1>  retf
  3275                              <1> 
  3276                              <1> 
  3277                              <1> %$currentname %+ _dualret_helper:
  3278                              <1>  lframe near
  3279                              <1>  lpar word, index_segment
  3280                              <1>  lpar word, offset
  3281                              <1>  lpar_return
  3282 00000055 5589E5              <1>  lenter
  3283 00000058 53                  <1>  push bx
  3284 00000059 57                  <1>  push di
  3285                              <1> 
  3286                              <1> %if code_seg + 2 != code_sel
  3287                              <1>  %error Unexpected layout
  3288                              <1> %endif
  3289                              <1> %if code2_seg + 2 != code2_sel
  3290                              <1>  %error Unexpected layout
  3291                              <1> %endif
  3292 0000005A 8B5E06              <1>  mov bx, word [bp + ?index_segment]
  3293 0000005D 368A9F[AE14]        <1>  mov bl, byte [ss:.table + bx]
  3294 00000062 368B3E[6202]        <1>  mov di, word [ss:pm_2_86m_0]
  3295 00000067 368B99[1C02]        <1>  mov bx, word [ss:code_seg + bx + di]
  3296 0000006C 895E06              <1>  mov word [bp + ?index_segment], bx
  3297 0000006F 5F                  <1>  pop di
  3298 00000070 5B                  <1>  pop bx
  3299 00000071 5D                  <1>  lleave
  3300 00000072 C3                  <1>  lret
  3301                              <1> 
  3302                              <1>  usesection lDEBUG_DATA_ENTRY
  3302          ------------------  <1>  note: usesection lDEBUG_DATA_ENTRY
  3303                              <1> .table:
  3304 000014AE 00                  <1>  db 0
  3305 000014AF 04                  <1>  db code2_seg - code_seg
  3306                              <1> 
  3307                              <1>  hiddenusesection %$currentname
  3307          ------------------  <1>  note: usesection lDEBUG_CODE2
  3308                              <1> %endif
  3309                              <1> 
  3310                              <1> 
  3311                              <1> %ifn _DUALCODE && ! _PM && _DUALCODENEARDUAL
  3312                              <1> %$currentname %+ _to_ %+ %$othername %+ _nearcall_helper:
  3313 00000073 50                  <1>  push ax
  3314 00000074 50                  <1>  push ax
  3315 00000075 50                  <1>  push ax
  3316 00000076 50                  <1>  push ax
  3317                              <1>  lframe 0
  3318                              <1>  lpar word, offset_segment
  3319                              <1>  lpar word, return_offset
  3320                              <1>  lpar word, placeholder
  3321                              <1>  lpar dword, chain
  3322 00000077 5589E5              <1>  lenter
  3323 0000007A 53                  <1>  push bx
  3324 0000007B 8B5E0A              <1>  mov bx, word [bp + ?offset_segment]
  3325                              <1> %if _DEBUG
  3326                              <1>  mov word [bp + ?return_offset], bx
  3327                              <1>  push word [cs:bx + 2]
  3328                              <1> %else
  3329 0000007E 2EFF37              <1>  push word [cs:bx]
  3330 00000081 8D5F02              <1>  lea bx, [bx + 2]
  3331 00000084 895E08              <1>  mov word [bp + ?return_offset], bx
  3332                              <1> %endif
  3333 00000087 8F4602              <1>  pop word [bp + ?chain]
  3334                              <1> 
  3335                              <1> %if _PM
  3336 0000008A 368B1E[6202]        <1>  mov bx, word [ss:pm_2_86m_0]
  3337                              <1> %if %$$othersegvar + 2 != %$$otherselvar
  3338                              <1>  %error Expected sel variable after seg variable
  3339                              <1> %endif
  3340 0000008F 368B9F[1C02]        <1>  mov bx, word [ss:%$$othersegvar + bx]
  3341                              <1> %else
  3342                              <1>  mov bx, word [ss:%$$othersegvar]
  3343                              <1> %endif
  3344 00000094 895E04              <1>  mov word [bp + ?chain + 2], bx
  3345                              <1> %if _PM
  3346 00000097 C7460A0100          <1>  mov word [bp + ?offset_segment], %$$currentindex
  3347                              <1> %else
  3348                              <1>  mov word [bp + ?offset_segment], cs
  3349                              <1> %endif
  3350 0000009C C74606[D908]        <1>  mov word [bp + ?placeholder], %$$othername %+ _retf_from_dual
  3351 000000A1 5B                  <1>  pop bx
  3352 000000A2 5D                  <1>  lleave
  3353 000000A3 CB                  <1>  retf
  3354                              <1> 
  3355                              <1> %$currentname %+ _retf_from_dual:
  3356 000000A4 E8AEFF              <1>  dualreturn
  3357 000000A7 CB                  <1>  retf
  3358                              <1> %endif
  3359                              <1> 
  3360                              <1> 
  3361                              <1> %assign %$counter %$counter + 1
  3363                                  %pop
  3364                                  %endif
  3365                                  
  3366                                  
  3367                                  	usesection lDEBUG_CODE
  3367          ------------------       note: usesection lDEBUG_CODE
  3368                                  
  3369                                  %if _SYMBOLIC
  3370                                   %ifn _LINK || _LINK_COMPAT
  3371                                  %include "symbols.asm"
  3372                                   %endif
  3373                                  %else
  3374                                  
  3375                                  %if _PM
  3376                                  
  3377                                  
  3378                                  	hiddenusesection SECTION_OF_ %+ selector_to_segment
  3378          ------------------       note: usesection lDEBUG_CODE
  3379                                  
  3380                                  	; For branches other than symbolic, here's selector_to_segment
  3381                                  	;  (as used by the puts in lineio.asm). Picked from symsnip
  3382                                  	;  binsrch.asm at revision 9c232415d568.
  3383                                  		; INP:	word [ss:sp] = selector to access
  3384                                  		; OUT:	word [ss:sp] = segment value to use for access
  3385                                  		; CHG:	-
  3386                                  dualfunction
  3387                                  selector_to_segment: section_of_function
  3388                                  	lframe dualdistance
  3389                                  	lpar word,	in_selector_out_segment
  3390                                  	lpar_return
  3391 000008DD 5589E5                  	lenter
  3392                                  
  3393 000008E0 E8BA00                  	call _CURRENT_SECTION %+ _ispm
  3394                                  				; is it PM ?
  3395 000008E3 751B                    	jnz .ret		; no, 86M --> (selector == segment)
  3396                                  
  3397                                  subcpu 286
  3398 000008E5 50                      	push ax
  3399 000008E6 53                      	push bx
  3400 000008E7 51                      	push cx
  3401 000008E8 52                      	push dx
  3402                                  
  3403 000008E9 8B5E06                  	mov bx, word [bp + ?in_selector_out_segment]
  3404 000008EC B80600                  	mov ax, 6
  3405 000008EF CD31                    	int 31h			; get segment base to cx:dx
  3406 000008F1 C1EA04                  	shr dx, 4
  3407 000008F4 C1E10C                  	shl cx, 12
  3408 000008F7 09CA                    	or dx, cx
  3409 000008F9 895606                  	mov word [bp + ?in_selector_out_segment], dx
  3410                                  
  3411 000008FC 5A                      	pop dx
  3412 000008FD 59                      	pop cx
  3413 000008FE 5B                      	pop bx
  3414 000008FF 58                      	pop ax
  3415                                  subcpureset
  3416                                  
  3417                                  .ret:
  3418 00000900 5D                      	lleave
  3419 00000901 E886FF                  	dualreturn
  3420 00000904 CB                      	lret
  3421                                  %endif
  3422                                  
  3423                                  %endif
  3424                                  
  3425                                  
  3426                                  	; support functions for symbols.asm
  3427                                  	usesection lDEBUG_CODE
  3427          ------------------       note: usesection lDEBUG_CODE
  3428                                  %if _PM
  3429                                  dualfunction
  3430                                  push_cxdx_or_edx: section_of_function
  3431                                  	lframe dualdistance
  3432                                  	lpar dword, return
  3433                                  	lpar_return
  3434 00000905 5589E5                  	lenter
  3435 00000908 51                      _no386	push cx
  3436 00000909 66                      	_386_o32
  3437 0000090A 52                      	push dx
  3438 0000090B 8F4606                  	pop word [bp + ?return]
  3439 0000090E 8F4608                  	pop word [bp + ?return + 2]
  3440 00000911 5D                      	lleave
  3441 00000912 E875FF                  	dualreturn
  3442 00000915 CB                      	lret
  3443                                  %endif
  3444                                  
  3445                                  		; INP:	ds:dx -> message
  3446                                  		;	cx = length
  3447                                  		; CHG:	-
  3448                                  		; STT:	ds, es don't care
  3449                                  disp_message_length_cx: section_of_function
  3450 00000916 50                      	push ax
  3451 00000917 53                      	push bx
  3452 00000918 51                      	push cx
  3453 00000919 52                      	push dx
  3454 0000091A 06                      	push es
  3455 0000091B 1E                      	push ds
  3456 0000091C 1E                      	 push ds
  3457 0000091D 07                      	 pop es			; es:dx -> message, cx = length
  3458 0000091E 16                      	 push ss
  3459 0000091F 1F                      	 pop ds			; ds = ss (required for puts)
  3460 00000920 E8(0000)                	call puts
  3461 00000923 1F                      	pop ds
  3462 00000924 07                      	pop es
  3463 00000925 5A                      	pop dx
  3464 00000926 59                      	pop cx
  3465 00000927 5B                      	pop bx
  3466 00000928 58                      	pop ax
  3467 00000929 C3                      	retn
  3468                                  
  3469                                  		; INP:	ds:dx -> message, ASCIZ
  3470                                  		; CHG:	-
  3471                                  		; STT:	ds, es don't care
  3472                                  disp_message: section_of_function
  3473 0000092A 06                      	push es
  3474 0000092B 1E                      	 push ds
  3475 0000092C 07                      	 pop es			; es:dx -> message
  3476 0000092D E8(0000)                	call putsz		; (sets up ds = ss internally)
  3477 00000930 07                      	pop es
  3478 00000931 C3                      	retn
  3479                                  
  3480                                  		; INP:	al = character to display
  3481                                  		; CHG:	-
  3482                                  		; STT:	ds, es don't care
  3483                                  %ifn _LINK
  3484                                  disp_al: equ putc
  3485                                  %endif
  3486                                  
  3487                                  
  3488                                  		; Display number in ax hexadecimal, always 4 digits
  3489                                  		;
  3490                                  		; INP:	ax = number
  3491                                  		; OUT:	displayed using disp_al
  3492                                  		; CHG:	none
  3493                                  disp_ax_hex: section_of_function
  3494 00000932 86C4                    	xchg al, ah
  3495 00000934 E80200                  	nearcall disp_al_hex
  3496 00000937 86C4                    	xchg al, ah
  3497                                  disp_al_hex: section_of_function
  3498 00000939 51                      	push cx
  3499 0000093A B104                    	mov cl, 4
  3500 0000093C D2C0                    	rol al, cl
  3501 0000093E E80300                  	nearcall disp_al_nybble_hex
  3502 00000941 D2C0                    	rol al, cl
  3503 00000943 59                      	pop cx
  3504                                  disp_al_nybble_hex: section_of_function
  3505 00000944 50                      	push ax
  3506 00000945 240F                    	and al, 0Fh
  3507 00000947 0430                    	add al, '0'
  3508 00000949 3C39                    	cmp al, '9'
  3509 0000094B 7602                    	jbe @F
  3510 0000094D 0407                    	add al, -'9' -1 +'A'
  3511                                  @@:
  3512 0000094F E8(0000)                	nearcall disp_al
  3513 00000952 58                      	pop ax
  3514 00000953 C3                      	retn
  3515                                  
  3516                                  
  3517                                  		; Display number in ax decimal
  3518                                  		;
  3519                                  		; INP:	ax = number
  3520                                  		; OUT:	displayed using disp_al
  3521                                  		; CHG:	none
  3522                                  disp_ax_dec: section_of_function			; ax (no leading zeros)
  3523 00000954 53                      		push bx
  3524 00000955 31DB                    		xor bx, bx
  3525                                  .pushax:
  3526 00000957 52                      		push dx
  3527 00000958 50                      		push ax
  3528 00000959 08DB                    		or bl, bl
  3529 0000095B 7405                    		jz .nobl
  3530 0000095D 80EB05                  		sub bl, 5
  3531 00000960 F6DB                    		neg bl
  3532                                  .nobl:
  3533 00000962 51                      		push cx
  3534 00000963 B91027                  		mov cx, 10000
  3535 00000966 E81B00                  		call .divide_out
  3536 00000969 B9E803                  		mov cx, 1000
  3537 0000096C E81500                  		call .divide_out
  3538 0000096F B96400                  		mov cx, 100
  3539 00000972 E80F00                  		call .divide_out
  3540 00000975 B10A                    		mov cl, 10
  3541 00000977 E80A00                  		call .divide_out
  3542                                  							; (Divisor 1 is useless)
  3543 0000097A 0430                    		add al, '0'
  3544 0000097C E8(0000)                		nearcall disp_al
  3545 0000097F 59                      		pop cx
  3546 00000980 58                      		pop ax
  3547 00000981 5A                      		pop dx
  3548 00000982 5B                      		pop bx					; Caller's register
  3549 00000983 C3                      		retn
  3550                                  
  3551                                  
  3552                                  		; INP:	ax = number
  3553                                  		;	cx = divisor
  3554                                  		; OUT:	ax = remainder of operation
  3555                                  		;	result displayed
  3556                                  .divide_out:
  3557 00000984 52                      		push dx
  3558 00000985 31D2                    		xor dx, dx
  3559 00000987 F7F1                    		div cx				; 0:ax / cx
  3560 00000989 52                      		push dx				; remainder
  3561 0000098A FECB                    		dec bl
  3562 0000098C 7503                    		jnz .nobl2
  3563 0000098E 80CF01                  		or bh, 1
  3564                                  .nobl2:
  3565 00000991 08C7                    		or bh, al
  3566 00000993 7405                    		jz .leadingzero
  3567 00000995 0430                    		add al, '0'
  3568 00000997 E8(0000)                		nearcall disp_al			; display result
  3569                                   .leadingzero:
  3570 0000099A 58                      		pop ax				; remainder
  3571 0000099B 5A                      		pop dx
  3572 0000099C C3                      		retn
  3573                                  
  3574                                  
  3575                                   %ifn _LINK || _LINK_COMPAT
  3576                                  %if !_LOADER
  3577                                  %include "cc.asm"
  3578                                  %endif
  3579                                  
  3580                                  
  3581                                  %include "bb.asm"
  3582                                  
  3583                                  
  3584                                  %include "ee.asm"
  3585                                  
  3586                                  
  3587                                  %include "ff.asm"
  3588                                  
  3589                                  
  3590                                  %include "hh.asm"
  3591                                  
  3592                                  
  3593                                  %include "iioo.asm"
  3594                                   %endif
  3595                                  
  3596                                  
  3597                                  	usesection lDEBUG_CODE
  3597          ------------------       note: usesection lDEBUG_CODE
  3598                                  
  3599                                  %if _PM == 0 && _ELDLINKINFO
  3600                                  ispm: section_of_function
  3601                                  	test sp, sp			; NZ, NC
  3602                                  	retn
  3603                                  
  3604                                  test_d_b_bit: section_of_function
  3605                                  test_high_limit: section_of_function
  3606                                  	cmp al, al			; ZR, NC
  3607                                  	retn
  3608                                  
  3609                                  setes2dx: section_of_function
  3610                                  	mov es, dx
  3611                                  	retn
  3612                                  
  3613                                  call_int2D: section_of_function
  3614                                  	int 2Dh
  3615                                  	retn
  3616                                  
  3617                                  _doscall: section_of_function
  3618                                  doscall_extseg: section_of_function
  3619                                  	int 21h
  3620                                  	retn
  3621                                  
  3622                                  	usesection lDEBUG_DATA_ENTRY
  3623                                  dpmi32:		db 0
  3624                                  
  3625                                  	usesection lDEBUG_CODE
  3626                                  %endif
  3627                                  
  3628                                  %if _PM
  3629                                  
  3630                                  %if _DUALCODE
  3631                                   %assign REPEAT 2
  3632                                  %else
  3633                                   %assign REPEAT 1
  3634                                  %endif
  3635                                  
  3636                                  	usesection lDEBUG_CODE
  3636          ------------------       note: usesection lDEBUG_CODE
  3637                                  %rep REPEAT
  3638                                  		; OUT:	NC
  3639                                  		;	ZR if in protected mode
  3640                                  		;	NZ otherwise
  3641                                  		; STT:	-
  3642                                  		;	([internalflags] & nodosloaded, [internalflags] & protectedmode set up)
  3643                                  _CURRENT_SECTION %+ _ispm:
  3644                                  	push ax
  3645                                  %if protectedmode & ~0FF00h
  3646                                   %error Internal flags re-ordered, adjust code here
  3647                                  %endif
  3648                                  	mov al, byte [ss:internalflags+1]	; get flag byte
  3649                                  	and al, protectedmode>>8		; separate PM flag
  3650                                  	xor al, protectedmode>>8		; ZR if in PM (NC)
  3651                                  	pop ax
  3652                                  	retn
  3653                                  
  3654                                  	usesection lDEBUG_CODE2
  3655                                  %endrep
  3638                              <1> 
  3639                              <1> 
  3640                              <1> 
  3641                              <1> 
  3642                              <1> 
  3643                              <1> _CURRENT_SECTION %+ _ispm:
  3644 0000099D 50                  <1>  push ax
  3645                              <1> %if protectedmode & ~0FF00h
  3646                              <1>  %error Internal flags re-ordered, adjust code here
  3647                              <1> %endif
  3648 0000099E 36A0[D901]          <1>  mov al, byte [ss:internalflags+1]
  3649 000009A2 2408                <1>  and al, protectedmode>>8
  3650 000009A4 3408                <1>  xor al, protectedmode>>8
  3651 000009A6 58                  <1>  pop ax
  3652 000009A7 C3                  <1>  retn
  3653                              <1> 
  3654                              <1>  usesection lDEBUG_CODE2
  3654          ------------------  <1>  note: usesection lDEBUG_CODE2
  3638                              <1> 
  3639                              <1> 
  3640                              <1> 
  3641                              <1> 
  3642                              <1> 
  3643                              <1> _CURRENT_SECTION %+ _ispm:
  3644 000000A8 50                  <1>  push ax
  3645                              <1> %if protectedmode & ~0FF00h
  3646                              <1>  %error Internal flags re-ordered, adjust code here
  3647                              <1> %endif
  3648 000000A9 36A0[D901]          <1>  mov al, byte [ss:internalflags+1]
  3649 000000AD 2408                <1>  and al, protectedmode>>8
  3650 000000AF 3408                <1>  xor al, protectedmode>>8
  3651 000000B1 58                  <1>  pop ax
  3652 000000B2 C3                  <1>  retn
  3653                              <1> 
  3654                              <1>  usesection lDEBUG_CODE2
  3654          ------------------  <1>  note: usesection lDEBUG_CODE2
  3656                                  	usesection lDEBUG_CODE
  3656          ------------------       note: usesection lDEBUG_CODE
  3657                                  ispm equ _CURRENT_SECTION %+ _ispm
  3658                                  check_section_of ispm
  3659                                  
  3660                                  %endif
  3661                                  
  3662                                  
  3663                                  setpspdbg:
  3664                                  %if _PM
  3665 000009A8 8B1E[760C]              	mov bx, word [pspdbg]
  3666                                  %else
  3667                                  	mov bx, ss		; = word [pspdbg] (if _PM=0 or in 86M)
  3668                                  %endif
  3669                                  
  3670                                  setpsp:
  3671                                  %if _APPLICATION || _DEVICE
  3672                                  %if _BOOTLDR
  3673 000009AC F606[D901]40            	testopt [internalflags], nodosloaded
  3674 000009B1 7403E99D00              	jnz .ret		; no PSPs -->
  3675                                  %endif
  3676                                  
  3677                                  %if _USESDA
  3678 000009B6 833E[AA0C]FF            	cmp word [pSDA+0], byte -1
  3679 000009BB 7411                    	je .int21
  3680                                  
  3681                                  .86m:
  3682 000009BD 1E                      	push ds
  3683 000009BE 56                      	push si
  3684 000009BF BE[AC0C]                	mov si, pSDA + so16aSegSel
  3685 000009C2 E8A30E                  	call update_dosdata_segment
  3686 000009C5 C574FE                  	lds si, [si - so16aSegSel]
  3687 000009C8 895C10                  	mov word [si+10h], bx	; set PSP segment
  3688 000009CB 5E                      	pop si
  3689 000009CC 1F                      	pop ds
  3690 000009CD C3                      	retn
  3691                                  
  3692                                  .int21:
  3693                                  %endif
  3694 000009CE B450                    	mov ah, 50h
  3695                                   %if _PM
  3696 000009D0 E8CAFF                  	call ispm
  3697 000009D3 7503                    	jnz .int21_86m
  3698                                    %if _NOEXTENDER
  3699 000009D5 E95BFE                  	jmp _doscall.pm		; insure non-extended (set to bx = PSP segment)
  3700                                    %else
  3701                                  	mov ax, 0002h
  3702                                  	int 31h			; segment to selector
  3703                                  	xchg bx, ax		; bx = selector
  3704                                  	mov ah, 50h		; reset to function number
  3705                                    %endif
  3706                                  .int21_86m:
  3707                                   %endif
  3708 000009D8 EB6D                    	jmp _int21
  3709                                  %else
  3710                                  	retn
  3711                                  %endif
  3712                                  
  3713                                  
  3714                                  getpsp:
  3715                                  %if _APPLICATION || _DEVICE
  3716                                  %if _BOOTLDR
  3717 000009DA 31DB                    	xor bx, bx		; = placeholder value if no PSPs
  3718 000009DC F606[D901]40            	testopt [internalflags], nodosloaded
  3719 000009E1 7570                    	jnz .ret		; no PSPs -->
  3720                                  %endif
  3721                                  %if _USESDA
  3722 000009E3 833E[AA0C]FF            	cmp word [pSDA+0], byte -1
  3723 000009E8 7411                    	je .int21
  3724 000009EA 1E                      	push ds
  3725 000009EB 56                      	push si
  3726 000009EC BE[AC0C]                	mov si, pSDA + so16aSegSel
  3727 000009EF E8760E                  	call update_dosdata_segment
  3728 000009F2 C574FE                  	lds si, [si - so16aSegSel]
  3729 000009F5 8B5C10                  	mov bx, word [si + 10h]	; bx = PSP segment
  3730 000009F8 5E                      	pop si
  3731 000009F9 1F                      	pop ds
  3732 000009FA C3                      	retn
  3733                                  
  3734                                  .int21:
  3735                                  %endif
  3736 000009FB B451                    	mov ah, 51h
  3737                                   %if _PM
  3738 000009FD E89DFF                  	call ispm
  3739 00000A00 7503                    	jnz .int21_86m
  3740                                    %if _NOEXTENDER
  3741 00000A02 E92EFE                  	jmp _doscall.pm		; insure non-extended (bx = PSP segment)
  3742                                    %else
  3743                                  	call _int21		; get PSP as a selector
  3744                                  	push bx
  3745                                  	dualcall selector_to_segment
  3746                                  	pop bx			; bx = PSP segment
  3747                                  	retn
  3748                                    %endif
  3749                                  .int21_86m:
  3750                                   %endif
  3751 00000A05 EB40                    	jmp _int21		; in 86 Mode call DOS the normal way
  3752                                  %else
  3753                                  	xor bx, bx		; = placeholder value if no PSPs
  3754                                  	retn
  3755                                  %endif
  3756                                  
  3757                                  
  3758                                  dual2function
  3759                                  _doscall_return_es: section_of_function
  3760                                  _doscall_return_es_parameter_es_ds: section_of_function
  3761                                  	lframe dual2distance
  3762                                  	lpar word, es_ds_value
  3763                                  	lpar_return
  3764                                  %if _PM
  3765                                  	lvar word, int_number
  3766 00000A07 5589E550                	lenter
  3767 00000A0B C746FE2100              	mov word [bp + ?int_number], 21h
  3768 00000A10 57                      	push di
  3769 00000A11 368B3E[6202]            	mov di, word [ss:pm_2_86m_0]
  3770 00000A16 36FFA5[B014]            	jmp near word [ss:.table + di]
  3771                                  
  3772                                  	usesection lDEBUG_DATA_ENTRY
  3772          ------------------       note: usesection lDEBUG_DATA_ENTRY
  3773                                  		; REM:	Dispatch table in section lDEBUG_CODE
  3774                                  	align 2, db 0
  3775                                  .table:
  3776 000014B0 [330A]                  	dw .86m
  3777 000014B2 [1B0A]                  	dw .pm
  3778                                  
  3779                                  	usesection lDEBUG_CODE
  3779          ------------------       note: usesection lDEBUG_CODE
  3780                                  .pm:
  3781 00000A1B 5F                      	pop di
  3782 00000A1C FF7604                  	push word [bp + ?es_ds_value]
  3783 00000A1F FF7604                  	push word [bp + ?es_ds_value]
  3784 00000A22 FF76FE                  	push word [bp + ?int_number]
  3785 00000A25 FF7600                  	push word [bp + ?frame_bp]
  3786 00000A28 E82F00                  	call intcall_return_parameter_es_parameter_ds
  3787 00000A2B 8F4604                  	pop word [bp + ?es_ds_value]		; discard returned ds
  3788 00000A2E 8F4604                  	pop word [bp + ?es_ds_value]		; get es
  3789 00000A31 EB10                    	jmp .ret
  3790                                  .86m:
  3791 00000A33 5F                      	pop di
  3792                                  %else
  3793                                  	lenter
  3794                                  %endif
  3795 00000A34 06                      	 push es
  3796 00000A35 1E                      	 push ds
  3797 00000A36 8E5E04                  	mov ds, word [bp + ?es_ds_value]
  3798 00000A39 8E4604                  	mov es, word [bp + ?es_ds_value]
  3799 00000A3C CD21                    	int 21h
  3800 00000A3E 8C4604                  	mov word [bp + ?es_ds_value], es
  3801 00000A41 1F                      	 pop ds
  3802 00000A42 07                      	 pop es
  3803                                  .ret:
  3804 00000A43 89EC5D                  	lleave
  3805                                  	dual2return
  3806 00000A46 C3                      	lret
  3807                                  
  3808                                  
  3809                                  		; Execute real Int21 instruction. If this is in PM it might get extended.
  3810                                  _int21:
  3811                                  %if _APPLICATION || _DEVICE
  3812                                  %if _BOOTLDR
  3813 00000A47 9C                      	pushf
  3814 00000A48 36F606[D901]40          	testopt [ss:internalflags], nodosloaded
  3815 00000A4E 7504                    	jnz .reterr		; no Int21 --> (throw?)
  3816 00000A50 9D                      	popf
  3817                                  %endif
  3818 00000A51 CD21                    	int 21h
  3819                                  setpsp.ret: equ $
  3820                                  getpsp.ret: equ $
  3821 00000A53 C3                      	retn
  3822                                  %if _BOOTLDR
  3823                                  .reterr:
  3824 00000A54 9D                      	popf
  3825 00000A55 B80100                  	mov ax, 1
  3826 00000A58 F9                      	stc
  3827 00000A59 C3                      	retn
  3828                                  %endif
  3829                                  %else
  3830                                  	mov ax, 1
  3831                                  	stc
  3832                                  	retn
  3833                                  %endif
  3834                                  
  3835                                  
  3836                                  %if _PM
  3837                                  intcall_return_parameter_es_parameter_ds:
  3838                                  	lframe near
  3839                                  	lpar word, es_value
  3840                                  	lpar word, ds_value
  3841                                  	lpar_return
  3842                                  	lpar word, int_number
  3843                                  	lpar word, bp_value
  3844                                  	lvar 32h, 86m_call_struc
  3845 00000A5A 5589E58D66CE            	lenter
  3846 00000A60 06                      	push es
  3847 00000A61 897ECE                  	mov word [bp + ?86m_call_struc +00h], di	; edi
  3848 00000A64 8976D2                  	mov word [bp + ?86m_call_struc +04h], si	; esi
  3849 00000A67 895EDE                  	mov word [bp + ?86m_call_struc +10h], bx	; ebx
  3850 00000A6A 8956E2                  	mov word [bp + ?86m_call_struc +14h], dx	; edx
  3851 00000A6D 894EE6                  	mov word [bp + ?86m_call_struc +18h], cx	; ecx
  3852 00000A70 8946EA                  	mov word [bp + ?86m_call_struc +1Ch], ax	; eax
  3853 00000A73 8B4604                  	mov ax, word [bp + ?bp_value]
  3854 00000A76 8946D6                  	mov word [bp + ?86m_call_struc +08h], ax	; bp
  3855 00000A79 B000                    	mov al, 0					; (preserve flags!)
  3856 00000A7B 9F                      	lahf
  3857 00000A7C 86C4                    	xchg al, ah
  3858 00000A7E 8946EE                  	mov word [bp + ?86m_call_struc +20h], ax	; flags
  3859 00000A81 31C0                    	xor ax, ax
  3860 00000A83 8946DC                  	mov word [bp + ?86m_call_struc +0Ch + 2], ax
  3861 00000A86 8946DA                  	mov word [bp + ?86m_call_struc +0Ch], ax
  3862 00000A89 8946FC                  	mov word [bp + ?86m_call_struc +2Eh], ax	; sp
  3863 00000A8C 8946FE                  	mov word [bp + ?86m_call_struc +30h], ax	; ss
  3864 00000A8F 8B460A                  	mov ax, word [bp + ?es_value]			; usually [pspdbg]
  3865 00000A92 8946F0                  	mov word [bp + ?86m_call_struc +22h], ax	; es
  3866 00000A95 8B4608                  	mov ax, word [bp + ?ds_value]			; usually [pspdbg]
  3867 00000A98 8946F2                  	mov word [bp + ?86m_call_struc +24h], ax	; ds
  3868 00000A9B 16                      	push ss
  3869 00000A9C 07                      	pop es				; => stack
  3870 00000A9D 8D7ECE                  	lea di, [bp + ?86m_call_struc]	; -> 86-Mode call structure
  3871 00000AA0 660FB7FF                _386	movzx edi, di			; (previously checked b[dpmi32] here)
  3872 00000AA4 8B5E06                  	mov bx, word [bp + ?int_number]			; int#
  3873 00000AA7 31C9                    	xor cx, cx
  3874 00000AA9 B80003                  	mov ax, 0300h
  3875 00000AAC CD31                    	int 31h
  3876 00000AAE 8A66EE                  	mov ah, byte [bp + ?86m_call_struc +20h]	; flags
  3877 00000AB1 9E                      	sahf
  3878 00000AB2 8B7ECE                  	mov di, word [bp + ?86m_call_struc +00h]	; edi
  3879 00000AB5 8B76D2                  	mov si, word [bp + ?86m_call_struc +04h]	; esi
  3880 00000AB8 8B5EDE                  	mov bx, word [bp + ?86m_call_struc +10h]	; ebx
  3881 00000ABB 8B56E2                  	mov dx, word [bp + ?86m_call_struc +14h]	; edx
  3882 00000ABE 8B4EE6                  	mov cx, word [bp + ?86m_call_struc +18h]	; ecx
  3883 00000AC1 8B46EA                  	mov ax, word [bp + ?86m_call_struc +1Ch]	; eax
  3884 00000AC4 FF76F0                  	push word [bp + ?86m_call_struc +22h]		; return es value
  3885 00000AC7 8F460A                  	pop word [bp + ?es_value]			;  in the parameter
  3886 00000ACA FF76F2                  	push word [bp + ?86m_call_struc +24h]		; return ds value
  3887 00000ACD 8F4608                  	pop word [bp + ?ds_value]			;  in the parameter
  3888 00000AD0 07                      	pop es
  3889 00000AD1 89EC5D                  	lleave
  3890 00000AD4 C20400                  	lret
  3891                                  
  3892                                  intcall:
  3893                                  	lframe near
  3894                                  	lpar word, es_ds_value
  3895                                  	lpar word, int_number
  3896 00000AD7 5589E5                  	lenter
  3897 00000ADA FF7606                  	push word [bp + ?es_ds_value]			; es
  3898 00000ADD FF7606                  	push word [bp + ?es_ds_value]			; ds
  3899 00000AE0 FF7604                  	push word [bp + ?int_number]			; int number
  3900 00000AE3 FF7600                  	push word [bp + ?frame_bp]			; bp
  3901 00000AE6 E871FF                  	call intcall_return_parameter_es_parameter_ds
  3902                                  		; (discard returned parameters ?es_value, ?ds_value, done by lleave)
  3903 00000AE9 89EC5D                  	lleave , forcerestoresp
  3904 00000AEC C20400                  	lret
  3905                                  
  3906                                  
  3907                                  %if _EXTENSIONS
  3908                                  intcall_ext_return_es: section_of_function
  3909                                  	lframe 6
  3910                                  	lpar word, es_ds_value
  3911                                  	lpar word, int_number
  3912                                  	lpar_return
  3913 00000AEF 5589E5                  	lenter
  3914 00000AF2 FF760A                  	push word [bp + ?es_ds_value]			; es
  3915 00000AF5 FF760A                  	push word [bp + ?es_ds_value]			; ds
  3916 00000AF8 FF7608                  	push word [bp + ?int_number]			; int number
  3917 00000AFB FF7600                  	push word [bp + ?frame_bp]			; bp
  3918 00000AFE E859FF                  	call intcall_return_parameter_es_parameter_ds
  3919 00000B01 8F460A                  	pop word [bp + ?es_ds_value]			; discard ds
  3920 00000B04 8F460A                  	pop word [bp + ?es_ds_value]			; return es
  3921 00000B07 5D                      	lleave , optimiserestoresp
  3922 00000B08 C3                      	retn
  3923                                  
  3924                                  
  3925                                  doscall_extseg: section_of_function
  3926 00000B09 9C                      	pushf
  3927 00000B0A E890FE                  	call ispm
  3928 00000B0D 750C                    	jnz .rm
  3929                                  subcpu 286
  3930 00000B0F 9D                      	popf
  3931                                  .pm:
  3932 00000B10 36FF36[2C02]            	push word [ss:extseg]
  3933 00000B15 6A21                    	push 21h
  3934 00000B17 E8BDFF                  	call intcall
  3935 00000B1A C3                      	retn
  3936                                  subcpureset
  3937                                  .rm:
  3938 00000B1B 9D                      	popf
  3939 00000B1C E928FF                  	jmp _int21
  3940                                  %endif
  3941                                  
  3942                                  call_int2D: section_of_function
  3943 00000B1F E87BFE                  	call ispm
  3944 00000B22 750B                    	jnz short .rm
  3945                                  subcpu 286
  3946 00000B24 36FF36[760C]            	push word [ss:pspdbg]	; es ds value. generally unused
  3947 00000B29 6A2D                    	push 2Dh		; interrupt 2Dh
  3948 00000B2B E8A9FF                  	call intcall		; call it
  3949 00000B2E C3                      	retn
  3950                                  subcpureset
  3951                                  .rm:
  3952 00000B2F CD2D                    	int 2Dh			; directly call int 2Dh
  3953 00000B31 C3                      	retn
  3954                                  
  3955                                  
  3956                                  		; Called in PM only, ds unknown.
  3957                                  		;
  3958                                  		; INP:	-
  3959                                  		; OUT:	CY if no DOS extender available ("MS-DOS" on Int2F.168A)
  3960                                  		;	NC if DOS extender available
  3961                                  		; CHG:	-
  3962                                  isextenderavailable:
  3963                                  subcpu 286
  3964 00000B32 1E                      	push ds
  3965 00000B33 06                      	push es
  3966 00000B34 60                      	pusha
  3967 00000B35 16                      	push ss
  3968 00000B36 1F                      	pop ds
  3969 00000B37 BE[0000]                	mov si, msg.msdos
  3970 00000B3A 660FB7F6                _386	movzx esi, si
  3971 00000B3E B88A16                  	mov ax, 168Ah
  3972 00000B41 CD2F                    	int 2Fh
  3973 00000B43 3C01                    	cmp al, 1			; CY if al is zero
  3974 00000B45 F5                      	cmc				; NC if al is zero, CY else
  3975 00000B46 61                      	popa
  3976 00000B47 07                      	pop es
  3977 00000B48 1F                      	pop ds
  3978 00000B49 C3                      	retn
  3979                                  subcpureset
  3980                                  
  3981                                  nodosextinst:
  3982 00000B4A 16                      	push ss
  3983 00000B4B 1F                      	pop ds
  3984 00000B4C B83D01                  	mov ax, 013Dh
  3985 00000B4F E8420B                  	call setrc
  3986 00000B52 BA[0000]                	mov dx, nodosext
  3987 00000B55 E9(0000)                	jmp putsz
  3988                                  %endif
  3989                                  
  3990                                  
  3991                                   %ifn _LINK || _LINK_COMPAT
  3992                                  %if !_LOADER
  3993                                  %include "ll.asm"
  3994                                  %endif
  3995                                  
  3996                                  
  3997                                  %include "mm.asm"
  3998                                   %endif
  3999                                  
  4000                                  
  4001                                  	usesection lDEBUG_CODE
  4001          ------------------       note: usesection lDEBUG_CODE
  4002                                  
  4003                                  %if !_LOADER
  4004                                  		; K command - enter Kommand line in new style
  4005                                  		; N command - change the Name of the program being debugged
  4006                                  		;
  4007                                  		; N command is subject to weird Microsoft compatibility if
  4008                                  		;  an options2 flag is set. In this mode, the entire line_in
  4009                                  		;  contents after the N command are used for the command line
  4010                                  		;  tail rather than only the tail after the program name.
  4011                                  		;  (Yes, really.) Also, the debuggee ds is assumed to point
  4012                                  		;  to a PSP and the FCBs and command line tail are written
  4013                                  		;  to this segment.
  4014                                  %if _MS_N_COMPAT
  4015                                  nn:
  4016 00000B58 800E[DF01]80            	setopt [internalflags2], dif2_nn_capitalise
  4017                                  				; prepare old style (MS Debug compatibility)
  4018 00000B5D F606[A601]02            	testopt [options2], opt2_nn_capitalise
  4019 00000B62 7505                    	jnz @F			; leave it set -->
  4020 00000B64 8026[DF01]7F            	clropt [internalflags2], dif2_nn_capitalise
  4021                                  				; disable old style, use new style
  4022                                  @@:
  4023                                  
  4024 00000B69 800E[DF01]40            	setopt [internalflags2], dif2_nn_compat
  4025                                  				; prepare old style (MS Debug compatibility)
  4026 00000B6E F606[A601]01            	testopt [options2], opt2_nn_compat
  4027 00000B73 750C                    	jnz @FF			; leave it set -->
  4028 00000B75 EB05                    	jmp @F
  4029                                  kk:
  4030 00000B77 8026[DF01]7F            	clropt [internalflags2], dif2_nn_capitalise
  4031                                  				; also disable capitalisation
  4032                                  @@:
  4033 00000B7C 8026[DF01]BF            	clropt [internalflags2], dif2_nn_compat
  4034                                  				; disable old style, use new style
  4035                                  @@:
  4036                                  %else
  4037                                  kk:
  4038                                  nn:
  4039                                  %endif
  4040 00000B81 16                      	push ss
  4041 00000B82 07                      	pop es
  4042                                  
  4043                                  %if _MS_N_COMPAT
  4044 00000B83 4E                      	dec si			; -> first non-blank
  4045                                  @@:
  4046 00000B84 4E                      	dec si			; -> before prior start of command
  4047 00000B85 803C20                  	cmp byte [si], 32	; blank ?
  4048 00000B88 74FA                    	je @B
  4049 00000B8A 803C09                  	cmp byte [si], 9
  4050 00000B8D 74F5                    	je @B			; yes, decrement -->
  4051 00000B8F 803C2C                  	cmp byte [si], ','
  4052 00000B92 74F0                    	je @B
  4053 00000B94 46                      	inc si			; restore -> start of command (first blank, if any)
  4054 00000B95 AC                      	lodsb			; make al = first text byte, si -> after
  4055                                  %endif
  4056                                  
  4057                                  %if _BOOTLDR
  4058                                   %if _APPLICATION || _DEVICE
  4059 00000B96 36F606[D901]40          	testopt [ss:internalflags], nodosloaded
  4060 00000B9C 740C                    	jz @F
  4061                                   %endif
  4062 00000B9E BA[0000]                	mov dx, msg.nobootsupp
  4063 00000BA1 B81901                  	mov ax, 0119h
  4064 00000BA4 E8ED0A                  	call setrc
  4065 00000BA7 E9(0000)                	jmp putsz
  4066                                  @@:
  4067                                  %endif
  4068                                  %if _APPLICATION || _DEVICE
  4069                                   %if _MS_N_COMPAT
  4070 00000BAA F606[DF01]40            	testopt [internalflags2], dif2_nn_compat
  4071 00000BAF 7405                    	jz @F
  4072 00000BB1 E89800                  	call nn_copy_to_line_out
  4073 00000BB4 4E                      	dec si
  4074 00000BB5 AC                      	lodsb			; restore al
  4075                                  @@:
  4076                                   %endif
  4077 00000BB6 BF8000                  	mov	di, DTA		; destination address
  4078                                  %if _MS_N_COMPAT	; (not needed if not including the blank scan)
  4079 00000BB9 E8(0000)                	call skipcomm0		; skip blanks before program load filename
  4080                                  %endif
  4081                                  
  4082                                  		; Copy and canonicalize file name.
  4083                                  nn1:
  4084 00000BBC 81FF[6E01]              	cmp di, N_BUFFER_END
  4085 00000BC0 7313                    	jae .toolong
  4086 00000BC2 E88C01                  	call ifsep		; check for separators CR, blank, tab, comma, ;, =
  4087 00000BC5 742E                    	je nn3			; if end of file name
  4088 00000BC7 363A06[DB0C]            	cmp al, byte [ss:swch1]
  4089                                  		; The use of ss here appears to be intended to
  4090                                  		;  allow loading from ds different from the
  4091                                  		;  data entry and PSP segment, However, the
  4092                                  		;  subsequent copy of the command tail around
  4093                                  		;  nn4 does not participate in this scheme.
  4094                                  		; So if this is used make sure to adjust that.
  4095 00000BCC 7427                    	je nn3			; if '/' (and '/' is the switch character)
  4096 00000BCE E8(0000)                	call capitalise
  4097 00000BD1 AA                      	stosb
  4098 00000BD2 AC                      	lodsb
  4099 00000BD3 EBE7                    	jmp short nn1		; back for more
  4100                                  
  4101                                  .toolong:
  4102                                  nn4.toolong:
  4103 00000BD5 16                      	push ss
  4104 00000BD6 1F                      	pop ds
  4105 00000BD7 BA[0000]                	mov dx, msg.n_toolongname
  4106 00000BDA E8(0000)                	call putsz
  4107 00000BDD B82601                  	mov ax, 0126h
  4108 00000BE0 E8B10A                  	call setrc
  4109 00000BE3 BF[6B01]                	mov di, N_BUFFER_END - 3
  4110 00000BE6 B000                    	mov al, 0		; truncate the name
  4111 00000BE8 AA                      	stosb
  4112 00000BE9 A2[D80D]                	mov byte [fileext], al	; invalid / none
  4113 00000BEC 893E[6A0E]              	mov word [execblk.cmdline], di
  4114 00000BF0 B8000D                  	mov ax, 13 << 8		; 0 in low byte (tail length), CR in high byte
  4115 00000BF3 AB                      	stosw
  4116 00000BF4 C3                      	retn
  4117                                  
  4118                                  
  4119                                  nn3:
  4120 00000BF5 16                      	push ss
  4121 00000BF6 1F                      	pop ds
  4122 00000BF7 B000                    	mov al, 0		; null terminate the file name string
  4123 00000BF9 AA                      	stosb
  4124 00000BFA 893E[6A0E]              	mov word [execblk.cmdline], di
  4125                                  				; save start of command tail
  4126                                  
  4127                                  %if _DEBUG4
  4128                                  	push dx
  4129                                  	mov dx, DTA
  4130                                  	call d4disp_msg
  4131                                  	mov dx, crlf
  4132                                  	call d4disp_msg
  4133                                  	pop dx
  4134                                  %endif
  4135                                  		; Determine file extension
  4136 00000BFE 81FF8100                	cmp di, DTA+1
  4137 00000C02 7438                    	je nn3d			; if no file name at all
  4138 00000C04 81FF8500                	cmp di, DTA+5
  4139 00000C08 7230                    	jb nn3c			; if no extension (name too short)
  4140 00000C0A B008                    	mov al, EXT_HEX
  4141 00000C0C 817DFB2E48              	cmp word [di-5], ".H"
  4142 00000C11 7507                    	jne nn3a		; if not .HEX
  4143 00000C13 817DFD4558              	cmp word [di-3], "EX"
  4144 00000C18 7422                    	je nn3d			; if .HEX
  4145                                  nn3a:
  4146 00000C1A B004                    	mov al, EXT_EXE
  4147 00000C1C 817DFB2E45              	cmp word [di-5], ".E"
  4148 00000C21 7507                    	jne nn3b		; if not .EXE
  4149 00000C23 817DFD5845              	cmp word [di-3], "XE"
  4150 00000C28 7412                    	je nn3d			; if .EXE
  4151                                  nn3b:
  4152 00000C2A B002                    	mov al, EXT_COM
  4153 00000C2C 817DFB2E43              	cmp word [di-5], ".C"
  4154 00000C31 7507                    	jne nn3c		; if not .COM
  4155 00000C33 817DFD4F4D              	cmp word [di-3], "OM"
  4156 00000C38 7402                    	je nn3d			; if .COM
  4157                                  nn3c:
  4158 00000C3A B001                    	mov al, EXT_OTHER
  4159                                  nn3d:
  4160 00000C3C A2[D80D]                	mov byte [fileext], al
  4161                                  
  4162                                  		; Finish the N command
  4163 00000C3F 57                      	push di
  4164                                  %if _MS_N_COMPAT
  4165 00000C40 F606[DF01]40            	testopt [internalflags2], dif2_nn_compat
  4166 00000C45 751D                    	jnz @F
  4167 00000C47 E80200                  	call nn_copy_to_line_out
  4168 00000C4A EB18                    	jmp @F
  4169                                  
  4170                                  		; INP:	si - 1 -> command line tail
  4171                                  		; OUT:	line_out has tail, terminated by 0 or 13 (CR)
  4172                                  		; CHG:	di, al
  4173                                  nn_copy_to_line_out:
  4174 00000C4C 56                      	push si
  4175                                  %endif
  4176 00000C4D BF[2E0B]                	mov di, line_out
  4177 00000C50 4E                      	dec si
  4178                                  nn4:
  4179 00000C51 AC                      	lodsb			; copy the remainder to line_out
  4180 00000C52 F606[DF01]80            	testopt [internalflags2], dif2_nn_capitalise
  4181 00000C57 7403                    	jz .nocaps
  4182 00000C59 E8(0000)                	call capitalise
  4183                                  .nocaps:
  4184 00000C5C AA                      	stosb
  4185 00000C5D E8(0000)                	call iseol?.notsemicolon
  4186 00000C60 75EF                    	jne nn4
  4187                                  %if _MS_N_COMPAT
  4188 00000C62 5E                      	pop si
  4189 00000C63 C3                      	retn
  4190                                  
  4191                                  @@:
  4192                                  %endif
  4193 00000C64 E8E20B                  	call InDOS
  4194 00000C67 740E                    	jz .fcb_setup
  4195                                  %if _DEVICE
  4196 00000C69 F606[EE01]40            	testopt [internalflags6], dif6_device_mode
  4197 00000C6E 7505                    	jnz @F
  4198                                  %endif
  4199 00000C70 8326[800E]00            	and word [reg_eax], 0
  4200                                  @@:
  4201 00000C75 EB23                    	jmp .fcb_none
  4202                                  
  4203                                  .fcb_setup:
  4204                                  		; Set up FCBs.
  4205 00000C77 BE[2E0B]                	mov si, line_out
  4206 00000C7A BF5C00                  	mov di, 5Ch
  4207 00000C7D E87A00                  	call nn6		; do first FCB
  4208                                  %if _DEVICE
  4209 00000C80 F606[EE01]40            	testopt [internalflags6], dif6_device_mode
  4210 00000C85 7503                    	jnz @F
  4211                                  %endif
  4212 00000C87 A2[800E]                	mov byte [reg_eax], al
  4213                                  @@:
  4214 00000C8A BF6C00                  	mov di, 6Ch
  4215 00000C8D E86A00                  	call nn6		; second FCB
  4216                                  %if _DEVICE
  4217 00000C90 F606[EE01]40            	testopt [internalflags6], dif6_device_mode
  4218 00000C95 7503                    	jnz @F
  4219                                  %endif
  4220 00000C97 A2[810E]                	mov byte [reg_eax+1], al
  4221                                  @@:
  4222                                  .fcb_none:
  4223                                  
  4224                                  		; Copy command tail.
  4225 00000C9A BE[2E0B]                	mov si, line_out
  4226 00000C9D 5F                      	pop di
  4227 00000C9E 81FF[6C01]              	cmp di, N_BUFFER_END - 2
  4228 00000CA2 7203E92EFF              	jae .toolong
  4229 00000CA7 57                      	push di			; -> counter byte
  4230 00000CA8 47                      	inc di			; -> first byte of buffer
  4231 00000CA9 8D5D7F                  	lea bx, [di + 127]	; -> behind last byte of PSP target buffer
  4232                                  				;  (within 128 bytes the CR must be written)
  4233 00000CAC B8[6E01]                	mov ax, N_BUFFER_END	; -> behind last byte in our N buffer
  4234 00000CAF 39C3                    	cmp bx, ax		; use whichever limit is smaller
  4235 00000CB1 7202                    	jb @F
  4236 00000CB3 89C3                    	mov bx, ax		; N buffer is smaller, use it as limit
  4237                                  @@:
  4238                                  nn5:
  4239 00000CB5 39DF                    	cmp di, bx		; can store one more (possibly CR) ?
  4240 00000CB7 7331                    	jae .toolong		; no -->
  4241 00000CB9 AC                      	lodsb
  4242 00000CBA AA                      	stosb			; store byte
  4243 00000CBB E8(0000)                	call iseol?.notsemicolon; end of string ?
  4244 00000CBE 75F5                    	jne nn5			; if not end of string -->
  4245                                  .toolong_terminate:	; jump destination from .toolong
  4246 00000CC0 C645FF0D                	mov byte [di - 1], 13	; (just overwrite this unconditionally)
  4247 00000CC4 57                      	push di
  4248 00000CC5 89F9                    	mov cx, di
  4249 00000CC7 81E9[6E01]              	sub cx, N_BUFFER_END
  4250 00000CCB F7D9                    	neg cx
  4251 00000CCD 31C0                    	xor ax, ax
  4252 00000CCF F3AA                    	rep stosb
  4253 00000CD1 5F                      	pop di
  4254 00000CD2 58                      	pop ax			; recover old DI
  4255 00000CD3 97                      	xchg ax, di
  4256 00000CD4 29F8                    	sub ax, di		; compute length of tail
  4257                                  %if _MS_N_COMPAT
  4258 00000CD6 89C1                    	mov cx, ax
  4259                                  %endif
  4260 00000CD8 48                      	dec ax
  4261 00000CD9 48                      	dec ax
  4262 00000CDA AA                      	stosb
  4263                                  %if _MS_N_COMPAT
  4264 00000CDB F606[DF01]40            	testopt [internalflags2], dif2_nn_compat
  4265 00000CE0 7407                    	jz @F
  4266 00000CE2 8E06[A00E]              	mov es, word [reg_ds]	; modify current ds, assuming a PSP
  4267 00000CE6 E8(0000)                	call ll_copy_cmdline_and_fcbs.have_cx
  4268                                  @@:
  4269                                  %endif
  4270                                  %if _DEBUG4
  4271                                  	mov dx, DTA
  4272                                  	call d4disp_msg
  4273                                  	mov dx, crlf
  4274                                  	call d4disp_msg
  4275                                  %endif
  4276 00000CE9 C3                      	retn			; done
  4277                                  
  4278                                  .toolong:
  4279 00000CEA BA[0000]                	mov dx, msg.n_toolongtail
  4280 00000CED E8(0000)                	call putsz
  4281 00000CF0 B82701                  	mov ax, 0127h
  4282 00000CF3 E89E09                  	call setrc
  4283 00000CF6 89DF                    	mov di, bx
  4284 00000CF8 EBC6                    	jmp .toolong_terminate
  4285                                  
  4286                                  
  4287                                  		; Subroutine to process an FCB.
  4288                                  		;
  4289                                  		; INP:	di -> FCB
  4290                                  		;	si -> input
  4291                                  nn6:
  4292 00000CFA AC                      	lodsb
  4293 00000CFB E8(0000)                	call iseol?.notsemicolon
  4294 00000CFE 740B                    	je nn7			; if end
  4295 00000D00 E84E00                  	call ifsep
  4296 00000D03 74F5                    	je nn6			; if separator (other than CR)
  4297 00000D05 3A06[DA0C]              	cmp al, byte [switchar]
  4298 00000D09 741C                    	je nn10			; if switch character
  4299                                  nn7:
  4300 00000D0B 4E                      	dec si
  4301 00000D0C B80129                  	mov ax, 2901h		; parse filename
  4302                                  	doscall
  1490 00000D0F E815FB              <1>  nearcall _doscall
  4303 00000D12 50                      	push ax			; save AL
  4304                                  nn8:
  4305 00000D13 AC                      	lodsb			; skip till separator
  4306 00000D14 E83A00                  	call ifsep
  4307 00000D17 7406                    	je nn9			; if separator character (including CR)
  4308 00000D19 3A06[DB0C]              	cmp al, byte [swch1]
  4309 00000D1D 75F4                    	jne nn8			; if not switchar (sort of)
  4310                                  nn9:
  4311 00000D1F 4E                      	dec si
  4312 00000D20 58                      	pop ax			; recover AL
  4313 00000D21 3C01                    	cmp al, 1
  4314 00000D23 7501                    	jne nn9a		; if not 1
  4315 00000D25 48                      	dec ax
  4316                                  nn9a:
  4317 00000D26 C3                      	retn
  4318                                  
  4319                                  		; Handle a switch (differently).
  4320 00000D27 AC                      nn10:	lodsb
  4321 00000D28 E8(0000)                	call iseol?.notsemicolon
  4322 00000D2B 74DE                    	je nn7			; if end of string
  4323 00000D2D E82100                  	call ifsep
  4324 00000D30 74F5                    	je nn10			; if another separator (other than CR)
  4325 00000D32 B000                    	mov al, 0
  4326 00000D34 AA                      	stosb
  4327 00000D35 4E                      	dec si
  4328 00000D36 AC                      	lodsb
  4329 00000D37 3C61                    	cmp al, 'a'
  4330 00000D39 7206                    	jb nn11			; if not a lower case letter
  4331 00000D3B 3C7A                    	cmp al, 'z'
  4332 00000D3D 7702                    	ja nn11
  4333 00000D3F 24DF                    	and al, TOUPPER		; convert to upper case
  4334 00000D41 AA                      nn11:	stosb
  4335 00000D42 B82020                  	mov ax, 32<<8|32
  4336 00000D45 AB                      	stosw
  4337 00000D46 AB                      	stosw
  4338 00000D47 AB                      	stosw
  4339 00000D48 AB                      	stosw
  4340 00000D49 AB                      	stosw
  4341 00000D4A 31C0                    	xor ax, ax
  4342 00000D4C AB                      	stosw
  4343 00000D4D AB                      	stosw
  4344 00000D4E AB                      	stosw
  4345 00000D4F AB                      	stosw
  4346 00000D50 C3                      	retn			; return with al = 0
  4347                                  
  4348                                  
  4349                                  		; Compare character with separators
  4350                                  		;
  4351                                  		; INP:	al = character
  4352                                  		; OUT:	ZR if al is CR, NUL, blank, tab, comma, semicolon, or equal sign
  4353                                  		;	NZ else
  4354                                  		; REM:	This is only used for parsing FCBs.
  4355                                  ifsep: section_of_function
  4356 00000D51 E8(0000)                	call iseol?		; semicolon or CR or NUL
  4357 00000D54 740E                    	je .return
  4358 00000D56 3C20                    	cmp al, 32
  4359 00000D58 740A                    	je .return
  4360 00000D5A 3C09                    	cmp al, 9
  4361 00000D5C 7406                    	je .return
  4362 00000D5E 3C2C                    	cmp al, ','
  4363 00000D60 7402                    	je .return
  4364 00000D62 3C3D                    	cmp al, '='
  4365                                  .return:
  4366 00000D64 C3                      	retn
  4367                                  %endif
  4368                                  %endif
  4369                                  
  4370                                  
  4371                                  %if _ELDLINKINFO && !_PM
  4372                                  verifysegm_or_error: section_of_function
  4373                                  verifysegm: section_of_function
  4374                                  	clc
  4375                                  	retn
  4376                                  %endif
  4377                                  
  4378                                  		; Ensure segment in bx is writeable
  4379                                  		;
  4380                                  		; INP:	bx = selector/segment
  4381                                  		; OUT:	NC if in 86M, bx unchanged
  4382                                  		;	NC if in PM and bx not a code segment, bx unchanged
  4383                                  		;	NC if in PM and was a code segment,
  4384                                  		;	 bx = word [scratchsel], set up to mirror INP:bx selector
  4385                                  		;	CY if in PM and a failure occurred, segment not writeable
  4386                                  		; CHG:	bx
  4387                                  		; STT:	ss = debugger data selector
  4388                                  %if _PM
  4389                                  verifysegm_or_error: section_of_function
  4390 00000D65 53                      	push bx
  4391 00000D66 E82100                  	call verifysegm
  4392 00000D69 7204                    	jc .ro
  4393 00000D6B 83C402                  	add sp, 2		; (discard bx on stack)
  4394 00000D6E C3                      	retn
  4395                                  
  4396                                  .ro:
  4397 00000D6F 16                      	push ss
  4398 00000D70 07                      	pop es
  4399 00000D71 E8(0000)                	call ee0a
  4400 00000D74 BF[0000]                	mov di, msg.readonly_verifysegm.selector
  4401 00000D77 58                      	pop ax			; get original selector
  4402 00000D78 E8(0000)                	call hexword
  4403 00000D7B BA[0000]                	mov dx, msg.readonly_verifysegm
  4404 00000D7E E8(0000)                	call putsz_error
  4405 00000D81 B80901                  	mov ax, 0109h
  4406 00000D84 E80D09                  	call setrc
  4407 00000D87 E976F2                  	jmp cmd3
  4408                                  
  4409                                  
  4410                                  verifysegm: section_of_function
  4411 00000D8A E810FC                  	call ispm
  4412 00000D8D 7537                    	jnz .rm			; (NC)
  4413 00000D8F 50                      	push ax
  4414 00000D90 06                      	push es
  4415 00000D91 66                      	_386_o32	; push edi
  4416 00000D92 57                      	push di
  4417 00000D93 55                      	push bp
  4418 00000D94 89E5                    	mov bp, sp
  4419 00000D96 83EC08                  	sub sp, 8
  4420 00000D99 16                      	 push ss
  4421 00000D9A 07                      	 pop es
  4422 00000D9B 89E7                    	mov di, sp
  4423 00000D9D 660FB7FF                _386	movzx edi, di
  4424 00000DA1 B80B00                  	mov ax, 000Bh		; get descriptor
  4425 00000DA4 CD31                    	int 31h
  4426 00000DA6 7217                    	jc @F
  4427 00000DA8 F6450508                	test byte [di+5], 8	; code segment ?
  4428 00000DAC 7411                    	jz @F			; (NC) no -->
  4429 00000DAE 806505F3                	and byte [di+5], 0F3h	; reset CODE+conforming attr
  4430 00000DB2 804D0502                	or byte [di+5], 2	; set writable
  4431 00000DB6 8B1E[0000]              	mov bx, word [scratchsel]
  4432 00000DBA B80C00                  	mov ax, 000Ch
  4433 00000DBD CD31                    	int 31h
  4434                                  @@:
  4435 00000DBF 89EC                    	mov sp, bp
  4436 00000DC1 5D                      	pop bp
  4437 00000DC2 66                      	_386_o32	; pop edi
  4438 00000DC3 5F                      	pop di
  4439 00000DC4 07                      	pop es
  4440 00000DC5 58                      	pop ax
  4441                                  .rm:
  4442                                  .retn:
  4443 00000DC6 C3                      	retn
  4444                                  
  4445                                  subcpu 286
  4446                                  		; INP:	dx = 86 Mode segment to access
  4447                                  		; OUT:	bx = scratch selector, addressing that segment,
  4448                                  		;	 limit set to 64 KiB (allow all 16-bit accesses)
  4449                                  		; CHG:	-
  4450                                  		; STT:	ss = lDEBUG_DATA_ENTRY selector, in PM
  4451                                  setrmsegm: section_of_function
  4452 00000DC7 368B1E[0000]            	mov bx, word [ss:scratchsel]
  4453 00000DCC E81100                  	call setrmaddr
  4454                                  
  4455                                  		; INP:	bx = selector
  4456                                  		; OUT:	limit set to 0FFFFh
  4457                                  		; STT:	in PM
  4458                                  setrmlimit: section_of_function
  4459 00000DCF 50                      	push ax
  4460 00000DD0 51                      	push cx
  4461 00000DD1 52                      	push dx
  4462 00000DD2 31C9                    	xor cx, cx
  4463                                  ; _386	dec cx		; limit 0FFFF_FFFFh on 386+
  4464                                  		; We don't want that here. All users expect a 64 KiB segment.
  4465 00000DD4 BAFFFF                  	mov dx, -1	; limit 0FFFFh on 286
  4466 00000DD7 B80800                  	mov ax, 8
  4467 00000DDA CD31                    	int 31h		; set limit
  4468 00000DDC 5A                      	pop dx		; restore base segment
  4469 00000DDD 59                      	pop cx
  4470 00000DDE 58                      	pop ax
  4471 00000DDF C3                      	retn
  4472                                  
  4473                                  setrmaddr:		;<--- set selector in BX to segment address in DX
  4474                                  .:
  4475 00000DE0 50                      	push ax
  4476 00000DE1 51                      	push cx
  4477 00000DE2 52                      	push dx
  4478 00000DE3 89D1                    	mov cx, dx
  4479 00000DE5 C1E204                  	shl dx, 4
  4480 00000DE8 C1E90C                  	shr cx, 12	; cx:dx = base address
  4481 00000DEB B80700                  	mov ax, 7
  4482 00000DEE CD31                    	int 31h		; set base
  4483 00000DF0 5A                      	pop dx
  4484 00000DF1 59                      	pop cx
  4485 00000DF2 58                      	pop ax
  4486 00000DF3 C3                      	retn
  4487                                  
  4488                                  subcpureset
  4489                                  %endif
  4490                                  
  4491                                  		; Read a byte relative to cs:eip
  4492                                  		;
  4493                                  		; INP:	reg_cs, reg_eip
  4494                                  		;	cx = (signed) eip adjustment
  4495                                  		; OUT:	al = byte at that address
  4496                                  		;	(e)bx = new offset (eip+adjustment)
  4497                                  		; CHG:	-
  4498                                  getcseipbyte:
  4499 00000DF4 06                      	push es
  4500                                  %if _PM
  4501 00000DF5 8B1E[AC0E]              	mov bx, word [reg_cs]
  4502 00000DF9 8EC3                    	mov es, bx
  4503 00000DFB E8F6F9                  	call test_d_b_bit
  4504 00000DFE 7416                    	jz .16
  4505                                  [cpu 386]
  4506 00000E00 668B1E[B80E]            	mov ebx, dword [reg_eip]
  4507 00000E05 6652                    	push edx
  4508 00000E07 660FBFD1                	movsx edx, cx
  4509 00000E0B 6601D3                  	add ebx, edx
  4510                                  ..@getcseipbyte_fault_skip_6_near_call:
  4511 00000E0E 26678A03                	mov al, byte [es:ebx]
  4512 00000E12 665A                    	pop edx
  4513 00000E14 07                      	pop es
  4514 00000E15 C3                      	retn
  4515                                  __CPU__
  4516                                  .16:
  4517                                  %else
  4518                                  	mov es, word [reg_cs]
  4519                                  %endif
  4520 00000E16 8B1E[B80E]              	mov bx, word [reg_eip]
  4521 00000E1A 01CB                    	add bx, cx
  4522                                  ..@getcseipbyte_fault_skip_2_near_call:
  4523 00000E1C 268A07                  	mov al, byte [es:bx]
  4524 00000E1F 07                      	pop es
  4525 00000E20 C3                      	retn
  4526                                  
  4527                                  		; Write to a byte relative to cs:eip
  4528                                  		;
  4529                                  		; INP:	reg_cs, reg_eip
  4530                                  		;	cx = (signed) eip adjustment
  4531                                  		;	al = source byte to write
  4532                                  		; OUT:	NC if apparently written
  4533                                  		;	CY if failed to get a writeable selector
  4534                                  		; CHG:	(e)bx
  4535                                  setcseipbyte:
  4536 00000E21 06                      	push es
  4537                                  %if _PM
  4538 00000E22 8B1E[AC0E]              	mov bx, word [reg_cs]
  4539 00000E26 E861FF                  	call verifysegm
  4540 00000E29 7226                    	jc .ret
  4541 00000E2B 8EC3                    	mov es, bx
  4542 00000E2D E8C4F9                  	call test_d_b_bit
  4543 00000E30 7415                    	jz .16
  4544                                  [cpu 386]
  4545 00000E32 668B1E[B80E]            	mov ebx, dword [reg_eip]
  4546 00000E37 6652                    	push edx
  4547 00000E39 660FBFD1                	movsx edx, cx
  4548                                  ..@setcseipbyte_fault_skip_6_near_call:
  4549 00000E3D 2667880413              	mov byte [es:ebx+edx],al
  4550 00000E42 665A                    	pop edx
  4551 00000E44 07                      	pop es
  4552 00000E45 F8                      	clc
  4553 00000E46 C3                      	retn
  4554                                  __CPU__
  4555                                  .16:
  4556                                  %else
  4557                                  	mov es, word [reg_cs]
  4558                                  %endif
  4559 00000E47 8B1E[B80E]              	mov bx, word [reg_eip]
  4560 00000E4B 01CB                    	add bx, cx
  4561                                  ..@setcseipbyte_fault_skip_2_near_call:
  4562 00000E4D 268807                  	mov byte [es:bx], al
  4563 00000E50 F8                      	clc
  4564                                  .ret:
  4565 00000E51 07                      	pop es
  4566 00000E52 C3                      	retn
  4567                                  
  4568                                  		; Exchange byte with memory
  4569                                  		;
  4570                                  		; INP:	bx:(e)dx-> destination byte
  4571                                  		;	al = source byte
  4572                                  		; REM:	Determines whether to use edx by the
  4573                                  		;	 segment limit of the selector.
  4574                                  		;	 (Uses in run.asm always pass a segmented
  4575                                  		;	 address obtained from getsegmented. This
  4576                                  		;	 will have edxh = 0 always so it doesn't
  4577                                  		;	 matter whether we use edx or dx.)
  4578                                  		; OUT:	CY if failed due to segment not writable
  4579                                  		;	NC if successful,
  4580                                  		;	 al = previous value of destination byte
  4581                                  		; CHG:	ah
  4582                                  writemem:
  4583                                  %if _DEBUG1
  4584                                  	push dx
  4585                                  	push ax
  4586                                  
  4587                                  	call getlinear_high_limit.do_not_use_test	; NB do NOT resetmode
  4588                                  	jc @F			; already an error ?  then return --> (CY)
  4589                                  	push bx
  4590                                  	push cx
  4591                                  	mov bx, test_records_Writemem
  4592                                  	call handle_test_case_multiple_16
  4593                                  				; check whether this should testcase the error
  4594                                  				; CY to indicate error from this call
  4595                                  	pop cx
  4596                                  	pop bx
  4597                                  @@:
  4598                                  	pop ax
  4599                                  	pop dx
  4600                                  	jnc .do_not_use_test
  4601                                  	retn			; return CY here
  4602                                  
  4603                                  %endif
  4604                                  .do_not_use_test:
  4605                                  
  4606 00000E53 88C4                    	mov ah, al
  4607                                  %if _PM
  4608 00000E55 E845FB                  	call ispm
  4609 00000E58 7516                    	jnz .16			; (NC from ispm) -->
  4610 00000E5A E82DFF                  	call verifysegm		; make bx a writeable segment
  4611 00000E5D 7220                    	jc .ret
  4612 00000E5F E8ACF9                  _386_PM	call test_high_limit	; 32-bit segment ?
  4613 00000E62 740C                    	jz .16			; (NC from test_d_b_bit) -->
  4614                                  [cpu 386]
  4615 00000E64 1E                      	push ds
  4616 00000E65 8EDB                    	mov ds, bx
  4617                                  ..@writemem_fault_skip_2_near_call_a:
  4618 00000E67 678602                  	xchg al, byte [edx]
  4619                                  ..@writemem_fault_skip_2_near_call_b:
  4620 00000E6A 673A22                  	cmp ah, byte [edx]
  4621 00000E6D 1F                      	pop ds
  4622                                  __CPU__
  4623 00000E6E EB0C                    	jmp short .cmp
  4624                                  .16:
  4625                                  %endif
  4626 00000E70 1E                      	push ds
  4627 00000E71 8EDB                    	mov ds, bx
  4628 00000E73 53                      	push bx
  4629 00000E74 89D3                    	mov bx, dx
  4630                                  ..@writemem_fault_skip_4_near_call_a:
  4631 00000E76 8607                    	xchg al, byte [bx]
  4632                                  ..@writemem_fault_skip_4_near_call_b:
  4633 00000E78 3A27                    	cmp ah, byte [bx]
  4634 00000E7A 5B                      	pop bx
  4635 00000E7B 1F                      	pop ds
  4636                                  .cmp:
  4637 00000E7C 7401                    	je .ret			; (NC)
  4638 00000E7E F9                      	stc			; Failed to compare (i.e. memory wasn't our byte after writing).
  4639                                  				; This check catches ROM that will silently fail to write.
  4640                                  .ret:
  4641 00000E7F C3                      	retn
  4642                                  
  4643                                  
  4644                                  		; Read byte from memory
  4645                                  		;
  4646                                  		; INP:	bx:(e)dx-> destination byte
  4647                                  		; REM:	Determines whether to use edx by the
  4648                                  		;	 segment limit of the selector.
  4649                                  		;	 (Uses in run.asm always pass a segmented
  4650                                  		;	 address obtained from getsegmented. This
  4651                                  		;	 will have edxh = 0 always so it doesn't
  4652                                  		;	 matter whether we use edx or dx.)
  4653                                  		; OUT:	 al = value of byte read
  4654                                  readmem: section_of_function
  4655                                  %if _DEBUG1
  4656                                  	push dx
  4657                                  	push ax
  4658                                  
  4659                                  	call getlinear_high_limit.do_not_use_test	; NB do NOT resetmode
  4660                                  	jc @F			; already an error ?  then return --> (CY)
  4661                                  	push bx
  4662                                  	push cx
  4663                                  	mov bx, test_records_Readmem
  4664                                  	call handle_test_case_multiple_16
  4665                                  				; check whether this should testcase the error
  4666                                  				; CY to indicate error from this call
  4667                                  	pop cx
  4668                                  	pop bx
  4669                                  @@:
  4670                                  	pop ax
  4671                                  	pop dx
  4672                                  	jnc .do_not_use_test
  4673                                  	mov al, byte [test_readmem_value]
  4674                                  				; return a most likely wrong value
  4675                                  	retn
  4676                                  
  4677                                  %endif
  4678                                  .do_not_use_test:
  4679                                  
  4680                                  %if _PM
  4681 00000E80 E88BF9                  _386_PM	call test_high_limit	; 32-bit segment ?
  4682 00000E83 7408                    	jz .16
  4683                                  [cpu 386]
  4684 00000E85 1E                      	push ds
  4685 00000E86 8EDB                    	mov ds, bx
  4686                                  ..@readmem_fault_skip_2_near_call:
  4687 00000E88 678A02                  	mov al, byte [edx]
  4688 00000E8B 1F                      	pop ds
  4689 00000E8C C3                      	retn
  4690                                  __CPU__
  4691                                  .16:
  4692                                  %endif
  4693 00000E8D 1E                      	push ds
  4694 00000E8E 53                      	push bx
  4695 00000E8F 8EDB                    	mov ds, bx
  4696 00000E91 89D3                    	mov bx, dx
  4697                                  ..@readmem_fault_skip_4_near_call:
  4698 00000E93 8A07                    	mov al, byte [bx]
  4699 00000E95 5B                      	pop bx
  4700 00000E96 1F                      	pop ds
  4701 00000E97 C3                      	retn
  4702                                  
  4703                                  
  4704                                  %if !_LOADER
  4705                                  		; Q command - quit.
  4706                                  qq:
  4707 00000E98 E816F9                  	call guard_re
  4708 00000E9B 31C9                    	xor cx, cx	; no qq mode selected
  4709 00000E9D 4E                      	dec si
  4710                                  .loop:
  4711 00000E9E AC                      	lodsb
  4712 00000E9F E8(0000)                	call capitalise
  4713 00000EA2 3C41                    	cmp al, 'A'
  4714 00000EA4 741C                    	je qq_a
  4715 00000EA6 B501                    	mov ch, qqmode_b; QB mode (breakpoint before terminate)
  4716 00000EA8 3C42                    	cmp al, 'B'
  4717 00000EAA 7412                    	je .otherletter
  4718 00000EAC B502                    	mov ch, qqmode_c; QC mode (terminate device in a container MCB)
  4719 00000EAE 3C43                    	cmp al, 'C'
  4720 00000EB0 740C                    	je .otherletter
  4721 00000EB2 B504                    	mov ch, qqmode_d; QD mode (terminate device in initialisation)
  4722 00000EB4 3C44                    	cmp al, 'D'
  4723 00000EB6 7406                    	je .otherletter
  4724 00000EB8 880E[B414]              	mov byte [qq_mode], cl
  4725 00000EBC EB1B                    	jmp qq_default
  4726                                  
  4727                                  .otherletter:
  4728 00000EBE 08E9                    	or cl, ch
  4729 00000EC0 EBDC                    	jmp .loop
  4730                                  
  4731                                  	usesection lDEBUG_DATA_ENTRY
  4731          ------------------       note: usesection lDEBUG_DATA_ENTRY
  4732 000014B4 00                      qq_mode:	db 0
  4733                                  qqmode_b:	equ 1
  4734                                  qqmode_c:	equ 2
  4735                                  qqmode_d:	equ 4
  4736                                  	usesection lDEBUG_CODE
  4736          ------------------       note: usesection lDEBUG_CODE
  4737                                  
  4738                                  qq_a:
  4739 00000EC2 AC                      	lodsb
  4740 00000EC3 E8(0000)                	call chkeol
  4741 00000EC6 E8D607                  	call terminate_attached_process
  4742 00000EC9 BB[0000]                	mov bx, msg.qq_a_unterminated
  4743 00000ECC 7403                    	jz .attached_unterminated
  4744 00000ECE BB[0000]                	mov bx, msg.qq_a_terminated
  4745                                  .attached_unterminated:
  4746 00000ED1 E8(0000)                	call putrunint
  4747 00000ED4 89DA                    	mov dx, bx
  4748 00000ED6 E9(0000)                	jmp putsz
  4749                                  
  4750                                  
  4751                                  qq_default:
  4752 00000ED9 E8(0000)                	call chkeol
  4753                                  
  4754                                  %if _RH
  4755 00000EDC 8026[B601]EF            	clropt [options6], opt6_rh_mode
  4756 00000EE1 8026[E301]BF            	clropt [internalflags3], dif3_auxbuff_guarded_3
  4757 00000EE6 8026[EE01]C7            	clropt [internalflags6], dif6_rh_mode_was | dif6_rh_mode | dif6_rh_mode_2
  4758                                  %endif
  4759 00000EEB E8A7F8                  	call guard_auxbuff
  4760                                  
  4761                                  %if _DEVICE
  4762                                   %if _APPLICATION || _BOOTLDR
  4763 00000EEE F606[EE01]40            	testopt [internalflags6], dif6_device_mode
  4764 00000EF3 7411                    	jz .nondevice
  4765                                   %endif
  4766 00000EF5 F6C106                  	test cl, qqmode_c | qqmode_d
  4767 00000EF8 750C                    	jnz .deviceselected
  4768 00000EFA BA[0000]                	mov dx, msg.qq_device_none_selected
  4769 00000EFD B83701                  	mov ax, 0137h
  4770 00000F00 E89107                  	call setrc
  4771 00000F03 E9(0000)                	jmp putsz
  4772                                  
  4773                                  .deviceselected:
  4774                                  .nondevice:
  4775                                  %endif
  4776                                   %if _BOOTLDR
  4777                                  		; Test whether we are in non-DOS mode, and were
  4778                                  		; currently entered in protected mode. Since
  4779                                  		; this will make the entire operation fail,
  4780                                  		; it has to be checked for before modifying
  4781                                  		; or releasing any of the resources.
  4782                                  		; (Does this ever occur? No?)
  4783 00000F06 F606[D901]40            	testopt [internalflags], nodosloaded
  4784 00000F0B 741E                    	jz .notpmnodos
  4785                                  %if _PM
  4786 00000F0D E88DFA                  	call ispm
  4787                                    %if _TSR	; same message, reuse code
  4788 00000F10 7425                    	jz .cannotpmquit
  4789                                    %else
  4790                                  	jnz .notpmnodos_nodos
  4791                                  	mov dx, msg.cannotpmquit
  4792                                  	mov ax, 0115h
  4793                                  	call setrc
  4794                                  	jmp putsz_error
  4795                                    %endif
  4796                                  %endif
  4797                                  .notpmnodos_nodos:
  4798 00000F12 E8910A                  	call bootgetmemorysize		; dx => behind usable memory
  4799 00000F15 A1[0000]                	mov ax, word [ boot_new_memsizekib ]
  4800 00000F18 B106                    	mov cl, 6
  4801 00000F1A D3E0                    	shl ax, cl
  4802 00000F1C 39D0                    	cmp ax, dx			; same?
  4803 00000F1E 740B                    	je @F
  4804 00000F20 BA[0000]                	mov dx, msg.cannotbootquit_memsizes
  4805 00000F23 B81B01                  	mov ax, 011Bh
  4806 00000F26 E86B07                  	call setrc
  4807 00000F29 EB15                    	jmp .putsz
  4808                                  %if !_TSR || !_PM
  4809                                  	.putsz equ putsz
  4810                                  %endif
  4811                                  
  4812                                  @@:
  4813                                  .notpmnodos:
  4814                                   %endif
  4815                                  %if _PM
  4816                                   %if _TSR
  4817                                  		; Test whether we are in TSR mode, and were
  4818                                  		; currently entered in protected mode. Since
  4819                                  		; this will make the entire operation fail,
  4820                                  		; it has to be checked for before modifying
  4821                                  		; or releasing any of the resources.
  4822 00000F2B F606[DA01]40            	testopt [internalflags], tsrmode
  4823 00000F30 7411                    	jz .notpmtsr
  4824 00000F32 E868FA                  	call ispm
  4825 00000F35 750C                    	jnz .notpmtsr
  4826                                  
  4827                                  ; This isn't yet implemented. Broken down:
  4828                                  ; * Uses terminate_attached_process which returns in real mode.
  4829                                  ;  * Exception vectors are implicitly restored/discarded by that.
  4830                                  ; * (RM) Interrupt vectors are currently restored in real mode. Unnecessary.
  4831                                  ; * The VDD is un-registered in real mode. Necessary?
  4832                                  ; * Normal 21.4C is used to return to the real parent.
  4833                                  ;  * We have to discard our DOS process resources. Any DPMI TSR resources?
  4834                                  ;  * We must again gain control in debuggee's mode after discarding them.
  4835                                  ;  * We must return to the debuggee and seemlessly discard our memory. The
  4836                                  ;    stack trick possibly/probably does not work in protected mode.
  4837                                  
  4838                                  .cannotpmquit:
  4839 00000F37 BA[0000]                	mov dx, msg.cannotpmquit
  4840 00000F3A B81501                  	mov ax, 0115h
  4841 00000F3D E85407                  	call setrc
  4842                                  .putsz:
  4843 00000F40 E9(0000)                	jmp putsz
  4844                                  
  4845                                  .notpmtsr:
  4846                                   %endif
  4847                                  
  4848                                   %if (opt4_int_2F_hook)&~0FFh
  4849                                    %fatal DCO4 re-ordered, adjust code here
  4850                                   %endif
  4851 00000F43 A1[AC01]                	mov ax, [options4]
  4852 00000F46 B4A8                     	mov ah, __TEST_IMM8
  4853 00000F48 8626[0000]              	xchg ah, [dpmidisable]		 	; disable DPMI hook
  4854                                  						; (SMC in section lDEBUG_DATA_ENTRY)
  4855 00000F4C 50                      	push ax
  4856 00000F4D 8026[AC01]FD            	clropt [options4], opt4_int_2F_hook	; avoid a new hook while terminating
  4857                                  %endif
  4858                                  %else	; !_LOADER
  4859                                  qq:
  4860                                  	call chkeol
  4861                                  %endif
  4862                                  
  4863                                  qq_restore_interrupts_simulated:
  4864 00000F52 31ED                    	xor bp, bp
  4865                                  
  4866                                  %if _CATCHINT2D
  4867                                  .2D:
  4868 00000F54 B02D                    	mov al, 2Dh		; interrupt number
  4869 00000F56 BE[0000]                	mov si, int2D		; -> IISP entry header
  4870 00000F59 B93244                  	mov cx, "2D"
  4871 00000F5C BA0800                  	mov dx, opt4_int_2D_force >> 16
  4872                                   %if (opt4_int_2D_force >> 16) == dif4_int_2D_hooked
  4873 00000F5F E89E06                  	call qq_int_unhook_sim.set_bx_to_dx
  4874                                   %else
  4875                                  	mov bx, dif4_int_2D_hooked
  4876                                  	call qq_int_unhook_sim
  4877                                   %endif
  4878                                  %endif
  4879                                  
  4880                                  
  4881                                  %if _CATCHINTFAULTCOND && _CATCHINT0D
  4882                                  .0D:
  4883 00000F62 B00D                    	mov al, 0Dh		; interrupt number
  4884 00000F64 BE[0000]                	mov si, intr0D		; -> IISP entry header
  4885 00000F67 B93044                  	mov cx, "0D"
  4886 00000F6A BA1000                  	mov dx, opt4_int_0D_force >> 16
  4887                                   %if (opt4_int_0D_force >> 16) == dif4_int_0D_hooked
  4888 00000F6D E89006                  	call qq_int_unhook_sim.set_bx_to_dx
  4889                                   %else
  4890                                  	mov bx, dif4_int_0D_hooked
  4891                                  	call qq_int_unhook_sim
  4892                                   %endif
  4893                                  %endif
  4894                                  
  4895                                  
  4896                                  %if _CATCHINTFAULTCOND && _CATCHINT0C
  4897                                  .0C:
  4898 00000F70 B00C                    	mov al, 0Ch		; interrupt number
  4899 00000F72 BE[0000]                	mov si, intr0C		; -> IISP entry header
  4900 00000F75 B93043                  	mov cx, "0C"
  4901 00000F78 BA2000                  	mov dx, opt4_int_0C_force >> 16
  4902                                   %if (opt4_int_0C_force >> 16) == dif4_int_0C_hooked
  4903 00000F7B E88206                  	call qq_int_unhook_sim.set_bx_to_dx
  4904                                   %else
  4905                                  	mov bx, dif4_int_0C_hooked
  4906                                  	call qq_int_unhook_sim
  4907                                   %endif
  4908                                  %endif
  4909                                  
  4910                                  
  4911                                  %if _CATCHINT08
  4912                                  .08:
  4913 00000F7E B008                    	mov al, 08h		; interrupt number
  4914 00000F80 BE[0000]                	mov si, intr8		; -> IISP entry header
  4915 00000F83 B93038                  	mov cx, "08"
  4916 00000F86 BA0400                  	mov dx, opt4_int_08_force >> 16
  4917                                   %if (opt4_int_08_force >> 16) == dif4_int_08_hooked
  4918 00000F89 E87406                  	call qq_int_unhook_sim.set_bx_to_dx
  4919                                   %else
  4920                                  	mov bx, dif4_int_08_hooked
  4921                                  	call qq_int_unhook_sim
  4922                                   %endif
  4923                                  %endif
  4924                                  
  4925                                  
  4926                                  .serial:
  4927 00000F8C A0[180E]                	mov al, byte [serial_installed_intnum]
  4928 00000F8F BE[0000]                	mov si, serial_interrupt_handler
  4929 00000F92 51                      	push cx			; (make space)
  4930 00000F93 89E7                    	mov di, sp		; es:di -> word on stack
  4931 00000F95 E8(0000)                	call hexbyte		; write byte value as text
  4932 00000F98 59                      	pop cx			; cx = what to write into error message
  4933 00000F99 BA0100                  	mov dx, opt4_int_serial_force >> 16
  4934                                   %if (opt4_int_serial_force >> 16) == dif4_int_serial_hooked
  4935 00000F9C E86106                  	call qq_int_unhook_sim.set_bx_to_dx
  4936                                   %else
  4937                                  	mov bx, dif4_int_serial_hooked
  4938                                  	call qq_int_unhook_sim
  4939                                   %endif
  4940                                  
  4941                                  %if _PM
  4942                                  .2F:
  4943 00000F9F B02F                    	mov al, 2Fh		; interrupt number
  4944 00000FA1 BE[0000]                	mov si, debug2F		; -> IISP entry header
  4945 00000FA4 B93246                  	mov cx, "2F"
  4946 00000FA7 BA0200                  	mov dx, opt4_int_2F_force >> 16
  4947 00000FAA F606[D901]01            	 testopt [internalflags], hooked2F
  4948 00000FAF 7403                    	 jz .noint2F
  4949 00000FB1 E85406                  	call qq_int_unhook_sim.need
  4950                                  
  4951                                  .noint2F:
  4952                                  %endif
  4953                                  
  4954                                  
  4955                                  %if CATCHINTAMOUNT && ! (_DEBUG && ! _DEBUG_COND)
  4956                                   %if _DEBUG
  4957                                  	testopt [internalflags6], dif6_debug_mode
  4958                                  	jnz .skipints
  4959                                   %endif
  4960                                  		; Simulate to restore interrupt vectors.
  4961 00000FB4 BE[490E]                	mov si, inttab
  4962 00000FB7 BF[5E0E]                	mov di, intforcetab
  4963                                  %if _CATCHINT06 && _DETECT95LX
  4964 00000FBA 8B0E[660E]              	mov cx, word [inttab_number_variable]
  4965                                  %else
  4966                                  	mov cx, inttab_number
  4967                                  %endif
  4968 00000FBE E324                    	jcxz .intsimend
  4969 00000FC0 31D2                    	xor dx, dx
  4970                                  .nextintsim:
  4971 00000FC2 AC                      	lodsb
  4972 00000FC3 93                      	xchg ax, bx			; bl = number
  4973 00000FC4 AD                      	lodsw				; si -> list
  4974 00000FC5 96                      	xchg ax, si			; si -> entry, ax -> list
  4975 00000FC6 93                      	xchg ax, bx			; al = number, bx -> list
  4976 00000FC7 57                      	push di
  4977 00000FC8 8A35                    	mov dh, byte [di]
  4978 00000FCA E8(0000)                	call UnhookInterruptForceSim
  4979 00000FCD 5F                      	pop di
  4980 00000FCE 16                      	push ss
  4981 00000FCF 07                      	pop es
  4982 00000FD0 730D                    	jnc @F
  4983 00000FD2 BF[0000]                	mov di, msg.serial_cannot_unhook.int
  4984 00000FD5 E8(0000)                	call hexbyte
  4985 00000FD8 BA[0000]                	mov dx, msg.serial_cannot_unhook.nowarn
  4986 00000FDB E8(0000)                	call putsz
  4987 00000FDE 45                      	inc bp
  4988                                  @@:
  4989 00000FDF 47                      	inc di
  4990 00000FE0 87DE                    	xchg bx, si			; si -> list
  4991 00000FE2 E2DE                    	loop .nextintsim
  4992                                  
  4993                                  .intsimend:
  4994                                  .skipints:
  4995                                  %endif
  4996                                  
  4997 00000FE4 BA[0000]                	mov dx, msg.empty_message
  4998 00000FE7 85ED                    	test bp, bp
  4999 00000FE9 7403E9BB03              	jnz qq_attached_unterminated.common
  5000                                  
  5001                                  
  5002                                  %if _DEVICE
  5003                                  qq_device_prepare:
  5004                                   %if _APPLICATION || _BOOTLDR
  5005 00000FEE F606[EE01]40            	testopt [internalflags6], dif6_device_mode
  5006 00000FF3 7503E9A401              	jz qq_nondevice
  5007                                   %endif
  5008                                  
  5009                                  %if _PM
  5010 00000FF8 BA[0000]                	mov dx, msg.qq_device_pm
  5011 00000FFB E89FF9                  	call ispm
  5012 00000FFE 7441                    	jz @F			; in PM -->
  5013                                  %endif
  5014                                  
  5015                                  		; Try quitting early in device init ?
  5016 00001000 F606[B414]04            	testopt [qq_mode], qqmode_d
  5017 00001005 743D                    	jz .device_c		; no, must be container quit -->
  5018                                  
  5019                                  .device_d:
  5020 00001007 F606[DA01]40            	testopt [internalflags], tsrmode
  5021 0000100C 741E                    	jz .check_device_c
  5022                                  
  5023 0000100E BE[800E]                	mov si, regs
  5024 00001011 BF[000F]                	mov di, device_quittable_regs
  5025 00001014 B92000                  	mov cx, words(regs.size)
  5026 00001017 F3A7                    	repe cmpsw		; can quit to device init ?
  5027 00001019 7511                    	jne .check_device_c
  5028 0000101B C43E[140E]              	les di, [device_header_address]
  5029 0000101F B0FF                    	mov al, -1
  5030 00001021 B104                    	mov cl, 4
  5031 00001023 F3AE                    	repe scasb		; is next device pointer still -1 ?
  5032 00001025 16                      	push ss
  5033 00001026 07                      	pop es
  5034 00001027 7503E97001              	je qq_device_got	; yes -->
  5035                                  
  5036                                  .check_device_c:
  5037                                  		; Cannot quit to device init. Clear the flag
  5038                                  		;  so we know later on that we're trying QC.
  5039 0000102C 8026[B414]FB            	clropt [qq_mode], qqmode_d
  5040 00001031 F606[B414]02            	testopt [qq_mode], qqmode_c
  5041                                  				; actually want to try QC ?
  5042 00001036 750C                    	jnz .device_c		; yes -->
  5043                                  
  5044 00001038 BA[0000]                	mov dx, msg.qq_device_no_d
  5045 0000103B B82101                  	mov ax, 0121h
  5046 0000103E E85306                  	call setrc
  5047                                  @@:
  5048 00001041 E96503                  	jmp qq_attached_unterminated.common
  5049                                  
  5050                                  .device_c:
  5051 00001044 B80258                  	mov ax, 5802h
  5052 00001047 CD21                    	int 21h
  5053 00001049 B400                    	mov ah, 0
  5054 0000104B 50                      	push ax			; preserve UMB link
  5055 0000104C B80358                  	mov ax, 5803h
  5056 0000104F BB0100                  	mov bx, 1
  5057 00001052 CD21                    	int 21h			; enable UMB link
  5058                                  				;  we want to support the case in which
  5059                                  				;  the first UMCB may have changed. so
  5060                                  				;  instead of searching for it again we
  5061                                  				;  just request the link enabled.
  5062                                  
  5063 00001054 BBFFFF                  	mov bx, -1
  5064 00001057 B452                    	mov ah, 52h
  5065 00001059 CD21                    	int 21h
  5066 0000105B 89DF                    	mov di, bx
  5067 0000105D 83FBBE                  	cmp bx, - (30h + 12h)
  5068 00001060 7603E91E01              	ja .no_c
  5069 00001065 83FB01                  	cmp bx, 1
  5070 00001068 7503E91601              	je .no_c
  5071 0000106D 268B57FE                	mov dx, word [es:bx - 2]
  5072 00001071 B93000                  	mov cx, 30h
  5073                                  
  5074                                  .nulloop:
  5075 00001074 BE[0000]                	mov si, msg.NULblank
  5076 00001077 A7                      	cmpsw			; di += 2, si += 2. compare
  5077 00001078 750A                    	jne .nulnext
  5078                                  .nulcheck:
  5079 0000107A 57                      	push di
  5080 0000107B 51                      	push cx
  5081 0000107C B103                    	mov cl, 3		; 3 more words to go
  5082 0000107E F3A7                    	repe cmpsw		; match ?
  5083 00001080 59                      	pop cx
  5084 00001081 5F                      	pop di
  5085 00001082 7406                    	je .nulfound
  5086                                  .nulnext:
  5087 00001084 4F                      	dec di			; di -= 1 so it ends up 1 higher than prior
  5088 00001085 E2ED                    	loop .nulloop
  5089 00001087 E9F900                  	jmp .no_c
  5090                                  
  5091                                  .nulfound:
  5092 0000108A 83EF0C                  	sub di, 3 * 2 + 4 + 2	; (strategy, interrupt, flags are words,
  5093                                  				;  next device pointer is a dword.
  5094                                  				;  additional plus 2 for the cmpsw output.)
  5095                                  
  5096                                  		; es:di -> NUL device header
  5097                                  .devloop:
  5098 0000108D A1[140E]                	mov ax, word [device_header_address]
  5099 00001090 263B05                  	cmp ax, word [es:di]
  5100 00001093 7509                    	jne .devnext
  5101 00001095 A1[160E]                	mov ax, word [device_header_address + 2]
  5102 00001098 263B4502                	cmp ax, word [es:di + 2]
  5103 0000109C 7411                    	je .mcb
  5104                                  .devnext:
  5105 0000109E 41                      	inc cx
  5106 0000109F 7903E9DF00              	js .no_c
  5107                                  
  5108 000010A4 26C43D                  	les di, [es:di]
  5109 000010A7 83FFFF                  	cmp di, -1
  5110 000010AA 75E1                    	jne .devloop
  5111 000010AC E9D400                  	jmp .no_c
  5112                                  
  5113                                  .mcb:
  5114                                  
  5115 000010AF 893E[B814]              	mov word [.device_reference], di
  5116 000010B3 8C06[BA14]              	mov word [.device_reference + 2], es
  5117                                  
  5118 000010B7 8326[C214]00            	and word [.counter], 0
  5119 000010BC 89C7                    	mov di, ax		; => start of memory allocated to us
  5120 000010BE 8B0E[120E]              	mov cx, word [device_mcb_paragraphs]
  5121                                  				; = amount paragraphs allocated to us
  5122 000010C2 01CF                    	add di, cx		; => behind memory allocated to us
  5123                                  
  5124                                  		; dx => first MCB
  5125                                  .mcbloop:
  5126 000010C4 8EC2                    	mov es, dx
  5127 000010C6 89D6                    	mov si, dx		; => MCB
  5128 000010C8 2603360300              	add si, word [es:3]
  5129 000010CD 46                      	inc si			; => next MCB (or behind current MCB)
  5130 000010CE 26803E00004D            	cmp byte [es:0], 'M'	; valid MCB ?
  5131 000010D4 740B                    	je @F
  5132 000010D6 26803E00005A            	cmp byte [es:0], 'Z'
  5133 000010DC 7403E9A200              	jne .no_c		; no -->
  5134                                  @@:
  5135 000010E1 39C2                    	cmp dx, ax		; start of MCB < allocation ?
  5136 000010E3 731F                    	jae .mcbnext		; no -->
  5137 000010E5 39FE                    	cmp si, di		; end of MCB > allocation ?
  5138 000010E7 721B                    	jb .mcbnext		; no -->
  5139                                  
  5140 000010E9 26833E010000            	cmp word [es:1], 0	; free ?
  5141 000010EF 7413                    	je .mcbnext		; do not match -->
  5142 000010F1 48                      	dec ax			; => our (sub) MCB
  5143 000010F2 39C2                    	cmp dx, ax		; matches (DEVLOAD style) ?
  5144 000010F4 7520                    	jne .mcbcontainer	; no -->
  5145 000010F6 26390E0300              	cmp word [es:3], cx	; size matches ?
  5146 000010FB 7519                    	jne .mcbcontainer	; no -->
  5147 000010FD 8326[BC14]00            	and word [.container_segment], 0
  5148 00001102 EB7E                    	jmp .mcbdone		; found a non-container MCB
  5149                                  
  5150                                  .mcbnext:
  5151 00001104 FF06[C214]              	inc word [.counter]	; safeguard against infinite loop
  5152 00001108 7479                    	jz .no_c
  5153 0000110A 89F2                    	mov dx, si		; => next MCB
  5154 0000110C 26803E00004D            	cmp byte [es:0], 'M'	; prior was 'M' ?
  5155 00001112 74B0                    	je .mcbloop		; yes, so loop -->
  5156 00001114 EB6D                    	jmp .no_c
  5157                                  
  5158                                  .mcbcontainer:
  5159 00001116 40                      	inc ax			; => allocated block (device header)
  5160 00001117 26833E010050            	cmp word [es:1], 50h	; SD owner system ?
  5161 0000111D 73E5                    	jae .mcbnext
  5162 0000111F 26813E08005344          	cmp word [es:8], "SD"
  5163 00001126 75DC                    	jne .mcbnext		; no -->
  5164                                  
  5165 00001128 26FF360000              	push word [es:0]
  5166 0000112D 8F06[C014]              	pop word [.container_is_z]
  5167 00001131 8936[BE14]              	mov word [.container_end], si
  5168 00001135 8916[BC14]              	mov word [.container_segment], dx
  5169 00001139 42                      	inc dx			; => sub-MCB
  5170                                  .submcbloop:
  5171 0000113A 8EC2                    	mov es, dx
  5172 0000113C 89D6                    	mov si, dx
  5173 0000113E 2603360300              	add si, word [es:3]
  5174 00001143 46                      	inc si			; => next sub or MCB (or behind Z MCB)
  5175 00001144 39C2                    	cmp dx, ax
  5176 00001146 731C                    	jae .submcbnext
  5177 00001148 39FE                    	cmp si, di
  5178 0000114A 7218                    	jb .submcbnext
  5179                                  
  5180 0000114C 50                      	push ax
  5181 0000114D 48                      	dec ax			; => our (sub) MCB
  5182 0000114E 39C2                    	cmp dx, ax		; matched start of allocation ?
  5183 00001150 58                      	pop ax
  5184 00001151 7511                    	jne .submcbnext
  5185 00001153 26390E0300              	cmp word [es:3], cx	; matches allocation size ?
  5186 00001158 750A                    	jne .submcbnext
  5187 0000115A 26833E010000            	cmp word [es:1], 0	; is not free ?
  5188 00001160 7402                    	je .submcbnext
  5189 00001162 EB1E                    	jmp .mcbdone		; all yes, found it -->
  5190                                  
  5191                                  .submcbnext:
  5192 00001164 FF06[C214]              	inc word [.counter]	; safeguard against infinite loop
  5193 00001168 7419                    	jz .no_c
  5194 0000116A 89F2                    	mov dx, si		; => next sub MCB or after container
  5195 0000116C 8B36[BE14]              	mov si, word [.container_end]
  5196 00001170 39F2                    	cmp dx, si		; after container ?
  5197 00001172 72C6                    	jb .submcbloop		; no -->
  5198                                  		; This jump could be a jne but generally
  5199                                  		;  we can assume that the container does
  5200                                  		;  not overflow across the 1 MiB limit.
  5201                                  		; And this is more hardened against errors.
  5202 00001174 89F2                    	mov dx, si		; insure we use actual container end
  5203 00001176 803E[C014]5A            	cmp byte [.container_is_z], 'Z'
  5204                                  				; container had a Z ?
  5205 0000117B 7403E944FF              	jne .mcbloop		; no -->
  5206                                  		; if here, loop now, dx already updated and
  5207                                  		;  furthermore es does not point at container!
  5208 00001180 EB01                    	jmp .no_c
  5209                                  
  5210                                  	usesection lDEBUG_DATA_ENTRY
  5210          ------------------       note: usesection lDEBUG_DATA_ENTRY
  5211 000014B5 00<rep 3h>              	align 4, db 0
  5212 000014B8 00000000                .device_reference:	dd 0
  5213 000014BC 0000                    .container_segment:	dw 0
  5214 000014BE 0000                    .container_end:		dw 0
  5215 000014C0 0000                    .container_is_z:	dw 0
  5216 000014C2 0000                    .counter:		dw 0
  5217                                  	usesection lDEBUG_CODE
  5217          ------------------       note: usesection lDEBUG_CODE
  5218                                  
  5219                                  .mcbdone:
  5220                                  
  5221 00001182 A8                      	db __TEST_IMM8		; (skip stc, NC)
  5222                                  .no_c:
  5223 00001183 F9                      	stc
  5224 00001184 5B                      	pop bx
  5225 00001185 9C                      	pushf
  5226 00001186 B80358                  	mov ax, 5803h
  5227 00001189 CD21                    	int 21h			; restore UMB link
  5228 0000118B 9D                      	popf
  5229 0000118C 16                      	push ss
  5230 0000118D 07                      	pop es
  5231 0000118E 730C                    	jnc @F
  5232 00001190 BA[0000]                	mov dx, msg.qq_device_no_c
  5233 00001193 B82201                  	mov ax, 0122h
  5234 00001196 E8FB04                  	call setrc
  5235 00001199 E90D02                  	jmp qq_attached_unterminated.common
  5236                                  
  5237                                  @@:
  5238                                  
  5239                                  qq_device_got:
  5240                                  qq_nondevice:
  5241                                  %endif
  5242                                  
  5243                                  
  5244                                  qq_restore_interrupts:
  5245                                  %if _CATCHINT2D
  5246                                  .2D:
  5247 0000119C B02D                    	mov al, 2Dh		; interrupt number
  5248 0000119E BE[0000]                	mov si, int2D		; -> IISP entry header
  5249 000011A1 B93244                  	mov cx, "2D"
  5250 000011A4 BA0800                  	mov dx, opt4_int_2D_force >> 16
  5251                                   %if (opt4_int_2D_force >> 16) == dif4_int_2D_hooked
  5252 000011A7 E87204                  	call qq_int_unhook_real.set_bx_to_dx
  5253                                   %else
  5254                                  	mov bx, dif4_int_2D_hooked
  5255                                  	call qq_int_unhook_real
  5256                                   %endif
  5257 000011AA 7303E9FA01              	jc qq_attached_unterminated.common
  5258                                  %endif
  5259                                  
  5260                                  
  5261                                  %if _CATCHINTFAULTCOND && _CATCHINT0D
  5262                                  .0D:
  5263 000011AF B00D                    	mov al, 0Dh		; interrupt number
  5264 000011B1 BE[0000]                	mov si, intr0D		; -> IISP entry header
  5265 000011B4 B93044                  	mov cx, "0D"
  5266 000011B7 BA1000                  	mov dx, opt4_int_0D_force >> 16
  5267                                   %if (opt4_int_0D_force >> 16) == dif4_int_0D_hooked
  5268 000011BA E85F04                  	call qq_int_unhook_real.set_bx_to_dx
  5269                                   %else
  5270                                  	mov bx, dif4_int_0D_hooked
  5271                                  	call qq_int_unhook_real
  5272                                   %endif
  5273 000011BD 7303E9E701              	jc qq_attached_unterminated.common
  5274                                  %endif
  5275                                  
  5276                                  
  5277                                  %if _CATCHINTFAULTCOND && _CATCHINT0C
  5278                                  .0C:
  5279 000011C2 B00C                    	mov al, 0Ch		; interrupt number
  5280 000011C4 BE[0000]                	mov si, intr0C		; -> IISP entry header
  5281 000011C7 B93043                  	mov cx, "0C"
  5282 000011CA BA2000                  	mov dx, opt4_int_0C_force >> 16
  5283                                   %if (opt4_int_0C_force >> 16) == dif4_int_0C_hooked
  5284 000011CD E84C04                  	call qq_int_unhook_real.set_bx_to_dx
  5285                                   %else
  5286                                  	mov bx, dif4_int_0C_hooked
  5287                                  	call qq_int_unhook_real
  5288                                   %endif
  5289 000011D0 7303E9D401              	jc qq_attached_unterminated.common
  5290                                  %endif
  5291                                  
  5292                                  
  5293                                  %if _CATCHINT08
  5294                                  .08:
  5295 000011D5 B008                    	mov al, 08h		; interrupt number
  5296 000011D7 BE[0000]                	mov si, intr8		; -> IISP entry header
  5297 000011DA B93038                  	mov cx, "08"
  5298 000011DD BA0400                  	mov dx, opt4_int_08_force >> 16
  5299                                   %if (opt4_int_08_force >> 16) == dif4_int_08_hooked
  5300 000011E0 E83904                  	call qq_int_unhook_real.set_bx_to_dx
  5301                                   %else
  5302                                  	mov bx, dif4_int_08_hooked
  5303                                  	call qq_int_unhook_real
  5304                                   %endif
  5305 000011E3 7303E9C101              	jc qq_attached_unterminated.common
  5306                                  %endif
  5307                                  
  5308                                  
  5309                                  .serial:
  5310 000011E8 F606[E90D]01            	testopt [serial_flags], sf_init_done
  5311 000011ED 740D                    	jz @F
  5312 000011EF E8(0000)                	call serial_clean_up			; unhook interrupt
  5313 000011F2 8026[E90D]EE            	clropt [serial_flags], sf_init_done | sf_use_serial
  5314                                  						; clear (in case return to cmd3)
  5315 000011F7 8026[A101]BF            	clropt [options], enable_serial		; do not output to serial any longer
  5316                                  @@:
  5317 000011FC F606[E401]01            	testopt [internalflags4], dif4_int_serial_hooked
  5318 00001201 741F                    	jz .done_serial
  5319 00001203 E8(0000)                	call serial_uninstall_interrupt_handler
  5320 00001206 731A                    	jnc .done_serial			; if it succeeded -->
  5321                                  
  5322 00001208 BF[0000]                	mov di, msg.serial_cannot_unhook.int
  5323 0000120B A0[180E]                	mov al, byte [serial_installed_intnum]
  5324 0000120E E8(0000)                	call hexbyte
  5325 00001211 BA[0000]                	mov dx, msg.serial_cannot_unhook.nowarn
  5326 00001214 C606[0800]00            	mov byte [serial_interrupt_handler + ieEOI], 0
  5327                                  						; we do not issue EOI any longer
  5328 00001219 B82301                  	mov ax, 0123h
  5329 0000121C E87504                  	call setrc
  5330 0000121F E98701                  	jmp qq_attached_unterminated.common
  5331                                  
  5332                                  
  5333                                  .done_serial:
  5334                                  
  5335                                  %if _PM
  5336                                  .2F:
  5337 00001222 B02F                    	mov al, 2Fh		; interrupt number
  5338 00001224 BE[0000]                	mov si, debug2F		; -> IISP entry header
  5339 00001227 B93246                  	mov cx, "2F"
  5340 0000122A BA0200                  	mov dx, opt4_int_2F_force >> 16
  5341                                   %if (opt4_int_2F_force >> 16) == dif4_int_2F_hooked
  5342 0000122D 89D3                    	mov bx, dx
  5343                                   %else
  5344                                  	mov bx, dif4_int_2F_hooked
  5345                                   %endif
  5346 0000122F F606[D901]01            	 testopt [internalflags], hooked2F
  5347 00001234 740D                    	 jz .noint2F
  5348 00001236 E8EB03                  	call qq_int_unhook_real.need
  5349 00001239 7303E96B01              	jc qq_attached_unterminated.common
  5350                                  
  5351                                  .got2F:
  5352 0000123E 8026[D901]FE            	clropt [internalflags], hooked2F
  5353                                  
  5354                                  .noint2F:
  5355                                  %endif
  5356                                  
  5357                                  %if _LOADER
  5358                                  	int 19h
  5359                                  %else ; _LOADER
  5360                                  %if _BOOTLDR
  5361                                   %if _APPLICATION || _DEVICE
  5362 00001243 F606[D901]40            	testopt [internalflags], nodosloaded
  5363 00001248 7543                    	jnz .areas
  5364                                   %else
  5365                                  	jmp .areas
  5366                                   %endif
  5367                                  %endif
  5368                                  
  5369                                  
  5370                                  %if _APPLICATION || _DEVICE
  5371                                  		; Cancel child's process if any.
  5372                                  		; This will drop to real mode if debuggee is in protected mode.
  5373                                  %if _TSR || _DEVICE
  5374 0000124A F606[DA01]40            	testopt [internalflags], tsrmode
  5375 0000124F 7423                    	jz .terminate_attached	; falls through for device or TSR application
  5376                                  
  5377                                  %if _PM
  5378 00001251 E849F7                  	call ispm
  5379 00001254 7414                    	jz @F			; in PM -->
  5380 00001256 F606[DA01]04            	testopt [internalflags], canswitchmode
  5381 0000125B 7415                    	jz @FF			; in 86 Mode and cannot switch to PM -->
  5382                                  
  5383 0000125D 800E[DA01]08            	setopt [internalflags], modeswitched	; set flag for resetmode
  5384 00001262 B000                    	mov al, 0
  5385 00001264 E8(0000)                	call sr_state		; save state
  5386 00001267 E8(0000)                	call switchmode 	; switch to PM
  5387                                  		; ! handle_mode_changed not called here !
  5388                                  		; do not call InDOS or other functions using seg/sels
  5389                                  @@:
  5390 0000126A E8(0000)                	call pm_reset_handlers
  5391                                  		; ! this calls resetmode
  5392                                  
  5393                                  		; remember that we cannot access Protected Mode any longer
  5394 0000126D 8026[DA01]DB            	clropt [internalflags], canswitchmode | switchbuffer
  5395                                  @@:
  5396                                  %endif
  5397                                  
  5398 00001272 EB19                    	jmp .areas
  5399                                  
  5400                                  .terminate_attached:
  5401                                  %endif
  5402                                  
  5403 00001274 E82804                  	call terminate_attached_process
  5404 00001277 7503E92101              	jz qq_attached_unterminated
  5405                                  %if _PM
  5406 0000127C E81EF7                  	call ispm
  5407 0000127F 750C                    	jnz @F
  5408                                  
  5409 00001281 BA[0000]                	mov dx, msg.qq_still_pm
  5410 00001284 B82401                  	mov ax, 0124h
  5411 00001287 E80A04                  	call setrc
  5412 0000128A E91C01                  	jmp qq_attached_unterminated.common
  5413                                  @@:
  5414                                  %endif
  5415                                  %endif
  5416                                  
  5417                                  
  5418                                  .areas:
  5419                                  %if _AREAS && _AREAS_HOOK_CLIENT
  5420                                  	call uninstall_areas.qq_entry
  5421                                   %if _AREAS_HOOK_SERVER
  5422                                  	jc .areas_error
  5423                                   %else
  5424                                  	jnc @F
  5425                                  	mov dx, msg.qqlate_areas_error
  5426                                  	mov ax, 0125h
  5427                                  	call setrc
  5428                                  	jmp qq_attached_unterminated.common
  5429                                   %endif
  5430                                  %endif
  5431                                  
  5432                                  @@:
  5433                                  %if _AREAS_HOOK_SERVER
  5434 0000128D 8B16[0200]              	mov dx, word [ddebugareas.next + 2]
  5435 00001291 8B1E[0000]              	mov bx, word [ddebugareas.next]
  5436 00001295 8CD0                    	mov ax, ss
  5437 00001297 39C2                    	cmp dx, ax
  5438 00001299 7426                    	je @F
  5439 0000129B 52                      	 push dx
  5440 0000129C 53                      	 push bx
  5441 0000129D B000                    	mov al, 0
  5442 0000129F 0E                      	push cs
  5443 000012A0 E8F400                  	call qqlate_86m_to_areastruc_entry
  5444 000012A3 16                      	push ss
  5445 000012A4 1F                      	pop ds
  5446 000012A5 16                      	push ss
  5447 000012A6 07                      	pop es
  5448 000012A7 5B                      	 pop bx
  5449 000012A8 5A                      	 pop dx
  5450 000012A9 3B16[0200]              	cmp dx, word [ddebugareas.next + 2]
  5451 000012AD 75DE                    	jne @B
  5452 000012AF 3B1E[0000]              	cmp bx, word [ddebugareas.next]
  5453 000012B3 75D8                    	jne @B
  5454                                  .areas_error:
  5455 000012B5 BA[0000]                	mov dx, msg.qqlate_areas_error
  5456 000012B8 B82501                  	mov ax, 0125h
  5457 000012BB E8D603                  	call setrc
  5458 000012BE E9E800                  	jmp qq_attached_unterminated.common
  5459                                  
  5460                                  @@:
  5461                                  %endif
  5462                                  
  5463                                  
  5464                                  .restoreints:
  5465                                  %if CATCHINTAMOUNT && ! (_DEBUG && ! _DEBUG_COND)
  5466                                   %if _DEBUG
  5467                                  	testopt [internalflags6], dif6_debug_mode
  5468                                  	jnz .skiprestoreints
  5469                                   %endif
  5470                                  		; Restore interrupt vectors.
  5471 000012C1 BE[490E]                	mov si, inttab
  5472 000012C4 BF[5E0E]                	mov di, intforcetab
  5473                                  %if _CATCHINT06 && _DETECT95LX
  5474 000012C7 8B0E[660E]              	mov cx, word [inttab_number_variable]
  5475                                  %else
  5476                                  	mov cx, inttab_number
  5477                                  %endif
  5478 000012CB E313                    	jcxz .intend
  5479 000012CD 31D2                    	xor dx, dx
  5480                                  .nextint:
  5481 000012CF AC                      	lodsb
  5482 000012D0 93                      	xchg ax, bx			; bl = number
  5483 000012D1 AD                      	lodsw				; si -> list
  5484 000012D2 96                      	xchg ax, si			; si -> entry, ax -> list
  5485 000012D3 93                      	xchg ax, bx			; al = number, bx -> list
  5486 000012D4 57                      	push di
  5487 000012D5 8A35                    	mov dh, byte [di]
  5488 000012D7 E8(0000)                	call UnhookInterruptForce
  5489 000012DA 5F                      	pop di
  5490 000012DB 47                      	inc di
  5491 000012DC 87DE                    	xchg bx, si			; si -> list
  5492 000012DE E2EF                    	loop .nextint
  5493                                  
  5494                                  .intend:
  5495                                  .skiprestoreints:
  5496                                  %endif
  5497                                  
  5498                                  
  5499                                  %if _PM
  5500 000012E0 58                      	pop ax					; (discard)
  5501                                  %endif
  5502                                  
  5503                                  
  5504                                  qqlate:
  5505                                  %if _SYMBOLIC
  5506                                  		; Free XMS symbol table. 86 Mode memory backed symbol table
  5507                                  		;  is freed by our process's termination.
  5508                                  		; Update: QD device termination does not currently terminate
  5509                                  		;  our process. In the meantime, free things explicitly.
  5510                                  		;  Note that the calls need to be in this order because of
  5511                                  		;  how zz_free_xms calls zz_free_reset first.
  5512                                  	nearcall zz_free_dos
  5513                                  	nearcall zz_free_xms
  5514                                  %endif
  5515                                  
  5516                                  		; Release the registered VDD.
  5517                                  %if _VDD
  5518 000012E1 F606[D801]04            	testopt [internalflags], ntpacket
  5519 000012E6 7408                    	jz .novdd
  5520 000012E8 A1[880C]                	mov ax, word [hVdd]
  5521 000012EB C4C4580190              	UnRegisterModule
  5522                                  .novdd:
  5523                                  %endif
  5524                                  
  5525                                  %if _VXCHG
  5526 000012F0 F606[EC01]01            	testopt [internalflags6], dif6_vv_mode
  5527 000012F5 7403                    	jz @F
  5528                                  
  5529 000012F7 E8(0000)                	call vv_disable
  5530                                  @@:
  5531                                  %endif
  5532                                  
  5533                                  %if _ALTVID
  5534 000012FA E8(0000)                	call setscreen
  5535                                  %endif
  5536                                  
  5537                                  		; Restore termination address.
  5538                                  %if _BOOTLDR
  5539                                   %if _APPLICATION || _DEVICE
  5540 000012FD F606[D901]40            	testopt [internalflags], nodosloaded
  5541 00001302 7403E9A101              	jnz .bootterminate	; terminate -->
  5542                                   %else
  5543                                  	jmp .bootterminate
  5544                                   %endif
  5545                                  %endif
  5546                                  %if _DEVICE
  5547                                   %if _APPLICATION
  5548 00001307 F606[EE01]40            	testopt [internalflags6], dif6_device_mode
  5549 0000130C 7403E9B100              	jnz .deviceterminate
  5550                                   %else
  5551                                  	jmp .deviceterminate
  5552                                   %endif
  5553                                  %endif
  5554                                  
  5555                                  %if _APPLICATION || _DEVICE
  5556                                  %if _TSR || _DEVICE
  5557                                  .appterminate:
  5558 00001311 16                      	 push ss
  5559 00001312 07                      	 pop es
  5560 00001313 F606[DA01]40            	testopt [internalflags], tsrmode
  5561 00001318 745D                    	jz .nontsrterminate
  5562                                  
  5563                                  .tsrterminate:
  5564 0000131A BA[D514]                	mov dx, qq.proceedtsrtermination
  5565                                  
  5566                                  .terminate_to_shim_process:
  5567 0000131D 31F6                    	xor si, si
  5568 0000131F 8E06[AC0B]              	mov es, word [auxbuff_segorsel]
  5569 00001323 31FF                    	xor di, di
  5570 00001325 31C0                    	xor ax, ax
  5571 00001327 B90800                  	mov cx, 8
  5572 0000132A F3AB                    	rep stosw		; 10h MCB bytes
  5573 0000132C B94000                  	mov cx, 40h
  5574 0000132F F3A5                    	rep movsw		; 80h PSP bytes
  5575 00001331 8CC0                    	mov ax, es
  5576 00001333 40                      	inc ax
  5577 00001334 26A30100                	mov word [es:1], ax	; fake MCB
  5578 00001338 1E                      	push ds
  5579 00001339 8ED8                    	mov ds, ax
  5580 0000133B C70634001800            	mov word [34h], 18h
  5581 00001341 A33600                  	mov word [36h], ax	; insure default PHT and fix segment
  5582 00001344 C70632000100            	mov word [32h], 1	; only one PHT entry (zero might crash)
  5583 0000134A C6061800FF              	mov byte [18h], -1	; PHT entry is closed
  5584 0000134F C7062C000000            	mov word [2Ch], 0	; PSP clear
  5585 00001355 E84401                  	call .setparent		; make it self-owned, just in case
  5586 00001358 8CD3                    	mov bx, ss		; => process segment
  5587 0000135A 4B                      	dec bx			; span actual MCB
  5588                                  %if _DEVICE
  5589                                   %if _APPLICATION
  5590 0000135B 36F606[EE01]40          	testopt [ss:internalflags6], dif6_device_mode
  5591 00001361 7403                    	jz @F
  5592                                   %endif
  5593 00001363 83EB04                  	sub bx, deviceshim_size_p + paras(10h)
  5594                                  				; span shim and pseudo MCB
  5595                                  @@:
  5596                                  %endif
  5597 00001366 8EDB                    	mov ds, bx		; => our (real) MCB
  5598 00001368 81FA[D514]              	cmp dx, qq.proceedtsrtermination
  5599 0000136C 7503                    	jne @F
  5600 0000136E A30100                  	mov word [1], ax	; owner = fake PSP
  5601                                  @@:
  5602 00001371 1F                      	pop ds
  5603 00001372 E82701                  	call .setparent		; make the fake PSP our parent
  5604 00001375 EB1B                    	jmp short terminate_00	; see ya
  5605                                  
  5606                                  .nontsrterminate:
  5607                                  %endif
  5608 00001377 BE[980C]                	mov si, psp22		; restore termination address
  5609 0000137A BF0A00                  	mov di, TPIV
  5610 0000137D A5                      	movsw
  5611 0000137E A5                      	movsw
  5612 0000137F BF1600                  	mov di, 16h		; restore PSP of parent
  5613 00001382 A5                      	movsw
  5614                                  		; Really done.
  5615                                  
  5616 00001383 F606[B414]01            	testopt [qq_mode], qqmode_b
  5617 00001388 7401                    	jz @F
  5618 0000138A CC                      	int3
  5619                                  
  5620                                  @@:
  5621 0000138B B44C                    	mov ah, 4Ch		; quit
  5622 0000138D A0[110E]                	mov al, byte [qqtermcode]
  5623                                  				; return code
  5624 00001390 CD21                    	int 21h
  5625                                  %endif
  5626                                  
  5627                                  
  5628                                  terminate_00:	; used by terminate_attached_process
  5629 00001392 B8004C                  	mov ax, 4C00h		; quit
  5630 00001395 CD21                    	int 21h
  5631                                  
  5632                                  
  5633                                  %if _AREAS_HOOK_SERVER
  5634                                  qqlate_86m_to_areastruc_entry:
  5635 00001397 B9[0000]                	mov cx, areastruc_entry.qq_entry
  5636 0000139A 16                      	push ss
  5637 0000139B 51                      	push cx
  5638 0000139C CB                      	retf
  5639                                  %endif
  5640                                  %endif	; !_LOADER
  5641                                  
  5642                                  
  5643                                  qq_attached_unterminated:
  5644                                  %if !_LOADER
  5645 0000139D E8(0000)                	call putrunint
  5646                                  %endif	; !_LOADER
  5647 000013A0 BA[0000]                	mov dx, msg.qq_unterm
  5648 000013A3 B82001                  	mov ax, 0120h
  5649 000013A6 E8EB02                  	call setrc
  5650                                  
  5651                                  .common:
  5652 000013A9 B81F01                  	mov ax, 011Fh
  5653 000013AC E8E502                  	call setrc
  5654                                  		; Restore state:
  5655                                  %if _PM
  5656                                   %if (opt4_int_2F_hook)&~0FFh
  5657                                    %fatal DCO4 re-ordered, adjust code here
  5658                                   %endif
  5659 000013AF 58                       	pop ax
  5660 000013B0 8826[0000]              	mov [dpmidisable], ah	; (SMC in section lDEBUG_DATA_ENTRY)
  5661 000013B4 2402                    	and al, opt4_int_2F_hook
  5662 000013B6 8026[AC01]FD            	clropt [options4], opt4_int_2F_hook
  5663 000013BB 0806[AC01]              	or [options4], al
  5664                                  %endif
  5665 000013BF E9(0000)                	jmp putsz
  5666                                  
  5667                                  
  5668                                  %if !_LOADER
  5669                                  %if _DEVICE
  5670                                  qqlate.deviceterminate:
  5671 000013C2 F606[B414]04            	testopt [qq_mode], qqmode_d
  5672 000013C7 7432                    	jz .mode_c
  5673                                  
  5674                                  .mode_d:
  5675                                  		; We modify the device request header
  5676                                  		;  only now, so in case of being unable
  5677                                  		;  to release something then the debugger
  5678                                  		;  will remain usable and stay resident.
  5679 000013C9 8E06[A40E]              	mov es, word [reg_es]
  5680 000013CD 8B1E[840E]              	mov bx, word [reg_ebx]
  5681 000013D1 8CD8                    	mov ax, ds			; => process segment
  5682 000013D3 83E804                  	sub ax, paras(deviceshim_size + 10h)
  5683                                  					; span shim and pseudo MCB
  5684 000013D6 26C747030381            	mov word [es:bx + 3], 8103h	; error, done, code: unknown command
  5685 000013DC 2683670E00              	and word [es:bx + 0Eh], 0
  5686 000013E1 26894710                	mov word [es:bx + 0Eh + 2], ax	; -> behind memory in use
  5687                                  		; es reset in run or qqlate.terminate_to_shim_process
  5688                                  
  5689                                  %if 0		; old code to manually release process resources
  5690                                  	xor bx, bx		; = 0
  5691                                  	mov cx, word [32h]	; get amount of handles
  5692                                  .loop:
  5693                                  	mov ah, 3Eh
  5694                                  	int 21h			; close it
  5695                                  	inc bx			; next handle
  5696                                  	loop .loop		; loop for all process handles -->
  5697                                  %else		; new code re-using TSR terminate handling
  5698 000013E5 BA[C414]                	mov dx, .proceed
  5699 000013E8 E932FF                  	jmp qqlate.terminate_to_shim_process
  5700                                  
  5701                                  
  5702                                  	usesection lDEBUG_DATA_ENTRY
  5702          ------------------       note: usesection lDEBUG_DATA_ENTRY
  5703                                  .proceed:
  5704 000014C4 FA                      	cli
  5705 000014C5 8CC8                    	mov ax, cs
  5706 000014C7 8ED0                    	mov ss, ax
  5707 000014C9 BC[7010]                	mov sp, stack_end
  5708 000014CC 8ED8                    	mov ds, ax
  5709 000014CE FC                      	cld
  5710 000014CF FB                      	sti
  5711                                  
  5712 000014D0 E87CFF                  	call entry_to_code_seg
  5713 000014D3 [EB13]                  	dw .proceedcode
  5714                                  
  5715                                  
  5716                                  	usesection lDEBUG_CODE
  5716          ------------------       note: usesection lDEBUG_CODE
  5717                                  	code_insure_low_byte_not_0CCh
  5718                                  .proceedcode:
  5719                                  %endif
  5720                                  
  5721                                  %if _DEBUG
  5722                                  		; avoid hooking interrupts again:
  5723                                  	mov byte [cs:..@patch_tsr_quit_run], __JMP_REL16
  5724                                  				; (SMC in section lDEBUG_CODE)
  5725                                  %endif
  5726 000013EB F606[B414]01            	testopt [qq_mode], qqmode_b
  5727 000013F0 7406                    	jz @F
  5728 000013F2 C706[B80E][0000]        	mov word [reg_eip], entry_int3_retf
  5729                                  @@:
  5730 000013F8 E9(0000)                	jmp run			; run this
  5731                                  
  5732                                  
  5733                                  .mode_c:
  5734                                  qqlate_device_container:
  5735 000013FB 06                      	push es
  5736 000013FC C43E[B814]              	les di, [qq_device_prepare.device_reference]
  5737 00001400 8CC2                    	mov dx, es		; => device header pointing to ours
  5738 00001402 8CD0                    	mov ax, ss		; => process segment
  5739 00001404 83E804                  	sub ax, deviceshim_size_p + paras(10h)
  5740                                  				; span shim and pseudo MCB
  5741                                  		; ! ax is re-used in .handlecontainer
  5742 00001407 8EC0                    	mov es, ax		; => our device header
  5743 00001409 26FF360200              	push word [es:0 + 2]
  5744 0000140E 26FF360000              	push word [es:0]	; get our next link
  5745 00001413 8EC2                    	mov es, dx
  5746 00001415 268F05                  	pop word [es:di]
  5747 00001418 268F4502                	pop word [es:di + 2]	; update their next link
  5748 0000141C 8EC0                    	mov es, ax
  5749 0000141E 26830E0000FF            	or word [es:0], -1
  5750 00001424 26830E0200FF            	or word [es:0 + 2], -1	; de-initialise our next link
  5751 0000142A 07                      	pop es
  5752                                  
  5753 0000142B 31C9                    	xor cx, cx		; flag: do not shrink our allocation
  5754 0000142D 8B1E[BC14]              	mov bx, word [qq_device_prepare.container_segment]
  5755 00001431 85DB                    	test bx, bx		; are we in a container ?
  5756 00001433 7451                    	jz .nocontainer		; no -->
  5757                                  .handlecontainer:
  5758 00001435 0306[120E]              	add ax, word [device_mcb_paragraphs]
  5759                                  				; => behind our allocation
  5760 00001439 89C2                    	mov dx, ax
  5761 0000143B F7DA                    	neg dx
  5762 0000143D 0316[BE14]              	add dx, word [qq_device_prepare.container_end]
  5763                                  				; are we last in container ?
  5764 00001441 1E                      	push ds
  5765 00001442 8EDB                    	mov ds, bx		; => container
  5766                                  
  5767 00001444 7418                    	je .notrail		; yes, easier -->
  5768                                  
  5769 00001446 48                      	dec ax			; => last paragraph allocated to us
  5770                                  				;  (buffer for trailer container MCB)
  5771 00001447 8EC0                    	mov es, ax
  5772 00001449 31F6                    	xor si, si
  5773 0000144B 31FF                    	xor di, di
  5774                                  		; copy over MCB letter, owner, and name/type
  5775 0000144D B90800                  	mov cx, words(16)
  5776 00001450 F3A5                    	rep movsw
  5777 00001452 36C606[C014]4D          	mov byte [ss:qq_device_prepare.container_is_z], 'M'
  5778                                  				; tell subsequent handler to use 'M'
  5779 00001458 2689160300              	mov word [es:3], dx	; set new size
  5780 0000145D 41                      	inc cx			; flag: shrink our allocation
  5781                                  
  5782                                  .notrail:
  5783 0000145E E82B00                  	call .setowner
  5784 00001461 26290E0300              	sub word [es:3], cx	; -= 1 in case we have trail
  5785 00001466 36A0[C014]              	mov al, byte [ss:qq_device_prepare.container_is_z]
  5786 0000146A 26A20000                	mov byte [es:0], al	; set our letter to M or Z
  5787                                  				;  (Z only if container had Z and also
  5788                                  				;  there is no trailing container created)
  5789                                  
  5790 0000146E 29DA                    	sub dx, bx		; device mode MCB minus container MCB
  5791 00001470 4A                      	dec dx			; account for MCB paragraph to get MCB size
  5792 00001471 89160300                	mov word [3], dx	; adjust size
  5793 00001475 C60600004D              	mov byte [0], 'M'	; set M unconditionally
  5794 0000147A 85D2                    	test dx, dx		; size zero ?
  5795 0000147C 7504                    	jnz @F
  5796 0000147E 89160100                	mov word [1], dx	; yes, zero the owner too
  5797                                  @@:
  5798 00001482 1F                      	pop ds
  5799 00001483 E98BFE                  	jmp qqlate.appterminate
  5800                                  
  5801                                  .nocontainer:
  5802 00001486 E80300                  	call .setowner
  5803 00001489 E985FE                  	jmp qqlate.appterminate
  5804                                  
  5805                                  
  5806                                  		; INP:	ss = debugger process/data segment
  5807                                  		; OUT:	es = dx => our device mode MCB
  5808                                  		;	owner of this MCB set to our process
  5809                                  		; STT:	R86M
  5810                                  		; CHG:	-
  5811                                  .setowner:
  5812 0000148C 8CD2                    	mov dx, ss
  5813 0000148E 83EA05                  	sub dx, deviceshim_size_p + paras(10h + 10h)
  5814                                  				; span shim, pseudo MCB, actual MCB
  5815 00001491 8EC2                    	mov es, dx		; => device mode MCB
  5816 00001493 268C160100              	mov word [es:1], ss	; insure valid owner (must be our PSP)
  5817 00001498 C3                      	retn
  5818                                  %endif
  5819                                  
  5820                                  
  5821                                  %if (_APPLICATION && _TSR) || _DEVICE
  5822                                  	usesection lDEBUG_DATA_ENTRY
  5822          ------------------       note: usesection lDEBUG_DATA_ENTRY
  5823                                  
  5824                                  qq.proceedtsrtermination:
  5825 000014D5 FA                      	cli
  5826 000014D6 8CC8                    	mov ax, cs
  5827 000014D8 8ED0                    	mov ss, ax
  5828 000014DA BC[7010]                	mov sp, stack_end
  5829 000014DD 8ED8                    	mov ds, ax
  5830 000014DF FC                      	cld
  5831 000014E0 FB                      	sti
  5832 000014E1 832E[900E]12            	sub word [reg_esp], 2+4+((qq.tsrfreecode_size+1)&~1)
  5833 000014E6 8B3E[900E]              	mov di, word [reg_esp]	; -> stack frame
  5834 000014EA 8E06[A80E]              	mov es, word [reg_ss]
  5835 000014EE A1[A00E]                	mov ax, word [reg_ds]
  5836 000014F1 AB                      	stosw			; debuggee's ds
  5837 000014F2 A1[B80E]                	mov ax, word [reg_eip]
  5838 000014F5 AB                      	stosw
  5839 000014F6 A1[AC0E]                	mov ax, word [reg_cs]
  5840 000014F9 AB                      	stosw			; debuggee's cs:ip
  5841 000014FA 06                      	push es
  5842 000014FB 57                      	push di
  5843 000014FC BE[3815]                	mov si, qq.tsrfreecode
  5844 000014FF B90600                  	mov cx, ((qq.tsrfreecode_size+1)>>1)
  5845 00001502 F3A5                    	rep movsw		; code on stack
  5846 00001504 8CC8                    	mov ax, cs		; => process segment
  5847 00001506 48                      	dec ax			; span actual MCB
  5848                                  %if _DEVICE
  5849                                   %if _APPLICATION
  5850 00001507 F606[EE01]40            	testopt [internalflags6], dif6_device_mode
  5851 0000150C 7403                    	jz @F
  5852                                   %endif
  5853 0000150E 83E804                  	sub ax, deviceshim_size_p + paras(10h)
  5854                                  				; span shim + pseudo MCB
  5855                                  @@:
  5856                                  %endif
  5857 00001511 A3[A00E]                	mov word [reg_ds], ax	; = our MCB
  5858 00001514 8F06[B80E]              	pop word [reg_eip]
  5859 00001518 8F06[AC0E]              	pop word [reg_cs]	; -> code on stack (at int3)
  5860 0000151C F606[B414]01            	testopt [qq_mode], qqmode_b
  5861                                  				; QB mode ?
  5862 00001521 7504                    	jnz @F			; yes, leave pointing cs:ip at int3
  5863 00001523 FF06[B80E]              	inc word [reg_eip]	; point cs:ip past the int3
  5864                                  @@:
  5865 00001527 F606[AB01]80            	testopt [options3], opt3_tsr_quit_leave_tf
  5866 0000152C 7505                    	jnz @F
  5867 0000152E 8026[BD0E]FE            	clropt [reg_efl], 100h	; clear TF
  5868                                  @@:
  5869                                  
  5870 00001533 E819FF                  	call entry_to_code_seg
  5871 00001536 [9914]                  	dw .proceedtsrcode
  5872                                  
  5873                                  
  5874                                  	usesection lDEBUG_CODE
  5874          ------------------       note: usesection lDEBUG_CODE
  5875                                  
  5876                                  	code_insure_low_byte_not_0CCh
  5877                                  .proceedtsrcode:
  5878                                  %if _DEBUG
  5879                                  		; avoid hooking interrupts again:
  5880                                  	mov byte [cs:..@patch_tsr_quit_run], __JMP_REL16
  5881                                  				; (SMC in section lDEBUG_CODE)
  5882                                  %endif
  5883 00001499 E9(0000)                	jmp run			; run this
  5884                                  
  5885                                  
  5886                                  	usesection lDEBUG_DATA_ENTRY
  5886          ------------------       note: usesection lDEBUG_DATA_ENTRY
  5887                                  
  5888                                  	align 2, db 0
  5889                                  	; (Update: Explicitly clears TF now, except if the
  5890                                  	; option opt3_tsr_quit_leave_tf is set. See above.)
  5891                                  	;
  5892                                  	; Note that since we are in control of debuggee's TF and
  5893                                  	; reset it every time the debugger is entered, this code
  5894                                  	; will not be entered with TF set. It might be entered
  5895                                  	; with IF set and an interrupt might occur; the only harm
  5896                                  	; done then is that the interrupt handler has less stack
  5897                                  	; available. All flags must be preserved by this code.
  5898                                  qq.tsrfreecode:
  5899 00001538 CC                      	int3			; breakpoint for QB mode, 1 byte
  5900 00001539 C70601000000            	mov word [1], 0		; free the MCB
  5901 0000153F 1F                      	pop ds			; restore debuggee's ds
  5902 00001540 CA0C00                  	retf ((qq.tsrfreecode_size+1)&~1)	; jump
  5903                                  qq.tsrfreecode_size: equ $-qq.tsrfreecode
  5904                                  
  5905                                  
  5906                                  	usesection lDEBUG_CODE
  5906          ------------------       note: usesection lDEBUG_CODE
  5907                                  
  5908                                  		; INP:	ax => PSP segment to set as parent
  5909                                  		;	ss:dx -> entrypoint to set as PRA
  5910                                  qqlate.setparent:
  5911 0000149C A31600                  	mov word [16h], ax
  5912 0000149F 89160A00                	mov word [0Ah], dx
  5913 000014A3 8C160C00                	mov word [0Ah+2], ss
  5914 000014A7 C3                      	retn
  5915                                  %endif
  5916                                  
  5917                                  
  5918                                  	usesection lDEBUG_CODE
  5918          ------------------       note: usesection lDEBUG_CODE
  5919                                  
  5920                                  %if _BOOTLDR
  5921                                  qqlate.bootterminate:
  5922 000014A8 812E[900E]BE00          	sub word [reg_esp], 2*8+4+((qq.bootfreecode_size+1)&~1)
  5923 000014AE 8B3E[900E]              	mov di, word [reg_esp]	; -> stack frame
  5924 000014B2 8E06[A80E]              	mov es, word [reg_ss]
  5925 000014B6 A1[A00E]                	mov ax, word [reg_ds]
  5926 000014B9 AB                      	stosw
  5927 000014BA A1[A40E]                	mov ax, word [reg_es]
  5928 000014BD AB                      	stosw
  5929 000014BE A1[980E]                	mov ax, word [reg_esi]
  5930 000014C1 AB                      	stosw
  5931 000014C2 A1[9C0E]                	mov ax, word [reg_edi]
  5932 000014C5 AB                      	stosw
  5933 000014C6 A1[800E]                	mov ax, word [reg_eax]
  5934 000014C9 AB                      	stosw
  5935 000014CA A1[880E]                	mov ax, word [reg_ecx]
  5936 000014CD AB                      	stosw
  5937 000014CE A1[840E]                	mov ax, word [reg_ebx]
  5938 000014D1 AB                      	stosw
  5939 000014D2 A1[8C0E]                	mov ax, word [reg_edx]
  5940 000014D5 AB                      	stosw
  5941 000014D6 A1[B80E]                	mov ax, word [reg_eip]
  5942 000014D9 AB                      	stosw
  5943 000014DA A1[AC0E]                	mov ax, word [reg_cs]
  5944 000014DD AB                      	stosw			; debuggee's cs:ip
  5945 000014DE 06                      	push es
  5946 000014DF 57                      	push di
  5947 000014E0 1E                      	 push ds
  5948 000014E1 0E                      	  push cs
  5949 000014E2 1F                      	  pop ds		; => lDEBUG_CODE
  5950 000014E3 BE[5615]                	mov si, qq.bootfreecode
  5951 000014E6 B95500                  	mov cx, ((qq.bootfreecode_size+1)>>1)
  5952 000014E9 F3A5                    	rep movsw		; code on stack
  5953 000014EB 1F                      	 pop ds
  5954                                  
  5955 000014EC 16                      	 push ss
  5956 000014ED 07                      	 pop es
  5957                                  
  5958 000014EE A1[0000]                	mov ax, word [ boot_new_memsizekib ]
  5959 000014F1 B106                    	mov cl, 6
  5960 000014F3 D3E0                    	shl ax, cl		; ax => source of EBDA (new position)
  5961 000014F5 8B16[0000]              	mov dx, word [ boot_old_memsizekib ]
  5962 000014F9 D3E2                    	shl dx, cl		; dx => destination of EBDA (old position)
  5963 000014FB 31C9                    	xor cx, cx		; size of EBDA to move (if none)
  5964 000014FD 1E                      	push ds
  5965 000014FE 8ED9                    	mov ds, cx
  5966 00001500 8B1E0E04                	mov bx, word [40Eh]	; new ref in word [0:40Eh] (if none)
  5967 00001504 1F                      	pop ds
  5968 00001505 803E[0000]00            	cmp byte [ boot_ebdaflag ], 0	; any EBDA ?
  5969 0000150A 7412                    	jz .noebda
  5970                                  
  5971 0000150C 1E                      	push ds
  5972 0000150D 8ED8                    	mov ds, ax		; => EBDA
  5973 0000150F 31DB                    	xor bx, bx
  5974 00001511 8A1E0000                	mov bl, byte [ 0 ]	; EBDA size in KiB
  5975 00001515 B106                    	mov cl, 6
  5976 00001517 D3E3                    	shl bx, cl		; *64, to paragraphs
  5977 00001519 89D9                    	mov cx, bx		; = size of EBDA to move (in paragraphs)
  5978 0000151B 89D3                    	mov bx, dx		; = new EBDA reference to put in word [0:40Eh]
  5979 0000151D 1F                      	pop ds
  5980                                  
  5981                                  .noebda:
  5982 0000151E A3[800E]                	mov word [reg_eax], ax	; => relocated (new) EBDA position
  5983                                  				;  (in front of debugger image)
  5984 00001521 891E[840E]              	mov word [reg_ebx], bx	; = what to put in word [0:40Eh],
  5985                                  				;  unchanged content of that word if no EBDA
  5986 00001525 890E[880E]              	mov word [reg_ecx], cx	; = EBDA size, 0 if no EBDA
  5987 00001529 8916[8C0E]              	mov word [reg_edx], dx	; = original (old) EBDA position
  5988                                  				; = original mem size (in paras)
  5989                                  				;  (behind/in debugger image)
  5990 0000152D C706[A00E]0000          	mov word [reg_ds], 0
  5991                                  
  5992 00001533 8F06[B80E]              	pop word [reg_eip]
  5993 00001537 8F06[AC0E]              	pop word [reg_cs]	; -> code on stack
  5994 0000153B F606[B414]01            	testopt [qq_mode], qqmode_b
  5995                                  				; QB mode ?
  5996 00001540 7504                    	jnz @F			; yes, leave pointing cs:ip at int3
  5997 00001542 FF06[B80E]              	inc word [reg_eip]	; point cs:ip past the int3
  5998                                  @@:
  5999 00001546 F606[AB01]80            	testopt [options3], opt3_tsr_quit_leave_tf
  6000 0000154B 7505                    	jnz @F
  6001 0000154D 8026[BD0E]FE            	clropt [reg_efl], 100h	; clear TF
  6002                                  @@:
  6003                                  	; call dumpregs
  6004                                  %if _DEBUG
  6005                                  		; avoid hooking interrupts again:
  6006                                  	mov byte [cs:..@patch_tsr_quit_run], __JMP_REL16
  6007                                  				; (SMC in section lDEBUG_CODE)
  6008                                  %endif
  6009                                  	; jmp cmd3
  6010 00001552 E9(0000)                	jmp run			; run this
  6011                                  
  6012                                  
  6013 00001555 00                      	align 2, db 0
  6014                                  qq.bootfreecode:
  6015 00001556 CC                      	int3			; breakpoint for QB mode, 1 byte
  6016 00001557 9C                      	pushf
  6017 00001558 FA                      	cli
  6018 00001559 E81800                  	call movp		; move EBDA back (if any)
  6019 0000155C 891E0E04                	mov word [40Eh], bx	; back relocate EBDA (if any)
  6020 00001560 B106                    	mov cl, 6
  6021 00001562 D3EA                    	shr dx, cl		; = to KiB
  6022 00001564 89161304                	mov word [413h], dx	; back relocate mem size
  6023 00001568 9D                      	popf
  6024 00001569 1F                      	pop ds
  6025 0000156A 07                      	pop es
  6026 0000156B 5E                      	pop si
  6027 0000156C 5F                      	pop di
  6028 0000156D 58                      	pop ax
  6029 0000156E 59                      	pop cx
  6030 0000156F 5B                      	pop bx
  6031 00001570 5A                      	pop dx
  6032 00001571 CAAA00                  	retf ((qq.bootfreecode_size+1)&~1)
  6033                                  %endif
  6034                                  %endif	; !_LOADER
  6035                                  
  6036                                  
  6037                                  		; Move paragraphs
  6038                                  		;
  6039                                  		; INP:	ax:0-> source
  6040                                  		;	dx:0-> destination
  6041                                  		;	cx = number of paragraphs
  6042                                  		; CHG:	-
  6043                                  		; Note:	Doesn't work correctly on HMA; doesn't always wrap to LMA either.
  6044                                  		;	Do not provide a wrapped/HMA source or destination!
  6045                                  movp: section_of_function
  6046 00001574 51                      	push cx
  6047 00001575 1E                      	push ds
  6048 00001576 56                      	push si
  6049 00001577 06                      	push es
  6050 00001578 57                      	push di
  6051                                  
  6052 00001579 39D0                    	cmp ax, dx		; source above destination ?
  6053 0000157B 770A                    	ja .up			; yes, move up (forwards) -->
  6054 0000157D 747B                    	je .return		; same, no need to move -->
  6055 0000157F 50                      	push ax
  6056 00001580 01C8                    	add ax, cx		; (expected not to carry)
  6057 00001582 39D0                    	cmp ax, dx		; end of source is above destination ?
  6058 00001584 58                      	pop ax
  6059 00001585 7730                    	ja .down		; yes, move from top down -->
  6060                                  	; Here, the end of source is below-or-equal the destination,
  6061                                  	;  so they do not overlap. In this case we prefer moving up.
  6062                                  
  6063                                  .up:
  6064 00001587 50                      	push ax
  6065 00001588 52                      	push dx
  6066                                  .uploop:
  6067 00001589 8ED8                    	mov ds, ax
  6068 0000158B 8EC2                    	mov es, dx
  6069 0000158D 31FF                    	xor di, di
  6070 0000158F 31F6                    	xor si, si		; -> start of segment
  6071 00001591 81E90010                	sub cx, 1000h		; 64 KiB left ?
  6072 00001595 7610                    	jbe .uplast		; no -->
  6073 00001597 51                      	push cx
  6074 00001598 B90080                  	mov cx, 10000h /2
  6075 0000159B F3A5                    	rep movsw		; move 64 KiB
  6076 0000159D 59                      	pop cx
  6077 0000159E 050010                  	add ax, 1000h
  6078 000015A1 81C20010                	add dx, 1000h		; -> next segment
  6079 000015A5 EBE2                    	jmp short .uploop	; proceed for more -->
  6080                                  .uplast:
  6081 000015A7 81C10010                	add cx, 1000h		; restore counter
  6082 000015AB D1E1                    	shl cx, 1
  6083 000015AD D1E1                    	shl cx, 1
  6084 000015AF D1E1                    	shl cx, 1		; *8, paragraphs to words
  6085 000015B1 F3A5                    	rep movsw		; move last part
  6086 000015B3 5A                      	pop dx
  6087 000015B4 58                      	pop ax
  6088 000015B5 EB43                    	jmp short .return
  6089                                  
  6090                                  .down:
  6091 000015B7 FD                      	std			; _AMD_ERRATUM_109_WORKAROUND as below
  6092                                  .dnloop:
  6093 000015B8 81E90010                	sub cx, 1000h		; 64 KiB left ?
  6094 000015BC 761A                    	jbe .dnlast		; no -->
  6095 000015BE 50                      	push ax
  6096 000015BF 52                      	push dx
  6097 000015C0 01C8                    	add ax, cx
  6098 000015C2 01CA                    	add dx, cx
  6099 000015C4 8ED8                    	mov ds, ax		; -> 64 KiB not yet moved
  6100 000015C6 8EC2                    	mov es, dx
  6101 000015C8 5A                      	pop dx
  6102 000015C9 58                      	pop ax
  6103 000015CA BFFEFF                  	mov di, -2
  6104 000015CD 89FE                    	mov si, di		; moved from last word down
  6105 000015CF 51                      	push cx
  6106 000015D0 B90080                  	mov cx, 10000h /2
  6107 000015D3 F3A5                    	rep movsw		; move 64 KiB
  6108 000015D5 59                      	pop cx
  6109 000015D6 EBE0                    	jmp short .dnloop	; proceed for more -->
  6110                                  .dnlast:
  6111 000015D8 81C10010                	add cx, 1000h		; restore counter
  6112 000015DC D1E1                    	shl cx, 1
  6113 000015DE D1E1                    	shl cx, 1
  6114 000015E0 D1E1                    	shl cx, 1		; *8, paragraphs to words
  6115 000015E2 89CF                    	mov di, cx
  6116 000015E4 4F                      	dec di
  6117 000015E5 D1E7                    	shl di, 1		; words to offset, -> last word
  6118 000015E7 89FE                    	mov si, di
  6119 000015E9 8ED8                    	mov ds, ax
  6120 000015EB 8EC2                    	mov es, dx		; first segment correct
  6121                                  
  6122                                  
  6123                                  	numdef AMD_ERRATUM_109_WORKAROUND, 1
  6124                                  		; Refer to comment in init.asm init_movp.
  6125                                  
  6126                                  %if _AMD_ERRATUM_109_WORKAROUND
  6127 000015ED E308                    	jcxz @FF
  6128 000015EF 83F914                  	cmp cx, 20
  6129 000015F2 7703                    	ja @FF
  6130                                  @@:
  6131 000015F4 A5                      	movsw
  6132 000015F5 E2FD                    	loop @B
  6133                                  @@:
  6134                                  %endif
  6135 000015F7 F3A5                    	rep movsw		; move first part
  6136 000015F9 FC                      	cld
  6137                                  .return:
  6138 000015FA 5F                      	pop di
  6139 000015FB 07                      	pop es
  6140 000015FC 5E                      	pop si
  6141 000015FD 1F                      	pop ds
  6142 000015FE 59                      	pop cx
  6143 000015FF C3                      	retn
  6144                                  %if !_LOADER && _BOOTLDR
  6145                                  qq.bootfreecode_size: equ $-qq.bootfreecode
  6146                                  %endif
  6147                                  
  6148                                  
  6149                                  %if (_CATCHINTFAULTCOND && _CATCHINT0D) 	|| (_CATCHINTFAULTCOND && _CATCHINT0C) 	|| _CATCHINT08 || _CATCHINT2D || _PM 	|| 1	; (serial)
  6153                                  		; INP:	ds:si -> IISP entry
  6154                                  		;	al = interrupt number
  6155                                  		;	dx = interrupt unhook force flag (dif4 high word)
  6156                                  		;	bx = interrupt hook status flag (dif4 low word)
  6157                                  		;	cx = letters to insert into message
  6158                                  		;	bp = number of interrupts already unable to unhook
  6159                                  		; OUT:	NC if able to unhook or not currently hooked
  6160                                  		;	CY if currently hooked and unable to unhook,
  6161                                  		;	 error message displayed
  6162                                  		;	 bp incremented
  6163                                  		; CHG:	es, dx, ah, di
  6164                                  qq_int_unhook_sim.set_bx_to_dx:
  6165 00001600 89D3                    	mov bx, dx
  6166                                  
  6167                                  qq_int_unhook_sim:
  6168 00001602 851E[E401]              	test word [internalflags4], bx
  6169 00001606 7413                    	jz .ret			; (NC)
  6170                                  
  6171                                  .need:
  6172 00001608 E8(0000)                	call UnhookInterruptForceSim
  6173                                  				; try unhooking it
  6174 0000160B 16                      	push ss
  6175 0000160C 07                      	pop es
  6176 0000160D 730C                    	jnc .ret
  6177                                  
  6178 0000160F 890E[0000]              	mov word [msg.serial_cannot_unhook.int], cx
  6179 00001613 BA[0000]                	mov dx, msg.serial_cannot_unhook.nowarn
  6180 00001616 E8(0000)                	call putsz
  6181 00001619 45                      	inc bp
  6182 0000161A F9                      	stc
  6183                                  
  6184                                  .ret:
  6185 0000161B C3                      	retn
  6186                                  %endif
  6187                                  
  6188                                  
  6189                                  %if (_CATCHINTFAULTCOND && _CATCHINT0D) 	|| (_CATCHINTFAULTCOND && _CATCHINT0C) 	|| _CATCHINT08 || _CATCHINT2D || _PM
  6192                                  		; INP:	al = interrupt number
  6193                                  		;	ds:si -> IISP entry
  6194                                  		;	dx = interrupt unhook force flag (dif4 high word)
  6195                                  		;	bx = interrupt hook status flag (dif4 low word)
  6196                                  		;	cx = text to insert into error message
  6197                                  		; OUT:	CY if is hooked and error unhooking,
  6198                                  		;	 dx -> error message
  6199                                  		;	NC if not hooked now (already wasn't or have unhooked),
  6200                                  		;	 ZR if was already unhooked
  6201                                  		;	 NZ if has been unhooked, was hooked
  6202                                  qq_int_unhook_real.set_bx_to_dx:
  6203 0000161C 89D3                    	mov bx, dx
  6204                                  
  6205                                  qq_int_unhook_real:
  6206 0000161E 851E[E401]              	test word [internalflags4], bx
  6207 00001622 7419                    	jz .ret			; --> (NC, ZR)
  6208                                  
  6209                                  .need:
  6210 00001624 E8(0000)                	call UnhookInterruptForce
  6211                                  				; try unhooking it
  6212 00001627 7309                    	jnc .unhooked
  6213                                  
  6214 00001629 890E[0000]              	mov word [msg.serial_cannot_unhook.int], cx
  6215 0000162D BA[0000]                	mov dx, msg.serial_cannot_unhook.nowarn
  6216 00001630 F9                      	stc
  6217 00001631 C3                      	retn
  6218                                  
  6219                                  .unhooked:
  6220 00001632 F7D3                    	not bx
  6221 00001634 211E[E401]              	and word [internalflags4], bx
  6222 00001638 E8(0000)                	call update_inttab_optional
  6223 0000163B 85E4                    	test sp, sp		; (NC, NZ)
  6224                                  .ret:
  6225 0000163D C3                      	retn
  6226                                  %endif
  6227                                  
  6228                                  
  6229                                   %ifn _LINK || _LINK_COMPAT
  6230                                  %include "ss.asm"
  6231                                   %endif
  6232                                  
  6233                                  
  6234                                  	usesection lDEBUG_CODE
  6234          ------------------       note: usesection lDEBUG_CODE
  6235                                  
  6236                                  %if 0
  6237                                  getdebuggeebyte:
  6238                                  	push bp
  6239                                  	mov bp, sp
  6240                                  	sub sp, byte 4
  6241                                  	push bx
  6242                                  	push cx
  6243                                  %define _dedata -4
  6244                                  %define _bp 0
  6245                                  %define _ip 2
  6246                                  %define _adroffset 4
  6247                                  %define _adrsegment 8
  6248                                  	test byte [], memorydump
  6249                                  	jz .realmemory
  6250                                  
  6251                                  	jmp short .return
  6252                                  .realmemory32:
  6253                                  .realmemory:
  6254                                  	mov ax, word [ bp + _adrsegment ]
  6255                                  	mov bx, word [ bp + _adroffset ]
  6256                                  	push ds
  6257                                  	mov ds, ax
  6258                                  	push word [ bx ]
  6259                                  	pop word [ bp + _dedata ]
  6260                                  	push word [ bx +2 ]
  6261                                  	pop word [ bp + _dedata +2 ]
  6262                                  	pop ds
  6263                                  ;	test ax, ax
  6264                                  ;	jnz .return
  6265                                  	mov dx, ax
  6266                                  	mov cl, 4
  6267                                  	shl ax, cl
  6268                                  	mov cl, 12
  6269                                  	shr dx, cl
  6270                                  	add ax, bx
  6271                                  	adc dx, byte 0
  6272                                  	jnz .return
  6273                                  	sub ax, 23h*4
  6274                                  	jb .return
  6275                                  	cmp ax, 2*4
  6276                                  	jae .return
  6277                                  
  6278                                  	push ds
  6279                                  	xor bx, bx
  6280                                  	mov ds, bx
  6281                                  	push si
  6282                                  	push di
  6283                                  	mov si, 22h*4
  6284                                  	mov di, hackints.dummy22
  6285                                  	movsw
  6286                                  	movsw
  6287                                  	mov bl, 8
  6288                                  	add si, bx
  6289                                  	add di, bx
  6290                                  	movsw
  6291                                  	movsw
  6292                                  
  6293                                  	mov cl, byte [ bx - 4 + hackints2324 ]
  6294                                  	mov byte [ bp + _dedata ], cl
  6295                                  .return:
  6296                                  	pop cx
  6297                                  	pop bx
  6298                                  	pop ax
  6299                                  	pop dx
  6300                                  	pop bp
  6301                                  	retn 6
  6302                                  
  6303                                  
  6304                                  		; Interrupt hack table
  6305                                  		;
  6306                                  		; This contains the Int23 and Int24 handler we want to show
  6307                                  		; the user. As we'll retrieve a dword per access,
  6308                                  	align 4, db 0
  6309                                  hackints:
  6310                                  .dummy22:	dd 0
  6311                                  .23:		dd 0
  6312                                  .24:		dd 0
  6313                                  .dummy25:	dd 0
  6314                                  %endif
  6315                                  
  6316                                  
  6317                                   %ifn _LINK || _LINK_COMPAT
  6318                                  %if !_LOADER
  6319                                  %include "ww.asm"
  6320                                  %endif
  6321                                   %endif
  6322                                  
  6323                                  
  6324                                  	usesection lDEBUG_CODE
  6324          ------------------       note: usesection lDEBUG_CODE
  6325                                  
  6326                                  %ifn _EMS
  6327                                  xx: equ error
  6328                                  %else
  6329                                   %define extcall nearcall
  6330                                   %define extcallcall nearcall
  6331                                   %imacro internalcoderelocation 0-*.nolist
  6332                                   %endmacro
  6333                                   %imacro internaldatarelocation 0-*.nolist
  6334                                   %endmacro
  6335                                   %imacro linkdatarelocation 0-*.nolist
  6336                                   %endmacro
  6337                                   %define relocated(address) address
  6338                                   %assign ELD 0
  6339                                  
  6340                                   %include "xxshared.asm"
  6341                                  
  6342                                   %undef extcall
  6343                                   %undef extcallcall
  6344                                   %unimacro internalcoderelocation 0-*.nolist
  6345                                   %unimacro internaldatarelocation 0-*.nolist
  6346                                   %unimacro linkdatarelocation 0-*.nolist
  6347                                   %undef relocated
  6348                                  %endif	; _EMS
  6349                                  
  6350                                  %if _DUALCODE
  6351                                  	usesection lDEBUG_CODE2
  6351          ------------------       note: usesection lDEBUG_CODE2
  6352                                  error_mirror:
  6353 000000B3 E874FF[3E16]            	dualcall error
  6354                                  
  6355                                  	usesection lDEBUG_CODE
  6355          ------------------       note: usesection lDEBUG_CODE
  6356                                  %else
  6357                                  error_mirror equ error
  6358                                  %endif
  6359                                  
  6360                                  %ifn _EXPRDUALCODE && _DUALCODE
  6361                                  %if _LINK
  6362                                  error_expr: equ error
  6363                                  %endif
  6364                                  %endif
  6365                                  
  6366                                  		; Error handlers.
  6367                                  dualfunction
  6368                                  error: section_of_function
  6369 0000163E 16                      	push ss
  6370 0000163F 07                      	pop es
  6371 00001640 16                      	push ss
  6372 00001641 1F                      	pop ds
  6373                                  %if _RH
  6374 00001642 8026[EE01]CF            	clropt [internalflags6], dif6_rh_mode_2 | dif6_rh_mode
  6375                                  %endif
  6376                                  
  6377                                  %if _EXTENSIONS && _EXT_PUTS_GETLINE
  6378 00001647 B304                    	mov bl, 4
  6379                                  		; INP:	bl = 4 means want to get effective carat position,
  6380                                  		;	 si -> text with error
  6381                                  		;	bl = 5 means want to get carat position with
  6382                                  		;	 si = input value for counter
  6383                                  		; OUT:	bl == 4 if to run default handling,
  6384                                  		;	 si may be modified
  6385                                  		;	bl == 5 if to use si as number of spaces to indent,
  6386                                  		;	 si = value for counter
  6387                                  		;	bl must be 4 or 5
  6388                                  		; CHG:	ax, bh, cx, dx, di
  6389                                  		; STT:	ds = es = ss
  6390                                  		;	UP, EI
  6391 00001649 E8(0000)                	call transfer_to_ext_puts_getline
  6392 0000164C 89F1                    	mov cx, si
  6393 0000164E 80FB04                  	cmp bl, 4
  6394 00001651 7511                    	jne .gotcx
  6395                                  %else
  6396                                  	mov cx, si
  6397                                  %endif
  6398 00001653 81E9[1300]              	sub cx, line_in+3
  6399 00001657 81F90001                	cmp cx, 256
  6400 0000165B 7705                    	ja .invalid
  6401 0000165D 030E[E40C]              	add cx, word [promptlen]; number of spaces to skip
  6402 00001661 A9                      	db __TEST_IMM16		; (skip xor)
  6403                                  .invalid:
  6404 00001662 31C9                    	xor cx, cx		; if we're really messed up
  6405                                  .gotcx:
  6406 00001664 8B26[6A0C]              	mov sp, [throwsp]
  6407 00001668 FF26[680C]              	jmp near [throwret]
  6408                                  		; INP:	cx = number of spaces to indent
  6409                                  
  6410                                  		; This is the default address in throwret.
  6411                                  		; Display the error, then jump to errret.
  6412                                  errhandler:
  6413 0000166C E8(0000)                	call get_columns	; ax = columns
  6414                                  .:
  6415 0000166F 29C1                    	sub cx, ax
  6416 00001671 73FC                    	jnc .
  6417 00001673 01C1                    	add cx, ax
  6418 00001675 7407                    	jz err2
  6419 00001677 B020                    	mov al, 32
  6420                                  .loop:
  6421 00001679 E8(0000)                	call putc
  6422 0000167C E2FB                    	loop .loop
  6423                                  err2:
  6424 0000167E BA[0000]                	mov dx, errcarat
  6425 00001681 E8(0000)                	call putsz		; print string
  6426 00001684 B8FF01                  	mov ax, 01FFh
  6427 00001687 E80A00                  	call setrc
  6428 0000168A C706[D20D][B105]        	mov word [lastcmd], dmycmd
  6429                                  				; cancel command repetition
  6430 00001690 FF26[660C]              	jmp near [errret]	; return to the prompt (cmd3, aa01)
  6431                                  
  6432                                  
  6433                                  setrc: section_of_function
  6434 00001694 833E[EC0C]00            	cmp word [rc], 0
  6435 00001699 7503                    	jne .ret
  6436 0000169B A3[EC0C]                	mov word [rc], ax
  6437                                  .ret:
  6438 0000169E C3                      	retn
  6439                                  
  6440                                  
  6441                                  %if !_LOADER
  6442                                  		; Terminate the attached process, if any
  6443                                  		;
  6444                                  		; OUT:	NZ if now no process attached
  6445                                  		;	ZR if still a process attached,
  6446                                  		;	 ie we failed to terminate this one
  6447                                  terminate_attached_process:
  6448 0000169F F606[DA01]80            	testopt [internalflags], attachedterm
  6449 000016A4 754A                    	jnz @F
  6450                                  %if _TSR && (_APPLICATION || _DEVICE)
  6451 000016A6 F606[DA01]40            	testopt [internalflags], tsrmode
  6452 000016AB 7544                    	jnz .tsr
  6453                                  %endif
  6454 000016AD 8026[BD0E]FC            	clropt [reg_efl], 300h	; clear TF and IF
  6455 000016B2 8C0E[AC0E]              	mov word [reg_cs], cs
  6456 000016B6 C706[B80E][9213]        	mov word [reg_eip], terminate_00
  6457 000016BC 50                      	 push ax		; (dummy to take space for return address)
  6458 000016BD 8C16[A80E]              	mov word [reg_ss], ss
  6459 000016C1 8926[900E]              	mov word [reg_esp], sp	; save current ss:sp
  6460 000016C5 58                      	 pop ax			; (discard)
  6461 000016C6 31C0                    	xor ax, ax
  6462 000016C8 A3[BA0E]                	mov word [reg_eip+2], ax
  6463 000016CB A3[920E]                	mov word [reg_esp+2], ax
  6464 000016CE A3[BE0E]                	mov word [reg_efl+2], ax
  6465                                  %if _PM
  6466 000016D1 A3[A40E]                	mov word [reg_es], ax
  6467 000016D4 A3[A00E]                	mov word [reg_ds], ax
  6468 000016D7 A3[B00E]                	mov word [reg_fs], ax
  6469 000016DA A3[B40E]                	mov word [reg_gs], ax	; insure valid segregs in PM
  6470                                  %endif
  6471 000016DD C706[700C]8000          	mov word [run_sp_reserve], 128
  6472 000016E3 E8(0000)                	call run
  6473                                  		; The dummy stack space above is to hold the return address
  6474                                  		; of this call. The debugger stack is used by this run.
  6475 000016E6 8326[700C]00            	and word [run_sp_reserve], 0
  6476                                  
  6477                                  %if _SYMBOLIC
  6478                                  	nearcall zz_detect_xms
  6479                                  	clropt [internalflags2], dif2_createdprocess
  6480                                  %endif
  6481                                  .testagain:
  6482 000016EB F606[DA01]80            	testopt [internalflags], attachedterm
  6483                                  @@:
  6484 000016F0 C3                      	retn
  6485                                  
  6486                                  %if _TSR && (_APPLICATION || _DEVICE)
  6487                                  .tsr:
  6488 000016F1 C706[D00D][0000]        	mov word [run_int], msg.tsr_cannot_terminate_attached
  6489 000016F7 EBF2                    	jmp .testagain
  6490                                  %endif
  6491                                  %endif
  6492                                  
  6493                                  
  6494                                   %ifn _LINK || _LINK_COMPAT
  6495                                  %include "vv.asm"
  6496                                   %endif
  6497                                  %if !_VXCHG && _LINK
  6498                                  vv equ error
  6499                                  %endif
  6500                                  
  6501                                  
  6502                                  %if _DEVICE && _DEVICE_SET_2324
  6503                                  	usesection lDEBUG_DATA_ENTRY
  6503          ------------------       note: usesection lDEBUG_DATA_ENTRY
  6504                                  devint23:
  6505 00001543 F9                      	stc
  6506 00001544 CB                      	retf
  6507                                  
  6508                                  devint24:
  6509 00001545 B003                    	mov al, 3
  6510 00001547 CF                      	iret
  6511                                  
  6512                                  	usesection lDEBUG_CODE
  6512          ------------------       note: usesection lDEBUG_CODE
  6513                                  %endif
  6514                                  
  6515                                  
  6516                                  ;--- this is called by "run"
  6517                                  ;--- set debuggee's INT 23/24.
  6518                                  ;--- don't use INT 21h here, DOS might be "in use".
  6519                                  ;--- registers may be modified - will soon be set to debuggee's
  6520                                  
  6521                                  %if !_LOADER
  6522                                  		; Low-level functions to reset to debuggee's interrupt vectors 23h/24h
  6523                                  		; INP:	-
  6524                                  		; OUT:	-
  6525                                  		; CHG:	bx, (e)dx, cx, ax
  6526                                  		; STT:	ds = our segment
  6527                                  		;	Do not use Int21, even if not in InDOS mode
  6528                                  setint2324:
  6529                                  %if _BOOTLDR
  6530                                   %if _APPLICATION || _DEVICE
  6531 000016F9 F606[D901]40            	testopt [internalflags], nodosloaded
  6532 000016FE 7521                    	jnz .ret		; don't touch int23/24 -->
  6533                                   %else
  6534                                  	retn
  6535                                   %endif
  6536                                  %endif
  6537                                  %if _APPLICATION || _DEVICE
  6538                                  %if _PM
  6539 00001700 E89AF2                  	call ispm
  6540 00001703 741D                    	jz .pm
  6541                                  %endif
  6542 00001705 06                      	push es
  6543 00001706 57                      	push di
  6544 00001707 56                      	push si
  6545                                  
  6546 00001708 31FF                    	xor di, di
  6547 0000170A 8EC7                    	mov es, di
  6548 0000170C BF8C00                  	mov di, 23h *4
  6549 0000170F BE[780C]                	mov si, run2324
  6550 00001712 A5                      	movsw
  6551 00001713 A5                      	movsw
  6552 00001714 A5                      	movsw
  6553 00001715 A5                      	movsw
  6554                                  
  6555                                  %if _PM
  6556 00001716 E83001                  	call InDOS
  6557 00001719 7503                    	jnz @F
  6558 0000171B E85B04                  	call hook2F
  6559                                  @@:
  6560                                  %endif
  6561 0000171E 5E                      	pop si
  6562 0000171F 5F                      	pop di
  6563 00001720 07                      	pop es
  6564                                  .ret:
  6565 00001721 C3                      	retn
  6566                                  %if _PM
  6567                                  .pm:
  6568 00001722 56                      	push si
  6569 00001723 BE[780C]                	mov si, run2324
  6570 00001726 BB2302                  	mov bx, 0223h
  6571                                  .loop:
  6572 00001729 66                      	_386_o32		; mov edx, dword [si+0]
  6573 0000172A 8B14                    	mov dx, word [si+0]
  6574 0000172C 8B4C04                  	mov cx, word [si+4]
  6575 0000172F B80502                  	mov ax, 0205h
  6576 00001732 CD31                    	int 31h
  6577 00001734 83C606                  	add si, 6
  6578 00001737 FEC3                    	inc bl
  6579 00001739 FECF                    	dec bh
  6580 0000173B 75EC                    	jnz .loop
  6581 0000173D 5E                      	pop si
  6582 0000173E C3                      	retn
  6583                                  %endif
  6584                                  %endif
  6585                                  
  6586                                  
  6587                                  		; Low-level functions to save debuggee's interrupt vectors 23h/24h
  6588                                  		;  and set our interrupt vectors instead
  6589                                  		; INP:	-
  6590                                  		; OUT:	-
  6591                                  		; CHG:	-
  6592                                  		; STT:	ds = our segment
  6593                                  		;	Do not use Int21, even if not in InDOS mode
  6594                                  getint2324:
  6595                                  %if _BOOTLDR
  6596                                   %if _APPLICATION || _DEVICE
  6597 0000173F F606[D901]40            	testopt [internalflags], nodosloaded
  6598 00001744 752A                    	jnz .ret		; don't touch int23/24 -->
  6599                                   %else
  6600                                  	retn
  6601                                   %endif
  6602                                  %endif
  6603                                  %if _APPLICATION || _DEVICE
  6604                                  %if _PM
  6605 00001746 E854F2                  	call ispm
  6606 00001749 7426                    	jz .pm
  6607                                  %endif
  6608 0000174B 56                      	push si
  6609 0000174C 57                      	push di
  6610 0000174D 06                      	push es
  6611                                  
  6612 0000174E 1E                      	push ds
  6613 0000174F 07                      	pop es
  6614 00001750 31FF                    	xor di, di
  6615 00001752 8EDF                    	mov ds, di
  6616 00001754 BF[780C]                	mov di, run2324
  6617 00001757 BE8C00                  	mov si, 23h *4
  6618 0000175A 56                      	push si
  6619 0000175B A5                      	movsw			; save interrupt vector 23h
  6620 0000175C A5                      	movsw
  6621 0000175D A5                      	movsw			; save interrupt vector 24h
  6622 0000175E A5                      	movsw
  6623 0000175F 5F                      	pop di
  6624 00001760 06                      	push es
  6625 00001761 1F                      	pop ds
  6626 00001762 31F6                    	xor si, si
  6627 00001764 8EC6                    	mov es, si
  6628 00001766 BE0E00                  	mov si, CCIV
  6629 00001769 A5                      	movsw
  6630 0000176A A5                      	movsw
  6631 0000176B A5                      	movsw
  6632 0000176C A5                      	movsw
  6633                                  
  6634 0000176D 07                      	pop es
  6635 0000176E 5F                      	pop di
  6636 0000176F 5E                      	pop si
  6637                                  .ret:
  6638 00001770 C3                      	retn
  6639                                  %if _PM
  6640                                  subcpu 286
  6641                                  .pm:
  6642 00001771 66                      	_386_o32
  6643 00001772 60                      	pusha
  6644 00001773 BF[780C]                	mov di, run2324
  6645 00001776 BB2302                  	mov bx, 0223h
  6646                                  .loop:
  6647 00001779 B80402                  	mov ax, 0204h
  6648 0000177C CD31                    	int 31h
  6649 0000177E 66                      	_386_o32		; mov dword [di+0], edx
  6650 0000177F 8915                    	mov word [di+0], dx
  6651 00001781 894D04                  	mov word [di+4], cx
  6652 00001784 83C706                  	add di, byte 6
  6653 00001787 FEC3                    	inc bl
  6654 00001789 FECF                    	dec bh
  6655 0000178B 75EC                    	jnz .loop
  6656                                  %if _ONLYNON386
  6657                                  	db __TEST_IMM8		; (skip pusha)
  6658                                  %else
  6659 0000178D A9                      	db __TEST_IMM16		; (skip pushad)
  6660                                  %endif
  6661                                  
  6662                                  restoredbgi2324:
  6663                                  setdbgi2324:
  6664 0000178E 66                      	_386_o32
  6665 0000178F 60                      	pusha
  6666 00001790 BE[840C]                	mov si, dbg2324
  6667 00001793 BB2302                  	mov bx, 0223h
  6668 00001796 6631D2                  _386	xor edx, edx
  6669                                  .loop:
  6670 00001799 AD                      	lodsw
  6671 0000179A 89C2                    	mov dx, ax
  6672 0000179C 8B0E[0000]              	mov cx, word [cssel]
  6673 000017A0 B80502                  	mov ax, 0205h
  6674 000017A3 CD31                    	int 31h
  6675 000017A5 FEC3                    	inc bl
  6676 000017A7 FECF                    	dec bh
  6677 000017A9 75EE                    	jnz .loop
  6678 000017AB 66                      	_386_o32
  6679 000017AC 61                      	popa
  6680 000017AD C3                      	retn
  6681                                  subcpureset
  6682                                  %endif
  6683                                  %endif
  6684                                  
  6685                                  %if 0
  6686                                  The next three subroutines concern the handling of Int23 and 24.
  6687                                  These interrupt vectors are saved and restored when running the
  6688                                  child process, but are not active when DEBUG itself is running.
  6689                                  It is still useful for the programmer to be able to check where Int23
  6690                                  and 24 point, so these values are copied into the interrupt table
  6691                                  during parts of the C, D, (DX, DI,) E, M, and S commands, so that
  6692                                  they appear to be in effect. The E command also copies these values
  6693                                  back.
  6694                                  
  6695                                  Between calls to dohack and unhack, there should be no calls to DOS,
  6696                                  so that there is no possibility of these vectors being used when
  6697                                  DEBUG itself is running.
  6698                                  
  6699                                  ; As long as no DOS is loaded anyway, Int23 and Int24 won't be touched
  6700                                  by us, so the whole hack is unnecessary and will be skipped.
  6701                                  %endif
  6702                                  
  6703                                  		; PREPHACK - Set up for interrupt vector substitution.
  6704                                  		; Entry	es = cs
  6705                                  prephack: section_of_function
  6706 000017AE 803E[940C]00            	cmp byte [hakstat], 0
  6707 000017B3 7509                    	jne .err		; if hack status error -->
  6708 000017B5 57                      	push di
  6709 000017B6 BF[8C0C]                	mov di, sav2324		; debugger's Int2324
  6710 000017B9 E80B00                  	call prehak1
  6711 000017BC 5F                      	pop di
  6712 000017BD C3                      	retn
  6713                                  
  6714                                  .err:
  6715 000017BE 52                      	push dx
  6716 000017BF BA[0000]                	mov dx, ph_msg
  6717 000017C2 E8(0000)                	call putsz		; display error
  6718 000017C5 5A                      	pop dx
  6719 000017C6 C3                      	retn
  6720                                  
  6721                                  		; INP:	di-> saved interrupt vectors
  6722                                  		; OUT:	-
  6723                                  		; CHG:	-
  6724                                  prehak1:
  6725                                  %if _PM
  6726 000017C7 E8D3F1                  	call ispm
  6727 000017CA 740F                    	jz .pm			; nothing to do
  6728                                  %endif
  6729 000017CC 1E                      	push ds
  6730 000017CD 56                      	push si
  6731 000017CE 31F6                    	xor si, si
  6732 000017D0 8EDE                    	mov ds, si
  6733 000017D2 BE8C00                  	mov si, 23h *4
  6734 000017D5 A5                      	movsw
  6735 000017D6 A5                      	movsw
  6736 000017D7 A5                      	movsw
  6737 000017D8 A5                      	movsw
  6738 000017D9 5E                      	pop si
  6739 000017DA 1F                      	pop ds
  6740                                  .pm:
  6741 000017DB C3                      	retn
  6742                                  
  6743                                  
  6744                                  		; DOHACK - Fake the interrupt vectors 23h and 24h to debuggee's
  6745                                  		; UNHACK - Restore interrupt vectors 23h and 24h to our values
  6746                                  		;	It's OK to do either of these twice in a row.
  6747                                  		;	In particular, the S command may do unhack twice in a row.
  6748                                  		; INP:	ds = our segment
  6749                                  		; OUT:	es = our segment
  6750                                  		; CHG:	-
  6751                                  		; STT:	Do not use Int21
  6752                                  dohack: section_of_function
  6753 000017DC 16                      	push ss
  6754 000017DD 07                      	pop es
  6755                                  %if _BOOTLDR
  6756                                   %if _APPLICATION || _DEVICE
  6757 000017DE F606[D901]40            	testopt [internalflags], nodosloaded
  6758 000017E3 7555                    	jnz unhack.ret		; nothing to hack -->
  6759                                   %else
  6760                                  	retn
  6761                                   %endif
  6762                                  %endif
  6763                                  %if _APPLICATION || _DEVICE
  6764 000017E5 56                      	push si
  6765 000017E6 C606[940C]01            	mov byte [hakstat], 1
  6766 000017EB BE[780C]                	mov si, run2324		; debuggee's interrupt vectors
  6767                                  %if _PM
  6768 000017EE E8ACF1                  	call ispm
  6769 000017F1 7537                    	jnz unhack.common
  6770                                  subcpu 286
  6771 000017F3 66                      	_386_o32
  6772 000017F4 60                      	pusha
  6773 000017F5 BB2302                  	mov bx, 0223h
  6774                                  .pm_loop:
  6775 000017F8 66                      	_386_o32
  6776 000017F9 8B14                    	mov dx, word [si+0+0]
  6777 000017FB 8B4C04                  	mov cx, word [si+0+4]
  6778 000017FE B80502                  	mov ax, 205h
  6779 00001801 CD31                    	int 31h
  6780 00001803 83C606                  	add si, byte 6
  6781 00001806 FEC3                    	inc bl
  6782 00001808 FECF                    	dec bh
  6783 0000180A 75EC                    	jnz .pm_loop
  6784 0000180C 66                      	_386_o32
  6785 0000180D 61                      	popa
  6786 0000180E 5E                      	pop si
  6787 0000180F C3                      	retn
  6788                                  subcpureset
  6789                                  %else
  6790                                  	jmp short unhack.common
  6791                                  %endif
  6792                                  %endif
  6793                                  
  6794                                  unhack: section_of_function
  6795 00001810 16                      	push ss
  6796 00001811 07                      	pop es
  6797                                  %if _BOOTLDR
  6798                                   %if _APPLICATION || _DEVICE
  6799 00001812 F606[D901]40            	testopt [internalflags], nodosloaded
  6800 00001817 7521                    	jnz .ret		; nothing to hack -->
  6801                                   %else
  6802                                  	retn
  6803                                   %endif
  6804                                  %endif
  6805                                  %if _APPLICATION || _DEVICE
  6806 00001819 C606[940C]00            	mov byte [hakstat], 0
  6807                                  %if _PM
  6808 0000181E E87CF1                  	call ispm
  6809 00001821 7503E968FF              	jz restoredbgi2324
  6810                                  %endif
  6811 00001826 56                      	push si
  6812 00001827 BE[8C0C]                	mov si, sav2324		; debugger's interrupt vectors
  6813                                  .common:
  6814 0000182A 57                      	push di
  6815 0000182B 06                      	push es
  6816 0000182C 31FF                    	xor di, di
  6817 0000182E 8EC7                    	mov es, di
  6818 00001830 BF8C00                  	mov di, 23h *4
  6819 00001833 A5                      	movsw
  6820 00001834 A5                      	movsw
  6821 00001835 A5                      	movsw
  6822 00001836 A5                      	movsw
  6823 00001837 07                      	pop es
  6824 00001838 5F                      	pop di
  6825 00001839 5E                      	pop si
  6826                                  .ret:
  6827 0000183A C3                      	retn
  6828                                  %endif
  6829                                  %endif
  6830                                  
  6831                                  %if _LOADER
  6832                                  prephack: section_of_function
  6833                                  dohack: section_of_function
  6834                                  unhack: section_of_function
  6835                                  	retn
  6836                                  %endif
  6837                                  
  6838                                  
  6839                                  InDOS_or_BIOS_output:
  6840 0000183B F606[B501]02            	testopt [options6], opt6_bios_output
  6841 00001840 7525                    	jnz InDOS.return	; if should do output to ROM-BIOS -->
  6842                                  
  6843                                  InDOS_or_BIOS_IO:
  6844 00001842 F606[B701]01            	testopt [options6], opt6_bios_io
  6845 00001847 751E                    	jnz InDOS.return	; if should do I/O from/to ROM-BIOS -->
  6846                                  
  6847                                  
  6848                                  		; OUT:	NZ if InDOS mode
  6849                                  		;	ZR if not
  6850                                  		; CHG:	-
  6851                                  		; STT:	ss = ds
  6852                                  InDOS: section_of_function
  6853                                  %if _BOOTLDR
  6854 00001849 F606[D901]40            	testopt [internalflags], nodosloaded
  6855 0000184E 7517                    	jnz .return		; always "in DOS" -->
  6856                                  %endif
  6857                                   %if _APPLICATION || _DEVICE
  6858 00001850 F606[A001]08            	testopt [options], fakeindos
  6859 00001855 7510                    	jnz .return		; faking InDOS on anyway -->
  6860                                  .real_indos:
  6861 00001857 1E                      	push ds
  6862 00001858 56                      	push si
  6863 00001859 BE[A40C]                	mov si, pInDOS + so16aSegSel
  6864 0000185C E80900                  	call update_dosdata_segment
  6865 0000185F C574FE                  	lds si, [si - so16aSegSel]
  6866 00001862 803C00                  	cmp byte [si], 0
  6867 00001865 5E                      	pop si
  6868 00001866 1F                      	pop ds
  6869                                   %endif
  6870                                  .return:
  6871 00001867 C3                      	retn
  6872                                  
  6873                                  
  6874                                  		; INP:	si -> word seg or sel, word segment, word selector
  6875                                  update_dosdata_segment:
  6876                                  %if _APPLICATION || _DEVICE
  6877 00001868 F606[DF01]20            	testopt [internalflags2], dif2_int31_segment
  6878 0000186D 742C                    	jz .ret
  6879 0000186F 52                      	push dx
  6880 00001870 50                      	push ax
  6881 00001871 53                      	push bx
  6882 00001872 B031                    	mov al, 31h
  6883 00001874 E8(0000)                	call get_86m_interrupt_handler_no_dos
  6884                                  %if _PM
  6885 00001877 395402                  	cmp word [si + soaSegment], dx
  6886 0000187A 7419                    	je @F
  6887                                  
  6888 0000187C E81EF1                  	call ispm
  6889 0000187F 750E                    	jnz .realmode
  6890                                  
  6891 00001881 89D3                    	mov bx, dx
  6892 00001883 B80200                  	mov ax, 0002h
  6893 00001886 CD31                    	int 31h
  6894                                  
  6895 00001888 8904                    	mov word [si + soaSegSel], ax
  6896 0000188A 894404                  	mov word [si + soaSelector], ax
  6897 0000188D EB06                    	jmp @F
  6898                                  
  6899                                  .realmode:
  6900 0000188F 8914                    	mov word [si + soaSegSel], dx
  6901 00001891 83640400                	and word [si + soaSelector], 0
  6902                                  
  6903                                  @@:
  6904 00001895 895402                  	mov word [si + soaSegment], dx
  6905 00001898 5B                      	pop bx
  6906 00001899 58                      	pop ax
  6907                                  %else
  6908                                  	pop bx
  6909                                  	pop ax
  6910                                  	mov word [si + soaSegSel], dx
  6911                                  %endif
  6912 0000189A 5A                      	pop dx
  6913                                  %endif
  6914                                  .ret:
  6915 0000189B C3                      	retn
  6916                                  
  6917                                  
  6918                                  ;	PARSECM - Parse command line for C and M commands.
  6919                                  ;	Entry	AL		First nonwhite character of parameters
  6920                                  ;		SI		Address of the character after that
  6921                                  ;		DI		(If _PM) getaddr or getaddrX for second parameter
  6922                                  ;	Exit	DS:ESI		Address from first parameter
  6923                                  ;		ES:EDI		Address from second parameter
  6924                                  ;		ECX		Length of address range minus one
  6925                                  ;		[bAddr32]	Set if any high word non-zero
  6926                                  
  6927                                  parsecm_have_address:
  6928 0000189C E809F0[0000]            	nearcall getrangeX_have_address_need_length
  6929 000018A1 EB0E                    	jmp @F
  6930                                  
  6931                                  parsecm:
  6932 000018A3 E808FF                  	call prephack
  6933 000018A6 8B1E[A00E]              	mov bx, word [reg_ds]	; get source range
  6934 000018AA 31C9                    	xor cx, cx
  6935 000018AC E8F9EF[0000]            	nearcall getrangeX	; get address range into bx:(e)dx bx:(e)cx
  6936                                  		; Bug fixed in Debug/X 2.00: This used the same scratch
  6937                                  		;  selector as the getaddr used for the second operand.
  6938                                  		; As we never write to the first operand of an C or M
  6939                                  		;  command the simple fix is to use getrangeX here.
  6940                                  @@:
  6941 000018B1 53                      	push bx			; save segment first address
  6942 000018B2 E8(0000)                	call skipcomm0
  6943 000018B5 8B1E[A00E]              	mov bx, word [reg_ds]
  6944 000018B9 66                      	_386_PM_o32	; sub ecx, edx
  6945 000018BA 29D1                    	sub cx, dx		; number of bytes minus one
  6946 000018BC 66                      	_386_PM_o32	; push edx
  6947 000018BD 52                      	push dx
  6948 000018BE 66                      	_386_PM_o32	; push ecx
  6949 000018BF 51                      	push cx
  6950                                  %if _PM
  6951 000018C0 8A0E[0000]              	mov cl, byte [bAddr32]
  6952 000018C4 51                      	push cx
  6953                                  %if _DUALCODE && _EXPRDUALCODE
  6954 000018C5 E8E0EF[B800]            	nearcall ..@parsecm_getaddr
  6955                                  
  6956                                  	usesection lDEBUG_CODE2
  6956          ------------------       note: usesection lDEBUG_CODE2
  6957                                  ..@parsecm_getaddr: section_of_function
  6958 000000B8 FFE7                    	jmp di
  6959                                  
  6960                                  	usesection lDEBUG_CODE
  6960          ------------------       note: usesection lDEBUG_CODE
  6961                                  %else
  6962                                  	call di			; get destination address into bx:edx
  6963                                  %endif
  6964 000018CA 59                      	pop cx
  6965 000018CB 080E[0000]              	or byte [bAddr32], cl	; if either is 32-bit, handle both as 32-bit
  6966                                  %else
  6967                                  	nearcall getaddr	; get destination address into bx:dx
  6968                                  %endif
  6969 000018CF 66                      	_386_PM_o32
  6970 000018D0 59                      	pop cx		; pop ecx
  6971 000018D1 66                      	_386_PM_o32	; mov edi, edx
  6972 000018D2 89D7                    	mov di, dx
  6973 000018D4 66                      	_386_PM_o32
  6974 000018D5 01CA                    	add dx, cx	; add edx, ecx
  6975 000018D7 7209                    	jc short errorj7	; if it wrapped around
  6976 000018D9 E8(0000)                	call chkeol		; expect end of line
  6977 000018DC 8EC3                    	mov es, bx
  6978 000018DE 66                      	_386_PM_o32	; pop esi
  6979 000018DF 5E                      	pop si
  6980 000018E0 1F                      	pop ds
  6981 000018E1 C3                      	retn
  6982                                  
  6983                                  errorj7:
  6984 000018E2 E959FD                  	jmp error
  6985                                  
  6986                                  
  6987                                  %if _APPLICATION || _DEVICE
  6988                                  ;	PARSELW - Parse command line for L and W commands.
  6989                                  ;
  6990                                  ;	Entry	AL	First nonwhite character of parameters
  6991                                  ;		SI	Address of the character after that
  6992                                  ;
  6993                                  ;	Exit	If there is at most one argument (program load/write), then the
  6994                                  ;		zero flag is set, and registers are set as follows:
  6995                                  ;		bx:(e)dx	Transfer address
  6996                                  ;
  6997                                  ;		If there are more arguments (absolute disk read/write), then the
  6998                                  ;		zero flag is clear, and registers are set as follows:
  6999                                  ;
  7000                                  ;		DOS versions prior to 3.31:
  7001                                  ;		AL	Drive number
  7002                                  ;		CX	Number of sectors to read
  7003                                  ;		DX	Beginning logical sector number
  7004                                  ;		DS:BX	Transfer address
  7005                                  ;
  7006                                  ;		Later DOS versions:
  7007                                  ;		AL	Drive number
  7008                                  ;		BX	Offset of packet
  7009                                  ;		CX	0FFFFh
  7010                                  
  7011                                  	usesection lDEBUG_DATA_ENTRY
  7011          ------------------       note: usesection lDEBUG_DATA_ENTRY
  7012                                  	align 4, db 0
  7013 00001548 00000000                packet:	dd 0		; sector number
  7014 0000154C 0000                    	dw 0		; number of sectors to read
  7015 0000154E 00000000                	dd 0		; transfer address Segm:OOOO
  7016                                  %if _PM
  7017 00001552 0000                    	dw 0		; transfer address might be Segm:OOOOOOOO!
  7018                                  %endif
  7019                                  
  7020                                  	usesection lDEBUG_CODE
  7020          ------------------       note: usesection lDEBUG_CODE
  7021                                  parselw:
  7022 000018E5 8B1E[AC0E]              	mov bx, word [reg_cs]	; default segment
  7023 000018E9 66                      	_386_o32	; xor edx, edx
  7024 000018EA 31D2                    	xor dx, dx
  7025 000018EC F606[D80D]08            	test byte [fileext], EXT_HEX
  7026 000018F1 7502                    	jnz @F			; if .HEX file, default offset is 0 -->
  7027 000018F3 B601                    	mov dh, 1		; default offset in dx = 100h
  7028                                  @@:
  7029 000018F5 E8(0000)                	call iseol?
  7030 000018F8 7473                    	je plw2			; if no arguments
  7031 000018FA E8ABEF[0000]            	nearcall getaddr	; get buffer address into bx:(e)dx
  7032 000018FF E8(0000)                	call skipcomm0
  7033 00001902 E8(0000)                	call iseol?
  7034 00001905 7466                    	je plw2			; if only one argument
  7035 00001907 53                      	push bx			; save segment
  7036 00001908 52                      	push dx			; save offset
  7037 00001909 BB8000                  	mov bx, 80h		; max number of sectors to read
  7038 0000190C F7DA                    	neg dx
  7039 0000190E 7406                    	jz plw1			; if address is zero
  7040 00001910 B109                    	mov cl, 9
  7041 00001912 D3EA                    	shr dx, cl		; max number of sectors which can be read
  7042 00001914 89D7                    	mov di, dx
  7043                                  plw1:
  7044 00001916 803C3A                  	cmp byte [si], ':'	; drive letter specification ?
  7045 00001919 750F                    	jne @F			; no -->
  7046                                  
  7047 0000191B 50                      	push ax
  7048 0000191C E8(0000)                	call capitalise
  7049 0000191F 2C41                    	sub al, 'A'
  7050 00001921 3C20                    	cmp al, 32		; valid drive ?
  7051 00001923 88C2                    	mov dl, al		; put drive number
  7052 00001925 46                      	inc si			; -> past the colon
  7053 00001926 58                      	pop ax
  7054 00001927 7207                    	jb @FF			; got it -->
  7055 00001929 4E                      	dec si			; -> at colon
  7056                                  
  7057                                  @@:
  7058 0000192A E87BEF[0000]            	nearcall getbyte	; get drive number (DL)
  7059 0000192F A8                      	db __TEST_IMM8		; (skip lodsb)
  7060                                  @@:
  7061 00001930 AC                      	lodsb
  7062 00001931 E8(0000)                	call skipcomm0
  7063 00001934 52                      	push dx
  7064 00001935 80C241                  	add dl, 'A'
  7065 00001938 8816[0000]              	mov byte [driveno], dl
  7066 0000193C E869EF[0000]            	nearcall getdword	; get relative sector number
  7067 00001941 E8(0000)                	call skipcomm0
  7068 00001944 53                      	push bx			; save sector number high
  7069 00001945 52                      	push dx			; save sector number low
  7070 00001946 56                      	push si			; in case we find an error
  7071 00001947 E85EEF[0000]            	nearcall getword	; get sector count
  7072 0000194C 4A                      	dec dx
  7073 0000194D 39FA                    	cmp dx, di
  7074 0000194F 7391                    	jae errorj7		; if too many sectors
  7075 00001951 42                      	inc dx
  7076 00001952 89D1                    	mov cx, dx
  7077 00001954 E8(0000)                	call chkeol		; expect end of line
  7078 00001957 F606[D801]07            	testopt [internalflags], oldpacket| newpacket| ntpacket
  7079 0000195C 7510                    	jnz plw3		; if using a packet -->
  7080 0000195E 5E                      	pop si			; in case of error
  7081 0000195F 5A                      	pop dx			; get LoWord starting logical sector number
  7082 00001960 5B                      	pop bx			; get HiWord
  7083 00001961 85DB                    	test bx, bx		; just a 16-bit sector number possible
  7084 00001963 7403E97AFF              	jnz errorj7		; if too big
  7085 00001968 58                      	pop ax			; drive number
  7086 00001969 5B                      	pop bx			; transfer buffer ofs
  7087 0000196A 1F                      	pop ds			; transfer buffer seg
  7088 0000196B 85C9                    	test cx, cx		; NZ
  7089                                  plw2:
  7090 0000196D C3                      	retn
  7091                                  
  7092                                  		; disk I/O packet for Int25/Int26, Int21.7305, VDD
  7093                                  plw3:
  7094 0000196E 5B                      	pop bx			; discard si
  7095 0000196F BB[4815]                	mov bx, packet
  7096 00001972 8F07                    	pop word [bx+0]		; LoWord sector number
  7097 00001974 8F4702                  	pop word [bx+2]		; HiWord sector number
  7098 00001977 894F04                  	mov word [bx+4], cx	; number of sectors
  7099 0000197A 58                      	pop ax			; drive number
  7100 0000197B 8F4706                  	pop word [bx+6]		; transfer address ofs
  7101 0000197E 5A                      	pop dx
  7102 0000197F 31C9                    	xor cx, cx
  7103                                  %if _PM
  7104 00001981 E819F0                  	call ispm
  7105 00001984 751B                    	jnz plw3_1
  7106 00001986 803E[0000]00            	cmp byte [dpmi32], 0
  7107 0000198B 7414                    	jz plw3_1
  7108                                  [cpu 386]
  7109 0000198D 89570A                  	mov word [bx+10], dx	; save segment of transfer buffer
  7110 00001990 660FB7DB                	movzx ebx, bx
  7111 00001994 66C1EA10                	shr edx, 16		; get HiWord(offset)
  7112 00001998 803E[0000]01            	cmp byte [bAddr32], 1
  7113 0000199D 7402                    	jz plw3_1
  7114 0000199F 31D2                    	xor dx, dx
  7115                                  __CPU__
  7116                                  plw3_1:
  7117                                  %endif
  7118 000019A1 895708                  	mov word [bx+8], dx	; transfer address seg
  7119 000019A4 49                      	dec cx			; NZ and make cx = -1
  7120 000019A5 C3                      	retn
  7121                                  %endif
  7122                                  
  7123                                  
  7124                                   %ifn _LINK || _LINK_COMPAT
  7125                                  %include "expr.asm"
  7126                                  %include "rr.asm"
  7127                                  
  7128                                  
  7129                                  %include "lineio.asm"
  7130                                  
  7131                                  
  7132                                  %include "ints.asm"
  7133                                   %endif
  7134                                  %if !_40COLUMNS && _LINK
  7135                                  puts_break_line_more: equ dmycmd
  7136                                  %endif
  7137                                  
  7138                                  
  7139                                  	usesection lDEBUG_CODE
  7139          ------------------       note: usesection lDEBUG_CODE
  7140                                  
  7141                                  %if _BOOTLDR
  7142                                  		; Determine the amount of actual memory
  7143                                  		;
  7144                                  		; This is important to call at the time we need the size,
  7145                                  		; not just save the size initially. Loading other pre-boot
  7146                                  		; installers or RPLs will change the size.
  7147                                  		;
  7148                                  		; INP:	-
  7149                                  		; OUT:	dx = segment behind usable memory (taking EBDAs & RPLs into account)
  7150                                  		;	ds = ss
  7151                                  		; CHG:	ax, cx, di, si, ds
  7152                                  bootgetmemorysize: section_of_function
  7153 000019A6 06                      	push es
  7154 000019A7 31C0                    	xor ax, ax
  7155 000019A9 8ED8                    	mov ds, ax
  7156 000019AB CD12                    	int 12h					; get memory size in KiB
  7157 000019AD B106                    	mov cl, 6
  7158 000019AF D3E0                    	shl ax, cl				; *64, convert to paragraphs
  7159 000019B1 50                      	push ax
  7160 000019B2 C536BC00                	lds si, [ 2Fh *4 ]			; get current Int2F
  7161 000019B6 46                      	inc si					; pointer valid (not 0FFFFh) ? (left increased!)
  7162 000019B7 741B                    	jz .norpl				; no -->
  7163 000019B9 8CD8                    	mov ax, ds
  7164 000019BB 85C0                    	test ax, ax				; segment valid (not zero) ?
  7165 000019BD 7415                    	jz .norpl				; no -->
  7166 000019BF 46<rep 2h>              	times 2 inc si				; +3 with above inc
  7167 000019C1 0E                      	push cs
  7168 000019C2 07                      	pop es
  7169 000019C3 BF[D919]                	mov di, .rpl
  7170 000019C6 B90300                  	mov cx, .rpl_size
  7171 000019C9 F3A6                    	repe cmpsb				; "RPL" signature ?
  7172 000019CB 7507                    	jne .norpl				; no -->
  7173 000019CD 5A                      	pop dx
  7174 000019CE B8064A                  	mov ax, 4A06h
  7175 000019D1 CD2F                    	int 2Fh					; adjust usable memory size for RPL
  7176 000019D3 A8                      	db __TEST_IMM8				; (skip pop)
  7177                                  .norpl:
  7178 000019D4 5A                      	pop dx
  7179                                  		; dx = segment behind last available memory
  7180 000019D5 16                      	 push ss
  7181 000019D6 1F                      	 pop ds
  7182 000019D7 07                      	pop es
  7183 000019D8 C3                      	retn
  7184                                  
  7185 000019D9 52504C                  .rpl:	db "RPL"
  7186                                  	endarea .rpl
  7187                                  %endif
  7188                                  
  7189                                  
  7190                                  %if !_LOADER
  7191                                  		; Ensure a debuggee process is loaded
  7192                                  		;
  7193                                  		; INP:	si:di = to preserve if have a process already
  7194                                  		; OUT:	NZ if have no process and unable to create process
  7195                                  		;	ZR if have a process or created empty process
  7196                                  		;	NC if had no process yet, created one or not
  7197                                  		;	CY if had a process already,
  7198                                  		;	 si:di = preserved input
  7199                                  		;	NC, ZR if had no process, created empty one,
  7200                                  		;	 si:di = debuggee cs:ip
  7201                                  		;	NC, NZ if int19 occurred (or bootloaded)
  7202                                  		; CHG:	si, di, cx
  7203                                  ensuredebuggeeloaded:
  7204 000019DC 50                      	push ax
  7205 000019DD 53                      	push bx
  7206 000019DE 52                      	push dx
  7207                                  
  7208 000019DF F606[E201]20            	testopt [internalflags3], dif3_gotint19
  7209 000019E4 746F                    	jz .notint19
  7210                                  
  7211 000019E6 8026[E201]DF            	clropt [internalflags3], dif3_gotint19
  7212                                  %if _BOOTLDR
  7213                                   %if _APPLICATION || _DEVICE
  7214 000019EB F606[D901]40            	testopt [internalflags], nodosloaded
  7215 000019F0 743B                    	jz .dosint19
  7216                                   %endif
  7217                                  
  7218                                  .bootint19:
  7219 000019F2 E86E01                  	call zeroregs
  7220                                  
  7221 000019F5 B86000                  	mov ax, 60h
  7222 000019F8 50                      	push ax
  7223 000019F9 BF[A00E]                	mov di, reg_ds
  7224 000019FC AB                      	stosw
  7225 000019FD AF                      	scasw			; (skip dummy high word)
  7226 000019FE AB                      	stosw
  7227 000019FF AF                      	scasw
  7228 00001A00 AB                      	stosw
  7229 00001A01 AF                      	scasw
  7230 00001A02 AB                      	stosw
  7231 00001A03 E8(0000)                	call adusetup
  7232 00001A06 E89DFF                  	call bootgetmemorysize
  7233 00001A09 83EA60                  	sub dx, 60h
  7234 00001A0C 81FA0010                	cmp dx, 1000h
  7235 00001A10 7602                    	jbe .bootbelow64kib	; if memory left <= 64 KiB
  7236 00001A12 31D2                    	xor dx, dx		; dx = 1000h (same thing, after shifting)
  7237                                  .bootbelow64kib:
  7238 00001A14 B104                    	mov cl, 4
  7239 00001A16 D3E2                    	shl dx, cl
  7240 00001A18 4A                      	dec dx
  7241 00001A19 4A                      	dec dx
  7242 00001A1A 8916[900E]              	mov word [reg_esp], dx
  7243 00001A1E 07                      	pop es
  7244 00001A1F 87D7                    	xchg dx, di		; es:di = child stack pointer
  7245 00001A21 31C0                    	xor ax, ax
  7246 00001A23 AB                      	stosw			; push 0 on client's stack
  7247                                  
  7248 00001A24 26C7060000CD19          	mov word [es:0], 019CDh	; place opcode for int 19h at cs:ip
  7249 00001A2B EB1B                    	jmp @F
  7250                                  %endif
  7251                                  
  7252                                   %if _APPLICATION || _DEVICE
  7253                                  .dosint19:
  7254 00001A2D 8B16[900E]              	mov dx, word [reg_esp]
  7255 00001A31 8B1E[A80E]              	mov bx, word [reg_ss]
  7256                                  
  7257 00001A35 E82B01                  	call zeroregs
  7258                                  
  7259                                  		; Upon receiving an int 19h in DOS
  7260                                  		;  just set up some shim that will
  7261                                  		;  lead to process termination.
  7262                                  		; Unlike before we do not longer try
  7263                                  		;  to create a new process then.
  7264 00001A38 8916[900E]              	mov word [reg_esp], dx
  7265 00001A3C 891E[A80E]              	mov word [reg_ss], bx	; preserve our stack
  7266 00001A40 FF36[740C]              	push word [pspdbe]
  7267 00001A44 8F06[AC0E]              	pop word [reg_cs]	; cs = PSP, ip = 0,
  7268                                  				;  cs:ip -> int 20h instruction
  7269                                  
  7270                                  @@:
  7271 00001A48 F606[DA01]80            	testopt [internalflags], attachedterm
  7272 00001A4D 7511                    	jnz .noprocess		; if also process not loaded
  7273                                  
  7274 00001A4F 80CA01                  	or dl, 1		; flags return NC, NZ
  7275 00001A52 E9FE00                  	jmp .return
  7276                                   %endif
  7277                                  
  7278                                  .notint19:
  7279 00001A55 F606[DA01]80            	testopt [internalflags], attachedterm
  7280 00001A5A 7504                    	jnz .noprocess		; not loaded, create -->
  7281                                  				; flags return ZR
  7282 00001A5C F9                      	stc			; flags return CY
  7283 00001A5D E9F300                  	jmp .return
  7284                                  
  7285                                  .noprocess:
  7286                                  %if _BOOTLDR
  7287                                   %if _APPLICATION || _DEVICE
  7288 00001A60 F606[D901]40            	testopt [internalflags], nodosloaded
  7289 00001A65 7403E9E900              	jnz .return		; flags return NC, NZ
  7290                                   %else
  7291                                  	jmp .return
  7292                                   %endif
  7293                                  %endif
  7294                                  
  7295                                   %if _APPLICATION || _DEVICE
  7296                                  .dosnoprocess:
  7297 00001A6A B448                    	mov ah, 48h		; get size of largest free block
  7298 00001A6C BBFFFF                  	mov bx, -1
  7299 00001A6F CD21                    	int 21h
  7300 00001A71 83FB20                  	cmp bx, 20h		; enough for PSP + 256 Bytes for code/stack ?
  7301 00001A74 7303E9E000              	jb .return_no_clr	; no -->
  7302 00001A79 B448                    	mov ah, 48h		; allocate it
  7303 00001A7B CD21                    	int 21h
  7304 00001A7D 7303E9D700              	jc .return_no_clr	; (memory taken between the calls)
  7305                                  
  7306 00001A82 50                      	push ax
  7307 00001A83 E8DD00                  	call zeroregs
  7308 00001A86 C606[B90E]01            	mov byte [reg_eip+1], 100h>>8
  7309 00001A8B 58                      	pop ax
  7310                                  
  7311 00001A8C 53                      	push bx
  7312                                  %if _SYMBOLIC
  7313                                  	push bx
  7314                                  %endif
  7315 00001A8D BF[A00E]                	mov di, reg_ds		; fill segment registers ds,es,ss,cs
  7316 00001A90 AB                      	stosw
  7317 00001A91 AF                      	scasw			; (skip dummy high word)
  7318 00001A92 AB                      	stosw
  7319 00001A93 AF                      	scasw
  7320 00001A94 AB                      	stosw
  7321 00001A95 AF                      	scasw
  7322 00001A96 AB                      	stosw
  7323 00001A97 E8(0000)                	call adusetup
  7324 00001A9A 8B1E[AC0E]              	mov bx, word [reg_cs]	; bx:dx = where to load program
  7325 00001A9E 8EC3                    	mov es, bx
  7326 00001AA0 58                      	pop ax			; get size of memory block
  7327 00001AA1 89C2                    	mov dx, ax
  7328 00001AA3 01DA                    	add dx, bx
  7329 00001AA5 2689160200              	mov word [es:ALASAP], dx
  7330 00001AAA 50                      	push ax
  7331 00001AAB 3D0010                  	cmp ax, 1000h
  7332 00001AAE 7602                    	jbe .below64kib		; if memory left <= 64 KiB
  7333 00001AB0 31C0                    	xor ax, ax		; ax = 1000h (same thing, after shifting)
  7334                                  .below64kib:
  7335 00001AB2 B104                    	mov cl, 4
  7336 00001AB4 D3E0                    	shl ax, cl
  7337 00001AB6 48                      	dec ax
  7338 00001AB7 48                      	dec ax
  7339 00001AB8 A3[900E]                	mov word [reg_esp], ax
  7340 00001ABB 97                      	xchg ax, di		; es:di = child stack pointer
  7341 00001ABC 31C0                    	xor ax, ax
  7342 00001ABE AB                      	stosw			; push 0 on client's stack
  7343                                  
  7344                                  		; Create a PSP
  7345 00001ABF B455                    	mov ah, 55h		; create child PSP
  7346 00001AC1 8CC2                    	mov dx, es
  7347 00001AC3 268B360200              	mov si, word [es:ALASAP]
  7348 00001AC8 F8                      	clc			; works around OS/2 bug
  7349 00001AC9 CD21                    	int 21h
  7350 00001ACB 2689360200              	mov word [es:ALASAP], si
  7351 00001AD0 E8D5EE                  	call setpspdbg		; reset PSP to ours
  7352 00001AD3 E8(0000)                	call ll_copy_cmdline_and_fcbs
  7353 00001AD6 58                      	pop ax
  7354                                  
  7355 00001AD7 1E                      	push ds
  7356 00001AD8 06                      	 push es
  7357 00001AD9 1F                      	 pop ds
  7358 00001ADA 3DFF0F                  	cmp ax, 0FFFh
  7359 00001ADD 7603                    	jbe @F
  7360 00001ADF B8FF0F                  	mov ax, 0FFFh		; 0FFFh for large blocks
  7361                                  @@:
  7362 00001AE2 83E810                  	sub ax, 10h		; cannot underflow because block is >= 110h Bytes
  7363                                  				; at most 0FEFh
  7364 00001AE5 BB0C00                  	mov bx, 0Ch
  7365 00001AE8 29C3                    	sub bx, ax		; 000Ch - 00FEFh = 0F01Dh
  7366 00001AEA B104                    	mov cl, 4
  7367 00001AEC D3E0                    	shl ax, cl		; 0FEF0h
  7368                                  		; call far 0F01Dh:0FEF0h = 1000C0h
  7369                                  		; This is either the same as 0C0h if A20 masked, or in the HMA.
  7370 00001AEE C60605009A              	mov byte [CPMCALL], 09Ah; call far imm:imm opcode
  7371 00001AF3 A30600                  	mov word [CPMCALL + 1], ax
  7372 00001AF6 891E0800                	mov word [CPMCALL + 3], bx	; adjusted CALL 5 dispatcher
  7373                                  
  7374 00001AFA BA8000                  	mov dx, 80h
  7375 00001AFD B41A                    	mov ah, 1Ah		; set DTA to default DTA
  7376 00001AFF CD21                    	int 21h
  7377 00001B01 1F                      	pop ds
  7378                                  
  7379                                  		; Finish up. Set termination address.
  7380 00001B02 B82225                  	mov ax, 2522h		; set interrupt vector 22h
  7381 00001B05 BA[0000]                	mov dx, int22
  7382 00001B08 CD21                    	int 21h
  7383 00001B0A 2689160A00              	mov word [es:TPIV], dx
  7384 00001B0F 268C1E0C00              	mov word [es:TPIV+2], ds
  7385                                  
  7386 00001B14 26C6060001C3            	mov byte [es:100h], 0C3h	; place opcode for retn at cs:ip
  7387                                  
  7388                                  %if _SYMBOLIC
  7389                                  	pop bx				; size of memory block
  7390                                  %endif
  7391 00001B1A 8C06[740C]              	mov word [pspdbe], es
  7392 00001B1E 8CC0                    	mov ax, es
  7393 00001B20 48                      	dec ax
  7394 00001B21 8EC0                    	mov es, ax
  7395 00001B23 40                      	inc ax
  7396 00001B24 26C70608004445          	mov word [es:8+0], "DE"
  7397 00001B2B 26C7060A004255          	mov word [es:8+2], "BU"
  7398 00001B32 26C7060C004747          	mov word [es:8+4], "GG"
  7399 00001B39 26C7060E004545          	mov word [es:8+6], "EE"	; set MCB name
  7400 00001B40 26A30100                	mov word [es:1], ax	; set MCB owner
  7401                                  
  7402                                  %if _SYMBOLIC
  7403                                  	setopt [internalflags2], dif2_createdprocess
  7404                                  	mov word [created_psp], ax
  7405                                  	mov word [created_size], bx
  7406                                  %endif
  7407                                  
  7408 00001B44 8B36[AC0E]              	mov si, word [reg_cs]
  7409 00001B48 8B3E[B80E]              	mov di, word [reg_eip]		; ? is this ever used ?
  7410                                  
  7411 00001B4C 8026[DA01]7F            	clropt [internalflags], attachedterm
  7412 00001B51 38C0                    	cmp al, al			; flags return ZR, NC
  7413                                   %endif
  7414                                  
  7415                                  .return:
  7416                                  @@:
  7417 00001B53 16                      	push ss
  7418 00001B54 07                      	pop es
  7419                                  
  7420 00001B55 5A                      	pop dx
  7421 00001B56 5B                      	pop bx
  7422 00001B57 58                      	pop ax
  7423 00001B58 C3                      	retn
  7424                                  
  7425                                  .return_no_clr:
  7426 00001B59 BA[0000]                	mov dx, msg.ensure_no_memory
  7427 00001B5C E8(0000)                	call putsz
  7428 00001B5F 85D2                    	test dx, dx			; flags return NZ, NC
  7429 00001B61 EBF0                    	jmp .return
  7430                                  %endif
  7431                                  
  7432                                  
  7433                                  zeroregs:
  7434                                  	; call set_efl_to_fl	; initialise EFL, and ax = 0
  7435                                  ; set_efl_to_fl:
  7436 00001B63 31C0                    	xor ax, ax		; initialise ax = 0 and FL = ZR NC etc
  7437 00001B65 50                      _no386	push ax			; dummy high word
  7438 00001B66 66                      	_386_o32	; pushfd
  7439 00001B67 9C                      	pushf
  7440 00001B68 8F06[BC0E]              	pop word [reg_efl]	; set to FL
  7441 00001B6C 8F06[BE0E]              	pop word [reg_efl+2]	; set to high word of EFL, or zero
  7442                                  	; retn
  7443                                  
  7444 00001B70 BF[800E]                	mov di, regs
  7445 00001B73 B91E00                  	mov cx, 15 * 2		; (8 standard + 6 segregs + eip) * 2
  7446 00001B76 F3AB                    	rep stosw		; initialise all registers
  7447 00001B78 C3                      	retn
  7448                                  
  7449                                  
  7450                                  %if _PM
  7451                                  		; Hook Int2F if a DPMI host is found. However for Win9x and DosEmu
  7452                                  		; Int2F.1687 is not hooked because it doesn't work. Debugging in
  7453                                  		; protected mode may still work, but the initial switch must be
  7454                                  		; single-stepped.
  7455                                  		;
  7456                                  		; CHG:	ah, bx, cx, dx, di, es
  7457                                  		; OUT:	al = 0FFh if installed
  7458                                  		;	al = status value 0F0h..0FEh else
  7459                                  		; STT:	V86/RM
  7460                                  		;	ds = debugger data segment
  7461                                  		;	! might be called with unknown ss
  7462                                  		;	  if [internalflags6] & dif6_in_amis_hook2F
  7463                                  hook2F:
  7464 00001B79 E8CDFC                  	call InDOS
  7465 00001B7C B0FE                    	mov al, 0FEh
  7466 00001B7E 7403E9A800              	jnz .return
  7467                                  %if _APPLICATION || _DEVICE
  7468                                  .not_in_dos:
  7469 00001B83 B0FD                    	mov al, 0FDh
  7470 00001B85 F606[D901]01            	testopt [internalflags], hooked2F
  7471 00001B8A 7403E99C00              	jnz .return		; don't hook now -->
  7472 00001B8F 48                      	dec ax			; 0FCh
  7473                                   %if _DEBUG
  7474                                  	testopt [internalflags6], dif6_in_hook2F
  7475                                  	jnz .return
  7476                                   %endif
  7477                                  .loop:
  7478                                   %if _GUARD_86M_INT2F
  7479 00001B90 06                      	push es
  7480 00001B91 31C0                    	xor ax, ax
  7481 00001B93 8EC0                    	mov es, ax		; (only used in 86 Mode)
  7482 00001B95 26A1BC00                	mov ax, [es:2Fh * 4]
  7483 00001B99 83F8FF                  	cmp ax, -1
  7484 00001B9C 7405                    	je @F			; --> (ZR)
  7485 00001B9E 260B06BE00              	or ax, [es:2Fh * 4 + 2]
  7486                                  @@:
  7487 00001BA3 07                      	pop es
  7488 00001BA4 B0FB                    	mov al, 0FBh
  7489 00001BA6 7503E98000              	jz .return
  7490                                   %endif
  7491                                   %if _DEBUG
  7492                                  	testopt [internalflags6], dif6_in_amis_hook2F
  7493                                  	jnz @F
  7494                                  	push si
  7495                                  	call findinstalleddebugger
  7496                                  				; CHG: si, di, es, ax, cx, dx
  7497                                  	pop si
  7498                                  	jc @F
  7499                                  	setopt [internalflags6], dif6_in_hook2F
  7500                                  				; avoid recursion
  7501                                  	inc ax			; al = 31h
  7502                                  	int 2Dh			; call out to debugger
  7503                                  	clropt [internalflags6], dif6_in_hook2F
  7504                                  	cmp al, 0FFh
  7505                                  	jne @F
  7506                                    %if _DISPHOOK
  7507                                  	mov dx, dpmihookamis
  7508                                  	call putsz
  7509                                    %endif
  7510                                  @@:
  7511                                   %endif
  7512 00001BAB B88716                  	mov ax, 1687h		; DPMI host installed?
  7513 00001BAE CD2F                    	int 2Fh
  7514 00001BB0 85C0                    	test ax, ax
  7515 00001BB2 B0FA                    	mov al, 0FAh
  7516 00001BB4 7575                    	jnz .return
  7517 00001BB6 893E[0000]              	mov word [dpmientry+0], di	; true host DPMI entry
  7518 00001BBA 8C06[0200]              	mov word [dpmientry+2], es
  7519 00001BBE 893E[0000]              	mov word [dpmiwatch+0], di
  7520 00001BC2 8C06[0200]              	mov word [dpmiwatch+2], es
  7521 00001BC6 48                      	dec ax			; 0F9h
  7522                                  		; Previously checked DIF nohook2F here.
  7523 00001BC7 48                      	dec ax			; 0F8h
  7524 00001BC8 F606[AC01]02            	testopt [options4], opt4_int_2F_hook
  7525 00001BCD 745C                    	jz .return		; requested to not hook -->
  7526 00001BCF B82F35                  	mov ax, 352Fh
  7527 00001BD2 CD21                    	int 21h
  7528 00001BD4 891E[0000]              	mov word [oldi2F+0], bx
  7529 00001BD8 8C06[0200]              	mov word [oldi2F+2], es
  7530 00001BDC BA[0000]                	mov dx, debug2F		; ds => lDEBUG_DATA_ENTRY
  7531 00001BDF B82F25                  	mov ax, 252Fh
  7532 00001BE2 CD21                    	int 21h
  7533                                  
  7534                                  		; Test whether we can hook the DPMI entrypoint call.
  7535 00001BE4 B88716                  	mov ax, 1687h
  7536 00001BE7 CD2F                    	int 2Fh
  7537 00001BE9 85C0                    	test ax, ax
  7538 00001BEB 7541                    	jnz .nohost
  7539 00001BED 81FF[0000]              	cmp di, mydpmientry	; our entrypoint returned ?
  7540 00001BF1 753B                    	jne .nohook
  7541 00001BF3 8CC0                    	mov ax, es
  7542 00001BF5 8CDB                    	mov bx, ds		; bx => lDEBUG_DATA_ENTRY
  7543 00001BF7 39D8                    	cmp ax, bx
  7544 00001BF9 7533                    	jne .nohook		; no -->
  7545                                  
  7546 00001BFB C706[0000][0000]        	mov word [dpmiwatch+0], mydpmientry
  7547 00001C01 8C1E[0200]              	mov word [dpmiwatch+2], ds	; => lDEBUG_DATA_ENTRY
  7548                                  
  7549 00001C05 800E[D901]01            	setopt [internalflags], hooked2F
  7550 00001C0A 800E[E401]02            	setopt [internalflags4], dif4_int_2F_hooked
  7551 00001C0F E8(0000)                	call update_inttab_optional
  7552                                  %if _DISPHOOK
  7553 00001C12 F606[EC01]04            	testopt [internalflags6], dif6_in_amis_hook2F
  7554 00001C17 7510                    	jnz @F
  7555 00001C19 8CD8                    	mov ax, ds		; ax => lDEBUG_DATA_ENTRY
  7556 00001C1B 1E                      	push ds
  7557 00001C1C 07                      	pop es
  7558 00001C1D BF[0000]                	mov di, dpmihookcs
  7559 00001C20 E8(0000)                	call hexword
  7560 00001C23 BA[0000]                	mov dx, dpmihook
  7561 00001C26 E8(0000)                	call putsz
  7562                                  @@:
  7563                                  %endif
  7564 00001C29 B0FF                    	mov al, 0FFh
  7565                                  %endif
  7566                                  .return:
  7567 00001C2B 1E                      	push ds
  7568 00001C2C 07                      	pop es
  7569 00001C2D C3                      	retn
  7570                                  
  7571                                  %if _APPLICATION || _DEVICE
  7572                                  .nohost:
  7573                                  .nohook:
  7574 00001C2E 1E                      	push ds
  7575 00001C2F C516[0000]              	lds dx, [oldi2F]
  7576 00001C33 B82F25                  	mov ax, 252Fh
  7577 00001C36 CD21                    	int 21h			; unhook
  7578 00001C38 1F                      	pop ds
  7579 00001C39 1E                      	push ds
  7580 00001C3A 07                      	pop es			; restore segregs
  7581 00001C3B 8026[AC01]FD            	clropt [options4], opt4_int_2F_hook
  7582                                  				; disable hook next
  7583 00001C40 F606[EC01]04            	testopt [internalflags6], dif6_in_amis_hook2F
  7584 00001C45 7506                    	jnz @F
  7585 00001C47 BA[0000]                	mov dx, msg.dpmi_no_hook
  7586 00001C4A E8(0000)                	call putsz		; display message about it
  7587                                  @@:
  7588 00001C4D E840FF                  	call .loop
  7589 00001C50 B0F0                    	mov al, 0F0h
  7590 00001C52 C3                      	retn
  7591                                  %endif
  7592                                  %endif
  7593                                  
  7594                                  
  7595                                  		; Following bits need to be *before* boot.asm
  7596                                  		;  to support the _BOOTLDR_DISCARD option.
  7597                                  		;  But boot.asm must be included before init.asm
  7598                                  		;  so that init will get the nearcall/dualcall
  7599                                  		;  uses in boot.asm in its relocation tables.
  7600                                  		; So all code section contents originally from
  7601                                  		;  init.asm is now moved to here.
  7602                                  %if _SYMBOLIC && (_APPLICATION || _DEVICE)
  7603                                  		; Moved this here so the nearcall macro is used
  7604                                  		;  before we write the relocate_from_code table.
  7605                                  	usesection lDEBUG_CODE
  7606                                  ..@switch_s_cont:
  7607                                  	nearcall zz_save_strat
  7608                                  	nearcall zz_switch_s
  7609                                  	dec si
  7610                                  	mov dx, si
  7611                                  	retf
  7612                                  
  7613                                  ..@switch_s_catch:
  7614                                  	mov sp, word [throwsp]	; restore stack
  7615                                  				;  (needed here if returned to errret)
  7616                                  	mov dx, errcarat
  7617                                  	call putsz
  7618                                  	xor dx, dx
  7619                                  	retf
  7620                                  %endif
  7621                                  
  7622                                  
  7623                                  	usesection lDEBUG_CODE
  7623          ------------------       note: usesection lDEBUG_CODE
  7624                                  initcont:
  7625                                  %if _APPLICATION
  7626 00001C53 CD21                    	int 21h				; resize to required
  7627                                  ;	jc ...				; (expected to work since it had to be larger. also we hooked ints)
  7628                                  %endif
  7629                                  
  7630                                  %if _APPLICATION || _DEVICE
  7631                                  .device:
  7632                                  %if _VXCHG
  7633 00001C55 E8(0000)                	call vv_set
  7634                                  %endif
  7635                                  
  7636 00001C58 1E                      	push ds
  7637 00001C59 07                      	pop es
  7638 00001C5A E8E2FA                  	call getint2324			; init run2324 to avoid using or displaying NUL vectors
  7639                                  
  7640 00001C5D 1E                      	push ds
  7641 00001C5E 07                      	pop es
  7642 00001C5F 5E                      	pop si
  7643 00001C60 AC                      	lodsb
  7644 00001C61 E813EF                  	call kk				; process the rest of the command line
  7645                                  %endif
  7646                                  
  7647                                  .boot_entry:
  7648 00001C64 1E                      	push ds
  7649 00001C65 07                      	pop es				; => lDEBUG_DATA_ENTRY
  7650                                  
  7651                                  %if _ALTVID
  7652                                  ;	mov al, ALTSCREENBITS
  7653 00001C66 E8(0000)                	call setscreen
  7654                                  %endif
  7655                                  
  7656 00001C69 BE[0000]                	mov si, cmd3
  7657                                  %if _BOOTLDR
  7658                                   %if _APPLICATION || _DEVICE
  7659 00001C6C F606[D901]40            	testopt [internalflags], nodosloaded
  7660 00001C71 7402                    	jz @F
  7661                                   %endif
  7662                                   %if _LOADER
  7663                                  	push si
  7664                                  	jmp moveloader_hook_ints
  7665                                   %else
  7666 00001C73 FFE6                    	jmp si				; directly jump to cmd3 of the installed image
  7667                                   %endif
  7668                                  @@:
  7669                                  %endif
  7670                                  %if _APPLICATION || _DEVICE
  7671 00001C75 56                      	push si
  7672 00001C76 E9(0000)                	jmp ll3				; load a program if one has been given at the command line
  7673                                  %endif
  7674                                  
  7675                                  
  7676                                   %if !_LINK && _LINK_COMPAT
  7677                                  	usesection lDEBUG_CODE
  7678                                  %if !_LOADER
  7679                                  %include "aa.asm"
  7680                                  %endif
  7681                                  
  7682                                  	usesection lDEBUG_CODE
  7683                                  %include "amis.asm"
  7684                                  
  7685                                  	usesection lDEBUG_CODE
  7686                                  %include "bb.asm"
  7687                                  
  7688                                  %if !_LOADER
  7689                                  	usesection lDEBUG_CODE
  7690                                  %include "cc.asm"
  7691                                  %endif
  7692                                  
  7693                                  	usesection lDEBUG_CODE
  7694                                  %include "dd.asm"
  7695                                  
  7696                                  	usesection lDEBUG_CODE
  7697                                  %include "ee.asm"
  7698                                  
  7699                                  	usesection lDEBUG_CODE
  7700                                  %include "expr.asm"
  7701                                  
  7702                                  	usesection lDEBUG_CODE
  7703                                  %include "ff.asm"
  7704                                  
  7705                                  %if _RN
  7706                                   %imacro internaldatarelocation 0-*.nolist
  7707                                   %endmacro
  7708                                  	usesection lDEBUG_CODE
  7709                                   %include "fptostr.asm"
  7710                                   %unimacro internaldatarelocation 0-*.nolist
  7711                                  %endif
  7712                                  %if _HELP_COMPRESSED
  7713                                  	overridedef STANDALONE, 0
  7714                                  	usesection lDEBUG_CODE
  7715                                  %include "helpdepk.asm"
  7716                                  	resetdef STANDALONE
  7717                                  %endif
  7718                                  
  7719                                  	usesection lDEBUG_CODE
  7720                                  %include "hh.asm"
  7721                                  
  7722                                  	usesection lDEBUG_CODE
  7723                                  %include "iioo.asm"
  7724                                  
  7725                                  %if _IMMASM
  7726                                  	usesection lDEBUG_CODE
  7727                                  %include "immasm.asm"
  7728                                  %else
  7729                                  	usesection lDEBUG_CODE
  7730                                  immasm:
  7731                                  	lodsb
  7732                                  	call chkeol
  7733                                  	jmp cmd3
  7734                                  %endif
  7735                                  
  7736                                  	usesection lDEBUG_CODE
  7737                                  %include "install.asm"
  7738                                  
  7739                                  	usesection lDEBUG_CODE
  7740                                  %include "ints.asm"
  7741                                  
  7742                                  	usesection lDEBUG_CODE
  7743                                  %include "lineio.asm"
  7744                                  
  7745                                  %if !_LOADER
  7746                                  	usesection lDEBUG_CODE
  7747                                  %include "ll.asm"
  7748                                  %endif
  7749                                  
  7750                                  	usesection lDEBUG_CODE
  7751                                  %include "mm.asm"
  7752                                  
  7753                                  	usesection lDEBUG_DATA_ENTRY
  7754                                  msg_start:
  7755                                  	%include "msg.asm"
  7756                                  msg_end:
  7757                                  
  7758                                  	numdef SHOWMSGSIZE, _DEFAULTSHOWSIZE
  7759                                  %if _SHOWMSGSIZE
  7760                                  %assign MSGSIZE msg_end - msg_start
  7761                                  %warning msg holds MSGSIZE bytes
  7762                                  %endif
  7763                                  
  7764                                  %if _PM
  7765                                  	usesection lDEBUG_CODE
  7766                                  %include "pmdata.asm"
  7767                                  
  7768                                  	usesection lDEBUG_CODE
  7769                                  %include "pmentry.asm"
  7770                                  
  7771                                  	usesection lDEBUG_CODE
  7772                                  %include "pminit.asm"
  7773                                  %endif
  7774                                  
  7775                                  	usesection lDEBUG_CODE
  7776                                  %include "rr.asm"
  7777                                  
  7778                                  	usesection lDEBUG_CODE
  7779                                  %include "run.asm"
  7780                                  
  7781                                  	usesection lDEBUG_CODE
  7782                                  %include "serialp.asm"
  7783                                  
  7784                                  	usesection lDEBUG_CODE
  7785                                  %include "ss.asm"
  7786                                  
  7787                                  %if _SYMBOLIC
  7788                                  	usesection lDEBUG_CODE
  7789                                  %include "symbols.asm"
  7790                                  %endif
  7791                                  
  7792                                  	usesection lDEBUG_CODE
  7793                                  %include "uu.asm"
  7794                                  
  7795                                  	usesection lDEBUG_CODE
  7796                                  %include "vv.asm"
  7797                                  
  7798                                  %if !_LOADER
  7799                                  	usesection lDEBUG_CODE
  7800                                  %include "ww.asm"
  7801                                  %endif
  7802                                  
  7803                                   %endif
  7804                                  
  7805                                   %ifn _LINK
  7806                                  %if _BOOTLDR_DISCARD
  7807                                  	usesection lDEBUG_CODE
  7808                                  ldebug_code_bootldr_truncated_size: equ fromparas(paras($ - code_start))
  7809                                  %else
  7810                                  ldebug_code_bootldr_truncated_size: equ ldebug_code_size
  7811                                  %endif
  7812                                  	endarea ldebug_code_bootldr_truncated, 1
  7813                                  
  7814                                  %if _BOOTLDR
  7815                                   %include "boot.asm"
  7816                                  %endif
  7817                                   %endif
  7818                                  
  7819                                  
  7820                                  %if _LINK
  7821                                  [list -]
  7894                                  	usesection DATASTACKBASE
  7894          ------------------       note: usesection DATASTACKBASE
  7895                                  	absolute $
  7896                                   %endif
  7897                                  
  7898                                  %if !_LOADER
  7899                                  	alignb 4
  7900 00000000 ????                    bp_offset:	resw 1
  7901                                  %if _PM
  7902 00000002 ????                    		resw 1
  7903                                  %endif
  7904                                  %endif
  7905                                  
  7906                                  %if _BREAKPOINTS
  7907                                  	alignb 4
  7908 00000004 ????????                ..@bb_saved_linear:	resd 1
  7909                                  
  7910                                  	alignb 4
  7911 00000008 ????                    ..@bb_id_start:		resw 1
  7912 0000000A ????                    ..@bb_id_length:	resw 1
  7913 0000000C ????                    ..@bb_when_start:	resw 1
  7914 0000000E ????                    ..@bb_when_length:	resw 1
  7915                                  %endif
  7916                                  
  7917                                  		; I/O buffers
  7918                                  	alignb 2
  7919 00000010 ??                      line_in:	resb 1			; maximal length of input line
  7920 00000011 ??                      		resb 1			; actual length (must be one less than previous byte)
  7921 00000012 <res FFh>               		resb 255		; buffer for 13-terminated input line
  7922                                  .end:
  7923                                  
  7924                                  %if _CONFIG
  7925 00000111 ??                      	alignb 2
  7926 00000112 <res 180h>              configpath:	resb 128 + 256
  7927 00000292 ????                    .dir_end:	resw 1
  7928                                  
  7929                                  	alignb 2
  7930 00000294 <res 180h>              scriptspath:	resb 128 + 256
  7931 00000414 ????                    .dir_end:	resw 1
  7932                                  
  7933                                  yy_try_scriptspath:
  7934 00000416 ??                      .nokeywordused:	resb 1
  7935 00000417 ??                      .didnotyettry:	resb 1
  7936                                  %endif
  7937                                   %if _EXTENSIONS
  7938                                  	alignb 2
  7939 00000418 ????                    ext_cmdline:	resw 1
  7940                                    %if _ELDTRAILER
  7941 0000041A ????????                eldheader:	resd 1
  7942                                    %endif
  7943                                   %endif
  7944                                   %if _EXTENSIONS || _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  7945 0000041E ??                      yy_is_script:	resb 1			; else extension
  7946                                   %endif
  7947                                  
  7948                                  	; zero-initialisation starts here
  7949                                  ..@init_first:
  7950 0000041F ??                      		resb 1			; line_in overflow stop
  7951                                  			; This byte is zero-initialised. When line_in
  7952                                  			;  is scanned using skipcomma (in bb.asm) but
  7953                                  			;  al already had the CR, then the scan may
  7954                                  			;  overflow line_in. Including this byte here
  7955                                  			;  (_after_ line_in) insures that the scan will
  7956                                  			;  stop while still reading within the section.
  7957                                  				; b_bplist and g_bplist are expected in that order by initcont
  7958                                  %if _BREAKPOINTS
  7959                                  	alignb 2
  7960                                  b_bplist:
  7961 00000420 ????                    .used_mask:	resb (_NUM_B_BP + _NUM_SYM_BP + 7) >> 3
  7962                                  					; bitmask of used points
  7963 00000422 ????                    .disabled_mask:	resb (_NUM_B_BP + _NUM_SYM_BP + 7) >> 3
  7964                                  					; bitmask of disabled points
  7965                                   %if _BREAKPOINTS_STICKY
  7966                                  .sticky_mask:	resb (_NUM_B_BP + _NUM_SYM_BP + 7) >> 3
  7967                                  					; bitmask of sticky points
  7968                                  					; desc: stay around during DEBUG's operation unless
  7969                                  					; explicitly removed/un-stickified. This allows
  7970                                  					; to keep breakpoints around while changing from PM.
  7971                                  					; Hits while in DEBUG are ignored though, use DDEBUG.
  7972                                  					; Disabling won't remove them, just ignores hits.
  7973                                   %endif
  7974                                  	alignb 2
  7975 00000424 <res 90h>               .bp:		resb (_NUM_B_BP + _NUM_SYM_BP) * BPSIZE
  7976                                  	alignb 2
  7977 000004B4 <res 20h>               .counter:	resw _NUM_B_BP
  7978                                  	alignb 2
  7979 000004D4 <res 20h>               .id:		resw _NUM_B_BP		; array of lengths/offsets, 0 = unused
  7980                                  			; low 10 bits = offset into .idbuffer (0..1023)
  7981                                  			; high 6 bits = length (0..63, 0 if unused)
  7982                                  	alignb 2
  7983 000004F4 <res 20h>               .when:		resw _NUM_B_BP		; array of pointers, 0 = unused
  7984                                  .idbuffer.free:
  7985 00000514 ????                    		resw 1			; offset into .idbuffer of free space
  7986                                  					; (0..1024)
  7987                                  .whenbuffer.free:
  7988 00000516 ????                    		resw 1			; *offset* into .whenbuffer
  7989                                  					;  (not a pointer)
  7990                                  .idbuffer:
  7991 00000518 <res 180h>              		resb _NUM_B_ID_BYTES	; buffer holding ID strings
  7992                                  .whenbuffer:
  7993 00000698 <res 400h>              		resb _NUM_B_WHEN_BYTES	; buffer holding condition strings
  7994                                  %endif
  7995                                  %if _NUM_G_BP
  7996 00000A98 ??                      	resb 1 - (($-$$) % 2)		; make g_bplist.bp aligned
  7997                                  g_bplist:
  7998 00000A99 ??                      .used_count:	resb 1			; for the byte counter of saved breakpoints
  7999 00000A9A <res 90h>               .bp:		resb _NUM_G_BP*BPSIZE
  8000                                  .end:
  8001                                  %endif
  8002                                  %if !_LOADER
  8003 00000B2A ??                      sss_silent_count_used:	resb 1
  8004 00000B2B ??                      drivenumber:		resb 1
  8005                                  %if _MCBPOSITION
  8006                                  mcbposition:		resb 1
  8007                                  %endif
  8008                                  %if _SDSUB
  8009                                  skipsd:			resb 1
  8010                                  %endif
  8011                                  %if _MCBLIMIT
  8012                                  	alignb 2
  8013                                  mcblimit:		resw 1
  8014                                  %endif
  8015                                  %endif
  8016                                  %if _HISTORY && ! _HISTORY_SEPARATE_FIXED
  8017                                  	alignb 2
  8018                                  historybuffer:	resb _HISTORY_SIZE
  8019                                  .end:
  8020                                  %endif
  8021                                  
  8022                                  		; $ - $$	= offset into section
  8023                                  		; % 2		= 1 if odd offset, 0 if even
  8024                                  		; 2 -		= 1 if odd, 2 if even
  8025                                  		; % 2		= 1 if odd, 0 if even
  8026                                  	; resb (2 - (($-$$) % 2)) % 2
  8027                                  		; $ - $$	= offset into section
  8028                                  		; % 2		= 1 if odd offset, 0 if even
  8029                                  		; 1 -		= 0 if odd, 1 if even
  8030 00000B2C ??                      	resb 1 - (($-$$) % 2)		; make line_out aligned
  8031 00000B2D ??                      trim_overflow:	resb 1			; actually part of line_out to avoid overflow of trimputs loop
  8032 00000B2E <res 107h>              line_out:	resb 263
  8033 00000C35 ??                      		resb 1			; reserved for terminating zero
  8034                                  line_out_end:
  8035                                  	alignb 2
  8036 00000C36 ????                    line_out_overflow:	resw 1		; 2642h if line_out didn't overflow
  8037                                  
  8038                                  %if !_LOADER
  8039                                  	alignb 4
  8040 00000C38 ????????                sss_silent_count:	resd 1
  8041                                  %endif
  8042                                  	alignb 2
  8043 00000C3C ????                    getrange_lines:		resw 1
  8044                                  
  8045 00000C3E ????                    serial_save_irq_mask:	resw 1
  8046 00000C40 ????                    serial_save_irq_off:	resw 1
  8047 00000C42 ????                    serial_save_dl:		resw 1
  8048 00000C44 ??                      serial_save_ier:	resb 1
  8049 00000C45 ??                      serial_save_lcr:	resb 1
  8050 00000C46 ??                      serial_save_mcr:	resb 1
  8051                                  %if _USE_TX_FIFO
  8052 00000C47 ??                       serial_fcr_setting:	resb 1
  8053                                  %endif
  8054 00000C48 ??                      serial_use_intnum:	resb 1
  8055 00000C49 ??                      serial_use_params:	resb 1
  8056 00000C4A ??                      serial_use_fifo:	resb 1
  8057                                  %if _RH
  8058 00000C4B ??                      rh_display_with_count:	resb 1
  8059                                  	alignb 2
  8060 00000C4C ????                    rh_count_number:	resw 1
  8061                                  %endif
  8062                                  	alignb 2
  8063                                  baseport:
  8064 00000C4E ????                    serial_use_baseport:	resw 1
  8065 00000C50 ????                    serial_use_dl:		resw 1
  8066 00000C52 ????                    serial_use_irqmask:	resw 1
  8067                                  
  8068                                  	alignb 2
  8069 00000C54 ????                    rxhead:		resw 1
  8070 00000C56 ????                    rxtail:		resw 1
  8071 00000C58 ????                    txhead:		resw 1
  8072 00000C5A ????                    txtail:		resw 1
  8073 00000C5C ????????                	alignb 16
  8074 00000C60 <res 80h>               rxfifo:		resb _RXFIFOSIZE
  8075                                  	alignb 16
  8076 00000CE0 <res 80h>               txfifo:		resb _TXFIFOSIZE
  8077                                  
  8078                                   %if _SYMBOLIC
  8079                                  %if _BUFFER_86MM_SLICE || _XMS_SYMBOL_TABLE
  8080                                  	alignb 16
  8081                                  access_slice_buffer:
  8082                                  .:
  8083                                  	resb ssString + 255
  8084                                  	alignb 2
  8085                                  .size:	equ $ - .
  8086                                   %if _SECOND_SLICE
  8087                                  	alignb 16
  8088                                  second_access_slice_buffer:
  8089                                  .:
  8090                                  	resb ssString + 255
  8091                                  	alignb 2
  8092                                  .size:	equ $ - .
  8093                                   %endif
  8094                                  %endif
  8095                                   %endif
  8096                                  
  8097                                  	alignb 2
  8098                                  while_buffer:
  8099                                  .length equ _WHILEBUFFSIZE
  8100 00000D60 <res 108h>              	resb .length
  8101                                  .end:
  8102                                  
  8103                                  %if (_MMXSUPP && _RM && ! _RM_AUX) || (_RN && ! _RN_AUX)
  8104                                  	alignb 4
  8105                                  rn_rm_buffer:
  8106                                   %if (_RN && ! _RN_AUX)
  8107                                  		resb 128
  8108                                   %else
  8109                                  		resb 108
  8110                                   %endif
  8111                                  %endif
  8112                                  
  8113                                  %if _SYMBOLIC
  8114                                  	alignb 16
  8115                                  str_buffer:	resb 512		; long enough for smName1 + smName2 content
  8116                                  		; by placing this buffer below the stack, a stack overflow
  8117                                  		;  might be less harmful if the str_buffer isn't in use.
  8118                                  %endif
  8119                                  
  8120                                  	; zero-initialisation ends here
  8121                                  ..@init_behind:
  8122                                  
  8123 00000E68 ????????????????        		alignb 16		; stack might be re-used as GDT, so align it on a paragraph
  8124 00000E70 <res 200h>              stack:		resb _STACKSIZE
  8125                                  		alignb 2		; ensure stack aligned
  8126                                  stack_end:
  8127                                  
  8128                                  %if _EXTENSIONS
  8129                                  	alignb 16
  8130                                  ext_data_area:
  8131 00001070 <res 4000h>             .:	resb _EXT_DATA_BOOT_SIZE
  8132                                  	alignb 16
  8133                                  .size equ $ - .
  8134                                  
  8135                                    %ifn _LINK
  8136                                  ext_data_max_size_equate equ 0FFF0h - (ext_data_area + SECTIONFIXUP)
  8137                                   %if ((_EXT_DATA_BOOT_SIZE + 15) & ~15) <= ((_EXT_DATA_INIT_SIZE + 15) & ~15)
  8138                                    ext_data_nonboot_add_size equ ((_EXT_DATA_INIT_SIZE + 15) & ~15) - ((_EXT_DATA_BOOT_SIZE + 15) & ~15)
  8139                                   %else
  8140                                    ext_data_nonboot_add_size equ 0
  8141                                   %endif
  8142                                    %endif
  8143                                  %else
  8144                                    %ifn _LINK
  8145                                   ext_data_max_size_equate equ 0
  8146                                   ext_data_nonboot_add_size equ 0
  8147                                    %endif
  8148                                  %endif
  8149                                  
  8150                                  %if _LINK
  8151                                   global end_of_datastack
  8152                                  %endif
  8153                                  	alignb 16
  8154                                  end_of_datastack:
  8155                                  
  8156                                    %ifn _LINK
  8157                                  datastack_size	equ $-section.DATASTACK.vstart
  8158                                  	endarea datastack, 1
  8159                                  
  8160                                  
  8161                                  auxbuff_size: equ (_AUXBUFFSIZE+15) & ~15
  8162                                  	endarea auxbuff, 1
  8163                                  
  8164                                  auxbuff_max_size: equ (_AUXBUFFMAXSIZE+15) & ~15
  8165                                  	endarea auxbuff_max, 1
  8166                                  
  8167                                  %if _INIT_MAX
  8168                                   auxbuff_init_size: equ (_AUXBUFFMAXSIZE+15) & ~15
  8169                                  %else
  8170                                   auxbuff_init_size: equ (_AUXBUFFSIZE+15) & ~15
  8171                                  %endif
  8172                                  	endarea auxbuff_init, 1
  8173                                  
  8174                                  
  8175                                  pspsegment_size:	equ 100h + DATAENTRYTABLESIZE + datastack_size
  8176                                  	endarea pspsegment, 1			; size of PSP and image when installed
  8177                                  
  8178                                  
  8179                                  	numdef SHOWASMTABLESIZE, _DEFAULTSHOWSIZE
  8180                                  %if _SHOWASMTABLESIZE
  8181                                  %assign ASMTABLESIZE asmtable1_size + asmtable2_size
  8182                                  %warning asmtables hold ASMTABLESIZE bytes
  8183                                  %endif
  8184                                  
  8185                                  
  8186                                  %assign __INITSIZE init_size
  8187                                  %if __INITSIZE > (64 * 1024)
  8188                                   %error init segment too large (%[__INITSIZE])
  8189                                  %endif
  8190                                  
  8191                                  	numdef SHOWINITSIZE, _DEFAULTSHOWSIZE
  8192                                  %if _SHOWINITSIZE
  8193                                  %warning init segment holds __INITSIZE bytes
  8194                                  %endif
  8195                                  
  8196                                  
  8197                                  %assign __CODESIZE ldebug_code_size
  8198                                  %if __CODESIZE > (64 * 1024)
  8199                                   %error code segment too large (%[__CODESIZE])
  8200                                  %endif
  8201                                  
  8202                                  	numdef SHOWCODESIZE, _DEFAULTSHOWSIZE
  8203                                  %if _SHOWCODESIZE
  8204                                  %warning code segment holds __CODESIZE bytes
  8205                                  %endif
  8206                                  
  8207                                  
  8208                                  %assign __CODETRUNCATEDSIZE ldebug_code_bootldr_truncated_size
  8209                                  %assign __CODEDISCARDSIZE ldebug_code_size - ldebug_code_bootldr_truncated_size
  8210                                  
  8211                                  %if _BOOTLDR_DISCARD
  8212                                  	numdef SHOWCODETRUNCATEDSIZE, _DEFAULTSHOWSIZE
  8213                                  %else
  8214                                  	numdef SHOWCODETRUNCATEDSIZE, 0
  8215                                  %endif
  8216                                  %if _SHOWCODETRUNCATEDSIZE
  8217                                  %warning code segment truncated holds __CODETRUNCATEDSIZE bytes (__CODEDISCARDSIZE bytes discarded)
  8218                                  %endif
  8219                                  
  8220                                  
  8221                                  %assign __CODE2SIZE ldebug_code2_size
  8222                                  %if __CODE2SIZE > (64 * 1024)
  8223                                   %error code segment 2 too large (%[__CODE2SIZE])
  8224                                  %endif
  8225                                  
  8226                                  %if _DUALCODE
  8227                                  	numdef SHOWCODE2SIZE, _DEFAULTSHOWSIZE
  8228                                  %else
  8229                                  	numdef SHOWCODE2SIZE, 0
  8230                                  %endif
  8231                                  %if _SHOWCODE2SIZE
  8232                                  %warning code segment 2 holds __CODE2SIZE bytes
  8233                                  %endif
  8234                                  
  8235                                  
  8236                                  %assign __MESSAGESEGMENTSIZE messagesegment_nobits_size
  8237                                  %if __MESSAGESEGMENTSIZE > (64 * 1024)
  8238                                   %error message segment too large (%[__MESSAGESEGMENTSIZE])
  8239                                  %endif
  8240                                  
  8241                                  %if _MESSAGESEGMENT
  8242                                  	numdef SHOWMESSAGESEGMENTSIZE, _DEFAULTSHOWSIZE
  8243                                  %else
  8244                                  	numdef SHOWMESSAGESEGMENTSIZE, 0
  8245                                  %endif
  8246                                  %if _SHOWMESSAGESEGMENTSIZE
  8247                                  %warning message segment holds __MESSAGESEGMENTSIZE bytes
  8248                                  %endif
  8249                                  
  8250                                  
  8251                                  %assign __MESSAGESEGMENTTRUNCATEDSIZE messagesegment_nobits_truncated_size
  8252                                  %assign __MESSAGESEGMENTDISCARDSIZE messagesegment_nobits_size - messagesegment_nobits_truncated_size
  8253                                  
  8254                                  %if _BOOTLDR_DISCARD_HELP
  8255                                  	numdef SHOWMESSAGESEGMENTTRUNCATEDSIZE, _DEFAULTSHOWSIZE
  8256                                  %else
  8257                                  	numdef SHOWMESSAGESEGMENTTRUNCATEDSIZE, 0
  8258                                  %endif
  8259                                  %if _SHOWMESSAGESEGMENTTRUNCATEDSIZE
  8260                                  %warning message segment truncated holds __MESSAGESEGMENTTRUNCATEDSIZE bytes (__MESSAGESEGMENTDISCARDSIZE bytes discarded)
  8261                                  %endif
  8262                                  
  8263                                  
  8264                                  %assign __PSPSEGMENTSIZE pspsegment_size
  8265                                  %assign __PSPSEGMENTMAXSIZE pspsegment_size - _EXT_DATA_BOOT_SIZE + ext_data_max_size_equate
  8266                                  %if __PSPSEGMENTSIZE > (64 * 1024)
  8267                                   %error resident size of PSP segment too large (%[__PSPSEGMENTSIZE])
  8268                                  %elif __PSPSEGMENTMAXSIZE > (64 * 1024 - 16)
  8269                                   %error resident maximum size of PSP segment too large (%[__PSPSEGMENTMAXSIZE])
  8270                                  %endif
  8271                                  
  8272                                  	numdef SHOWPSPSIZE, _DEFAULTSHOWSIZE
  8273                                  %if _SHOWPSPSIZE
  8274                                  %warning PSP segment holds __PSPSEGMENTSIZE bytes
  8275                                   %if _EXTENSIONS
  8276                                    %warning Maximum PSP segment holds __PSPSEGMENTMAXSIZE bytes
  8277                                   %endif
  8278                                  %endif
  8279                                  
  8280                                  %if CODE_INSURE_COUNT
  8281                                   %warning code_insure_low_byte_not_0CCh needed CODE_INSURE_COUNT times
  8282                                  %endif
  8283                                    %endif
